mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-11-07 09:16:08 -10:00
CMake: too-long-line fixes, options reorg, and some cleanups
- Try to avoid lines >140 characters.
- I intentionally left out the `unittests` directory. That is a
behemoth.
- Everything was done ad-hoc in accordance with what I believe is most
readable, anything changed is up for debate.
- Added a step to PR code format that enforces this.
- Reorganize options a little bit, and add some spacing.
- Small cleanups here and there, e.g. multi-arg target commands and
`Threads::Threads` instead of PTHREAD_LIB.
Verified long lines via:
```sh
$ find \( -name 'CMakeLists.txt' -o -name '*.cmake*' \) -exec wc -L {} \; | grep -ve "unittests\|External" | while read -r line; do [ "$(echo "$line" | cut -d' ' -f1)" -gt 140 ] && echo $line; done
290 ./Source/Tools/FEXInterpreter/CMakeLists.txt
```
FEXInterpreter will require some more invasive changes to get those long
lines out of there.
Signed-off-by: crueter <[email protected]>
This commit is contained in:
22 files changed
+212
-99
No files matched your search
@@ -61,3 +61,19 @@ jobs:
|
||||
--start-rev "$START_REV" \
|
||||
--end-rev "$END_REV" \
|
||||
--changed-files "$CHANGED_FILES"
|
||||
|
||||
- name: Check long CMake lines
|
||||
if: always()
|
||||
run: |
|
||||
# check lines > 140 chars
|
||||
# unit tests are left alone for now
|
||||
# FEXInterpreter is also left alone until its long echo lines can be removed
|
||||
echo "$CHANGED_FILES" | tr ',' '\n' | grep -ve "unittests\|External\|FEXInterpreter" \
|
||||
| grep -e "CMakeLists.txt\|\.cmake" | xargs -L1 wc -L | while read -r line; do
|
||||
if [ "$(echo "$line" | cut -d' ' -f1)" -gt 140 ]; then
|
||||
echo "$line"
|
||||
fi
|
||||
done | tee lines.txt
|
||||
|
||||
# if any lines were emitted, fail
|
||||
[ ! -s lines.txt ]
|
||||
@@ -0,0 +1 @@
|
||||
line_max_words = 140
|
||||
+76
-36
@@ -6,39 +6,57 @@ check_include_files("gdb/jit-reader.h" HAVE_GDB_JIT_READER_H)
|
||||
|
||||
option(BUILD_FEX_LINUX_TESTS "Build FEXLinuxTests (requires x86 compiler)" FALSE)
|
||||
option(BUILD_THUNKS "Build thunks" FALSE)
|
||||
option(BUILD_FEXCONFIG "Build FEXConfig" TRUE)
|
||||
option(ENABLE_CLANG_THUNKS "Build thunks with clang" TRUE)
|
||||
|
||||
option(BUILD_FEXCONFIG "Build FEXConfig" TRUE)
|
||||
option(ENABLE_IWYU "Enable the Include What You Use sanitizer" FALSE)
|
||||
option(ENABLE_LTO "Enable LTO with compilation" TRUE)
|
||||
option(ENABLE_XRAY "Enable building with LLVM X-Ray" FALSE)
|
||||
option(ENABLE_COVERAGE "Enable Code Coverage" FALSE)
|
||||
set(USE_LINKER "" CACHE STRING "Path to a custom linker program")
|
||||
|
||||
option(ENABLE_XRAY "Enable building with LLVM X-Ray" FALSE)
|
||||
option(ENABLE_UBSAN "Enable the Clang Undefined Behavior Sanitizer" FALSE)
|
||||
option(ENABLE_ASAN "Enable the Clang Address Sanitizer" FALSE)
|
||||
option(ENABLE_TSAN "Enable the Clang Thread Sanitizer" FALSE)
|
||||
option(ENABLE_COVERAGE "Enable Code Coverage" FALSE)
|
||||
|
||||
option(ENABLE_ASSERTIONS "Enable debug assertions" FALSE)
|
||||
option(ENABLE_GDB_SYMBOLS "Enable GDBSymbols integration support" ${HAVE_GDB_JIT_READER_H})
|
||||
|
||||
option(ENABLE_STRICT_WERROR "Enable stricter -Werror" FALSE)
|
||||
option(ENABLE_WERROR "Enable -Werror" FALSE)
|
||||
|
||||
option(ENABLE_FEX_ALLOCATOR "Enable allocator for FEX" TRUE)
|
||||
option(ENABLE_JEMALLOC_GLIBC_ALLOC "Enable jemalloc glibc allocator" TRUE)
|
||||
|
||||
option(ENABLE_OFFLINE_TELEMETRY "Enable FEX offline telemetry" TRUE)
|
||||
option(ENABLE_COMPILE_TIME_TRACE "Enable time trace compile option" FALSE)
|
||||
|
||||
option(ENABLE_LIBCXX "Use LLVM's libc++ instead of the GNU libstdc++" FALSE)
|
||||
option(ENABLE_CCACHE "Enable ccache for build caching" TRUE)
|
||||
|
||||
option(ENABLE_VIXL_SIMULATOR "Use the VIXL simulator for emulation (only useful for CI testing)" FALSE)
|
||||
option(ENABLE_VIXL_DISASSEMBLER "Enable debug disassembler output with VIXL" FALSE)
|
||||
option(ENABLE_ZYDIS "Enable x86/x86-64 guest disassembler output with Zydis" FALSE)
|
||||
|
||||
option(USE_LEGACY_BINFMTMISC "Use legacy method of setting up binfmt_misc" FALSE)
|
||||
|
||||
option(ENABLE_FEXCORE_PROFILER "Enable FEXCore's timeline profiling capabilities" FALSE)
|
||||
set(FEXCORE_PROFILER_BACKEND "gpuvis" CACHE STRING "Set which backend to use for FEXCore's profiler")
|
||||
set_property(CACHE FEXCORE_PROFILER_BACKEND PROPERTY STRINGS gpuvis tracy)
|
||||
|
||||
option(ENABLE_GLIBC_ALLOCATOR_HOOK_FAULT "Enables glibc memory allocation hooking with fault for CI testing")
|
||||
|
||||
option(USE_PDB_DEBUGINFO "Build debug info in PDB format" FALSE)
|
||||
option(BUILD_STEAM_SUPPORT "Enable Steam integration" FALSE)
|
||||
|
||||
set(X86_32_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/Data/CMake/toolchain_x86_32.cmake" CACHE FILEPATH "Toolchain file for the (cross-)compiler targeting i686")
|
||||
set(X86_64_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/Data/CMake/toolchain_x86_64.cmake" CACHE FILEPATH "Toolchain file for the (cross-)compiler targeting x86_64")
|
||||
set(X86_32_TOOLCHAIN_FILE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/Data/CMake/toolchain_x86_32.cmake"
|
||||
CACHE FILEPATH "Toolchain file for the (cross-)compiler targeting i686")
|
||||
|
||||
set(X86_64_TOOLCHAIN_FILE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/Data/CMake/toolchain_x86_64.cmake"
|
||||
CACHE FILEPATH "Toolchain file for the (cross-)compiler targeting x86_64")
|
||||
|
||||
set(X86_DEV_ROOTFS "/" CACHE FILEPATH "Path to the sysroot used for cross-compiling for i686 and x86_64")
|
||||
set(DATA_DIRECTORY "" CACHE PATH "Global data directory (override)")
|
||||
set(HOSTLIBS_DATA_DIRECTORY "" CACHE PATH "Global data directory (override)")
|
||||
@@ -81,7 +99,8 @@ else ()
|
||||
message(STATUS "Clang version ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
set(CLANG_MINIMUM_VERSION 13.0)
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${CLANG_MINIMUM_VERSION})
|
||||
message(FATAL_ERROR "Clang version too old for FEX. Need at least ${CLANG_MINIMUM_VERSION} but has ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
message(FATAL_ERROR "Clang version too old for FEX. Need at least "
|
||||
"${CLANG_MINIMUM_VERSION} but has ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -137,7 +156,8 @@ if (ENABLE_FEXCORE_PROFILER)
|
||||
# Tracy can gather call stack samples in regular intervals, but this
|
||||
# isn't useful for us since it would usually sample opaque JIT code
|
||||
add_compile_definitions(TRACY_NO_SAMPLING=1)
|
||||
# This pulls in libbacktrace which allocators in global constructors (before FEX can set up its allocator hooks)
|
||||
# This pulls in libbacktrace which allocators in global constructors
|
||||
# (before FEX can set up its allocator hooks)
|
||||
add_compile_definitions(TRACY_NO_CALLSTACK=1)
|
||||
if (MINGW)
|
||||
message(FATAL_ERROR "Tracy profiler not supported on MinGW")
|
||||
@@ -174,8 +194,7 @@ set(OVERRIDE_HASH "detect" CACHE STRING "Override the FEX git hash")
|
||||
|
||||
get_property(IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||
if (NOT IS_MULTI_CONFIG AND NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release
|
||||
CACHE STRING "Choose the type of build." FORCE)
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
|
||||
message(STATUS "No build type set, defaulting to a Release build")
|
||||
endif()
|
||||
|
||||
@@ -246,7 +265,7 @@ check_cxx_source_compiles(
|
||||
return program_invocation_name == nullptr;
|
||||
}"
|
||||
HAS_PROGRAM_INVOCATION_NAME)
|
||||
add_compile_definitions("HAS_PROGRAM_INVOCATION_NAME=${HAS_PROGRAM_INVOCATION_NAME}")
|
||||
add_compile_definitions( "HAS_PROGRAM_INVOCATION_NAME=${HAS_PROGRAM_INVOCATION_NAME}")
|
||||
|
||||
if (ENABLE_VIXL_SIMULATOR)
|
||||
# We can run the simulator on both x86-64 or AArch64 hosts
|
||||
@@ -278,7 +297,8 @@ if (ENABLE_COMPILE_TIME_TRACE)
|
||||
link_libraries(-ftime-trace)
|
||||
endif()
|
||||
|
||||
set(PTHREAD_LIB pthread)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
if (USE_LINKER)
|
||||
message(STATUS "Overriding linker to: ${USE_LINKER}")
|
||||
@@ -287,8 +307,8 @@ endif()
|
||||
|
||||
if (ENABLE_LIBCXX)
|
||||
message(WARNING "This is an unsupported configuration and should only be used for testing")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi")
|
||||
list(APPEND CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++")
|
||||
list(APPEND CMAKE_EXE_LINKER_FLAGS "-stdlib=libc++ -lc++abi")
|
||||
endif()
|
||||
|
||||
if (NOT ENABLE_OFFLINE_TELEMETRY)
|
||||
@@ -298,15 +318,16 @@ endif()
|
||||
|
||||
if (ENABLE_UBSAN)
|
||||
# See https://github.com/FEX-Emu/FEX/pull/4494#issuecomment-2800608944
|
||||
# and related discussion for the use of -fno-sanitize=alignment -fno-sanitize=function
|
||||
# with UBSAN.
|
||||
# alignment: we don't follow a strict alignment policy, for example IR uses packed structs
|
||||
# that are regularly access unaligned.
|
||||
# function: syscalls cast function pointers to void (*)(unsigned long...), causing warnings
|
||||
# related to this access.
|
||||
# and related discussion for the use of -fno-sanitize=alignment and -fno-sanitize=function with UBSAN.
|
||||
# alignment: we don't follow a strict alignment policy, for example IR uses packed structs that are regularly access unaligned.
|
||||
# function: syscalls cast function pointers to void (*)(unsigned long...), causing warnings related to this access.
|
||||
add_compile_definitions(ENABLE_UBSAN=1)
|
||||
add_compile_options(-fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize=alignment -fno-sanitize=function -fno-sanitize-recover=undefined)
|
||||
link_libraries(-fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize=alignment -fno-sanitize=function -fno-sanitize-recover=undefined)
|
||||
add_compile_options(-fno-omit-frame-pointer -fsanitize=undefined
|
||||
-fno-sanitize=alignment -fno-sanitize=function
|
||||
-fno-sanitize-recover=undefined)
|
||||
link_libraries(-fno-omit-frame-pointer -fsanitize=undefined
|
||||
-fno-sanitize=alignment -fno-sanitize=function
|
||||
-fno-sanitize-recover=undefined)
|
||||
endif()
|
||||
|
||||
if (ENABLE_ASAN)
|
||||
@@ -328,7 +349,8 @@ endif()
|
||||
if (ENABLE_JEMALLOC_GLIBC_ALLOC)
|
||||
# The glibc jemalloc subproject which hooks the glibc allocator.
|
||||
# Required for thunks to work.
|
||||
# All host native libraries will use this allocator, while *most* other FEX internal allocations will use the other jemalloc allocator.
|
||||
# All host native libraries will use this allocator, while *most*
|
||||
# other FEX internal allocations will use the other jemalloc allocator.
|
||||
add_subdirectory(External/jemalloc_glibc/)
|
||||
elseif (NOT MINGW)
|
||||
message(STATUS
|
||||
@@ -354,11 +376,11 @@ if (USE_PDB_DEBUGINFO)
|
||||
add_link_options(-g -Wl,--pdb=)
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fno-omit-frame-pointer")
|
||||
set(CMAKE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_LINKER_FLAGS_RELWITHDEBINFO} -fno-omit-frame-pointer")
|
||||
string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " -fno-omit-frame-pointer")
|
||||
string(APPEND CMAKE_LINKER_FLAGS_RELWITHDEBINFO " -fno-omit-frame-pointer")
|
||||
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer")
|
||||
set(CMAKE_LINKER_FLAGS_RELEASE "${CMAKE_LINKER_FLAGS_RELEASE} -fomit-frame-pointer")
|
||||
string(APPEND CMAKE_CXX_FLAGS_RELEASE " -fomit-frame-pointer")
|
||||
string(APPEND CMAKE_LINKER_FLAGS_RELEASE " -fomit-frame-pointer")
|
||||
|
||||
## Modules ##
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/Data/CMake/)
|
||||
@@ -424,7 +446,8 @@ if (BUILD_TESTING)
|
||||
add_subdirectory(External/Catch2/)
|
||||
|
||||
# Pull in catch_discover_tests definition
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/External/Catch2/contrib/")
|
||||
list(APPEND CMAKE_MODULE_PATH
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/External/Catch2/contrib/")
|
||||
endif()
|
||||
|
||||
include(Catch)
|
||||
@@ -451,7 +474,8 @@ endif()
|
||||
|
||||
if (NOT range-v3_FOUND)
|
||||
add_subdirectory(External/range-v3/)
|
||||
target_compile_definitions(range-v3 INTERFACE RANGES_DISABLE_DEPRECATED_WARNINGS)
|
||||
target_compile_definitions(range-v3 INTERFACE
|
||||
RANGES_DISABLE_DEPRECATED_WARNINGS)
|
||||
endif()
|
||||
|
||||
add_subdirectory(External/tiny-json/)
|
||||
@@ -492,11 +516,13 @@ if(ENABLE_WERROR OR ENABLE_STRICT_WERROR)
|
||||
endif()
|
||||
|
||||
set(FEX_TUNE_COMPILE_FLAGS)
|
||||
|
||||
if (NOT TUNE_ARCH STREQUAL "generic")
|
||||
set(TUNE_ARCH_STRING "${TUNE_ARCH}")
|
||||
if(ARCHITECTURE_arm64)
|
||||
set(TUNE_ARCH_STRING "${TUNE_ARCH}+crc")
|
||||
endif()
|
||||
|
||||
check_cxx_compiler_flag("-march=${TUNE_ARCH_STRING}" COMPILER_SUPPORTS_ARCH_TYPE)
|
||||
if(COMPILER_SUPPORTS_ARCH_TYPE)
|
||||
list(APPEND FEX_TUNE_COMPILE_FLAGS "-march=${TUNE_ARCH_STRING}")
|
||||
@@ -513,19 +539,23 @@ if (TUNE_CPU STREQUAL "native")
|
||||
if(ARCHITECTURE_arm64)
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 999999.0)
|
||||
# Clang 12.0 fixed the -mcpu=native bug with mixed big.little implementers
|
||||
# Clang can not currently check for native Apple M1 type in hypervisor. Currently disabled
|
||||
# Clang can not currently check for native Apple M1 type in hypervisor.
|
||||
# Currently disabled
|
||||
check_cxx_compiler_flag("-mcpu=native" COMPILER_SUPPORTS_CPU_TYPE)
|
||||
if(COMPILER_SUPPORTS_CPU_TYPE)
|
||||
list(APPEND FEX_TUNE_COMPILE_FLAGS "-mcpu=native")
|
||||
endif()
|
||||
else()
|
||||
execute_process(COMMAND python3 "${PROJECT_SOURCE_DIR}/Scripts/aarch64_fit_native.py" "/proc/cpuinfo" "${CMAKE_CXX_COMPILER_VERSION}"
|
||||
execute_process(COMMAND python3
|
||||
"${PROJECT_SOURCE_DIR}/Scripts/aarch64_fit_native.py"
|
||||
"/proc/cpuinfo" "${CMAKE_CXX_COMPILER_VERSION}"
|
||||
OUTPUT_VARIABLE AARCH64_CPU)
|
||||
|
||||
string(STRIP ${AARCH64_CPU} AARCH64_CPU)
|
||||
|
||||
execute_process(COMMAND python3 "${PROJECT_SOURCE_DIR}/Scripts/NeedDisabledSVE.py"
|
||||
RESULT_VARIABLE NEEDS_SVE_DISABLED)
|
||||
|
||||
if (NEEDS_SVE_DISABLED)
|
||||
message(STATUS "Platform has bugged SVE. Disabling")
|
||||
set(AARCH64_CPU "cortex-a78")
|
||||
@@ -547,7 +577,8 @@ elseif (NOT TUNE_CPU STREQUAL "none")
|
||||
if(COMPILER_SUPPORTS_CPU_TYPE)
|
||||
list(APPEND FEX_TUNE_COMPILE_FLAGS "-mcpu=${TUNE_CPU}")
|
||||
else()
|
||||
message(FATAL_ERROR "Trying to compile cpu type '${TUNE_CPU}' but the compiler doesn't support this")
|
||||
message(FATAL_ERROR "Trying to compile cpu type '${TUNE_CPU}' "
|
||||
"but the compiler doesn't support this")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -610,29 +641,38 @@ add_compile_options(-Wall)
|
||||
if (BUILD_TESTING)
|
||||
message(STATUS "Unit tests are enabled")
|
||||
|
||||
set(TEST_JOB_COUNT "" CACHE STRING "Override number of parallel jobs to use while running tests")
|
||||
set(TEST_JOB_COUNT "" CACHE STRING
|
||||
"Override number of parallel jobs to use while running tests")
|
||||
if (TEST_JOB_COUNT)
|
||||
message(STATUS "Running tests with ${TEST_JOB_COUNT} jobs")
|
||||
elseif(CMAKE_VERSION VERSION_LESS "3.29")
|
||||
execute_process(COMMAND "nproc" OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE TEST_JOB_COUNT)
|
||||
execute_process(COMMAND "nproc"
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
OUTPUT_VARIABLE TEST_JOB_COUNT)
|
||||
endif()
|
||||
|
||||
set(TEST_JOB_FLAG "-j${TEST_JOB_COUNT}")
|
||||
|
||||
# When running "ninja tests", defined below, it is useful to intentionally
|
||||
# oversubscribe the CPU cores since many of the tests spend their time idle.
|
||||
if ("$CACHE{TEST_JOB_COUNT}" STREQUAL "")
|
||||
execute_process(COMMAND "nproc" OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE TESTS_TARGET_JOB_COUNT)
|
||||
execute_process(COMMAND "nproc"
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
OUTPUT_VARIABLE TESTS_TARGET_JOB_COUNT)
|
||||
|
||||
math(EXPR TESTS_TARGET_JOB_COUNT "${TESTS_TARGET_JOB_COUNT} * 3 / 2")
|
||||
set(TESTS_TARGET_JOB_FLAG "-j${TESTS_TARGET_JOB_COUNT}")
|
||||
else()
|
||||
set(TESTS_TARGET_JOB_FLAG ${TEST_JOB_FLAG})
|
||||
endif()
|
||||
|
||||
# Runs the whole test suite, with large pages enabled to reduce the cost of fork() in ctest.
|
||||
# Runs the whole test suite, with large pages enabled to
|
||||
# reduce the cost of fork() in ctest.
|
||||
add_custom_target(tests
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
|
||||
USES_TERMINAL
|
||||
COMMAND ${CMAKE_COMMAND} -E env GLIBC_TUNABLES=glibc.malloc.hugetlb=1 ctest "--progress" "--timeout" "302" ${TESTS_TARGET_JOB_FLAG})
|
||||
COMMAND ${CMAKE_COMMAND} -E env GLIBC_TUNABLES=glibc.malloc.hugetlb=1
|
||||
ctest "--progress" "--timeout" "302" ${TESTS_TARGET_JOB_FLAG})
|
||||
endif()
|
||||
|
||||
add_subdirectory(External/SoftFloat-3e/)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# This applies some common linker options that reduce code size and linking time in Release mode. Namely:
|
||||
# --gc-sections: Linktime garbage collection, discards unused sections from the final output
|
||||
# --strip-all : Similar to running `strip`, discards the symbol table from the final output
|
||||
# --as-needed : Only includes libraries that are actually needed in the final output.
|
||||
# --as-needed : Only includes libraries that are actually needed in the final output
|
||||
|
||||
macro(LinkerGC target)
|
||||
if (CMAKE_BUILD_TYPE MATCHES "RELEASE")
|
||||
|
||||
@@ -6,14 +6,17 @@ set(CMAKE_CXX_COMPILER ${MINGW_TRIPLE}-clang++)
|
||||
set(CMAKE_DLLTOOL ${MINGW_TRIPLE}-dlltool)
|
||||
set(CMAKE_AR ${MINGW_TRIPLE}-ar)
|
||||
|
||||
# Compile everything as static to avoid requiring the MinGW runtime libraries, force page aligned sections so that
|
||||
# debug symbols work correctly, and disable loop alignment to workaround an LLVM bug
|
||||
# Compile everything as static to avoid requiring the MinGW runtime libraries,
|
||||
# force page aligned sections so that debug symbols work correctly,
|
||||
# and disable loop alignment to workaround an LLVM bug
|
||||
# (https://github.com/llvm/llvm-project/issues/47432)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_INIT "-static -Wl,--file-alignment=4096,/mllvm:-align-loops=1")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_INIT "-static -Wl,--file-alignment=4096,/mllvm:-align-loops=1")
|
||||
|
||||
set(CMAKE_C_STANDARD_LIBRARIES "" CACHE STRING "" FORCE)
|
||||
set(CMAKE_CXX_STANDARD_LIBRARIES "" CACHE STRING "" FORCE)
|
||||
set(CMAKE_STANDARD_LIBRARIES "" CACHE STRING "" FORCE)
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Windows)
|
||||
set(CMAKE_SYSTEM_PROCESSOR ${MINGW_TRIPLE})
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@ if (NOT USE_LEGACY_BINFMTMISC)
|
||||
configure_file(FEX-x86.conf.in ${CMAKE_BINARY_DIR}/Data/binfmts/FEX-x86.conf)
|
||||
configure_file(FEX-x86_64.conf.in ${CMAKE_BINARY_DIR}/Data/binfmts/FEX-x86_64.conf)
|
||||
|
||||
install(FILES ${CMAKE_BINARY_DIR}/Data/binfmts/FEX-x86.conf ${CMAKE_BINARY_DIR}/Data/binfmts/FEX-x86_64.conf
|
||||
install(FILES ${CMAKE_BINARY_DIR}/Data/binfmts/FEX-x86.conf
|
||||
${CMAKE_BINARY_DIR}/Data/binfmts/FEX-x86_64.conf
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/binfmt.d/
|
||||
COMPONENT Runtime)
|
||||
else()
|
||||
|
||||
@@ -33,9 +33,11 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/git_version.h.in
|
||||
include_directories(${CMAKE_BINARY_DIR}/generated)
|
||||
|
||||
# Disable strict aliasing for all build modes
|
||||
# See discussion in https://github.com/FEX-Emu/FEX/pull/4494#issuecomment-2800608944
|
||||
# See discussion in
|
||||
# https://github.com/FEX-Emu/FEX/pull/4494#issuecomment-2800608944
|
||||
# for background context.
|
||||
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-strict-aliasing> $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>)
|
||||
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-strict-aliasing>
|
||||
$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>)
|
||||
|
||||
add_subdirectory(Source/)
|
||||
|
||||
|
||||
@@ -104,9 +104,13 @@ if (ENABLE_ZYDIS)
|
||||
endif()
|
||||
|
||||
if (ARCHITECTURE_arm64 AND HAS_CLANG_PRESERVE_ALL)
|
||||
list(APPEND DEFINES "-DFEXCORE_PRESERVE_ALL_ATTR=__attribute__((preserve_all));-DFEXCORE_HAS_PRESERVE_ALL_ATTR=1")
|
||||
list(APPEND DEFINES
|
||||
"-DFEXCORE_PRESERVE_ALL_ATTR=__attribute__((preserve_all))"
|
||||
"-DFEXCORE_HAS_PRESERVE_ALL_ATTR=1")
|
||||
else()
|
||||
list(APPEND DEFINES "-DFEXCORE_PRESERVE_ALL_ATTR=;-DFEXCORE_HAS_PRESERVE_ALL_ATTR=0")
|
||||
list(APPEND DEFINES
|
||||
"-DFEXCORE_PRESERVE_ALL_ATTR="
|
||||
"-DFEXCORE_HAS_PRESERVE_ALL_ATTR=0")
|
||||
endif()
|
||||
|
||||
set(LIBS fmt::fmt xxHash::xxhash FEXHeaderUtils CodeEmitter cephes_128bit)
|
||||
@@ -187,8 +191,8 @@ add_custom_command(
|
||||
OUTPUT "${OUTPUT_MAN_NAME}"
|
||||
DEPENDS "${INPUT_CONFIG_NAME}"
|
||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/../Scripts/config_generator.py"
|
||||
COMMAND "python3" "${CMAKE_CURRENT_SOURCE_DIR}/../Scripts/config_generator.py" "${INPUT_CONFIG_NAME}" "${OUTPUT_CONFIG_NAME}" "${OUTPUT_MAN_NAME}"
|
||||
"${OUTPUT_CONFIG_OPTION_NAME}")
|
||||
COMMAND "python3" "${CMAKE_CURRENT_SOURCE_DIR}/../Scripts/config_generator.py"
|
||||
"${INPUT_CONFIG_NAME}" "${OUTPUT_CONFIG_NAME}" "${OUTPUT_MAN_NAME}" "${OUTPUT_CONFIG_OPTION_NAME}")
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT "${OUTPUT_MAN_NAME_COMPRESS}"
|
||||
@@ -284,8 +288,8 @@ function(AddLibrary Name Type)
|
||||
add_library(${Name} ${Type} $<TARGET_OBJECTS:${PROJECT_NAME}_object>)
|
||||
set_target_properties(${Name} PROPERTIES OUTPUT_NAME FEXCore)
|
||||
|
||||
# During generation of the import library (dll.a), MinGW needs some extra symbols from libraries
|
||||
# such as fmt, which are propagated by FEXCore_Base. Wonderful.
|
||||
# During generation of the import library (dll.a), MinGW needs some extra
|
||||
# symbols from libraries such as fmt, which are propagated by FEXCore_Base
|
||||
if (MINGW)
|
||||
target_link_libraries(${Name} PRIVATE FEXCore_Base)
|
||||
endif()
|
||||
@@ -311,7 +315,8 @@ if (ENABLE_FEX_ALLOCATOR)
|
||||
target_include_directories(JemallocLibs PRIVATE "${PROJECT_SOURCE_DIR}/include/")
|
||||
endif()
|
||||
if (ENABLE_JEMALLOC_GLIBC_ALLOC)
|
||||
set_source_files_properties(Interface/HLE/Thunks/Thunks.cpp PROPERTIES COMPILE_DEFINITIONS ENABLE_JEMALLOC_GLIBC=1)
|
||||
set_source_files_properties(Interface/HLE/Thunks/Thunks.cpp
|
||||
PROPERTIES COMPILE_DEFINITIONS ENABLE_JEMALLOC_GLIBC=1)
|
||||
target_link_libraries(JemallocLibs INTERFACE FEX_jemalloc_glibc)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -4,9 +4,11 @@ set(LIBS fmt::fmt vixl::vixl Catch2::Catch2WithMain FEXCore_Base JemallocLibs)
|
||||
foreach(TEST ${TESTS})
|
||||
get_filename_component(TEST_NAME ${TEST} NAME_WLE)
|
||||
add_executable(FEXCore_Tests_${TEST_NAME} ${TEST})
|
||||
|
||||
target_link_libraries(FEXCore_Tests_${TEST_NAME} PRIVATE ${LIBS})
|
||||
target_include_directories(FEXCore_Tests_${TEST_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../../Source/")
|
||||
target_compile_options(FEXCore_Tests_${TEST_NAME} PRIVATE ${FEX_TUNE_COMPILE_FLAGS})
|
||||
|
||||
set_target_properties(FEXCore_Tests_${TEST_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/FEXCore_Tests")
|
||||
catch_discover_tests(FEXCore_Tests_${TEST_NAME} TEST_SUFFIX ".${TEST_NAME}.FEXCore_Tests")
|
||||
endforeach()
|
||||
|
||||
@@ -3,4 +3,4 @@ list(APPEND LIBS FEXCore Common CommonTools JemallocLibs)
|
||||
add_executable(CodeSizeValidation Main.cpp)
|
||||
target_include_directories(CodeSizeValidation PRIVATE ${CMAKE_BINARY_DIR}/generated)
|
||||
|
||||
target_link_libraries(CodeSizeValidation PRIVATE ${LIBS} ${PTHREAD_LIB})
|
||||
target_link_libraries(CodeSizeValidation PRIVATE ${LIBS} Threads::Threads)
|
||||
@@ -1,5 +1,5 @@
|
||||
list(APPEND LIBS FEXCore Common JemallocLibs LinuxEmulation
|
||||
CommonTools ${PTHREAD_LIB} fmt::fmt)
|
||||
CommonTools Threads::Threads fmt::fmt)
|
||||
|
||||
set(DEFINES)
|
||||
if (ENABLE_VIXL_SIMULATOR)
|
||||
|
||||
@@ -10,9 +10,11 @@ target_link_libraries(FEXOfflineCompiler PRIVATE
|
||||
|
||||
if (MINGW)
|
||||
if (ARCHITECTURE_arm64ec)
|
||||
set_target_properties(FEXOfflineCompiler PROPERTIES OUTPUT_NAME "FEXOfflineCompiler64")
|
||||
set_target_properties(FEXOfflineCompiler PROPERTIES OUTPUT_NAME
|
||||
"FEXOfflineCompiler64")
|
||||
else()
|
||||
set_target_properties(FEXOfflineCompiler PROPERTIES OUTPUT_NAME "FEXOfflineCompiler32")
|
||||
set_target_properties(FEXOfflineCompiler PROPERTIES OUTPUT_NAME
|
||||
"FEXOfflineCompiler32")
|
||||
endif()
|
||||
patch_library_wine(FEXOfflineCompiler)
|
||||
target_include_directories(FEXOfflineCompiler PRIVATE
|
||||
@@ -22,7 +24,7 @@ if (MINGW)
|
||||
)
|
||||
target_link_libraries(FEXOfflineCompiler PRIVATE CommonWindows ntdll_ex)
|
||||
else()
|
||||
target_link_libraries(FEXOfflineCompiler PRIVATE ${PTHREAD_LIB} LinuxEmulation)
|
||||
target_link_libraries(FEXOfflineCompiler PRIVATE Threads::Threads LinuxEmulation)
|
||||
endif()
|
||||
|
||||
LinkerGC(FEXOfflineCompiler)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
add_executable(FEXRootFSFetcher Main.cpp XXFileHash.cpp)
|
||||
list(APPEND LIBS FEXCore Common JemallocDummy xxHash::xxhash ${PTHREAD_LIB})
|
||||
list(APPEND LIBS FEXCore Common JemallocDummy xxHash::xxhash Threads::Threads)
|
||||
|
||||
LinkerGC(FEXRootFSFetcher)
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ add_executable(FEXServer
|
||||
|
||||
target_include_directories(FEXServer PRIVATE ${CMAKE_BINARY_DIR}/generated)
|
||||
|
||||
target_link_libraries(FEXServer PRIVATE FEXCore Common CommonTools JemallocDummy ${PTHREAD_LIB})
|
||||
target_link_libraries(FEXServer PRIVATE FEXCore Common CommonTools JemallocDummy Threads::Threads)
|
||||
|
||||
LinkerGC(FEXServer)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
list(APPEND LIBS FEXCore Common JemallocLibs ${PTHREAD_LIB})
|
||||
list(APPEND LIBS FEXCore Common JemallocLibs Threads::Threads)
|
||||
|
||||
set(SRCS TestHarnessRunner.cpp)
|
||||
if (NOT MINGW)
|
||||
|
||||
@@ -6,13 +6,16 @@ function(build_implib name)
|
||||
COMMENT "Building lib${name_ex}.a")
|
||||
|
||||
add_library(${name_ex} SHARED IMPORTED)
|
||||
set_property(TARGET ${name_ex} PROPERTY IMPORTED_IMPLIB ${CMAKE_CURRENT_BINARY_DIR}/lib${name_ex}.a)
|
||||
set_property(TARGET ${name_ex} PROPERTY
|
||||
IMPORTED_IMPLIB ${CMAKE_CURRENT_BINARY_DIR}/lib${name_ex}.a)
|
||||
add_dependencies(${name_ex} ${name_ex}lib)
|
||||
endfunction()
|
||||
|
||||
function(patch_library_wine target)
|
||||
add_custom_command(TARGET ${target} POST_BUILD
|
||||
COMMAND dd bs=32 count=1 seek=2 conv=notrunc if=${CMAKE_SOURCE_DIR}/Source/Windows/wine_builtin.bin of=$<TARGET_FILE:${target}>)
|
||||
COMMAND dd bs=32 count=1 seek=2 conv=notrunc
|
||||
if=${CMAKE_SOURCE_DIR}/Source/Windows/wine_builtin.bin
|
||||
of=$<TARGET_FILE:${target}>)
|
||||
endfunction()
|
||||
|
||||
separate_arguments(CXX_FLAGS_LIST NATIVE_COMMAND "${CMAKE_CXX_FLAGS}")
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
target_sources(CommonWindowsRuntime PRIVATE Alloc.cpp IO.cpp Math.cpp String.cpp Misc.cpp CRT.cpp)
|
||||
target_sources(CommonWindowsRuntime PRIVATE
|
||||
Alloc.cpp IO.cpp Math.cpp String.cpp Misc.cpp CRT.cpp)
|
||||
add_subdirectory(Musl)
|
||||
@@ -1 +1,4 @@
|
||||
target_sources(CommonWindowsRuntime PRIVATE exp2.c log2_data.c remainder.c strtoimax.c strtoull.c exp_data.c fmod.c log2.c isnan.c remquo.c strtoll.c strtoumax.c __math_uflow.c __math_oflow.c __math_xflow.c __math_invalid.c __math_divzero.c)
|
||||
target_sources(CommonWindowsRuntime PRIVATE
|
||||
exp2.c log2_data.c remainder.c strtoimax.c strtoull.c exp_data.c fmod.c
|
||||
log2.c isnan.c remquo.c strtoll.c strtoumax.c __math_uflow.c __math_oflow.c
|
||||
__math_xflow.c __math_invalid.c __math_divzero.c)
|
||||
@@ -13,11 +13,13 @@ endif()
|
||||
|
||||
add_library(thunkgenlib STATIC analysis.cpp data_layout.cpp gen.cpp)
|
||||
target_include_directories(thunkgenlib INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_include_directories(thunkgenlib SYSTEM PUBLIC ${CLANG_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS})
|
||||
target_include_directories(thunkgenlib SYSTEM PUBLIC
|
||||
${CLANG_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS})
|
||||
target_link_libraries(thunkgenlib PUBLIC clang-cpp LLVM)
|
||||
target_link_libraries(thunkgenlib PRIVATE OpenSSL::Crypto)
|
||||
target_link_libraries(thunkgenlib PRIVATE fmt::fmt)
|
||||
target_compile_definitions(thunkgenlib INTERFACE -DCLANG_RESOURCE_DIR="${CLANG_RESOURCE_DIR}")
|
||||
target_compile_definitions(thunkgenlib INTERFACE
|
||||
-DCLANG_RESOURCE_DIR="${CLANG_RESOURCE_DIR}")
|
||||
|
||||
# Clang's libtooling won't compile with libstdc++'s debug mode
|
||||
target_compile_options(thunkgenlib PUBLIC "-U_GLIBCXX_DEBUG")
|
||||
|
||||
@@ -6,8 +6,9 @@ option(ENABLE_CLANG_THUNKS "Enable building thunks with clang" FALSE)
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
# Use include directories from pkg-config and fall back to global defaults if not available.
|
||||
# /usr/include is dropped to avoid mixing foreign-architecture standard library headers.
|
||||
# Helper to add include directories from pkg-config, falling back to
|
||||
# global defaults if not available. /usr/include is dropped to avoid
|
||||
# mixing foreign-architecture standard library headers.
|
||||
function(target_include_directories_from_pkgconfig target pkg)
|
||||
pkg_check_modules(PKG QUIET ${pkg})
|
||||
if (PKG_FOUND)
|
||||
@@ -34,7 +35,8 @@ if (CCACHE_PROGRAM)
|
||||
endif()
|
||||
|
||||
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||
# We've been included using ExternalProject_add, so set up the actual thunk libraries to be cross-compiled
|
||||
# We've been included using ExternalProject_add, so set up the
|
||||
# actual thunk libraries to be cross-compiled
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
|
||||
# This gets passed in from the main cmake project
|
||||
@@ -48,7 +50,8 @@ if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||
|
||||
# uninstall target
|
||||
if(NOT TARGET uninstall)
|
||||
configure_file("${FEX_PROJECT_SOURCE_DIR}/Data/CMake/cmake_uninstall.cmake.in"
|
||||
configure_file(
|
||||
"${FEX_PROJECT_SOURCE_DIR}/Data/CMake/cmake_uninstall.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/cmake_uninstall.cmake"
|
||||
IMMEDIATE @ONLY)
|
||||
|
||||
@@ -56,7 +59,8 @@ if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/cmake_uninstall.cmake)
|
||||
endif()
|
||||
else()
|
||||
# We've been included using add_subdirectory, so set up targets for IDE integration using the host toolchain
|
||||
# We've been included using add_subdirectory, so set up targets
|
||||
# for IDE integration using the host toolchain
|
||||
set(GENERATOR_EXE thunkgen)
|
||||
set(TARGET_TYPE OBJECT)
|
||||
set(GENERATE_GUEST_INSTALL_TARGETS FALSE)
|
||||
@@ -71,11 +75,14 @@ function(generate NAME SOURCE_FILE)
|
||||
# Interface target for the user to add include directories
|
||||
add_library(${NAME}-guest-deps INTERFACE)
|
||||
target_include_directories(${NAME}-guest-deps INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/../include")
|
||||
|
||||
if (BITNESS EQUAL 32)
|
||||
target_compile_definitions(${NAME}-guest-deps INTERFACE IS_32BIT_THUNK)
|
||||
endif()
|
||||
|
||||
# Shorthand for the include directories added after calling this function.
|
||||
# This is not evaluated directly, hence directories added after return are still picked up
|
||||
# This is not evaluated directly, hence directories added after return
|
||||
# are still picked up
|
||||
set(prop "$<TARGET_PROPERTY:${NAME}-guest-deps,INTERFACE_INCLUDE_DIRECTORIES>")
|
||||
set(compile_prop "$<TARGET_PROPERTY:${NAME}-guest-deps,INTERFACE_COMPILE_DEFINITIONS>")
|
||||
|
||||
@@ -98,7 +105,8 @@ function(generate NAME SOURCE_FILE)
|
||||
OUTPUT "${OUTFILE}"
|
||||
DEPENDS "${GENERATOR_EXE}"
|
||||
DEPENDS "${SOURCE_FILE}"
|
||||
COMMAND "${GENERATOR_EXE}" "${SOURCE_FILE}" "${NAME}" "-guest" "${OUTFILE}" "${X86_DEV_ROOTFS}" ${BITNESS_FLAGS} -- -std=c++20 ${BITNESS_FLAGS2}
|
||||
COMMAND "${GENERATOR_EXE}" "${SOURCE_FILE}" "${NAME}"
|
||||
"-guest" "${OUTFILE}" "${X86_DEV_ROOTFS}" ${BITNESS_FLAGS} -- -std=c++20 ${BITNESS_FLAGS2}
|
||||
# Expand compile definitions to space-separated list of -D parameters
|
||||
"$<$<BOOL:${compile_prop}>:;-D$<JOIN:${compile_prop},;-D>>"
|
||||
# Expand include directories to space-separated list of -isystem parameters
|
||||
@@ -118,7 +126,8 @@ function(add_guest_lib NAME SONAME)
|
||||
get_filename_component(SOURCE_LDS_FILE_ABS "${SOURCE_LDS_FILE}" ABSOLUTE)
|
||||
|
||||
set(SOURCE_LDS_32_FILE ../lib${NAME}/lib${NAME}_Guest_32.lds)
|
||||
get_filename_component(SOURCE_LDS_32_FILE_ABS "${SOURCE_LDS_32_FILE}" ABSOLUTE)
|
||||
get_filename_component(SOURCE_LDS_32_FILE_ABS
|
||||
"${SOURCE_LDS_32_FILE}" ABSOLUTE)
|
||||
|
||||
if (NOT EXISTS "${SOURCE_FILE_ABS}")
|
||||
set(SOURCE_FILE ../lib${NAME}/Guest.cpp)
|
||||
@@ -160,26 +169,32 @@ function(add_guest_lib NAME SONAME)
|
||||
|
||||
# We need to override the soname for the linker.
|
||||
# Our guest thunk libraries are named `lib<Thunk>-guest`.
|
||||
# Once we override the loaded name, the guest is free to dlopen again by SONAME rather than filepath.
|
||||
# eg:
|
||||
# dlopen("libGL.so.1", RTLD_GLOBAL | RTLD_NOW); -> We override this `libGL.so.1` to `libGL-guest.so`
|
||||
# Once we override the loaded name, the guest is free to dlopen again by
|
||||
# SONAME rather than filepath. eg:
|
||||
# dlopen("libGL.so.1", RTLD_GLOBAL | RTLD_NOW); ->
|
||||
# We override this `libGL.so.1` to `libGL-guest.so`
|
||||
# Later on in the program, it can do:
|
||||
# dlopen("libGL.so.1", RTLD_GLOBAL | RTLD_NOLOAD);
|
||||
# This second dlopen will only check to see if the previous load has made the library resident
|
||||
# This second dlopen will only check to see if the previous
|
||||
# load has made the library resident
|
||||
# Searching for SONAME in the process.
|
||||
#
|
||||
# Additionally, VDSO can only be opened by SONAME.
|
||||
# This means it will only ever open the handle with `dlopen("linux-vdso.so.1", RTLD_GLOBAL | RTLD_NOLOAD);
|
||||
# Note that this doesn't have a lib prefix, and also since it doesn't exist on the filesystem, it can never
|
||||
# This means it will only ever open the handle with
|
||||
# dlopen("linux-vdso.so.1", RTLD_GLOBAL | RTLD_NOLOAD);
|
||||
# Note that this doesn't have a lib prefix, and also since it doesn't
|
||||
# exist on the filesystem, it can never
|
||||
# Actually load from a path.
|
||||
target_link_options(${NAME}-guest PRIVATE "LINKER:-soname,${SONAME}")
|
||||
set_target_properties(${NAME}-guest PROPERTIES NO_SONAME ON)
|
||||
|
||||
if (GENERATE_GUEST_INSTALL_TARGETS)
|
||||
if (BITNESS EQUAL 64)
|
||||
install(TARGETS ${NAME}-guest DESTINATION ${DATA_DIRECTORY}/GuestThunks/)
|
||||
install(TARGETS ${NAME}-guest DESTINATION
|
||||
${DATA_DIRECTORY}/GuestThunks/)
|
||||
else()
|
||||
install(TARGETS ${NAME}-guest DESTINATION ${DATA_DIRECTORY}/GuestThunks_32/)
|
||||
install(TARGETS ${NAME}-guest DESTINATION
|
||||
${DATA_DIRECTORY}/GuestThunks_32/)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
@@ -228,8 +243,8 @@ target_link_options(VDSO-guest PRIVATE "-nostdlib" "LINKER:--no-undefined" "LINK
|
||||
if (BITNESS EQUAL 32)
|
||||
# 32-bit entrypoint points to __kernel_vsyscall and needs to exist
|
||||
target_link_options(VDSO-guest PRIVATE "LINKER:-e,__kernel_vsyscall")
|
||||
# 32-bit VDSO needs to have PIC disabled.
|
||||
# Otherwise GCC/Clang generates GOT prologues on the functions that corrupt vsyscall.
|
||||
# 32-bit VDSO needs to have PIC disabled. Otherwise GCC/Clang generates
|
||||
# GOT prologues on the functions that corrupt vsyscall.
|
||||
# Correct:
|
||||
# 00000350 <__kernel_vsyscall>:
|
||||
# 350: cd 80 int 0x80
|
||||
|
||||
@@ -7,8 +7,9 @@ option(ENABLE_CLANG_THUNKS "Enable building thunks with clang" FALSE)
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
# Helper to add include directories from pkg-config, falling back to global defaults if not available.
|
||||
# /usr/include is dropped to avoid mixing foreign-architecture standard library headers.
|
||||
# Helper to add include directories from pkg-config, falling back to
|
||||
# global defaults if not available. /usr/include is dropped to avoid
|
||||
# mixing foreign-architecture standard library headers.
|
||||
function(target_include_directories_from_pkgconfig target pkg)
|
||||
pkg_check_modules(PKG QUIET ${pkg})
|
||||
if (PKG_FOUND)
|
||||
@@ -39,13 +40,18 @@ function(generate NAME SOURCE_FILE GUEST_BITNESS)
|
||||
# Interface target for the user to add include directories
|
||||
add_library(${NAME}-${GUEST_BITNESS}-deps INTERFACE)
|
||||
target_include_directories(${NAME}-${GUEST_BITNESS}-deps INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/../include")
|
||||
|
||||
if (GUEST_BITNESS EQUAL 32)
|
||||
target_compile_definitions(${NAME}-${GUEST_BITNESS}-deps INTERFACE IS_32BIT_THUNK)
|
||||
target_compile_definitions(${NAME}-${GUEST_BITNESS}-deps INTERFACE
|
||||
IS_32BIT_THUNK)
|
||||
endif()
|
||||
|
||||
# Shorthand for the include directories added after calling this function.
|
||||
# This is not evaluated directly, hence directories added after return are still picked up
|
||||
# This is not evaluated directly, hence directories added after return
|
||||
# are still picked up
|
||||
set(prop "$<TARGET_PROPERTY:${NAME}-${GUEST_BITNESS}-deps,INTERFACE_INCLUDE_DIRECTORIES>")
|
||||
set(compile_prop "$<TARGET_PROPERTY:${NAME}-${GUEST_BITNESS}-deps,INTERFACE_COMPILE_DEFINITIONS>")
|
||||
|
||||
if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
|
||||
list(APPEND compile_prop ARCHITECTURE_x86_64=1)
|
||||
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
|
||||
@@ -71,7 +77,8 @@ function(generate NAME SOURCE_FILE GUEST_BITNESS)
|
||||
OUTPUT "${OUTFILE}"
|
||||
DEPENDS "${SOURCE_FILE}"
|
||||
DEPENDS thunkgen
|
||||
COMMAND thunkgen "${SOURCE_FILE}" "${NAME}" "-host" "${OUTFILE}" "${X86_DEV_ROOTFS}" ${BITNESS_FLAGS} -- -std=c++20
|
||||
COMMAND thunkgen "${SOURCE_FILE}" "${NAME}" "-host"
|
||||
"${OUTFILE}" "${X86_DEV_ROOTFS}" ${BITNESS_FLAGS} -- -std=c++20
|
||||
${THUNKGEN_SYSTEM_INCLUDES}
|
||||
# Expand compile definitions to space-separated list of -D parameters
|
||||
"$<$<BOOL:${compile_prop}>:;-D$<JOIN:${compile_prop},;-D>>"
|
||||
@@ -87,6 +94,7 @@ endfunction()
|
||||
function(add_host_lib NAME GUEST_BITNESS)
|
||||
set(SOURCE_FILE ../lib${NAME}/lib${NAME}_Host.cpp)
|
||||
get_filename_component(SOURCE_FILE_ABS "${SOURCE_FILE}" ABSOLUTE)
|
||||
|
||||
if (NOT EXISTS "${SOURCE_FILE_ABS}")
|
||||
set(SOURCE_FILE ../lib${NAME}/Host.cpp)
|
||||
get_filename_component(SOURCE_FILE_ABS "${SOURCE_FILE}" ABSOLUTE)
|
||||
@@ -96,26 +104,31 @@ function(add_host_lib NAME GUEST_BITNESS)
|
||||
endif()
|
||||
|
||||
add_library(${NAME}-host-${GUEST_BITNESS} SHARED ${SOURCE_FILE} ${GEN_lib${NAME}})
|
||||
set_target_properties(${NAME}-host-${GUEST_BITNESS} PROPERTIES OUTPUT_NAME "${NAME}-host")
|
||||
set_target_properties(${NAME}-host-${GUEST_BITNESS} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/HostLibs_${GUEST_BITNESS}")
|
||||
set_target_properties(${NAME}-host-${GUEST_BITNESS} PROPERTIES
|
||||
OUTPUT_NAME "${NAME}-host"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/HostLibs_${GUEST_BITNESS}")
|
||||
|
||||
target_include_directories(${NAME}-host-${GUEST_BITNESS} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/gen_${GUEST_BITNESS}/")
|
||||
target_link_libraries(${NAME}-host-${GUEST_BITNESS} PRIVATE dl)
|
||||
target_link_libraries(${NAME}-host-${GUEST_BITNESS} PRIVATE lib${NAME}-${GUEST_BITNESS}-deps)
|
||||
target_link_libraries(${NAME}-host-${GUEST_BITNESS} PRIVATE FEX)
|
||||
target_link_libraries(${NAME}-host-${GUEST_BITNESS} PRIVATE dl lib${NAME}-${GUEST_BITNESS}-deps FEX)
|
||||
## Make signed overflow well defined 2's complement overflow
|
||||
target_compile_options(${NAME}-host-${GUEST_BITNESS} PRIVATE -fwrapv)
|
||||
|
||||
if (NOT ENABLE_ASAN)
|
||||
# generated files forward-declare functions that need to be implemented manually, so pass --no-undefined to make sure errors are detected at compile-time rather than runtime
|
||||
# NOTE: ASan is not compatible with --no-undefined, see https://github.com/google/sanitizers/issues/380 for details
|
||||
# generated files forward-declare functions that need to be implemented
|
||||
# manually, so pass --no-undefined to make sure errors are detected at
|
||||
# compile-time rather than runtime
|
||||
# NOTE: ASan is not compatible with --no-undefined,
|
||||
# see https://github.com/google/sanitizers/issues/380 for details
|
||||
target_link_options(${NAME}-host-${GUEST_BITNESS} PRIVATE "LINKER:--no-undefined")
|
||||
endif()
|
||||
|
||||
if (${GUEST_BITNESS} EQUAL 32)
|
||||
install(TARGETS ${NAME}-host-${GUEST_BITNESS} COMPONENT Runtime DESTINATION ${HOSTLIBS_DATA_DIRECTORY}/HostThunks_32/)
|
||||
set(thunks_dir HostThunks_32)
|
||||
else()
|
||||
install(TARGETS ${NAME}-host-${GUEST_BITNESS} COMPONENT Runtime DESTINATION ${HOSTLIBS_DATA_DIRECTORY}/HostThunks/)
|
||||
set(thunks_dir HostThunks)
|
||||
endif()
|
||||
|
||||
install(TARGETS ${NAME}-host-${GUEST_BITNESS} COMPONENT Runtime DESTINATION ${HOSTLIBS_DATA_DIRECTORY}/${thunks_dir}/)
|
||||
endfunction()
|
||||
|
||||
set(BITNESS_LIST "64")
|
||||
@@ -143,7 +156,9 @@ endforeach()
|
||||
set(BITNESS_LIST "32;64")
|
||||
foreach(GUEST_BITNESS IN LISTS BITNESS_LIST)
|
||||
if (BUILD_FEX_LINUX_TESTS)
|
||||
generate(libfex_thunk_test ${CMAKE_CURRENT_SOURCE_DIR}/../libfex_thunk_test/libfex_thunk_test_interface.cpp ${GUEST_BITNESS})
|
||||
generate(libfex_thunk_test
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../libfex_thunk_test/libfex_thunk_test_interface.cpp
|
||||
${GUEST_BITNESS})
|
||||
add_host_lib(fex_thunk_test ${GUEST_BITNESS})
|
||||
endif()
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# -S skips importing the "site" package which cuts down on interpreter startup time.
|
||||
# This means that these scripts can only use the python standard library, since "site"
|
||||
# -S skips importing the "site" package which cuts down on
|
||||
# interpreter startup time. This means that these scripts
|
||||
# can only use the python standard library, since "site"
|
||||
# is what resolves third-party packages from pip or apt.
|
||||
set(PYTHON_TEST_RUNNER "python3" "-S")
|
||||
|
||||
@@ -24,6 +25,7 @@ endif()
|
||||
add_subdirectory(ASM/)
|
||||
add_subdirectory(32Bit_ASM/)
|
||||
if (ENABLE_VIXL_DISASSEMBLER)
|
||||
# Tests are only valid to run if the vixl disassembler is enabled and the active JIT is the ARM64 JIT.
|
||||
# Tests are only valid to run if the vixl disassembler
|
||||
# is enabled and the active JIT is the ARM64 JIT.
|
||||
add_subdirectory(InstructionCountCI/)
|
||||
endif()
|
||||
Reference in new issue
Block a user