ldc/tests/codegen/wasi.d
Martin Kinkelin 9707bb1af8
WebAssembly: Switch from legacy linked-list ModuleInfo registry to __minfo section (#3348)
As LLD 9+ supports the magic __{start,stop}___minfo linker symbols for
wasm targets.
2020-03-07 22:57:56 +01:00

39 lines
1 KiB
D

// REQUIRES: atleast_llvm900, target_WebAssembly, link_WebAssembly
// emit textual IR *and* compile & link
// RUN: %ldc -mtriple=wasm32-unknown-wasi -output-ll -output-o -of=%t.wasm %s
// RUN: FileCheck %s < %t.ll
// test predefined versions:
version (WASI) {} else static assert(0);
version (CRuntime_WASI) {} else static assert(0);
// make sure TLS globals are emitted as regular __gshared globals:
// CHECK: @_D4wasi13definedGlobali = global i32 123
int definedGlobal = 123;
// CHECK: @_D4wasi14declaredGlobali = external global i32
extern int declaredGlobal;
// make sure the ModuleInfo ref is emitted into the __minfo section:
// CHECK: @_D4wasi11__moduleRefZ = linkonce_odr hidden global %object.ModuleInfo* {{.*}}, section "__minfo"
// CHECK: @llvm.used = appending global [1 x i8*] [i8* {{.*}} @_D4wasi11__moduleRefZ
// test the magic linker symbols via linkability of the following:
extern(C) extern __gshared
{
void* __start___minfo;
void* __stop___minfo;
}
extern(C) void _start()
{
auto size = __stop___minfo - __start___minfo;
}