This is an archive of the discontinued LLVM Phabricator instance.

[Clang][Driver]Pass LLVM options to lld in case of LTO
Needs RevisionPublic

Authored by bin.narwal on May 8 2020, 7:23 AM.

Details

Reviewers
MaskRay
Summary

Hi,
When debugging ThinLTO with clang -mllvm -debug-only=function-import -flto=thin -fuse-ld=lld ..., it gives me below warning message:
warning: argument unused during compilation: '-mllvm -debug-only=function-import' [-Wunused-command-line-argument]

Actually lld already supports passing arguments to llvm using -mllvm, it would be easier for debug if driver passes it along to lld.

This simple patch does this. Note it also silently eats up such options if other linkers (ld.bfd, gold) are used.

Any comments? Thanks

Diff Detail

Event Timeline

bin.narwal created this revision.May 8 2020, 7:23 AM
MaskRay requested changes to this revision.May 8 2020, 7:45 AM

-mllvm,foobar is for compilation (.c/.cc -> .o)

-Wl,-mllvm,foobar for LTO options. For linking, -mllvm,foobar is not used and thus warned.

clang/lib/Driver/ToolChains/CommonArgs.cpp
363

This is wrong. The intention is not to pass -plugin when the linker is clearly lld. lld does not need -plugin for LTO.

This revision now requires changes to proceed.May 8 2020, 7:45 AM

-mllvm,foobar is for compilation (.c/.cc -> .o)

-Wl,-mllvm,foobar for LTO options. For linking, -mllvm,foobar is not used and thus warned.

Right, that's reasonable design. The wrong UseLLD condition is a typo, anyway, I will discard this patch.

Thanks