CMake: Fix usage of gc_binaries feature
The qt_internal_apply_gc_binaries function should apply both compile and link flags, not just link flags. The flags should be applied publically to all consumers of Bootstrap regardless if the gc_binaries feature is enabled. The flags should be applied publically to Core only in case if the feature is enabled (aka for static builds only). Change-Id: Id42af0d9b527004d74c04eff2c9e3c2be1e76aac Fixes: QTBUG-84461 Task-number: QTBUG-83929 Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
parent
2158e764dc
commit
a08bf7f00a
@ -1409,7 +1409,15 @@ function(qt_internal_add_link_flags_no_undefined target)
|
|||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(qt_internal_add_link_flags_gc_sections target visibility)
|
function(qt_internal_apply_gc_binaries_conditional target visibility)
|
||||||
|
# Should only be applied when the feature is enabled, aka for static builds.
|
||||||
|
if(NOT QT_FEATURE_gc_binaries)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
qt_internal_apply_gc_binaries("${target}" "${visibility}")
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(qt_internal_apply_gc_binaries target visibility)
|
||||||
set(possible_visibilities PRIVATE INTERFACE PUBLIC)
|
set(possible_visibilities PRIVATE INTERFACE PUBLIC)
|
||||||
list(FIND possible_visibilities "${visibility}" known_visibility)
|
list(FIND possible_visibilities "${visibility}" known_visibility)
|
||||||
if (known_visibility EQUAL "-1")
|
if (known_visibility EQUAL "-1")
|
||||||
@ -1419,13 +1427,22 @@ function(qt_internal_add_link_flags_gc_sections target visibility)
|
|||||||
if ((GCC OR CLANG) AND NOT EMSCRIPTEN)
|
if ((GCC OR CLANG) AND NOT EMSCRIPTEN)
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
set(gc_sections_flag "-Wl,-dead_strip")
|
set(gc_sections_flag "-Wl,-dead_strip")
|
||||||
elseif(LINUX OR BSD OR SOLARIS OR WIN32 OR ANDROID)
|
elseif(SOLARIS)
|
||||||
|
set(gc_sections_flag "-Wl,-z,ignore")
|
||||||
|
elseif(LINUX OR BSD OR WIN32 OR ANDROID)
|
||||||
set(gc_sections_flag "-Wl,--gc-sections")
|
set(gc_sections_flag "-Wl,--gc-sections")
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "Platform linker doesn't support gc sections. Target:\"${target}\".")
|
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
if(gc_sections_flag)
|
||||||
target_link_options("${target}" ${visibility} "${gc_sections_flag}")
|
target_link_options("${target}" ${visibility} "${gc_sections_flag}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if((GCC OR CLANG OR ICC) AND NOT EMSCRIPTEN)
|
||||||
|
set(split_sections_flags "-ffunction-sections" "-fdata-sections")
|
||||||
|
endif()
|
||||||
|
if(split_sections_flags)
|
||||||
|
target_compile_options("${target}" ${visibility} ${split_sections_flags})
|
||||||
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(qt_internal_add_linker_version_script target)
|
function(qt_internal_add_linker_version_script target)
|
||||||
|
@ -355,6 +355,9 @@ qt_feature("cross_compile" PUBLIC
|
|||||||
)
|
)
|
||||||
qt_feature_config("cross_compile" QMAKE_PUBLIC_CONFIG)
|
qt_feature_config("cross_compile" QMAKE_PUBLIC_CONFIG)
|
||||||
qt_feature_config("cross_compile" QMAKE_PRIVATE_CONFIG)
|
qt_feature_config("cross_compile" QMAKE_PRIVATE_CONFIG)
|
||||||
|
qt_feature("gc_binaries" PRIVATE
|
||||||
|
CONDITION NOT QT_FEATURE_shared
|
||||||
|
)
|
||||||
qt_feature("use_bfd_linker"
|
qt_feature("use_bfd_linker"
|
||||||
LABEL "bfd"
|
LABEL "bfd"
|
||||||
AUTODETECT false
|
AUTODETECT false
|
||||||
|
@ -270,7 +270,7 @@ set_target_properties(${target_name} PROPERTIES
|
|||||||
AUTOUIC OFF
|
AUTOUIC OFF
|
||||||
)
|
)
|
||||||
|
|
||||||
qt_internal_add_link_flags_gc_sections(${target_name} PRIVATE) # special case
|
qt_internal_apply_gc_binaries(${target_name} PRIVATE) # special case
|
||||||
|
|
||||||
qt_enable_msvc_cplusplus_define(${target_name} PUBLIC) # special case
|
qt_enable_msvc_cplusplus_define(${target_name} PUBLIC) # special case
|
||||||
qt_skip_warnings_are_errors(${target_name}) # special case
|
qt_skip_warnings_are_errors(${target_name}) # special case
|
||||||
|
@ -1272,7 +1272,7 @@ if(WIN32)
|
|||||||
set_target_properties(Core PROPERTIES COMPILE_DEFINITIONS "${defines}")
|
set_target_properties(Core PROPERTIES COMPILE_DEFINITIONS "${defines}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
qt_internal_add_link_flags_gc_sections(Core PRIVATE)
|
qt_internal_apply_gc_binaries_conditional(Core PUBLIC)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(isExe $<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>)
|
set(isExe $<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>)
|
||||||
|
@ -261,7 +261,7 @@ qt_extend_target(Bootstrap CONDITION MINGW AND WIN32
|
|||||||
# QMAKE_CFLAGS = "$$QMAKE_CFLAGS_SHSTK"
|
# QMAKE_CFLAGS = "$$QMAKE_CFLAGS_SHSTK"
|
||||||
|
|
||||||
# special case begin
|
# special case begin
|
||||||
qt_internal_add_link_flags_gc_sections(Bootstrap PUBLIC)
|
qt_internal_apply_gc_binaries(Bootstrap PUBLIC)
|
||||||
set_target_properties(Bootstrap PROPERTIES AUTOMOC OFF AUTOUIC OFF AUTORCC OFF)
|
set_target_properties(Bootstrap PROPERTIES AUTOMOC OFF AUTOUIC OFF AUTORCC OFF)
|
||||||
qt_internal_add_target_aliases(Bootstrap)
|
qt_internal_add_target_aliases(Bootstrap)
|
||||||
qt_enable_msvc_cplusplus_define(Bootstrap PUBLIC)
|
qt_enable_msvc_cplusplus_define(Bootstrap PUBLIC)
|
||||||
|
@ -863,7 +863,9 @@ def get_feature_mapping():
|
|||||||
"framework": {
|
"framework": {
|
||||||
"condition": "APPLE AND BUILD_SHARED_LIBS AND NOT CMAKE_BUILD_TYPE STREQUAL Debug"
|
"condition": "APPLE AND BUILD_SHARED_LIBS AND NOT CMAKE_BUILD_TYPE STREQUAL Debug"
|
||||||
},
|
},
|
||||||
"gc_binaries": None,
|
"gc_binaries": {
|
||||||
|
"condition" : "NOT QT_FEATURE_shared"
|
||||||
|
},
|
||||||
"gcc-sysroot": None,
|
"gcc-sysroot": None,
|
||||||
"gcov": None,
|
"gcov": None,
|
||||||
"gnu-libiconv": {
|
"gnu-libiconv": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user