Skip to content

[libc] Add missing -latomic for rv32 #99337

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

Merged
merged 1 commit into from
Jul 17, 2024

Conversation

mikhailramalho
Copy link
Member

On rv32, libatomic is needed to build libc when mpfr and gmp are enabled.

On rv32, libatomic is needed to build libc when mpfr and gmp are
enabled.
@llvmbot
Copy link
Member

llvmbot commented Jul 17, 2024

@llvm/pr-subscribers-libc

Author: Mikhail R. Gadelha (mikhailramalho)

Changes

On rv32, libatomic is needed to build libc when mpfr and gmp are enabled.


Full diff: https://github.com/llvm/llvm-project/pull/99337.diff

2 Files Affected:

  • (modified) libc/cmake/modules/LLVMLibCCheckMPFR.cmake (+1-1)
  • (modified) libc/test/src/CMakeLists.txt (+1-1)
diff --git a/libc/cmake/modules/LLVMLibCCheckMPFR.cmake b/libc/cmake/modules/LLVMLibCCheckMPFR.cmake
index 45334a54431ef..a27c2dc0c030b 100644
--- a/libc/cmake/modules/LLVMLibCCheckMPFR.cmake
+++ b/libc/cmake/modules/LLVMLibCCheckMPFR.cmake
@@ -13,6 +13,6 @@ else()
     SOURCES
     ${LIBC_SOURCE_DIR}/utils/MPFRWrapper/check_mpfr.cpp
     LINK_LIBRARIES
-      -lmpfr -lgmp
+      -lmpfr -lgmp -latomic
   )
 endif()
diff --git a/libc/test/src/CMakeLists.txt b/libc/test/src/CMakeLists.txt
index a5e7a2a4dee72..b9a50a47af75d 100644
--- a/libc/test/src/CMakeLists.txt
+++ b/libc/test/src/CMakeLists.txt
@@ -24,7 +24,7 @@ function(add_fp_unittest name)
       message(FATAL_ERROR "Hermetic math test cannot require MPFR.")
     endif()
     set(test_type UNIT_TEST_ONLY)
-    list(APPEND MATH_UNITTEST_LINK_LIBRARIES libcMPFRWrapper -lmpfr -lgmp)
+    list(APPEND MATH_UNITTEST_LINK_LIBRARIES libcMPFRWrapper -lmpfr -lgmp -latomic)
   endif()
   list(APPEND MATH_UNITTEST_LINK_LIBRARIES LibcFPTestHelpers)
 

@mikhailramalho
Copy link
Member Author

Intel 64 doesn't seem to mind this change, but I haven't tried it in arm64 or fuschia.

If this is merged and it fails in other systems, I can conditionally add the lib via LIBC_TARGET_ARCHITECTURE_IS_RISCV32

@mikhailramalho mikhailramalho merged commit e5ccc71 into llvm:main Jul 17, 2024
6 of 7 checks passed
@mikhailramalho mikhailramalho deleted the rv32-latomic branch July 17, 2024 16:41
yuxuanchen1997 pushed a commit that referenced this pull request Jul 25, 2024
Summary: On rv32, libatomic is needed to build libc when mpfr and gmp are enabled.

Test Plan: 

Reviewers: 

Subscribers: 

Tasks: 

Tags: 


Differential Revision: https://phabricator.intern.facebook.com/D60250843
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants