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.
|
# seemingly succeeds. Explicitly disable the version script test on darwin platforms.
|
||||||
# Also makes no sense with MSVC-style command-line
|
# Also makes no sense with MSVC-style command-line
|
||||||
if(NOT APPLE AND NOT MSVC)
|
if(NOT APPLE AND NOT MSVC)
|
||||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/version_flag.map" "VERS_1 { global: sym; };
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/version_flag.map" [=[
|
||||||
VERS_2 { global: sym; }
|
VERS_1 { global: sym1; };
|
||||||
VERS_1;
|
VERS_2 { global: sym2; } VERS_1;
|
||||||
")
|
]=])
|
||||||
if(DEFINED CMAKE_REQUIRED_FLAGS)
|
set(CMAKE_REQUIRED_LINK_OPTIONS "")
|
||||||
set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS})
|
list(APPEND CMAKE_REQUIRED_LINK_OPTIONS
|
||||||
else()
|
"-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/version_flag.map")
|
||||||
set(CMAKE_REQUIRED_FLAGS "")
|
|
||||||
endif()
|
|
||||||
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script=\"${CMAKE_CURRENT_BINARY_DIR}/version_flag.map\"")
|
|
||||||
|
|
||||||
# Pass the linker that the main project uses to the version script compile test.
|
# Pass the linker that the main project uses to the version script compile test.
|
||||||
qt_internal_get_active_linker_flags(linker_flags)
|
qt_internal_get_active_linker_flags(linker_flags)
|
||||||
if(linker_flags)
|
if(linker_flags)
|
||||||
set(CMAKE_REQUIRED_LINK_OPTIONS ${linker_flags})
|
list(APPEND CMAKE_REQUIRED_LINK_OPTIONS ${linker_flags})
|
||||||
endif()
|
endif()
|
||||||
|
check_cxx_source_compiles([=[
|
||||||
check_cxx_source_compiles("int main(void){return 0;}" HAVE_LD_VERSION_SCRIPT)
|
int sym1;
|
||||||
if(DEFINED CMAKE_REQUIRED_FLAGS_SAVE)
|
int sym2;
|
||||||
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE})
|
int main(void) { return 0; }
|
||||||
endif()
|
]=] HAVE_LD_VERSION_SCRIPT)
|
||||||
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
|
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/version_flag.map")
|
||||||
else()
|
else()
|
||||||
set(HAVE_LD_VERSION_SCRIPT OFF)
|
set(HAVE_LD_VERSION_SCRIPT OFF)
|
||||||
endif()
|
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)
|
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()
|
endfunction()
|
||||||
|
|
||||||
function(qt_internal_ensure_latest_win_nt_api)
|
function(qt_internal_ensure_latest_win_nt_api)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user