jdk

Форк
0
/
Flags.gmk 
225 строк · 9.5 Кб
1
#
2
# Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
#
5
# This code is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License version 2 only, as
7
# published by the Free Software Foundation.  Oracle designates this
8
# particular file as subject to the "Classpath" exception as provided
9
# by Oracle in the LICENSE file that accompanied this code.
10
#
11
# This code is distributed in the hope that it will be useful, but WITHOUT
12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14
# version 2 for more details (a copy is included in the LICENSE file that
15
# accompanied this code).
16
#
17
# You should have received a copy of the GNU General Public License version
18
# 2 along with this work; if not, write to the Free Software Foundation,
19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
#
21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
# or visit www.oracle.com if you need additional information or have any
23
# questions.
24
#
25

26
################################################################################
27
# This file contains functionality related to setting up compiler and linker
28
# flags, based on various more abstract sources of compilation description,
29
# like optimization level.
30

31
################################################################################
32
# $1 is the prefix of the file to be compiled
33
# $2 is the prefix of the library, i.e. $$($1_BASE)
34
define SetupCompileFileFlags
35
  ifeq ($$($1_OPTIMIZATION), )
36
    $1_OPT_CFLAGS := $$($2_OPT_CFLAGS)
37
    $1_OPT_CXXFLAGS := $$($2_OPT_CXXFLAGS)
38
  else
39
    ifeq ($$($1_OPTIMIZATION), NONE)
40
      $1_OPT_CFLAGS := $(C_O_FLAG_NONE)
41
      $1_OPT_CXXFLAGS := $(CXX_O_FLAG_NONE)
42
    else ifeq ($$($1_OPTIMIZATION), LOW)
43
      $1_OPT_CFLAGS := $(C_O_FLAG_NORM)
44
      $1_OPT_CXXFLAGS := $(CXX_O_FLAG_NORM)
45
    else ifeq ($$($1_OPTIMIZATION), HIGH)
46
      $1_OPT_CFLAGS := $(C_O_FLAG_HI)
47
      $1_OPT_CXXFLAGS := $(CXX_O_FLAG_HI)
48
    else ifeq ($$($1_OPTIMIZATION), HIGHEST)
49
      $1_OPT_CFLAGS := $(C_O_FLAG_HIGHEST)
50
      $1_OPT_CXXFLAGS := $(CXX_O_FLAG_HIGHEST)
51
    else ifeq ($$($1_OPTIMIZATION), HIGHEST_JVM)
52
      $1_OPT_CFLAGS := $(C_O_FLAG_HIGHEST_JVM)
53
      $1_OPT_CXXFLAGS := $(CXX_O_FLAG_HIGHEST_JVM)
54
    else ifeq ($$($1_OPTIMIZATION), SIZE)
55
      $1_OPT_CFLAGS := $(C_O_FLAG_SIZE)
56
      $1_OPT_CXXFLAGS := $(CXX_O_FLAG_SIZE)
57
    else
58
      $$(error Unknown value for file OPTIMIZATION: $$($1_OPTIMIZATION))
59
    endif
60
  endif
61

62
  ifneq ($$($2_PRECOMPILED_HEADER), )
63
    ifeq ($$(filter $$($1_FILENAME), $$($2_PRECOMPILED_HEADER_EXCLUDE)), )
64
      $1_USE_PCH_FLAGS := $$($2_USE_PCH_FLAGS)
65
    endif
66
  endif
67

68
  ifneq ($(DISABLE_WARNING_PREFIX), )
69
    $1_WARNINGS_FLAGS := $$(addprefix $(DISABLE_WARNING_PREFIX), \
70
      $$($2_DISABLED_WARNINGS_$(TOOLCHAIN_TYPE)_$$($1_FILENAME)) \
71
      $$($2_DISABLED_WARNINGS_$(TOOLCHAIN_TYPE)_$(OPENJDK_TARGET_OS)_$$($1_FILENAME)))
72
  endif
73

