Incorrect use of gcc -frandom-seed ? #2290

issue gavinandresen opened this issue on February 9, 2013
  1. gavinandresen commented at 8:31 PM on February 9, 2013: contributor

    According to the gcc manual:

    -frandom-seed=string
     This option provides a seed that GCC uses when it would otherwise
     use random numbers. It is used to generate certain symbol names
     that have to be different in every compiled file.  It is also used
     to place unique stamps in coverage data files and the object files
     that produce them. You can use the -frandom-seed option to produce
     reproducibly identical object files.
    
     The string should be different for every file you compile.
    

    For gitian builds, we are breaking the "should be different for every file you compile" rule, which doesn't seem to be causing an issues right now but which I could imagine causing impossible-to-debug problems in the future.

    A little googling turned up this discussion thread about what to do about it: http://lists.freebsd.org/pipermail/freebsd-toolchain/2010-November/000023.html

  2. luke-jr commented at 8:37 PM on February 9, 2013: member

    Perhaps we need to make it "$(git describe):${filename}"?

  3. old-c-coder commented at 7:57 PM on July 16, 2013: none

    How about changing the bitcoind make file, makefile.mingw (I'm a windows compiler) from:

    obj/%.o: %.cpp $(HEADERS) $(CXX) -c $(CFLAGS) -o $@ $< to:

    obj/%.o: %.cpp $(HEADERS) $(CXX) -c -frandom-seed=$@ $(CFLAGS) -o $@ $<

    and similarly for the bitcoin-qt makefiles? They compile OK.

    Ron

  4. gavinandresen commented at 10:36 PM on July 17, 2013: contributor

    RE: -frandom-seed=$@ : good idea!

  5. old-c-coder commented at 2:41 AM on July 18, 2013: none

    Do I do some sort of fork-clone-commit to github? It seems easy enough to modify all bitcoind makefile.* makefiles? But bitcoin-qt.pro, that is not clear at all to me. Don't even know how it does those 4 lines in makefile.release/debug now? Nor how to fix the missing lib path (for windows) in the makefiles by changing something in bitcoin-qt.pro, see message #41from May https://bitcointalk.org/index.php?topic=149479.msg2177060#msg2177060

    Ron

  6. luke-jr commented at 2:49 AM on July 18, 2013: member

    First, "fork" the repo on the GitHub website, then do:

    • git clone git@github.com:bitcoin/bitcoin.git
    • cd bitcoin
    • git remote add personal git@github.com:old-c-coder/bitcoin.git

    This sets up your local repo to pull from the master and push to your "fork". Then, to make your changes, do:

    • git checkout -b per_file_randomseed # (this names your branch)
    • #(make changes here)
    • git commit -a
    • git push personal per_file_randomseed Go back to GitHub's web interface and click the button that will show up - something like "Compare & Pull Request"

    Note that you will probably need to re-do your changes after automake is merged, but you might want to give it a go now for practice.

  7. old-c-coder commented at 3:58 AM on July 18, 2013: none

    Do I actually send an email to git@github.com? Do I change to a bitcoin directory on whose machine, drive,OS, where? Your 3rd line is equally "opaque" to me!

    I have no context for any of this. I am running github for windows, so I see none of your command line "arcana":)

    I presume I should fork a repository on https://github.com/bitcoin/bitcoin? If so, which "branch of the master" tab? And/or which "tag" tab that I see there? Or is this the wrong way to go? I seemed to have forked-cloned a "master" repository, in the past, and was unable to "commit" it?

    But I presume you have seen my "pull request" on the bitcoin-qt" splash screen and "liberating" wallet.dat?

    Ron

  8. old-c-coder commented at 2:23 PM on August 1, 2013: none

    Well, I just made my change to https://github.com/old-c-coder/bitcoin-git/commit/d511cff2fceb0a2b8e9fe248800edcf1b766288a showing the modified bitcoind makefiles

    Ron

  9. laanwj added the label Build system on Jun 1, 2014
  10. laanwj commented at 4:30 AM on November 25, 2014: member

    We don't use frandom-seed at all anymore after #4724, closing this.

  11. laanwj closed this on Nov 25, 2014

  12. sipa commented at 10:42 AM on November 25, 2014: member

    @laanwj That PR number seems wrong?

  13. laanwj commented at 11:19 AM on November 25, 2014: member

    eh #4727

  14. sipa commented at 11:22 AM on November 25, 2014: member

    @laanwj Then how do we end up with deterministic binaries?

  15. laanwj commented at 12:56 PM on November 26, 2014: member

    According the @theuni it's no longer necessary, and indeed in practice the gitian results are deterministic. I don't fully understand why either.

  16. theuni commented at 8:54 PM on December 8, 2014: member

    I also don't fully understand why. I dove into gcc's source to look at its usage, and it still seems to be using the system time as part of the random seed. I didn't track it any further, though.

    My best guess is that the random seed only gets used in rare collision cases which we don't hit. As a possible example, building and linking multiple source files with different definitions of the same static function, via a single gcc invocation like: "gcc file1.c file2.c -o file".

    It's easy enough to verify though. Just create a simple test.c and build it twice with gcc. The hashes should be identical even without gitian.

  17. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-01 15:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me