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
23 changes: 17 additions & 6 deletions crates/rk-shim/src/bringup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,16 @@ const NEWER_THAN_BRINGUP: &[&str] = &["-fzero-init-padding-bits="];

/// The arguments a call hands to its compiler.
///
/// rk puts the era's persona in `CC` as `-fgnuc-version=`, which only rucc knows. GCC refuses
/// rk puts the era's persona in `CC` as `-fgnuc-version=` and `-fgnu-as-version=`, which only rucc
/// knows. GCC refuses
/// it, so a delegated call leaves it out, along with the flags in [`NEWER_THAN_BRINGUP`]. Every
/// other argument goes through as kbuild wrote it.
#[must_use]
pub fn passed_on(args: &[String], delegated: bool) -> Vec<String> {
let refused = |a: &str| {
a.starts_with("-fgnuc-version=") || NEWER_THAN_BRINGUP.iter().any(|f| a.starts_with(f))
a.starts_with("-fgnuc-version=")
|| a.starts_with("-fgnu-as-version=")
|| NEWER_THAN_BRINGUP.iter().any(|f| a.starts_with(f))
};
args.iter()
.filter(|a| !(delegated && refused(a)))
Expand Down Expand Up @@ -177,10 +180,18 @@ mod tests {

#[test]
fn the_persona_is_not_passed_on_to_the_other_compiler() {
let args: Vec<String> = ["-fgnuc-version=14.2.0", "-m16", "-c", "-o", "a.o", "a.S"]
.iter()
.map(|s| (*s).to_string())
.collect();
let args: Vec<String> = [
"-fgnuc-version=14.2.0",
"-fgnu-as-version=2.44",
"-m16",
"-c",
"-o",
"a.o",
"a.S",
]
.iter()
.map(|s| (*s).to_string())
.collect();
assert_eq!(passed_on(&args, true), ["-m16", "-c", "-o", "a.o", "a.S"]);
assert_eq!(passed_on(&args, false), args, "rucc keeps it");
}
Expand Down
10 changes: 7 additions & 3 deletions crates/rk/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
//! The tree is never written to. kbuild's output goes under `O=`, and the compiler is the shim,
//! copied into the build directory with an `rk-cc.toml` naming the real compiler, so that every
//! sub make, including the ones that clean their environment, still goes through it. When the
//! compiler is rucc, the era's persona is part of `CC`, as `rk-cc -fgnuc-version=14.2.0`, which
//! is what a user building by hand would write too.
//! compiler is rucc, the era's persona is part of `CC`, as `rk-cc -fgnuc-version=14.2.0
//! -fgnu-as-version=2.44`, which is what a user building by hand would write too. The second one
//! is what `scripts/as-version.sh` reads, so `CONFIG_AS_VERSION` matches the reference's binutils.
//!
//! Nothing else is added to the command line, with one exception that changes no code:
//! `--stack-usage` passes `KCFLAGS=-fstack-usage`, as the kernel's own `scripts/stackusage` does,
Expand Down Expand Up @@ -524,7 +525,10 @@ pub fn run(plan: &Plan) -> Result<Outcome, String> {
.map_err(|e| format!("writing the shim's settings: {e}"))?;

let persona = if plan.compiler.rucc {
vec![format!("-fgnuc-version={}", plan.era.gnuc)]
vec![
format!("-fgnuc-version={}", plan.era.gnuc),
format!("-fgnu-as-version={}", plan.era.gnu_as),
]
} else {
Vec::new()
};
Expand Down
1 change: 1 addition & 0 deletions crates/rk/src/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ pub fn normalize(words: &[String], dirs: &[(&str, &str)]) -> Vec<String> {
continue;
}
if word.starts_with("-fgnuc-version=")
|| word.starts_with("-fgnu-as-version=")
|| word.starts_with("-Wp,-MD,")
|| word.starts_with("-Wp,-MMD,")
|| matches!(word.as_str(), "-MD" | "-MMD")
Expand Down
5 changes: 4 additions & 1 deletion crates/rk/src/probes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ pub fn question(record: &CompileRecord) -> String {
args.next();
continue;
}
if arg.starts_with("-fgnuc-version=") || (arg.starts_with("-o") && arg.len() > 2) {
if arg.starts_with("-fgnuc-version=")
|| arg.starts_with("-fgnu-as-version=")
|| (arg.starts_with("-o") && arg.len() > 2)
{
continue;
}
if arg.contains(".tmp_") {
Expand Down
1 change: 1 addition & 0 deletions crates/rk/src/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub fn replay_args(record: &CompileRecord, extra: &[String]) -> Vec<String> {
|| arg.starts_with("-Wp,-MD,")
|| arg.starts_with("-Wp,-MMD,")
|| arg.starts_with("-fgnuc-version=")
|| arg.starts_with("-fgnu-as-version=")
{
continue;
}
Expand Down
Loading