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

Linker issue with libclang_rt.builtins.a #6513

Open
ritikanair03 opened this issue Aug 2, 2022 · 7 comments
Open

Linker issue with libclang_rt.builtins.a #6513

ritikanair03 opened this issue Aug 2, 2022 · 7 comments
Labels
hip Issues related to execution on HIP backend.

Comments

@ritikanair03
Copy link

Running into this error while using the latest version of compiler with hip backend:
/opt/compiler/llvm/clang/test/Driver/Inputs/debian_per_target_tree/usr/lib/llvm-14/lib/clang/14.0.0/lib/x86_64-linux-gnu/libclang_rt.builtins.a: file not recognized: File truncated
Please provide a solution.

@bader
Copy link
Contributor

bader commented Aug 2, 2022

Something is wrong with your environment.
Remove /opt/compiler/llvm/clang/test/Driver/Inputs/debian_per_target_tree path from your environment variables or better start with clean environment if possible.

@ritikanair03
Copy link
Author

ritikanair03 commented Aug 3, 2022

We need libclang_rt.builtins.a file from the compiler to build a library.
While that file was present in the compiler but it is empty and didn't get created.

@bader
Copy link
Contributor

bader commented Aug 3, 2022

Are we talking about DPC++ compiler? AFAIK, DPC++ compiler doesn't use this library. I think it uses libgcc_s instead.
I'm not that familiar with HIP back-end, but I don't expect it to use different compiler built-in library.

@bader bader added the hip Issues related to execution on HIP backend. label Aug 3, 2022
@ritikanair03
Copy link
Author

we're using Intel LLVM compiler built for HIP backend with the following configuration:

export CC=gcc
export CXX=g++

export DPCPPCOMPROOT=/opt/compiler/llvm
python3 $DPCPPCOMPROOT/buildbot/configure.py -s $DPCPPCOMPROOT -o $DPCPPCOMPROOT/build --cmake-opt="-DLLVM_ENABLE_RUNTIMES=compiler-rt" -t release --shared-libs --hip
python3 $DPCPPCOMPROOT/buildbot/compile.py -s $DPCPPCOMPROOT/llvm -o $DPCPPCOMPROOT/build

And we're expecting the compiler to build libclang_rt.builtins.a file which we need to link with a library

@bader
Copy link
Contributor

bader commented Aug 3, 2022

We don't test this configuration, so I'm not sure if we can provide much help.

  1. I've found -print-libgcc-file-name option in clang's documentation, which might be useful. It "prints the library path for the currently used compiler runtime library ("libgcc.a" or "libclang_rt.builtins.*.a")."
  2. "You can instruct Clang to use compiler-rt with the --rtlib=compiler-rt flag. This is not supported on every platform." from https://clang.llvm.org/docs/Toolchain.html#compiler-rt-llvm. I'm not sure if this is set by default when compiler-rt runtime library build is ON.

Building libclang_rt.builtins.a is not related to DPC++ project, so you might want to contact compiler-rt developers via Discourse - https://discourse.llvm.org/c/runtimes/64.

One more note: don't use --shared-libs. According to LLVM documentation, it's intended for compiler developer's convenience (to speed-up incremental builds specifically) and not intended for building a production compiler.

@npmiller
Copy link
Contributor

And we're expecting the compiler to build libclang_rt.builtins.a file which we need to link with a library

The default target of compile.py is deploy-sycl-toolchain which I don't think includes compiler-rt, try to compile it manually afterwards:

python3 $DPCPPCOMPROOT/buildbot/compile.py -s $DPCPPCOMPROOT/llvm -o $DPCPPCOMPROOT/build
cd $DPCPPCOMPROOT/build
ninja install-compiler-rt

This should hopefully build libclang_rt.builtins.a and install it alongside the compiler.

@abagusetty
Copy link
Contributor

If this is associated with oneMKL related for HIP backend, please refer to the following threads (for workaround) in addition to the above:
oneapi-src/oneMKL#336

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hip Issues related to execution on HIP backend.
Projects
No open projects
oneAPI DPC++
  
Awaiting Triage
Development

No branches or pull requests

4 participants