Fix: OSX QT compile: use built-in swap if available, or defer #9366

pull kallewoof wants to merge 1 commits into bitcoin:master from kallewoof:macosx-qt-build-fix2 changing 7 files +95 −0
  1. kallewoof commented at 12:25 pm on December 16, 2016: member

    Uses built-in byte swap if available (Apple) and if bswap_XX is undefined.

    Defers to pre-defined version if found (e.g. protobuf). For protobuf case, the definitions are identical and thus include order should not affect results.

    Fixes compilation errors on recent Mac OS X with QT client enabled.

    Replaces https://github.com/bitcoin/bitcoin/pull/9361

  2. fanquake added the label MacOSX on Dec 16, 2016
  3. laanwj commented at 4:19 pm on December 16, 2016: member
    Yes, this looks better, thanks
  4. in src/test/bswap_protobuf_tests.cpp: in 4e7de87631 outdated
    0@@ -0,0 +1,26 @@
    1+// Copyright (c) 2016 The Bitcoin Core developers
    


    laanwj commented at 4:20 pm on December 16, 2016:
    I’d prefer moving this one to the qt unit tests, instead of adding a qt-specific unit test to the core unit tests.

    kallewoof commented at 1:35 am on December 17, 2016:
    I moved this into a new “CompatTests” test suite in the QT tests.
  5. theuni commented at 7:08 pm on December 16, 2016: member

    Hmm, is it really necessary to have the system-specific bswaps anymore? Since we require a modern compiler, these are likely to be detected/optimized automatically anyway.

    Test file: https://gist.github.com/theuni/deb0b97c31890bd0a06a65dd3cb51822 compiled with gcc/clang: c++ -std=c++11 -O2 -c -o bswapcomp.o bswap.cpp

    Results: https://gist.github.com/theuni/508b69da908be1e52bbdd0b7a135c318

    On x86-64, I see no difference for osx+clang, linux+clang, linux+gcc.

    doesn’t look like it’s worth bothering to me, or is there some platform that would be more likely to be a discrepancy?

  6. kallewoof commented at 11:17 pm on December 16, 2016: member

    @theuni So you think it’s better to basically #undef and #define them always for consistency?

    Edit: I meant to say that since we want the same thing to happen no matter which include order is taken, we might as well just redefine them each time on our own side.

  7. theuni commented at 0:13 am on December 17, 2016: member

    @kallewoof I was suggesting just skipping the platform includes (byteswap.h/OSByteOrder.h), skipping the use of any system implementations, and renaming bswap_foo -> int_bswap_foo to avoid collisions.

    Need others to chime in first though.

  8. kallewoof commented at 1:15 am on December 17, 2016: member
    FWIW I like the idea personally.
  9. kallewoof force-pushed on Dec 17, 2016
  10. kallewoof force-pushed on Dec 17, 2016
  11. Uses built-in byte swap if available (Apple) and if bswap_XX is undefined.
    Defers to pre-defined version if found (e.g. protobuf). For protobuf case, the definitions are identical and thus include order should not affect results.
    815f4148b2
  12. kallewoof force-pushed on Dec 17, 2016
  13. theuni commented at 8:10 am on December 17, 2016: member

    utACK https://github.com/bitcoin/bitcoin/pull/9366/commits/815f4148b2eff6c64c764e910e79677d5a67adc7 for the sake of fixing the build.

    Dropping the system includes (or alternatively autoconfing this) can come as a next step if it’s agreed upon.

  14. laanwj commented at 7:27 am on December 19, 2016: member

    Hmm, is it really necessary to have the system-specific bswaps anymore? Since we require a modern compiler, these are likely to be detected/optimized automatically anyway.

    If there are bswap primitives, I think we should use them. This is used internally in the serialization as well as crypto operations, so performance here (if there is a compiler where it makes sense) does matter. If you want to prove for every compiler, architecture combo in existence that this doesn’t matter, fine. But if not, I’d prefer to keep using system primitives if available.

  15. laanwj commented at 7:29 am on December 19, 2016: member
    utACK https://github.com/bitcoin/bitcoin/pull/9366/commits/815f4148b2eff6c64c764e910e79677d5a67adc7, let’s just fix this to fix the build, I think we’ve been through enough shed-painting here.
  16. laanwj merged this on Dec 19, 2016
  17. laanwj closed this on Dec 19, 2016

  18. laanwj referenced this in commit 79da3979b7 on Dec 19, 2016
  19. kallewoof deleted the branch on Dec 19, 2016
  20. droark commented at 0:23 am on February 1, 2017: contributor
    FYI, I backported this to 0.13. I noticed it when trying to compile the Elements Alpha refresh.
  21. laanwj referenced this in commit 59c37ae55a on Feb 1, 2017
  22. sickpig referenced this in commit cad55d5ed7 on Feb 28, 2017
  23. gandrewstone referenced this in commit 1d56e4c72c on Mar 1, 2017
  24. jtimon referenced this in commit 58db3a1e84 on Apr 20, 2017
  25. fanquake referenced this in commit 1d922d4e1c on Oct 19, 2019
  26. fanquake referenced this in commit 6bd4a50be8 on Oct 21, 2019
  27. fanquake referenced this in commit 609042a6bb on Oct 21, 2019
  28. fanquake referenced this in commit 8c6081a884 on Oct 24, 2019
  29. sidhujag referenced this in commit facce170a6 on Oct 28, 2019
  30. str4d referenced this in commit d84878d853 on Jul 30, 2020
  31. daira referenced this in commit 9e08c87035 on Aug 1, 2020
  32. sidhujag referenced this in commit f4cb552485 on Nov 10, 2020
  33. fanquake referenced this in commit 0e104cd301 on Mar 26, 2021
  34. fanquake referenced this in commit 9ac86bcc0d on Mar 29, 2021
  35. MarcoFalke referenced this in commit cf11f9c22f on Mar 29, 2021
  36. Fuzzbawls referenced this in commit 02148d0ab2 on Apr 1, 2021
  37. Fuzzbawls referenced this in commit fd0540d886 on Apr 1, 2021
  38. Fuzzbawls referenced this in commit db76bbcf2f on Apr 1, 2021
  39. Fuzzbawls referenced this in commit bcd3ee0e4b on Apr 17, 2021
  40. DrahtBot 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: 2024-11-24 03:12 UTC

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