-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Closed
Labels
A-linkageArea: linking into static, shared libraries and binariesArea: linking into static, shared libraries and binariesE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Description
From convo with @retep998, passing /DEBUG, even w/o emitting debuginfo, makes backtraces work. They 'see no reason' not to always pass this flag.
This should be a simple change to rustc::back::link
.
Metadata
Metadata
Assignees
Labels
A-linkageArea: linking into static, shared libraries and binariesArea: linking into static, shared libraries and binariesE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
alexcrichton commentedon Sep 16, 2015
@retep998 I'm curious, but to what degree did this make backtraces work? I just tried this out and it didn't help unless debuginfo was also generated.
retep998 commentedon Sep 16, 2015
All tests done at
opt-level=0
using x86_64-pc-windows-msvcWith
/DEBUG
but no debuginfo:With
/DEBUG
and debuginfo:With neither
sfackler commentedon Sep 16, 2015
What's the __ImageBase thing that's ending up in the build with no debuginfo?
retep998 commentedon Sep 17, 2015
@sfackler Since no debug info is being emitted, and each object file only exports symbols for publicly accessible symbols. Those
__ImageBase
functions are either local functions or monomorphized functions. As such they aren't publicly exported, so no name is attached to them and thus the linker cannot emit any sort of debug symbols for them. For all the other functions, they are exported symbols in their various libraries, and so they provide symbol names that the linker can turn into debug symbols.alexcrichton commentedon Sep 17, 2015
Huh, now I'm not sure what I was testing... At least for a "hello world" executable it didn't have any affect on size, so 👍 from me!
retep998 commentedon Sep 17, 2015
It shouldn't have any effect on binary size since all the debug info is being emitted to a separate .pdb.
apasel422 commentedon Sep 19, 2015
I have a PR for this ready to go, but despite the lack of impact on binary file size, I'm wondering if we actually want to go ahead with this. There's no way to turn it off short of creating a new
rustc
flag, it causes additional filesystem churn, and it is potentially surprising for multiple files to be created./DEBUG
flag to MSVC linker #28505briansmith commentedon Sep 20, 2015
As somebody that uses -msvc rustc a whole lot, those concerns don't matter to me at all. I'm already used to them when dealing with MSVC C/C++, and in practice they don't seem to matter anyway. Just make sure that the dependency tracking for incremental rebuilds is aware of the multiple outputs.
retep998 commentedon Sep 20, 2015
Here is some further testing on a simple .exe built using Cargo.
cargo build --release
wheredebug = false
cargo rustc --release -- -Clink-args="/DEBUG"
wheredebug = false
As you can see the only size increase here is a really tiny bit in
.rdata
indicating that there is a .PDB and providing the absolute path to it.cargo build --release
wheredebug = true
I find it really weird that when emitting debug info with -msvc we're still also emitting dwarf debug info into the .exe itself.
brson commentedon Sep 21, 2015
rustc tends to provide precise control over the output artifacts with
--emit
, so I might expect pdb output to tie into that, but there's no--no-emit
option. It's also different from the other outputs since pdb is a side-effect of turning on debuginfo - iow, nobody is saying 'i want a pdb', they just want debugging to work.@alexcrichton Does rustc have an existing option for tools to use that prints out all the outputs of an invocation?
alexcrichton commentedon Sep 21, 2015
We do have
rustc --print file-names
although it definitely doesn't include things like these pdb files. One thing I just remembered, though, is that we rundsymutil
for OSX when debuginfo is enabled, generating*.dSYM
folders. In that sense there's mild precedence for something like this.Diggsey commentedon Sep 23, 2015
For reference, MSVC will by default always produce a .pdb file, even for release builds, so there's a precedent for this. However, it somehow does this without passing
/DEBUG
to the linker (it just passes/PDB
) - this seems to directly contradict what msdn says about/PDB
being ignored when/DEBUG
is not specified.Auto merge of #28505 - apasel422:issue-28448, r=alexcrichton