New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rust build-support: fixing a compilation error in some crates #50452
Conversation
What's the motivation for |
This is the definition of
And the
So I think the addition is warranted. We might as well go for the full list of them as it can be found in the cargo search at Should we also add test cases so that we can ensure we are properly compiling something that actually depends on those? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the inline comments and #50452 (comment).
@@ -71,6 +71,8 @@ in '' | |||
export CARGO_PKG_VERSION_MAJOR=${builtins.elemAt version 0} | |||
export CARGO_PKG_VERSION_MINOR=${builtins.elemAt version 1} | |||
export CARGO_PKG_VERSION_PATCH=${builtins.elemAt version 2} | |||
export NUM_JOBS=1 | |||
export RUSTC="rustc" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we set this to the absolute path maybe? I am not sure what the exactly expectation is in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it matters, as I believe this is meant to be argv[0]
when rustc
is called, and since we call rustc
directly everywhere else, I believe this is what is expected in most build scripts.
Since we have rustc
in the builtInputs
, rustc
is in the path, I think we're fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember rustc
to do a realpath on /proc/self/exe at some point, when trying to cheat with our rustup patch.
@@ -71,6 +71,8 @@ in '' | |||
export CARGO_PKG_VERSION_MAJOR=${builtins.elemAt version 0} | |||
export CARGO_PKG_VERSION_MINOR=${builtins.elemAt version 1} | |||
export CARGO_PKG_VERSION_PATCH=${builtins.elemAt version 2} | |||
export NUM_JOBS=1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the docs this should not be required in the future. Does this imply that newer code will just ignore it an use the proper jobserver implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know, it's still in the docs. I was just trying to include as many environment variables from the docs as possible.
Rustc is already called with |
FWIW I'm not against it and don't know much about rust building,
so don't really have an opinion either way :).
Just noticed and was curious (and to confirm / be clear about such a
reason, whatever it may be).
…On Fri, 16 Nov 2018 09:02:53 -0800, Pierre-Etienne Meunier ***@***.***> wrote:
P-E-Meunier commented on this pull request.
> @@ -71,6 +71,8 @@ in ''
export CARGO_PKG_VERSION_MAJOR=${builtins.elemAt version 0}
export CARGO_PKG_VERSION_MINOR=${builtins.elemAt version 1}
export CARGO_PKG_VERSION_PATCH=${builtins.elemAt version 2}
+ export NUM_JOBS=1
I don't know, it's still in the docs. I was just trying to include as many environment variables from the docs as possible.
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#50452 (comment) part: text/html
|
Right.
I don't know how to add test cases in Nix, but I'd be happy to learn. |
I just ran into this failure myself when using diff --git a/pkgs/build-support/rust/build-rust-crate/configure-crate.nix b/pkgs/build-support/rust/build-rust-crate/configure-crate.nix
index 37fef2abd77..0be77fb4c0a 100644
--- a/pkgs/build-support/rust/build-rust-crate/configure-crate.nix
+++ b/pkgs/build-support/rust/build-rust-crate/configure-crate.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, echo_build_heading, noisily, makeDeps }:
+{ lib, stdenv, which, echo_build_heading, noisily, makeDeps }:
{ build, buildDependencies, colors, completeBuildDeps, completeDeps, crateAuthors, crateFeatures, crateName, crateVersion, extraLinkFlags, libName, libPath, release, target_os, verbose, workspace_member }:
let version_ = lib.splitString "-" crateVersion;
versionPre = if lib.tail version_ == [] then "" else builtins.elemAt version_ 1;
@@ -61,6 +61,8 @@ in ''
export CARGO_CFG_TARGET_POINTER_WIDTH=${toString stdenv.hostPlatform.parsed.cpu.bits}
export CARGO_CFG_TARGET_VENDOR=${stdenv.hostPlatform.parsed.vendor.name}
+ export RUSTC=$(${which}/bin/which rustc)
+ export RUSTDOC=$(${which}/bin/which rustdoc)
export CARGO_MANIFEST_DIR="."
export DEBUG="${toString (!release)}"
export OPT_LEVEL="${toString optLevel}"
diff --git a/pkgs/build-support/rust/build-rust-crate/default.nix b/pkgs/build-support/rust/build-rust-crate/default.nix
index ec11472bbae..ac790b0b62f 100644
--- a/pkgs/build-support/rust/build-rust-crate/default.nix
+++ b/pkgs/build-support/rust/build-rust-crate/default.nix
@@ -4,7 +4,7 @@
# This can be useful for deploying packages with NixOps, and to share
# binary dependencies between projects.
-{ lib, stdenv, defaultCrateOverrides, fetchCrate, rustc }:
+{ lib, stdenv, which, defaultCrateOverrides, fetchCrate, rustc }:
let
# This doesn't appear to be officially documented anywhere yet.
@@ -53,7 +53,7 @@ let
}
'';
- configureCrate = import ./configure-crate.nix { inherit lib stdenv echo_build_heading noisily makeDeps; };
+ configureCrate = import ./configure-crate.nix { inherit lib stdenv which echo_build_heading noisily makeDeps; };
buildCrate = import ./build-crate.nix { inherit lib stdenv echo_build_heading noisily makeDeps; };
installCrate = import ./install-crate.nix; i.e. I set the absolute path. I think not setting the absolute path is also just fine. In general a test case would be nice, though, but I don't think we should hold this up for that? |
@P-E-Meunier The tests are currently in Other then that we can go ahead and merge it. |
Looks like a compilation error in some crates might include |
Shouldn't this also set |
I'm currently tweaking this to try and compile Rust to WASM. This would be very cool, but doesn't work yet. When called with Cargo, Rustc generates perfect WASM. When called with Nix, Rustc does generate WASM, but it is not usable. |
This patch-set as of yesterday works nicely, and I've used this patch set
in ofborg. We should probably merge it, and do wasm dev in a different
patch set?
…On Sat, Dec 1, 2018 at 6:18 AM Pierre-Etienne Meunier < ***@***.***> wrote:
I'm currently tweaking this to try and compile Rust to WASM. This would be
very cool, but doesn't work yet. When called with Cargo, Rustc generates
perfect WASM. When called with Nix, Rustc does generate WASM, but it is not
usable.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#50452 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAErrJs8d5so8hx6WTxxl7Mo7pzbaWLLks5u0mV7gaJpZM4YmJeS>
.
|
I think this patch should work nicely and honestly I'm willing to go ahead with this, without a test, since it's been waiting for a little bit. I think |
No problem! Since I've used this commit to deploy stuff in production, I sort of messed up my branches locally to make this feasible, and merging would spare me a morning of rebasing, so yes please! |
See NixOS#50452 (comment) Signed-off-by: Austin Seipp <aseipp@pobox.com>
See #50452 (comment) Signed-off-by: Austin Seipp <aseipp@pobox.com>
Bofore this change, NUM_JOBS was set to 1. Some crates for building C/C++ code (e.g. the cc and cmake crates), rely on this variable to set the number of jobs. As a consequence, we were compiling embedded libraries serially. Change this to NIX_BUILD_CORES to permit parallel builds. Prior discussion: NixOS#50452 (comment)
BuildRustCrate fails on some crates (such as proc-macro2), because some environment variables were not set. This fixes it.
Additionally, an error message related to the install script is fixed.
Motivation for this change
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)