aboutsummaryrefslogtreecommitdiff
path: root/lld/COFF/PDB.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-09-09[LLD][COFF] Make `/summary` work when `/debug` isn't provided (#157476)Alexandre Ganea1-46/+26
Previously, `/summary` was meant to print some PDB information. Now move handling of `/summary` to `Writer.cpp` so that it can have an effect when `/debug` isn't provided. This will also provide grounds for extending with more general information.
2025-09-08[LLD][COFF] Display the size of all consumed inputs with /summary (take 2) ↵Alexandre Ganea1-2/+7
(#157284) When `/summary` is used, we now also display the cumulative size of all input OBJ files, including those pulled from archives. Lazy OBJ files that were not pulled in are not accounted for. Also added separators between digit groups, to make the output more bearable. Example output: ``` > lld-link ... /summary Summary -------------------------------------------------------------------------------- 4,958 Input OBJ files (expanded from all cmd-line inputs) 46,715,790,512 Size of all consumed OBJ files (non-lazy), in bytes 42 PDB type server dependencies 0 Precomp OBJ dependencies 293,910,064 Input type records 16,931,361,928 Size of all input type records, in bytes 11,201,549 Merged TPI records 2,765,494 Merged IPI records 38,649 Output PDB strings 21,512,230 Global symbol records 82,380,837 Module symbol records 715,313 Public symbol records ``` I've skipped over the exact amounts for "Size of all consumed inputs (non-lazy)" in the unit tests, since the sizes of OBJ files can fluctuate between compilers. _(this is a reopening of https://github.com/llvm/llvm-project/pull/157279 which wasa committed by mistake)_
2025-09-06Revert "[LLD][COFF] Display the size of all consumed inputs with `/summary`" ↵Alexandre Ganea1-7/+2
(#157282) Reverts llvm/llvm-project#157279
2025-09-06[LLD][COFF] Display the size of all consumed inputs with `/summary` (#157279)Alexandre Ganea1-2/+7
When `/summary` is used, we now also display the cumulative size of all input OBJ files, including those pulled from archives. Lazy OBJ files that were not pulled in are not accounted for. Also added separators between digit groups, to make the output more bearable. Example output: ``` > lld-link ... /summary Summary -------------------------------------------------------------------------------- 4,958 Input OBJ files (expanded from all cmd-line inputs) 46,715,790,512 Size of all consumed OBJ files (non-lazy), in bytes 42 PDB type server dependencies 0 Precomp OBJ dependencies 293,910,064 Input type records 16,931,361,928 Size of all input type records, in bytes 11,201,549 Merged TPI records 2,765,494 Merged IPI records 38,649 Output PDB strings 21,512,230 Global symbol records 82,380,837 Module symbol records 715,313 Public symbol records ``` We skip over the exact amounts for "Size of all consumed inputs (non-lazy)" in the unit tests, since the sizes of OBJ files can fluctuate between compilers.
2025-07-28[LLD][COFF] Allow symbols with empty chunks to have no associated output ↵Jacek Caban1-3/+6
section in the PDB writer (#149523) If a chunk is empty and there are no other non-empty chunks in the same section, `removeEmptySections()` will remove the entire section. In this case, use a section index of 0, as the MSVC linker does, instead of asserting.
2025-05-25[lld] Remove unused includes (NFC) (#141421)Kazu Hirata1-10/+0
2024-12-15[LLD][COFF] Store reference to SymbolTable instead of COFFLinkerContext in ↵Jacek Caban1-1/+1
InputFile (NFC) (#119296) This change prepares for the introduction of separate hybrid namespaces. Hybrid images will require two `SymbolTable` instances, making it necessary to associate `InputFile` objects with the relevant one.
2024-12-12[lld-link] Replace warn(...) with Warn(ctx)Fangrui Song1-24/+29
2024-12-05[lld-link] Use COFFSyncStreamFangrui Song1-7/+6
Add a operator<< overload for Symbol *.
2024-12-04[lld-link] Replace log(...) with LogFangrui Song1-1/+2
2024-12-03[lld-link] Simplify warnUnusable. NFCFangrui Song1-4/+3
2024-12-03[lld-link] Replace message(...) with Msg(ctx)Fangrui Song1-1/+1
to avoid the global ctx.
2024-11-08[LLD][COFF] Use correct machine types in PDB records on ARM64EC (#115309)Jacek Caban1-1/+11
2024-09-13[LLD][COFF][NFC] Store live flag in ImportThunkChunk. (#108459)Jacek Caban1-2/+2
Instead of ImportFile. This is a preparation for ARM64EC support, which has both x86 and ARM64EC thunks and each of them needs a separate flag.
2024-04-05[LLD][COFF] Add ARM64EC support to findLineTable. (#87240)Jacek Caban1-7/+7
Fixes asserts in error messages. Use chunk machine type (instead of global one) to support x86_64 objects and treat ARM64EC objects like ARM64 ones.
2024-01-25[LLD] Silence warning when compiling with MSVC targetting x86Alexandre Ganea1-1/+1
This fixes: ``` [5383/6995] Building CXX object tools\lld\COFF\CMakeFiles\lldCOFF.dir\PDB.cpp.obj C:\git\llvm-project\lld\COFF\PDB.cpp(835): warning C4018: '>=': signed/unsigned mismatch ```
2023-12-09[ADT] Rename SmallString::{starts,ends}with to {starts,ends}_with (#74916)Kazu Hirata1-1/+1
This patch renames {starts,ends}with to {starts,ends}_with for consistency with std::{string,string_view}::{starts,ends}_with in C++20. Since there are only a handful of occurrences, this patch skips the deprecation phase and simply renames them.
2023-10-12Use llvm::endianness::{big,little,native} (NFC)Kazu Hirata1-6/+7
Note that llvm::support::endianness has been renamed to llvm::endianness while becoming an enum class as opposed to an enum. This patch replaces support::{big,little,native} with llvm::endianness::{big,little,native}.
2023-10-05[LLD][COFF] Add support for `--time-trace` (#68236)Alexandre Ganea1-46/+76
This adds support for generating Chrome-tracing .json profile traces in the LLD COFF driver. Also add the necessary time scopes, so that the profile trace shows in great detail which tasks are executed. As an example, this is what we see when linking a Unreal Engine executable: ![image](https://github.com/llvm/llvm-project/assets/37383324/b2e26eb4-9d37-4cf9-b002-48b604e7dcb7)
2023-10-02[LLD][COFF] Delete unused field `DebugSHandler::source`Alexandre Ganea1-6/+3
2023-10-02[LLD][COFF] Remove unused `DebugSHandler::recordStringTableReferences`Alexandre Ganea1-2/+0
2023-06-05[lld] StringRef::{starts,ends}with => {starts,ends}_with. NFCFangrui Song1-3/+3
The latter form is now preferred to be similar to C++20 starts_with. This replacement also removes one function call when startswith is not inlined.
2023-04-27Fix PDB relocation on big-endian hostsUlrich Weigand1-3/+4
When running the LLD test suite on a big-endian host, the COFF/pdb-framedata.yaml test case currently fails. As it turns out, this is because code in DebugSHandler::finish intended to relocate RvaStart entries of FDO records does not work correctly when compiled for a big-endian host. Fixed by always reading file data in little-endian mode. Reviewed By: aganea Differential Revision: https://reviews.llvm.org/D149268
2023-02-24[PDB] Error on too large stream directoriesHans Wennborg1-0/+7
We hit this in Chromium builds where the PDB file was just under 4GB, but the stream directory was actually too large to be correctly represented. llvm-pdbutil would error about this in llvm::msf::validateSuperBlock, but lld should not write such PDB files in the first place. Differential revision: https://reviews.llvm.org/D144385
2023-01-10Move from llvm::makeArrayRef to ArrayRef deduction guides - last partserge-sans-paille1-4/+4
This is a follow-up to https://reviews.llvm.org/D140896, split into several parts as it touches a lot of files. Differential Revision: https://reviews.llvm.org/D141298
2023-01-09[LLD] Remove global state in lld/COFFAmy Huang1-49/+66
Remove globals from the lldCOFF library, by moving globals into a context class. This patch mostly moves the config object into COFFLinkerContext. See https://lists.llvm.org/pipermail/llvm-dev/2021-June/151184.html for context about removing globals from LLD. Reviewed By: aganea Differential Revision: https://reviews.llvm.org/D110450
2023-01-09Revert "[LLD] Remove global state in lld/COFF"Martin Storsjö1-66/+49
This reverts commit 7370ff624d217b0f8f7512ca5b651a9b8095a411. (and 47fb8ae2f9a4075de05433ef24f459b6befd1730). This commit broke the symbol type in import libraries generated for mingw autoexported symbols, when the source files were built with LTO. I'll commit a testcase that showcases this issue after the revert.
2023-01-08[LLD] Remove global state in lld/COFFAmy Huang1-49/+66
Remove globals from the lldCOFF library, by moving globals into a context class. This patch mostly moves the config object into COFFLinkerContext. See https://lists.llvm.org/pipermail/llvm-dev/2021-June/151184.html for context about removing globals from LLD. Reviewed By: aganea Differential Revision: https://reviews.llvm.org/D110450
2022-12-10[lld] Use std::optional instead of None in comments (NFC)Kazu Hirata1-2/+2
This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-06[CodeView] Add support for local S_CONSTANT recordsTobias Hieta1-3/+3
CodeView doesn't have the ability to represent variables in other ways than as in registers or memory values, but LLVM very often transforms simple values into constants, consider this program: int f () { int i = 123; return i; } LLVM will transform `i` into a constant value and just leave behind a llvm.dbg.value, this can't be represented as a S_LOCAL record in CodeView. But we can represent it as a S_CONSTANT record. This patch checks if the location of a debug value is null, then we will insert a S_CONSTANT record instead of a S_LOCAL value with the flag "OptimizedAway". In lld we then output the S_CONSTANT in the right scope, before they where always inserted in the global stream, now we check the scope before inserting it. This has shown to improve debugging for our developers internally. Fixes to llvm/llvm-project#55958 Reviewed By: aganea Differential Revision: https://reviews.llvm.org/D138995
2022-11-27[COFF] Change most Optional to std::optionalFangrui Song1-3/+3
2022-11-26[COFF] Use std::optional in PDB.cpp (NFC)Kazu Hirata1-2/+3
This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-08[lld] Fix duplicate word typos. NFCFangrui Song1-1/+1
Based on lld/ part of D137338 but reflowed comments.
2022-08-08[LLD][COFF] Ignore DEBUG_S_XFGHASH_TYPE/VIRTUALTobias Hieta1-0/+4
These are new debug types that ships with the latest Windows SDK and would warn and finally fail lld-link. The symbols seems to be related to Microsoft's XFG which is their version of CFG. We can't handle any of this yet, so for now we can just ignore these types so that lld doesn't fail with a new version of Windows SDK. Fixes: #56285 Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D129378
2022-07-23Convert for_each to range-based for loops (NFC)Kazu Hirata1-8/+10
2022-02-23Cleanup llvm/DebugInfo/PDB headersserge-sans-paille1-0/+2
accumulated preprocessed size: before: 1065515095 after: 1065629059 Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup Differential Revision: https://reviews.llvm.org/D120195
2022-01-20Re-land [LLD] Remove global state in lldCommonAlexandre Ganea1-6/+7
Move all variables at file-scope or function-static-scope into a hosting structure (lld::CommonLinkerContext) that lives at lldMain()-scope. Drivers will inherit from this structure and add their own global state, in the same way as for the existing COFFLinkerContext. See discussion in https://lists.llvm.org/pipermail/llvm-dev/2021-June/151184.html The previous land f860fe362282ed69b9d4503a20e5d20b9a041189 caused issues in https://lab.llvm.org/buildbot/#/builders/123/builds/8383, fixed by 22ee510dac9440a74b2e5b3fe3ff13ccdbf55af3. Differential Revision: https://reviews.llvm.org/D108850
2022-01-16Revert [LLD] Remove global state in lldCommonAlexandre Ganea1-7/+6
It seems to be causing issues on https://lab.llvm.org/buildbot/#/builders/123/builds/8383
2022-01-16[LLD] Remove global state in lldCommonAlexandre Ganea1-6/+7
Move all variables at file-scope or function-static-scope into a hosting structure (lld::CommonLinkerContext) that lives at lldMain()-scope. Drivers will inherit from this structure and add their own global state, in the same way as for the existing COFFLinkerContext. See discussion in https://lists.llvm.org/pipermail/llvm-dev/2021-June/151184.html Differential Revision: https://reviews.llvm.org/D108850
2021-11-12lld: const-qualify iterations through VarStreamArray, NFCDuncan P. N. Exon Smith1-2/+2
No functionality change here; just unblocking a patch to LLVM.
2021-10-31[lld/coff] Add parsing for /pdbpagesize: flagNico Weber1-1/+1
It's not used for anything yet, but we now accept `/pdbpagesize:4096` (the default behavior) and we give arguably more useful diagnostics for other values. It's plumbed through to the MSF layer, so just uncommenting out the bit in DriverUtils.cpp that rejects args other than 4096 is enough to try other values. Differential Revision: https://reviews.llvm.org/D112871
2021-10-23Use StringRef::contains (NFC)Kazu Hirata1-2/+2
2021-09-17Reland "[LLD] Remove global state in lld/COFF" after fixing asan and msan ↵Amy Huang1-58/+48
test failures Original commit description: [LLD] Remove global state in lld/COFF This patch removes globals from the lldCOFF library, by moving globals into a context class (COFFLinkingContext) and passing it around wherever it's needed. See https://lists.llvm.org/pipermail/llvm-dev/2021-June/151184.html for context about removing globals from LLD. I also haven't moved the `driver` or `config` variables yet. Differential Revision: https://reviews.llvm.org/D109634 This reverts commit a2fd05ada9030eab2258fff25e77a05adccae128. Original commits were b4fa71eed34d967195514fe9b0a5211fca2bc5bc and e03c7e367adb8f228332e3c2ef8f45484597b719.
2021-09-16Temporarily revert "[LLD] Remove global state in lld/COFF" and "[lld] Add ↵Amy Huang1-48/+58
test to check for timer output" Seems to be causing a number of asan test failures. This reverts commit b4fa71eed34d967195514fe9b0a5211fca2bc5bc and e03c7e367adb8f228332e3c2ef8f45484597b719.
2021-09-16[LLD] Remove global state in lld/COFFAmy Huang1-58/+48
This patch removes globals from the lldCOFF library, by moving globals into a context class (COFFLinkingContext) and passing it around wherever it's needed. See https://lists.llvm.org/pipermail/llvm-dev/2021-June/151184.html for context about removing globals from LLD. I also haven't moved the `driver` or `config` variables yet. Differential Revision: https://reviews.llvm.org/D109634
2021-08-31[LLD][COFF] Clean paths in PDB even when /pdbsourcepath is omittedAlexandre Ganea1-0/+1
Differential Revision: https://reviews.llvm.org/D109030
2021-07-08PR51018: Remove explicit conversions from SmallString to StringRef to ↵David Blaikie1-1/+1
future-proof against C++23 C++23 will make these conversions ambiguous - so fix them to make the codebase forward-compatible with C++23 (& a follow-up change I've made will make this ambiguous/invalid even in <C++23 so we don't regress this & it generally improves the code anyway)
2021-05-19[PDB] Do not record PGO or coverage public symbolsReid Kleckner1-1/+18
These symbols are long, and they tend to cause the PDB file size to overflow. They are generally not necessary when debugging problems in user code. This change reduces the size of chrome.dll.pdb with coverage from 6,937,108,480 bytes to 4,690,210,816 bytes. Differential Revision: https://reviews.llvm.org/D102719
2021-05-18[PDB] Improve error handling when writes failReid Kleckner1-3/+7
Handle PDB writing errors like any other error in LLD: emit an error and continue. This allows the linker to print timing data and summary data after linking, which can be helpful for finding PDB size problems. Also report how large the file would have been. Example output: lld-link: error: Output data is larger than 4 GiB. File size would have been 6,937,108,480 lld-link: error: failed to write PDB file ./chrome.dll.pdb Summary -------------------------------------------------------------------------------- 33282 Input OBJ files (expanded from all cmd-line inputs) 4 PDB type server dependencies 0 Precomp OBJ dependencies 33396931 Input type records ... snip ... Input File Reading: 59756 ms ( 45.5%) GC: 7500 ms ( 5.7%) ICF: 3336 ms ( 2.5%) Code Layout: 6329 ms ( 4.8%) PDB Emission (Cumulative): 46192 ms ( 35.2%) Add Objects: 27609 ms ( 21.0%) Type Merging: 16740 ms ( 12.8%) Symbol Merging: 10761 ms ( 8.2%) Publics Stream Layout: 9383 ms ( 7.1%) TPI Stream Layout: 1678 ms ( 1.3%) Commit to Disk: 3461 ms ( 2.6%) -------------------------------------------------- Total Link Time: 131244 ms (100.0%) Differential Revision: https://reviews.llvm.org/D102713
2021-03-11[PDB] Improve warning for corrupt debug infoReid Kleckner1-12/+17
The S_[GL]PROC32_ID symbol records are supposed to point to function ID records. If they don't, they are corrupt. The warning message here was very technical, but a user has encountered it in the wild. Add some more information and some more testing.