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

libtinfo.so.5: cannot open shared object file while running clang-format from this bzlmod #403

Open
cheshirekow opened this issue Oct 14, 2024 · 6 comments

Comments

@cheshirekow
Copy link

I apologize if I'm trying to use this project in the wrong way. To be honest I'm just looking for the simplest way to get clang-format and clang-tidy integrated into a bazel-based build currently using a gcc toolchain. It looks like I could do that by integrating this project but I'm running into issues running clang-format from this repo.

A Minimal Working Example is demonstrated in this MODULE.bazel (taken from the release page):

module(
    name="mwe",
    repo_name="mwe",
    version="0.1.0",
    compatibility_level=1,
)
bazel_dep(name = "toolchains_llvm", version = "1.2.0")
llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")
llvm.toolchain(
   llvm_version = "16.0.0",
)
use_repo(llvm, "llvm_toolchain")

In an otherwise empty project, with this file, running the following:

$ bazel run @llvm_toolchain//:clang-format -- --help
INFO: Analyzed target @@toolchains_llvm~~llvm~llvm_toolchain//:clang-format (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target @@toolchains_llvm~~llvm~llvm_toolchain//:clang-format up-to-date:
  bazel-bin/external/toolchains_llvm~~llvm~llvm_toolchain/clang-format
INFO: Elapsed time: 0.174s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/external/toolchains_llvm~~llvm~llvm_toolchain/clang-format --help
/home/josh/.cache/bazel/_bazel_josh/2a29d762c542cdfb3743d99dfc1bc836/execroot/_main/bazel-out/k8-fastbuild/bin/external/toolchains_llvm~~llvm~llvm_toolchain/clang-format: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory

My version of bazel is 7.3.2 (aquired through bazelisk):

$ bazel --version
bazel 7.3.2

My operating system is:

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.5 LTS
Release:	22.04
Codename:	jammy

Please let me know if any other information would help with addressing this issue. Again, I apologize if this isn't "intended usage" of this project.

@AustinSchuh
Copy link

So, what is going on here is that newer Ubuntu provide libtinfo6, but the default clang packaging requires libtinfo5. It is installable.

We patched these rules to extract the Debian package of libtinfo5 and copy the shared library in next to clang to make it happy.

@cheshirekow
Copy link
Author

Oh I see, thank you for that reply. Indeed if I sudo apt install libtinfo5 then I am able to bazel run clang-format. Though, I am a little confused by this part of your reply:

We patched these rules to extract the Debian package of libtinfo5 and copy the shared library in next to clang to make it happy.

This makes it sound like libtinfo5 is actual available inside @toolchains_llvm//, which would make me thing that it would be in the rpath of clang-format (or something) but it seems I still need to install it on the host system to actually run it?

@AustinSchuh
Copy link

We patched toolchains_llvm to also download a copy of libtinfo5.so, and drop it in the lib folder with clang. (I think we added a symlink instead of copying it, but I forget). Clang (and clang-format and others) then automatically finds it because it is already part of RPATH for the binaries. Since we've standardized on one OS for the team, we were able to get one by manually pulling it from the debian package for our distro.

I keep hoping that compilers will depend on libtinfo6 instead. Since this has been an issue for years, I'll have to keep hoping.

@cheshirekow
Copy link
Author

Ah, sorry, I think understand now. When you responded to the issue I had assumed you were a member of this project. I believe you're saying that in your own project you have patched this project to do what you said. Thank you for sharing your experience.

I guess I'm not sure if I should close this thread or not. From my perspective I understand the problem and I'm moving on.

@AustinSchuh
Copy link

I'd propose keeping it open. I keep pushing our folks to open source our changes (maintaining forks sucks and adds no value), and this is one of the ones to think about and talk through.

@jsharpe
Copy link
Member

jsharpe commented Oct 15, 2024

You might want to try llvm version 19 - I think they've removed the dependency on libtinfo in that release version

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

3 participants