Skip to content

Create symlink for llvm-link in libc docker image#210929

Merged
jinge90 merged 6 commits into
llvm:mainfrom
jinge90:update_libc_container
Jul 24, 2026
Merged

Create symlink for llvm-link in libc docker image#210929
jinge90 merged 6 commits into
llvm:mainfrom
jinge90:update_libc_container

Conversation

@jinge90

@jinge90 jinge90 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

We are working on using llvm-link to build LLVM libc bitcode library for GPU targets. In standalone build environment which amd-gpu pre-ci uses, only clang-23, clang++-23, lld-23 and llvm-23-tools are installed and added to /usr/bin path. This PR creates symlink for llvm-link.

Signed-off-by: jinge90 <ge.jin@intel.com>
@llvmorg-github-actions

Copy link
Copy Markdown

@llvm/pr-subscribers-github-workflow

Author: jinge90

Changes

Full diff: https://github.com/llvm/llvm-project/pull/210929.diff

1 Files Affected:

  • (modified) .github/workflows/containers/libc/Dockerfile (+4-2)
diff --git a/.github/workflows/containers/libc/Dockerfile b/.github/workflows/containers/libc/Dockerfile
index 1367b89fab104..1794ea3f3da8b 100644
--- a/.github/workflows/containers/libc/Dockerfile
+++ b/.github/workflows/containers/libc/Dockerfile
@@ -51,8 +51,10 @@ RUN wget https://apt.llvm.org/llvm.sh && \
 # testing CI for libc-based compiler-rt builtins. The package only symlinks
 # the tools into /usr/bin under versioned names (lit-23, FileCheck-23, ...),
 # so also symlink them under their canonical names.
-RUN apt-get install -y llvm-23-tools && \
-    ln -s -t /usr/bin $(dpkg -L llvm-23-tools | grep '^/usr/lib/llvm-23/bin/')
+# Also install LLVM tools to include llvm-link, we use it to build bitcode
+# for GPU targets.
+RUN apt-get install -y llvm-23-tools llvm-23 && \
+    ln -s -t /usr/bin $(dpkg -L llvm-23-tools llvm-23 | grep '^/usr/lib/llvm-23/bin/')
 
 
 # Install gmp and mpfr for cross compilation

@jinge90 jinge90 changed the title Install llvm 23 in libc docker image Install llvm-23 in libc docker image Jul 21, 2026

@boomanaiden154 boomanaiden154 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no package more specific than general llvm-23 that would work here?

@jinge90

jinge90 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

There's no package more specific than general llvm-23 that would work here?

Hi, @boomanaiden154
I am afraid there is no more specific package which can work here. The docker image is ubuntu, I used apt search to list all llvm related packages and checked them all, only llvm-23 includes llvm-link. Other packages are:
llvm-23-dev: llvm libraries and headers
llvm-23-linker-tools: linker plugin libraries
llvm-23-tools (already included in the image): tools used in testing
llvm-23-runtime: lli

Thanks very much.

@jinge90
jinge90 requested a review from boomanaiden154 July 22, 2026 01:47

@boomanaiden154 boomanaiden154 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you collect numbers on how much this increases the container image size?

@jinge90

jinge90 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Can you collect numbers on how much this increases the container image size?

Hi, @boomanaiden154
To my surprise, there is almost no image size increase at all. I created the docker image using previous Dockfile and find /usr/lib/llvm-23/bin/llvm-link does exist but the symbolic link "/usr/bin/llvm-link" is not created.
After applying the change to Dockfile, I create a new image and both llvm-23/bin/llvm-link and /usr/bin/llvm-link exists since we explicitly install llvm-23 and creates symbolic link in this PR.
The image size keeps 4.67 GB before and after applying this PR.
The llvm.sh 23 will install clang-23, so I manually run 'apt install clang-23' in my local ubuntu 24.04 and find all tools such as llvm-tool, llvm-readobj.... are installed into /usr/lib/llvm-23/bin, this aligns with my observation.
Although apt install -y llvm-23-tools llvm-23 seems to be redundant, I prefer to keeping them to make the dependency clear.
Thanks very much.

@jinge90
jinge90 requested a review from boomanaiden154 July 22, 2026 07:15
@boomanaiden154

