From f404c679cf292e6a7cf3886cd94511602c1c09f9 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 16 Dec 2019 11:31:24 -0800 Subject: compilers/d: Fix get_allow_undefined_link_args on macOS DMD and LDC are a real pain to use as linkers. On Unices they invoke the C compiler as the linker, just like meson does. This means we have to figure out what C compiler they're using and try to pass valid arguments to that compiler if the D compiler doesn't understand the linker arguments we want to pass. In this case that means gcc or clang. We can use-the -Xcc to pass arguments directly to the C compiler without dmd/ldc getting involved, so we'll use that. --- mesonbuild/compilers/d.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'mesonbuild/compilers/d.py') diff --git a/mesonbuild/compilers/d.py b/mesonbuild/compilers/d.py index 99889b0..5759f33 100644 --- a/mesonbuild/compilers/d.py +++ b/mesonbuild/compilers/d.py @@ -395,6 +395,17 @@ class DmdLikeCompilerMixin: soargs.append('-L=' + arg) return soargs + def get_allow_undefined_link_args(self) -> T.List[str]: + args = self.linker.get_allow_undefined_args() + if self.info.is_darwin(): + # On macOS we're passing these options to the C compiler, but + # they're linker options and need -Wl, so clang/gcc knows what to + # do with them. I'm assuming, but don't know for certain, that + # ldc/dmd do some kind of mapping internally for arguments they + # understand, but pass arguments they don't understand directly. + args = [a.replace('-L=', '-Xcc=-Wl,') for a in args] + return args + class DCompiler(Compiler): mscrt_args = { -- cgit v1.1