Adopting LLVM Binary Utilities in Toolchains Jordan Rupprecht - - PowerPoint PPT Presentation

adopting llvm binary utilities in toolchains
SMART_READER_LITE
LIVE PREVIEW

Adopting LLVM Binary Utilities in Toolchains Jordan Rupprecht - - PowerPoint PPT Presentation

Euro LLVM 2019 Proprietary + Confidential Adopting LLVM Binary Utilities in Toolchains Jordan Rupprecht rupprecht@google.com Euro LLVM 2019 Why? 1. Toolchains are expensive! a. Already build one for Clang + LLD b. Code, build, test,


slide-1
SLIDE 1

Proprietary + Confidential

Euro LLVM 2019

Adopting LLVM Binary Utilities in Toolchains

Jordan Rupprecht rupprecht@google.com

slide-2
SLIDE 2

Euro LLVM 2019

Why?

1. Toolchains are expensive!

a. Already build one for Clang + LLD b. Code, build, test, deploy, and debug miscompiles just once!

2. LLVM everywhere

a. Native supporu for LLVM bitcode embedded anywhere

slide-3
SLIDE 3

Euro LLVM 2019

Testing

1. Plug it in and see what breaks! a. Great for catching obvious failures b. Not great for subtle issues

# This fails, as expected, and # complains loudly. $ llvm-readelf --xyz foo # This "succeeds" but used to have # bug and create a bad object file. # It manifests as strange runtime # failures. $ llvm-objcopy --localize-hidden foo

slide-4
SLIDE 4

Euro LLVM 2019

Testing

1. Plug it in and see what breaks! 2. Use another binutils test suite a. Free test coverage! b. But noisy results.

$ objcopy -B foo ...

  • bjcopy: architecture foo

unknown $ llvm-objcopy -B foo ... llvm-objcopy: error: Invalid architecture: 'foo'

slide-5
SLIDE 5

Euro LLVM 2019

Testing

1. Plug it in and see what breaks! 2. Use another binutils test suite 3. Manual testing a. :(

slide-6
SLIDE 6

Euro LLVM 2019

Everything is broken!

1. Flags and formatuing

Different alias meanings $ readelf -s => --symbols $ llvm-readelf -s => --sections $ size foo | cut -f 2 text\t data\t bss\t ... 23616\t 1472\t 1336\t ... $ llvm-size foo | cut -f 2 text data bss ... 23616 1472 1336 ...

slide-7
SLIDE 7

Euro LLVM 2019

Everything is broken!

1. Flags and formatuing 2. Broken features

– llvm-ar: doesn't create thin archives correctly (in kernel builds) – llvm-size: miscalculated sizes (!) – llvm-symbolizer (addr2line): requires stdin input – llvm-objcopy/llvm-strip: lots of catching up to do – ...

slide-8
SLIDE 8

Euro LLVM 2019

Everything is broken!

1. Flags and formatuing 2. Broken features 3. Incompatibilities we want

# GNU ar uses -M and silently ignores rcs $ ar rcs -M < mri_script.txt $ llvm-ar rcs -M < mri_script.txt llvm-ar: error: Cannot mix -M and other

  • ptions

# GNU accepts any non-ambiguous prefix $ readelf --seg foo $ llvm-readelf --segments foo # -s removes more in llvm-strip; we need # an additional llvm flag, --keep-section $ strip -s foo $ llvm-strip -s --keep-section=.bar foo

slide-9
SLIDE 9

Euro LLVM 2019

Conclusion

Everything is now … less broken? Try it out! Contribute patches or fjle bugs!

Switched! ar, c++fjlt (llvm-cxxfjlt), nm, size, strings Very soon! addr2line (llvm-symbolizer),

  • bjdump, readelf

Great progress, but not yet

  • bjcopy, strip
slide-10
SLIDE 10

Proprietary + Confidential

Euro LLVM 2019

Thanks!

Jordan Rupprecht rupprecht@google.com Questions? Suggestions? Come to the BoF at 4:15pm today, or the round table at 2pm tomorrow.