-
Notifications
You must be signed in to change notification settings - Fork 7
Improve packaging for lsif-clang by bundling dynamic libraries #83
Conversation
(cherry picked from commit 4d1b5d9)
| for lib in $(ldd "$binary" | cut -d ">" -f 2 | awk '{print $1}' | grep -vE "(linux-vdso\.|ld-linux-x86-64\.|libc\.)"); do | ||
| cp --verbose "$lib" "$output/" | ||
| done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should double-check if the new libdwarf-dev and libelf-dev dependencies require updating this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This by takes every linked shared object except for the linux kernel vdso, dynamic linker and libc. Those are best kept left with the system or not copyable. So as long as all dependencies are linked, and not loaded with dlopen they will be included here.
It would be a good idea to update the docs here to explain this.
(I would also rename this copy_dependencies.sh to copy_needed_libraries.sh)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this needed an update for librt and libpthread; copying them across OSes lead to errors, but removing them fixes the issue. See the commit message of be6a3a1 for details.
But it works fine otherwise.
|
When running the installation script inside an Ubuntu 20.04 VM, I get an error with missing packages This happens both with the original commit and after the refactoring a392f4d. I wonder if this is aarch64 specific, where the older OSes are missing aarch64 packages. I can try reproducing on x86_64, but it seems like 22.04 avoids this. |
Looks like this was missed during cherry-picking. Co-authored-by: Joseph Lisee <jlisee@aurora.tech>
|
Hmm, this doesn't seem to work for me across Ubuntu versions, because of a glibc version mismatch. Maybe because of the upgrade to Ubuntu 22.04 for the image? |
jlisee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
glibc has a high degree of backwards compatibility so the if we build on Ubuntu 18.04 and bring all the other libraries we should be able to run on a large number of linux systems of that age and newer. This should allow using lsif-clang in most environments that people are building C++.
To share code between Dockerfile's this is what I would do:
- Create a
clang-tools-extra/lsif-clang/install_dependencies.shwhich useslsb_releaseto be be portable and does the cmake, llvm and clang apt based installs - Create a
clang-tools-extra/lsif-clang/configure.shwhich does theCC=... CXX=... cmakesteps
| for lib in $(ldd "$binary" | cut -d ">" -f 2 | awk '{print $1}' | grep -vE "(linux-vdso\.|ld-linux-x86-64\.|libc\.)"); do | ||
| cp --verbose "$lib" "$output/" | ||
| done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This by takes every linked shared object except for the linux kernel vdso, dynamic linker and libc. Those are best kept left with the system or not copyable. So as long as all dependencies are linked, and not loaded with dlopen they will be included here.
It would be a good idea to update the docs here to explain this.
(I would also rename this copy_dependencies.sh to copy_needed_libraries.sh)
Bundled.Dockerfile
Outdated
| # | ||
| # See issue https://github.com/sourcegraph/lsif-clang/issues/72 | ||
|
|
||
| FROM ubuntu:22.04 as build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my note, building on such a new version of Ubuntu greatly restricts the platforms that can run the resulting release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that makes sense. I'm testing the PR with that reverted right now on an x86_64 machine.
Yes sorry I didn't replay last night, but the entire point of using 18.04 is that you can still build new software on it but the resulting binaries are widely portable. |
|
No worries about the response, I think you're in a US timezone, whereas I am in Taipei right now. I'd like to double-check the change manually once before merging. On aarch64, it doesn't work, so I'm going to test with x86_64. As for debugging, I've been working on updating the Python driver script so that it can perform index merging after-the-fact, gracefully handling OOMs since it is multi-process instead of multi-threaded. I'm not 100% sure if it'll work (without blowing up the index size) but just giving you a heads up to avoid duplicate work. |
This reverts commit dde8835.
They link in private symbols from Glibc, leading to linker errors when trying to use lsif-clang across Ubuntu versions. Error with libpthread: lsif-clang: symbol lookup error: /home/varun/lsif-clang/build/bundled/lsif-clang-34e509b99/libpthread.so.0: undefined symbol: __libc_vfork, version GLIBC_PRIVATE Error with librt: lsif-clang: symbol lookup error: /home/varun/lsif-clang/build/bundled/lsif-clang-34e509b99/librt.so.1: undefined symbol: __clock_nanosleep, version GLIBC_PRIVATE
It messes up the lookup for the compile_commands.json file.
Using fewer RUN steps should lead to smaller images. Also use fewer apt-get update calls.
|
I've reverted the bump to 22.04 for the Dockerfile. There were also some other bugs that I noticed:
Thank you for submitting the original PR with this approach. I was investigating rewriting the CMake in the style of upstream Clang-based tools, which are often statically linked in a busybox-style binary. However, that would've likely been much more time-consuming to implement. I hadn't considered this approach. Sure, it feels hackier, but if it gets the job done for you, I don't have complaints. :) |
|
The Feel free to leave post-review comments and I'll address them tomorrow; I'm merging this for now. |
jlisee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to successfully to run this locally on my x64, Ubuntu 18.04 machine.
Based off #78.
(cherry picked from commit 4d1b5d9)
Test plan
We can add a publish step in a follow-up PR if needed.