Skip to content

[compiler-rt][Mips] Align definition of __sanitizer_sigaction with musl #124494

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 2 commits into from
Feb 14, 2025

Conversation

Gelbpunkt
Copy link
Contributor

The definition of __sanitizer_sigaction for MIPS matches the one in glibc 1. musl however uses a single definition of sigaction for all architectures 2 that is more similar to the other architectures supported by glibc. Fix the conditional logic so that __sanitizer_sigaction matches the musl definition on MIPS.

Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot
Copy link
Member

llvmbot commented Jan 27, 2025

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Jens Reidel (Gelbpunkt)

Changes

The definition of __sanitizer_sigaction for MIPS matches the one in glibc 1. musl however uses a single definition of sigaction for all architectures 2 that is more similar to the other architectures supported by glibc. Fix the conditional logic so that __sanitizer_sigaction matches the musl definition on MIPS.


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

1 Files Affected:

  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h (+24-24)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
index 7e62dc0e0523ec..139722036262d8 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -655,49 +655,49 @@ struct __sanitizer_sigaction {
 };
 #else // !SANITIZER_ANDROID
 struct __sanitizer_sigaction {
-#if defined(__mips__) && !SANITIZER_FREEBSD
+#    if defined(__mips__) && !SANITIZER_FREEBSD && !SANITIZER_MUSL
   unsigned int sa_flags;
-#endif
+#    endif
   union {
     __sanitizer_sigactionhandler_ptr sigaction;
     __sanitizer_sighandler_ptr handler;
   };
-#if SANITIZER_FREEBSD
+#    if SANITIZER_FREEBSD
   int sa_flags;
   __sanitizer_sigset_t sa_mask;
-#else
-#if defined(__s390x__)
+#    else
+#      if defined(__s390x__)
   int sa_resv;
-#else
+#      else
   __sanitizer_sigset_t sa_mask;
-#endif
-#ifndef __mips__
-#if defined(__sparc__)
-#if __GLIBC_PREREQ (2, 20)
+#      endif
+#      if !defined(__mips__) || SANITIZER_MUSL
+#        if defined(__sparc__)
+#          if __GLIBC_PREREQ(2, 20)
   // On sparc glibc 2.19 and earlier sa_flags was unsigned long.
-#if defined(__arch64__)
+#            if defined(__arch64__)
   // To maintain ABI compatibility on sparc64 when switching to an int,
   // __glibc_reserved0 was added.
   int __glibc_reserved0;
-#endif
+#            endif
   int sa_flags;
-#else
+#          else
   unsigned long sa_flags;
-#endif
-#else
+#          endif
+#        else
   int sa_flags;
-#endif
-#endif
-#endif
-#if SANITIZER_LINUX
+#        endif
+#      endif
+#    endif
+#    if SANITIZER_LINUX
   void (*sa_restorer)();
-#endif
-#if defined(__mips__) && (SANITIZER_WORDSIZE == 32)
+#    endif
+#    if defined(__mips__) && (SANITIZER_WORDSIZE == 32) && !SANITIZER_MUSL
   int sa_resv[1];
-#endif
-#if defined(__s390x__)
+#    endif
+#    if defined(__s390x__)
   __sanitizer_sigset_t sa_mask;
-#endif
+#    endif
 };
 #endif // !SANITIZER_ANDROID
 

@Gelbpunkt
Copy link
Contributor Author

Ping

Copy link
Collaborator

@vitalybuka vitalybuka left a comment

Choose a reason for hiding this comment

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

Could you please do not reformat in the same PR, or split format and change into 2 different commits?

The definition of __sanitizer_sigaction for MIPS matches the one in
glibc [1]. musl however uses a single definition of sigaction for all
architectures [2] that is more similar to the other architectures supported
by glibc. Fix the conditional logic so that __sanitizer_sigaction
matches the musl definition on MIPS.

[1]: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/mips/bits/sigaction.h;h=f7e3ad88abbf3c497aaed44247bc1085efebe462;hb=dc650eb715df0a272ce43dfb55a209d5b018cc04
[2]: https://git.musl-libc.org/cgit/musl/tree/include/signal.h#n169

Signed-off-by: Jens Reidel <[email protected]>
@Gelbpunkt Gelbpunkt force-pushed the mips-musl-sigaction branch from fa48ac7 to 23417e3 Compare February 7, 2025 19:43
@Gelbpunkt
Copy link
Contributor Author

Could you please do not reformat in the same PR, or split format and change into 2 different commits?

Done. I split the reformat into a different commit.

@vitalybuka
Copy link
Collaborator

Could you please do not reformat in the same PR, or split format and change into 2 different commits?

Done. I split the reformat into a different commit.

Thanks!

@vitalybuka
Copy link
Collaborator

vitalybuka commented Feb 7, 2025

Lets wait a little for @MaskRay who previously reviewed MUSL.
If you no response please request review from me again and I'll merge the patch.

@Gelbpunkt
Copy link
Contributor Author

@vitalybuka this should be ready to merge?

@vitalybuka vitalybuka merged commit 8730fd7 into llvm:main Feb 14, 2025
7 checks passed
Copy link

@Gelbpunkt Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

@Gelbpunkt Gelbpunkt deleted the mips-musl-sigaction branch February 14, 2025 18:40
joaosaffran pushed a commit to joaosaffran/llvm-project that referenced this pull request Feb 14, 2025
…sl (llvm#124494)

The definition of __sanitizer_sigaction for MIPS matches the one in
glibc [1]. musl however uses a single definition of sigaction for all
architectures [2] that is more similar to the other architectures
supported by glibc. Fix the conditional logic so that
__sanitizer_sigaction matches the musl definition on MIPS.

[1]:
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/mips/bits/sigaction.h;h=f7e3ad88abbf3c497aaed44247bc1085efebe462;hb=dc650eb715df0a272ce43dfb55a209d5b018cc04
[2]: https://git.musl-libc.org/cgit/musl/tree/include/signal.h#n169

---------

Signed-off-by: Jens Reidel <[email protected]>
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Feb 24, 2025
…sl (llvm#124494)

The definition of __sanitizer_sigaction for MIPS matches the one in
glibc [1]. musl however uses a single definition of sigaction for all
architectures [2] that is more similar to the other architectures
supported by glibc. Fix the conditional logic so that
__sanitizer_sigaction matches the musl definition on MIPS.

[1]:
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/mips/bits/sigaction.h;h=f7e3ad88abbf3c497aaed44247bc1085efebe462;hb=dc650eb715df0a272ce43dfb55a209d5b018cc04
[2]: https://git.musl-libc.org/cgit/musl/tree/include/signal.h#n169

---------

Signed-off-by: Jens Reidel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants