Skip to content

[compiler-rt][Mips] Fix stat size check on mips64 musl #143301

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 19, 2025

Conversation

Gelbpunkt
Copy link
Contributor

The sizes of the struct stat on MIPS64 differ in musl vs glibc.

See https://godbolt.org/z/qf9bcq8Y8 for the proof. Prior to this change, compilation for MIPS64 musl would fail.

@llvmbot
Copy link
Member

llvmbot commented Jun 8, 2025

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

Author: Jens Reidel (Gelbpunkt)

Changes

The sizes of the struct stat on MIPS64 differ in musl vs glibc.

See https://godbolt.org/z/qf9bcq8Y8 for the proof. Prior to this change, compilation for MIPS64 musl would fail.


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

1 Files Affected:

  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h (+3-1)
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 fdc52aa56c493..134081ac97931 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -102,8 +102,10 @@ const unsigned struct_kernel_stat_sz = SANITIZER_ANDROID
                                            ? FIRST_32_SECOND_64(104, 128)
 #      if defined(_ABIN32) && _MIPS_SIM == _ABIN32
                                            : FIRST_32_SECOND_64(176, 216);
-#      else
+#      elif !SANITIZER_MUSL
                                            : FIRST_32_SECOND_64(160, 216);
+#      else
+                                           : FIRST_32_SECOND_64(160, 208);
 #      endif
 const unsigned struct_kernel_stat64_sz = 104;
 #elif defined(__s390__) && !defined(__s390x__)

@Gelbpunkt Gelbpunkt force-pushed the struct-stat-size-fix-mips64-musl branch from 9fdb7f6 to 4b9c1d6 Compare June 8, 2025 06:00
@Gelbpunkt Gelbpunkt changed the title compiler-rt: Fix stat size check on mips64 musl [compiler-rt][Mips] Fix stat size check on mips64 musl Jun 8, 2025
The sizes of the struct stat on MIPS64 differ in musl vs glibc.

See https://godbolt.org/z/qf9bcq8Y8 for the proof. Prior to this change,
compilation for MIPS64 musl would fail.

Signed-off-by: Jens Reidel <[email protected]>
@Gelbpunkt Gelbpunkt force-pushed the struct-stat-size-fix-mips64-musl branch from 4b9c1d6 to 1edfdda Compare June 17, 2025 22:39
@brad0 brad0 requested review from vitalybuka and MaskRay June 17, 2025 22:48
@brad0
Copy link
Contributor

brad0 commented Jun 27, 2025

@MaskRay @vitalybuka

@Gelbpunkt
Copy link
Contributor Author

FYI I figured out why this is the case: musl's nlink_t is a u32 instead of a u64, which changes the size from 216 bytes to 208: https://git.musl-libc.org/cgit/musl/tree/arch/mips64/bits/alltypes.h.in#n22

So this is definitely correct :)

@brad0
Copy link
Contributor

brad0 commented Jul 16, 2025

cc @MaskRay

@brad0 brad0 merged commit a5d6fa6 into llvm:main Jul 19, 2025
7 checks passed
@Gelbpunkt Gelbpunkt deleted the struct-stat-size-fix-mips64-musl branch July 20, 2025 20:47
tru pushed a commit to llvmbot/llvm-project that referenced this pull request Jul 24, 2025
The sizes of the struct stat on MIPS64 differ in musl vs glibc.

See https://godbolt.org/z/qf9bcq8Y8 for the proof. Prior to this change,
compilation for MIPS64 musl would fail.

Signed-off-by: Jens Reidel <[email protected]>
(cherry picked from commit a5d6fa6)
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