Skip to content

Commit

Permalink
Fix broken logic in sage-env; add missing rpath to primecount spkg
Browse files Browse the repository at this point in the history
  • Loading branch information
culler committed May 13, 2024
1 parent 0b9a7dd commit 3f1894e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 25 deletions.
4 changes: 4 additions & 0 deletions build/pkgs/primecount/spkg-install.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
if [ "$UNAME" = "Darwin" ]; then
LDFLAGS="${LDFLAGS} -Wl,-rpath,${SAGE_LOCAL}/lib"
export LDFLAGS
fi
cd src

# Issue #33054: primecount needs "-std=gnu++..."
Expand Down
55 changes: 30 additions & 25 deletions src/bin/sage-env
Original file line number Diff line number Diff line change
Expand Up @@ -370,33 +370,38 @@ if [ -n "$PYTHONHOME" ]; then
fi

if [ -n "$SAGE_LOCAL" ]; then
# On OS X, test whether "ld-classic" is present in the selected XCode
# toolchain. If so, add "-Wl,-ld_classic" to LDFLAGS (see #36599) unless
# LD is already set, as it will be with conda on macOS. When the selected
# toolchain is in the Xcode app the output of "xcode-select -p" is
# "/Applications/Xcode.app/Contents/Developer", but "ld-classic" is not in
# the subdirectory "usr/bin/" but rather in the subdirectory
# "Toolchains/XcodeDefault.xctoolchain/usr/bin/". (See #37237.)
LDFLAGS="-L$SAGE_LOCAL/lib $LDFLAGS"
if [ "$UNAME" = "Darwin" ] && [ -z "$LD" ]; then
# Running xcode-select on a system with no toolchain writes an
# 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"
fi
else
# On a macOS system with no toolchain we don't want this script
# to call gcc because that will also print an error message to
# stderr. We can avoid this by setting AS and LD to their
# default values.
AS=as
LD=ld
fi
# Construct and export LDFLAGS
if [ "$UNAME" = "Darwin" ]; then
LDFLAGS="-L$SAGE_LOCAL/lib $LDFLAGS"
# On OS X, use the old linker if it is available.
# if "ld-classic" is present in the selected XCode
# toolchain, add "-Wl,-ld_classic" to LDFLAGS (see #36599) unless
# LD is already set, as it will be with conda on macOS. When the
# selected toolchain is in the Xcode app the output of "xcode-select -p"
# is "/Applications/Xcode.app/Contents/Developer", but "ld-classic" is
# not in the subdirectory "usr/bin/" but rather in the subdirectory
# "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.
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"
fi
else
# On a macOS system with no toolchain we don't want this script
# to call gcc because that will also print an error message to
# stderr. We can avoid this by setting AS and LD to their
# default values.
AS=as
LD=ld
fi
fi
fi
if [ "$UNAME" = "Linux" ]; then
LDFLAGS="-L$SAGE_LOCAL/lib -Wl,-rpath,$SAGE_LOCAL/lib $LDFLAGS"
LDFLAGS="-Wl,-rpath-link,$SAGE_LOCAL/lib $LDFLAGS"
fi
export LDFLAGS
Expand Down

0 comments on commit 3f1894e

Please sign in to comment.