llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.19k stars 12.04k forks source link

Reduce the size of llvm-nm and llvm-ar #32994

Open llvmbot opened 7 years ago

llvmbot commented 7 years ago
Bugzilla Link 33647
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @emaste,@pcc,@rui314

Extended Description

These two utilities are very big for what they are:

% size bin/llvm-nm bin/llvm-ar text data bss dec hex filename 11438972 3805936 128664 15373572 ea9504 bin/llvm-nm 11374922 3806224 121520 15302666 e9800a bin/llvm-ar

The main problem is that they support bitcode files. Until recently to find all the symbols in the bitcode they had to parse it and then parse any file level inline assembly.

This should not be necessary anymore now that bicode files have a symbol table.

rui314 commented 5 years ago

We now have a workaround in lld so that lld reads each file's symbol table if an archive file has no symbol table. That seems to be working well. So I guess this is now low priority? Or, is there any other tool that has to read an archive file symbol table which contain bitcode files?

emaste commented 6 years ago

Somewhat orthogonal, but if it is easy to read symbol tables from LLVM bitcode files, does it make sense to write a patch to GNU binutils so that their ar command can create symbol tables for our bitcode files?

There are other sets of binary utilities in use too, including ELF Tool Chain used by FreeBSD. It would be nice to have a BSD/MIT-licensed patch to ELF Tool Chain's ar to parse bitcode files.

https://sourceforge.net/p/elftoolchain/code/HEAD/tree/trunk/ar/

rui314 commented 7 years ago

I think if the symbol table part of the file format is stable, we should do that.

llvmbot commented 7 years ago

Somewhat orthogonal, but if it is easy to read symbol tables from LLVM bitcode files, does it make sense to write a patch to GNU binutils so that their ar command can create symbol tables for our bitcode files?

It might be possible to add a minimal bfd for that, yes.

I am not sure how stable the format is for now.

rui314 commented 7 years ago

Somewhat orthogonal, but if it is easy to read symbol tables from LLVM bitcode files, does it make sense to write a patch to GNU binutils so that their ar command can create symbol tables for our bitcode files?