build: Fix fuzz binary compilation under windows #21226

pull danben wants to merge 1 commits into bitcoin:master from danben:compile-fuzz-binary-windows changing 2 files +2 −2
  1. danben commented at 6:38 pm on February 18, 2021: contributor
    Small change to allow the fuzz binary to compile under windows. Also removed –disable-fuzz-binary from the windows CI test. This fixes #21212.
  2. in src/test/fuzz/fuzz.cpp:79 in e3da77aa03 outdated
    71@@ -72,7 +72,11 @@ extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv)
    72 }
    73 
    74 #if defined(PROVIDE_MAIN_FUNCTION)
    75+#ifdef WIN32
    76+int main(int argc, char** argv)
    77+#else
    78 __attribute__((weak)) int main(int argc, char** argv)
    79+#endif
    


    MarcoFalke commented at 6:48 pm on February 18, 2021:
    0#ifndef WIN32
    1__attribute__((weak))
    2#endif
    3int main(int argc, char** argv)
    

    MarcoFalke commented at 6:49 pm on February 18, 2021:
    Haven’t tried this, but with one less line of code you could achieve the same?
  3. MarcoFalke commented at 6:49 pm on February 18, 2021: member
    Nice find. Is this a feature or a bug of windows?
  4. MarcoFalke approved
  5. danben commented at 7:08 pm on February 18, 2021: contributor

    Nice find. Is this a feature or a bug of windows?

    Good question. I’m no Windows programmer but this and designated initializers came up when I initially tackled the fuzz binary thing. According to Wikipedia, weak symbols are specific to ELF. According to this thread, MinGW has supported weak symbols for some time but I guess people have problems with it. My understanding is that no one is trying to build for fuzzing on Windows so it seemed fine to just omit the annotation.

  6. MarcoFalke commented at 8:14 pm on February 18, 2021: member
    No need to attribute me. And please squash your commits according to https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#squashing-commits
  7. in src/test/fuzz/fuzz.cpp:76 in 5d9999aac9 outdated
    71@@ -72,7 +72,10 @@ extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv)
    72 }
    73 
    74 #if defined(PROVIDE_MAIN_FUNCTION)
    75-__attribute__((weak)) int main(int argc, char** argv)
    76+#ifndef WIN32
    77+__attribute__((weak))
    


    MarcoFalke commented at 8:21 pm on February 18, 2021:

    Hmm, I think we don’t even need the attribute at all, now that we have a proper configure check.

    • Afl does need the main function (preferably without the attribute)
    • honggfuzz and libFuzzer shouldn’t get it
    • raw builds need the main function (preferably without the attribute)

    danben commented at 8:22 pm on February 18, 2021:
    That sounds right. Perhaps that will save me from having to figure out where this mac failure is coming from.
  8. DrahtBot added the label Build system on Feb 18, 2021
  9. Fix fuzz binary compilation under windows 56ace907b9
  10. danben force-pushed on Feb 18, 2021
  11. DrahtBot commented at 4:28 am on February 19, 2021: 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:

    • #21003 (test: Move MakeNoLogFileContext to libtest_util, and use it in bench by MarcoFalke)

    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.

  12. MarcoFalke commented at 8:25 am on February 19, 2021: member
    review ACK 56ace907b9b7b4544c95e2945dc07e217718a8e5 the best bugfixes are the ones removing code
  13. MarcoFalke merged this on Feb 19, 2021
  14. MarcoFalke closed this on Feb 19, 2021

  15. danben deleted the branch on Feb 19, 2021
  16. sidhujag referenced this in commit b9208c562c on Feb 19, 2021
  17. DrahtBot locked this on Aug 16, 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: 2024-07-03 10:13 UTC

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