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:None 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 12: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. kallewoof cross-referenced this on Dec 17, 2016 from issue Fix: OSX QT compile: move bswap_XX into Bitcoin:: to avoid collision with existing definitions by kallewoof
  14. 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.

  15. 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.

  16. 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.

  17. laanwj merged this on Dec 19, 2016
  18. laanwj closed this on Dec 19, 2016

  19. laanwj referenced this in commit 79da3979b7 on Dec 19, 2016
  20. kallewoof deleted the branch on Dec 19, 2016
  21. fanquake cross-referenced this on Jan 4, 2017 from issue [Trivial] [Doc] Install Protobuf v3 on OS X by fanquake
  22. fanquake cross-referenced this on Jan 12, 2017 from issue Protocol Buffers v3.0.0 has been released by fanquake
  23. droark cross-referenced this on Jan 31, 2017 from issue Add Changes From Liquid, Bitcoin by martindale
  24. droark commented at 12: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.

  25. laanwj referenced this in commit 59c37ae55a on Feb 1, 2017
  26. QuantumExplorer cross-referenced this on Feb 28, 2017 from issue fixed protobuf 3.0 (byteswap) issue on macOS by QuantumExplorer
  27. sickpig referenced this in commit cad55d5ed7 on Feb 28, 2017
  28. sickpig cross-referenced this on Feb 28, 2017 from issue Fix macosx build (backport core #9169 and #9366) by sickpig
  29. sickpig cross-referenced this on Feb 28, 2017 from issue Get build working on Mac by kyuupichan
  30. gandrewstone referenced this in commit 1d56e4c72c on Mar 1, 2017
  31. jtimon referenced this in commit 58db3a1e84 on Apr 20, 2017
  32. kyuupichan cross-referenced this on Apr 22, 2017 from issue [port] Fix classic build on Mac by kyuupichan
  33. fanquake referenced this in commit 1d922d4e1c on Oct 19, 2019
  34. fanquake referenced this in commit 6bd4a50be8 on Oct 21, 2019
  35. fanquake referenced this in commit 609042a6bb on Oct 21, 2019
  36. fanquake referenced this in commit 8c6081a884 on Oct 24, 2019
  37. sidhujag referenced this in commit facce170a6 on Oct 28, 2019
  38. str4d referenced this in commit d84878d853 on Jul 30, 2020
  39. daira referenced this in commit 9e08c87035 on Aug 1, 2020
  40. sidhujag referenced this in commit f4cb552485 on Nov 10, 2020
  41. fanquake referenced this in commit 0e104cd301 on Mar 26, 2021
  42. fanquake cross-referenced this on Mar 26, 2021 from issue test: remove qt byteswap compattests by fanquake
  43. fanquake referenced this in commit 9ac86bcc0d on Mar 29, 2021
  44. MarcoFalke referenced this in commit cf11f9c22f on Mar 29, 2021
  45. Fuzzbawls referenced this in commit 02148d0ab2 on Apr 1, 2021
  46. Fuzzbawls referenced this in commit fd0540d886 on Apr 1, 2021
  47. Fuzzbawls referenced this in commit db76bbcf2f on Apr 1, 2021
  48. Fuzzbawls referenced this in commit bcd3ee0e4b on Apr 17, 2021
  49. bitcoin 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-20 06:55 UTC