Merge pull request #6779 from dcbaker/gdc-linker-args

Allow setting linker for GDC as well as LDC
pull/6436/merge
Jussi Pakkanen 5 years ago committed by GitHub
commit c557205695
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      docs/markdown/snippets/ldc_linker_override.md
  2. 2
      mesonbuild/compilers/d.py
  3. 21
      run_unittests.py

@ -1,5 +1,7 @@
## Support for overiding the linker with ldc ## Support for overiding the linker with ldc and gdc
LDC (the llvm D compiler) now honors D_LD linker variable (or d_ld in the cross LDC (the llvm D compiler) and GDC (The Gnu D Compiler) now honor D_LD linker
file) and is able to pick differnt linkers. ld.bfd, ld.gold, ld.lld, ld64, variable (or d_ld in the cross file) and is able to pick differnt linkers.
link, and lld-link are currently supported.
GDC supports all of the same values as GCC, LDC supports ld.bfd, ld.gold,
ld.lld, ld64, link, and lld-link.

@ -627,7 +627,7 @@ class DCompiler(Compiler):
return ' '.join(self.exelist) return ' '.join(self.exelist)
class GnuDCompiler(DCompiler, GnuCompiler): class GnuDCompiler(GnuCompiler, DCompiler):
# we mostly want DCompiler, but that gives us the Compiler.LINKER_PREFIX instead # we mostly want DCompiler, but that gives us the Compiler.LINKER_PREFIX instead
LINKER_PREFIX = GnuCompiler.LINKER_PREFIX LINKER_PREFIX = GnuCompiler.LINKER_PREFIX

@ -4990,9 +4990,18 @@ class WindowsTests(BasePlatformTests):
def test_link_environment_variable_optlink(self): def test_link_environment_variable_optlink(self):
self._check_ld('optlink', 'c', 'optlink') self._check_ld('optlink', 'c', 'optlink')
@skip_if_not_language('rust')
def test_link_environment_variable_rust(self): def test_link_environment_variable_rust(self):
self._check_ld('link', 'rust', 'link') self._check_ld('link', 'rust', 'link')
@skip_if_not_language('d')
def test_link_environment_variable_d(self):
env = get_fake_env()
comp = getattr(env, 'detect_d_compiler')(MachineChoice.HOST)
if comp.id == 'dmd':
raise unittest.SkipTest('meson cannot reliably make DMD use a different linker.')
self._check_ld('lld-link', 'd', 'lld-link')
def test_pefile_checksum(self): def test_pefile_checksum(self):
try: try:
import pefile import pefile
@ -6342,23 +6351,31 @@ c = ['{0}']
def test_ld_environment_variable_lld(self): def test_ld_environment_variable_lld(self):
self._check_ld('ld.lld', 'lld', 'c', 'ld.lld') self._check_ld('ld.lld', 'lld', 'c', 'ld.lld')
@skipIfNoExecutable('rustc') @skip_if_not_language('rust')
def test_ld_environment_variable_rust(self): def test_ld_environment_variable_rust(self):
self._check_ld('ld.gold', 'gold', 'rust', 'ld.gold') self._check_ld('ld.gold', 'gold', 'rust', 'ld.gold')
def test_ld_environment_variable_cpp(self): def test_ld_environment_variable_cpp(self):
self._check_ld('ld.gold', 'gold', 'cpp', 'ld.gold') self._check_ld('ld.gold', 'gold', 'cpp', 'ld.gold')
@skip_if_not_language('objc')
def test_ld_environment_variable_objc(self): def test_ld_environment_variable_objc(self):
self._check_ld('ld.gold', 'gold', 'objc', 'ld.gold') self._check_ld('ld.gold', 'gold', 'objc', 'ld.gold')
@skip_if_not_language('objcpp')
def test_ld_environment_variable_objcpp(self): def test_ld_environment_variable_objcpp(self):
self._check_ld('ld.gold', 'gold', 'objcpp', 'ld.gold') self._check_ld('ld.gold', 'gold', 'objcpp', 'ld.gold')
@skipIfNoExecutable('gfortran') @skip_if_not_language('fortran')
def test_ld_environment_variable_fortran(self): def test_ld_environment_variable_fortran(self):
self._check_ld('ld.gold', 'gold', 'fortran', 'ld.gold') self._check_ld('ld.gold', 'gold', 'fortran', 'ld.gold')
@skip_if_not_language('d')
def test_ld_environment_variable_d(self):
# At least for me, ldc defaults to gold, and gdc defaults to bfd, so
# let's pick lld, which isn't the default for either (currently)
self._check_ld('ld.lld', 'lld', 'd', 'ld.lld')
def compute_sha256(self, filename): def compute_sha256(self, filename):
with open(filename, 'rb') as f: with open(filename, 'rb') as f:
return hashlib.sha256(f.read()).hexdigest() return hashlib.sha256(f.read()).hexdigest()

Loading…
Cancel
Save