Skip to content

Commit

Permalink
Configure f16 and f128 support for wasm32/wasm64
Browse files Browse the repository at this point in the history
  • Loading branch information
kleisauke committed Aug 11, 2024
1 parent 3ad4d9c commit b4fa4c3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,13 @@ fn configure_f16_f128(target: &Target) {
"powerpc64" if &target.os == "aix" => (true, false),
// `f128` crashes <https://github.com/llvm/llvm-project/issues/41838>
"sparc" | "sparcv9" => (true, false),
// `f16` requires half-precision feature, `f128` is unsupported
"wasm32" | "wasm64" => (
// TODO: This requires updating `WASM_ALLOWED_FEATURES`:
// https://github.com/rust-lang/rust/blob/1.80.0/compiler/rustc_target/src/target_features.rs#L310
target.features.contains(&"half-precision".to_owned()),
false,
),
// Most everything else works as of LLVM 19
_ => (true, true),
};
Expand Down
3 changes: 2 additions & 1 deletion testcrate/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ fn main() {
if target.starts_with("arm-")
|| target.contains("apple-darwin")
|| target.contains("windows-msvc")
|| target.starts_with("wasm")
// GCC and LLVM disagree on the ABI of `f16` and `f128` with MinGW. See
// <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>.
|| target.contains("windows-gnu")
Expand Down Expand Up @@ -55,7 +56,7 @@ fn main() {
|| target.contains("windows-")
// Linking says "error: function signature mismatch: __extendhfsf2" and seems to
// think the signature is either `(i32) -> f32` or `(f32) -> f32`
|| target.starts_with("wasm32-")
|| target.starts_with("wasm")
{
features.insert(Feature::NoSysF16);
features.insert(Feature::NoSysF16F128Convert);
Expand Down

0 comments on commit b4fa4c3

Please sign in to comment.