Community Packages

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#72726 - [antlr4-runtime] Missing static library breaks CMake config file

Attached to Project: Community Packages
Opened by Tobias Markus (netcrusher) - Friday, 12 November 2021, 15:16 GMT
Last edited by Antonio Rojas (arojas) - Friday, 12 November 2021, 17:22 GMT
Task Type Bug Report
Category Packages
Status Assigned
Assigned To Christian Hesse (eworm)
Konstantin Gizdov (kgizdov)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 0
Private No

Details

Description:
The antlr4-runtime CMake build system defaults to building and installing both a static and a shared version of the runtime (targets antlr4-shared and antlr4-static in CMake). The exported CMake config files (antlr4-targets.cmake and antlr4-targets-release.cmake in /usr/lib/cmake/antlr4-runtime) also include the static target antlr4-static. However, makepkg automatically removes static libraries, resulting in a package that mentions the static version in the CMake config script while the static library does not actually exist in the final package.

This situation in turn breaks the CMake scripts since they check whether the exported targets are actually present. Example output:

CMake Error at /usr/lib64/cmake/antlr4-runtime/antlr4-targets.cmake:82 (message):
The imported target "antlr4_static" references the file

"/usr/lib/libantlr4-runtime.a"

but this file does not exist. Possible reasons include:

* The file was deleted, renamed, or moved to another location.

* An install or uninstall procedure did not complete successfully.

* The installation package was faulty and contained

"/usr/lib64/cmake/antlr4-runtime/antlr4-targets.cmake"

but not all the files it references.

Call Stack (most recent call first):
/usr/lib64/cmake/antlr4-runtime/antlr4-runtime-config.cmake:42 (include)
CMakeLists.txt:34 (find_package)


-- Configuring incomplete, errors occurred!

In this case, reason number 3 obviously applies.

I could also reproduce the cause of the issue by building the PKGBUILD locally and observing that CMake installs libantlr4-runtime.a to the pkg directory, but makepkg removes it.

Additional info:
* Package Version: antlr4-runtime 4.9.3

Steps to reproduce:
1. Install antlr4-runtime
2. Observe that /usr/lib/libantlr4-runtime.a does not exist:

$ ls /usr/lib/libantlr4-runtime.a
ls: cannot access '/usr/lib/libantlr4-runtime.a': No such file or directory

3. Observe that antlr4_static (/usr/lib/libantlr4-runtime.a) is mentioned in CMake target export files:

$ grep -rn antlr4_static /usr/lib/cmake/antlr4-runtime
/usr/lib/cmake/antlr4-runtime/antlr4-targets-release.cmake:19:# Import target "antlr4_static" for configuration "Release"
/usr/lib/cmake/antlr4-runtime/antlr4-targets-release.cmake:20:set_property(TARGET antlr4_static APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
/usr/lib/cmake/antlr4-runtime/antlr4-targets-release.cmake:21:set_target_properties(antlr4_static PROPERTIES
/usr/lib/cmake/antlr4-runtime/antlr4-targets-release.cmake:27:list(APPEND _IMPORT_CHECK_TARGETS antlr4_static )
/usr/lib/cmake/antlr4-runtime/antlr4-targets-release.cmake:28:list(APPEND _IMPORT_CHECK_FILES_FOR_antlr4_static "${_IMPORT_PREFIX}/lib/libantlr4-runtime.a" )
/usr/lib/cmake/antlr4-runtime/antlr4-targets.cmake:19:foreach(_expectedTarget antlr4_shared antlr4_static)
/usr/lib/cmake/antlr4-runtime/antlr4-targets.cmake:65:# Create imported target antlr4_static
/usr/lib/cmake/antlr4-runtime/antlr4-targets.cmake:66:add_library(antlr4_static STATIC IMPORTED)

4. Observe that "find_package(antlr4-runtime)" in CMake scripts fails (see example above)
This task depends upon

Comment by Konstantin Gizdov (kgizdov) - Friday, 12 November 2021, 17:41 GMT
By default, I think makepkg removes static librarties. And it also seems like there is no simple way of not including it. I will push a package to include it until we decide how to handle at least to fix the repo package. @eworm, do you have a preference on what to do about this?
Comment by Konstantin Gizdov (kgizdov) - Friday, 12 November 2021, 17:42 GMT
community/antlr4-runtime 4.9.3-2 has the static lib in it now.
Comment by Christian Hesse (eworm) - Friday, 26 November 2021, 13:09 GMT
I vote for not including static libraries if possible. Static linking is a mess where no one knows what, when and why to rebuild.
So if it is possible easily let's drop the static library and adjust the cmake files accordingly.
Comment by Konstantin Gizdov (kgizdov) - Friday, 26 November 2021, 14:16 GMT
I've tried to pass a bunch of flags, but nothing has worked. We probably need to patch their CMake.
Comment by Konstantin Gizdov (kgizdov) - Monday, 14 March 2022, 15:02 GMT
From their extensive docs on the matter, I believe they see the static lib as a major component of the way they support and distribute the C++ runtime, so I think we should leave it in.

Loading...