-
Notifications
You must be signed in to change notification settings - Fork 1.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
Add ldscript code for Python extensions in CMake #6665
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.
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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a helper for this... why not use it?
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" | |
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...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.
Urgh, looks like I made a commit with the wrong message as the fix -- I'll squash it away :-) |
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.