Live data from Hacker News

Unix version control lore: what, ident

dotat.at

11–20 of 29 posts

Re: Unix version control lore: what, ident

#11

Golang binaries embed the version of the compiler into them, and can easily add git revision information too. That's a nice feature for adding "foo -version", or similar, to show the users what their binaries were built from.

Here's a nice blog post with more information about that https://blog.carlana.net/post/2023/golang-git-hash-how-to/

Re: Unix version control lore: what, ident

#12
post #9

Relatedly, GCC/binutils still has a `.ident` assembly directive ( https://sourceware.org/binutils/docs/as/Ident.html ) and `#ident` preprocessor command ( https://gcc.gnu.org/onlinedocs/cpp/Other-Directives.html ) that emit data into an ELF .comment for `what` to read...

The original name was .SCCS. I put the SCCS strings in there to save memory. In the early 1980s, the 3B20 computers used to manage the U.S. phone network had a 32MiB memory limit. By 1985 the network had outgrown that memory limit, by just a few kilobytes. So I hacked the C compiler to look for #(*) strings and put them into .SCCS rather than .data. Since .SCCS didn't load into memory by default, I saved just enough to run one more process! Each binary was built from about 2,000 source files, so those strings added up to a significant amount of memory.

This was at Bell Labs Columbus Ohio. Also, I think it was COFF and not ELF. Used System V r2.

Re: Unix version control lore: what, ident

#13
post #2

I used to use these embedded version strings, and occasionally they were very helpful. As the article says, it's not as easy a fit for Git. The embedded version etc. strings could also make reproducible builds slightly more tricky than they already are. Even if they're not worth the trouble for current software, they could be a big timesaver for archaeology/reconstruction of old software.

I think that Git solves an imporant problem that those embedded version strings didn't - Git commits are guaranteed to be either unique or dirty. Generating a summary of your repository state should be done early, and included exactly in the artifacts, as should build flags. Google's internal build system included a bunch of build server information, including build time and build host, but importantly it included these variables in every built package as a simple .env file. This env file would cause the build system to "falsely" report all of these things, so you had a reproducible build, even with uniquifying data embedded.

Re: Unix version control lore: what, ident

#14
Years ago, when moving off svn to git, I cursed the fact that there was no such string replacement feature. I understand why it doesn't exist, but when it was an obstacle to my job, I loathed it.

It was easy enough to replace with a short script, and I use a variation of that to this date

Re: Unix version control lore: what, ident

#15
FreeBSD finally removed the last of the $Id$ in the source some months ago. I don't entirely know why they were so keen to do this but I'm sure they had a reason.

I don't see this, or binary .ident strings as e.g. clashing with idempotent builds.

Re: Unix version control lore: what, ident

#16
post #11

Golang binaries embed the version of the compiler into them, and can easily add git revision information too. That's a nice feature for adding "foo -version", or similar, to show the users what their binaries were built from.

Here's a nice blog post with more information about that https://blog.carlana.net/post/2023/golang-git-hash-how-to/

I'm currently using the ldflags approach [0], but the linked library [1] looks much nicer. I'll probably switch over to it soon. Thanks!

[0]: https://github.com/peterldowns/localias/blob/main/Justfile#L...

[1]: https://github.com/earthboundkid/versioninfo

Re: Unix version control lore: what, ident

#17
Good riddance to these tools because this technique, of relying on embedded strings in the code, is inherently insecure and unreliable. You can only really on it when you know you can trust the build, and yet they are used in cases where the build is of unknown etiology, so there's an inherent mismatch between when the tool is used and what it does.

Re: Unix version control lore: what, ident

#18
post #5
post #2

I used to use these embedded version strings, and occasionally they were very helpful. As the article says, it's not as easy a fit for Git. The embedded version etc. strings could also make reproducible builds slightly more tricky than they already are. Even if they're not worth the trouble for current software, they could be a big timesaver for archaeology/reconstruction of old software.

For Git, you could embed a string of the form: :path/in/repo/to/file.ext to be able to retrieve the exact source file contents used to build something.

Or just the hash from the blob of the file.

Re: Unix version control lore: what, ident

#19

Years ago, when moving off svn to git, I cursed the fact that there was no such string replacement feature. I understand why it doesn't exist, but when it was an obstacle to my job, I loathed it. It was easy enough to replace with a short script, and I use a variation of that to this date

There is a string replacement feature, and to my knowledge it has been there the whole time.

https://git-scm.com/book/en/v2/Customizing-Git-Git-Attribute... look under "Keyword Expansion" halfway down the page.

Re: Unix version control lore: what, ident

#20
We now know that keyword expansion is idiotic and have moved past it.

The worst ones are the ones that expand the log messages, when they are implemented in such a way that it becomes permanent.

A wall of short commit messages condensed into a block comment don't help anyone understand anything, without the actual changes to refer to.

Keywords are supposed to help someone who works outside of the context of the version control, but that's ironically the person who is trying to apply a patch that is failing because of the expanded cruft, whereas the person working in the version control system may have a way to do the merge on unexpanded artifacts.

Post reply on HN