summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2025-09-25 14:48:45 -0700
committerDylan Baker <dylan@pnwbakers.com>2025-10-06 09:03:07 -0700
commitc520e8981693056419d846f60ffb85061bf3191f (patch)
tree51f1a51f74b77f538d250d2dc5050d2ef495364d
parent08221c6d1fc4a6afe780a479bbc7e40899242601 (diff)
downloadmeson-c520e8981693056419d846f60ffb85061bf3191f.tar.gz
compilers/asm: Implement sanity checking code for NASM on Windows and Linux
This leaves other systems to be implemented, as I don't have a good way of checking that they work correctly.
-rw-r--r--mesonbuild/compilers/asm.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/mesonbuild/compilers/asm.py b/mesonbuild/compilers/asm.py
index df96c2eee..9eda37a80 100644
--- a/mesonbuild/compilers/asm.py
+++ b/mesonbuild/compilers/asm.py
@@ -1,6 +1,7 @@
from __future__ import annotations
import os
+import textwrap
import typing as T
from .. import mlog
@@ -196,6 +197,35 @@ class NasmCompiler(ASMCompiler):
return []
return self.crt_args[self.get_crt_val(crt_val, buildtype)]
+ def _sanity_check_compile_args(self, env: Environment, sourcename: str, binname: str) -> T.List[str]:
+ return (self.exelist_no_ccache + [sourcename] + self.get_output_args(binname) +
+ self.get_always_args() + self.get_crt_link_args('mt', ''))
+
+ def _sanity_check_source_code(self) -> str:
+ if self.info.is_linux():
+ return textwrap.dedent('''
+ section .text
+ global main
+
+ main:
+ mov eax, 1
+ mov ebx, 0
+ int 0x80
+ ''')
+ elif self.info.is_cygwin() or self.info.is_windows():
+ return textwrap.dedent('''
+ extern _ExitProcess@4
+
+ section .text
+ global main
+
+ main:
+ push 0
+ call _ExitProcess@4
+ ''')
+ return super()._sanity_check_source_code()
+
+
class YasmCompiler(NasmCompiler):
id = 'yasm'