rust: add support for armv6l-linux and armv7l-linux (#73472)
rust: add support for armv6l-linux and armv7l-linux
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
{ lib, stdenv, echo_build_heading, noisily, makeDeps }:
|
||||
{ lib, stdenv, echo_build_heading, noisily, makeDeps, rust }:
|
||||
{ crateName,
|
||||
dependencies,
|
||||
crateFeatures, crateRenames, libName, release, libPath,
|
||||
@@ -13,17 +13,6 @@
|
||||
(if release then "-C opt-level=3" else "-C debuginfo=2")
|
||||
(["-C codegen-units=$NIX_BUILD_CORES"] ++ extraRustcOpts);
|
||||
rustcMeta = "-C metadata=${metadata} -C extra-filename=-${metadata}";
|
||||
|
||||
# Some platforms have different names for rustc.
|
||||
rustPlatform =
|
||||
with stdenv.hostPlatform.parsed;
|
||||
let cpu_ = if cpu.name == "armv7a" then "armv7"
|
||||
else cpu.name;
|
||||
vendor_ = vendor.name;
|
||||
kernel_ = kernel.name;
|
||||
abi_ = abi.name;
|
||||
in
|
||||
"${cpu_}-${vendor_}-${kernel_}-${abi_}";
|
||||
in ''
|
||||
runHook preBuild
|
||||
norm=""
|
||||
@@ -67,7 +56,7 @@
|
||||
${crateFeatures} --out-dir target/bin --emit=dep-info,link -L dependency=target/deps \
|
||||
$LINK ${deps}$EXTRA_LIB --cap-lints allow \
|
||||
$BUILD_OUT_DIR $EXTRA_BUILD $EXTRA_FEATURES --color ${colors} \
|
||||
${if stdenv.hostPlatform != stdenv.buildPlatform then "--target ${rustPlatform} -C linker=${stdenv.hostPlatform.config}-gcc" else ""}
|
||||
${if stdenv.hostPlatform != stdenv.buildPlatform then "--target ${rust.toRustTarget stdenv.hostPlatform} -C linker=${stdenv.hostPlatform.config}-gcc" else ""}
|
||||
if [ "$crate_name_" != "$crate_name" ]; then
|
||||
mv target/bin/$crate_name_ target/bin/$crate_name
|
||||
fi
|
||||
|
||||
@@ -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, defaultCrateOverrides, fetchCrate, rustc, rust }:
|
||||
|
||||
let
|
||||
# This doesn't appear to be officially documented anywhere yet.
|
||||
@@ -59,7 +59,7 @@ let
|
||||
'';
|
||||
|
||||
configureCrate = import ./configure-crate.nix { inherit lib stdenv echo_build_heading noisily makeDeps; };
|
||||
buildCrate = import ./build-crate.nix { inherit lib stdenv echo_build_heading noisily makeDeps; };
|
||||
buildCrate = import ./build-crate.nix { inherit lib stdenv echo_build_heading noisily makeDeps rust; };
|
||||
installCrate = import ./install-crate.nix;
|
||||
|
||||
in
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{ stdenv, cacert, git, cargo, rustc, fetchcargo, buildPackages, windows }:
|
||||
{ stdenv, cacert, git, rust, cargo, rustc, fetchcargo, buildPackages, windows }:
|
||||
|
||||
{ name ? "${args.pname}-${args.version}"
|
||||
, cargoSha256 ? "unset"
|
||||
@@ -46,12 +46,7 @@ let
|
||||
cargoDepsCopy="$sourceRoot/${cargoVendorDir}"
|
||||
'';
|
||||
|
||||
hostConfig = stdenv.hostPlatform.config;
|
||||
|
||||
rustHostConfig = {
|
||||
x86_64-pc-mingw32 = "x86_64-pc-windows-gnu";
|
||||
}.${hostConfig} or hostConfig;
|
||||
rustTarget = if target == null then rustHostConfig else target;
|
||||
rustTarget = if target == null then rust.toRustTarget stdenv.hostPlatform else target;
|
||||
|
||||
ccForBuild="${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}cc";
|
||||
cxxForBuild="${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}c++";
|
||||
@@ -87,7 +82,7 @@ stdenv.mkDerivation (args // {
|
||||
--subst-var-by vendor "$(pwd)/$cargoDepsCopy"
|
||||
|
||||
cat >> .cargo/config <<'EOF'
|
||||
[target."${stdenv.buildPlatform.config}"]
|
||||
[target."${rust.toRustTarget stdenv.buildPlatform}"]
|
||||
"linker" = "${ccForBuild}"
|
||||
${stdenv.lib.optionalString (stdenv.buildPlatform.config != stdenv.hostPlatform.config) ''
|
||||
[target."${rustTarget}"]
|
||||
@@ -129,10 +124,10 @@ stdenv.mkDerivation (args // {
|
||||
(
|
||||
set -x
|
||||
env \
|
||||
"CC_${stdenv.buildPlatform.config}"="${ccForBuild}" \
|
||||
"CXX_${stdenv.buildPlatform.config}"="${cxxForBuild}" \
|
||||
"CC_${stdenv.hostPlatform.config}"="${ccForHost}" \
|
||||
"CXX_${stdenv.hostPlatform.config}"="${cxxForHost}" \
|
||||
"CC_${rust.toRustTarget stdenv.buildPlatform}"="${ccForBuild}" \
|
||||
"CXX_${rust.toRustTarget stdenv.buildPlatform}"="${cxxForBuild}" \
|
||||
"CC_${rust.toRustTarget stdenv.hostPlatform}"="${ccForHost}" \
|
||||
"CXX_${rust.toRustTarget stdenv.hostPlatform}"="${cxxForHost}" \
|
||||
cargo build \
|
||||
${stdenv.lib.optionalString (buildType == "release") "--release"} \
|
||||
--target ${rustTarget} \
|
||||
|
||||
Reference in New Issue
Block a user