build: Enable -fno-semantic-interposition for GCC

This matches the more optimized clang behavior for -fPIC
This commit is contained in:
rdb 2022-03-09 15:56:28 +01:00
parent 3456769703
commit 5475084717
2 changed files with 11 additions and 0 deletions

View File

@ -218,3 +218,10 @@ if(NOT MSVC)
add_compile_options("-fvisibility=hidden")
endif()
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
check_cxx_compiler_flag("-fno-semantic-interposition" COMPILER_SUPPORTS_FNO_SEMANTIC_INTERPOSITION)
if(COMPILER_SUPPORTS_FNO_SEMANTIC_INTERPOSITION)
add_compile_options("-fno-semantic-interposition")
endif()
endif()

View File

@ -1370,6 +1370,10 @@ def CompileCxx(obj,src,opts):
if 'NOARCH:' + arch.upper() not in opts:
cmd += " -arch %s" % arch
elif 'clang' not in GetCXX().split('/')[-1]:
# Enable interprocedural optimizations in GCC.
cmd += " -fno-semantic-interposition"
if "SYSROOT" in SDK:
if GetTarget() != "android":
cmd += ' --sysroot=%s' % (SDK["SYSROOT"])