Skip to content

Conversation

@kraj
Copy link
Contributor

@kraj kraj commented Oct 28, 2025

…RUNTIME_DIR is unset

current logic fails when LLVM_ENABLE_PER_TARGET_RUNTIME_DIR = OFF and it ends up with symlinks e.g.

libgcc.a -> ..//usr/lib/clang/21.1.4/lib/linux/libclang_rt.builtins.a

the real library is at
../lib/clang/21.1.4/lib/linux/libclang_rt.builtins-aarch64.a

The relative path is incorrect and its missing to add -arch suffix as well.

So we make checks a bit more explicit to cover this case.

The symlink for libgcc_so.1.0 is made to point to libunwind.so which is functionally correct but it fails some linux distro packaging complain because libunwind.so is made part of -dev package but libgcc_so.1.0 ends up in the real package, and creates an unneeded package -> dev dependency

create the symlink to point to libunwind.so.1 instead then the boundaries of packaging are not crossed and all is well.

The symlink for libgcc_so.1.0 is made to point to libunwind.so
which is functionally correct but it fails some linux distro packaging
complain because libunwind.so is made part of -dev package but
libgcc_so.1.0 ends up in the real package, and creates an unneeded
package -> dev dependency

create the symlink to point to libunwind.so.1 instead then the boundaries
of packaging are not crossed and all is well.
@kraj kraj force-pushed the users/kraj/llvm-libgcc-symlink-fixes branch from 4204fd1 to d21ab66 Compare October 29, 2025 00:24
@kraj kraj requested a review from petrhosek October 29, 2025 01:41
…UNTIME_DIR=OFF

The llvm-libgcc installation was creating incorrect symlinks for libgcc.a
when built with LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF, particularly seen with
Yocto cross-compilation environments.

Issues seen:

-  Absolute path in symlink: The previous code didn't handle absolute paths
   returned by get_compiler_rt_install_dir() in staging/sysroot environments,
   resulting in symlinks like:
   libgcc.a -> /absolute/path/to/sysroot/usr/lib/clang/.../libclang_rt.builtins.a

-  Missing architecture suffix: When the install path contained "clang", the
   code would skip setting builtins_suffix, creating:
   libgcc.a -> clang/21.1.4/lib/linux/libclang_rt.builtins.a
   instead of:
   libgcc.a -> clang/21.1.4/lib/linux/libclang_rt.builtins-aarch64.a

-  Incorrect relative path calculation: The original regex stripped too much
   or too little of the path, either creating symlinks pointing to non-existent
   locations or stripping the clang/ directory prefix entirely.

Solution:

- Extract the relative path starting from 'clang/' when present in absolute
  paths, ensuring the symlink points to the correct location within the
  installation hierarchy
- Always append the architecture suffix to the builtins library name
- Only prepend '../' to the path when LLVM_ENABLE_PER_TARGET_RUNTIME_DIR is
  enabled, as this is when the builtins are in a different directory level

The symlink now correctly points to the existing compiler-rt builtins library
without creating duplicate copies.

Tested with LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF in cross-compilation
environments (aarch64 target).
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