aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShritesh Bhattarai <shritesh@shritesh.com>2019-04-15 17:00:04 -0500
committerShritesh Bhattarai <shritesh@shritesh.com>2019-04-15 17:00:04 -0500
commita0d2185199e7723aabc38cacd83d6a140f12e01d (patch)
tree73cb0f562a778c58ff3e3fff7b6544b6ad4dd414
parent9465c6d5385dff70d41142f509fcdf074269a905 (diff)
downloadzig-a0d2185199e7723aabc38cacd83d6a140f12e01d.tar.gz
zig-a0d2185199e7723aabc38cacd83d6a140f12e01d.zip
wasm: add wasm-import-module attr to extern
-rw-r--r--src/codegen.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp
index 332eab59b9..88f0f739b6 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -495,6 +495,14 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, ZigFn *fn_table_entry) {
auto entry = g->exported_symbol_names.maybe_get(symbol_name);
if (entry == nullptr) {
fn_table_entry->llvm_value = LLVMAddFunction(g->module, buf_ptr(symbol_name), fn_llvm_type);
+
+ if (target_is_wasm(g->zig_target)) {
+ assert(fn_table_entry->proto_node->type == NodeTypeFnProto);
+ AstNodeFnProto *fn_proto = &fn_table_entry->proto_node->data.fn_proto;
+ if (fn_proto-> is_extern && fn_proto->lib_name != nullptr ) {
+ addLLVMFnAttrStr(fn_table_entry->llvm_value, "wasm-import-module", buf_ptr(fn_proto->lib_name));
+ }
+ }
} else {
assert(entry->value->id == TldIdFn);
TldFn *tld_fn = reinterpret_cast<TldFn *>(entry->value);