diff options
| author | Xavier Claessens <xavier.claessens@collabora.com> | 2023-10-16 14:35:25 -0400 |
|---|---|---|
| committer | Xavier Claessens <xclaesse@gmail.com> | 2023-10-19 08:13:57 -0400 |
| commit | e2a87afa52612c9ec6fd825e115838323ba13936 (patch) | |
| tree | fc74c96f26f42de9a2131b2847f30c1542a0ae9d /mesonbuild/compilers/rust.py | |
| parent | 361f7484d2fe9d1cf03b66a66d785618694aa62c (diff) | |
| download | meson-e2a87afa52612c9ec6fd825e115838323ba13936.tar.gz | |
rust: Always link dll and exe with the correct vscrt
This fixes missing flags in the link_whole case and link failure for
static libraries.
Diffstat (limited to 'mesonbuild/compilers/rust.py')
| -rw-r--r-- | mesonbuild/compilers/rust.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/mesonbuild/compilers/rust.py b/mesonbuild/compilers/rust.py index b5e6a6a0c..1fb94aa44 100644 --- a/mesonbuild/compilers/rust.py +++ b/mesonbuild/compilers/rust.py @@ -55,6 +55,17 @@ class RustCompiler(Compiler): '3': ['-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 + 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'], + } + def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice, is_cross: bool, info: 'MachineInfo', exe_wrapper: T.Optional['ExternalProgram'] = None, @@ -177,6 +188,11 @@ class RustCompiler(Compiler): # Rust handles this for us, we don't need to do anything return [] + def get_crt_link_args(self, crt_val: str, buildtype: str) -> T.List[str]: + if self.linker.id not in {'link', 'lld-link'}: + return [] + return self.MSVCRT_ARGS[self.get_crt_val(crt_val, buildtype)] + def get_colorout_args(self, colortype: str) -> T.List[str]: if colortype in {'always', 'never', 'auto'}: return [f'--color={colortype}'] |
