diff --git a/pkgs/applications/science/logic/elan/0001-dynamically-patchelf-binaries.patch b/pkgs/applications/science/logic/elan/0001-dynamically-patchelf-binaries.patch index dc76305bd749..768be10b6df3 100644 --- a/pkgs/applications/science/logic/elan/0001-dynamically-patchelf-binaries.patch +++ b/pkgs/applications/science/logic/elan/0001-dynamically-patchelf-binaries.patch @@ -22,13 +22,13 @@ index c51e76d..ae8159e 100644 + .output(); + } + -+ if dest_path.extension() == Some(::std::ffi::OsStr::new("lld")) { ++ if dest_path.file_name() == Some(::std::ffi::OsStr::new("leanc")) { + use std::os::unix::fs::PermissionsExt; + let new_path = dest_path.with_extension("orig"); + ::std::fs::rename(dest_path, &new_path)?; + ::std::fs::write(dest_path, format!(r#"#! @shell@ -+exec -a "$0" {} "$@" --dynamic-linker=@dynamicLinker@ -+"#, new_path.to_str().unwrap()))?; ++LEAN_CC="${{LEAN_CC:-@cc@}}" exec -a "$0" {} "$@" -L {}/lib # use bundled libraries, but not bundled compiler that doesn't know about NIX_LDFLAGS ++"#, new_path.to_str().unwrap(), dest_path.parent().unwrap().parent().unwrap().to_str().unwrap()))?; + ::std::fs::set_permissions(dest_path, ::std::fs::Permissions::from_mode(0o755))?; } diff --git a/pkgs/applications/science/logic/elan/default.nix b/pkgs/applications/science/logic/elan/default.nix index 4326c5b0d6b9..89331f53686a 100644 --- a/pkgs/applications/science/logic/elan/default.nix +++ b/pkgs/applications/science/logic/elan/default.nix @@ -24,9 +24,10 @@ rustPlatform.buildRustPackage rec { patches = lib.optionals stdenv.isLinux [ # Run patchelf on the downloaded binaries. - # This necessary because Lean 4 now dynamically links to GMP. + # This is necessary because Lean 4 is now dynamically linked. (runCommand "0001-dynamically-patchelf-binaries.patch" { CC = stdenv.cc; + cc = "${stdenv.cc}/bin/cc"; patchelf = patchelf; shell = runtimeShell; } '' @@ -34,6 +35,7 @@ rustPlatform.buildRustPackage rec { substitute ${./0001-dynamically-patchelf-binaries.patch} $out \ --subst-var patchelf \ --subst-var dynamicLinker \ + --subst-var cc \ --subst-var shell '') ];