issue 4014: output debug info for all referenced classes/structs and enumerators#398
issue 4014: output debug info for all referenced classes/structs and enumerators#398rainers wants to merge 1 commit intodlang:masterfrom
Conversation
|
I'm not sure this is a good idea. People rely on debug builds being fast, and duplicationg the debug info in ever .obj file can make for pretty slow builds. |
|
Furthermore passing unneeded symbols to OPTLINK could be a Bad Idea (™). |
|
I don't think debug info has a big impact on build times. I tried it combined file compilation (build all modules to one object file)
single file compilation (build all modules to object file first, then link)
so generating the debug info needs about 5% more compilation time, and |
That could be a valid concern ;-) But I have not seen any difficulties |
|
This pull request has been broken on win32 for essentially forever. It causes dmd to crash which on win32 pops up a dialog box, stalling the auto-tester. For now, I've disabled it from being tested (on every platform, sorry, quick hack). If/when it's fixed, let me know and I can remove the block. |
|
I just don't like the idea of duplicating the symbolic debug info. In reading the bug report, it seems the primary issue is that symdeb info is only generated for the module with the .init data. A better solution may be to have a module generated with only symdeb info for a class, and a single global defined. Then, other modules can reference that single global, thereby pulling in the symdeb data. |
|
I think that it could work, it was also my first idea about fixing the problem. But it has the drawback that you need to have the library compiled with debug information to be able to inspect data types declared in the library. For example, the phobos library in a standard installation comes without debug info, so you won't have any luck investigating non-templated structs or classes that are declared in phobos or druntime. Another (maybe constructed) argument: A struct with versioned members might not generate the same debug info when compiling the library and when actually using it in user code with the versioned declarations changed. This is a real problem in C/C++, the debugger can even switch between different representations when jumping from one source to another. I think the safer solution would be if the linker complains. The solution in the pull request is pretty simple and I haven't seen issues with it yet (I get linker crashes when compiling std.algorithm unittests with debug symbols for the library, but IIRC it happens without the patch aswell). If there is interest I can rebase the pull request and fix it. |
|
Another option may be to enable it with a compiler switch, say, -g2. |
|
I rebased the branch and fixed the problems that were also happening with the pull tester, but something caused the diff to gather other commits aswell. Can someone with more git-fu tell me what went wrong and how can I reduce the commits to my own ones? |
|
Given while on your branch. |
|
Some comments to the changes: I ran the test suite with command line option -g, but had to add a few tweaks:
I measured building the test suite with and without the patch, with and without debug info (not used multi-processor execution): clean quick: 1:11min, with -g: 1:18min 4014a quick: 1:11min, with -g: 1:13min Unfortunately the results for the full build don't seem very consistent, my processor is a mobile i7 with Turbo Boost. But I think they suggest that there is no noticeable build time penalty with the patch. |
|
|>||git rebase upstream/master| Thanks. But when I do this and push, I get To https://rainers@github.com/rainers/dmd.git I had this error before and pulled, so I guess it will bring me back to Last time I had the same issue I needed to git-reset something. |
|
When you rebase, you rewrite history, so you have to do a forced push, i.e.: |
|
Looks much better now. Thanks |
|
(background: I'm doing a review of pull requests < 1000 as they tend to be controversial) How about the option of doing it all on a flag, as Walter suggested? That may as well please everyone. I'm not sure I understand the best motivating use cases, but I presume those would go in the documentation. |
|
An option to have this would be an improvement, but I don't see a reason why incomplete debug information can be desirable. Maybe, use the "complete" debug info with the standard "-g", but allow "-g2" to get back to the current behaveour in case you run into trouble. |
Add isRandomNumberGenerator template
Brad, not sure if this is still useful, but you can disable the crash dialog boxes on Windows. I've encountered the need for this when using DustMite: Hope this helps. |
|
@braddr You should disable error reporting on test machines. |
That's the expected behavior.
Sounds like a good idea. How would that work if something references undefined debug info? |
I expect the behaviour of C/C++ where you can inspect a variable with struct type declared in some include file. Technically this is the same compilation unit as the actual source file, but this doesn't translate to D. What about di files that never get compiled to a library (C wrapper files in deimos)?
Isn't the init data just that global symbol containing the debug info? It might contain data actually never used, though. I'll try to rebase and enable the full debug info for referenced structs/classes with a flag -gf... |
|
Mmh, you don't even have initializers in Deimos, otherwise it would require linking. |
|
Rebased and option added. |
|
What's the status of this? I'll close for now, please reopen when ready. Thanks! |
|
It's a hack to write the debug information as a side effect of |
I agree to some extend, it should be better done in the backend. I'll have a look if it fits in there somewhere.
You mean when writing multiple object files? Yes, that will be incomplete aswell with this patch, but not as incomplete as without the patch. Moving it into the backend might also solve this. |
|
(@andralex for future reference, avoid closing a pull request as a person with push rights unless you mean to permanently close it. It will prevent the contributor from reopening it.) |
Yes, because toCtype is called only once per type per compile run. Thus when creating multiple objects
Either there or in the glue layer. AFAIK there is no data in the compiler that easily tells you which types are used in which object file. So I don't know a good solution but toCtype won't work as is due to the reason mentioned above. |
|
@alexrp ouch thanks for letting me know! I thought reopening is as simple as a button click regardless of who closed it. |
It still makes sense for abandoned pull request, it is as simple as writing a message to ask for reopening. |
|
Fine, so should I continue to proactively close pull requests that need attention from their proponents? |
|
In the closed pull request list, how can one tell which ones were not pulled? |
This should be a simple query, but the github API is awful. 3, 4, 5, 7, 8, 12, 14, 15, 17, 22, 26, 38, 57, 58, 62, 66, 70, 71, 74, 75, 84, 85, 88, 89, 91, 94, 97, 105, 109, 114, 115, 119, 120, 121, 123, 126, 135, 140, 141, 151, 155, 157, 159, 162, 173, 176, 177, 180, 181, 184, 188, 194, 198, 204, 207, 233, 234, 237, 240, 241, 242, 244, 248, 261, 263, 269, 277, 290, 296, 309, 318, 323, 339, 341, 342, 345, 347, 349, 351, 354, 357, 372, 377, 423, 426, 427, 448, 456, 457, 459, 461, 486, 489, 490, 495, 497, 501, 513, 520, 521, 523, 527, 545, 551, 559, 614, 632, 634, 638, 644, 646, 650, 653, 657, 660, 669, 674, 678, 682, 685, 687, 688, 696, 699, 701, 705, 714, 721, 726, 734, 738, 745, 760, 769, 770, 777, 786, 791, 793, 794, 843, 847, 861, 863, 868, 894, 902, 911, 928, 937, 941, 945, 950, 951, 952, 953, 955, 988, 1005, 1017, 1018, 1019, 1044, 1061, 1073, 1076, 1085, 1091, 1094, 1115, 1117, 1124, 1131, 1133, 1140, 1144, 1146, 1148, 1152, 1160, 1162, 1165, 1168, 1176, 1179, 1189, 1202, 1203, 1204, 1207, 1210, 1214, 1215, 1217, 1237, 1242, 1246, 1248, 1257, 1274, 1292, 1295, 1308, 1310, 1311, 1313, 1328, 1337, 1387, 1390, 1392, 1398, 1402, 1403, 1424, 1427, 1428, 1435, 1437, 1442, 1443, 1445, 1454, 1459, 1467, 1478, 1484, 1514, 1516, 1520, 1525, 1551, 1579, 1580, 1581, 1607, 1614, 1615, 1622, 1637, 1646, 1647, 1654, 1663, 1671, 1677, 1691, 1693, 1708, 1731, 1735, 1751, 1764, 1771, 1779, 1783, 1794, 1795, 1798, 1802, 1808, 1811, 1825, 1832, 1843, 1880, 1882, 1886, 1889, 1895, 1923, 1926, 1935, 1955, 1957, 1961, 1971, 1992, 2003, 2017, 2020 |
I've asked for this feature once, they said it would be a great idea if we could tell if a pull is closed or merged. But this was a few months ago, I don't know if they'll actually work on it.. |
|
Auto-merge toggled on |
|
Auto-merge toggled off |
…s and enumerators
|
Updated and rebased this PR. This is still an improvement, but I'm not sure this is the best possible solution. It still doesn't work well if the debug info is built into a library. The info is then linked to some random symbol (the first which referenced the type), but the code that is actually linked into the executable might not include this symbol.
I don't think this PR can solve all the problems of incremental building to separate object files. |
Sounds reasonable.
Can we handle this similarly to the new template instantiation logic. |
I changed my mind over this, it will cause a lot of link errors when building against a library witthout debug symbols. The init symbol still exists in the release library, so no harm done apart from being unable to debug that part of the application.
That is similar to assuming debug info is built with the init-symbol, that is what #4051 does. |
|
This is badly bitrotten. Closing for now. |
Not so sure, I've updated it 5 month ago and the merge conflict is probably only minor. I think it still represents the best solution to the issue. But it doesn't seem to have much chance to get merged, so I don't insist on keeping it open. |
|
Didn't mean to dismiss the work, just clean up the pr queue a bit. Please let me know what would be the best course of action. |
|
No problem. #4051 seems to be better in line with what @WalterBright and @MartinNowak expect, but it also has drawbacks. Maybe a combination of these would be best. |
This patch outputs full debug info for anything that is referenced, not only for declaration in modules on the command line. Leave it to the linker to filter out duplicates.
In toobj.c, it might also be possible to just leave out the call to toDebug()/toCtype(), because the debug info will always end up where the declaration is used.
The patch in cgcv.c was necessary, because it crashed on some debug info for me. Is the hack still necessary?
bugzilla: http://d.puremagic.com/issues/show_bug.cgi?id=4014