build: pass -fno-ident in Windows gitian descriptor #17948

pull fanquake wants to merge 1 commits into bitcoin:master from fanquake:pass_fno_ident changing 1 files +2 −2
  1. fanquake commented at 1:33 PM on January 17, 2020: member

    -fno-ident prevents compilers from emitting compiler name and version number information that can needlessly bloat binaries.

    For example, in the v0.19.0.1 Windows release binaries, there are > 1000 GCC compiler version strings embedded:

    # GCC: (GNU) 7.3-posix 20180312... & GCC: (GNU) 6.3.0 20170415.......
    strings bitcoind.exe | rg GCC | wc -l
        1021
    

    They end up collected in the end of the.rdata section, and cannot be removed by strip. i.e:

    objdump --section=.rdata --full-contents bitcoind.exe
    ...
     cfcc00 00000000 00000000 00000000 00000000  ................
     cfcc10 00000000 00000000 00000000 00000000  ................
     cfcc20 4743433a 2028474e 55292036 2e332e30  GCC: (GNU) 6.3.0
     cfcc30 20323031 37303431 35000000 00000000   20170415.......
     cfcc40 4743433a 2028474e 55292037 2e332d70  GCC: (GNU) 7.3-p
     cfcc50 6f736978 20323031 38303331 32000000  osix 20180312...
     cfcc60 4743433a 2028474e 55292037 2e332d70  GCC: (GNU) 7.3-p
     cfcc70 6f736978 20323031 38303331 32000000  osix 20180312...
    

    The flag is available for Clang and GCC.

    Relevant code in GCC:

      /* Attach a special .ident directive to the end of the file to identify
         the version of GCC which compiled this code.  The format of the .ident
         string is patterned after the ones produced by native SVR4 compilers.  */
      if (!flag_no_ident)
        {
          const char *pkg_version = "(GNU) ";
          char *ident_str;
    
    
          if (strcmp ("(GCC) ", pkgversion_string))
    	pkg_version = pkgversion_string;
    
    
          ident_str = ACONCAT (("GCC: ", pkg_version, version_string, NULL));
          targetm.asm_out.output_ident (ident_str);
        }
    
  2. fanquake added the label Build system on Jan 17, 2020
  3. fanquake added the label Needs gitian build on Jan 17, 2020
  4. fanquake requested review from theuni on Jan 17, 2020
  5. fanquake requested review from dongcarl on Jan 17, 2020
  6. DrahtBot commented at 2:57 PM on January 17, 2020: member

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    No conflicts as of last run.

  7. practicalswift commented at 4:13 PM on January 17, 2020: contributor

    Concept ACK

    In addition to binary bloat reduction I assume this can't hurt from a deterministic builds perspective too.

    FWIW: Chromium builds with -fno-ident IIRC.

  8. laanwj commented at 4:25 PM on January 17, 2020: member

    ACK on passing this for the gitian / distributed binaries.

    I'm less sure this is something that always needs to be passed by the build system, even for builds from sources and distro packages (which will have their own policy in regard to this).

  9. practicalswift commented at 12:26 PM on January 18, 2020: contributor

    I'm less sure this is something that always needs to be passed by the build system, even for builds from sources and distro packages (which will have their own policy in regard to this).

    What could be the drawback? Just curious :)

  10. DrahtBot commented at 5:50 PM on January 18, 2020: member

    <!--a722867cd34abeea1fadc8d60700f111-->

    Gitian builds

    File commit a654626f076a72416a3d354218d7107571d6caaf<br>(master) commit 24a38f4e743547dbf25167106b3e470080bbf300<br>(master and this pull)
    bitcoin-0.19.99-aarch64-linux-gnu-debug.tar.gz 7895a840c95d5b33... dc4c9781c31d6e22...
    bitcoin-0.19.99-aarch64-linux-gnu.tar.gz f8bc224a926e91d3... 930bc0dabf940215...
    bitcoin-0.19.99-arm-linux-gnueabihf-debug.tar.gz 00c38704f521a1e8... 6e0aa684aa4d192e...
    bitcoin-0.19.99-arm-linux-gnueabihf.tar.gz 000ddb8c912fa6cd... e6b519149e995731...
    bitcoin-0.19.99-i686-pc-linux-gnu-debug.tar.gz 200b1c38944a974b... 8c6f0166708b9cfa...
    bitcoin-0.19.99-i686-pc-linux-gnu.tar.gz d93a628e83397dee... 665e5f71a4a68343...
    bitcoin-0.19.99-osx-unsigned.dmg 812a252820cf7a16... e7d2df6d42102da0...
    bitcoin-0.19.99-osx64.tar.gz 2aad3d0a0a0d285c... f0f881b7fede1cab...
    bitcoin-0.19.99-riscv64-linux-gnu-debug.tar.gz d1b75bb5ff1eac59... 7f2ee57d16188c69...
    bitcoin-0.19.99-riscv64-linux-gnu.tar.gz f2701b17b4a630ee... c1db32ac35ee227c...
    bitcoin-0.19.99-win64-debug.zip 16318dba8cf0660e... 8c89eff3bfeba5ec...
    bitcoin-0.19.99-win64-setup-unsigned.exe 2aa39517c8fff989... 3dec300f43061821...
    bitcoin-0.19.99-win64.zip 622c25693f469997... f2611e77e9eef3d9...
    bitcoin-0.19.99-x86_64-linux-gnu-debug.tar.gz d5c9e11b1e22532d... fefeff37a3e224f4...
    bitcoin-0.19.99-x86_64-linux-gnu.tar.gz 6037241e14a5367f... 33bc9a57ce076b0a...
    bitcoin-0.19.99.tar.gz 3eb0788e811facc9... e22d7b26a4a30ae1...
    bitcoin-core-linux-0.20-res.yml e6d51241a0566433... df9aae83b9b6ead0...
    bitcoin-core-osx-0.20-res.yml 74d556dfd12603d2... 98e3579fed1cbc28...
    bitcoin-core-win-0.20-res.yml db3040a4bf8b762c... b426524bbcc8eb40...
    linux-build.log 2e4f0e5925d7556b... 9ad0a507a02a9b86...
    osx-build.log 540464b4a328f14d... 564438d4b83a744f...
    win-build.log 7b29a5f8528dda6d... a8109e085636dcaf...
    bitcoin-core-linux-0.20-res.yml.diff f8198acd8a9a62c7...
    bitcoin-core-osx-0.20-res.yml.diff a6090235c3628b52...
    bitcoin-core-win-0.20-res.yml.diff cec994067e30b653...
    linux-build.log.diff 0589de62261b0346...
    osx-build.log.diff b636d2899a98a530...
    win-build.log.diff ead78e44e2a1278d...
  11. DrahtBot removed the label Needs gitian build on Jan 18, 2020
  12. laanwj commented at 7:52 PM on January 20, 2020: member

    What could be the drawback? Just curious :)

    What if someone is building from source for some platform and wants these idents in the binary for some reason? There's no way to enable them.

    Having done embedded development where the intent is to compile all the software with the same set of compiler flags, I (personally) dislike it if projects provide unnecessary (it doesn't fix a bug or otherwise) gcc or linker flags when building from source.

    If you think there's no reason at all to include these kind of "what compiled me" signifiers, please look at annobin, which goes even further and stores the command line options too for every compilation unit in the binary, it can be used for auditing post-compilation that the expected compiler/settings were used (such as security/hardening options)—it's impossible to rule these things out as "useful for noone".

    So while I'm okay for leaving this out of the distributed binaries (we don't care), I don't want to decide this for everyone building the software hardwired in the build system.

  13. dongcarl commented at 4:29 PM on January 21, 2020: member

    What if someone is building from source for some platform and wants these idents in the binary for some reason? There's no way to enable them.

    True, this is worthwhile addition, but let's do that thru gitian descriptors.

    I think we could also add the same flag to our depends hosts; looking for Concept ACK/NACKs on that.

    If we're just doing this for release, then perhaps this is not necessary.

  14. sipa commented at 4:32 PM on January 21, 2020: member

    It's unclear to me what the goal is. Do we care about the 100 bytes or so this adds to our binary, or is this intended to improve some form of privacy?

  15. MarcoFalke commented at 6:12 PM on January 21, 2020: member

    Agree with @sipa. I don't see the danger of having these strings in the gitian/guix binary. Especially if this is going to be conditionally applied to only gitian builds, it might lead to further issues and build file code complexity.

  16. fanquake commented at 11:41 PM on January 21, 2020: member

    100 bytes or so this adds to our binary

    This currently adds > 3600 bytes to the Windows binaries.

    I don't see the danger of having these strings in the gitian/guix binary.

    I don't see a reason for us to be shipping around 1000s of bytes of useless data. Can you elaborate on the build system issues / complexity you foresee? We are already applying certain flags conditionally during gitian builds.

    Given the 3 concept ACK above I'll adjust these changes as suggested.

  17. sipa commented at 11:45 PM on January 21, 2020: member

    I think even 3600 bytes compared to a multi-megabyte binary is negligible.

  18. fanquake force-pushed on Jan 22, 2020
  19. luke-jr commented at 4:00 PM on January 27, 2020: member

    Agree with @laanwj: Fine for the gitian binaries, but leave normal builds alone. If the user wants -fno-ident, he can specify it or even make it a default option.

  20. DrahtBot commented at 12:03 PM on February 10, 2020: member

    <!--cf906140f33d8803c4a75a2196329ecb-->Needs rebase

  21. DrahtBot added the label Needs rebase on Feb 10, 2020
  22. build: pass -fno-ident in Windows gitian descriptor
    This prevents compilers from emitting compiler name and
    version number info that can needlessly bloat binaries.
    
    Accepted by Clang and GCC. See:
    
    https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-qn
    
    https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-fno-ident
    530d02addb
  23. fanquake force-pushed on Feb 13, 2020
  24. fanquake removed the label Needs rebase on Feb 13, 2020
  25. fanquake renamed this:
    build: pass -fno-ident to prevent compilers emitting ident directives
    build: pass -fno-ident in Windows gitian descriptor
    on Feb 13, 2020
  26. fanquake commented at 10:25 AM on February 13, 2020: member

    Rebased, updated to just pass -fno-ident in the Windows gitian descriptor and added additional info to the PR description. Comparing two depends builds, this removes > 6000 bytes from the binary.

  27. fanquake added the label Needs gitian build on Feb 13, 2020
  28. practicalswift commented at 11:03 AM on February 13, 2020: contributor

    ACK 530d02addbfea01ab24a2acd17af456a1e7b798a

  29. DrahtBot commented at 2:19 AM on February 17, 2020: member

    <!--a722867cd34abeea1fadc8d60700f111-->

    Gitian builds

    File commit 2a2631fb0dc781504df0f3fe8b42f21cbdb6f20d<br>(master) commit 85aa65d030fe540d87a29436af180124f64bb3da<br>(master and this pull)
    bitcoin-0.19.99-aarch64-linux-gnu-debug.tar.gz 51392e3413128845... bf456184a7a8f670...
    bitcoin-0.19.99-aarch64-linux-gnu.tar.gz 9c68060f909b176a... 7dc8ef17c7192a32...
    bitcoin-0.19.99-arm-linux-gnueabihf-debug.tar.gz a4c6bc9d98b02c39... 1a4535798a3c3a74...
    bitcoin-0.19.99-arm-linux-gnueabihf.tar.gz 91c276c85c6ea8f0... 20140eda04ac713d...
    bitcoin-0.19.99-osx-unsigned.dmg 71c8478f6158f433... 94bc2170765bbffe...
    bitcoin-0.19.99-osx64.tar.gz e9f498c9b0694e08... 5e8613b348908d6a...
    bitcoin-0.19.99-riscv64-linux-gnu-debug.tar.gz e53b974b60b018a7... 95b15cbb02618a4d...
    bitcoin-0.19.99-riscv64-linux-gnu.tar.gz 3ae4b4f4bf44d8ed... a2ce5a70dff657ed...
    bitcoin-0.19.99-win64-debug.zip 88fc928933abadaf... 5a6d2785c1cbd5e7...
    bitcoin-0.19.99-win64-setup-unsigned.exe 78c96ebfdbda69a3... a865292bb0ae019a...
    bitcoin-0.19.99-win64.zip be3e701005cfa682... aedca6a43c9fe36b...
    bitcoin-0.19.99-x86_64-linux-gnu-debug.tar.gz bdbbb809f6569067... 7e8399e0b50a7602...
    bitcoin-0.19.99-x86_64-linux-gnu.tar.gz 185e77d19a57404c... dd03d16b067382ea...
    bitcoin-0.19.99.tar.gz bd8f4dff76b14fe8... 31a2a08e442b8ee8...
    bitcoin-core-linux-0.20-res.yml c3a41885d43ad9c1... 9a04e6ef24ebc519...
    bitcoin-core-osx-0.20-res.yml 2ea28d851bd7def3... 10ffa681865c8396...
    bitcoin-core-win-0.20-res.yml db5c46d54aa23a95... a61bb2be21dac936...
    linux-build.log 67c5b5639d5edc84... 8c44572465563c1e...
    osx-build.log 635adff0cbd384f3... e1c91ec51d99f5cc...
    win-build.log f9061ed05f12c5c0... 4dc9afd11c210bda...
    bitcoin-core-linux-0.20-res.yml.diff 9b6ac4abc7ed9bff...
    bitcoin-core-osx-0.20-res.yml.diff 7f3e9b5279fd8219...
    bitcoin-core-win-0.20-res.yml.diff 59eac9489364352b...
    linux-build.log.diff ba7d69f4e18a1d87...
    osx-build.log.diff cd974a30aca222a3...
    win-build.log.diff 19187459a3ad4317...
  30. DrahtBot removed the label Needs gitian build on Feb 17, 2020
  31. laanwj commented at 11:05 AM on February 17, 2020: member

    ACK 530d02addbfea01ab24a2acd17af456a1e7b798a

  32. laanwj referenced this in commit 179504ccb6 on Feb 17, 2020
  33. laanwj merged this on Feb 17, 2020
  34. laanwj closed this on Feb 17, 2020

  35. fanquake deleted the branch on Feb 17, 2020
  36. MarkLTZ referenced this in commit ff2f58f31c on Apr 10, 2020
  37. PastaPastaPasta referenced this in commit 6873e94740 on Jun 27, 2021
  38. PastaPastaPasta referenced this in commit bad6cae7d3 on Jun 28, 2021
  39. PastaPastaPasta referenced this in commit 4372dc7b8c on Jun 29, 2021
  40. PastaPastaPasta referenced this in commit a7f5e48bd6 on Jul 1, 2021
  41. PastaPastaPasta referenced this in commit 993dde91b2 on Jul 1, 2021
  42. PastaPastaPasta referenced this in commit 99981859b6 on Jul 14, 2021
  43. PastaPastaPasta referenced this in commit a8d6cdf236 on Jul 14, 2021
  44. DrahtBot locked this on Feb 15, 2022

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-04-26 06:14 UTC

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