diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2025-11-12 19:11:03 +0100 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2025-11-12 14:56:22 -0800 |
| commit | 2ea823c80a89c8fca258a1fc3580bd27c5eec3be (patch) | |
| tree | b77e1b8cbffe4dd64d7be184af9f725feff7f212 | |
| parent | e9c6262d1d46a20b909562827a4312aca86a29f2 (diff) | |
| download | meson-2ea823c80a89c8fca258a1fc3580bd27c5eec3be.tar.gz | |
rust: use proper linker arguments to get the MSVC runtime library
Follow the suggestion in https://github.com/rust-lang/rust/issues/39016#issuecomment-2391095973
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
| -rw-r--r-- | mesonbuild/compilers/rust.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/mesonbuild/compilers/rust.py b/mesonbuild/compilers/rust.py index acd1344c6..32b8d8dae 100644 --- a/mesonbuild/compilers/rust.py +++ b/mesonbuild/compilers/rust.py @@ -88,15 +88,14 @@ class RustCompiler(Compiler): 'everything': ['-W', 'warnings'], } - # Those are static libraries, but we use dylib= here as workaround to avoid - # rust --tests to use /WHOLEARCHIVE. - # https://github.com/rust-lang/rust/issues/116910 + # libcore can be compiled with either static or dynamic CRT, so disable + # both of them just in case. MSVCRT_ARGS: T.Mapping[str, T.List[str]] = { 'none': [], - 'md': [], # this is the default, no need to inject anything - 'mdd': ['-l', 'dylib=msvcrtd'], - 'mt': ['-l', 'dylib=libcmt'], - 'mtd': ['-l', 'dylib=libcmtd'], + 'md': ['-Clink-arg=/nodefaultlib:libcmt', '-Clink-arg=/defaultlib:msvcrt'], + 'mdd': ['-Clink-arg=/nodefaultlib:libcmt', '-Clink-arg=/nodefaultlib:msvcrt', '-Clink-arg=/defaultlib:msvcrtd'], + 'mt': ['-Clink-arg=/defaultlib:libcmt', '-Clink-arg=/nodefaultlib:msvcrt'], + 'mtd': ['-Clink-arg=/nodefaultlib:libcmt', '-Clink-arg=/nodefaultlib:msvcrt', '-Clink-arg=/defaultlib:libcmtd'], } def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice, |
