From e92efbc4c89da0b9ba20168aee637dbc30229a8b Mon Sep 17 00:00:00 2001 From: Yu-hsin Wang Date: Mon, 6 Jan 2020 12:27:19 +0800 Subject: [PATCH] scons: Add '-Wl,--as-needed' to default LINKFLAGS In current build flow, EXTRAS flag is evaluated before building gem5 tools and binaries. Such that, unneeded libraries may be linked into gem5 binaries. Adding '-Wl,--as-needed' can fix this problem also shrinks binaries. Change-Id: Ifb001786a66b0dd9b29865e39a5740313002f250 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/24003 Reviewed-by: Jason Lowe-Power Reviewed-by: Gabe Black Maintainer: Jason Lowe-Power Tested-by: kokoro --- SConstruct | 1 + 1 file changed, 1 insertion(+) diff --git a/SConstruct b/SConstruct index ec74d699d..d84b91284 100755 --- a/SConstruct +++ b/SConstruct @@ -372,6 +372,7 @@ if main['GCC'] or main['CLANG']: main.Append(CCFLAGS=['-I/usr/local/include']) main.Append(CXXFLAGS=['-I/usr/local/include']) + main.Append(LINKFLAGS='-Wl,--as-needed') main['FILTER_PSHLINKFLAGS'] = lambda x: str(x).replace(' -shared', '') main['PSHLINKFLAGS'] = main.subst('${FILTER_PSHLINKFLAGS(SHLINKFLAGS)}') if GetOption('gold_linker'): -- 2.30.2