Skip to content

[libc] build fix for sigsetjmp #137047

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
Apr 23, 2025

Conversation

SchrodingerZhu
Copy link
Contributor

This PR fixes the build failure due to the sigsetjmp implementation.

  1. Use a most relaxed input constraint to fix clang build.
  2. Avoid create alias target if os directory for sigsetjmp_epilogue does not exist.

@llvmbot llvmbot added the libc label Apr 23, 2025
@SchrodingerZhu SchrodingerZhu requested a review from Copilot April 23, 2025 19:48
@llvmbot
Copy link
Member

llvmbot commented Apr 23, 2025

@llvm/pr-subscribers-libc

Author: Schrodinger ZHU Yifan (SchrodingerZhu)

Changes

This PR fixes the build failure due to the sigsetjmp implementation.

  1. Use a most relaxed input constraint to fix clang build.
  2. Avoid create alias target if os directory for sigsetjmp_epilogue does not exist.

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

2 Files Affected:

  • (modified) libc/src/setjmp/CMakeLists.txt (+6-7)
  • (modified) libc/src/setjmp/x86_64/sigsetjmp.cpp (+4-4)
diff --git a/libc/src/setjmp/CMakeLists.txt b/libc/src/setjmp/CMakeLists.txt
index 3a3628bafe7ca..2591319f15240 100644
--- a/libc/src/setjmp/CMakeLists.txt
+++ b/libc/src/setjmp/CMakeLists.txt
@@ -1,14 +1,13 @@
 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
   add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
+  add_object_library(
+    sigsetjmp_epilogue
+    ALIAS
+    DEPENDS
+      .${LIBC_TARGET_OS}.sigsetjmp_epilogue
+  )
 endif()
 
-add_object_library(
-  sigsetjmp_epilogue
-  ALIAS
-  DEPENDS
-    .${LIBC_TARGET_OS}.sigsetjmp_epilogue
-)
-
 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_ARCHITECTURE})
   add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_ARCHITECTURE})
 endif()
diff --git a/libc/src/setjmp/x86_64/sigsetjmp.cpp b/libc/src/setjmp/x86_64/sigsetjmp.cpp
index dc41a71321322..4c97a01822679 100644
--- a/libc/src/setjmp/x86_64/sigsetjmp.cpp
+++ b/libc/src/setjmp/x86_64/sigsetjmp.cpp
@@ -37,8 +37,8 @@ LLVM_LIBC_FUNCTION(int, sigsetjmp, (sigjmp_buf buf)) {
       
 .Lnosave:
       jmp %P[setjmp])" ::[retaddr] "i"(offsetof(__jmp_buf, sig_retaddr)),
-      [extra] "i"(offsetof(__jmp_buf, sig_extra)), [setjmp] "i"(setjmp),
-      [epilogue] "i"(sigsetjmp_epilogue)
+      [extra] "i"(offsetof(__jmp_buf, sig_extra)), [setjmp] "X"(setjmp),
+      [epilogue] "X"(sigsetjmp_epilogue)
       : "eax", "ebx", "ecx");
 }
 #endif
@@ -60,8 +60,8 @@ LLVM_LIBC_FUNCTION(int, sigsetjmp, (sigjmp_buf, int)) {
       
 .Lnosave:
       jmp %P[setjmp])" ::[retaddr] "i"(offsetof(__jmp_buf, sig_retaddr)),
-      [extra] "i"(offsetof(__jmp_buf, sig_extra)), [setjmp] "i"(setjmp),
-      [epilogue] "i"(sigsetjmp_epilogue)
+      [extra] "i"(offsetof(__jmp_buf, sig_extra)), [setjmp] "X"(setjmp),
+      [epilogue] "X"(sigsetjmp_epilogue)
       : "rax", "rbx");
 }
 

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a build failure in the sigsetjmp implementation by adjusting inline assembly constraints and avoiding alias target creation when the OS directory for sigsetjmp_epilogue is missing.

  • Update inline assembly constraints from "i" to "X" for both sigsetjmp functions
  • Bypass alias target creation when the required OS directory is absent
