Skip to content

Commit b4fa4c3

Browse files
committed
Configure f16 and f128 support for wasm32/wasm64
1 parent 3ad4d9c commit b4fa4c3

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

build.rs

+7
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,13 @@ fn configure_f16_f128(target: &Target) {
283283
"powerpc64" if &target.os == "aix" => (true, false),
284284
// `f128` crashes <https://github.com/llvm/llvm-project/issues/41838>
285285
"sparc" | "sparcv9" => (true, false),
286+
// `f16` requires half-precision feature, `f128` is unsupported
287+
"wasm32" | "wasm64" => (
288+
// TODO: This requires updating `WASM_ALLOWED_FEATURES`:
289+
// https://github.com/rust-lang/rust/blob/1.80.0/compiler/rustc_target/src/target_features.rs#L310
290+
target.features.contains(&"half-precision".to_owned()),
291+
false,
292+
),
286293
// Most everything else works as of LLVM 19
287294
_ => (true, true),
288295
};

testcrate/build.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ fn main() {
1818
if target.starts_with("arm-")
1919
|| target.contains("apple-darwin")
2020
|| target.contains("windows-msvc")
21+
|| target.starts_with("wasm")
2122
// GCC and LLVM disagree on the ABI of `f16` and `f128` with MinGW. See
2223
// <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>.
2324
|| target.contains("windows-gnu")
@@ -55,7 +56,7 @@ fn main() {
5556
|| target.contains("windows-")
5657
// Linking says "error: function signature mismatch: __extendhfsf2" and seems to
5758
// think the signature is either `(i32) -> f32` or `(f32) -> f32`
58-
|| target.starts_with("wasm32-")
59+
|| target.starts_with("wasm")
5960
{
6061
features.insert(Feature::NoSysF16);
6162
features.insert(Feature::NoSysF16F128Convert);

0 commit comments

Comments
 (0)