-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[compiler-rt][sanitizer] fix i386 build for Haiku #171075
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
Conversation
|
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Brad Smith (brad0) Changesr13 does not provide the trap err. Full diff: https://github.com/llvm/llvm-project/pull/171075.diff 2 Files Affected:
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
index 87a18b1120af6..37245c35cf919 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
@@ -1287,7 +1287,7 @@ uptr GetPageSize() {
uptr ReadBinaryName(/*out*/ char *buf, uptr buf_len) {
# if SANITIZER_HAIKU
- int cookie = 0;
+ int32_t cookie = 0;
image_info info;
const char *argv0 = "<UNKNOWN>";
while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) {
@@ -1987,7 +1987,7 @@ SignalContext::WriteFlag SignalContext::GetWriteFlag() const {
# elif SANITIZER_NETBSD
uptr err = ucontext->uc_mcontext.__gregs[_REG_ERR];
# elif SANITIZER_HAIKU
- uptr err = ucontext->uc_mcontext.r13;
+ uptr err = 0; // ucontext->uc_mcontext.r13;
# elif SANITIZER_SOLARIS && defined(__i386__)
const int Err = 13;
uptr err = ucontext->uc_mcontext.gregs[Err];
@@ -2617,6 +2617,11 @@ static void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) {
*pc = ucontext->uc_mcontext.mc_eip;
*bp = ucontext->uc_mcontext.mc_ebp;
*sp = ucontext->uc_mcontext.mc_esp;
+# elif SANITIZER_HAIKU
+ ucontext_t *ucontext = (ucontext_t*)context;
+ *pc = ucontext->uc_mcontext.eip;
+ *bp = ucontext->uc_mcontext.ebp;
+ *sp = ucontext->uc_mcontext.esp;
# else
ucontext_t *ucontext = (ucontext_t *)context;
# if SANITIZER_SOLARIS
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 24966523f3a02..82f0da14f5efe 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -629,7 +629,11 @@ typedef unsigned long __sanitizer_sigset_t;
# elif SANITIZER_APPLE
typedef unsigned __sanitizer_sigset_t;
# elif SANITIZER_HAIKU
+# if defined(__x86_64__)
typedef unsigned long __sanitizer_sigset_t;
+# else
+typedef unsigned long long __sanitizer_sigset_t;
+# endif
# elif SANITIZER_LINUX
struct __sanitizer_sigset_t {
// The size is determined by looking at sizeof of real sigset_t on linux.
|
You can test this locally with the following command:git-clang-format --diff origin/main HEAD --extensions cpp,h -- compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h --diff_from_common_commit
View the diff from clang-format here.diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
index 090b42a92..cf3146737 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
@@ -1987,10 +1987,11 @@ SignalContext::WriteFlag SignalContext::GetWriteFlag() const {
# elif SANITIZER_NETBSD
uptr err = ucontext->uc_mcontext.__gregs[_REG_ERR];
# elif SANITIZER_HAIKU
- uptr err = 0; // FIXME: ucontext->uc_mcontext.r13;
- // The err register was added on the main branch and not
- // available with the current release. To be reverted later.
- // https://github.com/haiku/haiku/commit/11adda21aa4e6b24f71a496868a44d7607bc3764
+ uptr err =
+ 0; // FIXME: ucontext->uc_mcontext.r13;
+ // The err register was added on the main branch and not
+ // available with the current release. To be reverted later.
+ // https://github.com/haiku/haiku/commit/11adda21aa4e6b24f71a496868a44d7607bc3764
# elif SANITIZER_SOLARIS && defined(__i386__)
const int Err = 13;
uptr err = ucontext->uc_mcontext.gregs[Err];
@@ -2621,7 +2622,7 @@ static void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) {
*bp = ucontext->uc_mcontext.mc_ebp;
*sp = ucontext->uc_mcontext.mc_esp;
# elif SANITIZER_HAIKU
- ucontext_t *ucontext = (ucontext_t *)context;
+ ucontext_t* ucontext = (ucontext_t*)context;
*pc = ucontext->uc_mcontext.eip;
*bp = ucontext->uc_mcontext.ebp;
*sp = ucontext->uc_mcontext.esp;
|
b8855b3 to
f0fc74a
Compare
| uptr err = ucontext->uc_mcontext.__gregs[_REG_ERR]; | ||
| # elif SANITIZER_HAIKU | ||
| uptr err = ucontext->uc_mcontext.r13; | ||
| uptr err = 0; // ucontext->uc_mcontext.r13; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but does it work for 64 bits though (should I think) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The err register got added on the main branch, but isn't yet on the current Haiku release. See haiku/haiku@11adda2 for more info. We'll use the register when possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh phewww :) might make sense to make a FIXME/TODO comment here then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The err register got added on the main branch, but isn't yet on the current Haiku release.
oh phewww :) might make sense to make a FIXME/TODO comment here then.
Ohh, that makes more sense. Yes, a comment for reference would make more sense. Then some point down the road flipping that back around.
| # if defined(__x86_64__) | ||
| typedef unsigned long __sanitizer_sigset_t; | ||
| # else | ||
| typedef unsigned long long __sanitizer_sigset_t; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unsigned long long should be the same as unsigned long on 64 bit, so this could be simplified to always use unsigned long long.
r13 does not provide the trap err.
f0fc74a to
e520525
Compare
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/10/builds/18805 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/205/builds/30205 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/203/builds/31415 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/204/builds/30226 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/206/builds/10315 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/140/builds/35443 Here is the relevant piece of the build log for the reference |
r13 does not provide the trap err. Co-authored-by: Jerome Duval <jerome.duval@gmail.com>
r13 does not provide the trap err.