You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Embed version number information in native libraries #5107
The Windows Native libraries produced by the CoreCLR build (coreclr.dll, mscordaccore.dll, etc.) all have easy ways to retrieve their version information (because they embed a Windows Version Resource, so filever can be used to get their version info).
However, as far as I can tell this is not true of Linux/Mac OS X binaries. It would be really useful if the version data were embedded somehow in these binaries. As far as I can tell, there is a place for this data in Mach-O binaries (dylib on Mac OS X), as ld has a -current_version switch that can be used to embed a version number (which can be viewed using otool -L <dylib name>). I'm not sure exactly what, if any, options exist in ELF binaries, but it could be as simple as defining a string or symbol somewhere that can be read using readelf. It looks like there's a .gnu.version section in most ELF files that has some kind of versioning information, but I'm certainly no expert.
This would really help diagnose issues where we just have a set of binaries and need to identify which coreclr version is in use. I realize that the managed assemblies (i.e. mscorlib) should have the same version number, but I don't want to rely on that, I'd rather be able to see the version info for each individual binary independently.
If I'm missing something and there is indeed a version stamp on all the binaries, let me know! I think this would be really useful for debugging if not though.
@markwilkie This issue is not unique to CoreCLR but applicable across the board. Are you tracking this requirement (to version native components on a per build basis)?
I'm against reinventing the wheel and messing with metadata in ELF/MachO/a.out/pe/other format. It only causes trouble for their consumers.
SCCS was defined in 1972 and the approach to embed sccs string is simple. The tools are standardized -- one of them is what(1) (in NetBSD since BSD-4.0 -- released in 1980).
$ cat t.c
static char sccsid[] = "@(#)ls.c 8.1 (Berkeley) 6/11/93";
int main(){}
$ gcc t.c -o test
$ ./test
$ what test
test
ls.c 8.1 (Berkeley) 6/11/93
AFAIK, what(1) is not standard on most Linux distributions. On Ubuntu, at least, it's provided by the cssc package and even then it's installed into /usr/lib/x86_64-linux-gnu/cssc/what not as a something available on $PATH.
I suspect if we go down this path, we'll end up having folks just do strings + grep to pull the version number out, not the end of the word but not as nice as @krytarowski shows above.
Using strings(1) with grep(1) (or specialized tools like radare2) is straight-forward. Lately Go broke some elf tools with additional tag and it's not nice at all.
I would assume that normally nobody will need it, perhaps just for debugging the runtime. If it will happen, then there will be plenty of ways and tools to get this data.
It definitely sounds like the SCCS id string is the most compatible way to do this. It would then support what but also strings+grep. While it's true that what is not installed on all distros, it seems useful to support it if doing so is simple and doesn't break strings+grep
@gkhanna79, @markwilkie could we also add the git sha hash to this version string? This would be really nice for our CSS support and internal devs to be able to checkout the sources for the build of our native binaries. Thanks.
We are close to having something be able to generate a version number but I'm not convinced that it will get done for RC2. I'm moving to RTM. Please let me know if anyone feels not having this for the x-plat mscorlib builds in RC2 will break anything critical.
Not exactly. I guess I can close dotnet/coreclr#3559 but I would keep this one open. The reason is that native binaries built in non-Windows platforms don't have version info yet, which is basically the topic of this issue. What I added is the versioning to all managed binaries in all platforms, and to native ones in Windows builds. I will now focus on adding it to the non-Windows native binaries following the example that @krytarowski mentions above using the sccsid string.
Activity
krytarowski commentedon Feb 12, 2016
How about just simple
what(1)? It will work without linker magic. We just need to embed a static ID string in the binary, for example:gkhanna79 commentedon Feb 27, 2016
@markwilkie This issue is not unique to CoreCLR but applicable across the board. Are you tracking this requirement (to version native components on a per build basis)?
markwilkie commentedon Feb 29, 2016
This is not yet currently be tracking as far as I know. @ellismg - any insight into the best way to handle this? Adding @jhendrixMSFT for visibility.
krytarowski commentedon Mar 1, 2016
I'm against reinventing the wheel and messing with metadata in ELF/MachO/a.out/pe/other format. It only causes trouble for their consumers.
SCCS was defined in 1972 and the approach to embed sccs string is simple. The tools are standardized -- one of them is
what(1) (in NetBSD since BSD-4.0 -- released in 1980).what(1) is defined by POSIXhttp://pubs.opengroup.org/onlinepubs/9699919799/utilities/what.html
ellismg commentedon Mar 1, 2016
AFAIK,
what(1)is not standard on most Linux distributions. On Ubuntu, at least, it's provided by the cssc package and even then it's installed into/usr/lib/x86_64-linux-gnu/cssc/whatnot as a something available on$PATH.I suspect if we go down this path, we'll end up having folks just do
strings+grepto pull the version number out, not the end of the word but not as nice as @krytarowski shows above.krytarowski commentedon Mar 1, 2016
Using
strings(1) withgrep(1) (or specialized tools likeradare2) is straight-forward. Lately Go broke some elf tools with additional tag and it's not nice at all.krytarowski commentedon Mar 1, 2016
For the reference:
I would assume that normally nobody will need it, perhaps just for debugging the runtime. If it will happen, then there will be plenty of ways and tools to get this data.
gkhanna79 commentedon Mar 1, 2016
@markwilkie I have assigned this to you to track as part of the overall engineering work you are driving for RC2.
@livarcocc - FYI since you are driving the signing for repos too.
CC @piotrpMSFT @schellap @weshaggard
analogrelay commentedon Mar 1, 2016
It definitely sounds like the SCCS id string is the most compatible way to do this. It would then support
whatbut alsostrings+grep. While it's true thatwhatis not installed on all distros, it seems useful to support it if doing so is simple and doesn't breakstrings+grepmikem8361 commentedon Mar 2, 2016
@gkhanna79, @markwilkie could we also add the git sha hash to this version string? This would be really nice for our CSS support and internal devs to be able to checkout the sources for the build of our native binaries. Thanks.
3 remaining items
sergiy-k commentedon Mar 23, 2016
@markwilkie, @joperezr, are we going to implement this for RC2?
markwilkie commentedon Mar 23, 2016
@weshaggard who can advise.
weshaggard commentedon Mar 23, 2016
We are close to having something be able to generate a version number but I'm not convinced that it will get done for RC2. I'm moving to RTM. Please let me know if anyone feels not having this for the x-plat mscorlib builds in RC2 will break anything critical.
analogrelay commentedon Mar 23, 2016
It's not critical, but man I really want it ;)
weshaggard commentedon Mar 23, 2016
@anurse I hear you but I don't think we will be able to get it through the system in time for RC2 which we are already locking down for.
analogrelay commentedon Mar 23, 2016
Oh totally, I get that :)
mikem8361 commentedon Mar 28, 2016
When we do add this version string including the git SHA hash will be invaluable to our CSS team (and of course internally).
gkhanna79 commentedon Apr 6, 2016
@joperezr With your PR merged, do we know have binaries building with the version info? If so, do you want to close https://github.com/dotnet/coreclr/issues/3559 and this issue?
joperezr commentedon Apr 6, 2016
Not exactly. I guess I can close dotnet/coreclr#3559 but I would keep this one open. The reason is that native binaries built in non-Windows platforms don't have version info yet, which is basically the topic of this issue. What I added is the versioning to all managed binaries in all platforms, and to native ones in Windows builds. I will now focus on adding it to the non-Windows native binaries following the example that @krytarowski mentions above using the sccsid string.
gkhanna79 commentedon Apr 6, 2016
Sounds good. Can we start to see binaries with versions in tonight's build?
joperezr commentedon Apr 6, 2016
Yes, if all goes well, mscorlib packages built for non-Windows should have version now.