From 0cc8e2cf1464a7ab2f1a599100da7356ddf4865b Mon Sep 17 00:00:00 2001 From: Frank Richter Date: Mon, 4 Nov 2024 12:28:12 +0100 Subject: [PATCH 1/6] cmake/common: Add language map entry for nasm --- mesonbuild/cmake/common.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mesonbuild/cmake/common.py b/mesonbuild/cmake/common.py index d9ff559971f7..0df9cfcbca44 100644 --- a/mesonbuild/cmake/common.py +++ b/mesonbuild/cmake/common.py @@ -17,6 +17,7 @@ 'c': 'C', 'cpp': 'CXX', 'cuda': 'CUDA', + 'nasm': 'ASM_NASM', 'objc': 'OBJC', 'objcpp': 'OBJCXX', 'cs': 'CSharp', From b3377a9aac1262caa0ec7c70d40eb10fc0ebc774 Mon Sep 17 00:00:00 2001 From: Frank Richter Date: Thu, 7 Nov 2024 20:35:05 +0100 Subject: [PATCH 2/6] Add a test case triggering warning after adding nasm language --- .../cmake/28 cmake nasm dependency/main.c | 18 ++++++++++++++ .../28 cmake nasm dependency/meson.build | 21 ++++++++++++++++ .../nativefile.ini.in | 2 ++ .../subprojects/cmTest1.wrap | 5 ++++ .../subprojects/cmTest1/CMakeLists.txt | 5 ++++ .../subprojects/cmTest1/cmTest.c | 8 +++++++ .../subprojects/cmTest2.wrap | 5 ++++ .../subprojects/cmTest2/CMakeLists.txt | 24 +++++++++++++++++++ .../subprojects/cmTest2/cmTestAsm.asm | 4 ++++ .../cmake/28 cmake nasm dependency/test.json | 9 +++++++ 10 files changed, 101 insertions(+) create mode 100644 test cases/cmake/28 cmake nasm dependency/main.c create mode 100644 test cases/cmake/28 cmake nasm dependency/meson.build create mode 100644 test cases/cmake/28 cmake nasm dependency/nativefile.ini.in create mode 100644 test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1.wrap create mode 100644 test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1/CMakeLists.txt create mode 100644 test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1/cmTest.c create mode 100644 test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2.wrap create mode 100644 test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2/CMakeLists.txt create mode 100644 test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2/cmTestAsm.asm create mode 100644 test cases/cmake/28 cmake nasm dependency/test.json diff --git a/test cases/cmake/28 cmake nasm dependency/main.c b/test cases/cmake/28 cmake nasm dependency/main.c new file mode 100644 index 000000000000..5aef9670e4bc --- /dev/null +++ b/test cases/cmake/28 cmake nasm dependency/main.c @@ -0,0 +1,18 @@ +#include +#include + +int32_t cmTestFunc(void); + +int main(void) +{ + if (cmTestFunc() > 4200) + { + printf("Test success.\n"); + return 0; + } + else + { + printf("Test failure.\n"); + return 1; + } +} diff --git a/test cases/cmake/28 cmake nasm dependency/meson.build b/test cases/cmake/28 cmake nasm dependency/meson.build new file mode 100644 index 000000000000..f70d3562804c --- /dev/null +++ b/test cases/cmake/28 cmake nasm dependency/meson.build @@ -0,0 +1,21 @@ +project('cmake nasm dependency', ['c', 'cpp']) + +if get_option('backend').startswith('vs') + error('MESON_SKIP_TEST: nasm is not supported by vs backend') +endif + +# This test aims to trigger CMakeToolchain.update_cmake_compiler_state() _twice_, +# as the 2nd CMake compilers state update resulted in a warning +# "Failed to determine CMake compilers state" after nasm was added as a language. + +# First dependency triggers initial compilers state update +sub_dep_1 = dependency('cmTest1') +# Add nasm as a language.. +add_languages('nasm', required: true, native: false) +# ...and check for 2nd dependency. Together with cmake_skip_compiler_test = 'always', +# this triggers another CMake compilers state update, this time with nasm +# in the mix +sub_dep_2 = dependency('cmTest2') + +exe1 = executable('exe1', ['main.c'], dependencies: [sub_dep_1, sub_dep_2]) +test('test1', exe1) diff --git a/test cases/cmake/28 cmake nasm dependency/nativefile.ini.in b/test cases/cmake/28 cmake nasm dependency/nativefile.ini.in new file mode 100644 index 000000000000..ca40a3d76ace --- /dev/null +++ b/test cases/cmake/28 cmake nasm dependency/nativefile.ini.in @@ -0,0 +1,2 @@ +[properties] +cmake_skip_compiler_test = 'always' diff --git a/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1.wrap b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1.wrap new file mode 100644 index 000000000000..babfb6c07300 --- /dev/null +++ b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1.wrap @@ -0,0 +1,5 @@ +[wrap-file] +method = cmake + +[provide] +cmTest1 = cmTest1_dep diff --git a/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1/CMakeLists.txt b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1/CMakeLists.txt new file mode 100644 index 000000000000..42f16f84e798 --- /dev/null +++ b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION ${CMAKE_VERSION}) + +project(cmTest1) + +add_library(cmTest1 STATIC cmTest.c) diff --git a/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1/cmTest.c b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1/cmTest.c new file mode 100644 index 000000000000..e32415c94c9f --- /dev/null +++ b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1/cmTest.c @@ -0,0 +1,8 @@ +#include + +extern const int32_t cmTestArea; + +int32_t cmTestFunc(void) +{ + return cmTestArea; +} diff --git a/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2.wrap b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2.wrap new file mode 100644 index 000000000000..a0ed381ae7a6 --- /dev/null +++ b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2.wrap @@ -0,0 +1,5 @@ +[wrap-file] +method = cmake + +[provide] +cmTest2 = cmTest2_dep diff --git a/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2/CMakeLists.txt b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2/CMakeLists.txt new file mode 100644 index 000000000000..45a56cc5723a --- /dev/null +++ b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION ${CMAKE_VERSION}) + +project(cmTest2) + +#Detect processor +if ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "[Aa][Mm][Dd]64") + SET(TEST_PROCESSOR "x86_64") +elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "[Xx]86_64") + SET(TEST_PROCESSOR "x86_64") +elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "[Ii]386") + SET(TEST_PROCESSOR "x86") +elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "[Ii]686") + SET(TEST_PROCESSOR "x86") +elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "[Aa][Rr][Mm]") + SET(TEST_PROCESSOR "arm") +elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "[Aa][Aa][Rr][Cc][Hh]64") + SET(TEST_PROCESSOR "arm") +else () + message(FATAL_ERROR "MESON_SKIP_TEST: Unsupported Assembler Platform ${CMAKE_SYSTEM_PROCESSOR}") +endif () + +enable_language(ASM_NASM) + +add_library(cmTest2 STATIC cmTestAsm.asm) diff --git a/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2/cmTestAsm.asm b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2/cmTestAsm.asm new file mode 100644 index 000000000000..ef386e181bfc --- /dev/null +++ b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2/cmTestAsm.asm @@ -0,0 +1,4 @@ +SECTION .rdata +GLOBAL cmTestArea +cmTestArea: + dd 4242 diff --git a/test cases/cmake/28 cmake nasm dependency/test.json b/test cases/cmake/28 cmake nasm dependency/test.json new file mode 100644 index 000000000000..791697089f4c --- /dev/null +++ b/test cases/cmake/28 cmake nasm dependency/test.json @@ -0,0 +1,9 @@ +{ + "stdout": [ + { + "line": ".*CMake Toolchain: Failed to determine CMake compilers state.*", + "match": "re", + "count": 0 + } + ] + } From ef13f82cbebab45fae1d7f68d94cd8c7e7955299 Mon Sep 17 00:00:00 2001 From: Frank Richter Date: Sat, 9 Nov 2024 13:18:21 +0100 Subject: [PATCH 3/6] Skip 'cmask nasm dependency' test if nasm is not available --- test cases/cmake/28 cmake nasm dependency/meson.build | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test cases/cmake/28 cmake nasm dependency/meson.build b/test cases/cmake/28 cmake nasm dependency/meson.build index f70d3562804c..1ddd6ec7c343 100644 --- a/test cases/cmake/28 cmake nasm dependency/meson.build +++ b/test cases/cmake/28 cmake nasm dependency/meson.build @@ -10,8 +10,10 @@ endif # First dependency triggers initial compilers state update sub_dep_1 = dependency('cmTest1') -# Add nasm as a language.. -add_languages('nasm', required: true, native: false) +# Add nasm as a language... +if not add_languages('nasm', required: false, native: false) + error('MESON_SKIP_TEST: nasm not found') +endif # ...and check for 2nd dependency. Together with cmake_skip_compiler_test = 'always', # this triggers another CMake compilers state update, this time with nasm # in the mix From 15ef7d25656645189e29f8fc1e3d3bf2ecb44b30 Mon Sep 17 00:00:00 2001 From: Frank Richter Date: Sat, 9 Nov 2024 14:57:46 +0100 Subject: [PATCH 4/6] Simplify 'cmake nasm dependency' test case --- .../cmake/28 cmake nasm dependency/meson.build | 18 ++++++------------ .../28 cmake nasm dependency/nativefile.ini.in | 2 -- .../subprojects/{cmTest1.wrap => cmTest.wrap} | 2 +- .../{cmTest2 => cmTest}/CMakeLists.txt | 4 ++-- .../subprojects/{cmTest1 => cmTest}/cmTest.c | 0 .../{cmTest2 => cmTest}/cmTestAsm.asm | 0 .../subprojects/cmTest1/CMakeLists.txt | 5 ----- .../subprojects/cmTest2.wrap | 5 ----- 8 files changed, 9 insertions(+), 27 deletions(-) delete mode 100644 test cases/cmake/28 cmake nasm dependency/nativefile.ini.in rename test cases/cmake/28 cmake nasm dependency/subprojects/{cmTest1.wrap => cmTest.wrap} (63%) rename test cases/cmake/28 cmake nasm dependency/subprojects/{cmTest2 => cmTest}/CMakeLists.txt (91%) rename test cases/cmake/28 cmake nasm dependency/subprojects/{cmTest1 => cmTest}/cmTest.c (100%) rename test cases/cmake/28 cmake nasm dependency/subprojects/{cmTest2 => cmTest}/cmTestAsm.asm (100%) delete mode 100644 test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1/CMakeLists.txt delete mode 100644 test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2.wrap diff --git a/test cases/cmake/28 cmake nasm dependency/meson.build b/test cases/cmake/28 cmake nasm dependency/meson.build index 1ddd6ec7c343..56780c711be1 100644 --- a/test cases/cmake/28 cmake nasm dependency/meson.build +++ b/test cases/cmake/28 cmake nasm dependency/meson.build @@ -4,20 +4,14 @@ if get_option('backend').startswith('vs') error('MESON_SKIP_TEST: nasm is not supported by vs backend') endif -# This test aims to trigger CMakeToolchain.update_cmake_compiler_state() _twice_, -# as the 2nd CMake compilers state update resulted in a warning -# "Failed to determine CMake compilers state" after nasm was added as a language. - -# First dependency triggers initial compilers state update -sub_dep_1 = dependency('cmTest1') -# Add nasm as a language... if not add_languages('nasm', required: false, native: false) error('MESON_SKIP_TEST: nasm not found') endif -# ...and check for 2nd dependency. Together with cmake_skip_compiler_test = 'always', -# this triggers another CMake compilers state update, this time with nasm -# in the mix -sub_dep_2 = dependency('cmTest2') -exe1 = executable('exe1', ['main.c'], dependencies: [sub_dep_1, sub_dep_2]) +# Using this dependency triggers CMakeToolchain.update_cmake_compiler_state(), +# and with nasm as a language, resulted in a warning +# "Failed to determine CMake compilers state" after nasm was added as a language. +sub_dep = dependency('cmTest') + +exe1 = executable('exe1', ['main.c'], dependencies: [sub_dep]) test('test1', exe1) diff --git a/test cases/cmake/28 cmake nasm dependency/nativefile.ini.in b/test cases/cmake/28 cmake nasm dependency/nativefile.ini.in deleted file mode 100644 index ca40a3d76ace..000000000000 --- a/test cases/cmake/28 cmake nasm dependency/nativefile.ini.in +++ /dev/null @@ -1,2 +0,0 @@ -[properties] -cmake_skip_compiler_test = 'always' diff --git a/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1.wrap b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest.wrap similarity index 63% rename from test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1.wrap rename to test cases/cmake/28 cmake nasm dependency/subprojects/cmTest.wrap index babfb6c07300..1ea202e45ca1 100644 --- a/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1.wrap +++ b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest.wrap @@ -2,4 +2,4 @@ method = cmake [provide] -cmTest1 = cmTest1_dep +cmTest = cmTest_dep diff --git a/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2/CMakeLists.txt b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest/CMakeLists.txt similarity index 91% rename from test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2/CMakeLists.txt rename to test cases/cmake/28 cmake nasm dependency/subprojects/cmTest/CMakeLists.txt index 45a56cc5723a..d7677828b7b2 100644 --- a/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2/CMakeLists.txt +++ b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION ${CMAKE_VERSION}) -project(cmTest2) +project(cmTest) #Detect processor if ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "[Aa][Mm][Dd]64") @@ -21,4 +21,4 @@ endif () enable_language(ASM_NASM) -add_library(cmTest2 STATIC cmTestAsm.asm) +add_library(cmTest STATIC cmTest.c cmTestAsm.asm) diff --git a/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1/cmTest.c b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest/cmTest.c similarity index 100% rename from test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1/cmTest.c rename to test cases/cmake/28 cmake nasm dependency/subprojects/cmTest/cmTest.c diff --git a/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2/cmTestAsm.asm b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest/cmTestAsm.asm similarity index 100% rename from test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2/cmTestAsm.asm rename to test cases/cmake/28 cmake nasm dependency/subprojects/cmTest/cmTestAsm.asm diff --git a/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1/CMakeLists.txt b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1/CMakeLists.txt deleted file mode 100644 index 42f16f84e798..000000000000 --- a/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest1/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION ${CMAKE_VERSION}) - -project(cmTest1) - -add_library(cmTest1 STATIC cmTest.c) diff --git a/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2.wrap b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2.wrap deleted file mode 100644 index a0ed381ae7a6..000000000000 --- a/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest2.wrap +++ /dev/null @@ -1,5 +0,0 @@ -[wrap-file] -method = cmake - -[provide] -cmTest2 = cmTest2_dep From 1ea8690b0a40a9661aa816dac8b921210f6bd8a5 Mon Sep 17 00:00:00 2001 From: Frank Richter Date: Sun, 24 Nov 2024 13:12:18 +0100 Subject: [PATCH 5/6] Disable 'cmake nasm dependency' test on ARM nasm targets x86, so enabling it only there makes sense. --- .../subprojects/cmTest/CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest/CMakeLists.txt b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest/CMakeLists.txt index d7677828b7b2..112767654164 100644 --- a/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest/CMakeLists.txt +++ b/test cases/cmake/28 cmake nasm dependency/subprojects/cmTest/CMakeLists.txt @@ -11,10 +11,6 @@ elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "[Ii]386") SET(TEST_PROCESSOR "x86") elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "[Ii]686") SET(TEST_PROCESSOR "x86") -elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "[Aa][Rr][Mm]") - SET(TEST_PROCESSOR "arm") -elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "[Aa][Aa][Rr][Cc][Hh]64") - SET(TEST_PROCESSOR "arm") else () message(FATAL_ERROR "MESON_SKIP_TEST: Unsupported Assembler Platform ${CMAKE_SYSTEM_PROCESSOR}") endif () From d8a1d5e3c33087d5a67e87161d124b8434d57bbd Mon Sep 17 00:00:00 2001 From: Frank Richter Date: Sun, 24 Nov 2024 13:37:00 +0100 Subject: [PATCH 6/6] Disable 'cmake nasm dependency' test on cross builds To work around weird segfault on Ubuntu Rolling (--cross ubuntu-armhf.json --cross linux-mingw-w64-64bit.json, 0, gcc, g++) --- test cases/cmake/28 cmake nasm dependency/meson.build | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test cases/cmake/28 cmake nasm dependency/meson.build b/test cases/cmake/28 cmake nasm dependency/meson.build index 56780c711be1..e6fc39b833c0 100644 --- a/test cases/cmake/28 cmake nasm dependency/meson.build +++ b/test cases/cmake/28 cmake nasm dependency/meson.build @@ -1,5 +1,9 @@ project('cmake nasm dependency', ['c', 'cpp']) +if meson.is_cross_build() + error('MESON_SKIP_TEST: skip this on cross builds') +endif + if get_option('backend').startswith('vs') error('MESON_SKIP_TEST: nasm is not supported by vs backend') endif