diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2020-03-06 16:00:32 -0800 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2020-03-09 16:55:08 -0700 |
commit | fe86c594c6a3b5f99d2150ae165c951e7a41955a (patch) | |
tree | ce9c363e5f28951f19055ee9392653db28db1a61 /mesonbuild/environment.py | |
parent | 1fe153a3a5ae235aa9b51cc4ff74e49fd339c858 (diff) | |
download | meson-fe86c594c6a3b5f99d2150ae165c951e7a41955a.zip meson-fe86c594c6a3b5f99d2150ae165c951e7a41955a.tar.gz meson-fe86c594c6a3b5f99d2150ae165c951e7a41955a.tar.bz2 |
Allow invoking the linker directly through dmd
DMD is awful in a lot of ways. To change the linker you set an
environment variable, which is pretty much impossible for us.
Diffstat (limited to 'mesonbuild/environment.py')
-rw-r--r-- | mesonbuild/environment.py | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index e4c61a3..ece1242 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -1526,20 +1526,30 @@ class Environment: full_version=full_version, linker=linker) elif 'The D Language Foundation' in out or 'Digital Mars' in out: # DMD seems to require a file - if info.is_windows() or info.is_cygwin(): - if is_msvc: - linker_cmd = ['link'] - elif arch == 'x86': - linker_cmd = ['optlink'] + # We cannot use NamedTemproraryFile on windows, its documented + # to not work for our uses. So, just use mkstemp and only have + # one path for simplicity. + o, f = tempfile.mkstemp('.d') + os.close(o) + + # DMD as different detection logic for x86 and x86_64 + arch_arg = '-m64' if arch == 'x86_64' else '-m32' + + try: + if info.is_windows() or info.is_cygwin(): + objfile = os.path.basename(f)[:-1] + 'obj' + linker = self._guess_win_linker( + exelist, compilers.DmdDCompiler, for_machine, + invoked_directly=False, extra_args=[f, arch_arg]) else: - linker_cmd = ['lld-link'] - linker = self._guess_win_linker(linker_cmd, compilers.DmdDCompiler, for_machine, - use_linker_prefix=False) - else: - with tempfile.NamedTemporaryFile(suffix='.d') as f: + objfile = os.path.basename(f)[:-1] + 'o' linker = self._guess_nix_linker( exelist, compilers.DmdDCompiler, for_machine, - extra_args=[f.name]) + extra_args=[f, arch_arg]) + finally: + mesonlib.windows_proof_rm(f) + mesonlib.windows_proof_rm(objfile) + return compilers.DmdDCompiler( exelist, version, for_machine, info, arch, full_version=full_version, linker=linker) |