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.
pull/6356/head
Dylan Baker 5 years ago
parent c0fd20f164
commit f404c679cf
  1. 11
      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 = {

Loading…
Cancel
Save