FS#77691 - [llvm] Compile broken after update...

Attached to Project: Arch Linux
Opened by Jordan Malek (jakjm) - Wednesday, 01 March 2023, 15:07 GMT
Last edited by Evangelos Foutras (foutrelis) - Saturday, 25 March 2023, 12:25 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Evangelos Foutras (foutrelis)
Architecture x86_64
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 2
Private No

Details

Description: Problem when compiling with clang and llvm-15.0.7-2

Receiving the following errors following the update from llvm-15.0.7-1 to 15.0.7-2
when I compile my project.
/usr/bin/ld: cannot find -lLLVMBitWriter: No such file or directory
/usr/bin/ld: cannot find -lLLVMCore: No such file or directory

Steps to reproduce:
invoke clang or g++ using the -lLLVMBitWriter and -lLLVMCore library options.
Additional info:
* package version(s)
* config and/or log files etc.
* link to upstream bug report, if any

Steps to reproduce:
This task depends upon

Closed by  Evangelos Foutras (foutrelis)
Saturday, 25 March 2023, 12:25 GMT
Reason for closing:  Won't fix
Additional comments about closing:  Please try using the "llvm_config(foo USE_SHARED <list-of-components>)" macro in your CMake project.
Comment by Jordan Malek (jakjm) - Wednesday, 01 March 2023, 16:52 GMT
I have downgraded to 15.0.7-1 and I have confirmed I no longer have the issue. So I believe indeed 15.0.7-2 is causing the issue.
Comment by Michel Koss (MichelKoss1) - Wednesday, 01 March 2023, 21:00 GMT
Perhaps your project should learn to use llvm-config:

$ llvm-config --libs Core
-lLLVM-15
$ llvm-config --libs BitWriter
-lLLVM-15

The libs are there. Try running:
g++ `llvm-config --libs Core BitWriter`
Comment by Jordan Malek (jakjm) - Wednesday, 01 March 2023, 22:23 GMT
Thank you very much for your reply.
The project uses CMake and I believe it's using the files inside /usr/lib/cmake/llvm (which I see is also provided by the llvm package) in order to generate the flags it uses somehow,
such as LLVMConfig.cmake
I am going to do a little snooping to see if I might stumble upon where the flag is being added - I don't have any experience with cmake so I won't be very efficient.


Comment by Jordan Malek (jakjm) - Wednesday, 01 March 2023, 22:52 GMT
I haven't been able to find anything - I'm going to keep using the downgraded version for now because I'm not sure how to fix the project configuration
is it possible that one the of the files in the package (such as the files inside /usr/lib/cmake/llvm) adds the BitWriter and Core flag? Or is it the project that is at fault?
Comment by Toolybird (Toolybird) - Thursday, 02 March 2023, 03:57 GMT
Obviously due to static libs removal in  FS#77644  (note especially the last comment in that ticket). Also note PM's commit message "Let's see if anything breaks after we remove them." It seems likely that projects will need to adapt.
Comment by Evangelos Foutras (foutrelis) - Friday, 03 March 2023, 05:07 GMT
LLVM's CMake files have always been a bit weird in how they (don't) handle linking to LLVM as a shared library. [1]

Most projects using CMake likely implement workarounds to be able to successfully link to libLLVM (instead of the individual component libraries).

[1] https://bugs.llvm.org/show_bug.cgi?id=35245
Comment by Jules Pénuchot (jpenuchot) - Monday, 06 March 2023, 23:38 GMT
The last change on LLVM packaging broke the CMake part to a point where one of the simplest examples of the CMake documentation can't even build on Arch, eg. this line:

```
llvm_map_components_to_libnames(llvm_libs support core irreader)
```

Source: https://llvm.org/docs/CMake.html#embedding-llvm-in-your-project
Comment by Jules Pénuchot (jpenuchot) - Friday, 24 March 2023, 22:04 GMT
So are we getting an update on this issue? Or will the package remain in a broken state forever?
Comment by Evangelos Foutras (foutrelis) - Saturday, 25 March 2023, 12:24 GMT
I do not intent to add the static libraries back because of this issue. Your CMake project(s) could be adjusted to link dynamically to LLVM. (FWIW, this is also how LLVM is packaged on Gentoo.)

I believe this should work for most cases: llvm_config(foo USE_SHARED <list-of-components>)

Again, the upstream issue for this is: https://github.com/llvm/llvm-project/issues/34593

Loading...