Add example for cross compilation env

wip/nixpkgs-raku
oxalica 3 years ago
parent 3fbf30fe20
commit 0bb9ef6d8b
No known key found for this signature in database
GPG Key ID: CED392DE0C483D00
  1. 1
      README.md
  2. 3
      examples/cross-aarch64/.cargo/config
  3. 98
      examples/cross-aarch64/Cargo.lock
  4. 7
      examples/cross-aarch64/Cargo.toml
  5. 9
      examples/cross-aarch64/Makefile
  6. 18
      examples/cross-aarch64/shell.nix
  7. 7
      examples/cross-aarch64/src/main.rs

@ -182,6 +182,7 @@ Some examples (assume `nixpkgs` had the overlay applied):
};
}
```
- See more examples in directory `examples`.
For more details, see also the source code of `./rust-overlay.nix`.

@ -0,0 +1,3 @@
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-unknown-linux-gnu-gcc"
runner = "qemu-aarch64"

@ -0,0 +1,98 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "autocfg"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]]
name = "bitflags"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
name = "cc"
version = "1.0.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "cross-aarch64"
version = "0.1.0"
dependencies = [
"openssl",
]
[[package]]
name = "foreign-types"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
dependencies = [
"foreign-types-shared",
]
[[package]]
name = "foreign-types-shared"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.85"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ccac4b00700875e6a07c6cde370d44d32fa01c5a65cdd2fca6858c479d28bb3"
[[package]]
name = "openssl"
version = "0.10.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "038d43985d1ddca7a9900630d8cd031b56e4794eecc2e9ea39dd17aa04399a70"
dependencies = [
"bitflags",
"cfg-if",
"foreign-types",
"lazy_static",
"libc",
"openssl-sys",
]
[[package]]
name = "openssl-sys"
version = "0.9.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "921fc71883267538946025deffb622905ecad223c28efbfdef9bb59a0175f3e6"
dependencies = [
"autocfg",
"cc",
"libc",
"pkg-config",
"vcpkg",
]
[[package]]
name = "pkg-config"
version = "0.3.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c"
[[package]]
name = "vcpkg"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb"

@ -0,0 +1,7 @@
[package]
name = "cross-aarch64"
version = "0.1.0"
edition = "2018"
[dependencies]
openssl = "0.10.32"

@ -0,0 +1,9 @@
.PHONY: all test
test: all
nix-shell ./shell.nix --command \
"cargo test --target aarch64-unknown-linux-gnu"
all: Cargo.toml Cargo.lock src/main.rs
nix-shell ./shell.nix --command \
"cargo test --target aarch64-unknown-linux-gnu --no-run"

@ -0,0 +1,18 @@
with import <nixpkgs> {
crossSystem = "aarch64-linux";
overlays = [ (import ../..) ];
};
mkShell {
nativeBuildInputs = [
# Manual `buildPackages` is required here. See: https://github.com/NixOS/nixpkgs/issues/49526
# build = host = x86_64, target = aarch64
buildPackages.rust-bin.stable.latest.rust
buildPackages.pkg-config
# build = host = target = x86_64, just to avoid re-build.
pkgsBuildBuild.qemu
];
buildInputs = [
# build = x86_64, host = target = aarch64
openssl
];
}

@ -0,0 +1,7 @@
#[test]
fn test_openssl_version() {
openssl::init();
assert!(openssl::version::version().starts_with("OpenSSL "));
}
fn main() {}
Loading…
Cancel
Save