diff options
-rw-r--r-- | docs/markdown/Builtin-options.md | 24 | ||||
-rw-r--r-- | mesonbuild/backend/vs2010backend.py | 7 | ||||
-rw-r--r-- | mesonbuild/compilers/compilers.py | 2 | ||||
-rw-r--r-- | mesonbuild/compilers/d.py | 16 | ||||
-rw-r--r-- | mesonbuild/compilers/mixins/visualstudio.py | 15 |
5 files changed, 41 insertions, 23 deletions
diff --git a/docs/markdown/Builtin-options.md b/docs/markdown/Builtin-options.md index 05ff4ff..febcc8a 100644 --- a/docs/markdown/Builtin-options.md +++ b/docs/markdown/Builtin-options.md @@ -126,23 +126,23 @@ platforms or with all compilers: | b_sanitize | none | see below | Code sanitizer to use | | b_staticpic | true | true, false | Build static libraries as position independent | | b_pie | false | true, false | Build position-independent executables (since 0.49.0)| -| b_vscrt | from_buildtype| none, md, mdd, mt, mtd, from_buildtype | VS runtime library to use (since 0.48.0) | +| b_vscrt | from_buildtype| none, md, mdd, mt, mtd, from_buildtype, static_from_buildtype | VS runtime library to use (since 0.48.0) (static_from_buildtype since 0.56.0) | The value of `b_sanitize` can be one of: `none`, `address`, `thread`, `undefined`, `memory`, `address,undefined`. <a name="b_vscrt-from_buildtype"></a> -The default value of `b_vscrt` is `from_buildtype`. In that case, the following -table is used internally to pick the CRT compiler arguments based on the value -of the `buildtype` option: - -| buildtype | Visual Studio CRT | -| -------- | ----------------- | -| debug | `/MDd` | -| debugoptimized | `/MD` | -| release | `/MD` | -| minsize | `/MD` | -| custom | error! | +The default value of `b_vscrt` is `from_buildtype`. The following table is used +internally to pick the CRT compiler arguments for `from_buildtype` or +`static_from_buildtype` *(since 0.56)* based on the value of the `buildtype` option: + +| buildtype | from_buildtype | static_from_buildtype | +| -------- | -------------- | --------------------- | +| debug | `/MDd` | `/MTd` | +| debugoptimized | `/MD` | `/MT` | +| release | `/MD` | `/MT` | +| minsize | `/MD` | `/MT` | +| custom | error! | error! | ### Notes about Apple Bitcode support diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index 08360d3..6edf36a 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -838,6 +838,13 @@ class Vs2010Backend(backends.Backend): else: ET.SubElement(type_config, 'UseDebugLibraries').text = 'false' ET.SubElement(clconf, 'RuntimeLibrary').text = 'MultiThreadedDLL' + elif vscrt_type.value == 'static_from_buildtype': + if self.buildtype == 'debug': + ET.SubElement(type_config, 'UseDebugLibraries').text = 'true' + ET.SubElement(clconf, 'RuntimeLibrary').text = 'MultiThreadedDebug' + else: + ET.SubElement(type_config, 'UseDebugLibraries').text = 'false' + ET.SubElement(clconf, 'RuntimeLibrary').text = 'MultiThreaded' elif vscrt_type.value == 'mdd': ET.SubElement(type_config, 'UseDebugLibraries').text = 'true' ET.SubElement(clconf, 'RuntimeLibrary').text = 'MultiThreadedDebugDLL' diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index fa1046a..fd3bdb7 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -289,7 +289,7 @@ base_options = {'b_pch': coredata.UserBooleanOption('Use precompiled headers', T 'b_bitcode': coredata.UserBooleanOption('Generate and embed bitcode (only macOS/iOS/tvOS)', False), 'b_vscrt': coredata.UserComboOption('VS run-time library type to use.', - ['none', 'md', 'mdd', 'mt', 'mtd', 'from_buildtype'], + ['none', 'md', 'mdd', 'mt', 'mtd', 'from_buildtype', 'static_from_buildtype'], 'from_buildtype'), } # type: OptionDictType diff --git a/mesonbuild/compilers/d.py b/mesonbuild/compilers/d.py index 630291a..95850ea 100644 --- a/mesonbuild/compilers/d.py +++ b/mesonbuild/compilers/d.py @@ -389,19 +389,25 @@ class DmdLikeCompilerMixin(CompilerMixinBase): if crt_val in self.mscrt_args: return self.mscrt_args[crt_val] - assert(crt_val == 'from_buildtype') + assert(crt_val in ['from_buildtype', 'static_from_buildtype']) + + dbg = 'mdd' + rel = 'md' + if crt_val == 'static_from_buildtype': + dbg = 'mtd' + rel = 'mt' # Match what build type flags used to do. if buildtype == 'plain': return [] elif buildtype == 'debug': - return self.mscrt_args['mdd'] + return self.mscrt_args[dbg] elif buildtype == 'debugoptimized': - return self.mscrt_args['md'] + return self.mscrt_args[rel] elif buildtype == 'release': - return self.mscrt_args['md'] + return self.mscrt_args[rel] elif buildtype == 'minsize': - return self.mscrt_args['md'] + return self.mscrt_args[rel] else: assert(buildtype == 'custom') raise EnvironmentException('Requested C runtime based on buildtype, but buildtype is "custom".') diff --git a/mesonbuild/compilers/mixins/visualstudio.py b/mesonbuild/compilers/mixins/visualstudio.py index 75ab635..3e8b8e3 100644 --- a/mesonbuild/compilers/mixins/visualstudio.py +++ b/mesonbuild/compilers/mixins/visualstudio.py @@ -362,18 +362,23 @@ class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta): def get_crt_compile_args(self, crt_val: str, buildtype: str) -> T.List[str]: if crt_val in self.crt_args: return self.crt_args[crt_val] - assert(crt_val == 'from_buildtype') + assert(crt_val in ['from_buildtype', 'static_from_buildtype']) + dbg = 'mdd' + rel = 'md' + if crt_val == 'static_from_buildtype': + dbg = 'mtd' + rel = 'mt' # Match what build type flags used to do. if buildtype == 'plain': return [] elif buildtype == 'debug': - return self.crt_args['mdd'] + return self.crt_args[dbg] elif buildtype == 'debugoptimized': - return self.crt_args['md'] + return self.crt_args[rel] elif buildtype == 'release': - return self.crt_args['md'] + return self.crt_args[rel] elif buildtype == 'minsize': - return self.crt_args['md'] + return self.crt_args[rel] else: assert(buildtype == 'custom') raise mesonlib.EnvironmentException('Requested C runtime based on buildtype, but buildtype is "custom".') |