Skip to content

Conversation

SchrodingerZhu
Copy link
Contributor

@SchrodingerZhu SchrodingerZhu commented Oct 8, 2025

Fix auxv rv32 build problem

@llvmbot llvmbot added the libc label Oct 8, 2025
@llvmbot
Copy link
Member

llvmbot commented Oct 8, 2025

@llvm/pr-subscribers-libc

Author: Schrodinger ZHU Yifan (SchrodingerZhu)

Changes

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

1 Files Affected:

  • (modified) libc/src/__support/OSUtil/linux/auxv.h (+6-1)
diff --git a/libc/src/__support/OSUtil/linux/auxv.h b/libc/src/__support/OSUtil/linux/auxv.h
index 7fb996f01dd84..894868ae5824d 100644
--- a/libc/src/__support/OSUtil/linux/auxv.h
+++ b/libc/src/__support/OSUtil/linux/auxv.h
@@ -81,7 +81,12 @@ LIBC_INLINE void Vector::initialize_unsafe(const Entry *auxv) {
 [[gnu::cold]]
 LIBC_INLINE void Vector::fallback_initialize_unsync() {
   constexpr size_t AUXV_MMAP_SIZE = FALLBACK_AUXV_ENTRIES * sizeof(Entry);
-  long mmap_ret = syscall_impl<long>(SYS_mmap, nullptr, AUXV_MMAP_SIZE,
+#ifdef SYS_mmap2
+  constexpr int MMAP_SYSNO = SYS_mmap2;
+#else
+  constexpr int MMAP_SYSNO = SYS_mmap;
+#endif
+  long mmap_ret = syscall_impl<long>(MMAP_SYSNO, nullptr, AUXV_MMAP_SIZE,
                                      PROT_READ | PROT_WRITE,
                                      MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
   // We do not proceed if mmap fails.

@SchrodingerZhu SchrodingerZhu merged commit 1892e6f into llvm:main Oct 8, 2025
19 of 20 checks passed
@SchrodingerZhu SchrodingerZhu deleted the libc-mmap-fix branch October 8, 2025 18:34
svkeerthy pushed a commit that referenced this pull request Oct 9, 2025
clingfei pushed a commit to clingfei/llvm-project that referenced this pull request Oct 10, 2025
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