[PATCH] D69607: Add a feature to explain why some file gets included to the linker's output

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 31 02:11:57 PDT 2019


ruiu marked 2 inline comments as done.
ruiu added inline comments.


================
Comment at: lld/ELF/Explain.cpp:175
+  error("--explain: no such file or symbol: '" + name +
+        "'. Use --verbose option to see a list of input files.");
+  return nullptr;
----------------
grimar wrote:
> grimar wrote:
> > But it doesn't seem helps for the case mentioned in the description?
> > 
> > If we have a `main.o` compiled from
> > ```
> > .global _start;
> > _start:
> > callq foo
> > ```
> > 
> > And a `foo.a` which contains a `foo.o` compiled from
> > 
> > ```
> > .globl foo;
> > foo:
> > ```
> > 
> > Then when I invoke `-flavor gnu main.o foo.a "-o" out --verbose` I see:
> > ```
> > lld: main.o
> > lld: foo.a
> > ```
> > 
> > Then, like a possible normal user :) I do:
> > `-flavor gnu --explain=foo.a main.o foo.a "-o" out --verbose`
> > 
> > and I see:
> > 
> > ```
> > lld: main.o
> > lld: foo.a
> > lld: error: --explain: no such file or symbol: 'foo.a'. Use --verbose option to
> > see a list of input files.
> > ```
> > 
> > How I am supposed to realise that I should invoke `-flavor gnu --explain=foo.a(foo.o) main.o foo.a "-o" out --verbose`
> > to see the following?
> > 
> > ```
> > lld: main.o
> > lld: foo.a
> > Explain: This is why 'foo.a(foo.o)' is linked:
> > Explain:
> > Explain: '(--entry option)' uses '_start' defined in 'main.o'
> > Explain: which uses 'foo' defined in 'foo.a(foo.o)'
> > ```
> > 
> btw, note that it says `'(--entry option)' uses '_start'`, but in fact I am not using any command line option like `-e`
That's I think fine. It's an implicit option but still there.


================
Comment at: lld/ELF/Explain.cpp:175
+  error("--explain: no such file or symbol: '" + name +
+        "'. Use --verbose option to see a list of input files.");
+  return nullptr;
----------------
ruiu wrote:
> grimar wrote:
> > grimar wrote:
> > > But it doesn't seem helps for the case mentioned in the description?
> > > 
> > > If we have a `main.o` compiled from
> > > ```
> > > .global _start;
> > > _start:
> > > callq foo
> > > ```
> > > 
> > > And a `foo.a` which contains a `foo.o` compiled from
> > > 
> > > ```
> > > .globl foo;
> > > foo:
> > > ```
> > > 
> > > Then when I invoke `-flavor gnu main.o foo.a "-o" out --verbose` I see:
> > > ```
> > > lld: main.o
> > > lld: foo.a
> > > ```
> > > 
> > > Then, like a possible normal user :) I do:
> > > `-flavor gnu --explain=foo.a main.o foo.a "-o" out --verbose`
> > > 
> > > and I see:
> > > 
> > > ```
> > > lld: main.o
> > > lld: foo.a
> > > lld: error: --explain: no such file or symbol: 'foo.a'. Use --verbose option to
> > > see a list of input files.
> > > ```
> > > 
> > > How I am supposed to realise that I should invoke `-flavor gnu --explain=foo.a(foo.o) main.o foo.a "-o" out --verbose`
> > > to see the following?
> > > 
> > > ```
> > > lld: main.o
> > > lld: foo.a
> > > Explain: This is why 'foo.a(foo.o)' is linked:
> > > Explain:
> > > Explain: '(--entry option)' uses '_start' defined in 'main.o'
> > > Explain: which uses 'foo' defined in 'foo.a(foo.o)'
> > > ```
> > > 
> > btw, note that it says `'(--entry option)' uses '_start'`, but in fact I am not using any command line option like `-e`
> That's I think fine. It's an implicit option but still there.
Well, I don't think we should print out all section names because it's just too long, and I believe showing a hint is better. The problem is that --verbose option doesn't show archive members, but that can be fixed simply by adding a log() call to fetch().


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69607/new/

https://reviews.llvm.org/D69607





More information about the llvm-commits mailing list