From 319232816447040085b220203ace95b0178c5954 Mon Sep 17 00:00:00 2001 From: Flaviu Tamas Date: Sat, 13 Aug 2022 10:25:14 -0400 Subject: 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. --- CHANGES.txt | 3 +++ SCons/Environment.py | 2 +- SCons/Environment.xml | 1 + SCons/EnvironmentTests.py | 10 ++++++++-- doc/generated/functions.gen | 1 + 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 4519888..3ed22c0 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 c38b51c..e458f25 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 485fe39..a3bcc93 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 8bf327a..a021794 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 efc4c9e..a3e4edf 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 -- cgit v0.12 From 13306124f5ba211d7189ddded73806bdc29f5a59 Mon Sep 17 00:00:00 2001 From: Flaviu Tamas Date: Sat, 13 Aug 2022 10:36:11 -0400 Subject: fix a couple typos --- SCons/Environment.xml | 6 +++--- doc/generated/functions.gen | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/SCons/Environment.xml b/SCons/Environment.xml index a3bcc93..7a288f3 100644 --- a/SCons/Environment.xml +++ b/SCons/Environment.xml @@ -2493,15 +2493,15 @@ This can be used to call a *-config command typical of the POSIX programming environment (for example, pkg-config). -Note that such a comamnd is executed using the +Note that such a command is executed using the SCons execution environment; if the command needs additional information, -that information needs to be explcitly provided. +that information needs to be explicitly provided. See &f-link-ParseConfig; for more details. -Flag values are translated accordig to the prefix found, +Flag values are translated according to the prefix found, and added to the following construction variables: diff --git a/doc/generated/functions.gen b/doc/generated/functions.gen index a3e4edf..c135173 100644 --- a/doc/generated/functions.gen +++ b/doc/generated/functions.gen @@ -2925,15 +2925,15 @@ This can be used to call a *-config command typical of the POSIX programming environment (for example, pkg-config). -Note that such a comamnd is executed using the +Note that such a command is executed using the SCons execution environment; if the command needs additional information, -that information needs to be explcitly provided. +that information needs to be explicitly provided. See &f-link-ParseConfig; for more details. -Flag values are translated accordig to the prefix found, +Flag values are translated according to the prefix found, and added to the following construction variables: -- cgit v0.12 From e22babfadab1d82330ef556753c06d4eb45c2bd1 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 13 Aug 2022 14:16:20 -0700 Subject: Updated CHANGES.txt to better represent the change. Added blurb to RELEASE.txt --- CHANGES.txt | 6 +----- RELEASE.txt | 3 +-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 3ed22c0..ee49590 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -9,15 +9,11 @@ NOTE: 4.3.0 now requires Python 3.6.0 and above. Python 3.5.x is no longer suppo RELEASE VERSION/DATE TO BE FILLED IN LATER - From John Doe: - - - Whatever John Doe did. - 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 + - Added -fsanitize support to ParseFlags(). This will propagate to CCFLAGS and LINKFLAGS. RELEASE 4.4.0 - Sat, 30 Jul 2022 14:08:29 -0700 diff --git a/RELEASE.txt b/RELEASE.txt index 6306ca7..711b6f2 100755 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -26,8 +26,7 @@ DEPRECATED FUNCTIONALITY CHANGED/ENHANCED EXISTING FUNCTIONALITY --------------------------------------- -- List modifications to existing features, where the previous behavior - wouldn't actually be considered a bug +- Added -fsanitize support to ParseFlags(). This will propagate to CCFLAGS and LINKFLAGS. FIXES ----- -- cgit v0.12