diff --git a/CHANGES.txt b/CHANGES.txt index 224f114658..a527c0fd35 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -22,6 +22,12 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER expected exceptions (whereas previously many of these were silently caught and suppressed by the SCons Action exection code). + From Ryan Carsten Schmidt: + - Teach ParseFlags to put a --stdlib=libname argument into CXXFLAGS. + If placed in CCFLAGS (the default location), it could be fed to the + C compiler (gcc, clang) where it is not applicable and causes a + warning message. + From Mats Wichmann: - Updated Value Node docs and tests. - Python 3.13 compat: re.sub deprecated count, flags as positional args, diff --git a/RELEASE.txt b/RELEASE.txt index f42b979cbe..55c9401a8f 100644 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -39,6 +39,8 @@ CHANGED/ENHANCED EXISTING FUNCTIONALITY NOTE: With this change, user created Actions should now catch and handle expected exceptions (whereas previously many of these were silently caught and suppressed by the SCons Action exection code). +- ParseFlags now sorts a --stdlib=libname argument into CXXFLAGS instead + of CCFLAGS; the latter variable could cause a compiler warning. - The implementation of Variables was slightly refactored, there should not be user-visible changes. diff --git a/SCons/Environment.py b/SCons/Environment.py index 4a1ae42d64..2def741ff8 100644 --- a/SCons/Environment.py +++ b/SCons/Environment.py @@ -881,11 +881,11 @@ def ParseFlags(self, *flags) -> dict: 'RPATH' : [], } - def do_parse(arg) -> None: - # if arg is a sequence, recurse with each element + def do_parse(arg: Union[str, Sequence]) -> None: if not arg: return + # if arg is a sequence, recurse with each element if not is_String(arg): for t in arg: do_parse(t) return @@ -902,7 +902,7 @@ def append_define(name, mapping=mapping) -> None: else: mapping['CPPDEFINES'].append([t[0], '='.join(t[1:])]) - # Loop through the flags and add them to the appropriate option. + # Loop through the flags and add them to the appropriate variable. # This tries to strike a balance between checking for all possible # flags and keeping the logic to a finite size, so it doesn't # check for some that don't occur often. It particular, if the @@ -926,6 +926,8 @@ def append_define(name, mapping=mapping) -> None: append_next_arg_to = None # for multi-word args for arg in params: if append_next_arg_to: + # these are the second pass for options where the + # option-argument follows as a second word. if append_next_arg_to == 'CPPDEFINES': append_define(arg) elif append_next_arg_to == '-include': @@ -1022,6 +1024,8 @@ def append_define(name, mapping=mapping) -> None: else: key = 'CFLAGS' mapping[key].append(arg) + elif arg.startswith('-stdlib='): + mapping['CXXFLAGS'].append(arg) elif arg[0] == '+': mapping['CCFLAGS'].append(arg) mapping['LINKFLAGS'].append(arg) diff --git a/SCons/Environment.xml b/SCons/Environment.xml index c908d11c97..da8a19220d 100644 --- a/SCons/Environment.xml +++ b/SCons/Environment.xml @@ -2687,6 +2687,7 @@ and added to the following construction variables: -openmp CCFLAGS, LINKFLAGS -pthread CCFLAGS, LINKFLAGS -std= CFLAGS +-stdlib= CXXFLAGS -Wa, ASFLAGS, CCFLAGS -Wl,-rpath= RPATH -Wl,-R, RPATH diff --git a/SCons/EnvironmentTests.py b/SCons/EnvironmentTests.py index 8061e595b5..9d1229c44d 100644 --- a/SCons/EnvironmentTests.py +++ b/SCons/EnvironmentTests.py @@ -822,6 +822,7 @@ def test_ParseFlags(self) -> None: "-DFOO -DBAR=value -D BAZ " "-fsanitize=memory " "-fsanitize-address-use-after-return " + "-stdlib=libc++" ) d = env.ParseFlags(s) @@ -841,7 +842,7 @@ def test_ParseFlags(self) -> None: '+DD64', '-fsanitize=memory', '-fsanitize-address-use-after-return'], repr(d['CCFLAGS']) - assert d['CXXFLAGS'] == ['-std=c++0x'], repr(d['CXXFLAGS']) + assert d['CXXFLAGS'] == ['-std=c++0x', '-stdlib=libc++'], repr(d['CXXFLAGS']) assert d['CPPDEFINES'] == ['FOO', ['BAR', 'value'], 'BAZ'], d['CPPDEFINES'] assert d['CPPFLAGS'] == ['-Wp,-cpp'], d['CPPFLAGS'] assert d['CPPPATH'] == ['/usr/include/fum',