[PATCH 1/2] ld: Add --pdb option

Martin Storsjö martin@martin.st
Mon Oct 3 18:58:19 GMT 2022


On Mon, 3 Oct 2022, Mark Harmstone wrote:

> Hi Martin,
>
>> As I assume you're aware, lld's mingw port also supports PDB generation - 
>> and the description of this option also sounds like it's chosen to match 
>> lld's option for outputting PDB files - that's good!
>
> Yes, that's right. One notable difference is that the parameter here is 
> optional, unlike with lld, making it a lot easier to fit this into e.g. CMake 
> toolchain files or LDFLAGS.

LLD also has got that behaviour, since 
https://github.com/llvm/llvm-project/commit/2c52ddf31f5421c5373923535b958b84c79772e3 
in 2019. That's in particular why I wanted to make sure that this case 
works the same in binutils too.

> It looks like the equals sign is mandatory when providing optional 
> parameters, otherwise it interprets the filename as another parameter.

Yep, that's the case in LLD too.

Unfortunately I didn't think of this behaviour initially when I first 
added this option - otherwise we could have had e.g. --pdb as a boolean 
option to just output to the default name, and e.g. --output-pdb=<name> if 
you wanted to specify the name. But oh well, "-pdb=" works, and I guess it 
isn't the worst thing in the world.

> But it does mean that the form "-pdb=out.pdb" will work on both ld and 
> lld, which I think is the most important thing.

TBH, I consider the "-pdb=" case equally important too - that's what most 
people would use in the end.

// Martin



More information about the Binutils mailing list