-
Notifications
You must be signed in to change notification settings - Fork 192
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
__main_argc_argv
is not retained in main module linked with libc.so
#367
Comments
I think option 3 makes the most sense. |
Option 3 sounds good to me, too, but see also WebAssembly/wasi-libc#429 (comment) for the discussion regarding |
Yes, we would have to find a way to not break |
i have been using Option 1 if it matters. as you can see in the above url, i needed many non-default linker options to build a reasonable pie executable. |
does swift use llvm wasm-ld?
can you explain a bit? |
That's good to know, thanks for sharing.
Right, it's one of tweaks but I think it would be better if we can reduce the number of such tweaks that is needed due to toolchain internal implementation. Also we actually don't need to "export" the entry point but just need to include it in the final linked module.
Yes, we are using LLVM and wasm-ld, and doing main entry point codegen like what clang does.
If we made |
Anyway, I will trace the problem of |
my memory was a bit wrong. |
I'm trying to add shared-everything support in WebAssembly port of CRuby, and found an issue.
Dependencies
_start
issue_start
while shared-everything link bytecodealliance/wasm-tools#1339gh run download 7227946508 --repo WebAssembly/wasi-sdk --name dist-ubuntu-bionic
Repro
The main problem here is:
__main_argc_argv
is defined with hidden visibility__main_argc_argv
is referenced fromlibc.so
's__main_void
(which is referenced fromcrt1-command.o
's_start
)but the use of
__main_argc_argv
inlibc.so
doesn't mark it live.With static-link,
libc.a
,crt1-command.o
, andmain.o
are linked together into a single image, so symbols are fully resolved.Options
There are several ways to resolve the issue. I prefer option 3 as an ideal solution, but I'd like to hear @dicej opinion before tackling it.
Option 1. Adding
-Xlinker -export-if-defined=__main_argc_argv
toclang
command.This is a tentative workaround without toolchain modification.
Option 2. Set
__main_argc_argv
's visibility as default in clangOption 3. Move
__main_void
tocrt1-command.o
__main_void
into the main module cleanly solves the liveness issue.--no-gc-sections
.The text was updated successfully, but these errors were encountered: