<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/92698>92698</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang][WebAssembly] Odd builtin behaviour
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Photosounder
      </td>
    </tr>
</table>

<pre>
    Using clang (version 18.1.4) to compile WebAssembly and going the `-nostdlib` route I'm noticing strange things when I try to use some builtins to implement libc functions. For instance doing `static float asinf(float x) { return __builtin_asinf(x); }` or `static double sqrt(double x) { return __builtin_sqrt(x); }` works fine but doing `static double exp2(double x) { return __builtin_exp2(x); }` gives me `wasm-ld: error: C:/msys/tmp/rl-89dcca.o: undefined symbol: exp2` and making it non-static with an `extern` prototype above itself just makes it call itself in a loop. That's even though `__has_builtin(__builtin_exp2)` is positive.

It seems as though some builtins aren't really there for WebAssembly, but there doesn't seem to be a clear way to determine which are actually usable, and knowing which I can actually use is what I would need.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVE-PuzYQ_TTOZRQETvh34LD7iyLl1B5a9RgZmIB_azzUMySbb1-ZJOp2q0q9AMZv3ps_T2OY7eARG5W_q_ywMYuMFJpfRxJiWnyPYdNSf29-Z-sH6JzxAyhdXTGwJQ9ZlWTJXukahKCjabYO4Q9s35hxat0djO9hoBgrI4Iq0q0nlt7ZVhUpBFoE4aR0OYEnsV0EsgTjBwQZrR8YbiN6OIGEe9RYGIFpQmgX68R6jj_tNDuc0As423ZwWXwnljwncKQA1rMY3yH0ax6qSFmM2A4ujoyAYesvSleP02esRZXvEFCW4OF8fgqdX7iIULt3UOUhlkDhC2NPS-sQ-M8gSlfP039TPnHfGG8UPhgu1sci5V9ZP1nxc9b_R-OJ-6Yx2CsyTOtEboanrevV7g0wBArx44favSl9nPjOSh9lmpU-Bret6r7rTEIREs0Rk-yB71NLbo2PYkW6Tn0yHzFxK-DJb5_J36yMYHyUxU_B4CN6DiQk9xnBtHRFsMLoLvBzYYksyJGkM869bqwHA45oTuC30YjSJQNe0YOMtAxjZD-fR8OvJihdfW9IHYUtw0xsxV4xUelBpW-P50mAEScGwy_Kf3rOBPRKlwIBjXP36O2AcKHw1ftK_1gH-LjsCfkRE6mja1sEA51DE-BmVnP3KBimOPjbaLsxyoDpZFk1Fjatw0gau_vh6Rbb-wCeoDP-KxRjbbfRCJzgRovrwSP2yaZvdn29q80Gm6zMimyXZ1m5GZu0yst2r02-y0y6wzItM4N13hb1zrR5jxvb6FTv0zyrsyLL8jJJ86Loq-qS7U2HJbZqn-JkrEucu04JhWFjmRdsal3U1caZFh2vW0brdYsorePCCU3Eb9tlYLVPnWXhvxnEiltX0yMiP6j8_WuD8wP80vevsUCLo7laWsJmCa4ZRWZ-2Fjp42BlXNqko0npYxR4vrZzoJ_YidLHNd9o9zXlvwIAAP__Zia0Xw">