Copy link
Copy Markdown
Contributor

I created the docker image using previous Dockfile and find /usr/lib/llvm-23/bin/llvm-link

Then can we just create a symlink rather than installing additional packages?

@jinge90

jinge90 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

I created the docker image using previous Dockfile and find /usr/lib/llvm-23/bin/llvm-link

Then can we just create a symlink rather than installing additional packages?

Hi, @boomanaiden154
I expect it should work if we just create a symlink since these binaries (llvm-link, llvm-objdump, llvm-readelf...) have been already installed together with clang-23.
However, is it acceptable if we keep apt-get install llvm-23? I prefer it for 2 reasons:

  1. it has no impact to image size
  2. we already did the same thing for llvm-23-tools and aligning with llvm-23-tools makes the logic more clear and unified.

Thanks very much.

@boomanaiden154

Copy link
Copy Markdown
Contributor

it has no impact to image size

This I'm a bit skeptical of, but if I guess llvm-23 is a metapackage where we already install all of its dependents, it makes sense.

we already did the same thing for llvm-23-tools and aligning with llvm-23-tools makes the logic more clear and unified.

This argument does not make any sense to me. Neither llvm-23-tools nor llvm-23 really seem to indicate that they have llvm-link in them. I think keeping llvm-23 makes the meaning less clear. If llvm-23 pulls in additional dependencies that we don't already have installed, this will also result in an image size regression.

@jinge90

jinge90 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

it has no impact to image size

This I'm a bit skeptical of, but if I guess llvm-23 is a metapackage where we already install all of its dependents, it makes sense.

we already did the same thing for llvm-23-tools and aligning with llvm-23-tools makes the logic more clear and unified.

This argument does not make any sense to me. Neither llvm-23-tools nor llvm-23 really seem to indicate that they have llvm-link in them. I think keeping llvm-23 makes the meaning less clear. If llvm-23 pulls in additional dependencies that we don't already have installed, this will also result in an image size regression.

Hi, @boomanaiden154
Got it, I will update the PR to directly create a symbolic link for llvm-link once I finished verification locally.
Thanks very much.

Signed-off-by: jinge90 <ge.jin@intel.com>
@jinge90

jinge90 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

I created the docker image using previous Dockfile and find /usr/lib/llvm-23/bin/llvm-link

Then can we just create a symlink rather than installing additional packages?

Hi, @boomanaiden154 I expect it should work if we just create a symlink since these binaries (llvm-link, llvm-objdump, llvm-readelf...) have been already installed together with clang-23. However, is it acceptable if we keep apt-get install llvm-23? I prefer it for 2 reasons:

  1. it has no impact to image size
  2. we already did the same thing for llvm-23-tools and aligning with llvm-23-tools makes the logic more clear and unified.

Thanks very much.

Hi, @boomanaiden154
I updated the PR to create symlink directly instead of installing llvm-23, could you help review again?
Thanks very much.

Signed-off-by: jinge90 <ge.jin@intel.com>
@jinge90 jinge90 closed this Jul 23, 2026
@jinge90 jinge90 reopened this Jul 23, 2026
@jinge90 jinge90 changed the title Install llvm-23 in libc docker image Create symlink for llvm-link in libc docker image Jul 23, 2026

@boomanaiden154 boomanaiden154 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you collect numbers on how much this increases the container image size?

ln -s -t /usr/bin $(dpkg -L llvm-23-tools | grep '^/usr/lib/llvm-23/bin/')

# llvm-link is required to build bitcode library for GPU targets
RUN if [ ! -e /usr/bin/llvm-link ]; then \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can drop the if statement and only keep the ln -s command, and also fold this into the previous RUN line.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @boomanaiden154
Done.
Thanks very much.

Signed-off-by: jinge90 <ge.jin@intel.com>
@jinge90

jinge90 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

Can you collect numbers on how much this increases the container image size?

Hi, @boomanaiden154
In my local machine, the image size increase 586 bytes after the change. The total image size is 4.67G.
Thanks very much.

@boomanaiden154 boomanaiden154 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jinge90
jinge90 merged commit 7d13e22 into llvm:main Jul 24, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants