From 730a7b296fdff8aca58e15829485b3b68262d3c0 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 13 Jan 2020 11:15:36 -0800 Subject: environment: Replace LD with LD The rust code is ugly, because rust is annoying. It doesn't invoke a linker directly (unless that linker is link.exe or lld-link.exe), instead it invokes the C compiler (gcc or clang usually) to do it's linking. Meson doesn't have good abstractions for this, though we probably should because some of the D compilers do the same thing. Either that or we should just call the c compiler directly, like vala does. This changes the public interface for meson, which we don't do unless we absolutely have to. In this case I think we need to do it. A fair number of projects have already been using 'ld' in their cross/native files to get the ld binary and call it directly in custom_targets or generators, and we broke that. While we could hit this problem again names like `c_ld` and `cpp_ld` are far less likely to cause collisions than `ld`. Additionally this gives a way to set the linker on a per-compiler basis, which is probably in itself very useful. Fixes #6442 --- run_unittests.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'run_unittests.py') diff --git a/run_unittests.py b/run_unittests.py index b034773..d8c3a1c 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -44,6 +44,7 @@ from distutils.dir_util import copy_tree import mesonbuild.mlog import mesonbuild.depfile import mesonbuild.compilers +import mesonbuild.envconfig import mesonbuild.environment import mesonbuild.mesonlib import mesonbuild.coredata @@ -4663,7 +4664,8 @@ class WindowsTests(BasePlatformTests): def _check_ld(self, name: str, lang: str, expected: str) -> None: if not shutil.which(name): raise unittest.SkipTest('Could not find {}.'.format(name)) - with mock.patch.dict(os.environ, {'LD': name}): + envvar = mesonbuild.envconfig.BinaryTable.evarMap['{}ld'.format(lang)] + with mock.patch.dict(os.environ, {envvar: name}): env = get_fake_env() try: comp = getattr(env, 'detect_{}_compiler'.format(lang))(MachineChoice.HOST) @@ -5943,7 +5945,8 @@ c = ['{0}'] raise unittest.SkipTest('Solaris currently cannot override the linker.') if not shutil.which(check): raise unittest.SkipTest('Could not find {}.'.format(check)) - with mock.patch.dict(os.environ, {'LD': name}): + envvar = mesonbuild.envconfig.BinaryTable.evarMap['{}ld'.format(lang)] + with mock.patch.dict(os.environ, {envvar: name}): env = get_fake_env() comp = getattr(env, 'detect_{}_compiler'.format(lang))(MachineChoice.HOST) if lang != 'rust' and comp.use_linker_args('foo') == []: -- cgit v1.1