Skip to content

Embed version number information in native libraries #5107

Closed
dotnet/coreclr
#4393

Description

@analogrelay

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.

Activity

  1. krytarowski commented on Feb 12, 2016

    @krytarowski
    Contributor

    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:

    $ what /netbsd
    /netbsd
        NetBSD 7.99.25 (GENERIC) #0: Fri Dec 25 20:05:36 CET 2015
    
  2. gkhanna79 commented on Feb 27, 2016

    @gkhanna79
    Member

    @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)?

  3. markwilkie commented on Feb 29, 2016

    @markwilkie
    Contributor

    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.

  4. krytarowski commented on Mar 1, 2016

    @krytarowski
    Contributor

    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
    

    what(1) is defined by POSIX
    http://pubs.opengroup.org/onlinepubs/9699919799/utilities/what.html

  5. ellismg commented on Mar 1, 2016

    @ellismg
    Contributor

    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.

  6. krytarowski commented on Mar 1, 2016

    @krytarowski
    Contributor

    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.

  7. krytarowski commented on Mar 1, 2016

    @krytarowski
    Contributor

    For the reference:

    $ rafind2 -s '@(#)' -Z /tmp/test 
    0xd20 @(#)ls.c        8.1 (Berkeley) 6/11/93
    

    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.

  8. gkhanna79 commented on Mar 1, 2016

    @gkhanna79
    Member

    @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

  9. analogrelay commented on Mar 1, 2016

    @analogrelay
    ContributorAuthor

    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

  10. mikem8361 commented on Mar 2, 2016

    @mikem8361
    Contributor

    @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.

  11. 3 remaining items

  12. sergiy-k commented on Mar 23, 2016

    @sergiy-k
    Contributor

    @markwilkie, @joperezr, are we going to implement this for RC2?

  13. markwilkie commented on Mar 23, 2016

    @markwilkie
    Contributor

    @weshaggard who can advise.

  14. weshaggard commented on Mar 23, 2016

    @weshaggard
    Member

    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.

  15. analogrelay commented on Mar 23, 2016

    @analogrelay
    ContributorAuthor

    It's not critical, but man I really want it ;)

  16. weshaggard commented on Mar 23, 2016

    @weshaggard
    Member

    @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.

  17. analogrelay commented on Mar 23, 2016

    @analogrelay
    ContributorAuthor

    Oh totally, I get that :)

  18. mikem8361 commented on Mar 28, 2016

    @mikem8361
    Contributor

    When we do add this version string including the git SHA hash will be invaluable to our CSS team (and of course internally).

  19. gkhanna79 commented on Apr 6, 2016

    @gkhanna79
    Member

    @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?

  20. joperezr commented on Apr 6, 2016

    @joperezr
    Member

    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.

  21. gkhanna79 commented on Apr 6, 2016

    @gkhanna79
    Member

    Sounds good. Can we start to see binaries with versions in tonight's build?

  22. joperezr commented on Apr 6, 2016

    @joperezr
    Member

    Yes, if all goes well, mscorlib packages built for non-Windows should have version now.

  23. transferred this issue fromdotnet/coreclron Jan 30, 2020
  24. added this to the 1.0.0-rtm milestone on Jan 30, 2020
  25. ghost locked as resolved and limited conversation to collaborators on Jan 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions