Emscripten: Provide CMAKE_<LANG>_COMPILER_ARCHITECTURE_ID

Extend commit 96d9b94a98 (Emscripten: Add platform modules, 2025-05-16,
v4.2.0-rc1~607^2~3) to account for commit 7f0f382c55 (Provide
CMAKE_<LANG>_COMPILER_ARCHITECTURE_ID on more compilers, 2025-03-24,
v4.1.0-rc1~499^2).

Fixes: #27425
This commit is contained in:
Brad King
2025-11-25 14:13:20 -05:00
parent 27cc5d58bf
commit 5ec87b2ba7
7 changed files with 24 additions and 0 deletions

View File

@@ -126,6 +126,12 @@ targets a UNIX platform.
``sw_64``
Sunway
``wasm32``
WebAssembly (Emscripten) 32-bit
``wasm64``
WebAssembly (Emscripten) 64-bit
``x86_64``
Intel 64-bit

View File

@@ -144,6 +144,10 @@ static unsigned short const info_byte_order_little_endian[] = {
# else
# define ARCHITECTURE_ID "ppc"
# endif
#elif defined(__wasm64) || defined(__wasm64__)
# define ARCHITECTURE_ID "wasm64"
#elif defined(__wasm32) || defined(__wasm32__)
# define ARCHITECTURE_ID "wasm32"
#endif
/* Construct the string literal in pieces to prevent the source from

View File

@@ -143,6 +143,10 @@
# else
PRINT *, 'INFO:arch[ppc]'
# endif
#elif defined(__wasm64) || defined(__wasm64__)
PRINT *, 'INFO:arch[wasm64]'
#elif defined(__wasm32) || defined(__wasm32__)
PRINT *, 'INFO:arch[wasm32]'
#endif
PRINT *, 'ABI Detection'

View File

@@ -151,6 +151,10 @@ PRINT *, 'INFO:arch[ppcle]'
# else
PRINT *, 'INFO:arch[ppc]'
# endif
#elif defined(__wasm64) || defined(__wasm64__)
PRINT *, 'INFO:arch[wasm64]'
#elif defined(__wasm32) || defined(__wasm32__)
PRINT *, 'INFO:arch[wasm32]'
#endif
PRINT *, 'ABI Detection'

View File

@@ -69,6 +69,10 @@ function(cmake_parse_compiler_architecture_id triple arch_id_var)
set(ARCHITECTURE_ID "ppcle")
elseif(_dumpmachine_triple MATCHES "^(powerpc|ppc)-")
set(ARCHITECTURE_ID "ppc")
elseif(_dumpmachine_triple MATCHES "^wasm64-")
set(ARCHITECTURE_ID "wasm64")
elseif(_dumpmachine_triple MATCHES "^wasm32-")
set(ARCHITECTURE_ID "wasm32")
else()
set(ARCHITECTURE_ID "")
endif()

View File

@@ -1,2 +1,3 @@
-- CMAKE_C_BYTE_ORDER='LITTLE_ENDIAN'
-- CMAKE_C_COMPILER_ARCHITECTURE_ID='wasm(32|64)'
-- CMAKE_C_SIZEOF_DATA_PTR='[1-9][0-9]*'

View File

@@ -1,6 +1,7 @@
enable_language(C)
foreach(var IN ITEMS
CMAKE_C_BYTE_ORDER
CMAKE_C_COMPILER_ARCHITECTURE_ID
CMAKE_C_SIZEOF_DATA_PTR
)
message(STATUS "${var}='${${var}}'")