diff --git a/src/bin/sage-env b/src/bin/sage-env index b9221fe3567..5a53ab1d2ce 100644 --- a/src/bin/sage-env +++ b/src/bin/sage-env @@ -383,12 +383,15 @@ if [ -n "$SAGE_LOCAL" ]; then # "Toolchains/XcodeDefault.xctoolchain/usr/bin/". (See #37237.) if [ -z "$LD" ]; then # Running xcode-select on a system with no toolchain writes an - # error message to stderr, so redirect stderr to /dev/null. + # error message to stderr, so redirect stderr to /dev/null. XCODE_PATH=$(/usr/bin/xcode-select -p 2> /dev/null) if [ -n $XCODE_PATH ]; then if [ -x "$XCODE_PATH/usr/bin/ld-classic" -o \ -x "$XCODE_PATH/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld-classic" ]; then - LDFLAGS="$LDFLAGS -Wl,-ld_classic" + # Add -ld_classic only if -ld_classic is not deprecated. + if [ -z "$(ld -ld_classic 2>&1 | grep 'ld_classic is deprecated')" ]; then + LDFLAGS="$LDFLAGS -Wl,-ld_classic" + fi fi else # On a macOS system with no toolchain we don't want this script diff --git a/src/sage/doctest/parsing.py b/src/sage/doctest/parsing.py index 0bc4965cd09..20f6eb6ce69 100644 --- a/src/sage/doctest/parsing.py +++ b/src/sage/doctest/parsing.py @@ -1516,6 +1516,21 @@ def do_fixup(self, want, got): pythran_numpy_warning_regex = re.compile(r'WARNING: Overriding pythran description with argspec information for: numpy\.random\.[a-z_]+') got = pythran_numpy_warning_regex.sub('', got) did_fixup = True + + if "ld_classic is deprecated" in got: + # New warnings as of Oct '24, Xcode 16. + ld_warn_regex = re.compile("ld: warning: -ld_classic is deprecated and will be removed in a future release") + got = ld_warn_regex.sub('', got) + did_fixup = True + + if "duplicate libraries" in got: + # New warnings as of Sept '23, OS X 13.6, new command-line + # tools. In particular, these seem to come from ld in + # Xcode 15. + dup_lib_regex = re.compile("ld: warning: ignoring duplicate libraries: .*") + got = dup_lib_regex.sub('', got) + did_fixup = True + return did_fixup, want, got def output_difference(self, example, got, optionflags): diff --git a/src/sage/tests/cmdline.py b/src/sage/tests/cmdline.py index 406bf1befab..27c614d290f 100644 --- a/src/sage/tests/cmdline.py +++ b/src/sage/tests/cmdline.py @@ -776,4 +776,13 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False p.stderr.close() err.append(s) - return (''.join(out), ''.join(err), p.wait()) + # In case out or err contains a quoted string, force the use of + # double quotes so that the output is enclosed in single + # quotes. This avoids some doctest failures with some versions of + # OS X and Xcode. + out = ''.join(out) + out = out.replace("'", '"') + err = ''.join(err) + err = err.replace("'", '"') + + return (out, err, p.wait())