summaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/d.py
diff options
context:
space:
mode:
authorAxel Ricard <axel.ricard@allegrodvt.com>2024-05-21 14:22:40 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2024-05-22 23:53:09 +0300
commit8d7ffe6e863834f0190eb6ae9dfe0891c9083c31 (patch)
treeecc79ca124b21801adb0ba5478d3c57edd5262e3 /mesonbuild/compilers/d.py
parentaa9b7b9445ad5bf0948cadac86109ba40e193424 (diff)
downloadmeson-8d7ffe6e863834f0190eb6ae9dfe0891c9083c31.tar.gz
fix sanity check for d cross-compilation
Diffstat (limited to 'mesonbuild/compilers/d.py')
-rw-r--r--mesonbuild/compilers/d.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/mesonbuild/compilers/d.py b/mesonbuild/compilers/d.py
index de344c057..46cffdd0f 100644
--- a/mesonbuild/compilers/d.py
+++ b/mesonbuild/compilers/d.py
@@ -443,10 +443,18 @@ class DCompiler(Compiler):
output_name = os.path.join(work_dir, 'dtest')
with open(source_name, 'w', encoding='utf-8') as ofile:
ofile.write('''void main() { }''')
- pc = subprocess.Popen(self.exelist + self.get_output_args(output_name) + self._get_target_arch_args() + [source_name], cwd=work_dir)
+
+ compile_cmdlist = self.exelist + self.get_output_args(output_name) + self._get_target_arch_args() + [source_name]
+
+ # If cross-compiling, we can't run the sanity check, only compile it.
+ if environment.need_exe_wrapper(self.for_machine) and not environment.has_exe_wrapper():
+ compile_cmdlist += self.get_compile_only_args()
+
+ pc = subprocess.Popen(compile_cmdlist, cwd=work_dir)
pc.wait()
if pc.returncode != 0:
raise EnvironmentException('D compiler %s cannot compile programs.' % self.name_string())
+
if environment.need_exe_wrapper(self.for_machine):
if not environment.has_exe_wrapper():
# Can't check if the binaries run so we have to assume they do
@@ -545,7 +553,9 @@ class DCompiler(Compiler):
# LDC2 on Windows targets to current OS architecture, but
# it should follow the target specified by the MSVC toolchain.
if self.info.is_windows():
- if self.arch == 'x86_64':
+ if self.is_cross:
+ return [f'-mtriple={self.arch}-windows-msvc']
+ elif self.arch == 'x86_64':
return ['-m64']
return ['-m32']
return []