<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 - Handling of extern globals in WebAssembly"
href="https://bugs.llvm.org/show_bug.cgi?id=40364">40364</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Handling of extern globals in WebAssembly
</td>
</tr>
<tr>
<th>Product</th>
<td>lld
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>alonzakai@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, peter.smith@linaro.org
</td>
</tr></table>
<p>
<div>
<pre>They seem to be turned into address 0:
extern "C" int foo;
int main() {
foo++;
return foo;
}
==> emcc a.cpp -o a.bc ==>
@foo = external global i32, align 4
; Function Attrs: noinline norecurse nounwind optnone
define hidden i32 @main() #0 {
entry:
%retval = alloca i32, align 4
store i32 0, i32* %retval, align 4
%0 = load i32, i32* @foo, align 4
%inc = add nsw i32 %0, 1
store i32 %inc, i32* @foo, align 4
%1 = load i32, i32* @foo, align 4
ret i32 %1
}
==> wasm-ld a.bc -o a.wasm --entry=main --no-gc-sections --export-dynamic ==>
(func $main (; 1 ;) (type $1) (result i32)
[..]
(i32.store
(i32.const 0)
(i32.add
(i32.load
(i32.const 0)
)
(i32.const 1)
)
)
(i32.load
(i32.const 0)
)
)
Perhaps they should be handled like extern functions, that is, an import would
be emitted, something like
(import "env" "foo" (global $gimport$0 i32))</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>