build with -fstack-reuse=none #15983

pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:1905-buildStackReuseNone changing 1 files +4 −0
  1. MarcoFalke commented at 6:20 pm on May 8, 2019: member

    All versions of gcc that we commonly use for building are subject to bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90348. To work around that, set -fstack-reuse=none for all builds. See #15959 (comment)

    This option does not exist for clang https://clang.llvm.org/docs/ClangCommandLineReference.html#target-independent-compilation-options, but it does for gcc https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html

  2. MarcoFalke added the label Build system on May 8, 2019
  3. MarcoFalke added the label Needs backport on May 8, 2019
  4. MarcoFalke added this to the milestone 0.17.2 on May 8, 2019
  5. gmaxwell commented at 8:20 pm on May 8, 2019: contributor
    @jamesob any chance you can benchmark?
  6. jamesob commented at 8:21 pm on May 8, 2019: member
    @gmaxwell yep, running now.
  7. jamesob commented at 0:36 am on May 9, 2019: member

    Performance came back negligibly different, though I’m not totally sure this PR worked for me as intended. I double-checked to see if -fstack-reuse=none made it into the build parameters, and I don’t see it in any Makefiles after configuration (gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609):

    0Wed 8 20:32 james/.bitcoinperf/fad88bd6c9f85e6e7f8fb66a94aa75c67d26b7d8
    1$ grep -R 'fstack-reuse' .
    2
    3./autom4te.cache/output.0:{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C++ compiler accepts -fstack-reuse=none" >&5
    4./autom4te.cache/output.0:$as_echo_n "checking whether C++ compiler accepts -fstack-reuse=none... " >&6; }
    5./autom4te.cache/output.0:  CXXFLAGS="$CXXFLAGS  -fstack-reuse=none"
    6./autom4te.cache/output.0:  HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-reuse=none"
    7./autom4te.cache/traces.0:m4trace:configure.ac:737: -1- AX_CHECK_COMPILE_FLAG([-fstack-reuse=none], [HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-reuse=none"])
    

    In any case, here’s the bench data:

    ibd local 500005 505000 dbcache=2048

    1905-buildStackReuseNone vs. master (absolute)

    bench name x 1905-buildStackReuseNone master
    ibd.local.500005.505000.dbcache=2048 3 304.0416 (± 3.5953) 312.8965 (± 4.2451)
    ibd.local.500005.505000.dbcache=2048.mem-usage 3 2463438.6667 (± 3039.5620) 2462478.0000 (± 5874.0000)
    build.make.7.gcc 1 302.9981 (± 0.0000)
    build.make.7.gcc.mem-usage 1 1024568.0000 (± 0.0000)
    ibd.local.500000.505000.dbcache=2048 1 315.0404 (± 0.0000)
    ibd.local.500000.505000.dbcache=2048.mem-usage 1 2458576.0000 (± 0.0000)

    1905-buildStackReuseNone vs. master (relative)

    bench name x 1905-buildStackReuseNone master
    ibd.local.500005.505000.dbcache=2048 3 1.00 1.029
    ibd.local.500005.505000.dbcache=2048.mem-usage 3 1.00 1.000
    build.make.7.gcc 1 1.00
    build.make.7.gcc.mem-usage 1 1.00
    ibd.local.500000.505000.dbcache=2048 1 1.00
    ibd.local.500000.505000.dbcache=2048.mem-usage 1 1.00
  8. MarcoFalke commented at 12:04 pm on May 9, 2019: member

    It should be supported for all versions of gcc we support: https://gcc.gnu.org/onlinedocs/gcc-4.8.0/gcc/Code-Gen-Options.html

    I had to run ./autogen.sh && ./configure for it to end up in the CXXFLAGS (they are printed at the end of ./configure)

    Also, the results of the micro benchmarks would be useful.

  9. MarcoFalke commented at 12:33 pm on May 9, 2019: member
    See for example, how it is picked up on trusty: https://travis-ci.org/bitcoin/bitcoin/jobs/529914026#L2522
  10. laanwj commented at 6:08 pm on May 14, 2019: member
    • Tested that build with clang still works, it rejects the argument as expected:
    0configure:23543: checking whether C++ compiler accepts -fstack-reuse=none
    1configure:23562: /opt/clang90/bin/clang++ -std=c++11 -c -g -O2  -fstack-reuse=none -ggdb -DLIBEVENT_EXPERIMENTAL -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS conftest.cpp >&5
    2clang-9: error: unknown argument: '-fstack-reuse=none'
    3configure:23562: $? = 1
    
    • Checked that the argument is successfully passed for gcc (Ubuntu 7.4.0-1ubuntu1~18.04) 7.4.0
    0configure:23543: checking whether C++ compiler accepts -fstack-reuse=none
    1configure:23562: g++ -std=c++11 -c -O2 -g  -fstack-reuse=none  -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS conftest.cpp >&5
    2configure:23562: $? = 0
    3configure:23570: result: yes
    
    0$ make V=1
    1Making all in src
    2...
    3/bin/bash ../libtool  --tag=CXX --preserve-dup-deps  --mode=compile /usr/bin/ccache g++ -std=c++11 ...-fstack-reuse=none ...`crypto/chacha20.cpp
    
  11. in configure.ac:740 in fad88bd6c9 outdated
    733@@ -734,6 +734,7 @@ if test x$TARGET_OS != xwindows; then
    734   AX_CHECK_COMPILE_FLAG([-fPIC],[PIC_FLAGS="-fPIC"])
    735 fi
    736 
    737+AX_CHECK_COMPILE_FLAG([-fstack-reuse=none],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-reuse=none"])
    


    ryanofsky commented at 7:03 pm on May 15, 2019:
    Should have a comment here linking to the bug, because otherwise it’s not obvious why you’d want this flag.

    MarcoFalke commented at 7:15 pm on May 15, 2019:
    Done
  12. ryanofsky approved
  13. ryanofsky commented at 7:05 pm on May 15, 2019: member
    utACK fad88bd6c9f85e6e7f8fb66a94aa75c67d26b7d8. Not tested, but config file change looks right and should do what’s described.
  14. MarcoFalke force-pushed on May 15, 2019
  15. in configure.ac:739 in fae91e3b19 outdated
    733@@ -734,6 +734,10 @@ if test x$TARGET_OS != xwindows; then
    734   AX_CHECK_COMPILE_FLAG([-fPIC],[PIC_FLAGS="-fPIC"])
    735 fi
    736 
    737+# All versions of gcc that we commonly use for building are subject to bug
    738+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90348. To work around that, set
    739+# -fstack-reuse=none for all builds.
    


    ryanofsky commented at 7:38 pm on May 15, 2019:
    Maybe mention that -fstack-reuse flag is gcc specific and won’t affect other compilers like clang.
  16. ryanofsky approved
  17. ryanofsky commented at 7:38 pm on May 15, 2019: member
    utACK fae91e3b19627cba63f05caa18eb990888684036. Just new comment added.
  18. build with -fstack-reuse=none faf38bc056
  19. MarcoFalke force-pushed on May 15, 2019
  20. DrahtBot commented at 10:59 pm on May 15, 2019: member

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

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #15985 (Add test for GCC bug 90348 by sipa)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  21. MarcoFalke merged this on May 16, 2019
  22. MarcoFalke closed this on May 16, 2019

  23. MarcoFalke referenced this in commit 2b56c9a86a on May 16, 2019
  24. MarcoFalke deleted the branch on May 16, 2019
  25. MarcoFalke referenced this in commit 5935f0126e on May 16, 2019
  26. pull[bot] referenced this in commit d936cf9eaf on Jun 5, 2019
  27. fanquake commented at 8:01 am on June 7, 2019: member
    Included for backport in #16035.
  28. fanquake removed the label Needs backport on Jun 7, 2019
  29. MarcoFalke commented at 8:01 am on June 7, 2019: member
    @fanquake What about 17.2?
  30. fanquake commented at 8:03 am on June 7, 2019: member
    @MarcoFalke I’ll do that now so it’s not forgotten.
  31. fanquake referenced this in commit 05fb9f7fbb on Jun 7, 2019
  32. fanquake commented at 8:31 am on June 7, 2019: member
    Done in #16163.
  33. laanwj referenced this in commit c165df198d on Jun 13, 2019
  34. HashUnlimited referenced this in commit 69f7db3dee on Aug 23, 2019
  35. Bushstar referenced this in commit 9f1f0399e8 on Aug 24, 2019
  36. PastaPastaPasta referenced this in commit e29c493498 on Jun 27, 2021
  37. PastaPastaPasta referenced this in commit 244561e067 on Jun 27, 2021
  38. PastaPastaPasta referenced this in commit b2ca1cf545 on Jun 28, 2021
  39. PastaPastaPasta referenced this in commit 56aa431ff2 on Jun 28, 2021
  40. PastaPastaPasta referenced this in commit 5125f35a40 on Jun 29, 2021
  41. PastaPastaPasta referenced this in commit e8d1bcf812 on Jun 29, 2021
  42. PastaPastaPasta referenced this in commit 661667e794 on Jul 1, 2021
  43. PastaPastaPasta referenced this in commit 7fa2a56306 on Jul 1, 2021
  44. PastaPastaPasta referenced this in commit 546c385868 on Jul 8, 2021
  45. PastaPastaPasta referenced this in commit 7c690ead6b on Jul 10, 2021
  46. barton2526 referenced this in commit c06743b3e8 on Jul 13, 2021
  47. PastaPastaPasta referenced this in commit 6964c52112 on Sep 11, 2021
  48. Munkybooty referenced this in commit 1e4e0a8c0f on Oct 17, 2021
  49. Munkybooty referenced this in commit 113028f8ec on Oct 20, 2021
  50. Munkybooty referenced this in commit d65a0d249a on Oct 25, 2021
  51. Munkybooty referenced this in commit 86fb7c9be3 on Oct 26, 2021
  52. Munkybooty referenced this in commit cb9acd937f on Oct 26, 2021
  53. Munkybooty referenced this in commit 4d281cf745 on Oct 28, 2021
  54. Munkybooty referenced this in commit 8179bd5316 on Nov 9, 2021
  55. pravblockc referenced this in commit e7dff9f13f on Nov 18, 2021
  56. DrahtBot locked this on Dec 16, 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: 2024-12-25 03:12 UTC

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