This is an archive of the discontinued LLVM Phabricator instance.

[llvm-nm] Fix output for Mach-O universal files wrapping bitcode objects
Needs ReviewPublic

Authored by alice on May 19 2016, 6:49 AM.

Details

Reviewers
enderby
Bigcheese
Summary

Currently llvm-nm can look at a Mach-O universal binary and do one of a few generally unsurprising things (e.g. accept command line options to nm any selection of the contained architectures or all of them or if nothing is specified but the file contains a slice for the local machine’s own architecture then go with that); and obviously it can look at an LLVM bitcode file and do most of the same nm stuff other than have addresses for anything. Currently it can’t do both at once: if you’re targeting Darwin and you've configured some project to build with, say, -flto -arch x86_64 -arch i386, you'll end up with object files that are Mach-O universal binary wrappers containing LLVM bitcode for each architecture, and if you run llvm-nm on one of those, it will tend to silently exit 0. This patch fixes this, and adds two lit tests, one confirming its existing sensible output for -arch=all on Mach-O universal files that consist of native objects rather than bitcode, and one which shows that it currently fails on a universal file containing i386 bitcode and x86_64 bitcode but passes with the code changes in this patch applied.

Diff Detail

Event Timeline

alice updated this revision to Diff 57774.May 19 2016, 6:49 AM
alice retitled this revision from to [llvm-nm] Fix output for Mach-O universal files wrapping bitcode objects.
alice updated this object.
alice added reviewers: Bigcheese, enderby.
alice set the repository for this revision to rL LLVM.
alice added a subscriber: llvm-commits.
alice added a comment.May 19 2016, 7:08 AM

I’ve noticed this causing issues in e.g. some autotools/configure-based packages I’ve tried configuring to build with LTO and as universal binaries, some of them will invoke a macro that has it go "checking command to parse /.../nm output from /.../cc object… failed” and the build will indeed fail in some cases as a result.

(ALSO! Hi, this is my first attempt submitting a thing to LLVM and so I’ve tried to be painstaking about following the guidelines and policies and coding style conventions and such, but if I’ve missed anything, I’d be grateful to find out, down to and including (in all seriousness) the most minor and nitpicky of inconsequential details... I like to do things right)

enderby edited edge metadata.May 19 2016, 9:49 AM
enderby added a subscriber: enderby.

Looks fine to me.

There is a whole bunch of better error handling that still needs to happen, I’m grinding through adding all of that, to llvm-nm and other tools. But what you have fixes the problem you point out with bitcode files in universal files. And is consistant with the code that is there today.

Kev