Files not reviewed (1)
  • libc/src/setjmp/CMakeLists.txt: Language not supported

@SchrodingerZhu SchrodingerZhu merged commit f07511a into llvm:main Apr 23, 2025
14 of 17 checks passed
@SchrodingerZhu SchrodingerZhu deleted the libc/fix-for-sigsetjmp branch April 23, 2025 19:50
gulfemsavrun added a commit to gulfemsavrun/llvm-project that referenced this pull request Apr 23, 2025
This reverts commit f07511a.

This reverts commit 5bb4cf9.

It caused a CMake configuration issue.
gulfemsavrun added a commit that referenced this pull request Apr 23, 2025
This reverts commit f07511a.

This reverts commit 5bb4cf9.

It caused a CMake configuration issue.
SchrodingerZhu added a commit that referenced this pull request Apr 24, 2025
SchrodingerZhu added a commit that referenced this pull request Apr 29, 2025
Reland `sigsetjmp` patches with build fixes.

We wrap every target replying on the epilogue library into conditional
checks.

---------

Co-authored-by: Petr Hosek <[email protected]>
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
This PR fixes the build failure due to the `sigsetjmp` implementation.

1. Use a most relaxed input constraint to fix `clang` build.
2. Avoid create alias target if os directory for `sigsetjmp_epilogue`
does not exist.
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
This reverts commit f07511a.

This reverts commit 5bb4cf9.

It caused a CMake configuration issue.
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
Reland `sigsetjmp` patches with build fixes.

We wrap every target replying on the epilogue library into conditional
checks.

---------

Co-authored-by: Petr Hosek <[email protected]>
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
This PR fixes the build failure due to the `sigsetjmp` implementation.

1. Use a most relaxed input constraint to fix `clang` build.
2. Avoid create alias target if os directory for `sigsetjmp_epilogue`
does not exist.
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
This reverts commit f07511a.

This reverts commit 5bb4cf9.

It caused a CMake configuration issue.
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
Reland `sigsetjmp` patches with build fixes.

We wrap every target replying on the epilogue library into conditional
checks.

---------

Co-authored-by: Petr Hosek <[email protected]>
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
This PR fixes the build failure due to the `sigsetjmp` implementation.

1. Use a most relaxed input constraint to fix `clang` build.
2. Avoid create alias target if os directory for `sigsetjmp_epilogue`
does not exist.
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
This reverts commit f07511a.

This reverts commit 5bb4cf9.

It caused a CMake configuration issue.
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
Reland `sigsetjmp` patches with build fixes.

We wrap every target replying on the epilogue library into conditional
checks.

---------

Co-authored-by: Petr Hosek <[email protected]>
GeorgeARM pushed a commit to GeorgeARM/llvm-project that referenced this pull request May 7, 2025
Reland `sigsetjmp` patches with build fixes.

We wrap every target replying on the epilogue library into conditional
checks.

---------

Co-authored-by: Petr Hosek <[email protected]>
Ankur-0429 pushed a commit to Ankur-0429/llvm-project that referenced this pull request May 9, 2025
This PR fixes the build failure due to the `sigsetjmp` implementation.

1. Use a most relaxed input constraint to fix `clang` build.
2. Avoid create alias target if os directory for `sigsetjmp_epilogue`
does not exist.
Ankur-0429 pushed a commit to Ankur-0429/llvm-project that referenced this pull request May 9, 2025
This reverts commit f07511a.

This reverts commit 5bb4cf9.

It caused a CMake configuration issue.
Ankur-0429 pushed a commit to Ankur-0429/llvm-project that referenced this pull request May 9, 2025
Reland `sigsetjmp` patches with build fixes.

We wrap every target replying on the epilogue library into conditional
checks.

---------

Co-authored-by: Petr Hosek <[email protected]>
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