69 endif |
69 endif |
70 CXX = $(CXX32) |
70 CXX = $(CXX32) |
71 CC = $(CC32) |
71 CC = $(CC32) |
72 endif |
72 endif |
73 |
73 |
|
74 ifeq ($(USE_CLANG), true) |
|
75 CXX = clang++ |
|
76 CC = clang |
|
77 endif |
|
78 |
74 HOSTCXX = $(CXX) |
79 HOSTCXX = $(CXX) |
75 HOSTCC = $(CC) |
80 HOSTCC = $(CC) |
76 endif |
81 endif |
77 |
82 |
78 AS = $(CC) -c -x assembler-with-cpp |
83 AS = $(CC) -c -x assembler-with-cpp |
79 endif |
84 endif |
80 |
85 |
81 |
86 |
82 # -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only |
87 ifeq ($(USE_CLANG), true) |
83 # prints the numbers (e.g. "2.95", "3.2.1") |
88 CC_VER_MAJOR := $(shell $(CC) -v 2>&1 | grep version | sed "s/.*version \([0-9]*\.[0-9]*\).*/\1/" | cut -d'.' -f1) |
84 CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1) |
89 CC_VER_MINOR := $(shell $(CC) -v 2>&1 | grep version | sed "s/.*version \([0-9]*\.[0-9]*\).*/\1/" | cut -d'.' -f2) |
85 CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2) |
90 else |
86 |
91 # -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only |
87 # check for precompiled headers support |
92 # prints the numbers (e.g. "2.95", "3.2.1") |
88 ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0" |
93 CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1) |
89 # Allow the user to turn off precompiled headers from the command line. |
94 CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2) |
90 ifneq ($(USE_PRECOMPILED_HEADER),0) |
95 endif |
91 PRECOMPILED_HEADER_DIR=. |
96 |
92 PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp |
97 ifeq ($(USE_CLANG), true) |
93 PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch |
98 # clang has precompiled headers support by default, but the user can switch |
94 endif |
99 # it off by using 'USE_PRECOMPILED_HEADER=0'. |
95 endif |
100 ifdef LP64 |
96 |
101 ifeq ($(USE_PRECOMPILED_HEADER),) |
|
102 USE_PRECOMPILED_HEADER=1 |
|
103 endif |
|
104 else |
|
105 # We don't support precompiled headers on 32-bit builds because there some files are |
|
106 # compiled with -fPIC while others are compiled without (see 'NONPIC_OBJ_FILES' rules.make) |
|
107 # Clang produces an error if the PCH file was compiled with other options than the actual compilation unit. |
|
108 USE_PRECOMPILED_HEADER=0 |
|
109 endif |
|
110 |
|
111 ifeq ($(USE_PRECOMPILED_HEADER),1) |
|
112 |
|
113 ifndef LP64 |
|
114 $(error " Precompiled Headers only supported on 64-bit platforms!") |
|
115 endif |
|
116 |
|
117 PRECOMPILED_HEADER_DIR=. |
|
118 PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp |
|
119 PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.pch |
|
120 |
|
121 PCH_FLAG = -include precompiled.hpp |
|
122 PCH_FLAG/DEFAULT = $(PCH_FLAG) |
|
123 PCH_FLAG/NO_PCH = -DNO_PCH |
|
124 PCH_FLAG/BY_FILE = $(PCH_FLAG/$@)$(PCH_FLAG/DEFAULT$(PCH_FLAG/$@)) |
|
125 |
|
126 VM_PCH_FLAG/LIBJVM = $(PCH_FLAG/BY_FILE) |
|
127 VM_PCH_FLAG/AOUT = |
|
128 VM_PCH_FLAG = $(VM_PCH_FLAG/$(LINK_INTO)) |
|
129 |
|
130 # We only use precompiled headers for the JVM build |
|
131 CFLAGS += $(VM_PCH_FLAG) |
|
132 |
|
133 # There are some files which don't like precompiled headers |
|
134 # The following files are build with 'OPT_CFLAGS/NOOPT' (-O0) in the opt build. |
|
135 # But Clang doesn't support a precompiled header which was compiled with -O3 |
|
136 # to be used in a compilation unit which uses '-O0'. We could also prepare an |
|
137 # extra '-O0' PCH file for the opt build and use it here, but it's probably |
|
138 # not worth the effort as long as only two files need this special handling. |
|
139 PCH_FLAG/loopTransform.o = $(PCH_FLAG/NO_PCH) |
|
140 PCH_FLAG/sharedRuntimeTrig.o = $(PCH_FLAG/NO_PCH) |
|
141 PCH_FLAG/sharedRuntimeTrans.o = $(PCH_FLAG/NO_PCH) |
|
142 |
|
143 endif |
|
144 else # ($(USE_CLANG), true) |
|
145 # check for precompiled headers support |
|
146 ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0" |
|
147 # Allow the user to turn off precompiled headers from the command line. |
|
148 ifneq ($(USE_PRECOMPILED_HEADER),0) |
|
149 PRECOMPILED_HEADER_DIR=. |
|
150 PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp |
|
151 PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch |
|
152 endif |
|
153 endif |
|
154 endif |
|
155 |
|
156 # -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp. |
|
157 ifeq ($(USE_PRECOMPILED_HEADER),0) |
|
158 CFLAGS += -DDONT_USE_PRECOMPILED_HEADER |
|
159 endif |
97 |
160 |
98 #------------------------------------------------------------------------ |
161 #------------------------------------------------------------------------ |
99 # Compiler flags |
162 # Compiler flags |
100 |
163 |
101 # position-independent code |
164 # position-independent code |
113 CFLAGS += $(LLVM_CFLAGS) |
176 CFLAGS += $(LLVM_CFLAGS) |
114 endif |
177 endif |
115 CFLAGS += $(VM_PICFLAG) |
178 CFLAGS += $(VM_PICFLAG) |
116 CFLAGS += -fno-rtti |
179 CFLAGS += -fno-rtti |
117 CFLAGS += -fno-exceptions |
180 CFLAGS += -fno-exceptions |
118 CFLAGS += -pthread |
181 ifeq ($(USE_CLANG),) |
119 CFLAGS += -fcheck-new |
182 CFLAGS += -pthread |
120 # version 4 and above support fvisibility=hidden (matches jni_x86.h file) |
183 CFLAGS += -fcheck-new |
121 # except 4.1.2 gives pointless warnings that can't be disabled (afaik) |
184 # version 4 and above support fvisibility=hidden (matches jni_x86.h file) |
122 ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0" |
185 # except 4.1.2 gives pointless warnings that can't be disabled (afaik) |
123 CFLAGS += -fvisibility=hidden |
186 ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0" |
|
187 CFLAGS += -fvisibility=hidden |
|
188 endif |
|
189 else |
|
190 CFLAGS += -fvisibility=hidden |
|
191 endif |
|
192 |
|
193 ifeq ($(USE_CLANG), true) |
|
194 # Before Clang 3.1, we had to pass the stack alignment specification directly to llvm with the help of '-mllvm' |
|
195 # Starting with version 3.1, Clang understands the '-mstack-alignment' (and rejects '-mllvm -stack-alignment') |
|
196 ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 1 \) \))" "0" |
|
197 STACK_ALIGNMENT_OPT = -mno-omit-leaf-frame-pointer -mstack-alignment=16 |
|
198 else |
|
199 STACK_ALIGNMENT_OPT = -mno-omit-leaf-frame-pointer -mllvm -stack-alignment=16 |
|
200 endif |
124 endif |
201 endif |
125 |
202 |
126 ARCHFLAG = $(ARCHFLAG/$(BUILDARCH)) |
203 ARCHFLAG = $(ARCHFLAG/$(BUILDARCH)) |
127 ARCHFLAG/i486 = -m32 -march=i586 |
204 ARCHFLAG/i486 = -m32 -march=i586 |
128 ARCHFLAG/amd64 = -m64 |
205 ARCHFLAG/amd64 = -m64 $(STACK_ALIGNMENT_OPT) |
129 ARCHFLAG/ia64 = |
206 ARCHFLAG/ia64 = |
130 ARCHFLAG/sparc = -m32 -mcpu=v9 |
207 ARCHFLAG/sparc = -m32 -mcpu=v9 |
131 ARCHFLAG/sparcv9 = -m64 -mcpu=v9 |
208 ARCHFLAG/sparcv9 = -m64 -mcpu=v9 |
132 ARCHFLAG/zero = $(ZERO_ARCHFLAG) |
209 ARCHFLAG/zero = $(ZERO_ARCHFLAG) |
133 |
210 |
161 # Compiler warnings are treated as errors |
238 # Compiler warnings are treated as errors |
162 ifneq ($(COMPILER_WARNINGS_FATAL),false) |
239 ifneq ($(COMPILER_WARNINGS_FATAL),false) |
163 WARNINGS_ARE_ERRORS = -Werror |
240 WARNINGS_ARE_ERRORS = -Werror |
164 endif |
241 endif |
165 |
242 |
166 # Except for a few acceptable ones |
243 ifeq ($(USE_CLANG), true) |
167 # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit |
244 # However we need to clean the code up before we can unrestrictedly enable this option with Clang |
168 # conversions which might affect the values. To avoid that, we need to turn |
245 WARNINGS_ARE_ERRORS += -Wno-unused-value -Wno-logical-op-parentheses -Wno-parentheses-equality -Wno-parentheses |
169 # it off explicitly. |
246 WARNINGS_ARE_ERRORS += -Wno-switch -Wno-tautological-compare |
170 ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0" |
247 # Not yet supported by clang in Xcode 4.6.2 |
|
248 # WARNINGS_ARE_ERRORS += -Wno-tautological-constant-out-of-range-compare |
|
249 WARNINGS_ARE_ERRORS += -Wno-delete-non-virtual-dtor -Wno-deprecated -Wno-format -Wno-dynamic-class-memaccess |
|
250 WARNINGS_ARE_ERRORS += -Wno-return-type -Wno-empty-body |
|
251 endif |
|
252 |
171 WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef |
253 WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef |
172 else |
254 |
173 WARNING_FLAGS = -Wpointer-arith -Wconversion -Wsign-compare -Wundef |
255 ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0" |
|
256 # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit |
|
257 # conversions which might affect the values. Only enable it in earlier versions. |
|
258 WARNING_FLAGS = -Wunused-function |
|
259 ifeq ($(USE_CLANG),) |
|
260 WARNINGS_FLAGS += -Wconversion |
|
261 endif |
174 endif |
262 endif |
175 |
263 |
176 CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS) |
264 CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS) |
177 # Special cases |
265 # Special cases |
178 CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) |
266 CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) |
212 OPT_CFLAGS += -fno-expensive-optimizations |
300 OPT_CFLAGS += -fno-expensive-optimizations |
213 endif |
301 endif |
214 |
302 |
215 OPT_CFLAGS/NOOPT=-O0 |
303 OPT_CFLAGS/NOOPT=-O0 |
216 |
304 |
217 # 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation. |
305 # Work around some compiler bugs. |
218 ifneq "$(shell expr \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) = 3 \) \))" "0" |
306 ifeq ($(USE_CLANG), true) |
219 OPT_CFLAGS/mulnode.o += -O0 |
307 ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 2), 1) |
|
308 OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT) |
|
309 endif |
|
310 else |
|
311 # 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation. |
|
312 ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 3), 1) |
|
313 OPT_CFLAGS/mulnode.o += $(OPT_CFLAGS/NOOPT) |
|
314 endif |
220 endif |
315 endif |
221 |
316 |
222 # Flags for generating make dependency flags. |
317 # Flags for generating make dependency flags. |
223 ifneq ("${CC_VER_MAJOR}", "2") |
318 DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d) |
224 DEPFLAGS = -fpch-deps -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d) |
319 ifeq ($(USE_CLANG),) |
|
320 ifneq ($(CC_VER_MAJOR), 2) |
|
321 DEPFLAGS += -fpch-deps |
|
322 endif |
225 endif |
323 endif |
226 |
324 |
227 # -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp. |
325 # -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp. |
228 ifeq ($(USE_PRECOMPILED_HEADER),0) |
326 ifeq ($(USE_PRECOMPILED_HEADER),0) |
229 CFLAGS += -DDONT_USE_PRECOMPILED_HEADER |
327 CFLAGS += -DDONT_USE_PRECOMPILED_HEADER |
247 # Linker flags |
345 # Linker flags |
248 |
346 |
249 # statically link libstdc++.so, work with gcc but ignored by g++ |
347 # statically link libstdc++.so, work with gcc but ignored by g++ |
250 STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic |
348 STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic |
251 |
349 |
252 # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x. |
350 ifeq ($(USE_CLANG),) |
253 ifneq ("${CC_VER_MAJOR}", "2") |
351 # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x. |
254 STATIC_LIBGCC += -static-libgcc |
352 ifneq ("${CC_VER_MAJOR}", "2") |
255 endif |
353 STATIC_LIBGCC += -static-libgcc |
256 |
354 endif |
257 ifeq ($(BUILDARCH), ia64) |
355 |
258 LFLAGS += -Wl,-relax |
356 ifeq ($(BUILDARCH), ia64) |
|
357 LFLAGS += -Wl,-relax |
|
358 endif |
259 endif |
359 endif |
260 |
360 |
261 # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file. |
361 # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file. |
262 MAPFLAG = -Xlinker --version-script=FILENAME |
362 MAPFLAG = -Xlinker --version-script=FILENAME |
263 |
363 |
294 endif |
394 endif |
295 |
395 |
296 #------------------------------------------------------------------------ |
396 #------------------------------------------------------------------------ |
297 # Debug flags |
397 # Debug flags |
298 |
398 |
299 # Use the stabs format for debugging information (this is the default |
399 ifeq ($(USE_CLANG), true) |
300 # on gcc-2.91). It's good enough, has all the information about line |
400 # Restrict the debug information created by Clang to avoid |
301 # numbers and local variables, and libjvm.so is only about 16M. |
401 # too big object files and speed the build up a little bit |
302 # Change this back to "-g" if you want the most expressive format. |
402 # (see http://llvm.org/bugs/show_bug.cgi?id=7554) |
303 # (warning: that could easily inflate libjvm.so to 150M!) |
403 CFLAGS += -flimit-debug-info |
304 # Note: The Itanium gcc compiler crashes when using -gstabs. |
404 endif |
305 DEBUG_CFLAGS/ia64 = -g |
405 |
306 DEBUG_CFLAGS/amd64 = -g |
406 # DEBUG_BINARIES uses full -g debug information for all configs |
307 DEBUG_CFLAGS/arm = -g |
|
308 DEBUG_CFLAGS/ppc = -g |
|
309 DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH)) |
|
310 ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),) |
|
311 DEBUG_CFLAGS += -gstabs |
|
312 endif |
|
313 |
|
314 # DEBUG_BINARIES overrides everything, use full -g debug information |
|
315 ifeq ($(DEBUG_BINARIES), true) |
407 ifeq ($(DEBUG_BINARIES), true) |
316 DEBUG_CFLAGS = -g |
408 CFLAGS += -g |
317 CFLAGS += $(DEBUG_CFLAGS) |
409 else |
|
410 # Use the stabs format for debugging information (this is the default |
|
411 # on gcc-2.91). It's good enough, has all the information about line |
|
412 # numbers and local variables, and libjvm.so is only about 16M. |
|
413 # Change this back to "-g" if you want the most expressive format. |
|
414 # (warning: that could easily inflate libjvm.so to 150M!) |
|
415 # Note: The Itanium gcc compiler crashes when using -gstabs. |
|
416 DEBUG_CFLAGS/ia64 = -g |
|
417 DEBUG_CFLAGS/amd64 = -g |
|
418 DEBUG_CFLAGS/arm = -g |
|
419 DEBUG_CFLAGS/ppc = -g |
|
420 DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH)) |
|
421 ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),) |
|
422 DEBUG_CFLAGS += -gstabs |
|
423 endif |
318 endif |
424 endif |
319 |
425 |
320 # If we are building HEADLESS, pass on to VM |
426 # If we are building HEADLESS, pass on to VM |
321 # so it can set the java.awt.headless property |
427 # so it can set the java.awt.headless property |
322 ifdef HEADLESS |
428 ifdef HEADLESS |