From c520e8981693056419d846f60ffb85061bf3191f Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 25 Sep 2025 14:48:45 -0700 Subject: 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. --- mesonbuild/compilers/asm.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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' -- cgit v1.2.3