mirror of
https://github.com/SebastianWendel/nixpkgs.git
synced 2024-09-20 04:19:00 +02:00
rust: patched the source to hardcode gcc path
to avoid using a wrapper.
This commit is contained in:
parent
35aa131371
commit
6eed023894
|
@ -1,5 +1,19 @@
|
||||||
{stdenv, fetchurl, which, file, perl, curl, python27, makeWrapper}:
|
{stdenv, fetchurl, which, file, perl, curl, python27, makeWrapper}:
|
||||||
|
|
||||||
|
/* Rust's build process has a few quirks :
|
||||||
|
|
||||||
|
- It requires some patched in llvm that haven't landed upstream, so it
|
||||||
|
compiles its own llvm. This might change in the future, so at some
|
||||||
|
point we may be able to switch to nix's llvm.
|
||||||
|
|
||||||
|
- The Rust compiler is written is Rust, so it requires a bootstrap
|
||||||
|
compiler, which is downloaded during the build. To make the build
|
||||||
|
pure, we download it ourself before and put it where it is
|
||||||
|
expected. Once the language is stable (1.0) , we might want to
|
||||||
|
switch it to use nix's packaged rust compiler.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
with if stdenv.system == "i686-linux" then {
|
with if stdenv.system == "i686-linux" then {
|
||||||
platform = "linux-i386";
|
platform = "linux-i386";
|
||||||
snapshot = "03e60be1f1b90dddd15f3597bc45ec8d9626b35d";
|
snapshot = "03e60be1f1b90dddd15f3597bc45ec8d9626b35d";
|
||||||
|
@ -38,6 +52,14 @@ stdenv.mkDerivation {
|
||||||
ln -s $snapshot $sourceRoot/dl/${snapshotName}
|
ln -s $snapshot $sourceRoot/dl/${snapshotName}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
# The compiler requires cc, so we patch the source to tell it where to find it
|
||||||
|
patches = [ ./hardcode_paths.patch ];
|
||||||
|
postPatch = ''
|
||||||
|
substituteInPlace src/librustc/back/link.rs \
|
||||||
|
--subst-var-by "gccPath" ${stdenv.gcc}/bin/cc \
|
||||||
|
--subst-var-by "binutilsPath" ${stdenv.gcc.binutils}/bin/ar
|
||||||
|
'';
|
||||||
|
|
||||||
# Modify the snapshot compiler so that is can be executed
|
# Modify the snapshot compiler so that is can be executed
|
||||||
preBuild = if stdenv.isLinux then ''
|
preBuild = if stdenv.isLinux then ''
|
||||||
make ${target}/stage0/bin/rustc
|
make ${target}/stage0/bin/rustc
|
||||||
|
@ -46,13 +68,6 @@ stdenv.mkDerivation {
|
||||||
${target}/stage0/bin/rustc
|
${target}/stage0/bin/rustc
|
||||||
'' else null;
|
'' else null;
|
||||||
|
|
||||||
# rustc requires cc
|
|
||||||
postInstall = ''
|
|
||||||
for f in $out/bin/*; do
|
|
||||||
wrapProgram $f --prefix PATH : "${stdenv.gcc}/bin"
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
|
|
||||||
buildInputs = [ which file perl curl python27 makeWrapper ];
|
buildInputs = [ which file perl curl python27 makeWrapper ];
|
||||||
enableParallelBuilding = true;
|
enableParallelBuilding = true;
|
||||||
|
|
||||||
|
|
44
pkgs/development/compilers/rust/hardcode_paths.patch
Normal file
44
pkgs/development/compilers/rust/hardcode_paths.patch
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs
|
||||||
|
index 101b2e3..124267f 100644
|
||||||
|
--- a/src/librustc/back/link.rs
|
||||||
|
+++ b/src/librustc/back/link.rs
|
||||||
|
@@ -728,7 +728,7 @@ pub fn get_cc_prog(sess: Session) -> ~str {
|
||||||
|
_ => {},
|
||||||
|
}
|
||||||
|
|
||||||
|
- get_system_tool(sess, "cc")
|
||||||
|
+ ~"@gccPath@"
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_ar_prog(sess: Session) -> ~str {
|
||||||
|
@@ -737,27 +737,9 @@ pub fn get_ar_prog(sess: Session) -> ~str {
|
||||||
|
None => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
- get_system_tool(sess, "ar")
|
||||||
|
+ ~"@binutilsPath@"
|
||||||
|
}
|
||||||
|
|
||||||
|
-fn get_system_tool(sess: Session, tool: &str) -> ~str {
|
||||||
|
- match sess.targ_cfg.os {
|
||||||
|
- abi::OsAndroid => match sess.opts.android_cross_path {
|
||||||
|
- Some(ref path) => {
|
||||||
|
- let tool_str = match tool {
|
||||||
|
- "cc" => "gcc",
|
||||||
|
- _ => tool
|
||||||
|
- };
|
||||||
|
- format!("{}/bin/arm-linux-androideabi-{}", *path, tool_str)
|
||||||
|
- }
|
||||||
|
- None => {
|
||||||
|
- sess.fatal(format!("need Android NDK path for the '{}' tool \
|
||||||
|
- (--android-cross-path)", tool))
|
||||||
|
- }
|
||||||
|
- },
|
||||||
|
- _ => tool.to_owned(),
|
||||||
|
- }
|
||||||
|
-}
|
||||||
|
|
||||||
|
/// Perform the linkage portion of the compilation phase. This will generate all
|
||||||
|
/// of the requested outputs for this compilation session.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue