diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2022-01-11 11:30:53 +0100 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2022-01-11 11:30:53 +0100 |
| commit | a615425b513eb981cb2d5f0b780d720203c8defe (patch) | |
| tree | 20cc2e7305456b4175b1e19040016edb8ad303d2 /src/stage1 | |
| parent | 4731a6e5d57d5fe6c17c42028aebd9fce3682ddb (diff) | |
| parent | 247b638ccf8bfd5e0c4729935d230022726f97aa (diff) | |
| download | zig-a615425b513eb981cb2d5f0b780d720203c8defe.tar.gz zig-a615425b513eb981cb2d5f0b780d720203c8defe.zip | |
Merge branch 'linker-eport-symbols' of github.com:Luukdegram/zig into Luukdegram-linker-eport-symbols
Diffstat (limited to 'src/stage1')
| -rw-r--r-- | src/stage1/codegen.cpp | 12 | ||||
| -rw-r--r-- | src/stage1/stage2.h | 3 | ||||
| -rw-r--r-- | src/stage1/zig0.cpp | 5 |
3 files changed, 20 insertions, 0 deletions
diff --git a/src/stage1/codegen.cpp b/src/stage1/codegen.cpp index 0cf8024995..cfd455e815 100644 --- a/src/stage1/codegen.cpp +++ b/src/stage1/codegen.cpp @@ -9905,6 +9905,18 @@ void codegen_build_object(CodeGen *g) { codegen_add_time_event(g, "Done"); codegen_switch_sub_prog_node(g, nullptr); + + // append all export symbols to stage2 so we can provide them to the linker + if (target_is_wasm(g->zig_target)){ + Error err; + auto export_it = g->exported_symbol_names.entry_iterator(); + decltype(g->exported_symbol_names)::Entry *curr_entry = nullptr; + while ((curr_entry = export_it.next()) != nullptr) { + if ((err = stage2_append_symbol(&g->stage1, buf_ptr(curr_entry->key), buf_len(curr_entry->key)))) { + fprintf(stderr, "Unable to export symbol '%s': %s\n", buf_ptr(curr_entry->key), err_str(err)); + } + } + } } ZigPackage *codegen_create_package(CodeGen *g, const char *root_src_dir, const char *root_src_path, diff --git a/src/stage1/stage2.h b/src/stage1/stage2.h index b7c8616ec0..58b3a7687f 100644 --- a/src/stage1/stage2.h +++ b/src/stage1/stage2.h @@ -182,4 +182,7 @@ ZIG_EXTERN_C const char *stage2_add_link_lib(struct ZigStage1 *stage1, const char *lib_name_ptr, size_t lib_name_len, const char *symbol_name_ptr, size_t symbol_name_len); +// ABI warning +ZIG_EXTERN_C enum Error stage2_append_symbol(struct ZigStage1 *stage1, const char *name_ptr, size_t name_len); + #endif diff --git a/src/stage1/zig0.cpp b/src/stage1/zig0.cpp index 9e15bc6e2e..439f2bd1d4 100644 --- a/src/stage1/zig0.cpp +++ b/src/stage1/zig0.cpp @@ -554,3 +554,8 @@ const char *stage2_version_string(void) { struct Stage2SemVer stage2_version(void) { return {ZIG_VERSION_MAJOR, ZIG_VERSION_MINOR, ZIG_VERSION_PATCH}; } + +Error stage2_append_symbol(struct ZigStage1 *stage1, const char *name_ptr, size_t name_len) +{ + return ErrorNone; +} |
