From 47bc42b5ac66ed4a144ad7822c12cd9a3f34c333 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 4 Mar 2024 11:41:04 -0500 Subject: ci: Add nasm assembler to Debian and Fedora base images --- .gitlab/ci/docker/debian12-x86_64/deps_packages.lst | 3 +++ .gitlab/ci/docker/fedora39/deps_packages.lst | 3 +++ .gitlab/os-linux.yml | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.gitlab/ci/docker/debian12-x86_64/deps_packages.lst b/.gitlab/ci/docker/debian12-x86_64/deps_packages.lst index a59f2c9..014c7ea 100644 --- a/.gitlab/ci/docker/debian12-x86_64/deps_packages.lst +++ b/.gitlab/ci/docker/debian12-x86_64/deps_packages.lst @@ -32,6 +32,9 @@ cvs subversion mercurial +# Install ASM_NASM language toolchain. +nasm + # Install HIP language toolchain. hipcc diff --git a/.gitlab/ci/docker/fedora39/deps_packages.lst b/.gitlab/ci/docker/fedora39/deps_packages.lst index 7656cbc..e51a985 100644 --- a/.gitlab/ci/docker/fedora39/deps_packages.lst +++ b/.gitlab/ci/docker/fedora39/deps_packages.lst @@ -46,6 +46,9 @@ file jq which +# Install ASM_NASM language toolchain. +nasm + # Install HIP language toolchain. hsakmt-devel lld diff --git a/.gitlab/os-linux.yml b/.gitlab/os-linux.yml index e0364a5..1299ce3 100644 --- a/.gitlab/os-linux.yml +++ b/.gitlab/os-linux.yml @@ -45,7 +45,7 @@ ### Debian .debian12: - image: "kitware/cmake:ci-debian12-x86_64-2023-07-27" + image: "kitware/cmake:ci-debian12-x86_64-2024-03-04" variables: GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci" @@ -69,7 +69,7 @@ ### Fedora .fedora39: - image: "kitware/cmake:ci-fedora39-x86_64-2023-11-16" + image: "kitware/cmake:ci-fedora39-x86_64-2024-03-04" variables: GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci/long file name for testing purposes" -- cgit v0.12 From 7cf45c9e6a7633cb231dfa07d8e7346200242af0 Mon Sep 17 00:00:00 2001 From: Vito Gamberini Date: Mon, 4 Mar 2024 11:42:46 -0500 Subject: ASM_NASM: Improve support for standalone usage * Add tests for standalone NASM usage * Change generic ASM_NASM executable linker to * Use CMAKE_SYSTEM_PROCESSOR to determine output format when used without a C/CXX compiler --- .gitlab/ci/configure_debian12_ninja.cmake | 2 ++ .gitlab/ci/configure_fedora39_makefiles.cmake | 1 + Modules/CMakeASM_NASMInformation.cmake | 11 +++++++++++ Tests/CMakeLists.txt | 4 ++++ Tests/NasmOnly/CMakeLists.txt | 7 +++++++ Tests/NasmOnly/libnasm1.nasm | 6 ++++++ Tests/NasmOnly/nasmonly.nasm | 19 +++++++++++++++++++ 7 files changed, 50 insertions(+) create mode 100644 Tests/NasmOnly/CMakeLists.txt create mode 100644 Tests/NasmOnly/libnasm1.nasm create mode 100644 Tests/NasmOnly/nasmonly.nasm diff --git a/.gitlab/ci/configure_debian12_ninja.cmake b/.gitlab/ci/configure_debian12_ninja.cmake index 89c1108..efca7a1 100644 --- a/.gitlab/ci/configure_debian12_ninja.cmake +++ b/.gitlab/ci/configure_debian12_ninja.cmake @@ -1,2 +1,4 @@ +set(CMake_TEST_ASM_NASM "ON" CACHE BOOL "") + include("${CMAKE_CURRENT_LIST_DIR}/configure_debian12_ninja_common.cmake") set(CMake_TEST_UseSWIG "ON" CACHE BOOL "") diff --git a/.gitlab/ci/configure_fedora39_makefiles.cmake b/.gitlab/ci/configure_fedora39_makefiles.cmake index fe03851..6b33d24 100644 --- a/.gitlab/ci/configure_fedora39_makefiles.cmake +++ b/.gitlab/ci/configure_fedora39_makefiles.cmake @@ -6,6 +6,7 @@ if (NOT "$ENV{CMAKE_CI_NIGHTLY}" STREQUAL "") set(CMake_TEST_CTestUpdate_P4 "ON" CACHE BOOL "") endif() +set(CMake_TEST_ASM_NASM "ON" CACHE BOOL "") set(CMake_TEST_FindALSA "ON" CACHE BOOL "") set(CMake_TEST_FindBLAS "All;static=1;Generic" CACHE STRING "") set(CMake_TEST_FindBoost "ON" CACHE BOOL "") diff --git a/Modules/CMakeASM_NASMInformation.cmake b/Modules/CMakeASM_NASMInformation.cmake index a72575b..898b823 100644 --- a/Modules/CMakeASM_NASMInformation.cmake +++ b/Modules/CMakeASM_NASMInformation.cmake @@ -12,6 +12,8 @@ if(NOT CMAKE_ASM_NASM_OBJECT_FORMAT) set(CMAKE_ASM_NASM_OBJECT_FORMAT win64) elseif(DEFINED CMAKE_CXX_SIZEOF_DATA_PTR AND CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8) set(CMAKE_ASM_NASM_OBJECT_FORMAT win64) + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + set(CMAKE_ASM_NASM_OBJECT_FORMAT win64) else() set(CMAKE_ASM_NASM_OBJECT_FORMAT win32) endif() @@ -20,6 +22,8 @@ if(NOT CMAKE_ASM_NASM_OBJECT_FORMAT) set(CMAKE_ASM_NASM_OBJECT_FORMAT macho64) elseif(DEFINED CMAKE_CXX_SIZEOF_DATA_PTR AND CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8) set(CMAKE_ASM_NASM_OBJECT_FORMAT macho64) + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + set(CMAKE_ASM_NASM_OBJECT_FORMAT macho64) else() set(CMAKE_ASM_NASM_OBJECT_FORMAT macho) endif() @@ -28,6 +32,8 @@ if(NOT CMAKE_ASM_NASM_OBJECT_FORMAT) set(CMAKE_ASM_NASM_OBJECT_FORMAT elf64) elseif(DEFINED CMAKE_CXX_SIZEOF_DATA_PTR AND CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8) set(CMAKE_ASM_NASM_OBJECT_FORMAT elf64) + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + set(CMAKE_ASM_NASM_OBJECT_FORMAT elf64) else() set(CMAKE_ASM_NASM_OBJECT_FORMAT elf) endif() @@ -38,6 +44,11 @@ if(NOT CMAKE_ASM_NASM_COMPILE_OBJECT) set(CMAKE_ASM_NASM_COMPILE_OBJECT " -f ${CMAKE_ASM_NASM_OBJECT_FORMAT} -o ") endif() +if(NOT CMAKE_ASM_NASM_LINK_EXECUTABLE) + set(CMAKE_ASM_NASM_LINK_EXECUTABLE + " -o ") +endif() + if(CMAKE_ASM_NASM_COMPILER_ID STREQUAL "NASM") set(CMAKE_DEPFILE_FLAGS_ASM_NASM "-MD -MT ") diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 1ee45d6..0309532 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -498,6 +498,10 @@ if(BUILD_TESTING) ADD_TEST_MACRO(ReturnTest ReturnTest) ADD_TEST_MACRO(Properties Properties) ADD_TEST_MACRO(Assembler HelloAsm) + # relies on Linux syscall interface + if(CMake_TEST_ASM_NASM AND CMAKE_SYSTEM_NAME MATCHES "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + ADD_TEST_MACRO(NasmOnly NasmOnly) + endif() ADD_TEST_MACRO(SourceGroups SourceGroups) ADD_TEST_MACRO(Preprocess Preprocess) set(ExportImport_BUILD_OPTIONS -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM} diff --git a/Tests/NasmOnly/CMakeLists.txt b/Tests/NasmOnly/CMakeLists.txt new file mode 100644 index 0000000..e4190c2 --- /dev/null +++ b/Tests/NasmOnly/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.28) + +project(NasmOnly LANGUAGES ASM_NASM) + +add_library(testnasm1 STATIC libnasm1.nasm) +add_executable(NasmOnly nasmonly.nasm) +target_link_libraries(NasmOnly testnasm1) diff --git a/Tests/NasmOnly/libnasm1.nasm b/Tests/NasmOnly/libnasm1.nasm new file mode 100644 index 0000000..c72a1ad --- /dev/null +++ b/Tests/NasmOnly/libnasm1.nasm @@ -0,0 +1,6 @@ +global LibNasm1Func + +section .text +LibNasm1Func: + mov rax, 1 + ret diff --git a/Tests/NasmOnly/nasmonly.nasm b/Tests/NasmOnly/nasmonly.nasm new file mode 100644 index 0000000..db9b655 --- /dev/null +++ b/Tests/NasmOnly/nasmonly.nasm @@ -0,0 +1,19 @@ +global _start + +extern LibNasm1Func + +section .text +_start: + xor rax, rax + call LibNasm1Func + cmp rax, 1 + jne err + + mov rax, 60 + xor rdi, rdi + syscall + +err: + mov rax, 60 + mov rdi, 1 + syscall -- cgit v0.12