Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 23, 2026

LLVM < 19 depends on libtinfo.so.5, which is absent from Ubuntu 24.04+ (replaced by libtinfo6). This causes build failures: error while loading shared libraries: libtinfo.so.5: cannot open shared object file.

Changes

Added patch libtinfo5_fix.patch to toolchains_llvm 1.6.0.envoy:

  • toolchain/internal/repo.bzl: Downloads libtinfo5 from Ubuntu 22.04 archives (amd64/aarch64) and extracts libtinfo.so.5.9 when:

    • OS is Linux
    • LLVM major version < 19
    • Architecture is amd64 or aarch64
    • Gracefully skips unsupported architectures
  • toolchain/cc_wrapper.sh.tpl: Prepends LD_LIBRARY_PATH with toolchain's lib directory on Linux:

    if [[ "$(uname -s)" == "Linux" ]]; then
      export LD_LIBRARY_PATH="${toolchain_path_prefix}lib:${LD_LIBRARY_PATH}"
    fi

Updated source.json: Added patch with SHA256 checksum.

Details

.deb archives sourced from Ubuntu 22.04:

  • amd64: http://security.ubuntu.com/ubuntu/pool/universe/n/ncurses/libtinfo5_6.3-2ubuntu0.1_amd64.deb
  • arm64: http://ports.ubuntu.com/pool/universe/n/ncurses/libtinfo5_6.3-2ubuntu0.1_arm64.deb

Verified checksums match upstream package database.

Upstream tracking: bazel-contrib/toolchains_llvm#528

Original prompt

Problem

LLVM versions < 19 distributed via toolchains_llvm depend on libtinfo.so.5, which is not available on Ubuntu 24.04+ (only libtinfo6 is present). This causes builds to fail with:

error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory

This is tracked upstream at bazel-contrib/toolchains_llvm#528

Solution

Add a patch to the existing toolchains_llvm registry entry at bazel-registry/modules/toolchains_llvm/1.6.0.envoy/ that:

  1. Modifies toolchain/internal/repo.bzl to download and extract libtinfo5 from Ubuntu 22.04 archives when:

    • OS is Linux
    • LLVM major version < 19
    • Architecture is amd64 or aarch64
  2. Modifies toolchain/cc_wrapper.sh.tpl to prepend LD_LIBRARY_PATH with the toolchain's lib directory on Linux, so the injected library is found.

Implementation Details

Patch file to create: bazel-registry/modules/toolchains_llvm/1.6.0.envoy/patches/libtinfo5_fix.patch

The patch should:

For toolchain/cc_wrapper.sh.tpl - Add after the clang existence check (around line 87):

# Inject libtinfo5 path if present to fix issues on Ubuntu 24.04+
if [[ "$(uname -s)" == "Linux" ]]; then
  export LD_LIBRARY_PATH="${toolchain_path_prefix}lib:${LD_LIBRARY_PATH}"
fi

For toolchain/internal/repo.bzl - Add after updated_attrs = _download_llvm(rctx) (around line 438):

    # Inject libtinfo5 for older LLVMs on Linux
    # LLVM < 19 depends on libtinfo.so.5 which is missing on Ubuntu 24.04+
    if os == "linux" and major_llvm_version < 19:
        libtinfo_map = {
            "amd64": {
                "url": "http://security.ubuntu.com/ubuntu/pool/universe/n/ncurses/libtinfo5_6.3-2ubuntu0.1_amd64.deb",
                "sha256": "ab89265d8dd18bda6a29d7c796367d6d9f22a39a8fa83589577321e7caf3857b",
                "path": "./lib/x86_64-linux-gnu/libtinfo.so.5.9"
            },
            "aarch64": {
                "url": "http://ports.ubuntu.com/pool/universe/n/ncurses/libtinfo5_6.3-2ubuntu0.1_arm64.deb",
                "sha256": "be34705c5d2952298f480b4b571b382e7c921d65195889e6870b55ad834ce02c",
                "path": "./lib/aarch64-linux-gnu/libtinfo.so.5.9"
            }
        }
        
        arch_info = libtinfo_map.get(rctx.os.arch)
        
        if arch_info:
            print("DEBUG: Injecting libtinfo5 compatibility lib for " + rctx.os.arch)
            rctx.download(
                url = arch_info["url"],
                sha256 = arch_info["sha256"],
                output = "libtinfo5.deb",
            )
            rctx.execute(["ar", "x", "libtinfo5.deb", "data.tar.xz"])
            rctx.execute(["tar", "-xf", "data.tar.xz", "--strip-components=3", "-C", "lib", arch_info["path"]])
            rctx.execute(["ln", "-s", "libtinfo.so.5.9", "lib/libtinfo.so.5"])

Update source.json

After creating the patch file, update bazel-registry/modules/toolchains_llvm/1.6.0.envoy/source.json to include the new patch. The SHA256 of the patch file must be calculated correctly.

CRITICAL INSTRUCTIONS

  1. SHA256 checksums for the .deb files are VERIFIED - use exactly:

    • amd64: ab89265d8dd18bda6a29d7c796367d6d9f22a39a8fa83589577321e7caf3857b
    • arm64: be34705c5d2952298f480b4b571b382e7c921d65195889e6870b55ad834ce02c
  2. The patch file's SHA256 for source.json must be calculated AFTER creating the patch file - do not use a placeholder.

  3. The patch must be a valid unified diff that applies cleanly to toolchains_llvm v1.6.0.

  4. Reference the actual source files from https://github.com/bazel-contrib/toolchains_llvm at tag v1.6.0 to get correct line numbers for the patch.

  5. The logic must be safe - if the architecture is not in the map, it should skip gracefully (no error).

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@netlify
Copy link

netlify bot commented Jan 23, 2026

Deploy Preview for nifty-bassi-e26446 ready!

Name Link
🔨 Latest commit 4fb34d5
🔍 Latest deploy log https://app.netlify.com/projects/nifty-bassi-e26446/deploys/69737ab0254e1c0008e324f9
😎 Deploy Preview https://deploy-preview-3589--nifty-bassi-e26446.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Co-authored-by: phlax <454682+phlax@users.noreply.github.com>
Copilot AI changed the title [WIP] Add patch for libtinfo.so.5 dependency in LLVM Add libtinfo5 compatibility patch for LLVM < 19 on Ubuntu 24.04+ Jan 23, 2026
Copilot AI requested a review from phlax January 23, 2026 13:44
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

Successfully merging this pull request may close these issues.

2 participants