Skip to content

Commit

Permalink
unwind: make build.rs do clean rebuilds
Browse files Browse the repository at this point in the history
If the build by this was interrupted or otherwise left incomplete, there
could be object files hanging around, which triggers an assertion later.
Since we unconditionally rebuild everything here anyway, start with a
clean slate each build.
  • Loading branch information
gburgessiv committed Aug 24, 2021
1 parent 362e0f5 commit 90950a1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions library/unwind/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ fn main() {
}

mod llvm_libunwind {
use std::env;
use std::path::Path;
use std::path::{Path, PathBuf};
use std::{env, fs, io};

/// Compile the libunwind C/C++ source code.
pub fn compile() {
Expand All @@ -76,6 +76,14 @@ mod llvm_libunwind {
let mut cpp_cfg = cc::Build::new();
let root = Path::new("../../src/llvm-project/libunwind");

// We depend on starting with a fresh build directory each time.
let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
if let Err(x) = fs::remove_dir_all(&out_dir) {
if x.kind() != io::ErrorKind::NotFound {
panic!("Failed removing OUT_DIR at {}: {}", out_dir.display(), x);
}
}

cpp_cfg.cpp(true);
cpp_cfg.cpp_set_stdlib(None);
cpp_cfg.flag("-nostdinc++");
Expand Down Expand Up @@ -137,7 +145,7 @@ mod llvm_libunwind {
"UnwindRegistersSave.S",
];

let cpp_sources = vec!["Unwind-EHABI.cpp", "Unwind-seh.cpp", "libunwind.cpp"];
let cpp_sources = &["Unwind-EHABI.cpp", "Unwind-seh.cpp", "libunwind.cpp"];
let cpp_len = cpp_sources.len();

if target.contains("x86_64-fortanix-unknown-sgx") {
Expand Down

0 comments on commit 90950a1

Please sign in to comment.