Skip to content

Commit

Permalink
Check that library/profiler_builtins actually found some source files
Browse files Browse the repository at this point in the history
The current `build.rs` will automatically skip source files that don't exist.
An unfortunate side-effect is that if _no_ files could be found (e.g. because
the directory was wrong), the build fails with a mysterious linker error.

We can reduce the awkwardness of this by explicitly checking that at least one
source file was found.
  • Loading branch information
Zalathar committed Aug 23, 2024
1 parent 2168ce3 commit eb747e5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions profiler_builtins/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,16 @@ fn main() {
let root = Path::new("../../src/llvm-project/compiler-rt");

let src_root = root.join("lib").join("profile");
assert!(src_root.exists(), "profiler runtime source directory not found: {src_root:?}");
let mut n_sources_found = 0u32;
for src in profile_sources {
let path = src_root.join(src);
if path.exists() {
cfg.file(path);
n_sources_found += 1;
}
}
assert!(n_sources_found > 0, "couldn't find any profiler runtime source files in {src_root:?}");

cfg.include(root.join("include"));
cfg.warnings(false);
Expand Down

0 comments on commit eb747e5

Please sign in to comment.