Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bolt can be installed starting with LLVM 15 - README potentially needs an update #31

Open
lilianmoraru opened this issue Jan 16, 2023 · 6 comments

Comments

@lilianmoraru
Copy link

lilianmoraru commented Jan 16, 2023

The README.md mentions the need to build bolt yourself - this is not required any more, at least on Debian-based distros. It is available in the LLVM repositories( https://apt.llvm.org/ ) starting with LLVM 15(maybe even LLVM 14, have not checked).

Example install on Ubuntu(matching the version used by rustc), starting with rustc 1.65:

# `grep "LLVM version"` if we worry that the LLVM version won't be always the last in the list
export LLVM_MAJOR_VERSION="$(rustc -vV | grep "LLVM version" | cut -d ' ' -f3 | cut -d '.' -f1)"
# `tail -1`  if we worry that `LLVM version` won't be English-only in the future
export LLVM_MAJOR_VERSION="$(rustc -vV | tail -1 | cut -d ' ' -f3 | cut -d '.' -f1)"

export UBUNTU_CODENAME="$(lsb_release -c | cut -d ':' -f2 | xargs)"
echo "deb http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME}-${LLVM_MAJOR_VERSION} main" | sudo tee -a /etc/apt/sources.list
echo "deb-src http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME}-${LLVM_MAJOR_VERSION} main" | sudo tee -a /etc/apt/sources.list
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -

sudo apt install bolt-${LLVM_MAJOR_VERSION}

dpkg -L bolt-15:

/.
/usr
/usr/bin
/usr/lib
/usr/lib/llvm-15
/usr/lib/llvm-15/bin
/usr/lib/llvm-15/bin/llvm-bolt
/usr/lib/llvm-15/bin/llvm-bolt-heatmap
/usr/lib/llvm-15/bin/merge-fdata
/usr/share
/usr/share/doc
/usr/share/doc/bolt-15
/usr/share/doc/bolt-15/NEWS.Debian.gz
/usr/share/doc/bolt-15/changelog.Debian.gz
/usr/share/doc/bolt-15/copyright
/usr/bin/llvm-bolt-15
/usr/bin/llvm-bolt-heatmap-15
/usr/bin/llvm-boltdiff-15
/usr/bin/merge-fdata-15
/usr/bin/perf2bolt-15
/usr/lib/llvm-15/bin/llvm-boltdiff
/usr/lib/llvm-15/bin/perf2bolt

This might also need an update:

"Build LLVM with BOLT and add its `bin` directory to PATH."

@Kobzol
Copy link
Owner

Kobzol commented Jan 16, 2023

Thanks for letting me know! I will check it out, modify the README, and check if LLVM autodetection in cargo-pgo can use the version from Debian packages.

@Kobzol
Copy link
Owner

Kobzol commented Jan 17, 2023

Hmm, while the package can be installed, when I actually try to use BOLT, it fails with this error:

BOLT-ERROR: library not found: /usr/lib/libbolt_rt_instr.a

Does it work for you?

@lilianmoraru
Copy link
Author

lilianmoraru commented Jan 17, 2023

It seems to be provided by libbolt-15-dev(bolt-${LLVM_MAJOR_VERSION}-dev).

dpkg -L libbolt-15-dev:

/.
/usr
/usr/lib
/usr/lib/llvm-15
/usr/lib/llvm-15/lib
/usr/lib/llvm-15/lib/libbolt_rt_hugify.a
/usr/lib/llvm-15/lib/libbolt_rt_instr.a
/usr/share
/usr/share/doc
/usr/share/doc/libbolt-15-dev
/usr/share/doc/libbolt-15-dev/NEWS.Debian.gz
/usr/share/doc/libbolt-15-dev/changelog.Debian.gz
/usr/share/doc/libbolt-15-dev/copyright

This is the hack that I had to do(after trying with linker flags), which I am not particularly happy or proud about:

sudo ln -sf /usr/lib/llvm-15/lib/libbolt_rt_instr.a /usr/lib/libbolt_rt_instr.a

It found it and then llvm-bolt threw SIGSEGV on my test on fd-find 😄

@Kobzol
Copy link
Owner

Kobzol commented Jan 18, 2023

I see 😅 Well, I think that I will wait a bit until modifying the readme, as this installation option still seems to be quite unstable. It would be best if BOLT would be built on the LLVM GitHub releases page, I pinged the LLVM maintainers about this, but it hasn't been implemented yet.

@lilianmoraru
Copy link
Author

The self-built version of LLVM 15 is also crashing on fd-find but works fine against cargo-pgo(the apt packages as well).

@Kobzol
Copy link
Owner

Kobzol commented Jan 18, 2023

Even ignoring the crash, I think that it might not be production ready if you have to link library files manually :D But I can at least add a link to this issue to README: https://github.com/Kobzol/cargo-pgo/blob/main/README.md#bolt-installation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants