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

Have linking look for .imports alongside each .a. #35

Closed
sbc100 opened this issue Jan 10, 2018 · 6 comments
Closed

Have linking look for .imports alongside each .a. #35

sbc100 opened this issue Jan 10, 2018 · 6 comments

Comments

@sbc100
Copy link
Member

sbc100 commented Jan 10, 2018

Currently we rely on the clang driver adding -allow-undefined-file wasm.syms along with -lc. Without this (if -lc is used on its own) symbols such as syscalls will cause the link to fail.

I propose that we have the linker looks for an optional .imports files alongside each library can can list symbols which that library expects the wasm embedder to provide. We can then rename wasm.syms to libc.imports and remove the -allow-undefined-file from the driver.

@sbc100
Copy link
Member Author

sbc100 commented Jan 10, 2018

LLD change: https://reviews.llvm.org/D41922

@sbc100
Copy link
Member Author

sbc100 commented Jan 10, 2018

Clang driver change: https://reviews.llvm.org/D41923

@sbc100
Copy link
Member Author

sbc100 commented Jan 10, 2018

waterfall change: WebAssembly/waterfall#309

@sbc100
Copy link
Member Author

sbc100 commented Jan 10, 2018

musl change: jfbastien/musl#34

@dschuff
Copy link
Member

dschuff commented Jan 11, 2018

This seems fine for the short term, seems like a better/more general mechanism than -allow-undefined-file. Longer term I think it will make more sense to have another kind of symbol, to indicate that a symbol should not participate in the usual linking but should be made into an import in the final binary. This kind of symbol would also be used by dynamically-linked executables (and dynamic libraries) for the same purpose (e.g. syscalls or other calls that come from the host environment). The dynamic loader could then have the same behavior without having to have extra files to go along with the dylibs.
We'll want to think carefully about how these symbols interact with "regular" symbols.

@NWilson
Copy link
Contributor

NWilson commented Jan 11, 2018

Funny, I have a branch I haven't yet turned into a PR where I was thinking along the same lines! I was going to take the easier route of renaming the (extremely generic) "wasm.syms" to "libc.syms". But I hadn't considered removing the -allow-undefined-file argument.

jyknight pushed a commit to jyknight/llvm-monorepo that referenced this issue Jan 11, 2018
This allows libraries to supply a list of symbols which are
allowed to be undefined at link time (i.e. result in imports).

This method replaces the existing mechanism (-allow-undefined-file)
used by the clang driver to allow undefined symbols in libc.

For more on motivation for this see:
 WebAssembly/tool-conventions#35

In the long run we hope to remove this features and instead
include this information in the object format itself.

Differential Revision: https://reviews.llvm.org/D41922

llvm-svn=322320
dtzWill pushed a commit to llvm-mirror/clang that referenced this issue Jan 11, 2018
jyknight pushed a commit to jyknight/llvm-monorepo that referenced this issue Jan 11, 2018
spurious pushed a commit to spurious/clang-mirror that referenced this issue Jan 11, 2018
@sbc100 sbc100 closed this as completed Jan 17, 2018
angerman added a commit to WebGHC/ghc that referenced this issue Jan 11, 2019
We can use `.imports` files next to the `.a` files, and have the
linker pick them up automatically.

See WebAssembly/tool-conventions#35
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

3 participants