make it all work
This commit is contained in:
parent
4eaf069485
commit
98e1f635c8
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
hello*
|
||||
tmp
|
||||
|
|
|
@ -3,17 +3,14 @@
|
|||
lib,
|
||||
makeWrapper,
|
||||
scdoc,
|
||||
substituteAll,
|
||||
qbe,
|
||||
harec,
|
||||
binutils-unwrapped,
|
||||
tzdata,
|
||||
python3,
|
||||
writeScript,
|
||||
rustc,
|
||||
}:
|
||||
let
|
||||
platform = lib.toLower stdenv.hostPlatform.uname.system;
|
||||
arch = stdenv.hostPlatform.uname.processor;
|
||||
qbePlatform = {
|
||||
x86_64 = "amd64_apple";
|
||||
|
@ -21,7 +18,7 @@ let
|
|||
}.${arch};
|
||||
hareAs = ./hare-as.py;
|
||||
hareLd = stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "rust-ld";
|
||||
pname = "hare-ld";
|
||||
version = "1.0";
|
||||
src = [ ./ld.rs ];
|
||||
buildInputs = [ rustc ];
|
||||
|
@ -31,11 +28,33 @@ let
|
|||
done
|
||||
'';
|
||||
buildPhase = ''
|
||||
rustc -o rust-ld.bin $src
|
||||
rustc -o hare-ld.bin ld.rs
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp rust-ld.bin $out/bin/rust-ld
|
||||
cp hare-ld.bin $out/bin/hare-ld
|
||||
'';
|
||||
});
|
||||
hareCc = stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "hare-cc";
|
||||
version = "1.0";
|
||||
src = [ ./ld.rs ];
|
||||
buildInputs = [ rustc ];
|
||||
unpackPhase = ''
|
||||
for srcFile in $src; do
|
||||
cp $srcFile $(stripHash $srcFile)
|
||||
done
|
||||
'';
|
||||
buildPhase = ''
|
||||
sed -i \
|
||||
-e 's/"ld"/"cc"/g' \
|
||||
-e '11 a let mut args = vec![];' \
|
||||
ld.rs
|
||||
rustc -o hare-cc.bin ld.rs
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp hare-cc.bin $out/bin/hare-cc
|
||||
'';
|
||||
});
|
||||
in
|
||||
|
@ -72,9 +91,9 @@ stdenv.mkDerivation (finalAttrs: {
|
|||
"ARCH=${arch}"
|
||||
"VERSION=${finalAttrs.version}-nixpkgs"
|
||||
"QBEFLAGS=-t${qbePlatform}"
|
||||
"CC=${stdenv.cc.targetPrefix}cc"
|
||||
"CC=${hareCc}/bin/hare-cc"
|
||||
"AS=${hareAs}"
|
||||
"LD=${hareLd}/bin/rust-ld"
|
||||
"LD=${hareLd}/bin/hare-ld"
|
||||
# Strip the variable of an empty $(SRCDIR)/hare/third-party, since nix does
|
||||
# not follow the FHS.
|
||||
"HAREPATH=$(SRCDIR)/hare/stdlib"
|
||||
|
@ -90,8 +109,9 @@ stdenv.mkDerivation (finalAttrs: {
|
|||
postFixup = ''
|
||||
wrapProgram $out/bin/hare \
|
||||
--prefix PATH : ${lib.makeBinPath [harec qbe]} \
|
||||
--set LD ${hareLd}/bin/rust-ld \
|
||||
--set AS ${hareAs}
|
||||
--set CC ${hareCc}/bin/hare-cc \
|
||||
--set AS ${hareAs} \
|
||||
--set LD ${hareLd}/bin/hare-ld
|
||||
'';
|
||||
|
||||
setupHook = ./setup-hook.sh;
|
||||
|
|
|
@ -19,6 +19,7 @@ fn main() {
|
|||
_ = argv.remove(0);
|
||||
}
|
||||
"--gc-sections" => {}
|
||||
"-Wl,--gc-sections" | "-Wl,--no-gc-sections" => {}
|
||||
_ if arg.starts_with("-T") => {}
|
||||
_ if arg.starts_with("-z") => {}
|
||||
_ if arg.starts_with("--script=") => {}
|
||||
|
|
Loading…
Reference in a new issue