tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
elan: fix for Lean >= 4.16.0
Sebastian Ullrich
1 year ago
f317e28d
95c18ad1
+26
-11
1 changed file
expand all
collapse all
unified
split
pkgs
by-name
el
elan
0001-dynamically-patchelf-binaries.patch
+26
-11
pkgs/by-name/el/elan/0001-dynamically-patchelf-binaries.patch
···
2
2
index c51e76d..ae8159e 100644
3
3
--- a/src/elan-dist/src/component/package.rs
4
4
+++ b/src/elan-dist/src/component/package.rs
5
5
-
@@ -56,6 +56,37 @@ fn unpack_without_first_dir<R: Read>(archive: &mut tar::Archive<R>, path: &Path)
5
5
+
@@ -56,6 +56,52 @@ fn unpack_without_first_dir<R: Read>(archive: &mut tar::Archive<R>, path: &Path)
6
6
entry
7
7
.unpack(&full_path)
8
8
.chain_err(|| ErrorKind::ExtractingPackage)?;
···
14
14
+
15
15
+fn nix_patch_if_needed(dest_path: &Path) -> Result<()> {
16
16
+ let is_bin = matches!(dest_path.parent(), Some(p) if p.ends_with("bin"));
17
17
-
+ if is_bin {
18
18
-
+ let _ = ::std::process::Command::new("@patchelf@/bin/patchelf")
19
19
-
+ .arg("--set-interpreter")
20
20
-
+ .arg("@dynamicLinker@")
21
21
-
+ .arg(dest_path)
22
22
-
+ .output();
23
23
-
+ }
17
17
+
+ if !is_bin { return Ok(()) }
18
18
+
+ let _ = ::std::process::Command::new("@patchelf@/bin/patchelf")
19
19
+
+ .arg("--set-interpreter")
20
20
+
+ .arg("@dynamicLinker@")
21
21
+
+ .arg(dest_path)
22
22
+
+ .output();
24
23
+
25
24
+ if dest_path.file_name() == Some(::std::ffi::OsStr::new("leanc")) {
26
25
+ use std::os::unix::fs::PermissionsExt;
···
32
31
+LEAN_CC="${LEAN_CC:-@cc@}" exec -a "$0" "$dir/leanc.orig" "$@" -L"$dir/../lib"
33
32
+"#)?;
34
33
+ ::std::fs::set_permissions(dest_path, ::std::fs::Permissions::from_mode(0o755))?;
35
35
-
+ }
34
34
+
+ } else if dest_path.file_name() == Some(::std::ffi::OsStr::new("lake")) {
35
35
+
+ // since Lean 4.16.0, `lake` calls `LEAN_CC` directly instead of through `leanc`
36
36
+
+ use std::os::unix::fs::PermissionsExt;
37
37
+
+ ::std::fs::write(dest_path.with_file_name("cc"), r#"#! @shell@
38
38
+
+dir="$(dirname "${BASH_SOURCE[0]}")"
39
39
+
+# use bundled libraries, but not bundled compiler that doesn't know about NIX_LDFLAGS
40
40
+
+exec "@cc@" "$@" -L"$dir/../lib"
41
41
+
+"#)?;
42
42
+
+ ::std::fs::set_permissions(dest_path.with_file_name("cc"), ::std::fs::Permissions::from_mode(0o755))?;
36
43
+
37
37
-
+ if dest_path.file_name() == Some(::std::ffi::OsStr::new("llvm-ar")) {
44
44
+
+ let new_path = dest_path.with_extension("orig");
45
45
+
+ ::std::fs::rename(dest_path, &new_path)?;
46
46
+
+ ::std::fs::write(dest_path, r#"#! @shell@
47
47
+
+dir="$(dirname "${BASH_SOURCE[0]}")"
48
48
+
+# use custom `cc`
49
49
+
+LEAN_CC="${LEAN_CC:-"$dir/cc"}" exec -a "$0" "$dir/lake.orig" "$@"
50
50
+
+"#)?;
51
51
+
+ ::std::fs::set_permissions(dest_path, ::std::fs::Permissions::from_mode(0o755))?;
52
52
+
+ } else if dest_path.file_name() == Some(::std::ffi::OsStr::new("llvm-ar")) {
38
53
+ ::std::fs::remove_file(dest_path)?;
39
54
+ ::std::os::unix::fs::symlink("@ar@", dest_path)?;
40
55
}
41
41
-
56
56
+
42
57
Ok(())