Skip to content

Commit 543cd2d

Browse files
committed
Check whether command-line tools includes the executable ld-classic,
and if so, set LDFLAGS to use it.
1 parent 2341fb4 commit 543cd2d

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/bin/sage-env

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -277,15 +277,6 @@ export UNAME=`uname | sed 's/CYGWIN.*/CYGWIN/' `
277277
# Mac OS X-specific setup
278278
if [ "$UNAME" = "Darwin" ]; then
279279
export MACOSX_VERSION=`uname -r | awk -F. '{print $1}'`
280-
# Try to identify command-line tools version.
281-
# See https://apple.stackexchange.com/q/180957/351985.
282-
XCLT_VERSION=`pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | awk '/version: / { print $NF }' | cut -d. -f-1`
283-
# If this didn't produce an integer, set to 0.
284-
case $XCLT_VERSION in
285-
''|*[!0-9]*) export XCLT_VERSION=0 ;; # bad
286-
*) : ;; # good
287-
esac
288-
export XCLT_VERSION
289280
# Work around problems on recent OS X crashing with an error message
290281
# "... may have been in progress in another thread when fork() was called"
291282
# when objective-C functions are called after fork(). See Issue #25921.
@@ -383,7 +374,10 @@ if [ -n "$PYTHONHOME" ]; then
383374
fi
384375

385376
if [ -n "$SAGE_LOCAL" ]; then
386-
if [ "$UNAME" = "Darwin" ] && [ "$XCLT_VERSION" -ge 15 ]; then
377+
# On OS X, test whether "ld-classic" is present in the installed
378+
# version of the command-line tools. If so, we add "-ld_classic"
379+
# to LD_FLAGS. See #36599.
380+
if [ "$UNAME" = "Darwin" ] && [ -x "$(xcode-select -p)/usr/bin/ld-classic" ] ; then
387381
LDFLAGS="-L$SAGE_LOCAL/lib -Wl,-ld_classic,-rpath,$SAGE_LOCAL/lib $LDFLAGS"
388382
else
389383
LDFLAGS="-L$SAGE_LOCAL/lib -Wl,-rpath,$SAGE_LOCAL/lib $LDFLAGS"

0 commit comments

Comments
 (0)