Skip to content

Commit 0df1f22

Browse files
author
Release Manager
committed
gh-38931: OS X: do not use -ld_classic Recent versions of Xcode have deprecated `-ld_classic`, so (a) we stop using it, (b) we filter warnings about it when doctesting, and (c) we filter some other warnings related to ld in Xcode. Without these changes, when building with the latest Xcode, I get many doctest failures because of the new warning ``` ld: warning: -ld_classic is deprecated and will be removed in a future release ``` ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [X] The title is concise and informative. - [X] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: #38931 Reported by: John H. Palmieri Reviewer(s): Marc Culler
2 parents 7254cca + e79ccb9 commit 0df1f22

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

src/bin/sage-env

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,12 +383,15 @@ if [ -n "$SAGE_LOCAL" ]; then
383383
# "Toolchains/XcodeDefault.xctoolchain/usr/bin/". (See #37237.)
384384
if [ -z "$LD" ]; then
385385
# Running xcode-select on a system with no toolchain writes an
386-
# error message to stderr, so redirect stderr to /dev/null.
386+
# error message to stderr, so redirect stderr to /dev/null.
387387
XCODE_PATH=$(/usr/bin/xcode-select -p 2> /dev/null)
388388
if [ -n $XCODE_PATH ]; then
389389
if [ -x "$XCODE_PATH/usr/bin/ld-classic" -o \
390390
-x "$XCODE_PATH/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld-classic" ]; then
391-
LDFLAGS="$LDFLAGS -Wl,-ld_classic"
391+
# Add -ld_classic only if -ld_classic is not deprecated.
392+
if [ -z "$(ld -ld_classic 2>&1 | grep 'ld_classic is deprecated')" ]; then
393+
LDFLAGS="$LDFLAGS -Wl,-ld_classic"
394+
fi
392395
fi
393396
else
394397
# On a macOS system with no toolchain we don't want this script

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)