Skip to content

Commit

Permalink
Merge pull request #150 from AeneasVerif/fix-rustc-tests
Browse files Browse the repository at this point in the history
Fix linking under nix on Mac (again)
  • Loading branch information
sonmarcho authored Apr 26, 2024
2 parents f07b385 + f0192c3 commit d780b40
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
25 changes: 23 additions & 2 deletions charon/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,30 @@ fn process(options: &CliOpts) -> Result<(), i32> {
let exit_status = if options.no_cargo {
// Run just the driver.
let mut cmd;
if cargo_path_override.is_some() {
trace!("We appear to have been built with nix; the driver should be correctly linked.");
if let Some(cargo_path) = cargo_path_override {
cmd = Command::new(driver_path);
if cfg!(target_os = "macos") {
let toolchain_path = PathBuf::from(cargo_path)
.parent()
.unwrap()
.parent()
.unwrap()
.to_owned();
// Inspired from what rustup does.
const MAC_LOADER_PATH: &str = "DYLD_FALLBACK_LIBRARY_PATH";
let mut path_components = if let Some(path) = env::var_os(MAC_LOADER_PATH) {
env::split_paths(&path).collect::<Vec<_>>()
} else {
vec![]
};
path_components.insert(0, toolchain_path.join("lib"));
let new_path = env::join_paths(path_components).unwrap();
cmd.env(MAC_LOADER_PATH, new_path);
} else {
trace!(
"We appear to have been built with nix; the driver should be correctly linked."
);
}
} else {
assert!(use_rustup); // Otherwise we panicked earlier.
trace!("Calling the driver via `rustup`");
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
grep -q "^// \?@\? \?$1:" "$2"
}
${pkgs.coreutils}/bin/timeout 5s ${charon}/bin/charon-driver rustc "$FILE" -- --no-serialize > "$FILE.charon-output" 2>&1
${pkgs.coreutils}/bin/timeout 5s ${charon}/bin/charon --no-cargo --input "$FILE" --no-serialize > "$FILE.charon-output" 2>&1
status=$?
if [ $status -eq 124 ]; then
result=timeout
Expand Down

0 comments on commit d780b40

Please sign in to comment.