xref: /trunk/main/solenv/inc/wntmsc14.mk (revision 91144cd0085a7583d2099b982122deb2184ab956)
1#**************************************************************
2#
3#  Licensed to the Apache Software Foundation (ASF) under one
4#  or more contributor license agreements.  See the NOTICE file
5#  distributed with this work for additional information
6#  regarding copyright ownership.  The ASF licenses this file
7#  to you under the Apache License, Version 2.0 (the
8#  "License"); you may not use this file except in compliance
9#  with the License.  You may obtain a copy of the License at
10#
11#    http://www.apache.org/licenses/LICENSE-2.0
12#
13#  Unless required by applicable law or agreed to in writing,
14#  software distributed under the License is distributed on an
15#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16#  KIND, either express or implied.  See the License for the
17#  specific language governing permissions and limitations
18#  under the License.
19#
20#**************************************************************
21
22# mk file for $(COMEX) == 14 -- the UCRT compiler generation, i.e. VS2015
23# (cl 19.00) and every toolset since.
24#
25# This is included at the END of wntmsci11.mk (x86) and wntmscx.mk (x64), so
26# it holds ONLY what differs from VC9 and nothing the two generations share.
27# Two things follow from that shape and both are deliberate:
28#
29#   * a VC9 build is byte-identical.  Nothing here is reached at COMEX 12 --
30#     there is no condition inside this file, because the file itself is the
31#     condition.
32#
33#   * the two architectures cannot drift.  Every line below is either
34#     architecture-neutral or branches on $(CPU) in one place, rather than
35#     being written out twice.
36
37# --- C++ dialect ---------------------------------------------------------
38
39# C++14, not 17.  Three things in this tree depend on the dialect and all
40# three say 14:
41#
42#   * std::tr1.  The MSVC standard library still ships it, but only while
43#     _HAS_CXX17 is 0 -- and boost/tr1 and the shims in main/stlport reach for
44#     std::tr1 by name.
45#   * the empty exception specification.  throw() is deprecated in C++17 and
46#     removed in C++20, and there are still thousands of them here; migrating
47#     them to noexcept is a separate change.
48#   * <hash_map> and <hash_set>, which a modern MSVC turns into a hard #error
49#     under C++17.
50#
51# There is no /std:c++03 to fall back to -- a modern cl rejects it outright
52# (D9002) -- so C++14 is the floor whether or not it is chosen.
53CFLAGSCXX+=-std:c++14
54
55# Report the real __cplusplus.  Without this MSVC reports 199711L whatever
56# /std: says, and the shims in main/stlport/systemstl branch on
57# __cplusplus >= 201103L to decide whether <hash_map> can forward to
58# <unordered_map>.  Left off, they take the pre-C++11 branch and reach for
59# boost/tr1 instead.
60CFLAGSCXX+=-Zc:__cplusplus
61
62# --- the CRT -------------------------------------------------------------
63
64# The two halves of the old snprintf shim are NOT symmetric, which is easy to
65# get wrong in either direction:
66#
67#   * snprintf -- the UCRT declares a real, conforming one.  Defining the name
68#     away would be a redefinition with different linkage that it refuses to
69#     compile (C1189), so the shim is dropped.
70#     sal/inc/systools/win32/snprintf.h drops its own declarations on the same
71#     condition, and so does uwinapi's implementation of them.
72#   * snwprintf -- the UCRT declares no such thing.  The wide C99 name has
73#     never existed in any MSVC CRT; only _snwprintf does.  So this half stays,
74#     and the bare calls in svx's sendreportw32.cxx and framework's
75#     spinfieldtoolbarcontroller.cxx keep compiling.
76CDEFS+=-Dsnwprintf=_snwprintf
77
78# stdext::hash_map and stdext::hash_set are deprecated to the point of a hard
79# #error.  The tree reaches them through the stlport shims in a great many
80# places; these are the stdext containers, not std::unordered_map, so
81# replacing them is a refactor and not a build fix.
82CDEFS+=-D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
83
84# The CRT split in three when the UCRT arrived: a startup/import library, the
85# compiler runtime, and the C library proper.  Normally cl emits /DEFAULTLIB
86# directives naming all three -- but this build links with -NODEFAULTLIB, so
87# anything not named here is not linked.  The first of the three is already in
88# LIBCMT from the base file; these are the other two.
89#
90# They MUST follow the same static/dynamic choice the base file made, or the
91# link mixes the two models: a module setting DYNAMIC_CRT= (sal's kill is the
92# one that does) gets libcmt.lib and then fails on __except_handler4, which
93# lives in libvcruntime.lib and not in the import library of the same name.
94# Named as well as appended, because appending only reaches a module that lets
95# LIBCMT alone.  embedserv's in-process server REPLACES it outright -- it wants
96# the static CRT whatever the rest of the build is doing -- and an append made
97# before that assignment is simply lost.  Such a module names the matching
98# variable instead, which is empty on VC9 and so changes nothing there.
99LIBCRTEXTRA_DYNAMIC=vcruntime.lib ucrt.lib
100LIBCRTEXTRA_STATIC=libvcruntime.lib libucrt.lib
101
102.IF "$(DYNAMIC_CRT)"!=""
103LIBCMT+=$(LIBCRTEXTRA_DYNAMIC)
104.ELSE
105LIBCMT+=$(LIBCRTEXTRA_STATIC)
106.ENDIF
107
108# --- what the modern toolchain removed -----------------------------------
109
110# -Yd (write debug info into every object that uses the precompiled header)
111# was removed after VC9.  -Z7 alone already does what this build wants, which
112# is debug information inside the object rather than in a separate .pdb that
113# every compile would have to serialise on.
114CFLAGSENABLESYMBOLS=-Z7
115
116# ATL and MFC are deliberately NOT set here.  configure already computes
117# ATL_INCLUDE / ATL_LIB / ATL_LIB_X64 / MFC_INCLUDE / MFC_LIB, honours
118# --with-atl-include-dir and friends, and then VALIDATES the result by looking
119# for atlbase.h and atls.lib -- and it exports them, which is why the base
120# file assigns them with *= (only if unset) rather than plainly.  Assigning
121# them here would override both configure's checked value and the user's
122# explicit flag with a guess.
123#
124# The guess would often be wrong, too: the "C++ ATL" component is a separate
125# Visual Studio install option, so a BuildTools installation frequently has no
126# atlmfc directory under the toolset at all.  Builds that need ATL point at
127# whichever copy they have -- commonly the WinDDK one -- through the configure
128# options, and that keeps working here unchanged.
129
130# --- warnings ------------------------------------------------------------
131
132# The base warning list was written against VC9 and is kept as it is; these
133# are the ones a modern cl adds in volume, and each is a report about old
134# code rather than about a defect this build introduced:
135#
136#   C4996 -- "was declared deprecated".  The tree calls the POSIX and
137#            non-secure CRT names throughout.  _CRT_SECURE_NO_DEPRECATE and
138#            _CRT_NONSTDC_NO_DEPRECATE, already set in the base file, silence
139#            most but not all of them.
140#   C4577 -- "noexcept used with no exception handling mode specified".  This
141#            build compiles with -EHa, which does specify one; the warning
142#            fires anyway on the empty specifications the tree is still full
143#            of.
144#   C5040 -- an exception specification on a function pointer type is
145#            non-standard.  Same population, same reason.
146CFLAGSWARNCXX+=-wd4996 -wd4577 -wd5040
147CFLAGSWARNCC+=-wd4996
148CFLAGSWALLCC=$(CFLAGSWARNCC)
149CFLAGSWALLCXX=$(CFLAGSWARNCXX)
150
151# --- subsystem version ---------------------------------------------------
152
153# /SUBSYSTEM:WINDOWS takes an optional version and the base files pass it
154# without one, so the value is whatever the linker happens to default to.  That
155# default is NOT stable across toolsets: VC9 emitted a 5.x subsystem, every
156# toolset from VS2015 on emits 6.00.  The same makefile line therefore silently
157# changed what these binaries claim about themselves, and that is not cosmetic
158# -- Windows reads the subsystem version to pick which drag-and-drop
159# implementation a process gets.
160#
161# At 6.00 a drop target is resolved through the brokered path in ole32
162# (CDragOperation::GetDropTarget -> PrivDragDrop -> SDDInfo::SDDInfo ->
163# UnmarshalFromEndpointProperty).  Every drop into this office dies there with
164# E_INVALIDARG before any of our own code runs: RegisterDragDrop succeeds and
165# the frame carries both the OleDropTargetInterface and OleEndPointID window
166# properties, yet IDropTarget::DragEnter is never called and the pointer stays
167# "unavailable" -- which is the whole of the "cannot drag anything into the
168# office" report.  Below 6.00 the classic path is used and drops work.
169#
170# Measured, not inferred: patching these four bytes and nothing else in one
171# soffice.exe flips it.  At 6.00 PrivDragDrop returns 0x80070057 and the cursor
172# is IDC_NO; at 5.02 it returns S_OK and the drop is offered and accepted.
173#
174# So pin it, per architecture, to the lowest version its linker accepts -- the
175# same neighbourhood the office shipped in for its whole VC9 life.  Note this
176# restores the classic path rather than making our drop targets work with the
177# brokered one; why they are rejected there is a separate, still unexplained
178# incompatibility.  The version only matters on the executable, since that is
179# what the loader reads for the process, but both flags are set so the pair
180# cannot drift apart.
181.IF "$(CPU)" == "X"
182LINKFLAGSAPPGUI=/SUBSYSTEM:WINDOWS,5.02
183LINKFLAGSSHLGUI=/SUBSYSTEM:WINDOWS,5.02 /DLL
184.ELSE
185LINKFLAGSAPPGUI=/SUBSYSTEM:WINDOWS,5.01
186LINKFLAGSSHLGUI=/SUBSYSTEM:WINDOWS,5.01 /DLL
187.ENDIF
188