Skip to content

Commit e5e3b80

Browse files
mojyackkraj
authored andcommitted
Fix build on ppc64+musl
In powerpc64-unknown-linux-musl, signal.h does not include asm/ptrace.h, which causes "member access into incomplete type 'struct pt_regs'" errors. Include the header explicitly to fix this. Also in sanitizer_linux_libcdep.cpp, there is a usage of TlsPreTcbSize which is not defined in such a platform. Guard the branch with macro.
1 parent 4351233 commit e5e3b80

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ extern "C" SANITIZER_WEAK_ATTRIBUTE const char *strerrorname_np(int);
9292
# include <sys/sysmacros.h>
9393
# endif
9494

95+
# if SANITIZER_LINUX && defined(__powerpc64__)
96+
# include <asm/ptrace.h>
97+
# endif
98+
9599
# if SANITIZER_FREEBSD
96100
# include <machine/atomic.h>
97101
# include <sys/exec.h>

compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -605,21 +605,22 @@ static void GetTls(uptr *addr, uptr *size) {
605605
*addr = tp - RoundUpTo(*size, align);
606606
*size = tp - *addr + ThreadDescriptorSize();
607607
# else
608-
if (SANITIZER_GLIBC)
609-
*size += 1664;
610-
else if (SANITIZER_FREEBSD)
611-
*size += 128; // RTLD_STATIC_TLS_EXTRA
612-
# if defined(__mips__) || defined(__powerpc64__) || SANITIZER_RISCV64
608+
# if SANITIZER_GLIBC
609+
*size += 1664;
610+
# elif SANITIZER_FREEBSD
611+
*size += 128; // RTLD_STATIC_TLS_EXTRA
612+
# if defined(__mips__) || defined(__powerpc64__) || SANITIZER_RISCV64
613613
const uptr pre_tcb_size = TlsPreTcbSize();
614614
*addr -= pre_tcb_size;
615615
*size += pre_tcb_size;
616-
# else
616+
# else
617617
// arm and aarch64 reserve two words at TP, so this underestimates the range.
618618
// However, this is sufficient for the purpose of finding the pointers to
619619
// thread-specific data keys.
620620
const uptr tcb_size = ThreadDescriptorSize();
621621
*addr -= tcb_size;
622622
*size += tcb_size;
623+
# endif
623624
# endif
624625
# endif
625626
# elif SANITIZER_NETBSD

compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
# include <sys/ptrace.h>
9797
# if defined(__mips64) || defined(__aarch64__) || defined(__arm__) || \
9898
defined(__hexagon__) || defined(__loongarch__) || SANITIZER_RISCV64 || \
99-
defined(__sparc__)
99+
defined(__sparc__) || defined(__powerpc64__)
100100
# include <asm/ptrace.h>
101101
# ifdef __arm__
102102
typedef struct user_fpregs elf_fpregset_t;

compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
#include <sys/types.h> // for pid_t
3232
#include <sys/uio.h> // for iovec
3333
#include <elf.h> // for NT_PRSTATUS
34-
#if (defined(__aarch64__) || SANITIZER_RISCV64 || SANITIZER_LOONGARCH64) && \
34+
#if (defined(__aarch64__) || defined(__powerpc64__) || \
35+
SANITIZER_RISCV64 || SANITIZER_LOONGARCH64) && \
3536
!SANITIZER_ANDROID
3637
// GLIBC 2.20+ sys/user does not include asm/ptrace.h
3738
# include <asm/ptrace.h>

0 commit comments

Comments
 (0)