74
  $1_BASE_CFLAGS :=  $$($2_CFLAGS) $$($2_EXTRA_CFLAGS) \
75
      $$($2_SYSROOT_CFLAGS)
76
  $1_BASE_CXXFLAGS := $$($2_CXXFLAGS) $$($2_EXTRA_CXXFLAGS) \
77
      $$($2_SYSROOT_CFLAGS) $$($1_EXTRA_CXXFLAGS)
78
  $1_BASE_ASFLAGS := $$($2_ASFLAGS) $$($2_EXTRA_ASFLAGS)
79
endef
80

81
################################################################################
82
define SetupCompilerFlags
83
  # Pickup extra OPENJDK_TARGET_OS_TYPE, OPENJDK_TARGET_OS, TOOLCHAIN_TYPE and
84
  # OPENJDK_TARGET_OS plus OPENJDK_TARGET_CPU pair dependent variables for CFLAGS.
85
  $1_EXTRA_CFLAGS := $$($1_CFLAGS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_CFLAGS_$(OPENJDK_TARGET_OS)) \
86
      $$($1_CFLAGS_$(TOOLCHAIN_TYPE)) \
87
      $$($1_CFLAGS_$(OPENJDK_TARGET_OS)_$(OPENJDK_TARGET_CPU))
88

89
  ifneq ($(DEBUG_LEVEL), release)
90
    # Pickup extra debug dependent variables for CFLAGS
91
    $1_EXTRA_CFLAGS += $$($1_CFLAGS_debug)
92
    $1_EXTRA_CFLAGS += $$($1_CFLAGS_$(OPENJDK_TARGET_OS_TYPE)_debug)
93
    $1_EXTRA_CFLAGS += $$($1_CFLAGS_$(OPENJDK_TARGET_OS)_debug)
94
    $1_EXTRA_CFLAGS += $$($1_CFLAGS_$(OPENJDK_TARGET_OS)_$(OPENJDK_TARGET_CPU)_debug)
95
  else
96
    $1_EXTRA_CFLAGS += $$($1_CFLAGS_release)
97
    $1_EXTRA_CFLAGS += $$($1_CFLAGS_$(OPENJDK_TARGET_OS_TYPE)_release)
98
    $1_EXTRA_CFLAGS += $$($1_CFLAGS_$(OPENJDK_TARGET_OS)_release)
99
    $1_EXTRA_CFLAGS += $$($1_CFLAGS_$(OPENJDK_TARGET_OS)_$(OPENJDK_TARGET_CPU)_release)
100
  endif
101
  ifeq ($(STATIC_LIBS), true)
102
    $1_EXTRA_CFLAGS += $$(STATIC_LIBS_CFLAGS)
103
  endif
104

105
  # Pickup extra OPENJDK_TARGET_OS_TYPE, OPENJDK_TARGET_OS and/or TOOLCHAIN_TYPE
106
  # dependent variables for CXXFLAGS.
107
  $1_EXTRA_CXXFLAGS := $$($1_CXXFLAGS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_CXXFLAGS_$(OPENJDK_TARGET_OS)) \
108
      $$($1_CXXFLAGS_$(TOOLCHAIN_TYPE))
109

110
  ifneq ($(DEBUG_LEVEL), release)
111
    # Pickup extra debug dependent variables for CXXFLAGS
112
    $1_EXTRA_CXXFLAGS += $$($1_CXXFLAGS_debug)
113
    $1_EXTRA_CXXFLAGS += $$($1_CXXFLAGS_$(OPENJDK_TARGET_OS_TYPE)_debug)
114
    $1_EXTRA_CXXFLAGS += $$($1_CXXFLAGS_$(OPENJDK_TARGET_OS)_debug)
115
  else
116
    $1_EXTRA_CXXFLAGS += $$($1_CXXFLAGS_release)
117
    $1_EXTRA_CXXFLAGS += $$($1_CXXFLAGS_$(OPENJDK_TARGET_OS_TYPE)_release)
