Skip to content

[sanitizer_common] Fix building with NetBSD 10.99.12 or newer #134708

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

Conversation

brad0
Copy link
Contributor

@brad0 brad0 commented Apr 7, 2025

NetBSD/src@16543c4

__lwp_getprivate_fast() was moved to a new arch-specific header file.

Closes: #125566

NetBSD/src@16543c4

__lwp_getprivate_fast() was moved to a new arch-specific header file.

Closes: llvm#125566
@llvmbot
Copy link
Member

llvmbot commented Apr 7, 2025

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

Author: Brad Smith (brad0)

Changes

NetBSD/src@16543c4

__lwp_getprivate_fast() was moved to a new arch-specific header file.

Closes: #125566


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

1 Files Affected:

  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp (+7-1)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
index e5e79d4e0521c..304d14b20c6d5 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -29,7 +29,13 @@
 #  include "sanitizer_solaris.h"
 
 #  if SANITIZER_NETBSD
-#    define _RTLD_SOURCE  // for __lwp_gettcb_fast() / __lwp_getprivate_fast()
+#    // for __lwp_gettcb_fast() / __lwp_getprivate_fast()
+#    include <sys/param.h>
+#    if defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 1099001200)
+#      include <machine/lwp_private.h>
+#    else
+#      define _RTLD_SOURCE
+#    endif
 #  endif
 
 #  include <dlfcn.h>  // for dlsym()

@@ -29,7 +29,13 @@
# include "sanitizer_solaris.h"

# if SANITIZER_NETBSD
# define _RTLD_SOURCE // for __lwp_gettcb_fast() / __lwp_getprivate_fast()
# // for __lwp_gettcb_fast() / __lwp_getprivate_fast()
# include <sys/param.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be moved under the if condition, since it didn't seem to be needed for older NetBSD versions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, that's required for the if condition.

Copy link
Member

Choose a reason for hiding this comment

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

yes he s right we need this header prior

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see, thanks!

@brad0 brad0 merged commit 9fdac84 into llvm:main Apr 7, 2025
11 of 12 checks passed
@brad0 brad0 deleted the compiler_rt_sanitizer_linux_libcdep_netbsd branch April 7, 2025 19:57
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.

compiler-rt: build fix for NetBSD-10.99.12
5 participants