Bump version to 6.4.7.2.M8
[LibreOffice.git] / solenv / gbuild / platform / com_GCC_defs.mk
blob712a61df544f3354db37a3f87e8ce57c431bbe5f
1 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 gb_AWK := awk
11 gb_YACC := bison
13 gb_CLASSPATHSEP := :
14 gb_LICENSE := LICENSE
15 gb_README = README_$(1)
17 # use CC/CXX if they are nondefaults
18 ifneq ($(origin CC),default)
19 gb_CC := $(CC)
20 gb_GCCP := $(CC)
21 else
22 gb_CC := gcc
23 gb_GCCP := gcc
24 endif
26 ifneq ($(origin CXX),default)
27 gb_CXX := $(CXX)
28 else
29 gb_CXX := g++
30 endif
32 ifneq ($(origin AR),default)
33 gb_AR := $(AR)
34 else
35 gb_AR := $(shell $(CC) -print-prog-name=ar)
36 endif
38 # shell setup (env.vars) for the compiler
39 gb_COMPILER_SETUP :=
41 ifneq ($(USE_LD),)
42 gb_LinkTarget_LDFLAGS += -fuse-ld=$(USE_LD)
43 endif
45 ifeq ($(strip $(gb_COMPILEROPTFLAGS)),)
46 gb_COMPILEROPTFLAGS := -O2
47 endif
49 gb_CPPU_ENV := gcc3
51 gb_AFLAGS := $(AFLAGS)
53 gb_COMPILERDEFS := \
54 -DBOOST_ERROR_CODE_HEADER_ONLY \
55 -DBOOST_SYSTEM_NO_DEPRECATED \
56 -DCPPU_ENV=$(gb_CPPU_ENV) \
58 gb_CFLAGS_COMMON := \
59 -Wall \
60 -Wendif-labels \
61 -Wextra \
62 -Wstrict-prototypes \
63 -Wundef \
64 -Wunreachable-code \
65 $(if $(and $(COM_IS_CLANG),$(or $(findstring icecc,$(CC)),$(findstring icecc,$(CCACHE_PREFIX)))),,-Wunused-macros) \
66 -finput-charset=UTF-8 \
67 -fmessage-length=0 \
68 -fno-common \
69 -pipe \
70 -fstack-protector-strong \
72 gb_CXXFLAGS_COMMON := \
73 -Wall \
74 -Wno-missing-braces \
75 -Wnon-virtual-dtor \
76 -Wendif-labels \
77 -Wextra \
78 -Wundef \
79 -Wunreachable-code \
80 $(if $(and $(COM_IS_CLANG),$(or $(findstring icecc,$(CC)),$(findstring icecc,$(CCACHE_PREFIX)))),,-Wunused-macros) \
81 -finput-charset=UTF-8 \
82 -fmessage-length=0 \
83 -fno-common \
84 -pipe \
85 -fstack-protector-strong \
87 gb_CXXFLAGS_DISABLE_WARNINGS = -w
89 ifeq ($(HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED),TRUE)
90 gb_CXXFLAGS_COMMON += -Wno-maybe-uninitialized
91 endif
93 gb_CXXFLAGS_Wundef = -Wno-undef
95 ifeq ($(strip $(gb_GCOV)),YES)
96 gb_CFLAGS_COMMON += -fprofile-arcs -ftest-coverage
97 gb_CXXFLAGS_COMMON += -fprofile-arcs -ftest-coverage
98 gb_LinkTarget_LDFLAGS += -fprofile-arcs -lgcov
99 gb_COMPILEROPTFLAGS := -O0
100 endif
102 ifeq ($(DISABLE_DYNLOADING),TRUE)
103 gb_CFLAGS_COMMON += -ffunction-sections -fdata-sections
104 gb_CXXFLAGS_COMMON += -ffunction-sections -fdata-sections
105 gb_LinkTarget_LDFLAGS += -Wl,--gc-sections
106 endif
108 ifeq ($(COM_IS_CLANG),TRUE)
109 gb_CXXFLAGS_COMMON += \
110 -Wimplicit-fallthrough \
111 -Wunused-exception-parameter \
112 -Wrange-loop-analysis
113 else
114 gb_CFLAGS_COMMON += \
115 -Wduplicated-cond \
116 -Wlogical-op \
117 -Wshift-overflow=2
118 gb_CXXFLAGS_COMMON += \
119 -Wduplicated-cond \
120 -Wlogical-op \
121 -Wshift-overflow=2 \
122 -Wunused-const-variable=1
123 endif
125 # GCC 8 -Wcast-function-type (included in -Wextra) unhelpfully even warns on reinterpret_cast
126 # between incompatible function types:
127 ifeq ($(shell expr '$(GCC_VERSION)' '>=' 800),1)
128 gb_CXXFLAGS_COMMON += \
129 -Wno-cast-function-type
130 endif
132 # If CC or CXX already include -fvisibility=hidden, don't duplicate it
133 ifeq (,$(filter -fvisibility=hidden,$(CC)))
134 gb_VISIBILITY_FLAGS := -fvisibility=hidden
135 endif
136 gb_VISIBILITY_FLAGS_CXX := -fvisibility-inlines-hidden
137 gb_CXXFLAGS_COMMON += $(gb_VISIBILITY_FLAGS_CXX)
139 gb_LinkTarget_LDFLAGS += -fstack-protector-strong
141 ifneq ($(ENABLE_PCH),)
142 ifeq ($(COM_IS_CLANG),TRUE)
143 # Clang by default includes in the PCH timestamps of the files it was
144 # generated from, which would make the PCH be a "new" file for ccache
145 # even if the file has not actually changed. Disabling the timestamp
146 # prevents this at the cost of risking using an outdated PCH (which
147 # should be unlikely, given that gbuild has dependencies set up
148 # for our includes and system includes are unlikely to change).
149 gb_NO_PCH_TIMESTAMP := -Xclang -fno-pch-timestamp
150 else
151 gb_CFLAGS_COMMON += -fpch-preprocess -Winvalid-pch
152 gb_CXXFLAGS_COMMON += -fpch-preprocess -Winvalid-pch
153 gb_NO_PCH_TIMESTAMP :=
154 endif
155 endif
157 gb_CFLAGS_WERROR = $(if $(ENABLE_WERROR),-Werror)
159 # This is the default in non-C++11 mode
160 ifeq ($(COM_IS_CLANG),TRUE)
161 gb_CXX03FLAGS := -std=gnu++98 -Werror=c++11-extensions -Wno-c++11-long-long \
162 -Wno-deprecated-declarations
163 else
164 gb_CXX03FLAGS := -std=gnu++98 -Wno-long-long \
165 -Wno-variadic-macros -Wno-non-virtual-dtor -Wno-deprecated-declarations
166 endif
168 # On Windows MSVC only supports C90 so force gnu89 (especially in clang) to
169 # to catch potential gnu89/C90 incompatibilities locally.
170 gb_CFLAGS_COMMON += -std=gnu89
172 ifeq ($(ENABLE_LTO),TRUE)
173 ifeq ($(COM_IS_CLANG),TRUE)
174 gb_LTOFLAGS := -flto
175 gb_LTOPLUGINFLAGS := --plugin LLVMgold.so
176 else
177 gb_LTOFLAGS := -flto=$(PARALLELISM) -fuse-linker-plugin -O2
178 endif
179 endif
181 gb_LinkTarget_EXCEPTIONFLAGS := \
182 -DEXCEPTIONS_ON \
183 -fexceptions
185 ifeq ($(gb_ENABLE_DBGUTIL),$(false))
186 # Clang doesn't have this option
187 ifeq ($(HAVE_GCC_FNO_ENFORCE_EH_SPECS),TRUE)
188 gb_LinkTarget_EXCEPTIONFLAGS += \
189 -fno-enforce-eh-specs
190 endif
191 endif
193 gb_PrecompiledHeader_EXCEPTIONFLAGS := $(gb_LinkTarget_EXCEPTIONFLAGS)
195 # optimization level
196 gb_COMPILERNOOPTFLAGS := -O0 -fstrict-aliasing -fstrict-overflow
198 ifeq ($(OS),ANDROID)
199 gb_DEBUGINFO_FLAGS=-glldb
200 # Clang does not know -ggdb2 or some other options
201 else ifeq ($(HAVE_GCC_GGDB2),TRUE)
202 gb_DEBUGINFO_FLAGS=-ggdb2
203 else
204 gb_DEBUGINFO_FLAGS=-g2
205 endif
206 gb_LINKER_DEBUGINFO_FLAGS=
208 ifeq ($(HAVE_GCC_SPLIT_DWARF),TRUE)
209 gb_DEBUGINFO_FLAGS+=-gsplit-dwarf
210 endif
212 ifeq ($(ENABLE_GDB_INDEX),TRUE)
213 gb_LINKER_DEBUGINFO_FLAGS += -Wl,--gdb-index
214 gb_DEBUGINFO_FLAGS += -ggnu-pubnames
215 endif
217 gb_LinkTarget_INCLUDE :=\
218 $(SOLARINC) \
219 -I$(BUILDDIR)/config_$(gb_Side) \
221 ifeq ($(COM_IS_CLANG),TRUE)
222 gb_COMPILER_TEST_FLAGS := -Xclang -plugin-arg-loplugin -Xclang --unit-test-mode
223 ifeq ($(COMPILER_PLUGIN_TOOL),)
224 gb_COMPILER_PLUGINS := -Xclang -load -Xclang $(BUILDDIR)/compilerplugins/clang/plugin.so -Xclang -add-plugin -Xclang loplugin
225 ifneq ($(COMPILER_PLUGIN_WARNINGS_ONLY),)
226 gb_COMPILER_PLUGINS += -Xclang -plugin-arg-loplugin -Xclang \
227 --warnings-only='$(COMPILER_PLUGIN_WARNINGS_ONLY)'
228 endif
229 else
230 gb_COMPILER_PLUGINS := -Xclang -load -Xclang $(BUILDDIR)/compilerplugins/clang/plugin.so -Xclang -plugin -Xclang loplugin $(foreach plugin,$(COMPILER_PLUGIN_TOOL), -Xclang -plugin-arg-loplugin -Xclang $(plugin))
231 ifneq ($(UPDATE_FILES),)
232 gb_COMPILER_PLUGINS += -Xclang -plugin-arg-loplugin -Xclang --scope=$(UPDATE_FILES)
233 endif
234 endif
235 ifeq ($(COMPILER_PLUGINS_DEBUG),TRUE)
236 gb_COMPILER_PLUGINS += -Xclang -plugin-arg-loplugin -Xclang --debug
237 endif
238 # set CCACHE_CPP2=1 to prevent clang generating spurious warnings
239 gb_COMPILER_SETUP += CCACHE_CPP2=1
240 gb_COMPILER_PLUGINS_SETUP := ICECC_EXTRAFILES=$(SRCDIR)/include/sal/log-areas.dox CCACHE_EXTRAFILES=$(SRCDIR)/include/sal/log-areas.dox
241 gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS := \
242 -Xclang -plugin-arg-loplugin -Xclang --warnings-as-errors
243 else
244 # Set CCACHE_CPP2 to prevent GCC -Werror=implicit-fallthrough= when ccache strips comments from C
245 # code (which still needs /*fallthrough*/-style comments to silence that warning):
246 ifeq ($(ENABLE_WERROR),TRUE)
247 gb_COMPILER_SETUP += CCACHE_CPP2=1
248 endif
249 gb_COMPILER_TEST_FLAGS :=
250 gb_COMPILER_PLUGINS :=
251 gb_COMPILER_PLUGINS_SETUP :=
252 gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS :=
253 endif
255 # Executable class
257 gb_Executable_EXT_for_build :=
259 # Helper class
261 ifeq ($(OS_FOR_BUILD),MACOSX)
262 gb_Helper_LIBRARY_PATH_VAR := DYLD_LIBRARY_PATH
263 else ifeq ($(OS_FOR_BUILD),AIX)
264 gb_Helper_LIBRARY_PATH_VAR := LIBPATH
265 else ifeq ($(OS_FOR_BUILD),WNT)
266 # In theory possible if cross-compiling to some Unix from Windows,
267 # in practice strongly discouraged to even try that
268 gb_Helper_LIBRARY_PATH_VAR := PATH
269 else ifeq ($(OS_FOR_BUILD),HAIKU)
270 gb_Helper_LIBRARY_PATH_VAR := LIBRARY_PATH
271 else
272 gb_Helper_LIBRARY_PATH_VAR := LD_LIBRARY_PATH
273 endif
275 gb_Helper_set_ld_path := $(gb_Helper_LIBRARY_PATH_VAR)=$${$(gb_Helper_LIBRARY_PATH_VAR):+$$$(gb_Helper_LIBRARY_PATH_VAR):}"$(INSTROOT_FOR_BUILD)/$(LIBO_URE_LIB_FOLDER_FOR_BUILD):$(INSTROOT_FOR_BUILD)/$(LIBO_LIB_FOLDER_FOR_BUILD)"
277 # $(1): list of : separated directory pathnames to append to the ld path
278 define gb_Helper_extend_ld_path
279 $(gb_Helper_set_ld_path):$(1)
280 endef
282 # Convert path to file URL.
283 define gb_Helper_make_url
284 file://$(strip $(1))
285 endef
287 gb_Helper_get_rcfile = $(1)rc
289 ifneq ($(ENABLE_PCH),)
290 # Enable use of .sum files for PCHs.
291 gb_COMPILER_SETUP += CCACHE_PCH_EXTSUM=1
292 # CCACHE_SLOPPINESS should contain pch_defines,time_macros for PCHs.
293 gb_CCACHE_SLOPPINESS :=
294 ifeq ($(shell test -z "$$CCACHE_SLOPPINESS" && echo 1),1)
295 gb_CCACHE_SLOPPINESS := CCACHE_SLOPPINESS=pch_defines,time_macros
296 else
297 ifeq ($(shell echo "$$CCACHE_SLOPPINESS" | grep -q pch_defines | grep -q time_macros && echo 1),1)
298 gb_CCACHE_SLOPPINESS := CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS:pch_defines,time_macros
299 endif
300 endif
301 gb_COMPILER_SETUP += $(gb_CCACHE_SLOPPINESS)
302 endif
304 ifneq ($(CCACHE_DEPEND_MODE),)
305 gb_COMPILER_SETUP += CCACHE_DEPEND=1
306 endif
308 # vim: set noet sw=4: