mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-02-06 06:55:07 +00:00
Enhance setting write gs base with cmake variable (#3066)
In linux x86-64, developer can use cmake variable to configure whether to enable writing linear memory base address to x86 GS register or not: - `cmake -DWAMR_DISABLE_WRITE_GS_BASE=1`: disabled it - `cmake -DWAMR_DISABLE_WRITE_GS_BASE=0`: enabled it - `cmake` without `-DWAMR_DISABLE_WRITE_GS_BASE=1/0`: auto-detected by the compiler
This commit is contained in:
parent
7f035d4206
commit
c8b59588a7
|
@ -421,32 +421,49 @@ if (WAMR_BUILD_STATIC_PGO EQUAL 1)
|
||||||
add_definitions (-DWASM_ENABLE_STATIC_PGO=1)
|
add_definitions (-DWASM_ENABLE_STATIC_PGO=1)
|
||||||
message (" AOT static PGO enabled")
|
message (" AOT static PGO enabled")
|
||||||
endif ()
|
endif ()
|
||||||
if (WAMR_DISABLE_WRITE_GS_BASE EQUAL 1)
|
if (WAMR_BUILD_TARGET STREQUAL "X86_64"
|
||||||
add_definitions (-DWASM_DISABLE_WRITE_GS_BASE=1)
|
AND WAMR_BUILD_PLATFORM STREQUAL "linux")
|
||||||
message (" Write linear memory base addr to x86 GS register disabled")
|
if (WAMR_DISABLE_WRITE_GS_BASE EQUAL 1)
|
||||||
elseif (WAMR_BUILD_TARGET STREQUAL "X86_64"
|
# disabled by user
|
||||||
AND WAMR_BUILD_PLATFORM STREQUAL "linux")
|
set (DISABLE_WRITE_GS_BASE 1)
|
||||||
set (TEST_WRGSBASE_SOURCE "${CMAKE_BINARY_DIR}/test_wrgsbase.c")
|
elseif (WAMR_DISABLE_WRITE_GS_BASE EQUAL 0)
|
||||||
file (WRITE "${TEST_WRGSBASE_SOURCE}" "
|
# enabled by user
|
||||||
#include <stdio.h>
|
set (DISABLE_WRITE_GS_BASE 0)
|
||||||
#include <stdint.h>
|
elseif (CMAKE_CROSSCOMPILING)
|
||||||
int main() {
|
# disabled in cross compilation environment
|
||||||
uint64_t value;
|
set (DISABLE_WRITE_GS_BASE 1)
|
||||||
asm volatile (\"wrgsbase %0\" : : \"r\"(value));
|
else ()
|
||||||
printf(\"WRGSBASE instruction is available.\\n\");
|
# auto-detected by the compiler
|
||||||
return 0;
|
set (TEST_WRGSBASE_SOURCE "${CMAKE_BINARY_DIR}/test_wrgsbase.c")
|
||||||
}")
|
file (WRITE "${TEST_WRGSBASE_SOURCE}" "
|
||||||
# Try to compile and run the test program
|
#include <stdio.h>
|
||||||
try_run (TEST_WRGSBASE_RESULT
|
#include <stdint.h>
|
||||||
TEST_WRGSBASE_COMPILED
|
int main() {
|
||||||
${CMAKE_BINARY_DIR}/test_wrgsbase
|
uint64_t value;
|
||||||
SOURCES ${TEST_WRGSBASE_SOURCE}
|
asm volatile (\"wrgsbase %0\" : : \"r\"(value));
|
||||||
CMAKE_FLAGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
printf(\"WRGSBASE instruction is available.\\n\");
|
||||||
)
|
return 0;
|
||||||
#message("${TEST_WRGSBASE_COMPILED}, ${TEST_WRGSBASE_RESULT}")
|
}")
|
||||||
if (NOT TEST_WRGSBASE_RESULT EQUAL 0)
|
# Try to compile and run the test program
|
||||||
|
try_run (TEST_WRGSBASE_RESULT
|
||||||
|
TEST_WRGSBASE_COMPILED
|
||||||
|
${CMAKE_BINARY_DIR}/test_wrgsbase
|
||||||
|
SOURCES ${TEST_WRGSBASE_SOURCE}
|
||||||
|
CMAKE_FLAGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
||||||
|
)
|
||||||
|
#message("${TEST_WRGSBASE_COMPILED}, ${TEST_WRGSBASE_RESULT}")
|
||||||
|
if (TEST_WRGSBASE_RESULT EQUAL 0)
|
||||||
|
set (DISABLE_WRITE_GS_BASE 0)
|
||||||
|
else ()
|
||||||
|
set (DISABLE_WRITE_GS_BASE 1)
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
if (DISABLE_WRITE_GS_BASE EQUAL 1)
|
||||||
add_definitions (-DWASM_DISABLE_WRITE_GS_BASE=1)
|
add_definitions (-DWASM_DISABLE_WRITE_GS_BASE=1)
|
||||||
message (" Write linear memory base addr to x86 GS register disabled")
|
message (" Write linear memory base addr to x86 GS register disabled")
|
||||||
|
else ()
|
||||||
|
add_definitions (-DWASM_DISABLE_WRITE_GS_BASE=0)
|
||||||
|
message (" Write linear memory base addr to x86 GS register enabled")
|
||||||
endif ()
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
if (WAMR_CONFIGUABLE_BOUNDS_CHECKS EQUAL 1)
|
if (WAMR_CONFIGUABLE_BOUNDS_CHECKS EQUAL 1)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user