tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / solenv / gbuild / platform / com_GCC_defs.mk
blob528e45630b258b709e8bdf42316e27df370d2fd0
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
12 gb_CLASSPATHSEP := :
13 gb_LICENSE := LICENSE
14 gb_README = README_$(1)
16 # use CC/CXX if they are nondefaults
17 ifneq ($(origin CC),default)
18 gb_CC := $(CC)
19 gb_GCCP := $(CC)
20 else
21 gb_CC := gcc
22 gb_GCCP := gcc
23 endif
25 ifneq ($(origin CXX),default)
26 gb_CXX := $(CXX)
27 else
28 gb_CXX := g++
29 endif
31 ifneq ($(origin AR),default)
32 gb_AR := $(AR)
33 else
34 gb_AR := $(shell $(CC) -print-prog-name=ar)
35 endif
37 # shell setup (env.vars) for the compiler
38 gb_COMPILER_SETUP :=
40 ifeq ($(strip $(gb_COMPILEROPTFLAGS)),)
41 gb_COMPILEROPTFLAGS := -O2
42 endif
44 gb_COMPILEROPTFLAGS += $(if $(ENABLE_HARDENING_FLAGS),$(HARDENING_OPT_CFLAGS))
46 gb_AFLAGS := $(AFLAGS)
48 gb_COMPILERDEFS := \
49 -DBOOST_SYSTEM_NO_DEPRECATED \
50 -DCPPU_ENV=$(CPPU_ENV) \
51 $(if $(filter EMSCRIPTEN,$(OS)),-U_FORTIFY_SOURCE) \
53 # enable debug STL
54 ifeq ($(ENABLE_DBGUTIL),TRUE)
55 ifneq ($(HAVE_LIBSTDCPP),)
56 gb_COMPILERDEFS_STDLIB_DEBUG = -D_GLIBCXX_DEBUG
57 else
58 ifneq ($(LIBCPP_DEBUG),)
59 gb_COMPILERDEFS_STDLIB_DEBUG = $(LIBCPP_DEBUG)
60 endif
61 endif
62 gb_COMPILERDEFS += $(gb_COMPILERDEFS_STDLIB_DEBUG)
63 endif
65 gb_CFLAGS_COMMON := \
66 -Wall \
67 -Wendif-labels \
68 -Wextra \
69 -Wstrict-prototypes \
70 -Wundef \
71 -Wunreachable-code \
72 $(if $(or $(and $(COM_IS_CLANG),$(or $(findstring icecc,$(CC)),$(findstring icecc,$(CCACHE_PREFIX)))),$(findstring sccache,$(CC))),,-Wunused-macros) \
73 $(if $(COM_IS_CLANG),-Wembedded-directive) \
74 $(if $(COM_IS_CLANG),-Wshadow-all) \
75 -finput-charset=UTF-8 \
76 -fmessage-length=0 \
77 -fno-common \
78 -pipe \
79 $(if $(ENABLE_HARDENING_FLAGS),$(HARDENING_CFLAGS)) \
80 $(if $(filter EMSCRIPTEN,$(OS)),-fno-stack-protector,-fstack-protector-strong) \
82 gb_CXXFLAGS_COMMON := \
83 -Wall \
84 -Wno-missing-braces \
85 -Wendif-labels \
86 -Wextra \
87 -Wundef \
88 -Wunreachable-code \
89 -Wshadow \
90 $(if $(or $(and $(COM_IS_CLANG),$(or $(findstring icecc,$(CXX)),$(findstring icecc,$(CCACHE_PREFIX)))),$(findstring sccache,$(CXX))),,-Wunused-macros) \
91 $(if $(COM_IS_CLANG),-Wembedded-directive) \
92 -finput-charset=UTF-8 \
93 -fmessage-length=0 \
94 -fno-common \
95 -pipe \
96 $(if $(ENABLE_HARDENING_FLAGS),$(HARDENING_CFLAGS)) \
97 $(if $(filter EMSCRIPTEN,$(OS)),-fno-stack-protector,-fstack-protector-strong) \
99 ifeq ($(HAVE_WDEPRECATED_COPY_DTOR),TRUE)
100 gb_CXXFLAGS_COMMON += -Wdeprecated-copy-dtor
101 endif
103 gb_CXXFLAGS_DISABLE_WARNINGS = -w
105 ifeq ($(HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED),TRUE)
106 gb_CXXFLAGS_COMMON += -Wno-maybe-uninitialized
107 endif
109 ifeq ($(HAVE_BROKEN_GCC_WSTRINGOP_OVERFLOW),TRUE)
110 gb_CXXFLAGS_COMMON += -Wno-stringop-overflow
111 endif
113 gb_CXXFLAGS_Wundef = -Wno-undef
115 gb_CXXFLAGS_include := -include$(gb_SPACE)
117 ifeq ($(strip $(gb_GCOV)),YES)
118 gb_CFLAGS_COMMON += -fprofile-arcs -ftest-coverage
119 gb_CXXFLAGS_COMMON += -fprofile-arcs -ftest-coverage
120 gb_LinkTarget_LDFLAGS += -fprofile-arcs -lgcov
121 gb_COMPILEROPTFLAGS := -O0
122 endif
124 ifeq ($(DISABLE_DYNLOADING),TRUE)
125 gb_CFLAGS_COMMON += -ffunction-sections -fdata-sections
126 gb_CXXFLAGS_COMMON += -ffunction-sections -fdata-sections
127 ifneq ($(OS),EMSCRIPTEN)
128 gb_LinkTarget_LDFLAGS += -Wl,--gc-sections
129 endif
130 endif
132 ifeq ($(COM_IS_CLANG),TRUE)
133 gb_CXXFLAGS_COMMON += \
134 -Wimplicit-fallthrough \
135 -Wunused-exception-parameter \
136 -Wrange-loop-analysis
137 else
138 gb_CFLAGS_COMMON += \
139 -Wduplicated-cond \
140 -Wlogical-op \
141 -Wshift-overflow=2
142 gb_CXXFLAGS_COMMON += \
143 -Wduplicated-cond \
144 -Wlogical-op \
145 -Wshift-overflow=2 \
146 -Wunused-const-variable=1
147 endif
149 # If CC or CXX already include -fvisibility=hidden, don't duplicate it
150 ifeq (,$(filter -fvisibility=hidden,$(CC)))
151 gb_VISIBILITY_FLAGS := -fvisibility=hidden
152 endif
153 gb_VISIBILITY_FLAGS_CXX := -fvisibility-inlines-hidden
154 gb_CXXFLAGS_COMMON += $(gb_VISIBILITY_FLAGS_CXX)
156 gb_LinkTarget_LDFLAGS += $(if $(filter EMSCRIPTEN,$(OS)),-fno-stack-protector,-fstack-protector-strong)
158 ifneq ($(gb_ENABLE_PCH),)
159 ifeq ($(COM_IS_CLANG),TRUE)
160 # Clang by default includes in the PCH timestamps of the files it was
161 # generated from, which would make the PCH be a "new" file for ccache
162 # even if the file has not actually changed. Disabling the timestamp
163 # prevents this at the cost of risking using an outdated PCH (which
164 # should be unlikely, given that gbuild has dependencies set up
165 # for our includes and system includes are unlikely to change).
166 gb_NO_PCH_TIMESTAMP := -Xclang -fno-pch-timestamp
167 else
168 gb_CFLAGS_COMMON += -fpch-preprocess -Winvalid-pch
169 gb_CXXFLAGS_COMMON += -fpch-preprocess -Winvalid-pch
170 gb_NO_PCH_TIMESTAMP :=
171 endif
172 endif
174 gb_CFLAGS_WERROR = $(if $(ENABLE_WERROR),-Werror)
176 # This is the default in non-C++11 mode
177 ifeq ($(COM_IS_CLANG),TRUE)
178 gb_CXX03FLAGS := -std=gnu++98 -Werror=c++11-extensions -Wno-c++11-long-long \
179 -Wno-deprecated-declarations
180 else
181 gb_CXX03FLAGS := -std=gnu++98 -Wno-long-long \
182 -Wno-variadic-macros -Wno-deprecated-declarations
183 endif
185 ifeq ($(ENABLE_LTO),TRUE)
186 ifeq ($(COM_IS_CLANG),TRUE)
187 gb_LTOFLAGS := -flto=thin
188 ifeq (,$(index,iOS MACOSX,$(OS)))
189 gb_LTOPLUGINFLAGS := --plugin $(if $(LD_PLUGIN),$(LD_PLUGIN),LLVMgold.so)
190 endif
191 else
192 # use parallelism based on make's job handling
193 gb_LTOFLAGS := -flto=jobserver -fuse-linker-plugin -O2
194 # clang does not support -flto=<number>
195 gb_CLANG_LTOFLAGS := -flto=thin
196 endif
197 endif
199 gb_LinkTarget_EXCEPTIONFLAGS := \
200 -fexceptions
202 ifeq ($(ENABLE_DBGUTIL),)
203 # Clang doesn't have this option
204 ifeq ($(HAVE_GCC_FNO_ENFORCE_EH_SPECS),TRUE)
205 gb_LinkTarget_EXCEPTIONFLAGS += \
206 -fno-enforce-eh-specs
207 gb_FilterOutClangCFLAGS += -fno-enforce-eh-specs
208 endif
209 endif
211 gb_PrecompiledHeader_EXCEPTIONFLAGS := $(gb_LinkTarget_EXCEPTIONFLAGS)
213 # We turn on and off this one depending on whether icecream and/or ccache are used,
214 # and changing cxxflags cause PCH rebuilds, so e.g. a plain temporary 'CCACHE_DISABLE=1'
215 # would cause a rebuild. Ignore the flag there, it's irrelevant for PCH use anyway.
216 gb_PrecompiledHeader_ignore_flags_for_flags_file := -Wunused-macros
218 # optimization level
219 gb_COMPILERNOOPTFLAGS := -O0 -Wp,-U_FORTIFY_SOURCE -fstrict-aliasing -fstrict-overflow
220 gb_COMPILERDEBUGOPTFLAGS := -Og
222 ifeq ($(OS),ANDROID)
223 gb_DEBUGINFO_FLAGS=-glldb
224 # Clang does not know -ggdb2 or some other options
225 else ifeq ($(HAVE_GCC_GGDB2),TRUE)
226 gb_DEBUGINFO_FLAGS=-ggdb2
227 else
228 gb_DEBUGINFO_FLAGS=-g2
229 endif
230 gb_LINKER_DEBUGINFO_FLAGS=
232 ifeq ($(HAVE_EXTERNAL_DWARF),TRUE)
233 gb_DEBUGINFO_FLAGS+=-gsplit-dwarf
234 # GCC 11 defaults to -gdwarf-5, which GDB 10 doesn't support in split debug info
235 ifeq ($(COM_IS_CLANG),)
236 gb_DEBUGINFO_FLAGS+=-gdwarf-4
237 endif
238 endif
240 ifeq ($(HAVE_CLANG_DEBUG_INFO_KIND_CONSTRUCTOR),TRUE)
241 gb_DEBUGINFO_FLAGS+=-Xclang -debug-info-kind=constructor
242 endif
244 ifeq ($(ENABLE_GDB_INDEX),TRUE)
245 gb_LINKER_DEBUGINFO_FLAGS += -Wl,--gdb-index
246 gb_DEBUGINFO_FLAGS += -ggnu-pubnames
247 endif
249 gb_LinkTarget_INCLUDE :=\
250 $(SOLARINC) \
251 -I$(BUILDDIR)/config_$(gb_Side) \
253 ifeq ($(COM_IS_CLANG),TRUE)
254 gb_COMPILER_TEST_FLAGS := -Xclang -plugin-arg-loplugin -Xclang --unit-test-mode
255 gb_COMPILER_PLUGINS := -Xclang -load -Xclang $(BUILDDIR)/compilerplugins/clang/plugin.so -Xclang -add-plugin -Xclang loplugin
256 ifneq ($(COMPILER_PLUGIN_WARNINGS_ONLY),)
257 gb_COMPILER_PLUGINS += -Xclang -plugin-arg-loplugin -Xclang \
258 --warnings-only='$(COMPILER_PLUGIN_WARNINGS_ONLY)'
259 endif
260 ifeq ($(COMPILER_PLUGINS_DEBUG),TRUE)
261 gb_COMPILER_PLUGINS += -Xclang -plugin-arg-loplugin -Xclang --debug
262 endif
263 gb_COMPILER_PLUGINS_TOOL := -Xclang -load -Xclang $(BUILDDIR)/compilerplugins/clang/plugin.so -Xclang -plugin -Xclang loplugin $(foreach plugin,$(COMPILER_PLUGIN_TOOL), -Xclang -plugin-arg-loplugin -Xclang $(plugin))
264 ifneq ($(UPDATE_FILES),)
265 gb_COMPILER_PLUGINS_TOOL += -Xclang -plugin-arg-loplugin -Xclang --scope=$(UPDATE_FILES)
266 endif
267 ifeq ($(COMPILER_PLUGINS_DEBUG),TRUE)
268 gb_COMPILER_PLUGINS_TOOL += -Xclang -plugin-arg-loplugin -Xclang --debug
269 endif
271 # Set CCACHE_CPP2=1 to prevent Clang generating spurious warnings.
273 # For Emscripten, the emcc command is a Python script that outputs annoying warnings like
274 # .../emscripten/tools/building.py:638: ResourceWarning: unclosed file <_io.TextIOWrapper name='/tmp/emscripten_temp_0fvvg__1/conftest.js.jso.js' mode='w' encoding='utf-8'>
275 # into stderr, which makes a configure script think that there is a problem in
276 # compiling even a microscopic test program with an option like -Werror which
277 # surely *is* supported. Avoid this by setting PYTHONWARNINGS=ignore.
279 gb_COMPILER_SETUP += CCACHE_CPP2=1 $(if $(filter EMSCRIPTEN,$(OS)),PYTHONWARNINGS=ignore)
280 gb_COMPILER_PLUGINS_SETUP := ICECC_EXTRAFILES=$(SRCDIR)/include/sal/log-areas.dox CCACHE_EXTRAFILES=$(SRCDIR)/include/sal/log-areas.dox SCCACHE_EXTRAFILES=$(SRCDIR)/include/sal/log-areas.dox
281 gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS := \
282 -Xclang -plugin-arg-loplugin -Xclang --warnings-as-errors
283 else
284 # Set CCACHE_CPP2 to prevent GCC -Werror=implicit-fallthrough= when ccache strips comments from C
285 # code (which still needs /*fallthrough*/-style comments to silence that warning):
286 ifeq ($(ENABLE_WERROR),TRUE)
287 gb_COMPILER_SETUP += CCACHE_CPP2=1
288 endif
289 gb_COMPILER_TEST_FLAGS :=
290 gb_COMPILER_PLUGINS :=
291 gb_COMPILER_PLUGINS_TOOL :=
292 gb_COMPILER_PLUGINS_SETUP :=
293 gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS :=
294 endif
296 # Executable class
298 gb_Executable_EXT_for_build :=
300 # Helper class
302 ifeq ($(OS_FOR_BUILD),MACOSX)
303 gb_Helper_LIBRARY_PATH_VAR := DYLD_LIBRARY_PATH
304 else ifeq ($(OS_FOR_BUILD),WNT)
305 # In theory possible if cross-compiling to some Unix from Windows,
306 # in practice strongly discouraged to even try that
307 gb_Helper_LIBRARY_PATH_VAR := PATH
308 else ifeq ($(OS_FOR_BUILD),HAIKU)
309 gb_Helper_LIBRARY_PATH_VAR := LIBRARY_PATH
310 else
311 gb_Helper_LIBRARY_PATH_VAR := LD_LIBRARY_PATH
312 endif
314 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)"
316 # $(1): list of : separated directory pathnames to append to the ld path
317 define gb_Helper_extend_ld_path
318 $(gb_Helper_set_ld_path):$(1)
319 endef
321 # Convert path to file URL.
322 define gb_Helper_make_url
323 file://$(strip $(1))
324 endef
326 gb_Helper_get_rcfile = $(1)rc
328 ifneq ($(gb_ENABLE_PCH),)
329 # Enable use of .sum files for PCHs.
330 gb_COMPILER_SETUP += CCACHE_PCH_EXTSUM=1
331 endif
333 # vim: set noet sw=4: