bump product version to 6.3.0.0.beta1
[LibreOffice.git] / solenv / gbuild / platform / com_GCC_defs.mk
blob4a4688dd3a1f586c4634388f75b1ab6fd38a4489
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 \
71 gb_CXXFLAGS_COMMON := \
72 -Wall \
73 -Wno-missing-braces \
74 -Wnon-virtual-dtor \
75 -Wendif-labels \
76 -Wextra \
77 -Wundef \
78 -Wunreachable-code \
79 $(if $(and $(COM_IS_CLANG),$(or $(findstring icecc,$(CC)),$(findstring icecc,$(CCACHE_PREFIX)))),,-Wunused-macros) \
80 -finput-charset=UTF-8 \
81 -fmessage-length=0 \
82 -fno-common \
83 -pipe \
85 gb_Helper_disable_warnings = $(1) -w
87 ifeq ($(HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED),TRUE)
88 gb_CXXFLAGS_COMMON += -Wno-maybe-uninitialized
89 endif
91 gb_CXXFLAGS_Wundef = -Wno-undef
93 ifeq ($(strip $(gb_GCOV)),YES)
94 gb_CFLAGS_COMMON += -fprofile-arcs -ftest-coverage
95 gb_CXXFLAGS_COMMON += -fprofile-arcs -ftest-coverage
96 gb_LinkTarget_LDFLAGS += -fprofile-arcs -lgcov
97 gb_COMPILEROPTFLAGS := -O0
98 endif
100 ifeq ($(DISABLE_DYNLOADING),TRUE)
101 gb_CFLAGS_COMMON += -ffunction-sections -fdata-sections
102 gb_CXXFLAGS_COMMON += -ffunction-sections -fdata-sections
103 gb_LinkTarget_LDFLAGS += -Wl,--gc-sections
104 endif
106 ifeq ($(COM_IS_CLANG),TRUE)
107 gb_CXXFLAGS_COMMON += -Wimplicit-fallthrough
108 else
109 gb_CFLAGS_COMMON += \
110 -Wduplicated-cond \
111 -Wlogical-op \
112 -Wshift-overflow=2
113 gb_CXXFLAGS_COMMON += \
114 -Wduplicated-cond \
115 -Wlogical-op \
116 -Wshift-overflow=2 \
117 -Wunused-const-variable=1
118 endif
120 # GCC 8 -Wcast-function-type (included in -Wextra) unhelpfully even warns on reinterpret_cast
121 # between incompatible function types:
122 ifeq ($(shell expr '$(GCC_VERSION)' '>=' 800),1)
123 gb_CXXFLAGS_COMMON += \
124 -Wno-cast-function-type
125 endif
127 # If CC or CXX already include -fvisibility=hidden, don't duplicate it
128 ifeq (,$(filter -fvisibility=hidden,$(CC)))
129 ifeq ($(NEED_CLANG_LINUX_UBSAN_RTTI_VISIBILITY),TRUE)
130 gb_VISIBILITY_FLAGS := -fvisibility-ms-compat
131 else
132 gb_VISIBILITY_FLAGS := -fvisibility=hidden
133 endif
134 endif
135 gb_VISIBILITY_FLAGS_CXX := -fvisibility-inlines-hidden
136 gb_CXXFLAGS_COMMON += $(gb_VISIBILITY_FLAGS_CXX)
138 ifeq ($(HAVE_GCC_STACK_PROTECTOR_STRONG),TRUE)
139 gb_CFLAGS_COMMON += -fstack-protector-strong
140 gb_CXXFLAGS_COMMON += -fstack-protector-strong
141 gb_LinkTarget_LDFLAGS += -fstack-protector-strong
142 endif
144 ifneq ($(ENABLE_PCH),)
145 ifeq ($(COM_IS_CLANG),TRUE)
146 # Clang by default includes in the PCH timestamps of the files it was
147 # generated from, which would make the PCH be a "new" file for ccache
148 # even if the file has not actually changed. Disabling the timestamp
149 # prevents this at the cost of risking using an outdated PCH (which
150 # should be unlikely, given that gbuild has dependencies set up
151 # for our includes and system includes are unlikely to change).
152 gb_NO_PCH_TIMESTAMP := -Xclang -fno-pch-timestamp
153 else
154 gb_CFLAGS_COMMON += -fpch-preprocess -Winvalid-pch
155 gb_CXXFLAGS_COMMON += -fpch-preprocess -Winvalid-pch
156 gb_NO_PCH_TIMESTAMP :=
157 endif
158 endif
160 gb_CFLAGS_WERROR = $(if $(ENABLE_WERROR),-Werror)
162 # This is the default in non-C++11 mode
163 ifeq ($(COM_IS_CLANG),TRUE)
164 gb_CXX03FLAGS := -std=gnu++98 -Werror=c++11-extensions -Wno-c++11-long-long \
165 -Wno-deprecated-declarations
166 else
167 gb_CXX03FLAGS := -std=gnu++98 -Wno-long-long \
168 -Wno-variadic-macros -Wno-non-virtual-dtor -Wno-deprecated-declarations
169 endif
171 # On Windows MSVC only supports C90 so force gnu89 (especially in clang) to
172 # to catch potential gnu89/C90 incompatibilities locally.
173 gb_CFLAGS_COMMON += -std=gnu89
175 ifeq ($(ENABLE_LTO),TRUE)
176 ifeq ($(COM_IS_CLANG),TRUE)
177 gb_LTOFLAGS := -flto
178 gb_LTOPLUGINFLAGS := --plugin LLVMgold.so
179 else
180 gb_LTOFLAGS := -flto=$(PARALLELISM) -fuse-linker-plugin -O2
181 endif
182 endif
184 gb_LinkTarget_EXCEPTIONFLAGS := \
185 -DEXCEPTIONS_ON \
186 -fexceptions
188 ifeq ($(gb_ENABLE_DBGUTIL),$(false))
189 # Clang doesn't have this option
190 ifeq ($(HAVE_GCC_FNO_ENFORCE_EH_SPECS),TRUE)
191 gb_LinkTarget_EXCEPTIONFLAGS += \
192 -fno-enforce-eh-specs
193 endif
194 endif
196 gb_PrecompiledHeader_EXCEPTIONFLAGS := $(gb_LinkTarget_EXCEPTIONFLAGS)
198 # optimization level
199 gb_COMPILERNOOPTFLAGS := -O0 -fstrict-aliasing -fstrict-overflow
201 ifeq ($(OS),ANDROID)
202 gb_DEBUGINFO_FLAGS=-glldb
203 # Clang does not know -ggdb2 or some other options
204 else ifeq ($(HAVE_GCC_GGDB2),TRUE)
205 gb_DEBUGINFO_FLAGS=-ggdb2
206 else
207 gb_DEBUGINFO_FLAGS=-g2
208 endif
209 gb_LINKER_DEBUGINFO_FLAGS=
211 ifeq ($(HAVE_GCC_SPLIT_DWARF),TRUE)
212 gb_DEBUGINFO_FLAGS+=-gsplit-dwarf
213 endif
215 ifeq ($(ENABLE_GDB_INDEX),TRUE)
216 gb_LINKER_DEBUGINFO_FLAGS += -Wl,--gdb-index
217 gb_DEBUGINFO_FLAGS += -ggnu-pubnames
218 endif
220 gb_LinkTarget_INCLUDE :=\
221 $(SOLARINC) \
222 -I$(BUILDDIR)/config_$(gb_Side) \
224 ifeq ($(COM_IS_CLANG),TRUE)
225 gb_COMPILER_TEST_FLAGS := -Xclang -plugin-arg-loplugin -Xclang --unit-test-mode
226 ifeq ($(COMPILER_PLUGIN_TOOL),)
227 gb_COMPILER_PLUGINS := -Xclang -load -Xclang $(BUILDDIR)/compilerplugins/obj/plugin.so -Xclang -add-plugin -Xclang loplugin
228 ifneq ($(COMPILER_PLUGIN_WARNINGS_ONLY),)
229 gb_COMPILER_PLUGINS += -Xclang -plugin-arg-loplugin -Xclang \
230 --warnings-only='$(COMPILER_PLUGIN_WARNINGS_ONLY)'
231 endif
232 else
233 gb_COMPILER_PLUGINS := -Xclang -load -Xclang $(BUILDDIR)/compilerplugins/obj/plugin.so -Xclang -plugin -Xclang loplugin $(foreach plugin,$(COMPILER_PLUGIN_TOOL), -Xclang -plugin-arg-loplugin -Xclang $(plugin))
234 ifneq ($(UPDATE_FILES),)
235 gb_COMPILER_PLUGINS += -Xclang -plugin-arg-loplugin -Xclang --scope=$(UPDATE_FILES)
236 endif
237 endif
238 ifeq ($(COMPILER_PLUGINS_DEBUG),TRUE)
239 gb_COMPILER_PLUGINS += -Xclang -plugin-arg-loplugin -Xclang --debug
240 endif
241 # set CCACHE_CPP2=1 to prevent clang generating spurious warnings
242 gb_COMPILER_SETUP += CCACHE_CPP2=1
243 gb_COMPILER_PLUGINS_SETUP := ICECC_EXTRAFILES=$(SRCDIR)/include/sal/log-areas.dox CCACHE_EXTRAFILES=$(SRCDIR)/include/sal/log-areas.dox
244 gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS := \
245 -Xclang -plugin-arg-loplugin -Xclang --warnings-as-errors
246 else
247 # Set CCACHE_CPP2 to prevent GCC -Werror=implicit-fallthrough= when ccache strips comments from C
248 # code (which still needs /*fallthrough*/-style comments to silence that warning):
249 ifeq ($(ENABLE_WERROR),TRUE)
250 gb_COMPILER_SETUP += CCACHE_CPP2=1
251 endif
252 gb_COMPILER_TEST_FLAGS :=
253 gb_COMPILER_PLUGINS :=
254 gb_COMPILER_PLUGINS_SETUP :=
255 gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS :=
256 endif
258 # Executable class
260 gb_Executable_EXT_for_build :=
262 # Helper class
264 ifeq ($(OS_FOR_BUILD),MACOSX)
265 gb_Helper_LIBRARY_PATH_VAR := DYLD_LIBRARY_PATH
266 else ifeq ($(OS_FOR_BUILD),AIX)
267 gb_Helper_LIBRARY_PATH_VAR := LIBPATH
268 else ifeq ($(OS_FOR_BUILD),WNT)
269 # In theory possible if cross-compiling to some Unix from Windows,
270 # in practice strongly discouraged to even try that
271 gb_Helper_LIBRARY_PATH_VAR := PATH
272 else ifeq ($(OS_FOR_BUILD),HAIKU)
273 gb_Helper_LIBRARY_PATH_VAR := LIBRARY_PATH
274 else
275 gb_Helper_LIBRARY_PATH_VAR := LD_LIBRARY_PATH
276 endif
278 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)"
280 # $(1): list of : separated directory pathnames to append to the ld path
281 define gb_Helper_extend_ld_path
282 $(gb_Helper_set_ld_path):$(1)
283 endef
285 # Convert path to file URL.
286 define gb_Helper_make_url
287 file://$(strip $(1))
288 endef
290 gb_Helper_get_rcfile = $(1)rc
292 ifneq ($(ENABLE_PCH),)
293 # Enable use of .sum files for PCHs.
294 gb_COMPILER_SETUP += CCACHE_PCH_EXTSUM=1
295 # CCACHE_SLOPPINESS should contain pch_defines,time_macros for PCHs.
296 gb_CCACHE_SLOPPINESS :=
297 ifeq ($(shell test -z "$$CCACHE_SLOPPINESS" && echo 1),1)
298 gb_CCACHE_SLOPPINESS := CCACHE_SLOPPINESS=pch_defines,time_macros
299 else
300 ifeq ($(shell echo "$$CCACHE_SLOPPINESS" | grep -q pch_defines | grep -q time_macros && echo 1),1)
301 gb_CCACHE_SLOPPINESS := CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS:pch_defines,time_macros
302 endif
303 endif
304 gb_COMPILER_SETUP += $(gb_CCACHE_SLOPPINESS)
305 endif
307 ifneq ($(CCACHE_DEPEND_MODE),)
308 gb_COMPILER_SETUP += CCACHE_DEPEND=1
309 endif
311 # vim: set noet sw=4: