Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Every export in WebAssembly is removed in ldc 1.15.0-beta1 #3023

Closed
skoppe opened this issue Mar 12, 2019 · 5 comments
Closed

Every export in WebAssembly is removed in ldc 1.15.0-beta1 #3023

skoppe opened this issue Mar 12, 2019 · 5 comments

Comments

@skoppe
Copy link
Contributor

skoppe commented Mar 12, 2019

In ldc 1.14 and before, any function marked with extern(C) export was exported in the wasm binary.

With ldc 1.15-beta1 pretty much everything is stripped. The only way I can export anything is to pass --export=funcname to the linker.

Ironically in ldc 1.14 the hard part was to remove exports (since it was exporting way too much, including *init_Z), but in ldc 1.15-beta1 all that stuff is removed (yay!), but also the things I want to export.

@skoppe
Copy link
Contributor Author

skoppe commented Mar 12, 2019

Here is the relevant section from lld

When building an executable, only the entry point and symbols flagged as WASM_SYMBOL_EXPORTED are exported by default. In LLVM the WASM_SYMBOL_EXPORTED flag is applied to any symbol in the llvm.used list which corresponds to attribute((used)) in C/C++ sources.

In addition, symbols can be exported via the linker command line using --export.

Finally, just like with native ELF linker the --export-dynamic flag can be used to export symbol in the executable which are marked as visibility=default.

If I add --export-dynamicto the linker I get the same behaviour as with ldc 1.14

But, is there a way I can add the __attribute__((used)) to my function?

@skoppe
Copy link
Contributor Author

skoppe commented Mar 12, 2019

Nice. I see in the llir that it is correct:

@llvm.used = appending global [1 x i8*] [i8* bitcast (i8* (i32)* @allocString to i8*)], section "llvm.metadata" ; [#uses = 0]

except it still doesn't get exported.

I am not sure what version of llvm ldc uses. It could be that the change I am waiting for (https://reviews.llvm.org/D57869) is still in the pipeline.

@kinke
Copy link
Member

kinke commented Mar 12, 2019

I am not sure what version of llvm ldc uses.

8.0.0-rc4 as mentioned in the release notes. That change is very fresh, so very likely not to be part of LLVM 8 (which was branched off trunk mid-January).

@skoppe
Copy link
Contributor Author

skoppe commented Mar 12, 2019

Ok. I am going to use --export-dynamic until that change is released. Thanks for the quick replies.

@skoppe skoppe closed this as completed Mar 12, 2019
kinke added a commit to kinke/ldc that referenced this issue May 11, 2019
This fixes issue ldc-developers#3023 and restores the behavior of previous LLD
versions (of exporting/not stripping all symbols with default/public
visibility).
kinke added a commit that referenced this issue May 15, 2019
This fixes issue #3023 and restores the behavior of previous LLD
versions (of exporting/not stripping all symbols with default/public
visibility).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants