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

Use version-script with cmake builds #776

Merged
merged 2 commits into from
Mar 23, 2023

Conversation

opoplawski
Copy link
Contributor

@opoplawski opoplawski commented Nov 19, 2022

This is an attempt to resurrect symbol versioning and fix #775 . One problem is the new unit tests that link to libclamav and test internal functions do not have access to the symbols. I started adding them to the symbol map, but I don't think this is the proper solution. I think instead there perhaps be a static library that is used for the unit tests?

@opoplawski
Copy link
Contributor Author

We're going to need a check for the existence of version-script I think - there are some examples out there like https://github.com/jrl-umi3218/jrl-cmakemodules/blob/master/version-script.cmake

libclamav/CMakeLists.txt Outdated Show resolved Hide resolved
@val-ms
Copy link
Contributor

val-ms commented Nov 22, 2022

I am also seeing failures in our internal jenkins for our statically linked DEB and RPM builds with this failure:

/root/.mussels/install/host-static/lib/libxml2.a(xmlIO.c.o): In function `xmlGzfileOpenW':
xmlIO.c:(.text+0x25a): undefined reference to `gzdopen'
xmlIO.c:(.text+0x298): undefined reference to `gzopen64'
/root/.mussels/install/host-static/lib/libxml2.a(xmlIO.c.o): In function `xmlCreateZMemBuff':
xmlIO.c:(.text+0xa8c): undefined reference to `deflateInit2_'
xmlIO.c:(.text+0xaa3): undefined reference to `crc32'
xmlIO.c:(.text+0xb46): undefined reference to `deflateEnd'
xmlIO.c:(.text+0xbc1): undefined reference to `deflateEnd'
/root/.mussels/install/host-static/lib/libxml2.a(xmlIO.c.o): In function `xmlGzfileClose':
xmlIO.c:(.text+0xbe5): undefined reference to `gzclose'
/root/.mussels/install/host-static/lib/libxml2.a(xmlIO.c.o): In function `xmlGzfileRead':
xmlIO.c:(.text+0xc25): undefined reference to `gzread'
/root/.mussels/install/host-static/lib/libxml2.a(xmlIO.c.o): In function `xmlGzfileWrite':
xmlIO.c:(.text+0xd95): undefined reference to `gzwrite'
/root/.mussels/install/host-static/lib/libxml2.a(xmlIO.c.o): In function `xmlGzfileOpen':
xmlIO.c:(.text+0x16b5): undefined reference to `gzdopen'
xmlIO.c:(.text+0x1714): undefined reference to `gzopen64'
xmlIO.c:(.text+0x1776): undefined reference to `gzdopen'
xmlIO.c:(.text+0x1828): undefined reference to `gzopen64'
/root/.mussels/install/host-static/lib/libxml2.a(xmlIO.c.o): In function `__xmlParserInputBufferCreateFilename':
xmlIO.c:(.text+0x1c93): undefined reference to `gzdirect'
/root/.mussels/install/host-static/lib/libxml2.a(xmlIO.c.o): In function `xmlIOHTTPWrite':
xmlIO.c:(.text+0x2a56): undefined reference to `deflate'
xmlIO.c:(.text+0x2acb): undefined reference to `deflate'
xmlIO.c:(.text+0x2bea): undefined reference to `crc32'
/root/.mussels/install/host-static/lib/libxml2.a(xmlIO.c.o): In function `xmlIOHTTPCloseWrite':
xmlIO.c:(.text+0x32a1): undefined reference to `deflate'
xmlIO.c:(.text+0x33f7): undefined reference to `deflateEnd'
/root/.mussels/install/host-static/lib/libxml2.a(xmlIO.c.o): In function `xmlIOHTTPOpenW':
xmlIO.c:(.text+0x3798): undefined reference to `deflateEnd'
xmlIO.c:(.text+0x37e1): undefined reference to `deflateEnd'
/root/.mussels/install/host-static/lib/libxml2.a(nanohttp.c.o): In function `xmlNanoHTTPFreeCtxt':
nanohttp.c:(.text+0x405): undefined reference to `inflateEnd'
/root/.mussels/install/host-static/lib/libxml2.a(nanohttp.c.o): In function `xmlNanoHTTPRead':
nanohttp.c:(.text+0xe4f): undefined reference to `inflate'
/root/.mussels/install/host-static/lib/libxml2.a(nanohttp.c.o): In function `xmlNanoHTTPMethodRedir':
nanohttp.c:(.text+0x1cfb): undefined reference to `inflateInit2_'
collect2: error: ld returned 1 exit status
[ 99%] Built target clamdtop
unit_tests/CMakeFiles/check_clamav.dir/build.make:402: recipe for target 'unit_tests/check_clamav' failed
make[2]: *** [unit_tests/check_clamav] Error 1
CMakeFiles/Makefile2:2099: recipe for target 'unit_tests/CMakeFiles/check_clamav.dir/all' failed
make[1]: *** [unit_tests/CMakeFiles/check_clamav.dir/all] Error 2

I'm not sure why.

@val-ms
Copy link
Contributor

val-ms commented Nov 22, 2022

We have limited time left before the 1.0.0 stable release. We're aiming to publish it one week from today and so are hoping to have everything wrapped up and ready to go by end of business on Wednesday, to account for the american thanksgiving holiday weekend.
That is -- I have low expectations that we'll be able to solve this in time.

To resolve your concern about the ABI/namespace change in time for the 1.0.0 release, I have placed a PR to bump the SO version: #778

@val-ms val-ms changed the title WIP: Use version-script with cmake builds Use version-script with cmake builds Mar 17, 2023
@val-ms
Copy link
Contributor

val-ms commented Mar 17, 2023

I just rebased this PR with the upstream main branch so it will pass tests in the internal Jenkins pipeline.

@val-ms
Copy link
Contributor

val-ms commented Mar 19, 2023

This PR is also missing using the libclamunrar.map as seen in #816. I have a commit in a personal/internal branch that i'm testing and if testing goes well, I'll push it here along with pushing a commit that resolves the linking issue I observed with the check_clamav unit test program when linking a static libxml2.a library.

Only use version-script on UNIX, except APPLE
@val-ms val-ms force-pushed the versionscript branch 2 times, most recently from c426a0b to c3b6720 Compare March 23, 2023 02:31
libclamav/libclamav.map Show resolved Hide resolved
libclamav/libclamav.map Show resolved Hide resolved
libclamav.map: Add missing symbol and correct symbol version.

libclamunrar.map: Use symbol version-script for libclamunrar, too.
Thank you to Sebastian Andrzej Siewior for the help.

Also fix a unittest linker issue...
Adding libclamav.map causes libclamav to no longer export zlib
when zlib is statically linked.

What was weird is that libxml2 depends on zlib and the check_clamav
unit test program was using those symbols from libclamav.

Introducing libclamav.map broke that even though we were explicitly
trying to link check_clamav with ZLIB::ZLIB as well.

For reasons I can't explain, linking check_clamav with the
ClamAV::common library managed to properly link it with ZLIB::ZLIB
and so the undefined references go away.

Also in this commit, I've removed the `.map` files from .gitignore
I'm not sure why they were ignored before.
@val-ms val-ms merged commit 38cc06f into Cisco-Talos:main Mar 23, 2023
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.

ABI changes in 1.0.0 - time for a soname bump?
2 participants