Fix version script test
1. Don't reassign different versions to same symbol 2. Define symbols used This fixes warnings with LLD linker (or errors if -Wl,--fatal-warnings is added by toolchain e.g. with Android NDK) 3. Add -Wl,--version-script to CMAKE_REQUIRED_LINK_OPTIONS instead of CMAKE_REQUIRED_FLAGS to prevent unused argument warning in compilation phase (there is no need for _SAVE variable because we are inside a function and our CMAKE_REQUIRED_LINK_OPTIONS won't escase its scope) 4. Fix removal of version script file (incorrect file name was used) Pick-to: 6.2 6.5 Task-number: QTBUG-111514 Change-Id: I0a1548c4268ad511760a0d4aa69ba7a0bdcbb0bc Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
07d6d31a4c
commit
d68dbd8b7d
@ -120,35 +120,33 @@ function(qt_run_linker_version_script_support)
|
||||
# seemingly succeeds. Explicitly disable the version script test on darwin platforms.
|
||||
# Also makes no sense with MSVC-style command-line
|
||||
if(NOT APPLE AND NOT MSVC)
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/version_flag.map" "VERS_1 { global: sym; };
|
||||
VERS_2 { global: sym; }
|
||||
VERS_1;
|
||||
")
|
||||
if(DEFINED CMAKE_REQUIRED_FLAGS)
|
||||
set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS})
|
||||
else()
|
||||
set(CMAKE_REQUIRED_FLAGS "")
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script=\"${CMAKE_CURRENT_BINARY_DIR}/version_flag.map\"")
|
||||
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/version_flag.map" [=[
|
||||
VERS_1 { global: sym1; };
|
||||
VERS_2 { global: sym2; } VERS_1;
|
||||
]=])
|
||||
set(CMAKE_REQUIRED_LINK_OPTIONS "")
|
||||
list(APPEND CMAKE_REQUIRED_LINK_OPTIONS
|
||||
"-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/version_flag.map")
|
||||
# Pass the linker that the main project uses to the version script compile test.
|
||||
qt_internal_get_active_linker_flags(linker_flags)
|
||||
if(linker_flags)
|
||||
set(CMAKE_REQUIRED_LINK_OPTIONS ${linker_flags})
|
||||
list(APPEND CMAKE_REQUIRED_LINK_OPTIONS ${linker_flags})
|
||||
endif()
|
||||
|
||||
check_cxx_source_compiles("int main(void){return 0;}" HAVE_LD_VERSION_SCRIPT)
|
||||
if(DEFINED CMAKE_REQUIRED_FLAGS_SAVE)
|
||||
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE})
|
||||
endif()
|
||||
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
|
||||
check_cxx_source_compiles([=[
|
||||
int sym1;
|
||||
int sym2;
|
||||
int main(void) { return 0; }
|
||||
]=] HAVE_LD_VERSION_SCRIPT)
|
||||
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/version_flag.map")
|
||||
else()
|
||||
set(HAVE_LD_VERSION_SCRIPT OFF)
|
||||
endif()
|
||||
|
||||
set(TEST_ld_version_script "${HAVE_LD_VERSION_SCRIPT}" CACHE INTERNAL "linker version script support")
|
||||
set(TEST_ld_version_script "${HAVE_LD_VERSION_SCRIPT}"
|
||||
CACHE INTERNAL "linker version script support")
|
||||
list(APPEND QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT TEST_ld_version_script)
|
||||
set(QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT ${QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT} CACHE INTERNAL "Test variables that should be exported")
|
||||
set(QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT ${QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT}
|
||||
CACHE INTERNAL "Test variables that should be exported")
|
||||
endfunction()
|
||||
|
||||
function(qt_internal_ensure_latest_win_nt_api)
|
||||
|
Loading…
Reference in New Issue
Block a user