diff options
author | Flaviu Tamas <tamasflaviu@gmail.com> | 2022-08-13 10:25:14 -0400 |
---|---|---|
committer | Flaviu Tamas <tamasflaviu@gmail.com> | 2022-08-13 10:40:06 -0400 |
commit | 319232816447040085b220203ace95b0178c5954 (patch) | |
tree | e62ab264502a9375e04715f74a3c11aaffb28d0b | |
parent | d3fff18065a9cd614147117e4dcaa3a312635ea1 (diff) | |
download | scons-git-319232816447040085b220203ace95b0178c5954.tar.gz |
Fix -fsanitize flag handling
These parameters need to be passed to both the compiler and the linker,
otherwise lots of "undefined reference to `__asan_stack_malloc_0'"
errors get emitted at link time, since the appropriate library is not
linked in.
-rwxr-xr-x | CHANGES.txt | 3 | ||||
-rw-r--r-- | SCons/Environment.py | 2 | ||||
-rw-r--r-- | SCons/Environment.xml | 1 | ||||
-rw-r--r-- | SCons/EnvironmentTests.py | 10 | ||||
-rw-r--r-- | doc/generated/functions.gen | 1 |
5 files changed, 14 insertions, 3 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 451988850..3ed22c0e2 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -16,6 +16,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER From Dan Mezhiborsky: - Add newline to end of compilation db (compile_commands.json). + From Flaviu Tamas + - Fixed -fsanitize argument not being passed to the linker + RELEASE 4.4.0 - Sat, 30 Jul 2022 14:08:29 -0700 diff --git a/SCons/Environment.py b/SCons/Environment.py index c38b51cd0..e458f256d 100644 --- a/SCons/Environment.py +++ b/SCons/Environment.py @@ -802,7 +802,7 @@ class SubstitutionEnvironment: '-openmp', '-fmerge-all-constants', '-fopenmp', - ): + ) or arg.startswith('-fsanitize'): mapping['CCFLAGS'].append(arg) mapping['LINKFLAGS'].append(arg) elif arg == '-mwindows': diff --git a/SCons/Environment.xml b/SCons/Environment.xml index 485fe3949..a3bcc93b6 100644 --- a/SCons/Environment.xml +++ b/SCons/Environment.xml @@ -2512,6 +2512,7 @@ and added to the following construction variables: -frameworkdir= FRAMEWORKPATH -fmerge-all-constants CCFLAGS, LINKFLAGS -fopenmp CCFLAGS, LINKFLAGS +-fsanitize CCFLAGS, LINKFLAGS -include CCFLAGS -imacros CCFLAGS -isysroot CCFLAGS, LINKFLAGS diff --git a/SCons/EnvironmentTests.py b/SCons/EnvironmentTests.py index 8bf327a2c..a021794c9 100644 --- a/SCons/EnvironmentTests.py +++ b/SCons/EnvironmentTests.py @@ -820,6 +820,8 @@ sys.exit(0) "--param l1-cache-size=32 --param l2-cache-size=6144 " "+DD64 " "-DFOO -DBAR=value -D BAZ " + "-fsanitize=memory " + "-fsanitize-address-use-after-return " ) d = env.ParseFlags(s) @@ -836,7 +838,9 @@ sys.exit(0) ('-imacros', env.fs.File('/usr/include/foo4')), ('-include', env.fs.File('/usr/include/foo5')), ('--param', 'l1-cache-size=32'), ('--param', 'l2-cache-size=6144'), - '+DD64'], repr(d['CCFLAGS']) + '+DD64', + '-fsanitize=memory', + '-fsanitize-address-use-after-return'], repr(d['CCFLAGS']) assert d['CXXFLAGS'] == ['-std=c++0x'], repr(d['CXXFLAGS']) assert d['CPPDEFINES'] == ['FOO', ['BAR', 'value'], 'BAZ'], d['CPPDEFINES'] assert d['CPPFLAGS'] == ['-Wp,-cpp'], d['CPPFLAGS'] @@ -856,7 +860,9 @@ sys.exit(0) '-mno-cygwin', '-mwindows', ('-arch', 'i386'), ('-isysroot', '/tmp'), - '+DD64'], repr(d['LINKFLAGS']) + '+DD64', + '-fsanitize=memory', + '-fsanitize-address-use-after-return'], repr(d['LINKFLAGS']) assert d['RPATH'] == ['rpath1', 'rpath2', 'rpath3'], d['RPATH'] diff --git a/doc/generated/functions.gen b/doc/generated/functions.gen index efc4c9edf..a3e4edfbb 100644 --- a/doc/generated/functions.gen +++ b/doc/generated/functions.gen @@ -2944,6 +2944,7 @@ and added to the following construction variables: -frameworkdir= FRAMEWORKPATH -fmerge-all-constants CCFLAGS, LINKFLAGS -fopenmp CCFLAGS, LINKFLAGS +-fsanitize CCFLAGS, LINKFLAGS -include CCFLAGS -imacros CCFLAGS -isysroot CCFLAGS, LINKFLAGS |