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/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 # please make generic Windows modifications to windows.mk
21 include $(GBUILDDIR
)/platform
/windows.mk
31 # use CC/CXX if they are nondefaults
32 ifneq ($(origin CC
),default
)
36 ifneq ($(origin CXX
),default
)
40 # _SILENCE_CXX23_DENORM_DEPRECATION_WARNING is needed at least with Boost 1.82.0 using
41 # std::numeric_limits::has_denorm in
42 # workdir/UnpackedTarball/boost/boost/spirit/home/classic/core/primitives/impl/numerics.ipp, in turn
43 # included from boost/spirit/include/classic_core.hpp as included from various of our code files:
45 # _SCL_SECURE_NO_WARNINGS avoids deprecation warnings for STL algorithms
46 # like std::copy, std::transform (when MSVC_USE_DEBUG_RUNTIME is enabled)
49 -DBOOST_OPTIONAL_USE_OLD_DEFINITION_OF_NONE \
50 -DBOOST_SYSTEM_NO_DEPRECATED \
51 -D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING \
52 -D_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING \
53 -D_SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING \
54 -D_SILENCE_CXX23_DENORM_DEPRECATION_WARNING \
55 -D_CRT_NON_CONFORMING_SWPRINTFS \
56 -D_CRT_NONSTDC_NO_DEPRECATE \
57 -D_CRT_SECURE_NO_DEPRECATE \
58 -D_SCL_SECURE_NO_WARNINGS \
61 -DCPPU_ENV
=$(CPPU_ENV
) \
63 ifeq ($(CPUNAME
),INTEL
)
65 -DBOOST_MEM_FN_ENABLE_CDECL \
70 $(gb_WIN_VERSION_DEFS
) \
74 gb_AFLAGS
:= $(AFLAGS
)
76 # Do we really need to disable this many warnings? It seems to me that
77 # many of these warnings are for constructs that we have been actively
78 # cleaning away from the code, to avoid warnings when building with
79 # gcc or Clang and -Wall -Werror.
81 # C4127: conditional expression is constant
83 # C4201: nonstandard extension used : nameless struct/union
85 # C4244: 'argument' : conversion from 'type1' to 'type2', possible loss of data
87 # C4250: 'class1' : inherits 'class2::member' via dominance
89 # C4251: 'identifier' : class 'type' needs to have dll-interface to be
90 # used by clients of class 'type2'
92 # C4267: conversion from 'size_t' to 'type', possible loss of data
94 # C4275: non-DLL-interface classkey 'identifier' used as base for
95 # DLL-interface classkey 'identifier'
97 # C4505: 'function' : unreferenced local function has been removed
99 # C4611: interaction between 'function' and C++ object destruction is
102 # C4702: unreachable code
104 # C4706: assignment within conditional expression
106 # build-time penalty is too high for ci use/disable when JENKINS_HOME is set
107 MSVC_ANALYZE_FLAGS
:= $(if
$(ENABLE_MSVC_ANALYZE
),-analyze
:ruleset
$(SRCDIR
)/solenv
/vs
/LibreOffice.ruleset
,)
109 gb_FilterOutClangCFLAGS
+= $(MSVC_ANALYZE_FLAGS
)
117 $(if
$(MSVC_USE_DEBUG_RUNTIME
),-MDd
,-MD
) \
124 gb_CXXFLAGS_DISABLE_WARNINGS
= -w
134 $(if
$(MSVC_USE_DEBUG_RUNTIME
),-MDd
,-MD
) \
148 $(if
$(ENABLE_DEBUG
),$(MSVC_ANALYZE_FLAGS
),) \
150 ifneq ($(COM_IS_CLANG
),TRUE
)
151 gb_CXXFLAGS
+= -Zc
:inline
152 gb_CXXFLAGS_ZCINLINE_OFF
:= -Zc
:inline-
155 ifeq ($(CPUNAME
),INTEL
)
165 ifeq ($(HAVE_DLLEXPORTINLINES
),TRUE
)
166 gb_CXXFLAGS
+= -Zc
:dllexportInlines-
169 gb_CXXFLAGS_include
:= -FI
170 ifeq ($(COM_IS_CLANG
),TRUE
)
171 gb_CXXFLAGS_no_pch_warnings
:= -Wno-clang-cl-pch
174 ifneq ($(COM_IS_CLANG
),TRUE
)
176 # Work around MSVC 2017 C4702 compiler bug with release builds
177 # https://lists.freedesktop.org/archives/libreoffice/2018-July/080532.html
178 # https://lists.freedesktop.org/archives/libreoffice/2018-August/080776.html
180 $(if
$(ENABLE_OPTIMIZED
),-wd4702
) \
184 # rc.exe does not support -nologo in 6.1.6723.1 that is in the Windows SDK 6.0A
185 gb_RCFLAGS
+= -nologo
187 # C4005: 'identifier' : macro redefinition
199 gb_CFLAGS_WERROR
= $(if
$(ENABLE_WERROR
),-WX
)
201 # there does not seem to be a way to force C++03 with MSVC, nor with clang-cl against MSVC system
202 # headers; the oldest version that MSVC supports is C++14, so use that as a rather imperfect
204 gb_CXX03FLAGS
:= -std
:c
++14
206 gb_LinkTarget_EXCEPTIONFLAGS
:= \
209 gb_PrecompiledHeader_EXCEPTIONFLAGS
:= $(gb_LinkTarget_EXCEPTIONFLAGS
)
211 ifneq ($(gb_ENABLE_PCH
),)
212 ifeq ($(COM_IS_CLANG
),TRUE
)
213 # the same as in com_GCC_defs.mk
214 gb_NO_PCH_TIMESTAMP
:= -Xclang
-fno-pch-timestamp
218 gb_LinkTarget_LDFLAGS
:= \
219 $(if
$(findstring s
,$(filter-out --%,$(MAKEFLAGS
))),-nologo
,) \
220 $(patsubst %,-LIBPATH
:%,$(filter-out .
,$(subst ;, ,$(subst \
,/,$(ILIB
))))) \
222 # Prevent warning spamming
223 # Happens because of the way we link our unit tests with our libraries.
224 # LNK4049: locally defined symbol
225 gb_LinkTarget_LDFLAGS
+= \
226 /ignore
:4217 /ignore
:4049
229 ifeq ($(ENABLE_Z7_DEBUG
),)
230 gb_DEBUGINFO_FLAGS
:= \
235 # ccache does not work with -Zi
236 gb_DEBUGINFO_FLAGS
:= \
241 # See gb_Windows_PE_TARGETTYPEFLAGS_DEBUGINFO
242 gb_LINKER_DEBUGINFO_FLAGS
:=
244 gb_COMPILEROPTFLAGS
:= -O2
-Oy-
245 gb_COMPILERNOOPTFLAGS
:= -Od
246 gb_COMPILERDEBUGOPTFLAGS
:=
248 ifeq ($(gb_FULLDEPS
),$(true
))
249 gb_COMPILERDEPFLAGS
:= -showIncludes
250 define gb_create_deps
251 |
$(GBUILDDIR
)/platform
/filter-showIncludes.awk
-vdepfile
=$(1) -vobjectfile
=$(2) -vsourcefile
=$(3); exit
$${PIPESTATUS
[0]}
254 gb_COMPILERDEPFLAGS
:=
255 define gb_create_deps
256 |
$(GBUILDDIR
)/platform
/filter-sourceName.awk
; exit
$${PIPESTATUS
[0]}
260 gb_LTOFLAGS
:= $(if
$(filter TRUE
,$(ENABLE_LTO
)),-GL
)
262 # VS2019 produces a warning C4857, that it doesn't support -std:c++20; it can't
263 # be suppressed by -wd4857, only by -Wv:18. The warning seems incorrect, because
264 # using -std:c++17 produces errors about undeclared 'char8_t'. VS2022 doesn't
265 # have the problem, so drop -Wv:18 when bumping baseline.
266 # Similarly, at least VS2022 Preview 17.12.0 Preview 2.1 with --with-latest-c++ emits a "warning
267 # C4857: C++/CLI mode does not support C++ versions newer than C++20; setting language to
268 # /std:c++20" that cannot be disabled by adding -wd4857, so hardcode a -std:c++20 substitution in
271 $(if
$(COM_IS_CLANG
), \
272 $(patsubst -std
=%,-std
:c
++20 -Zc
:__cplusplus
,$(gb_CXXFLAGS
)), \
273 $(if
$(filter -std
:c
++latest
,$(CXXFLAGS_CXX11
)), \
274 $(patsubst -std
:c
++latest
,-std
:c
++20,$(gb_CXXFLAGS
)), \
276 $(gb_LinkTarget_EXCEPTIONFLAGS
) \
277 -AI
$(INSTDIR
)/$(LIBO_URE_LIB_FOLDER
) \
280 $(if
$(filter 16.0,$(VCVER
)),-Wv
:18) \
284 ifeq ($(COM_IS_CLANG
),TRUE
)
289 -Wstrict-prototypes \
295 -Wimplicit-fallthrough \
296 -Wno-missing-braces \
297 -Woverloaded-virtual \
304 ifeq ($(COM_IS_CLANG
),TRUE
)
305 gb_COMPILER_TEST_FLAGS
:= -Xclang
-plugin-arg-loplugin
-Xclang
--unit-test-mode
306 gb_COMPILER_PLUGINS
:= -Xclang
-load
-Xclang
$(BUILDDIR
)/compilerplugins
/clang
/plugin.dll
-Xclang
-add-plugin
-Xclang loplugin
307 ifneq ($(COMPILER_PLUGIN_WARNINGS_ONLY
),)
308 gb_COMPILER_PLUGINS
+= -Xclang
-plugin-arg-loplugin
-Xclang \
309 --warnings-only
='$(COMPILER_PLUGIN_WARNINGS_ONLY)'
311 ifeq ($(COMPILER_PLUGINS_DEBUG
),TRUE
)
312 gb_COMPILER_PLUGINS
+= -Xclang
-plugin-arg-loplugin
-Xclang
--debug
314 gb_COMPILER_PLUGINS_TOOL
:= -Xclang
-load
-Xclang
$(BUILDDIR
)/compilerplugins
/clang
/plugin.dll
-Xclang
-plugin
-Xclang loplugin
$(foreach plugin
,$(COMPILER_PLUGIN_TOOL
), -Xclang
-plugin-arg-loplugin
-Xclang
$(plugin
))
315 ifneq ($(UPDATE_FILES
),)
316 gb_COMPILER_PLUGINS_TOOL
+= -Xclang
-plugin-arg-loplugin
-Xclang
--scope
=$(UPDATE_FILES
)
318 ifeq ($(COMPILER_PLUGINS_DEBUG
),TRUE
)
319 gb_COMPILER_PLUGINS_TOOL
+= -Xclang
-plugin-arg-loplugin
-Xclang
--debug
321 gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS
:= \
322 -Xclang
-plugin-arg-loplugin
-Xclang
--warnings-as-errors
324 gb_COMPILER_TEST_FLAGS
:=
325 gb_COMPILER_PLUGINS
:=
326 gb_COMPILER_PLUGINS_TOOL
:=
327 gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS
:=
332 gb_Helper_set_ld_path
:= $(call gb_Helper_cyg_path
,PATH
="$(INSTDIR_FOR_BUILD)/$(LIBO_URE_LIB_FOLDER):$(INSTDIR_FOR_BUILD)/$(LIBO_BIN_FOLDER):$$PATH")
334 define gb_Helper_prepend_ld_path
335 PATH
="$(call gb_Helper_cyg_path,$(INSTDIR_FOR_BUILD)/$(LIBO_URE_LIB_FOLDER):$(INSTDIR_FOR_BUILD)/$(LIBO_BIN_FOLDER):$(1):$$PATH")
338 # $(1): one directory pathname to append to the ld path
339 define gb_Helper_extend_ld_path
340 $(gb_Helper_set_ld_path
)':$(call gb_Helper_cyg_path,$(1))'
343 # common macros to build GPG related libraries
344 # we explicitly have to replace cygwin with mingw32 for the host, but the build must stay cygwin, or cmd.exe processes will be spawned
345 gb_WIN_GPG_WINDRES_target
:= $(if
$(filter INTEL
,$(CPUNAME
)),pe-i386
,pe-x86-64
)
346 gb_WIN_GPG_platform_switches
:= --build
=$(BUILD_PLATFORM
) --host
=$(subst cygwin
,mingw32
,$(HOST_PLATFORM
))
347 gb_WIN_GPG_cross_setup_exports
= export REAL_BUILD_CC
="$(filter-out -%,$(CC_FOR_BUILD))" REAL_BUILD_CC_FLAGS
="$(filter -%,$(CC_FOR_BUILD))" \
348 && export CC_FOR_BUILD
="$(call gb_Executable_get_target_for_build,gcc-wrapper) --wrapper-env-prefix=REAL_BUILD_ $(SOLARINC) -L$(subst ;, -L,$(ILIB_FOR_BUILD))" \
349 && export RC
='windres -O COFF --target=$(gb_WIN_GPG_WINDRES_target) --preprocessor=$(call gb_Executable_get_target_for_build,cpp) --preprocessor-arg=-+ -DRC_INVOKED -DWINAPI_FAMILY=0 $(SOLARINC)'
351 ifneq ($(gb_ENABLE_PCH
),)
352 # Enable use of .sum files for PCHs.
353 gb_COMPILER_SETUP
+= CCACHE_PCH_EXTSUM
=1
356 # vim: set noet sw=4: