<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/109443>109443</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
wasm-ld: Disabling on-by-default features doesn't work when LTO is used
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
alexcrichton
</td>
</tr>
</table>
<pre>
Given this input:
```llvm
target triple = "wasm32-unknown-unknown"
target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20"
define void @foo(ptr %a) #0 {
call void %a()
ret void
}
attributes #0 = { "target-cpu"="mvp" }
```
Locally I see:
```
$ llvm-as wat.ll
$ wasm-ld wat.bc -o foo.wasm --no-entry --export foo
$ wasm-tools validate -f=-reference-types foo.wasm
error: func 0 failed to validate
Caused by:
0: zero byte expected (at offset 0x4b)
```
This issue is a reduction of https://github.com/rust-lang/rust/issues/130604 and is where a user is trying to disable reference types for their entire compilation and use LTO as well, but it looks like the `"target-cpu"` isn't taking effect with `wasm-ld`.
cc @sbc100 do you know what might be causing this?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VF2vozYQ_TXOy8iRsQmBBx5yN0pVaaU-dP-AgSG417GRPU4u_fWVyce9u2orgQF75njOOWN0jObsEFu2e2O740YnmnxotcWPPph-Iu82nR-W9jdzRQc0mQjGzYmYOjBxZOI5VuJ-WXu93KdIhzMSUDCzRWDqCEzKm44XJXly787f3PPJpPwpZ9CkrV58omce8gtTB-QzUwcl14HPhWDqUOebz_Lz3VQlU4eq5G6NrEr-ZyFr7gxThyLfOVSK16b3ccDROISrNwOwUozeM1nPFIDJnWayASaVALZ_u4cD9NraR_gaUTPZPNcC0rr02GB__LqTJgqmS4TxgZkp7t8yzTt_3s8pV6eOTMrLdWZSwifGU-mvkN99rmaB3yEi_pc1j09ZQjaJ6wg3TV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