Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions config-divergences.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,19 @@
[[divergence]]
symbol = "CC_VERSION_TEXT"
reason = "the first line of --version, which names the compiler and so always differs"

[[divergence]]
symbol = "CC_HAS_KASAN_*"
reason = "rucc has no -fsanitize=kernel-address or kernel-hwaddress, and plan section 8.10 keeps the sanitizers out of the grade, with KASAN off in both builds"

[[divergence]]
symbol = "KASAN"
reason = "only visible when the compiler can build it, see CC_HAS_KASAN_*"

[[divergence]]
symbol = "HAVE_KCSAN_COMPILER"
reason = "rucc has no -fsanitize=thread, and plan section 8.10 keeps the sanitizers out of the grade, with KCSAN off in both builds"

[[divergence]]
symbol = "KCSAN"
reason = "only visible when the compiler can build it, see HAVE_KCSAN_COMPILER"
25 changes: 24 additions & 1 deletion crates/rk/src/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,23 @@ pub fn load(out: &Path) -> Result<Commands, String> {
continue;
};
if let Some((object, words)) = parse_cmd(&text) {
commands.insert(object, words);
commands.insert(relative(&object, out), words);
}
}
}
}
Ok(commands)
}

/// An object's name relative to the output directory. objtool is built by its own makefile, which
/// names its objects by their full path, so without this every one of them is in one build only.
fn relative(object: &str, out: &Path) -> String {
Path::new(object).strip_prefix(out).map_or_else(
|_| object.to_string(),
|rest| rest.to_string_lossy().into_owned(),
)
}

/// A command made comparable: `CC` for the compiler, no persona, no output or dependency file,
/// and `OUT` and `SRC` for the directories named in `dirs`, longest first.
#[must_use]
Expand Down Expand Up @@ -289,6 +298,20 @@ mod tests {
c
}

#[test]
fn an_object_named_by_its_full_path_is_keyed_like_the_rest() {
let out = Path::new("/w/out/def-gcc");
assert_eq!(
relative("/w/out/def-gcc/tools/objtool/elf.o", out),
"tools/objtool/elf.o"
);
assert_eq!(relative("kernel/fork.o", out), "kernel/fork.o");
assert_eq!(
relative("/w/out/def-rucc/elf.o", out),
"/w/out/def-rucc/elf.o"
);
}

#[test]
fn a_cmd_file_gives_the_compile_command_without_what_follows() {
let (object, words) = parse_cmd(GCC).unwrap();
Expand Down
Loading