[PATCH] D83152: llvm-nm: add flag to suppress no symbols warning

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 7 02:03:50 PDT 2020


jhenderson added a comment.

In D83152#2134405 <https://reviews.llvm.org/D83152#2134405>, @keith wrote:

> In D83152#2133950 <https://reviews.llvm.org/D83152#2133950>, @rupprecht wrote:
>
> > In D83152#2133855 <https://reviews.llvm.org/D83152#2133855>, @MaskRay wrote:
> >
> > > I cannot find any search result about `no-warning-for-no-symbols`. Is `-no-warning-for-no-symbols` really an existing option? libtool is an `ar` like tool.
> >
> >
> > I found it by looking for underscores instead of hyphens: `-no_warning_for_no_symbols`.
> >  However, the flag is an ar/ranlib/libtool flag, not nm, AFAICT.
>
>
> Yea sorry I should have been more clear, it's not the _exact_ same spelling because of the conventions used in nm with `-` instead of `_`.
>
> >> Second, I wonder how you are going to plug `-no-warning-for-no-symbols` into a build system. If you only parse stdout, you can ignore stderr. Even if you do, you can probably use `grep -v '^no symbols'`. This will have better portability (supported on older nm, supported on other binary formats).
> > 
> > I agree this is likely the simpler option (just add `2> /dev/null` to the build script using `nm`)
>
> If folks feel strongly about this that would definitely work, this felt like a safer way to silence this for the future for me, but if you all think it's not worth adding an option for that's fine.


I don't have strong opinions either way. I think there probably is some benefit to adding the new option: one counter-point to redirecting stderr to `/dev/null` is that will hide any real error messages llvm-nm (e.g. caused by a missing input file). I don't think that's a good idea personally. That being said, if stderr is being redirected somewhere other than `/dev/null` maybe it's okay. Another issue is that because stderr and stdout are often handled independently, but end up in the same final output, you can end up with the "no symbols" message appearing quite some way from where it really belongs, which could be slightly confusing. However, it's not an issue I actually have at the moment.

Another possible benefit (again not something I personally have worried about, but one I thought of) is that users could specify the option to avoid having to special case parsing scripts to handle no symbols. A naive script would typically just iterate through the lines and expect each one to correspond to a symbol, so if there are none, the parser might break.

Another option name could just be `--quiet`, although there's a small risk that could clash in the future with a GNU option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83152





More information about the llvm-commits mailing list