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

cmake: link CMAKE_DL_LIBS #725

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alalazo
Copy link

@alalazo alalazo commented Jan 18, 2024

Without the explicit command in the PR, I get a build failure when building from sources on Ubuntu 20.04 and adding GPU support.

The build was done with Spack, see spack/spack#42139

If it is of any use, I attach a log of the failed build (before this change): spack-build-out.txt

Link btop to ${CMAKE_DL_LIBS} when
building using shared libs and GPU support on linux
@imwints
Copy link
Contributor

imwints commented Jan 18, 2024

This is because glibc on Ubuntu 20.04 is too old. This is the same issue as here.

There are newer Ubuntu LTS's available with proper support for CMake, glibc and gcc. (20.04 doesn't have a new enough CMake anyway, and only gcc-10 while 11 or newer is recommended).

I'd like to keep this in line with the Makefile which doesn't support that either.

@alalazo
Copy link
Author

alalazo commented Jan 18, 2024

There are newer Ubuntu LTS's available with proper support for CMake, glibc and gcc. (20.04 doesn't have a new enough CMake anyway, and only gcc-10 while 11 or newer is recommended).

I built the tool with a package manager that doesn't require root privileges. We can currently deal with cmake and compiler but we don't yet build our own glibc. So glibc remains our only issue for a pristine build.

Since I'll use that patch to build btop, I thought it would be good to upstream it. I think one point would be: would it make building with newer glibc worse? If not this seems an improvement 🙂

@alalazo
Copy link
Author

alalazo commented Jan 18, 2024

I'd like to keep this in line with the Makefile which doesn't support that either.

Does this mean that a similar change in the Makefile is welcome, or is it a policy to build only with the system provided toolchain on each OS?

@imwints
Copy link
Contributor

imwints commented Jan 20, 2024

No, there is no such policy, but it's just unusual to run into a system with brand new compiler and outdated libc.

You don't even need to patch the build files. Just configure cmake with proper LDFLAGS like so LDFLAGS=-ldl cmake -B ...
IMO this is not worth patching since it's so uncommon and LDFLAGS is even simpler.

@haampie
Copy link

haampie commented Oct 21, 2024

Hi @imwints,

Could you please merge this? You're explicitly using dlopen, so link to libdl.so.

Multiple people have run into this, and it should be the build system that gets it right, especially if it's just 3 lines.

@antoine-morvan
Copy link

it's just unusual to run into a system with brand new compiler and outdated libc.

What's unusual for you might be usual for someone else ;)

I agree with haampie, if there is an explicit dependency, then the build system should handle it explicitly (actually doesn't matter 3 lines or 3K ^^').

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.

4 participants