Merge pull request #151328 from Kha/elan-lean-cc

elan: set LEAN_CC to stdenv cc
This commit is contained in:
Gabriel Ebner 2021-12-19 17:39:28 +01:00 committed by GitHub
commit a3bbbe08bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View file

@ -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))?;
}

View file

@ -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
'')
];