aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-03-06 16:00:32 -0800
committerDylan Baker <dylan@pnwbakers.com>2020-03-09 16:55:08 -0700
commitfe86c594c6a3b5f99d2150ae165c951e7a41955a (patch)
treece9c363e5f28951f19055ee9392653db28db1a61
parent1fe153a3a5ae235aa9b51cc4ff74e49fd339c858 (diff)
downloadmeson-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.
-rw-r--r--mesonbuild/compilers/d.py3
-rw-r--r--mesonbuild/environment.py32
2 files changed, 24 insertions, 11 deletions
diff --git a/mesonbuild/compilers/d.py b/mesonbuild/compilers/d.py
index 293a2ae..a026e83 100644
--- a/mesonbuild/compilers/d.py
+++ b/mesonbuild/compilers/d.py
@@ -765,3 +765,6 @@ class DmdDCompiler(DmdLikeCompilerMixin, DCompiler):
def get_optimization_args(self, optimization_level):
return dmd_optimization_args[optimization_level]
+
+ def can_linker_accept_rsp(self) -> bool:
+ return False
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)