feat: copy .pdb
files to Editable Installation
and Wheel
for easier debugging on windows
#2220
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.
Close #2213
What I Did
I added a
--with-debuginfo
option to bothmaturin dev
andmaturin build
. Currently, it only works onmsvc
. When this option is specified:maturin dev
will copy the debug file (e.g.,mylib.pdb
) with the same name as theartifact
(e.g.,mylib.dll
) to theeditable install
directory.maturin build
will include the debug file in thewheel
.bin
bindings,*.pdb
will be distributed along with*.exe
in theScripts
directory.Even if developers do not generate debug information, there will be no impact as long as they don't manually specify
--with-debuginfo
.Specifically, with the following configuration:
The resulting directory structure would look like this:
Please note that the debug file is
lib_name.pdb
instead of_lib_name.pdb
, due to the linker flag/PDBALTPATH:%_PDB%
.Why Didn't I Implement Support for
macOS
andLinux
?Linux
On Linux, the default
split-debuginfo
isoff
, so the debug information is included in the.so
file. Therefore, no additional actions are needed by default.macOS
Currently, the default value for
split-debuginfo
on macOS ispacked
, but it seems recommended to set it tounpacked
, see https://internals.rust-lang.org/t/help-test-faster-incremental-debug-macos-builds-on-nightly/14016.I tried to reference python-build-standalone's approach. I downloaded these three distribution packages:
I found that only the
x86_64-pc-windows-msvc-install_only
package contained.pdb
debug information, while the other two platforms did not have any separate debug information. So, I am unsure how to implement this feature for those platforms.Most importantly, I do not have experience developing on macOS, nor do I have a macOS machine to perform the necessary testing. Therefore, this will need to be left for others to implement.
Next, I will work on writing tests and documentation, but I would like to get your feedback on the current implementation first.