| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Extend the _Py_TYPEOF macro to more implementations of __typeof__ and standardized equivalents on C23 and C++11. On MSVC, __typeof__ is enabled through _MSC_VER check; for others, an autoconf probe is implemented.
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead. |
Sorry, something went wrong.
|
Hello! Sorry for the delay in reviewing. Ideally, find a way to use Py_SETREF (which _Py_TYPEOF) in Lib/test/test_cext/extension.c -- which tests on different compiler settings. Also, I'd prefer not adding the configure check. I don't see much benefit over __STDC_VERSION__, and I'd rather avoid Python.h defining another HAVE_* macro. (And removing it will remove the conflict.) |
Sorry, something went wrong.
|
Thanks for reviewing, I did the PR to see if it gets a better chance than #121643, however cpython has grown to requiring more patches (__attribute__((section)) usage and an already-reported mimalloc bug #134070), so I'm fine patching cpython for my compiler. On C23 typeof, I recently came across a peculiar GCC behavior that lead to it to silently remove noreturn from function pointers llvm/llvm-project#176070, so for GCC it's probably safer to stick to __typeof__. |
Sorry, something went wrong.
|
Thanks. |
Sorry, something went wrong.
|
Just tested 3.15 master (default and --disable-gil), in addition to #134070 these are enough for slimcc to pass all tests (sans test_gdb, probably caused by lacking DWARF info). diff --git a/Include/internal/pycore_debug_offsets.h b/Include/internal/pycore_debug_offsets.h
index 66f14e6..fbdc40a 100644
--- a/Include/internal/pycore_debug_offsets.h
+++ b/Include/internal/pycore_debug_offsets.h
@@ -41,7 +41,7 @@ extern "C" {
#define _GENERATE_DEBUG_SECTION_APPLE(name)
#endif
-#if defined(__linux__) && (defined(__GNUC__) || defined(__clang__))
+#if defined(__linux__) && (defined(__GNUC__) || defined(__clang__) || (_Py__has_attribute(section) && _Py__has_attribute(used)))
#define _GENERATE_DEBUG_SECTION_LINUX(name) \
__attribute__((section("." Py_STRINGIFY(name)))) \
__attribute__((used))
diff --git a/Objects/mimalloc/init.c b/Objects/mimalloc/init.c
index 81b2410..3856a10 100644
--- a/Objects/mimalloc/init.c
+++ b/Objects/mimalloc/init.c
@@ -676,7 +676,7 @@ static void mi_cdecl mi_process_done(void) {
}
static bool mi_initialized = _mi_process_init();
-#elif defined(__GNUC__) || defined(__clang__)
+#elif defined(__GNUC__) || defined(__clang__) || _Py__has_attribute(constructor)
// GCC,Clang: use the constructor attribute |
Sorry, something went wrong.
|
Do you want to work on this PR, or may I take over? Does slimcc recognize [[gcc::section, gcc::used]] attributes, with the C23 syntax?
I don't think this bug is likely to hit CPython, so I'd prefer not working around it. |
Sorry, something went wrong.
Yes, it does! But the corresponding check of C23 style attributes should be __has_c_attribute(gnu::section) instead.
IMO __attribute__((section)) is kind of "owned" by GNU tool chain so it's somewhat expected for compilers reporting __has_attribute(section) to aim for compatible behavior.
Please do! Thank you for taking care in this. |
Sorry, something went wrong.
|
This PR is stale because it has been open for 30 days with no activity. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Extend the _Py_TYPEOF macro to more implementations of typeof and standardized equivalents on C23 and C++11. On MSVC, typeof is enabled through _MSC_VER check; for others, an autoconf probe is implemented.