diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2025-10-13 12:19:21 +0200 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2025-10-14 09:22:08 -0700 |
| commit | 7bae4ed773f9ecca1e0e737461bf5e5aabb68812 (patch) | |
| tree | 32be5d2dca8ec5302d04ecc80bf31cd6a4cc9f03 | |
| parent | 5cc1ee7f90da50f40a3263f9e63d9e356dda197c (diff) | |
| download | meson-7bae4ed773f9ecca1e0e737461bf5e5aabb68812.tar.gz | |
compilers: clang: pass /nodefaultlib
Work around https://github.com/llvm/llvm-project/issues/129881.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
| -rw-r--r-- | docs/markdown/snippets/b_msvcrt_clang.md | 2 | ||||
| -rw-r--r-- | mesonbuild/compilers/mixins/clang.py | 25 |
2 files changed, 18 insertions, 9 deletions
diff --git a/docs/markdown/snippets/b_msvcrt_clang.md b/docs/markdown/snippets/b_msvcrt_clang.md index 2a509bda6..ab381f9c5 100644 --- a/docs/markdown/snippets/b_msvcrt_clang.md +++ b/docs/markdown/snippets/b_msvcrt_clang.md @@ -2,3 +2,5 @@ `-Db_msvcrt` will now link the appropriate runtime library, and set the appropriate preprocessor symbols, also when the compiler is clang. +This is only supported when using `link.exe` or `lld-link.exe` as the +linker. diff --git a/mesonbuild/compilers/mixins/clang.py b/mesonbuild/compilers/mixins/clang.py index 3b22ec388..8351672a1 100644 --- a/mesonbuild/compilers/mixins/clang.py +++ b/mesonbuild/compilers/mixins/clang.py @@ -54,23 +54,26 @@ class ClangCompiler(GnuLikeCompiler): id = 'clang' - # -fms-runtime-lib is not supported together with -c, emulate it + # -fms-runtime-lib is a compilation option which sets up an automatic dependency + # from the .o files to the final link product CRT_D_ARGS: T.Dict[str, T.List[str]] = { 'none': [], - 'md': ['-D_MT', '-D_DLL'], - 'mdd': ['-D_MT', '-D_DLL', '-D_DEBUG'], - 'mt': ['-D_MT'], - 'mtd': ['-D_MT', '-D_DEBUG'], - } - - CRT_ARGS: T.Dict[str, T.List[str]] = { - 'none': [], 'md': ['-fms-runtime-lib=dll'], 'mdd': ['-fms-runtime-lib=dll_dbg'], 'mt': ['-fms-runtime-lib=static'], 'mtd': ['-fms-runtime-lib=static_dbg'], } + # disable libcmt to avoid warnings, as that is the default and clang + # adds it by default. + CRT_ARGS: T.Dict[str, T.List[str]] = { + 'none': [], + 'md': ['-Wl,/nodefaultlib:libcmt'], + 'mdd': ['-Wl,/nodefaultlib:libcmt'], + 'mt': [], + 'mtd': ['-Wl,/nodefaultlib:libcmt'], + } + def __init__(self, defines: T.Optional[T.Dict[str, str]]): super().__init__() self.defines = defines or {} @@ -88,10 +91,14 @@ class ClangCompiler(GnuLikeCompiler): self.can_compile_suffixes.add('ll') def get_crt_compile_args(self, crt_val: str, buildtype: str) -> T.List[str]: + if not isinstance(self.linker, VisualStudioLikeLinkerMixin): + return [] crt_val = self.get_crt_val(crt_val, buildtype) return self.CRT_D_ARGS[crt_val] def get_crt_link_args(self, crt_val: str, buildtype: str) -> T.List[str]: + if not isinstance(self.linker, VisualStudioLikeLinkerMixin): + return [] crt_val = self.get_crt_val(crt_val, buildtype) return self.CRT_ARGS[crt_val] |
