Add —sysroot to CFLAGS for build.rs files to consume
build.rs used to work without this, but perhaps recent changes to the way
sysroots are constructed have broken it.
Change-Id: I814b3101eca1ef4d4b798dd1c1841c8a6b6b2505
diff --git a/src/lib.rs b/src/lib.rs
index 24320e9..c28d4b8 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -314,13 +314,15 @@
let pkg_path = pkg_config_path(target_options)?;
let mut cmd = Command::new(cargo_path(target_options)?);
+ let sysroot_as_path = sysroot_path(target_options)?;
+ let sysroot_as_str = sysroot_as_path.to_str().unwrap();
cmd.env("CARGO_TARGET_X86_64_UNKNOWN_FUCHSIA_RUNNER", fargo_command)
.env(
"CARGO_TARGET_X86_64_UNKNOWN_FUCHSIA_RUSTFLAGS",
format!(
"-C link-arg=--target=x86_64-unknown-fuchsia -C link-arg=--sysroot={} -Lnative={}",
- sysroot_path(target_options)?.to_str().unwrap(),
+ sysroot_as_str,
shared_libraries_path(target_options)?.to_str().unwrap(),
),
)
@@ -340,6 +342,10 @@
"CXX",
clang_cpp_compiler_path(target_options)?.to_str().unwrap(),
)
+ .env(
+ "CFLAGS",
+ format!("--sysroot={}", sysroot_as_str),
+ )
.env("AR", clang_archiver_path(target_options)?.to_str().unwrap())
.env(
"RANLIB",