diff --git a/linux/CMakeLists.txt b/linux/CMakeLists.txt index 4118edba..ca942a3f 100644 --- a/linux/CMakeLists.txt +++ b/linux/CMakeLists.txt @@ -40,12 +40,19 @@ endif() # default. In most cases, you should add new options to specific targets instead # of modifying this function. function(APPLY_STANDARD_SETTINGS TARGET) + # Not ideal, there doesn't appear to be a way to get target arch so getting host arch. won't work for cross compiling + execute_process(COMMAND uname -m OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE ARCH) target_compile_features(${TARGET} PUBLIC cxx_std_14) target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") # -Os -fno-ident (optimize for size, and strip idents, don't generate a build-id, fix hash style) target_compile_options(${TARGET} PRIVATE -Wall -Werror -Os -fno-ident) - target_link_libraries(${TARGET} PRIVATE -Qn -Os -Wl,-s,--hash-style=gnu,--build-id=none,--script=${PROJECT_BUILD_DIR}/../elf_x86_64.x) + # on x86_64 use an included elf_x86_64.x for reproducibility. for other arches don't (and then don't be reproducible) + if(${ARCH} STREQUAL "x86_64") + target_link_libraries(${TARGET} PRIVATE -Qn -Os -Wl,-s,--hash-style=gnu,--build-id=none,--script=${PROJECT_BUILD_DIR}/../elf_x86_64.x) + else() + target_link_libraries(${TARGET} PRIVATE -Qn -Os -Wl,-s,--hash-style=gnu,--build-id=none) + endif() endfunction() # Flutter library and tool build rules.