-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
PYBIND11_PLATFORM_ABI_ID
Modernization Continued (WIP)
#5439
base: master
Are you sure you want to change the base?
Conversation
With this PR at commit 14f8425 and logs_30720380481.zip downloaded from here:
This doesn't look right, @robertmaynard I was trying to follow your #4953 (comment) but maybe I'm misunderstanding? (I want to leave NVHPC for later.) |
This presumes that GCC will rev the major value of |
One more thing to fix would be to remove the compiler id |
I am surprised by |
It's generated in this line:
|
Ah, interesting. So for |
Yes. |
Further constrain to GXX_ABI 1002 or greater and less than 2000, hopefully future proof by summarizing that as `1` along with CXX11 on or off.
I just pushed a new commit that produces something like
It also ensures |
Here are the results extracted from the latest CI logs: (Click on any job, then the gear that appears in the top-right corner of the window with the log for that job, then "Download log archive".)
On chat @cryos and I decided to go with Looking at these:
I think we want to omit But what about Does anyone know if And what should we do about this one? Could/should we just omit these lines
and rely on the new |
After discussions with Ralf Grosse-Kunstleve we think these would make good identifiers that are concise and clear.
Within the `__GXX_ABI_VERSION` block this should always be defined, guard against unexpected defines and make the error obvious.
Here are the results extracted from the latest CI logs:
|
The current changes affect "C language object files created with the compiler are binary compatible with the GCC and C/C++ language library." AFAICT, the compiler also links against the system Upshot: I think we should also omit |
…X_USE_CXX11_ABI` (similarly to `gxx_abi` for `__GXX_ABI_VERSION`).
…`_gcc` with `_system`
I just pushed up the experimental commit fe2dbcb which changes Rationale:
I'll post a new |
Latest logs_31272968106.zip — https://github.com/pybind/pybind11/actions/runs/11999580827/job/33447666543?pr=5439
|
@robertmaynard do you have a moment to look at this PR? (The changes are small and all in just one file.)
|
Looks good to me
NVHPC should be ABI compatible with gcc. I am fine either way in how you want to manage that integration from a PR perspective. |
Thanks a lot @robertmaynard for the review!
Based on your comment, I added commit 9fc9515: Add NVHPC (__PGI) to the list of compilers (assumed to be) compatible with system compiler. |
…block. Also add comment pointing to this PR (pybind#5439).
…ILD_ABI block." This reverts commit d412303.
…stem compiler." This reverts commit 9fc9515.
…CXX_USE_CXX11_ABI
I had to backtrack (b6ccce3, a584398), after spending more time on this than I'd like to admit. I determined conclusively that
Without a way to obtain For now I settled on 23a5f2b, which is probably (?) what @robertmaynard suggested previously. |
Latest logs_31336371389.zip — https://github.com/pybind/pybind11/actions/runs/12026563895/job/33525815426?pr=5439
|
…C is always in the 1xxx ABI family.
Latest logs_31368853117.zip — https://github.com/pybind/pybind11/actions/runs/12039062120/job/33566108736?pr=5439
|
@dkolsen-pgi wrote on chat (thanks a lot!):
I used this command to produce a list of all pre-defined preprocessor macros (NVHPC 23.5):
I settled on this approach (@ commit 02daf15): # elif defined(_GLIBCXX_USE_CXX11_ABI) // See PR #5439.
# if defined(__NVCOMPILER)
// // Assume that NVHPC is in the 1xxx ABI family.
// // THIS ASSUMPTION IS NOT FUTURE PROOF but apparently the best we can do.
// // Please let us know if there is a way to validate the assumption here.
# elif !defined(__GXX_ABI_VERSION)
# error \
"Unknown platform or compiler (_GLIBCXX_USE_CXX11_ABI): PLEASE REVISE THIS CODE."
# endif
# if defined(__GXX_ABI_VERSION) && __GXX_ABI_VERSION < 1002 || __GXX_ABI_VERSION >= 2000
# error "Unknown platform or compiler (__GXX_ABI_VERSION): PLEASE REVISE THIS CODE."
# endif
# define PYBIND11_BUILD_ABI \
"_gxx_abi_1xxx_use_cxx11_abi_" PYBIND11_PLATFORM_ABI_ID_TOSTRING( \
_GLIBCXX_USE_CXX11_ABI)
# else
# error "Unknown platform or compiler: PLEASE REVISE THIS CODE."
# endif |
Hi @isuruf, could you please help with a review of the latest state? Do you think this will work for Conda? The latest |
Two comments about this PR: Can we remove Could the |
I want get rid of it, too, but I felt hesitant because
Regarding the very small risk, I used github search code to look for and many clones of that. But then again, that only mentions I believe the best approach is to remove it in a follow-on PR. I'll do right after this PR is merged. That way it'll be easier to refer to and discuss the removal, in case there are breakages. |
Great, that sounds like a good plan. Regarding this message:
The leading underscore is an artifact of string concatenation in |
I totally agree. Sorry this slipped my mind before. I'll try to fold that into this PR. |
Getting rid of the leading underscore isn't so easy, unfortunately, mainly because I found many manipulations of I'm guessing people found themselves forced to introduce those manipulations exactly because of the problems fixed by this PR. Here is one randomly picked example (out of nearly 600 build.ninja file paths produced by github search code):
Now, assuming diff --git a/include/pybind11/conduit/pybind11_platform_abi_id.h b/include/pybind11/conduit/pybind11_platform_abi_id.h
index af9a68ff..a44bd7f4 100644
--- a/include/pybind11/conduit/pybind11_platform_abi_id.h
+++ b/include/pybind11/conduit/pybind11_platform_abi_id.h
@@ -24,13 +24,13 @@
// compiler is compatible.
#ifndef PYBIND11_COMPILER_TYPE
# if defined(__MINGW32__)
-# define PYBIND11_COMPILER_TYPE "_mingw"
+# define PYBIND11_COMPILER_TYPE "mingw"
# elif defined(__CYGWIN__)
-# define PYBIND11_COMPILER_TYPE "_gcc_cygwin"
+# define PYBIND11_COMPILER_TYPE "gcc_cygwin"
# elif defined(_MSC_VER)
-# define PYBIND11_COMPILER_TYPE "_msvc"
+# define PYBIND11_COMPILER_TYPE "msvc"
# elif defined(__INTEL_COMPILER) || defined(__clang__) || defined(__GNUC__)
-# define PYBIND11_COMPILER_TYPE "_system" // Assumed compatible with system compiler.
+# define PYBIND11_COMPILER_TYPE "system" // Assumed compatible with system compiler.
# else
# error "Unknown PYBIND11_COMPILER_TYPE: PLEASE REVISE THIS CODE."
# endif
diff --git a/include/pybind11/detail/internals.h b/include/pybind11/detail/internals.h
index 278f35bb..037f59e0 100644
--- a/include/pybind11/detail/internals.h
+++ b/include/pybind11/detail/internals.h
@@ -272,11 +272,11 @@ struct type_info {
#define PYBIND11_INTERNALS_ID \
"__pybind11_internals_v" PYBIND11_TOSTRING(PYBIND11_INTERNALS_VERSION) \
- PYBIND11_PLATFORM_ABI_ID "__"
+ "_" PYBIND11_PLATFORM_ABI_ID "__"
#define PYBIND11_MODULE_LOCAL_ID \
"__pybind11_module_local_v" PYBIND11_TOSTRING(PYBIND11_INTERNALS_VERSION) \
- PYBIND11_PLATFORM_ABI_ID "__"
+ "_" PYBIND11_PLATFORM_ABI_ID "__"
/// Each module locally stores a pointer to the `internals` data. The data
/// itself is shared among modules with the same `PYBIND11_INTERNALS_ID`. ... we'll essentially break manipulations like above, because the On balance I'd say, the leading underscore is annoying, but removing it isn't worth such troubles. Unless we find some other compromise solution? |
…d compatibility.
…ro definitions is the same as in the list defining `PYBIND11_PLATFORM_ABI_ID`
What I learned from the work on #5439 (comment) got me to add I don't expect any extra fallout from those two changes. The |
Just to double-check, the latest logs_31527439795.zip — https://github.com/pybind/pybind11/actions/runs/12108518322/job/33756607834?pr=5439
|
Description
WORK IN PROGRESS
PR #4953 already modernized the
PYBIND11_BUILD_ABI
for MSVC.To be addressed in this PR:
PYBIND11_INTERNALS_VERSION
Suggested changelog entry: