Skip to content

Commit caf1f9f

Browse files
committed
Revert "Try adding a fallback mapping of Rust->LLVM triples"
This reverts commit 2c08857.
1 parent 2c08857 commit caf1f9f

1 file changed

Lines changed: 2 additions & 32 deletions

File tree

Modules/cpython-sys/build.rs

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -33,32 +33,6 @@ fn gil_disabled(srcdir: &Path, builddir: Option<&str>) -> bool {
3333
false
3434
}
3535

36-
/// Map a Rust target triple to the corresponding LLVM/clang target triple.
37-
/// Most are identical, but some platforms differ:
38-
/// - Apple: aarch64 → arm64, darwin → macosx, ios-sim → ios-simulator
39-
/// - RISC-V: riscv64gc → riscv64, riscv32gc → riscv32
40-
/// - WASI threads: wasip1-threads → wasi
41-
fn rust_target_to_llvm(rust_target: &str) -> String {
42-
match rust_target {
43-
"aarch64-apple-darwin" => "arm64-apple-macosx".into(),
44-
"x86_64-apple-darwin" => "x86_64-apple-macosx".into(),
45-
"aarch64-apple-ios" => "arm64-apple-ios".into(),
46-
"aarch64-apple-ios-sim" => "arm64-apple-ios-simulator".into(),
47-
"x86_64-apple-ios" => "x86_64-apple-ios-simulator".into(),
48-
"wasm32-wasip1-threads" => "wasm32-wasi".into(),
49-
other => {
50-
// riscv64gc-* → riscv64-*, riscv32gc-* → riscv32-*
51-
if let Some(rest) = other.strip_prefix("riscv64gc-") {
52-
return format!("riscv64-{rest}");
53-
}
54-
if let Some(rest) = other.strip_prefix("riscv32gc-") {
55-
return format!("riscv32-{rest}");
56-
}
57-
other.into()
58-
}
59-
}
60-
}
61-
6236
fn generate_c_api_bindings(srcdir: &Path, builddir: Option<&str>, out_path: &Path) {
6337
let mut builder = bindgen::Builder::default().header("wrapper.h");
6438

@@ -69,13 +43,9 @@ fn generate_c_api_bindings(srcdir: &Path, builddir: Option<&str>, out_path: &Pat
6943
// LLVM_TARGET is the clang/LLVM triple which may differ from the Rust
7044
// target (e.g. arm64-apple-macosx vs aarch64-apple-darwin, or
7145
// riscv64-unknown-linux-gnu vs riscv64gc-unknown-linux-gnu).
72-
// Falls back to Cargo's TARGET with known Rust→LLVM mappings.
46+
// Falls back to Cargo's TARGET if LLVM_TARGET is not set.
7347
let target = env::var("LLVM_TARGET")
74-
.ok()
75-
.filter(|s| !s.is_empty())
76-
.or_else(|| {
77-
env::var("TARGET").ok().map(|t| rust_target_to_llvm(&t))
78-
})
48+
.or_else(|_| env::var("TARGET"))
7949
.unwrap_or_default();
8050
if !target.is_empty() {
8151
builder = builder.clang_arg(format!("--target={}", target));

0 commit comments

Comments
 (0)