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

libatomic is mandatory even when platform does not need it #634

Open
jpalus opened this issue Oct 19, 2022 · 1 comment
Open

libatomic is mandatory even when platform does not need it #634

jpalus opened this issue Oct 19, 2022 · 1 comment

Comments

@jpalus
Copy link

jpalus commented Oct 19, 2022

Few older platforms require libatomic for atomic operations but many of them don't (ARMv7 and higher, i686 and higher). mimalloc however uses it irrespective of target platform when libatomic is installed making it also part of public interface meaning libraries depending on mimalloc also need libatomic:

mimalloc/CMakeLists.txt

Lines 229 to 232 in f2712f4

find_library(MI_LIBATOMIC atomic)
if (MI_LIBATOMIC OR MI_USE_LIBATOMIC)
list(APPEND mi_libraries atomic)
endif()

Would be good if:

  • mimalloc checked if libatomic is really required for target platform (by trying to compile representative atomic operation used within project)
  • even if required I don't see a reason for libatomic being part of public interface so probably better to make it private
pld-gitsync pushed a commit to pld-linux/mimalloc that referenced this issue Oct 19, 2022
@daanx
Copy link
Collaborator

daanx commented Oct 31, 2022

Hmm tricky; the current solution seems nice -- if lib atomic is found on the system we use it which prevents link errors on Android for example. On many systems there is no libatomic and there we won't link with it.

From your message, it seems you say there are systems where we do not need libatomic but it is installed on the system?

I am not a cmake expert, how would we make libatomic private?

Thanks

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

No branches or pull requests

2 participants