1
0
Fork 0

fix compilation with nixpkgs 21.05

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

Closes #131
This commit is contained in:
Sebastien Bourdeauducq 2021-06-25 15:57:39 +08:00
parent 8c8a5d53b9
commit 2ba4d8935d
4 changed files with 11 additions and 0 deletions

View File

@ -31,6 +31,7 @@ let
]; ];
buildPhase = '' buildPhase = ''
export XARGO_RUST_SRC="${rustPlatform.rust.rustc}/lib/rustlib/src/rust/library" 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) export CARGO_HOME=$(mktemp -d cargo-home.XXX)
make TARGET=${target} GWARGS="${if json == null then "-V ${variant}" else json}" make TARGET=${target} GWARGS="${if json == null then "-V ${variant}" else json}"
''; '';

View File

@ -30,6 +30,7 @@ in
]; ];
XARGO_RUST_SRC = "${rustPlatform.rust.rustc}/lib/rustlib/src/rust/library"; 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"; OPENOCD_ZYNQ = "${zynq-rs}/openocd";
SZL = "${zc706-szl}/szl.elf"; SZL = "${zc706-szl}/szl.elf";
} }

View File

@ -5,6 +5,8 @@ fn main() {
mod libc { mod libc {
use std::path::Path; use std::path::Path;
use std::env;
pub fn compile() { pub fn compile() {
let cfg = &mut cc::Build::new(); let cfg = &mut cc::Build::new();
cfg.no_default_flags(true); cfg.no_default_flags(true);
@ -16,6 +18,9 @@ mod libc {
cfg.flag("-ffreestanding"); cfg.flag("-ffreestanding");
cfg.flag("-fno-PIC"); cfg.flag("-fno-PIC");
cfg.flag("-isystem../include"); 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("-fno-stack-protector");
cfg.flag("--target=armv7-none-eabihf"); cfg.flag("--target=armv7-none-eabihf");
cfg.flag("-O2"); cfg.flag("-O2");

View File

@ -6,6 +6,7 @@ fn main() {
mod llvm_libunwind { mod llvm_libunwind {
use std::path::Path; use std::path::Path;
use std::env;
fn setup_options(cfg: &mut cc::Build) { fn setup_options(cfg: &mut cc::Build) {
cfg.no_default_flags(true); cfg.no_default_flags(true);
@ -16,6 +17,9 @@ mod llvm_libunwind {
cfg.flag("-fno-PIC"); cfg.flag("-fno-PIC");
cfg.flag("-Isrc"); cfg.flag("-Isrc");
cfg.flag("-isystem../include"); 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("-fno-stack-protector");
cfg.flag("--target=armv7-none-eabihf"); cfg.flag("--target=armv7-none-eabihf");
cfg.flag("-O2"); cfg.flag("-O2");