Hi all,
Is it possible to add zlib source code into llvm repo? Any advice on how to do so?
I’d like to setup build of symbolizer as a static library with no external dependencies except libc.
Similar to https://github.com/google/sanitizers/blob/master/address-sanitizer/internal_symbolizer/howto.
Then the library can be linked into sanitized program and avoid dependency on standalone llvm-symbolizer tool.
Out solution uses LTO and internalize everything but symbolizer API, so we have no symbol conflicts with instrumented binary.
For LTO we need zlib in source code.
This is not clear to me.
It seems that what you want ultimately is a build where zlib would be LTO together with your program?
Assuming this is correct, you don’t need the source code for zlib, but you need a static archive of zlib build for LTO.
(What may be missing, is the ability to the LLVM build system to select a static zlib archive to link to?)
Yes, zlib build for LTO will work, but user will have to build this lib from zlib source code anyway.
Hi Vitaly,
Can you go over the exact use case with a bit more details? (i.e. without assuming we’re all familiar with the product, who are the user, and how are they using it).
That’d help to understand the need dump an external library source code directly inside LLVM.
Also have you consider changing the LLVM build system to build zlib optionally as an external project? (Like we can include clang -DLLVM_EXTERNAL_CLANG_DIR=….)
Hi Vitaly,
Can you go over the exact use case with a bit more details? (i.e. without assuming we’re all familiar with the product, who are the user, and how are they using it).
That’d help to understand the need dump an external library source code directly inside LLVM.
Sanitizer runtime supports weak hooks for symbolizer interface.http://llvm-cs.pcc.me.uk/projects/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc#328
If these symbols are defined, runtime will use them instead of invoking llvm-symbolizer tool.
So it would be nice to have this library in clang distribution and make clang driver link this library with sanitizer runtimes.
Library includes llvm::symbolize::LLVMSymbolizer with dependencies, mostly from LLVM plus zlib.
Library must not be instrumented with sanitizes and do not depend on any instrumented code. So using LTO and -internalize-public-api-list flag we make sure that library exports only weak hooks like: _sanitizer_symbolize* symbols, and has undefined symbols only from libc.
Also have you consider changing the LLVM build system to build zlib optionally as an external project? (Like we can include clang -DLLVM_EXTERNAL_CLANG_DIR=….)
Maybe -DLLVM_EXTERNAL_ZLIB is OK temporarily, but long temp it does not sound like convenient solution.
Are you asking whether it is possible to add it to your local repository, or to the mainline llvm.org distribution? In the case of the former, it just requires cmake hacking. For the later, we’d need to have extreme justification of why it is absolutely necessary. It isn’t a goal of llvm to include all dependencies out of the box, and each one we pick up introduces new complexities.
-Chris
I was asking about the former, and You’ve answered my question.
Thanks.