Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for C++ libs #580

Open
nickdalt opened this issue Feb 19, 2020 · 4 comments
Open

Support for C++ libs #580

nickdalt opened this issue Feb 19, 2020 · 4 comments

Comments

@nickdalt
Copy link

Currently C++ support appears to be limited to DLL and EXE targets.

What I would like to see is sourcelink information being generated for static lib targets and then when the final link occurs into a executable the resulting pdb contains the combined sourcelink information for all the static libs that went into building the executable.

I am not sure if this would require an update to link.exe in order to support this scenario

@tmat
Copy link
Member

tmat commented Feb 19, 2020

This should be possible today, but I'm not sure if it works out-of-the box with just including the Source Link nuget packages in your projects. You might need some tweaking of the build.

The linker supports embedding source link record in each static lib's PDB and then preservers all these records in the final linked binary. link.exe has /sourcelink switch that instructs it to embed specified Source Link JSON.

@nickdalt
Copy link
Author

I test shows few problems:-

  1. Including the NuGet packages in a C++ static lib project does nothing at all. With a exe project it works as expected.

  2. While the linker supports the /sourcelink switch the lib tool does not

lib /sourcelink
LINK : warning LNK4044: unrecognized option '/sourcelink'; ignored

So currently the only option would appear to be to create source link files for each lib and then ship them with the libs. They would then need to be combined in the final link (assuming the /sourcelink switch cannot be used multiple times).

Ideally the lib tool would be updated to support /sourcelink

@bormm
Copy link

bormm commented Jan 26, 2021

Any news about this @tmat ?

@sylveon
Copy link

sylveon commented May 24, 2022

Am also interested in using SourceLink with static libraries

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants