<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - WASM backend fails on multiple symbols in same section for ctors"
href="https://bugs.llvm.org/show_bug.cgi?id=35467">35467</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>WASM backend fails on multiple symbols in same section for ctors
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: WebAssembly
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>ncw@realvnc.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>When compiling simple code with a C++ constructor, the WASM backend refuses to
emit the code with the following error from WasmObjectWriter.cpp:
<span class="quote">> LLVM ERROR: function sections must contain one function each</span >
The error only occurs when compiling with "-O0", and does not occur when
compiling with "-Os".
I think this is a distinct problem to the one observed in
<a class="bz_bug_link
bz_status_NEW "
title="NEW - WASM backend cannot build libcxx - fails on .text.__startup section"
href="show_bug.cgi?id=35414">https://bugs.llvm.org/show_bug.cgi?id=35414</a>.
=== Full testcase ===
### C++ code:
struct WithCtor {
WithCtor();
};
WithCtor::WithCtor() {}
static WithCtor withCtor;
### LLVM output from "clang++ -O0 -emit-llvm"
%struct.WithCtor = type { i8 }
@_ZL8withCtor = internal global %struct.WithCtor zeroinitializer, align 1
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void
()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_init_test.cxx, i8* null }]
@_ZN8WithCtorC1Ev = hidden alias %struct.WithCtor* (%struct.WithCtor*),
%struct.WithCtor* (%struct.WithCtor*)* @_ZN8WithCtorC2Ev
; Function Attrs: noinline nounwind optnone
define hidden %struct.WithCtor* @_ZN8WithCtorC2Ev(%struct.WithCtor* returned
%this) unnamed_addr #0 {
entry:
%this.addr = alloca %struct.WithCtor*, align 4
store %struct.WithCtor* %this, %struct.WithCtor** %this.addr, align 4
%this1 = load %struct.WithCtor*, %struct.WithCtor** %this.addr, align 4
ret %struct.WithCtor* %this1
}
; Function Attrs: noinline
define internal void @__cxx_global_var_init() #1 section ".text.__startup" {
entry:
%call = call %struct.WithCtor* @_ZN8WithCtorC1Ev(%struct.WithCtor*
@_ZL8withCtor)
ret void
}
; Function Attrs: noinline
define internal void @_GLOBAL__sub_I_init_test.cxx() #1 section
".text.__startup" {
entry:
call void @__cxx_global_var_init()
ret void
}
### Fails when compiled with "llc -filetype=obj output.o"</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>