Skip to content

Commit b74215a

Browse files
committed
Switch wasm math symbols to their original names
The names `Math_*` were given to help undefined symbol messages indicate how to implement them, but these are all implemented in compiler-rt now so there's no need to rename them! This change should make it so wasm binaries by default, no matter the math symbols used, will not have unresolved symbols.
1 parent 7a1eed7 commit b74215a

File tree

1 file changed

+1
-28
lines changed

1 file changed

+1
-28
lines changed

src/libstd/sys/wasm/cmath.rs

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -74,46 +74,19 @@ pub unsafe fn tanhf(n: f32) -> f32 {
7474
f64::tanh(n as f64) as f32
7575
}
7676

77-
// Right now all these functions, the f64 version of the functions above, all
78-
// shell out to random names. These names aren't actually defined anywhere, per
79-
// se, but we need this to compile somehow.
80-
//
81-
// The idea with this is that when you're using wasm then, for now, we have no
82-
// way of providing an implementation of these which delegates to a "correct"
83-
// implementation. For example most wasm applications probably just want to
84-
// delegate to the javascript `Math` object and its related functions, but wasm
85-
// doesn't currently have the ability to seamlessly do that (when you
86-
// instantiate a module you have to set that up).
87-
//
88-
// As a result these are just defined here with "hopefully helpful" names. The
89-
// symbols won't ever be needed or show up unless these functions are called,
90-
// and hopefully when they're called the errors are self-explanatory enough to
91-
// figure out what's going on.
92-
77+
// These symbols are all defined in `compiler-builtins`
9378
extern {
94-
#[link_name = "Math_acos"]
9579
pub fn acos(n: f64) -> f64;
96-
#[link_name = "Math_asin"]
9780
pub fn asin(n: f64) -> f64;
98-
#[link_name = "Math_atan"]
9981
pub fn atan(n: f64) -> f64;
100-
#[link_name = "Math_atan2"]
10182
pub fn atan2(a: f64, b: f64) -> f64;
102-
#[link_name = "Math_cbrt"]
10383
pub fn cbrt(n: f64) -> f64;
104-
#[link_name = "Math_cosh"]
10584
pub fn cosh(n: f64) -> f64;
106-
#[link_name = "Math_expm1"]
10785
pub fn expm1(n: f64) -> f64;
10886
pub fn fdim(a: f64, b: f64) -> f64;
109-
#[link_name = "Math_log1p"]
11087
pub fn log1p(n: f64) -> f64;
111-
#[link_name = "Math_sinh"]
11288
pub fn sinh(n: f64) -> f64;
113-
#[link_name = "Math_tan"]
11489
pub fn tan(n: f64) -> f64;
115-
#[link_name = "Math_tanh"]
11690
pub fn tanh(n: f64) -> f64;
117-
#[link_name = "Math_hypot"]
11891
pub fn hypot(x: f64, y: f64) -> f64;
11992
}

0 commit comments

Comments
 (0)