Skip to content

Commit 5230edf

Browse files
authored
Merge dd7c9e2 into d490636
2 parents d490636 + dd7c9e2 commit 5230edf

File tree

13 files changed

+110
-1
lines changed

13 files changed

+110
-1
lines changed

azure-pipelines.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ jobs:
9494
- bash: ci/intel-scripts/cache_exclude_windows.sh
9595
displayName: exclude unused files from cache
9696
condition: and(ne(variables.CACHE_RESTORED, 'true'), eq(variables.ifort, 'true'))
97+
- script: choco install -y nasm
98+
displayName: install NASM
9799
- task: UsePythonVersion@0
98100
inputs:
99101
versionSpec: '3.7'

mesonbuild/build.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,6 +1546,7 @@ def get_clink_dynamic_linker_and_stdlibs(self) -> T.Tuple['Compiler', T.List[str
15461546
MASK_LANGS = frozenset([
15471547
# (language, linker)
15481548
('cpp', 'cuda'),
1549+
('nasm', 'c'),
15491550
])
15501551
# Pick a compiler based on the language priority-order
15511552
for l in clink_langs:

mesonbuild/compilers/compilers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
# List of languages that by default consume and output libraries following the
8585
# C ABI; these can generally be used interchangeably
8686
# This must be sorted, see sort_clink().
87-
clib_langs = ('objcpp', 'cpp', 'objc', 'c', 'fortran')
87+
clib_langs = ('objcpp', 'cpp', 'objc', 'c', 'nasm', 'fortran')
8888
# List of languages that can be linked with C code directly by the linker
8989
# used in build.py:process_compilers() and build.py:get_dynamic_linker()
9090
# This must be sorted, see sort_clink().

mesonbuild/compilers/detect.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,13 @@ def detect_static_linker(env: 'Environment', compiler: Compiler) -> StaticLinker
189189
trials = [['xilib']]
190190
elif is_windows() and compiler.id == 'pgi': # this handles cpp / nvidia HPC, in addition to just c/fortran
191191
trials = [['ar']] # For PGI on Windows, "ar" is just a wrapper calling link/lib.
192+
elif is_windows() and compiler.id == 'nasm':
193+
# This may well be LINK.EXE if it's under a MSVC environment
194+
trials = [
195+
defaults['vs_static_linker'],
196+
defaults['clang_cl_static_linker'],
197+
default_linkers
198+
]
192199
else:
193200
trials = default_linkers
194201
popen_exceptions = {}

mesonbuild/compilers/mixins/visualstudio.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,24 @@ def get_instruction_set_args(self, instruction_set: str) -> T.Optional[T.List[st
437437
def get_pch_base_name(self, header: str) -> str:
438438
return os.path.basename(header)
439439

440+
# Linking ASM-only objects into an executable or DLL
441+
# require this, otherwise it'll fail to find
442+
# _WinMain or _DllMainCRTStartup.
443+
def get_crt_link_args(self, crt_val: str, buildtype: str) -> T.List[str]:
444+
host_crt_compile_args = self.get_crt_compile_args(crt_val, buildtype)
445+
for arg in host_crt_compile_args:
446+
if arg == '/MTd':
447+
return ['/DEFAULTLIB:libucrtd.lib', '/DEFAULTLIB:libvcruntimed.lib', '/DEFAULTLIB:libcmtd.lib']
448+
elif arg == '/MT':
449+
return ['/DEFAULTLIB:libucrt.lib', '/DEFAULTLIB:libvcruntime.lib', '/DEFAULTLIB:libcmt.lib']
450+
elif arg == '/MDd':
451+
return ['/DEFAULTLIB:ucrtd.lib', '/DEFAULTLIB:vcruntimed.lib', '/DEFAULTLIB:msvcrtd.lib']
452+
elif arg == '/MD':
453+
return ['/DEFAULTLIB:ucrt.lib', '/DEFAULTLIB:vcruntime.lib', '/DEFAULTLIB:msvcrt.lib']
454+
else:
455+
continue
456+
return []
457+
440458

441459
class ClangClCompiler(VisualStudioLikeCompiler):
442460

test cases/nasm/3 nasm only/dummy.asm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
global dummy
2+
section .rdata align=16
3+
dummy:
4+
dd 0x00010203

test cases/nasm/3 nasm only/dummy.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
EXPORTS
2+
dummy
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
project('nasm only')
2+
3+
if not add_languages('nasm', required: false)
4+
error('MESON_SKIP_TEST: nasm not found')
5+
endif
6+
7+
sources = files('dummy.asm')
8+
9+
dummy = library(
10+
'dummy',
11+
sources,
12+
vs_module_defs: 'dummy.def',
13+
)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
global dummy
2+
section .rdata align=16
3+
dummy:
4+
dd 0x00010203
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <inttypes.h>
2+
#include <stdint.h>
3+
#include <stdio.h>
4+
5+
extern uint32_t dummy[];
6+
7+
int main()
8+
{
9+
if (*dummy != 0x00010203u) {
10+
fprintf(stderr, "Dummy value was: %" PRIu32 "\n", *dummy);
11+
return 1;
12+
}
13+
14+
return 0;
15+
}

0 commit comments

Comments
 (0)