118
    $1_EXTRA_CXXFLAGS += $$($1_CXXFLAGS_$(OPENJDK_TARGET_OS)_release)
119
  endif
120
  ifeq ($(STATIC_LIBS), true)
121
    $1_EXTRA_CXXFLAGS += $$(STATIC_LIB_CFLAGS)
122
  endif
123

124
  # If no C++ flags are explicitly set, default to using the C flags.
125
  # After that, we can set additional C++ flags that should not interfere
126
  # with the mechanism for copying the C flags by default.
127
  ifeq ($$($1_CXXFLAGS), )
128
    $1_CXXFLAGS := $$($1_CFLAGS)
129
  endif
130
  ifeq ($$(strip $$($1_EXTRA_CXXFLAGS)), )
131
    $1_EXTRA_CXXFLAGS := $$($1_EXTRA_CFLAGS)
132
  endif
133

134
  $$(call SetIfEmpty, $1_COMPILE_WITH_DEBUG_SYMBOLS, $$(COMPILE_WITH_DEBUG_SYMBOLS))
135

136
  ifeq ($(STATIC_LIBS), true)
137
    # For release builds where debug symbols are configured to be moved to
138
    # separate debuginfo files, disable debug symbols for static libs instead.
139
    # We don't currently support this configuration and we don't want symbol
140
    # information in release builds unless explicitly asked to provide it.
141
    ifeq ($(DEBUG_LEVEL), release)
142
      ifeq ($(COPY_DEBUG_SYMBOLS), true)
143
        $1_COMPILE_WITH_DEBUG_SYMBOLS := false
144
      endif
145
    endif
146
  endif
147

148
  ifeq ($$($1_COMPILE_WITH_DEBUG_SYMBOLS), true)
149
    $1_EXTRA_CFLAGS += $$(CFLAGS_DEBUG_SYMBOLS)
150
    $1_EXTRA_CXXFLAGS += $$(CFLAGS_DEBUG_SYMBOLS)
151
    $1_EXTRA_ASFLAGS += $$(ASFLAGS_DEBUG_SYMBOLS)
152
  endif
153

154
  # Pass the library name for static JNI library naming
155
  ifeq ($$($1_TYPE), STATIC_LIBRARY)
156
    $1_EXTRA_CFLAGS += -DLIBRARY_NAME=$$($1_NAME)
157
    $1_EXTRA_CXXFLAGS += -DLIBRARY_NAME=$$($1_NAME)
158
  endif
159

160
  # Pick up disabled warnings, if possible on this platform.
161
  ifneq ($(DISABLE_WARNING_PREFIX), )
162
    $1_EXTRA_CFLAGS += $$(addprefix $(DISABLE_WARNING_PREFIX), \
163
        $$(DISABLED_WARNINGS) \
164
        $$(DISABLED_WARNINGS_C) \
165
        $$($1_DISABLED_WARNINGS_$(TOOLCHAIN_TYPE)) \
166
        $$($1_DISABLED_WARNINGS_C_$(TOOLCHAIN_TYPE)) \
167
        $$($1_DISABLED_WARNINGS_$(TOOLCHAIN_TYPE)_$(OPENJDK_TARGET_OS)) \
168
        $$($1_DISABLED_WARNINGS_C_$(TOOLCHAIN_TYPE)_$(OPENJDK_TARGET_OS)))
169
    $1_EXTRA_CXXFLAGS += $$(addprefix $(DISABLE_WARNING_PREFIX), \
170
        $$(DISABLED_WARNINGS) \
171
        $$(DISABLED_WARNINGS_CXX) \
172
        $$($1_DISABLED_WARNINGS_$(TOOLCHAIN_TYPE)) \
173
        $$($1_DISABLED_WARNINGS_CXX_$(TOOLCHAIN_TYPE)) \
174
        $$($1_DISABLED_WARNINGS_$(TOOLCHAIN_TYPE)_$(OPENJDK_TARGET_OS)) \
175
        $$($1_DISABLED_WARNINGS_CXX_$(TOOLCHAIN_TYPE)_$(OPENJDK_TARGET_OS)))
