Bug 1086445 - libLLVMTableGen not packaged
libLLVMTableGen not packaged
Status: RESOLVED FIXED
Classification: openSUSE
Product: openSUSE Tumbleweed
Classification: openSUSE
Component: Development
Current
Other Other
: P5 - None : Normal (vote)
: ---
Assigned To: Michal Srb
E-mail List
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2018-03-22 11:00 UTC by Guillaume GARDET
Modified: 2021-11-19 01:40 UTC (History)
4 users (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Guillaume GARDET 2018-03-22 11:00:37 UTC
Currently, in Tumbleweed, LLVM only packages libLLVM.so* and we are missing additional libraries, such as libLLVMTableGen.so*

Some packages fails to build (e.g. ldc package) because of the missing additional libraries.
Comment 1 Michal Srb 2018-05-14 07:24:21 UTC
In the past we used to build each LLVM component into a separate shared library. However, that build mode is only meant for LLVM developers and is not meant to be used in production. For example it causes issues when the library gets reloaded. So we switched to the recommended build mode where all LLVM components end in single libLLVM.so library.

You can check the output of llvm-config:

> > llvm-config --libs tablegen
> -lLLVM
> > llvm-config --libfiles tablegen
> /usr/lib64/libLLVM.so

I have tried to build devel:languages:D/ldc locally and it is failing with compilation errors (not configuration or linking). The errors look to me like it is expecting older version of LLVM.

The devel:languages:D/ldc version is 0.17.4, while the newest seem to be 1.9.0 and that one reportedly supports LLVM 6.

Please reopen if there is up-to-date version of ldc that fails to build with LLVM.
Comment 2 Guillaume GARDET 2018-05-15 08:54:56 UTC
0.17.5 is the latest version to bootstrap (not using D compiler).

After backporting patches to add support to LLVM6 and only use -lLLVM, I still get linker errors in Tumbleweed:

[  136s] CMakeFiles/gen_gccbuiltins.dir/utils/gen_gccbuiltins.cpp.o: In function `dtype[abi:cxx11](llvm::Record*, bool)':
[  136s] /home/abuild/rpmbuild/BUILD/ldc-0.17.5-src/utils/gen_gccbuiltins.cpp:34: undefined reference to `llvm::Record::getValueInit(llvm::StringRef) const'
[  136s] CMakeFiles/gen_gccbuiltins.dir/utils/gen_gccbuiltins.cpp.o: In function `attributes[abi:cxx11](llvm::ListInit*)':
[  136s] /home/abuild/rpmbuild/BUILD/ldc-0.17.5-src/utils/gen_gccbuiltins.cpp:91: undefined reference to `llvm::ListInit::getElementAsRecord(unsigned int) const'
[  136s] /home/abuild/rpmbuild/BUILD/ldc-0.17.5-src/utils/gen_gccbuiltins.cpp:91: undefined reference to `llvm::Record::getName() const'
[  136s] CMakeFiles/gen_gccbuiltins.dir/utils/gen_gccbuiltins.cpp.o: In function `getValue':
[  136s] /usr/include/llvm/TableGen/Record.h:1352: undefined reference to `llvm::StringInit::get(llvm::StringRef)'
[  136s] CMakeFiles/gen_gccbuiltins.dir/utils/gen_gccbuiltins.cpp.o: In function `processRecord(llvm::raw_ostream&, llvm::Record&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
[  136s] /home/abuild/rpmbuild/BUILD/ldc-0.17.5-src/utils/gen_gccbuiltins.cpp:104: undefined reference to `llvm::Record::getValueAsString(llvm::StringRef) const'
[  136s] /home/abuild/rpmbuild/BUILD/ldc-0.17.5-src/utils/gen_gccbuiltins.cpp:105: undefined reference to `llvm::Record::getName() const'
[  136s] /home/abuild/rpmbuild/BUILD/ldc-0.17.5-src/utils/gen_gccbuiltins.cpp:115: undefined reference to `llvm::Record::getValueAsListInit(llvm::StringRef) const'
[  136s] /home/abuild/rpmbuild/BUILD/ldc-0.17.5-src/utils/gen_gccbuiltins.cpp:125: undefined reference to `llvm::ListInit::getElementAsRecord(unsigned int) const'
[  136s] /home/abuild/rpmbuild/BUILD/ldc-0.17.5-src/utils/gen_gccbuiltins.cpp:125: undefined reference to `llvm::Record::getName() const'
[  136s] /home/abuild/rpmbuild/BUILD/ldc-0.17.5-src/utils/gen_gccbuiltins.cpp:129: undefined reference to `llvm::Record::getValueAsListInit(llvm::StringRef) const'
[  136s] /home/abuild/rpmbuild/BUILD/ldc-0.17.5-src/utils/gen_gccbuiltins.cpp:139: undefined reference to `llvm::ListInit::getElementAsRecord(unsigned int) const'
[  136s] /home/abuild/rpmbuild/BUILD/ldc-0.17.5-src/utils/gen_gccbuiltins.cpp:146: undefined reference to `llvm::Record::getValueAsListInit(llvm::StringRef) const'
[  136s] /home/abuild/rpmbuild/BUILD/ldc-0.17.5-src/utils/gen_gccbuiltins.cpp:157: undefined reference to `llvm::ListInit::getElementAsRecord(unsigned int) const'
[  136s] CMakeFiles/gen_gccbuiltins.dir/utils/gen_gccbuiltins.cpp.o: In function `main':
[  136s] /home/abuild/rpmbuild/BUILD/ldc-0.17.5-src/utils/gen_gccbuiltins.cpp:219: undefined reference to `llvm::TableGenMain(char*, bool (*)(llvm::raw_ostream&, llvm::RecordKeeper&))'
[  136s] clang-6.0.0: error: linker command failed with exit code 1 (use -v to see invocation)
Comment 3 Michal Srb 2018-05-15 09:36:11 UTC
You are right, those symbols are in the installed header files, but not in the LLVM library. I need to investigate what is up with that.
Comment 4 Michal Srb 2018-05-15 11:18:14 UTC
Turns out the tablegen component is excluded from the libLLVM library intentionally. Here is comment from cmake file that does it:

  # Also exclude libLLVMTableGen for the following reasons:
  #  - it is only used by internal *-tblgen utilities;
  #  - it pollutes the global options space.

But apparently ldc needs it to build. I am thinking of one of following solutions, each has some drawback:
* Modify libLLVM to include the tablegen component. We risk problems from conflicting options between tablegen and other llvm/clang tools.
* Build the component into a separate libLLVMTableGen.so library. We would have to hack it into the build system to produce it even that we don't produce any other components as individual libraries.
* Export the libLLVMTableGen.a in some llvm-devel-static package. (But our guidelines recommend to not distribute static libraries unless really necessary...)
Comment 5 Guillaume GARDET 2018-05-15 11:46:36 UTC
Fedora exports the single libLLVM.so but also each LLVM lib into a static .a lib. You may do something similar. That way, we do not risk to break something, but still be able to use a particular library when needed, such as in ldc case.
Comment 6 Michal Srb 2018-05-15 14:32:46 UTC
I have went with the second option and modified LLVM to build TableGen into its own libLLVMTableGen.so library. So it is back again, but all the other components remain in libLLVM.

It is currently building in OBS in home:michalsrb:branches:devel:tools:compiler/llvm6. Please test if you can build ldc against it.
Comment 7 Guillaume GARDET 2018-05-15 16:36:25 UTC
(In reply to Michal Srb from comment #6)
> I have went with the second option and modified LLVM to build TableGen into
> its own libLLVMTableGen.so library. So it is back again, but all the other
> components remain in libLLVM.
> 
> It is currently building in OBS in
> home:michalsrb:branches:devel:tools:compiler/llvm6. Please test if you can
> build ldc against it.

llvm6 does not build in your home project.
Comment 8 Michal Srb 2018-05-31 15:39:51 UTC
(In reply to Guillaume GARDET from comment #7)
> llvm6 does not build in your home project.

You are right, sorry. It takes long time to build llvm in build service, so I did quick local build, but forgot to enable checks. The modifications I did were incorrect and the build failed on the checks.

It took a while, but now I made another version that seems to work. It is building now and should be ready in few hours. (It succeeded locally with checks and I did some manual testing as well.)

Please try if you can build ldc with it.
Comment 9 Guillaume GARDET 2018-06-01 12:42:24 UTC
(In reply to Michal Srb from comment #8)
> Please try if you can build ldc with it.

Yes, I can build ldc 0.17.5 with your patched llvm. Thanks.

You can push it to devel and Factory.
Comment 10 Michal Srb 2018-06-01 13:11:00 UTC
Submitted to Factory:
https://build.opensuse.org/request/show/613475
Comment 11 Aaron Puchert 2020-02-14 01:40:40 UTC
It seems that the final ldc package doesn't depend on libLLVMTableGen.so. [1]

Is the library only needed for the build process? If it is, I would consider moving it from libLLVM* to llvm*-devel.

[1] https://build.opensuse.org/package/binaries/devel:languages:D/ldc/openSUSE_Tumbleweed
Comment 12 Guillaume GARDET 2020-02-14 07:20:11 UTC
(In reply to Aaron Puchert from comment #11)
> It seems that the final ldc package doesn't depend on libLLVMTableGen.so. [1]
> 
> Is the library only needed for the build process? If it is, I would consider
> moving it from libLLVM* to llvm*-devel.

No, llvm package itself requires it.
Comment 13 Aaron Puchert 2020-02-14 12:01:14 UTC
Sure, but I can link llvm-tblgen to LLVMTableGen statically, as upstream does it. The question is where LLVMTableGen is otherwise required.
Comment 14 Guillaume GARDET 2020-02-14 12:28:46 UTC
(In reply to Aaron Puchert from comment #13)
> Sure, but I can link llvm-tblgen to LLVMTableGen statically, as upstream
> does it. The question is where LLVMTableGen is otherwise required.

I do not know, sorry.
Comment 15 Aaron Puchert 2020-02-14 22:54:56 UTC
LLVMTableGen is referenced in utils/CMakeLists.txt [1] for utils/gen_gccbuiltins.cpp [2], so it seems to be a genuine dependency. According to the header of gen_gccbuiltins.cpp, it should only be required for building the compiler.

But since the library is a pretty small part of libLLVM*, it makes probably no sense to move it.

[1] https://github.com/ldc-developers/ldc/blob/master/utils/CMakeLists.txt
[2] https://github.com/ldc-developers/ldc/blob/master/utils/gen_gccbuiltins.cpp
Comment 17 OBSbugzilla Bot 2020-07-24 06:51:01 UTC
This is an autogenerated message for OBS integration:
This bug (1086445) was mentioned in
https://build.opensuse.org/request/show/822551 Factory / llvm10
Comment 18 OBSbugzilla Bot 2021-11-19 01:40:59 UTC
This is an autogenerated message for OBS integration:
This bug (1086445) was mentioned in
https://build.opensuse.org/request/show/932377 Backports:SLE-15-SP3 / llvm12