Skip to content

Commit 67d7515

Browse files
committed
Simplify LLVM target triple version removal
1 parent 953ce0d commit 67d7515

File tree

1 file changed

+5
-14
lines changed
  • dev-tools/gen-target-info/src

1 file changed

+5
-14
lines changed

dev-tools/gen-target-info/src/main.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,11 @@ fn generate_target_mapping(f: &mut File, target_specs: &RustcTargetSpecs) -> std
3030
// FIXME(madsmtm): Should become unnecessary after
3131
// https://github.com/rust-lang/rust/pull/131037
3232
let unversioned_llvm_target = if spec.llvm_target.contains("apple") {
33-
let mut components = spec.llvm_target.split("-");
34-
let arch = components.next().expect("LLVM target should have arch");
35-
let vendor = components.next().expect("LLVM target should have vendor");
36-
let os = components.next().expect("LLVM target should have os");
37-
let environment = components.next();
38-
assert_eq!(components.next(), None, "too many LLVM target components");
39-
40-
let os = os.trim_end_matches(|c: char| c.is_numeric() || c == '.');
41-
42-
if let Some(env) = environment {
43-
format!("{arch}-{vendor}-{os}-{env}")
44-
} else {
45-
format!("{arch}-{vendor}-{os}")
46-
}
33+
let mut components = spec.llvm_target.split("-").collect::<Vec<_>>();
34+
35+
components[2] = components[2].trim_end_matches(|c: char| c.is_numeric() || c == '.');
36+
37+
components.join("-")
4738
} else {
4839
spec.llvm_target.clone()
4940
};

0 commit comments

Comments
 (0)