mirror of
https://github.com/python/cpython.git
synced 2026-01-05 23:12:38 +00:00
[3.12] gh-129838: Don't redefine _Py_NO_SANITIZE_UNDEFINED (GH-129839) (#130365)
gh-129838: Don't redefine _Py_NO_SANITIZE_UNDEFINED (GH-129839)
Newer GCC versions accept both __attribute__((no_sanitize("undefined")))
and __attribute__((no_sanitize_undefined)) so check that the macro is
not already defined.
(cherry picked from commit 568db400ff)
Co-authored-by: Collin Funk <collin.funk1@gmail.com>
This commit is contained in:
parent
5c0aba0b81
commit
f314cc4db5
2 changed files with 7 additions and 4 deletions
|
|
@ -0,0 +1,2 @@
|
|||
Don't redefine ``_Py_NO_SANITIZE_UNDEFINED`` when compiling with a recent
|
||||
GCC version and undefined sanitizer enabled.
|
||||
|
|
@ -29,14 +29,15 @@
|
|||
#define PUTS(fd, str) _Py_write_noraise(fd, str, strlen(str))
|
||||
|
||||
|
||||
// clang uses __attribute__((no_sanitize("undefined")))
|
||||
// GCC 4.9+ uses __attribute__((no_sanitize_undefined))
|
||||
#if defined(__has_feature) // Clang
|
||||
// Clang and GCC 9.0+ use __attribute__((no_sanitize("undefined")))
|
||||
#if defined(__has_feature)
|
||||
# if __has_feature(undefined_behavior_sanitizer)
|
||||
# define _Py_NO_SANITIZE_UNDEFINED __attribute__((no_sanitize("undefined")))
|
||||
# endif
|
||||
#endif
|
||||
#if defined(__GNUC__) \
|
||||
|
||||
// GCC 4.9+ uses __attribute__((no_sanitize_undefined))
|
||||
#if !defined(_Py_NO_SANITIZE_UNDEFINED) && defined(__GNUC__) \
|
||||
&& ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 9))
|
||||
# define _Py_NO_SANITIZE_UNDEFINED __attribute__((no_sanitize_undefined))
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue