-
-
Notifications
You must be signed in to change notification settings - Fork 271
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
feat: copy .pdb
files to Editable Installation
and Wheel
for easier debugging on windows
#2220
base: main
Are you sure you want to change the base?
Conversation
…sier debugging on windows
✅ Deploy Preview for maturin-guide ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
…oid mistakenly assuming MSVC debug information during cross-compilation.
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.
Thanks for the PR!
For Linux, when --with-debuginfo
is presented, we can explicitly pass -C split-debuginfo=off
to rustc, similarly for macOS we pass -C split-debuginfo=unpacked
.
(And it'd be better to check for existing split-debuginfo
rustc flag and error out when its value is incompatible with --with-debuginfo
.)
/// Include debug information in the Wheel. | ||
/// Currently only support `.pdb` files with | ||
/// the same name as the binary(`exe/dll`) on `msvc` platform | ||
#[arg(long)] |
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.
This can't be used together with --strip
. (Not sure if clap
supports this kind of setup though)
#[arg(long)] | |
#[arg(long, conflicts_with = "strip")] |
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.
On MSVC
, even if RUSTFLAGS="-Cstrip=symbols"
is specified, rustc
(at least with version 1.81
that I used) will still generate a .pdb
file, so we can't let it conflict. Not sure how it behaves on macOS
.
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.
But does the .pdb
file contain useful information?
Thank you for the review!
I'm concerned that there is no simple and robust way to check the value of Considering the difficulty of confirming existing configurations and the uncertainty of whether developers are indeed generating the corresponding debug files, I implemented Specifically, when using This commit introduced a regression on FreeBSD, which I couldn’t reproduce on Windows. I’m unsure if it’s a sporadic issue. Could we re-run the CI? |
It's handled by
I disagree, it should provide a seamless user experience by default w/o asking user to look up how to set the right |
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.