Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sage-env: identify the version of command-line tools (OS X) and set LDFLAGS accordingly #36599

Merged
merged 4 commits into from
Nov 10, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/bin/sage-env
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,15 @@ export UNAME=`uname | sed 's/CYGWIN.*/CYGWIN/' `
# Mac OS X-specific setup
if [ "$UNAME" = "Darwin" ]; then
export MACOSX_VERSION=`uname -r | awk -F. '{print $1}'`
# Try to identify command-line tools version.
# See https://apple.stackexchange.com/q/180957/351985.
XCLT_VERSION=`pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | awk '/version: / { print $NF }' | cut -d. -f-1`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if querying with pkgutil is the right approach.
I think on a system several versions of CLT (and separately several versions of Xcode) can be installed.

# If this didn't produce an integer, set to 0.
case $XCLT_VERSION in
''|*[!0-9]*) export XCLT_VERSION=0 ;; # bad
*) : ;; # good
esac
export XCLT_VERSION
# Work around problems on recent OS X crashing with an error message
# "... may have been in progress in another thread when fork() was called"
# when objective-C functions are called after fork(). See Issue #25921.
Expand Down Expand Up @@ -374,7 +383,11 @@ if [ -n "$PYTHONHOME" ]; then
fi

if [ -n "$SAGE_LOCAL" ]; then
LDFLAGS="-L$SAGE_LOCAL/lib -Wl,-rpath,$SAGE_LOCAL/lib $LDFLAGS"
if [ "$UNAME" = "Darwin" ] && [ "$XCLT_VERSION" -ge 15 ]; then
LDFLAGS="-L$SAGE_LOCAL/lib -Wl,-ld_classic,-rpath,$SAGE_LOCAL/lib $LDFLAGS"
else
LDFLAGS="-L$SAGE_LOCAL/lib -Wl,-rpath,$SAGE_LOCAL/lib $LDFLAGS"
fi
if [ "$UNAME" = "Linux" ]; then
LDFLAGS="-Wl,-rpath-link,$SAGE_LOCAL/lib $LDFLAGS"
fi
Expand Down
Loading