This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Don't error when --undefined symbols are not found
ClosedPublic

Authored by sbc100 on Aug 3 2018, 4:00 PM.

Details

Summary

This matches the behavior of the ELF linker where -u/--undefined
means symbols will get pulled in from archives but won't result
in link error if they are missing.

This results in nice simplification of the code too.

Diff Detail

Repository
rL LLVM

Event Timeline

sbc100 created this revision.Aug 3 2018, 4:00 PM
sbc100 edited the summary of this revision. (Show Details)Aug 3 2018, 4:02 PM
sbc100 added reviewers: ruiu, dschuff.
sbc100 retitled this revision from Don't error when --undefined symbols are not found to [WebAssembly] Don't error when --undefined symbols are not found.
sbc100 updated this revision to Diff 159120.Aug 3 2018, 4:05 PM
  • Update comment
ruiu added a comment.Aug 3 2018, 4:15 PM

In ELF, we took a different approach. What we did in the lld/ELF driver is this:

  1. Add all symbols to the symbol table
  2. For each symbol that is given by --undefined, look up the symbol table, and if it is a lazy symbol, fetch it.

I don't think there's particular reason to implement it in a different way, so could you do it that way?

ruiu added a comment.Aug 3 2018, 4:40 PM

Is this the right patch? Looks like this is the same as the another one.

sbc100 updated this revision to Diff 159129.Aug 3 2018, 4:40 PM
  • Handle --undefined like the ELF linker
sbc100 updated this revision to Diff 159130.Aug 3 2018, 4:43 PM
  • revert part
ruiu added a comment.Aug 3 2018, 4:46 PM

Generally looking good.

wasm/Driver.cpp
487–489 ↗(On Diff #159130)

Not sure if this has to be inside a guard for --relocatable. Any reason for that?

sbc100 updated this revision to Diff 159132.Aug 3 2018, 4:50 PM
  • --undefined should work with -r
sbc100 added inline comments.Aug 3 2018, 4:51 PM
wasm/Driver.cpp
487–489 ↗(On Diff #159130)

Its was that way before. but I think you are probably right. Fixed.

ruiu accepted this revision.Aug 3 2018, 4:54 PM

LGTM

This revision is now accepted and ready to land.Aug 3 2018, 4:54 PM
This revision was automatically updated to reflect the committed changes.