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

Building on musl fails to link against libanl when not using static linking (aka MUSL_OPTIMIZED_BUILD) #1948

Closed
hhoffstaette opened this issue Jul 5, 2024 · 6 comments · Fixed by #2036
Labels
kind/bug Something isn't working
Milestone

Comments

@hhoffstaette
Copy link
Contributor

hhoffstaette commented Jul 5, 2024

Describe the bug

sysdig can be built with MUSL_OPTIMIZED_BUILD - unfortunately this is misleading as it implies static linking and statically built dependencies, which is not necessary on musl.
I found that using a regular build against unbundled dependencies on musl fails, as falcosecurity-libs tries to unconditionally link against libanl, which does not exist on musl.

How to reproduce it

Build sysdig on musl with MUSL_OPTIMIZED_BUILD disabled and unbundled dependencies built as shared libs. It should error out with a failure to link -lanl.

Expected behaviour

sysdig should build successfully on musl against shared unbundled dependencies.

Environment

  • musl 1.2.5 in a Gentoo chroot (with musl as system C library)

  • Installation method: from source - I am the package maintainer :)

Additional information

We had to fix this in Gentoo for an older version in this commit:
https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=844fbd1e96beda0fb94ea06aba8f2618bfdad1f7

@hhoffstaette hhoffstaette added the kind/bug Something isn't working label Jul 5, 2024
@hhoffstaette
Copy link
Contributor Author

For libs-0.17.2 I had to rebase the patch (while finally updating our sysdig package to 0.38.0) and it looks like this:

--- libs-0.17.2/userspace/libsinsp/CMakeLists.txt~	2024-06-14 11:38:50.000000000 +0200
+++ libs-0.17.2/userspace/libsinsp/CMakeLists.txt	2024-07-05 00:18:03.326406540 +0200
@@ -258,8 +258,8 @@ if(NOT WIN32)
 			)
 
 			if(NOT MUSL_OPTIMIZED_BUILD)
-				target_link_libraries(sinsp INTERFACE rt anl)
-				list(APPEND SINSP_PKGCONFIG_LIBRARIES rt anl)
+				target_link_libraries(sinsp INTERFACE rt)
+				list(APPEND SINSP_PKGCONFIG_LIBRARIES rt)
 			endif()
 
 		else()

Obviously this is not correct on glibc systems, so the patch is only applied conditionally when building on musl. Can we somehow sanitize this without breaking things?

@hhoffstaette hhoffstaette changed the title Building on musl fails when not using static linking aka MUSL_OPTIMIZED_BUILD Building on musl fails to link against libanl when not using static linking (aka MUSL_OPTIMIZED_BUILD) Jul 5, 2024
@FedeDP
Copy link
Contributor

FedeDP commented Jul 5, 2024

Hi! Thanks for opening this issue :)
Mmh perhaps we could only link anl if we can find it in the system? Likely using find_library ?

@hhoffstaette
Copy link
Contributor Author

hhoffstaette commented Jul 5, 2024

Hi! Thanks for opening this issue :) Mmh perhaps we could only link anl if we can find it in the system? Likely using find_library ?

Yes, that would be one option. Like I said in the Gentoo bug mentioned above, libanl has only been an empty stub for quite some time now (since ~2021), so it's not even that critical any more.

@FedeDP
Copy link
Contributor

FedeDP commented Aug 29, 2024

Opened #2036 to fix this ;)

@FedeDP
Copy link
Contributor

FedeDP commented Aug 29, 2024

/milestone 0.19.0

@poiana poiana added this to the 0.19.0 milestone Aug 29, 2024
@FedeDP
Copy link
Contributor

FedeDP commented Sep 5, 2024

/milestone 0.18.0

@poiana poiana modified the milestones: 0.19.0, 0.18.0 Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants