Skip to content

Instantly share code, notes, and snippets.

@aaronjanse
Created July 20, 2020 23:21
Show Gist options
  • Save aaronjanse/18dcfeebe895f86622cee294a4d73f42 to your computer and use it in GitHub Desktop.
Save aaronjanse/18dcfeebe895f86622cee294a4d73f42 to your computer and use it in GitHub Desktop.
Broken `relibc`, compiled using Nix
{ stdenv, buildPackages, fetchurl, lib , makeRustPlatform }:
let
rpath = lib.makeLibraryPath [
buildPackages.stdenv.cc.libc
"$out"
];
bootstrapCrossRust = stdenv.mkDerivation {
name = "binary-redox-rust";
src = fetchTarball {
name = "rust-install.tar.gz";
url = "https://gateway.pinata.cloud/ipfs/QmNp6fPTjPA6LnCYvW1UmbAHcPpU7tqZhstfSpSXMJCRwp";
sha256 = "0p1bxffbbl1bp8glwg2iqb18zjx678kyn91afjr5czlmcrrp3ybw";
};
dontBuild = true;
dontPatchELF = true;
dontStrip = true;
installPhase = ''
mkdir $out/
cp -r * $out/
find $out/ -executable -type f -exec patchelf \
--set-interpreter "${buildPackages.stdenv.cc.libc}/lib/ld-linux-x86-64.so.2" \
--set-rpath "${rpath}" \
"{}" \;
find $out/ -name "*.so" -type f -exec patchelf \
--set-rpath "${rpath}" \
"{}" \;
'';
meta.platforms = with stdenv.lib; platforms.redox ++ platforms.linux;
};
redoxRustPlatform = buildPackages.makeRustPlatform {
rustc = bootstrapCrossRust;
cargo = bootstrapCrossRust;
};
in
redoxRustPlatform.buildRustPackage rec {
pname = "relibc";
version = "0.1.0";
src = buildPackages.fetchgit {
url = "https://gitlab.redox-os.org/redox-os/relibc/";
rev = "db6a5894216a84528e02ce3c2faa3415fdf8c6a4";
sha256 = "03lns01gg53j96d0yc522q68avalp66jh8r18v05yrrlq34mlicy";
fetchSubmodules = true;
};
RUSTC_BOOTSTRAP = 1;
dontInstall = true;
dontFixup = true;
doCheck = false;
buildPhase = ''
make
mkdir $out
DESTDIR=$out make install
'';
cargoSha256 = "1kdh0zmbap59a3w352r55r4f3c62mp0hrpwk04amshp9m5mr8h85";
cargoPatches = [
./fix-Cargo.lock.patch
];
meta = with stdenv.lib; {
homepage = "https://gitlab.redox-os.org/redox-os/relibc";
description = "C Library in Rust for Redox and Linux";
license = licenses.mit;
maintainers = [ maintainers.aaronjanse ];
platforms = platforms.redox ++ platforms.linux;
};
}
diff --git a/Cargo.lock b/Cargo.lock
index 6b4064e..8efc0d5 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -294,14 +294,6 @@ dependencies = [
"rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
-[[package]]
-name = "redox_syscall"
-version = "0.1.56"
-source = "git+https://gitlab.redox-os.org/redox-os/syscall?rev=0e1e7d5d#0e1e7d5d36f8c6f045e30c37515d366350eb2122"
-dependencies = [
- "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
[[package]]
name = "redox_syscall"
version = "0.1.56"
@@ -322,7 +314,7 @@ dependencies = [
"posix-regex 0.1.0",
"ralloc 1.0.0",
"rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "redox_syscall 0.1.56 (git+https://gitlab.redox-os.org/redox-os/syscall?rev=0e1e7d5d)",
+ "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",
"sc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"spin 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -567,7 +559,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
"checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
"checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
-"checksum redox_syscall 0.1.56 (git+https://gitlab.redox-os.org/redox-os/syscall?rev=0e1e7d5d)" = "<none>"
"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
"checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e"
"checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084"
diff --git a/Cargo.toml b/Cargo.toml
index 72ffe06..2fbe691 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -39,7 +39,7 @@ optional = true
sc = "0.2.2"
[target.'cfg(target_os = "redox")'.dependencies]
-redox_syscall = { git = "https://gitlab.redox-os.org/redox-os/syscall", rev = "0e1e7d5d" }
+redox_syscall = "0.1.56"
spin = "0.4.10"
[features]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment