From 3d5fc6c2d1685ff8b87c7249ff6d40eaf3760535 Mon Sep 17 00:00:00 2001 From: Marc Culler Date: Sat, 27 Apr 2024 11:02:19 -0500 Subject: [PATCH 01/15] Update python3.11, make Makefile honest, clean up macOS rpath snafu. --- build/make/Makefile.in | 2 +- build/pkgs/python3/checksums.ini | 6 +-- build/pkgs/python3/package-version.txt | 2 +- .../python3/patches/2.6.5-FD_SETSIZE.patch | 47 ------------------- build/pkgs/python3/patches/2.7.3-dylib.patch | 15 ------ .../patches/3.2.6-no-enable-new-dtags.patch | 22 --------- build/pkgs/python3/spkg-build.in | 25 +++++----- src/bin/sage-env | 39 +++++++++------ 8 files changed, 43 insertions(+), 115 deletions(-) delete mode 100644 build/pkgs/python3/patches/2.6.5-FD_SETSIZE.patch delete mode 100644 build/pkgs/python3/patches/2.7.3-dylib.patch delete mode 100644 build/pkgs/python3/patches/3.2.6-no-enable-new-dtags.patch diff --git a/build/make/Makefile.in b/build/make/Makefile.in index 28003ba0aff..7416ea7d3d2 100644 --- a/build/make/Makefile.in +++ b/build/make/Makefile.in @@ -9,7 +9,7 @@ # obscure the substance of the actual rules, this file can be debugged by # running: # -# $ make -f build/make/Makefile -n DEBUG_RULES=1 +# $ make -f build/make/Makefile -n DEBUG_RULES=1 SAGE_PKGCONFIG=1 # # This will not actually run any rules (the -n flag) but will print all the # rules generated from the templates. diff --git a/build/pkgs/python3/checksums.ini b/build/pkgs/python3/checksums.ini index f2727eaf401..936ac821ed2 100644 --- a/build/pkgs/python3/checksums.ini +++ b/build/pkgs/python3/checksums.ini @@ -1,5 +1,5 @@ tarball=Python-VERSION.tar.xz -sha1=89ee31611b73dc0c32c178d15aa208734b462c5a -md5=4efe92adf28875c77d3b9b2e8d3bc44a -cksum=2916176597 +sha1=a368aeed7a3325e47b55168452c356a8eb27ab50 +md5=b353b8433e560e1af2b130f56dfbd973 +cksum=534846730 upstream_url=https://www.python.org/ftp/python/VERSION/Python-VERSION.tar.xz diff --git a/build/pkgs/python3/package-version.txt b/build/pkgs/python3/package-version.txt index 371cfe355dd..b6d8b7612f0 100644 --- a/build/pkgs/python3/package-version.txt +++ b/build/pkgs/python3/package-version.txt @@ -1 +1 @@ -3.11.1 +3.11.8 diff --git a/build/pkgs/python3/patches/2.6.5-FD_SETSIZE.patch b/build/pkgs/python3/patches/2.6.5-FD_SETSIZE.patch deleted file mode 100644 index d1e0aa7352e..00000000000 --- a/build/pkgs/python3/patches/2.6.5-FD_SETSIZE.patch +++ /dev/null @@ -1,47 +0,0 @@ -This patch has never been submitted upstream for some reason, but it simply -increases the default number of file descriptors the Python process can have on -Cygwin, which mitigates some issues; see -https://cygwin.com/ml/cygwin/2011-03/msg00651.html -diff --git a/Python-3.6.1/Modules/selectmodule.c.orig b/Python-3.6.1/Modules/selectmodule.c -index 47da493..ae60234 100644 ---- a/Modules/selectmodule.c -+++ b/Modules/selectmodule.c -@@ -8,6 +8,21 @@ - #define _GNU_SOURCE - #endif - -+/* Windows #defines FD_SETSIZE to 64 if FD_SETSIZE isn't already defined. -+ 64 is too small (too many people have bumped into that limit). -+ Here we boost it. -+ -+ Cygwin also defines FD_SETSIZE to 64, so also increase the limit on -+ Cygwin. We must do this before sys/types.h is included, which otherwise -+ sets FD_SETSIZE to the default. -+ -+ Users who want even more than the boosted limit should #define -+ FD_SETSIZE higher before this; e.g., via compiler /D switch. -+*/ -+#if (defined(MS_WINDOWS) || defined(__CYGWIN__)) && !defined(FD_SETSIZE) -+#define FD_SETSIZE 512 -+#endif -+ - #include "Python.h" - #include - -@@ -26,16 +41,6 @@ - #undef HAVE_BROKEN_POLL - #endif - --/* Windows #defines FD_SETSIZE to 64 if FD_SETSIZE isn't already defined. -- 64 is too small (too many people have bumped into that limit). -- Here we boost it. -- Users who want even more than the boosted limit should #define -- FD_SETSIZE higher before this; e.g., via compiler /D switch. --*/ --#if defined(MS_WINDOWS) && !defined(FD_SETSIZE) --#define FD_SETSIZE 512 --#endif -- - #if defined(HAVE_POLL_H) - #include - #elif defined(HAVE_SYS_POLL_H) diff --git a/build/pkgs/python3/patches/2.7.3-dylib.patch b/build/pkgs/python3/patches/2.7.3-dylib.patch deleted file mode 100644 index be0de05d388..00000000000 --- a/build/pkgs/python3/patches/2.7.3-dylib.patch +++ /dev/null @@ -1,15 +0,0 @@ -This patch provides a workaround to one long-standing problem with building -extension modules on Cygwin; see https://bugs.python.org/issue2445 for more -background. -diff --git a/Lib/distutils/unixccompiler.py.orig b/Lib/distutils/unixccompiler.py -index 3f321c2..fb5a8fc 100644 ---- a/Lib/distutils/unixccompiler.py -+++ b/Lib/distutils/unixccompiler.py -@@ -81,6 +81,7 @@ class UnixCCompiler(CCompiler): - xcode_stub_lib_format = dylib_lib_format - if sys.platform == "cygwin": - exe_extension = ".exe" -+ dylib_lib_extension = ".dll.a" - - def preprocess(self, source, output_file=None, macros=None, - include_dirs=None, extra_preargs=None, extra_postargs=None): diff --git a/build/pkgs/python3/patches/3.2.6-no-enable-new-dtags.patch b/build/pkgs/python3/patches/3.2.6-no-enable-new-dtags.patch deleted file mode 100644 index ea9b7cecd03..00000000000 --- a/build/pkgs/python3/patches/3.2.6-no-enable-new-dtags.patch +++ /dev/null @@ -1,22 +0,0 @@ -The --enable-new-dtags linker flag should not be used when building non-ELF -binaries. This is related to http://bugs.python.org/issue17362 -diff --git a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py -index 69045f8..7ed0a5f 100644 ---- a/Lib/distutils/unixccompiler.py -+++ b/Lib/distutils/unixccompiler.py -@@ -243,9 +243,13 @@ class UnixCCompiler(CCompiler): - # -Wl whenever gcc was used in the past it is probably - # safest to keep doing so. - if sysconfig.get_config_var("GNULD") == "yes": -- # GNU ld needs an extra option to get a RUNPATH -+ # GNU ELF ld needs an extra option to get a RUNPATH - # instead of just an RPATH. -- return "-Wl,--enable-new-dtags,-R" + dir -+ if sys.platform in ["win32", "cygwin"] or \ -+ "mingw" in compiler: -+ return [] -+ else: -+ return "-Wl,--enable-new-dtags,-R" + dir - else: - return "-Wl,-R" + dir - else: diff --git a/build/pkgs/python3/spkg-build.in b/build/pkgs/python3/spkg-build.in index c8058023b28..f2a8b4311db 100644 --- a/build/pkgs/python3/spkg-build.in +++ b/build/pkgs/python3/spkg-build.in @@ -73,25 +73,26 @@ sdh_configure --enable-shared $PYTHON_CONFIGURE # we need to provide paths into $SAGE_LOCAL, so that setup.py finds # the libraries needed for the extension modules - in particular sqlite3. # (The search code there does not know about CPATH and LIBRARY_PATH.) -make_LDFLAGS="-L. -Wl,-rpath,. -L$SAGE_LOCAL/lib $LDFLAGS" -make_CPPFLAGS="-I$SAGE_LOCAL/include $CPPFLAGS" -# Also, we need to add an rpath, like we do for SAGE_LOCAL in src/bin/sage-env. -# SAGE_INST_LOCAL is the installation hierarchy for the current package -# -- for python3, this is SAGE_VENV. -make_LDFLAGS="-Wl,-rpath,$SAGE_INST_LOCAL/lib $make_LDFLAGS" +if [ "$UNAME" = "Darwin" ]; then + make_LDFLAGS="-L$SAGE_LOCAL/lib -L$SAGE_INST_LOCAL/lib $LDFLAGS" + # This enables python to find libpython + export DYLD_LIBRARY_PATH="." +fi if [ "$UNAME" = "Linux" ]; then + make_LDFLAGS="-L. -Wl,-rpath,. -L$SAGE_LOCAL/lib $LDFLAGS" + make_CPPFLAGS="-I$SAGE_LOCAL/include $CPPFLAGS" + # Also, we need to add an rpath, like we do for SAGE_LOCAL in src/bin/sage-env. + # SAGE_INST_LOCAL is the installation hierarchy for the current package + # -- for python3, this is SAGE_VENV. + make_LDFLAGS="-Wl,-rpath,$SAGE_INST_LOCAL/lib $make_LDFLAGS" make_LDFLAGS="-Wl,-rpath-link,$SAGE_INST_LOCAL/lib $make_LDFLAGS" + # This enables python to find libpython + export LD_LIBRARY_PATH="." fi sdh_make LDFLAGS="$make_LDFLAGS" CPPFLAGS="$make_CPPFLAGS" -if [ "$UNAME" = "Darwin" ]; then - export DYLD_LIBRARY_PATH="." -else - export LD_LIBRARY_PATH="." -fi - # When building on a case-insensitive filesystem (on any OS, not just Windows) # the Python executable is output to the build directory as 'python.exe' if [ -f "python.exe" ]; then diff --git a/src/bin/sage-env b/src/bin/sage-env index 61901897bcd..dacecf7df94 100644 --- a/src/bin/sage-env +++ b/src/bin/sage-env @@ -370,20 +370,31 @@ if [ -n "$PYTHONHOME" ]; then fi if [ -n "$SAGE_LOCAL" ]; then - # On OS X, test whether "ld-classic" is present in the installed - # version of the command-line tools. If so, we add "-ld_classic" - # to LD_FLAGS. See #36599. - # When the full XCode is installed and in use, for example after - # "sudo xcode-select -s /Applications/Xcode.app", then "xcode-select -p" - # gives "/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. - # However, if LD is set explicitly, as it is within conda on macOS, - # do not not do this. - if [ "$UNAME" = "Darwin" ] && [ -z "$LD" ] && [ -x "$(xcode-select -p)/usr/bin/ld-classic" -o -x "$(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld-classic" ] ; 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" + # On OS X, test whether "ld-classic" is present in the selected XCode + # toolchain. If so, add "-Wl,-ld_classic" to LD_FLAGS (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" + 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,-ldclassic" + 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 if [ "$UNAME" = "Linux" ]; then LDFLAGS="-Wl,-rpath-link,$SAGE_LOCAL/lib $LDFLAGS" From 4f969ee7da236b97b67a7935e5e7868119017d29 Mon Sep 17 00:00:00 2001 From: Marc Culler Date: Sat, 27 Apr 2024 11:41:44 -0500 Subject: [PATCH 02/15] typos --- src/bin/sage-env | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bin/sage-env b/src/bin/sage-env index dacecf7df94..a2e7ba64a50 100644 --- a/src/bin/sage-env +++ b/src/bin/sage-env @@ -371,7 +371,7 @@ 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 LD_FLAGS (see #36599) unless + # 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 @@ -385,7 +385,7 @@ if [ -n "$SAGE_LOCAL" ]; then 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,-ldclassic" + LDFLAGS="$LDFLAGS -Wl,-ld_classic" fi else # On a macOS system with no toolchain we don't want this script From 17672deaae4c5a98f85da39dddb5eb78dd21972c Mon Sep 17 00:00:00 2001 From: Marc Culler Date: Sat, 27 Apr 2024 14:39:46 -0500 Subject: [PATCH 03/15] Fix primecountpy, which needs an rpath. --- build/pkgs/primecountpy/spkg-install.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build/pkgs/primecountpy/spkg-install.in b/build/pkgs/primecountpy/spkg-install.in index 37ac1a53437..829ebe2fcc5 100644 --- a/build/pkgs/primecountpy/spkg-install.in +++ b/build/pkgs/primecountpy/spkg-install.in @@ -1,2 +1,7 @@ +if [ "$UNAME" = "Darwin" ]; then + LDFLAGS="${LDFLAGS} -Wl,-rpath,${SAGE_LOCAL}/lib" + export LDFLAGS +fi + cd src sdh_pip_install . From 02ad303e1b9c44b81c99e245118caf4c3a957b21 Mon Sep 17 00:00:00 2001 From: Marc Culler Date: Sun, 28 Apr 2024 14:27:02 -0500 Subject: [PATCH 04/15] Avoid overwriting user LDFLAGS --- src/bin/sage-env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/sage-env b/src/bin/sage-env index a2e7ba64a50..aadde032cc6 100644 --- a/src/bin/sage-env +++ b/src/bin/sage-env @@ -377,7 +377,7 @@ if [ -n "$SAGE_LOCAL" ]; then # "/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="$LDFLAGS -L$SAGE_LOCAL/lib" 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. From e7338cd0d395cfc144352897cf280385fecb21ea Mon Sep 17 00:00:00 2001 From: Marc Culler Date: Sun, 28 Apr 2024 17:59:24 -0500 Subject: [PATCH 05/15] Put /lib in front of user's LDFLAGS --- src/bin/sage-env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/sage-env b/src/bin/sage-env index aadde032cc6..c9d1e532db9 100644 --- a/src/bin/sage-env +++ b/src/bin/sage-env @@ -377,7 +377,7 @@ if [ -n "$SAGE_LOCAL" ]; then # "/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="$LDFLAGS -L$SAGE_LOCAL/lib" + 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. From 24f2545d7312f0b29cb85a229de6a86399c7b2de Mon Sep 17 00:00:00 2001 From: Marc Culler Date: Sun, 28 Apr 2024 22:59:01 -0500 Subject: [PATCH 06/15] Add rpath to LDFLAGS for symengine_py and bliss --- build/pkgs/bliss/spkg-install.in | 4 ++++ build/pkgs/symengine_py/spkg-install.in | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/build/pkgs/bliss/spkg-install.in b/build/pkgs/bliss/spkg-install.in index 4124a2338e5..b988d6262ce 100644 --- a/build/pkgs/bliss/spkg-install.in +++ b/build/pkgs/bliss/spkg-install.in @@ -1,3 +1,7 @@ +if [ "$UNAME" = "Darwin" ]; then + LDFLAGS="${LDFLAGS} -Wl,-rpath,${SAGE_LOCAL}/lib" + export LDFLAGS +fi cd src sdh_cmake -DUSE_GMP=OFF -DCMAKE_VERBOSE_MAKEFILE=ON sdh_make diff --git a/build/pkgs/symengine_py/spkg-install.in b/build/pkgs/symengine_py/spkg-install.in index 37ac1a53437..829ebe2fcc5 100644 --- a/build/pkgs/symengine_py/spkg-install.in +++ b/build/pkgs/symengine_py/spkg-install.in @@ -1,2 +1,7 @@ +if [ "$UNAME" = "Darwin" ]; then + LDFLAGS="${LDFLAGS} -Wl,-rpath,${SAGE_LOCAL}/lib" + export LDFLAGS +fi + cd src sdh_pip_install . From 64b11b8e7e0803db1f55eb45264b492668a018f9 Mon Sep 17 00:00:00 2001 From: Marc Culler Date: Mon, 6 May 2024 07:44:28 -0500 Subject: [PATCH 07/15] Cleaner fix for printing make rules without setting an apparently unrelated variable. --- build/make/Makefile.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build/make/Makefile.in b/build/make/Makefile.in index 7416ea7d3d2..2856fd71ade 100644 --- a/build/make/Makefile.in +++ b/build/make/Makefile.in @@ -9,7 +9,7 @@ # obscure the substance of the actual rules, this file can be debugged by # running: # -# $ make -f build/make/Makefile -n DEBUG_RULES=1 SAGE_PKGCONFIG=1 +# $ make -f build/make/Makefile -n DEBUG_RULES=1 # # This will not actually run any rules (the -n flag) but will print all the # rules generated from the templates. @@ -17,6 +17,7 @@ # Always use bash for make rules SHELL = @SHELL@ +ifndef DEBUG_RULES # Check a variable that is only set in build/make/install, but not in sage-env, for example ifndef SAGE_PKGCONFIG # Set by build/bin/sage-sdist, which invokes the Makefile directly in @@ -25,6 +26,7 @@ ifndef SAGE_SPKG_COPY_UPSTREAM $(error This Makefile needs to be invoked by build/make/install) endif endif +endif # Directory to keep track of which packages are installed - relative to installation prefix SPKG_INST_RELDIR = var/lib/sage/installed From 8e72038b4ab24fb63c06b28f6eb43097b9ab24d6 Mon Sep 17 00:00:00 2001 From: Marc Culler Date: Sat, 27 Apr 2024 11:02:19 -0500 Subject: [PATCH 08/15] Update python3.11, make Makefile honest, clean up macOS rpath snafu. --- build/make/Makefile.in | 2 +- src/bin/sage-env | 39 +++++++++++++++++++++++++-------------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/build/make/Makefile.in b/build/make/Makefile.in index 49c0cc4ebcf..73df3be3882 100644 --- a/build/make/Makefile.in +++ b/build/make/Makefile.in @@ -9,7 +9,7 @@ # obscure the substance of the actual rules, this file can be debugged by # running: # -# $ make -f build/make/Makefile -n DEBUG_RULES=1 +# $ make -f build/make/Makefile -n DEBUG_RULES=1 SAGE_PKGCONFIG=1 # # This will not actually run any rules (the -n flag) but will print all the # rules generated from the templates. diff --git a/src/bin/sage-env b/src/bin/sage-env index 61901897bcd..dacecf7df94 100644 --- a/src/bin/sage-env +++ b/src/bin/sage-env @@ -370,20 +370,31 @@ if [ -n "$PYTHONHOME" ]; then fi if [ -n "$SAGE_LOCAL" ]; then - # On OS X, test whether "ld-classic" is present in the installed - # version of the command-line tools. If so, we add "-ld_classic" - # to LD_FLAGS. See #36599. - # When the full XCode is installed and in use, for example after - # "sudo xcode-select -s /Applications/Xcode.app", then "xcode-select -p" - # gives "/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. - # However, if LD is set explicitly, as it is within conda on macOS, - # do not not do this. - if [ "$UNAME" = "Darwin" ] && [ -z "$LD" ] && [ -x "$(xcode-select -p)/usr/bin/ld-classic" -o -x "$(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld-classic" ] ; 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" + # On OS X, test whether "ld-classic" is present in the selected XCode + # toolchain. If so, add "-Wl,-ld_classic" to LD_FLAGS (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" + 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,-ldclassic" + 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 if [ "$UNAME" = "Linux" ]; then LDFLAGS="-Wl,-rpath-link,$SAGE_LOCAL/lib $LDFLAGS" From a30a5e386c92e7341ad6e554fc82e8759ac7a528 Mon Sep 17 00:00:00 2001 From: Marc Culler Date: Sat, 27 Apr 2024 11:41:44 -0500 Subject: [PATCH 09/15] typos --- src/bin/sage-env | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bin/sage-env b/src/bin/sage-env index dacecf7df94..a2e7ba64a50 100644 --- a/src/bin/sage-env +++ b/src/bin/sage-env @@ -371,7 +371,7 @@ 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 LD_FLAGS (see #36599) unless + # 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 @@ -385,7 +385,7 @@ if [ -n "$SAGE_LOCAL" ]; then 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,-ldclassic" + LDFLAGS="$LDFLAGS -Wl,-ld_classic" fi else # On a macOS system with no toolchain we don't want this script From e0ad5739218b65b56813b4213203869156ee8422 Mon Sep 17 00:00:00 2001 From: Marc Culler Date: Sat, 27 Apr 2024 14:39:46 -0500 Subject: [PATCH 10/15] Fix primecountpy, which needs an rpath. --- build/pkgs/primecountpy/spkg-install.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build/pkgs/primecountpy/spkg-install.in b/build/pkgs/primecountpy/spkg-install.in index 37ac1a53437..829ebe2fcc5 100644 --- a/build/pkgs/primecountpy/spkg-install.in +++ b/build/pkgs/primecountpy/spkg-install.in @@ -1,2 +1,7 @@ +if [ "$UNAME" = "Darwin" ]; then + LDFLAGS="${LDFLAGS} -Wl,-rpath,${SAGE_LOCAL}/lib" + export LDFLAGS +fi + cd src sdh_pip_install . From 38273e6b0abe8376f0923c032ab24a2ae0aaf1d7 Mon Sep 17 00:00:00 2001 From: Marc Culler Date: Sun, 28 Apr 2024 14:27:02 -0500 Subject: [PATCH 11/15] Avoid overwriting user LDFLAGS --- src/bin/sage-env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/sage-env b/src/bin/sage-env index a2e7ba64a50..aadde032cc6 100644 --- a/src/bin/sage-env +++ b/src/bin/sage-env @@ -377,7 +377,7 @@ if [ -n "$SAGE_LOCAL" ]; then # "/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="$LDFLAGS -L$SAGE_LOCAL/lib" 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. From c086cc48e5940ee5d88c8fa22731fb7a7cdddba4 Mon Sep 17 00:00:00 2001 From: Marc Culler Date: Sun, 28 Apr 2024 17:59:24 -0500 Subject: [PATCH 12/15] Put /lib in front of user's LDFLAGS --- src/bin/sage-env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/sage-env b/src/bin/sage-env index aadde032cc6..c9d1e532db9 100644 --- a/src/bin/sage-env +++ b/src/bin/sage-env @@ -377,7 +377,7 @@ if [ -n "$SAGE_LOCAL" ]; then # "/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="$LDFLAGS -L$SAGE_LOCAL/lib" + 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. From e790efc572822d0254fa2b6993604fe5d63cba02 Mon Sep 17 00:00:00 2001 From: Marc Culler Date: Sun, 28 Apr 2024 22:59:01 -0500 Subject: [PATCH 13/15] Add rpath to LDFLAGS for symengine_py and bliss --- build/pkgs/bliss/spkg-install.in | 4 ++++ build/pkgs/symengine_py/spkg-install.in | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/build/pkgs/bliss/spkg-install.in b/build/pkgs/bliss/spkg-install.in index 4124a2338e5..b988d6262ce 100644 --- a/build/pkgs/bliss/spkg-install.in +++ b/build/pkgs/bliss/spkg-install.in @@ -1,3 +1,7 @@ +if [ "$UNAME" = "Darwin" ]; then + LDFLAGS="${LDFLAGS} -Wl,-rpath,${SAGE_LOCAL}/lib" + export LDFLAGS +fi cd src sdh_cmake -DUSE_GMP=OFF -DCMAKE_VERBOSE_MAKEFILE=ON sdh_make diff --git a/build/pkgs/symengine_py/spkg-install.in b/build/pkgs/symengine_py/spkg-install.in index 37ac1a53437..829ebe2fcc5 100644 --- a/build/pkgs/symengine_py/spkg-install.in +++ b/build/pkgs/symengine_py/spkg-install.in @@ -1,2 +1,7 @@ +if [ "$UNAME" = "Darwin" ]; then + LDFLAGS="${LDFLAGS} -Wl,-rpath,${SAGE_LOCAL}/lib" + export LDFLAGS +fi + cd src sdh_pip_install . From 2fbd1598a0f0c3c99c6de11a8d991b263afd4993 Mon Sep 17 00:00:00 2001 From: Marc Culler Date: Mon, 6 May 2024 07:44:28 -0500 Subject: [PATCH 14/15] Cleaner fix for printing make rules without setting an apparently unrelated variable. --- build/make/Makefile.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build/make/Makefile.in b/build/make/Makefile.in index 73df3be3882..7a13e5a9e23 100644 --- a/build/make/Makefile.in +++ b/build/make/Makefile.in @@ -9,7 +9,7 @@ # obscure the substance of the actual rules, this file can be debugged by # running: # -# $ make -f build/make/Makefile -n DEBUG_RULES=1 SAGE_PKGCONFIG=1 +# $ make -f build/make/Makefile -n DEBUG_RULES=1 # # This will not actually run any rules (the -n flag) but will print all the # rules generated from the templates. @@ -17,6 +17,7 @@ # Always use bash for make rules SHELL = @SHELL@ +ifndef DEBUG_RULES # Check a variable that is only set in build/make/install, but not in sage-env, for example ifndef SAGE_PKGCONFIG # Set by build/bin/sage-sdist, which invokes the Makefile directly in @@ -25,6 +26,7 @@ ifndef SAGE_SPKG_COPY_UPSTREAM $(error This Makefile needs to be invoked by build/make/install) endif endif +endif # Directory to keep track of which packages are installed - relative to installation prefix SPKG_INST_RELDIR = var/lib/sage/installed From 3f1894eb06d5111c4bfb2b468a701db73d68b784 Mon Sep 17 00:00:00 2001 From: Marc Culler Date: Sun, 12 May 2024 22:47:10 -0500 Subject: [PATCH 15/15] Fix broken logic in sage-env; add missing rpath to primecount spkg --- build/pkgs/primecount/spkg-install.in | 4 ++ src/bin/sage-env | 55 +++++++++++++++------------ 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/build/pkgs/primecount/spkg-install.in b/build/pkgs/primecount/spkg-install.in index 0a63840d8cb..7589fad8cb9 100644 --- a/build/pkgs/primecount/spkg-install.in +++ b/build/pkgs/primecount/spkg-install.in @@ -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++..." diff --git a/src/bin/sage-env b/src/bin/sage-env index c9d1e532db9..b9221fe3567 100644 --- a/src/bin/sage-env +++ b/src/bin/sage-env @@ -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