https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97789
--- Comment #8 from David Binderman <dcb314 at hotmail dot com> --- (In reply to David Binderman from comment #6) >Maybe something like > > $ git rev-parse HEAD >> gcc/trunk.git/gcc/DATESTAMP > > would be enough to get it into the output of gcc -v. For the record, my current bash code for this is: cd ../trunk.git HASH=`git rev-parse HEAD` cd ../working echo $HASH and later ../trunk.git/configure --with-pkgversion=$HASH Here is an example of it in practice: $ ./results/bin/gcc -v Using built-in specs. COLLECT_GCC=./results/bin/gcc COLLECT_LTO_WRAPPER=/home/dcb/gcc/results.20201111/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../trunk.git/configure --prefix=/home/dcb/gcc/results.20201111 --disable-bootstrap --disable-multilib --disable-werror --with-pkgversion=46c705e70e078f6a1920d92e49042125d5e18495 --enable-checking=df,extra,fold,rtl,yes --enable-languages=c,c++,fortran Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.0.0 20201111 (experimental) (46c705e70e078f6a1920d92e49042125d5e18495) $