Browse Source

fix compilation with nixpkgs 21.05

The environment variable is optional to keep compatibility with other build environments.

Closes #131
exception
parent
commit
2ba4d8935d
  1. 1
      default.nix
  2. 1
      shell.nix
  3. 5
      src/libc/build.rs
  4. 4
      src/libunwind/build.rs

1
default.nix

@ -31,6 +31,7 @@ let
];
buildPhase = ''
export XARGO_RUST_SRC="${rustPlatform.rust.rustc}/lib/rustlib/src/rust/library"
export CLANG_EXTRA_INCLUDE_DIR="${pkgs.llvmPackages_9.clang-unwrapped.lib}/lib/clang/9.0.1/include"
export CARGO_HOME=$(mktemp -d cargo-home.XXX)
make TARGET=${target} GWARGS="${if json == null then "-V ${variant}" else json}"
'';

1
shell.nix

@ -30,6 +30,7 @@ in
];
XARGO_RUST_SRC = "${rustPlatform.rust.rustc}/lib/rustlib/src/rust/library";
CLANG_EXTRA_INCLUDE_DIR = "${pkgs.llvmPackages_9.clang-unwrapped.lib}/lib/clang/9.0.1/include";
OPENOCD_ZYNQ = "${zynq-rs}/openocd";
SZL = "${zc706-szl}/szl.elf";
}

5
src/libc/build.rs

@ -5,6 +5,8 @@ fn main() {
mod libc {
use std::path::Path;
use std::env;
pub fn compile() {
let cfg = &mut cc::Build::new();
cfg.no_default_flags(true);
@ -16,6 +18,9 @@ mod libc {
cfg.flag("-ffreestanding");
cfg.flag("-fno-PIC");
cfg.flag("-isystem../include");
if let Ok(extra_include) = env::var("CLANG_EXTRA_INCLUDE_DIR") {
cfg.flag(&("-isystem".to_owned() + &extra_include));
}
cfg.flag("-fno-stack-protector");
cfg.flag("--target=armv7-none-eabihf");
cfg.flag("-O2");

4
src/libunwind/build.rs

@ -6,6 +6,7 @@ fn main() {
mod llvm_libunwind {
use std::path::Path;
use std::env;
fn setup_options(cfg: &mut cc::Build) {
cfg.no_default_flags(true);
@ -16,6 +17,9 @@ mod llvm_libunwind {
cfg.flag("-fno-PIC");
cfg.flag("-Isrc");
cfg.flag("-isystem../include");
if let Ok(extra_include) = env::var("CLANG_EXTRA_INCLUDE_DIR") {
cfg.flag(&("-isystem".to_owned() + &extra_include));
}
cfg.flag("-fno-stack-protector");
cfg.flag("--target=armv7-none-eabihf");
cfg.flag("-O2");

Loading…
Cancel
Save