Skip to content

Commit

Permalink
Merge pull request mesonbuild#6090 from GoaLitiuM/master
Browse files Browse the repository at this point in the history
d: Fix various linking issues
  • Loading branch information
jpakkane authored Oct 22, 2019
2 parents 1ed70e2 + 31d3971 commit dea2c09
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
11 changes: 10 additions & 1 deletion mesonbuild/compilers/d.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,10 @@ def get_soname_args(self, *args, **kwargs) -> typing.List[str]:
return Compiler.get_soname_args(self, *args, **kwargs)

def get_allow_undefined_link_args(self) -> typing.List[str]:
return self.linker.get_allow_undefined_args()
args = []
for arg in self.linker.get_allow_undefined_args():
args.append('-L=' + arg)
return args


class DCompiler(Compiler):
Expand Down Expand Up @@ -637,6 +640,9 @@ def compute_parameters_with_absolute_paths(self, parameter_list, build_dir):

return parameter_list

def get_allow_undefined_link_args(self) -> typing.List[str]:
return self.linker.get_allow_undefined_args()


class LLVMDCompiler(DmdLikeCompilerMixin, LinkerEnvVarsMixin, BasicLinkerIsCompilerMixin, DCompiler):

Expand Down Expand Up @@ -667,6 +673,9 @@ def get_buildtype_args(self, buildtype):
def get_pic_args(self):
return ['-relocation-model=pic']

def get_std_shared_lib_link_args(self):
return ['-shared']

def get_crt_link_args(self, crt_val, buildtype):
return self.get_crt_args(crt_val, buildtype)

Expand Down
24 changes: 17 additions & 7 deletions mesonbuild/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -1369,12 +1369,15 @@ def detect_d_compiler(self, for_machine: MachineChoice):
# LDC seems to require a file
m = self.machines[for_machine]
if m.is_windows() or m.is_cygwin():
# Getting LDC on windows to give useful linker output when not
# doing real work is painfully hard. It ships with a verison of
# lld-link, so just assume that we're going to use lld-link
# with it.
_, o, _ = Popen_safe(['lld-link.exe', '--version'])
linker = ClangClDynamicLinker(for_machine, version=search_version(o))
if is_msvc:
linker = MSVCDynamicLinker(for_machine, version=version)
else:
# Getting LDC on windows to give useful linker output when not
# doing real work is painfully hard. It ships with a verison of
# lld-link, so just assume that we're going to use lld-link
# with it.
_, o, _ = Popen_safe(['lld-link.exe', '--version'])
linker = ClangClDynamicLinker(for_machine, version=search_version(o))
else:
with tempfile.NamedTemporaryFile(suffix='.d') as f:
linker = self._guess_nix_linker(
Expand All @@ -1393,7 +1396,14 @@ def detect_d_compiler(self, for_machine: MachineChoice):
# DMD seems to require a file
m = self.machines[for_machine]
if m.is_windows() or m.is_cygwin():
linker = OptlinkDynamicLinker(for_machine, version=full_version)
if is_msvc:
linker = MSVCDynamicLinker(for_machine, version=version)
elif arch == 'x86':
linker = OptlinkDynamicLinker(for_machine, version=full_version)
else:
# DMD ships with lld-link
_, o, _ = Popen_safe(['lld-link.exe', '--version'])
linker = ClangClDynamicLinker(for_machine, version=search_version(o))
else:
with tempfile.NamedTemporaryFile(suffix='.d') as f:
linker = self._guess_nix_linker(
Expand Down

0 comments on commit dea2c09

Please sign in to comment.