Add ldscript code for Python extensions in CMake#6665
Merged
steven-johnson merged 3 commits intomainfrom Mar 29, 2022
Merged
Conversation
We added ldscripts to the Makefile for Python extensions (to restrict exported symbols to just the PyInit_foo symbol), but neglected to do so for CMake. This corrects that.
alexreinking
requested changes
Mar 29, 2022
Comment on lines
+27
to
+33
| if (APPLE) | ||
| configure_file(ext.ldscript.apple.in "${CMAKE_CURRENT_BINARY_DIR}/${GEN}.ldscript") | ||
| target_link_options(py_${GEN} PRIVATE "-Wl,-exported_symbols_list,${CMAKE_CURRENT_BINARY_DIR}/${GEN}.ldscript") | ||
| elseif (UNIX) | ||
| configure_file(ext.ldscript.linux.in "${CMAKE_CURRENT_BINARY_DIR}/${GEN}.ldscript") | ||
| target_link_options(py_${GEN} PRIVATE "-Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/${GEN}.ldscript") | ||
| endif() |
Member
There was a problem hiding this comment.
We have a helper for this... why not use it?
Suggested change
| if (APPLE) | |
| configure_file(ext.ldscript.apple.in "${CMAKE_CURRENT_BINARY_DIR}/${GEN}.ldscript") | |
| target_link_options(py_${GEN} PRIVATE "-Wl,-exported_symbols_list,${CMAKE_CURRENT_BINARY_DIR}/${GEN}.ldscript") | |
| elseif (UNIX) | |
| configure_file(ext.ldscript.linux.in "${CMAKE_CURRENT_BINARY_DIR}/${GEN}.ldscript") | |
| target_link_options(py_${GEN} PRIVATE "-Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/${GEN}.ldscript") | |
| endif() | |
| include(TargetExportScript) | |
| configure_file(ext.ldscript.apple.in "${CMAKE_CURRENT_BINARY_DIR}/${GEN}.ldscript.apple") | |
| configure_file(ext.ldscript.linux.in "${CMAKE_CURRENT_BINARY_DIR}/${GEN}.ldscript") | |
| target_export_script( | |
| py_${GEN} | |
| APPLE_LD "${CMAKE_CURRENT_BINARY_DIR}/${GEN}.ldscript.apple" | |
| GNU_LD "${CMAKE_CURRENT_BINARY_DIR}/${GEN}.ldscript" | |
| ) |
Contributor
Author
There was a problem hiding this comment.
...because I didn't know apparently completely forgot about it? :-)
Currently, there is no way to set 'synthetic' GeneratorParams via a GeneratorStub. ('synthetic' == things like "fieldname.type" for an input Buffer with an undefined static type.)
C++ GeneratorStubs are rarely used, but the Python stubs are useful, and (more importantly) revising this behavior to be possible will make some future work on Python generators more consistent.
Note that this should (in theory) have no effect on any existing C++ stub users; the new fields added to the stubs all have unique names, and aren't added to the default signatures.
alexreinking
approved these changes
Mar 29, 2022
Contributor
Author
|
Urgh, looks like I made a commit with the wrong message as the fix -- I'll squash it away :-) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We added ldscripts to the Makefile for Python extensions (to restrict exported symbols to just the PyInit_foo symbol), but neglected to do so for CMake. This corrects that.