Skip to content

Commit 2a45742

Browse files
committed
OS X: do not use -ld_classic. Filter out some ld warnings when doctesting.
1 parent 209ae4c commit 2a45742

File tree

3 files changed

+25
-27
lines changed

3 files changed

+25
-27
lines changed

src/bin/sage-env

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -373,32 +373,6 @@ if [ -n "$SAGE_LOCAL" ]; then
373373
# Construct and export LDFLAGS
374374
if [ "$UNAME" = "Darwin" ]; then
375375
LDFLAGS="-L$SAGE_LOCAL/lib $LDFLAGS"
376-
# On OS X, use the old linker if it is available.
377-
# if "ld-classic" is present in the selected XCode
378-
# toolchain, add "-Wl,-ld_classic" to LDFLAGS (see #36599) unless
379-
# LD is already set, as it will be with conda on macOS. When the
380-
# selected toolchain is in the Xcode app the output of "xcode-select -p"
381-
# is "/Applications/Xcode.app/Contents/Developer", but "ld-classic" is
382-
# not in the subdirectory "usr/bin/" but rather in the subdirectory
383-
# "Toolchains/XcodeDefault.xctoolchain/usr/bin/". (See #37237.)
384-
if [ -z "$LD" ]; then
385-
# Running xcode-select on a system with no toolchain writes an
386-
# error message to stderr, so redirect stderr to /dev/null.
387-
XCODE_PATH=$(/usr/bin/xcode-select -p 2> /dev/null)
388-
if [ -n $XCODE_PATH ]; then
389-
if [ -x "$XCODE_PATH/usr/bin/ld-classic" -o \
390-
-x "$XCODE_PATH/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld-classic" ]; then
391-
LDFLAGS="$LDFLAGS -Wl,-ld_classic"
392-
fi
393-
else
394-
# On a macOS system with no toolchain we don't want this script
395-
# to call gcc because that will also print an error message to
396-
# stderr. We can avoid this by setting AS and LD to their
397-
# default values.
398-
AS=as
399-
LD=ld
400-
fi
401-
fi
402376
fi
403377
if [ "$UNAME" = "Linux" ]; then
404378
LDFLAGS="-L$SAGE_LOCAL/lib -Wl,-rpath,$SAGE_LOCAL/lib $LDFLAGS"

src/sage/doctest/parsing.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,6 +1516,21 @@ def do_fixup(self, want, got):
15161516
pythran_numpy_warning_regex = re.compile(r'WARNING: Overriding pythran description with argspec information for: numpy\.random\.[a-z_]+')
15171517
got = pythran_numpy_warning_regex.sub('', got)
15181518
did_fixup = True
1519+
1520+
if "ld_classic is deprecated" in got:
1521+
# New warnings as of Oct '24, Xcode 16.
1522+
ld_warn_regex = re.compile("ld: warning: -ld_classic is deprecated and will be removed in a future release")
1523+
got = ld_warn_regex.sub('', got)
1524+
did_fixup = True
1525+
1526+
if "duplicate libraries" in got:
1527+
# New warnings as of Sept '23, OS X 13.6, new command-line
1528+
# tools. In particular, these seem to come from ld in
1529+
# Xcode 15.
1530+
dup_lib_regex = re.compile("ld: warning: ignoring duplicate libraries: .*")
1531+
got = dup_lib_regex.sub('', got)
1532+
did_fixup = True
1533+
15191534
return did_fixup, want, got
15201535

15211536
def output_difference(self, example, got, optionflags):

src/sage/tests/cmdline.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,4 +776,13 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False
776776
p.stderr.close()
777777
err.append(s)
778778

779-
return (''.join(out), ''.join(err), p.wait())
779+
# In case out or err contains a quoted string, force the use of
780+
# double quotes so that the output is enclosed in single
781+
# quotes. This avoids some doctest failures with some versions of
782+
# OS X and Xcode.
783+
out = ''.join(out)
784+
out = out.replace("'", '"')
785+
err = ''.join(err)
786+
err = err.replace("'", '"')
787+
788+
return (out, err, p.wait())

0 commit comments

Comments
 (0)