Microsoft SourceLink equivalent for LLVM/Clang

I made an interesting discovery today, SourceLink []

It would appear it is information describing where to fetch the source code for a particular built object file or image.

My research indicates no search format exists for DWARF and/or neither Clang nor GCC emit this sort of information.

Are there DWARF gods here who would like to introduce this in DWARF?

As an aside could Clang be taught such a trick for Windows in its PDB generation process? I’ve not been tracking the PDB progress closely recently but having this parity with PDBs generated by MSVC would be nifty.

I was made aware of this recently when talking to the Microsoft people at cppcon. I haven’t added PDB support for this yet, but I don’t think it would be difficult. It’s low priority simply because the number of people currently using this is probably close to zero just because Its discoverability is also close to zero. It was also only introduced in the Microsoft Linker within the past couple of months, so it’s very new.

Anyway, it’s in my backlog and I’ll probably implement it soonish just for the sake of parity as you said.

I haven’t looked at the schema in too much detail, but my understanding is that it’s some JSON that you embed in the PDB file describes source file locations. Neither the compiler nor the linker have to do any work to construct this JSON at all, it’s purely up to the developer to pass a hand-written JSON file on the command line to the linker, but the paths in the JSON can refer to arbitrary URLs, including – for example – to something like Github URLs.

This brilliant feature needs to be in Clang!

Sadly I don’t work on this anymore (you may have notice that the email address that you added bounced), but I still remember enough of the details that I’m able to offer some guidance if you want to try adding support for it.