Merge pull request #4122 from lightmare/prevent-duplicate-flags

scons: prevent duplication of linker flags
This commit is contained in:
Artem Pavlenko 2020-01-30 20:02:12 +00:00 committed by GitHub
commit 3be9ce8fa0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1423,14 +1423,16 @@ if not preconfigured:
env.Append(LINKFLAGS = DEFAULT_CXX14_LINKFLAGS)
custom_ldflags = env.ParseFlags(env['CUSTOM_LDFLAGS'])
# ParseFlags puts everything it does not recognize into CCFLAGS,
# but let's assume the user knows better, put those in LINKFLAGS
env.Append(LINKFLAGS = custom_ldflags.pop('CCFLAGS'))
env.Append(LINKFLAGS = custom_ldflags.pop('LINKFLAGS'),
LIBS = custom_ldflags.pop('LIBS'))
env.AppendUnique(FRAMEWORKS = custom_ldflags.pop('FRAMEWORKS'),
LIBPATH = custom_ldflags.pop('LIBPATH'),
RPATH = custom_ldflags.pop('RPATH'))
# ParseFlags puts everything it does not recognize into CCFLAGS,
# but let's assume the user knows better: add those to LINKFLAGS.
# In order to prevent duplication of flags which ParseFlags puts
# into both CCFLAGS and LINKFLAGS, call AppendUnique.
env.AppendUnique(LINKFLAGS = custom_ldflags.pop('CCFLAGS'))
invalid_ldflags = {k:v for k,v in custom_ldflags.items() if v}
if invalid_ldflags: