This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Don't use default GetLinkerPath
ClosedPublic

Authored by sbc100 on Mar 23 2019, 6:28 PM.

Details

Summary

We can't (don't want to) honor the same set of "-fuse-ld" flags
with WebAssembly since the ELF linkers (ld.lld, ld.gnu, etc) don't
work with wasm object files.

Instead we implement our own linker finding logic, similar or other
non-ELF platforms like MSVC.

We've had a few issues with CLANG_DEFAULT_LINKER overriding the
WebAssembly linker which doesn't make sense since there is no generic
linker that can handle WebAssembly today.

Diff Detail

Repository
rC Clang

Event Timeline

sbc100 created this revision.Mar 23 2019, 6:28 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 23 2019, 6:28 PM
phosek accepted this revision.Mar 24 2019, 6:14 PM

LGTM

clang/lib/Driver/ToolChains/Fuchsia.h
89 ↗(On Diff #192018)

This seems unrelated?

clang/lib/Driver/ToolChains/MipsLinux.h
51 ↗(On Diff #192018)

ditto

clang/lib/Driver/ToolChains/WebAssembly.cpp
50 ↗(On Diff #192018)

I'd also consider handling the else if (UseLinker.empty() || UseLinker == "ld") case which should return the default linker (i.e. wasm-ld), this matches the behavior of the generic driver logic in ToolChain and can be used to select the default linker for the target.

57 ↗(On Diff #192018)

Nit: you could use getDefaultLinker() instead of hardcoding wasm-ld here so if the name ever changes you only need to change the getter.

This revision is now accepted and ready to land.Mar 24 2019, 6:14 PM
sbc100 updated this revision to Diff 192125.Mar 25 2019, 9:21 AM
sbc100 marked an inline comment as done.
  • feedback
sbc100 updated this revision to Diff 192126.Mar 25 2019, 9:33 AM
sbc100 marked 4 inline comments as done.
  • feedback
sbc100 edited the summary of this revision. (Show Details)Mar 25 2019, 9:34 AM
sbc100 added inline comments.
clang/lib/Driver/ToolChains/Fuchsia.h
89 ↗(On Diff #192018)

You're right.. I shouldn't have tried the sneak that past. This change makes the output of "git grep getDefaultLinker" a lot more useful and confirms with the style guide so might still land it.

clang/lib/Driver/ToolChains/WebAssembly.cpp
57 ↗(On Diff #192018)

Done. My rational for this was that since the function has exactly one call site (here) it made more sense to keep the information local to its use

dschuff accepted this revision.Mar 25 2019, 10:12 AM
This revision was automatically updated to reflect the committed changes.