176
  endif
177

178
  # Check if warnings should be considered errors.
179
  # Pick first binary and toolchain specific, then binary specific, then general setting.
180
  ifeq ($$($1_WARNINGS_AS_ERRORS_$(TOOLCHAIN_TYPE)), )
181
    ifeq ($$($1_WARNINGS_AS_ERRORS), )
182
      $1_WARNINGS_AS_ERRORS_$(TOOLCHAIN_TYPE) := $$(WARNINGS_AS_ERRORS)
183
    else
184
      $1_WARNINGS_AS_ERRORS_$(TOOLCHAIN_TYPE) := $$($1_WARNINGS_AS_ERRORS)
185
    endif
186
  endif
187

188
  ifeq ($$($1_WARNINGS_AS_ERRORS_$(TOOLCHAIN_TYPE)), true)
189
    $1_EXTRA_CFLAGS += $(CFLAGS_WARNINGS_ARE_ERRORS)
190
    $1_EXTRA_CXXFLAGS += $(CFLAGS_WARNINGS_ARE_ERRORS)
191
  endif
192

193
  ifeq (NONE, $$($1_OPTIMIZATION))
194
    $1_OPT_CFLAGS := $(C_O_FLAG_NONE)
195
    $1_OPT_CXXFLAGS := $(CXX_O_FLAG_NONE)
196
  else ifeq (LOW, $$($1_OPTIMIZATION))
197
    $1_OPT_CFLAGS := $(C_O_FLAG_NORM)
198
    $1_OPT_CXXFLAGS := $(CXX_O_FLAG_NORM)
199
  else ifeq (HIGH, $$($1_OPTIMIZATION))
200
    $1_OPT_CFLAGS := $(C_O_FLAG_HI)
201
    $1_OPT_CXXFLAGS := $(CXX_O_FLAG_HI)
202
  else ifeq (HIGHEST, $$($1_OPTIMIZATION))
203
    $1_OPT_CFLAGS := $(C_O_FLAG_HIGHEST)
204
    $1_OPT_CXXFLAGS := $(CXX_O_FLAG_HIGHEST)
205
  else ifeq (HIGHEST_JVM, $$($1_OPTIMIZATION))
206
    $1_OPT_CFLAGS := $(C_O_FLAG_HIGHEST_JVM)
207
    $1_OPT_CXXFLAGS := $(CXX_O_FLAG_HIGHEST_JVM)
208
  else ifeq (SIZE, $$($1_OPTIMIZATION))
209
    $1_OPT_CFLAGS := $(C_O_FLAG_SIZE)
210
    $1_OPT_CXXFLAGS := $(CXX_O_FLAG_SIZE)
211
  else ifneq (, $$($1_OPTIMIZATION))
212
    $$(error Unknown value for OPTIMIZATION: $$($1_OPTIMIZATION))
213
  endif
214
endef
215

216
################################################################################
217
define SetupLinkerFlags
218
  # Pickup extra OPENJDK_TARGET_OS_TYPE, OPENJDK_TARGET_OS and TOOLCHAIN_TYPE
219
  # dependent variables for LDFLAGS and LIBS, and additionally the pair dependent
220
  # TOOLCHAIN_TYPE plus OPENJDK_TARGET_OS
221
  $1_EXTRA_LDFLAGS += $$($1_LDFLAGS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_LDFLAGS_$(OPENJDK_TARGET_OS)) \
222
      $$($1_LDFLAGS_$(TOOLCHAIN_TYPE)) $$($1_LDFLAGS_$(TOOLCHAIN_TYPE)_$(OPENJDK_TARGET_OS))
223
  $1_EXTRA_LIBS += $$($1_LIBS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_LIBS_$(OPENJDK_TARGET_OS)) \
224
      $$($1_LIBS_$(TOOLCHAIN_TYPE)) $$($1_LIBS_$(TOOLCHAIN_TYPE)_$(OPENJDK_TARGET_OS))
225
endef
226

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.