From 54750847179c62990051a6a2bd798b621fdb75d7 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 9 Mar 2022 15:56:28 +0100 Subject: [PATCH] build: Enable -fno-semantic-interposition for GCC This matches the more optimized clang behavior for -fPIC --- dtool/CompilerFlags.cmake | 7 +++++++ makepanda/makepanda.py | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/dtool/CompilerFlags.cmake b/dtool/CompilerFlags.cmake index b2ec74b980..0b6945878e 100644 --- a/dtool/CompilerFlags.cmake +++ b/dtool/CompilerFlags.cmake @@ -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() diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index f11797c44f..ee011366ba 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -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"])