Unverified Commit 2a20f493 authored by George Huebner's avatar George Huebner
Browse files

sage: fixes for LLVM stdenv

Also backport a fix that silences `xcode-select: not found` warnings
parent a9f96508
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
From 06d3bb5d8ef007bbcd71ee157fd97cd69557383b Mon Sep 17 00:00:00 2001
From: George Huebner <george@feyor.sh>
Date: Sat, 20 Jul 2024 18:46:04 -0500
Subject: [PATCH] sage.cython: silence linker

(Nix+LLVM specific issue) "ld: warning: directory not found" causes
any cython doctest to fail and is annoying, so I told ld to shut up.
---
 src/sage/misc/cython.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/sage/misc/cython.py b/src/sage/misc/cython.py
index 545e1227b0..c5f4b69221 100644
--- a/src/sage/misc/cython.py
+++ b/src/sage/misc/cython.py
@@ -339,7 +339,7 @@ def cython(filename, verbose=0, compile_message=False,
     Cython.Compiler.Options.pre_import = "sage.all" if sage_namespace else None
 
     extra_compile_args = ['-w']  # no warnings
-    extra_link_args = []
+    extra_link_args = ['-w']
 
     ext = Extension(name,
                     sources=[pyxfile],
-- 
2.44.1
+3 −1
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
, coreutils
, gnused
, gnugrep
, gawk
, binutils
, pythonEnv
, python3
@@ -70,6 +71,7 @@ let
    coreutils
    gnused
    gnugrep
    gawk
    binutils.bintools
    pkg-config
    pari
@@ -186,7 +188,7 @@ writeTextFile rec {
    export SAGE_EXTCODE='${sagelib.src}/src/sage/ext_data'

  # for find_library
    export DYLD_LIBRARY_PATH="${lib.makeLibraryPath [stdenv.cc.libc singular giac]}''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH"
    export DYLD_LIBRARY_PATH="${lib.makeLibraryPath [stdenv.cc.libc singular giac gap]}''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH"
  '';
} // { # equivalent of `passthru`, which `writeTextFile` doesn't support
  lib = sagelib;
+18 −0
Original line number Diff line number Diff line
{ stdenv
, lib
, fetchFromGitHub
, fetchpatch
, fetchurl
@@ -40,6 +41,10 @@ stdenv.mkDerivation rec {
    # we can now set the cache dir to be within the .sage directory. This is
    # not strictly necessary, but keeps us from littering in the user's HOME.
    ./patches/sympow-cache.patch
  ] ++ lib.optionals (stdenv.cc.isClang) [
    # https://github.com/NixOS/nixpkgs/pull/264126
    # Dead links in python sysconfig cause LLVM linker warnings, leading to cython doctest failures.
    ./patches/silence-linker.patch
  ];

  # Since sage unfortunately does not release bugfix releases, packagers must
@@ -64,6 +69,13 @@ stdenv.mkDerivation rec {
    # compile libs/gap/element.pyx with -O1
    # a more conservative version of https://github.com/sagemath/sage/pull/37951
    ./patches/gap-element-crash.patch

    # https://github.com/sagemath/sage/pull/37886, landed in 10.4.beta7
    (fetchpatch {
      name = "remove-xcode.patch";
      url = "https://github.com/sagemath/sage/commit/8e72038b4ab24fb63c06b28f6eb43097b9ab24d6.patch";
      sha256 = "sha256-hufDJFUBa/Trn1xsVNvzb2c1wE9iyhqewj3RMjVtENA=";
    })
  ];

  # Patches needed because of package updates. We could just pin the versions of
@@ -73,6 +85,12 @@ stdenv.mkDerivation rec {
  # should come from or be proposed to upstream. This list will probably never
  # be empty since dependencies update all the time.
  packageUpgradePatches = [
    # https://github.com/sagemath/sage/pull/37646, landed in 10.4.beta1
    (fetchpatch {
      name = "cpp-17.patch";
      url = "https://github.com/sagemath/sage/commit/9b0a40d6cd17706db31d5ff8cdd78910409ba1c8.patch";
      sha256 = "sha256-2pJ9eH+o9O76Tsmklc/frzDOFkvPjvs2JQWCSqA+tMs=";
    })
    # https://github.com/sagemath/sage/pull/37763, landed in 10.4.beta2
    (fetchpatch {
      name = "scipy-fault-tolerance.patch";