build: pass -dead_strip_dylibs to ld on macOS #17663

pull fanquake wants to merge 1 commits into bitcoin:master from fanquake:macos_ld_dead_strip_dylibs changing 1 files +1 −0
  1. fanquake commented at 11:14 PM on December 3, 2019: member

    This strips some unused dylibs from bitcoin-qt.

    otool -L src/qt/bitcoin-qt
      /usr/lib/libSystem.B.dylib
    - /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration
      /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
      /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
      /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
      /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
      /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices
      /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation 
    -/System/Library/Frameworks/Security.framework/Versions/A/Security 
      /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration 
      /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics 
      /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL 
    -/System/Library/Frameworks/AGL.framework/Versions/A/AGL 
      /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon 
      /usr/lib/libc++.1.dylib 
      /System/Library/Frameworks/CFNetwork.framework/Versions/A/CFNetwork 
      /System/Library/Frameworks/CoreText.framework/Versions/A/CoreText 
      /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
      /usr/lib/libobjc.A.dylib
    

    AGL - ObjC wrapper for OpenGL. DiskArbitration - mount/unmount notifications and events. Security - low level security operations, authentication services.

    From man ld:

    Remove dylibs that are unreachable by the entry point or exported symbols. 
    That is, suppresses the generation of load command commands for dylibs 
    which supplied no symbols during the link. This option should not be 
    used when linking against a dylib which is required at runtime for 
    some indirect reason such as the dylib has an important initializer.
    
  2. build: pass -dead_strip_dylibs to ld on macOS
    This strips some unused dylibs from bitcoin-qt.
    
    From man ld:
    Remove dylibs that are unreachable by the entry point or exported symbols. 
    That is, suppresses the generation of load command commands for dylibs 
    which supplied no symbols during the link. This option should not be 
    used when linking against a dylib which is required at runtime for 
    some indirect reason such as the dylib has an important initializer.
    bd44711e1b
  3. fanquake added the label macOS on Dec 3, 2019
  4. fanquake added the label Build system on Dec 3, 2019
  5. fanquake added the label Needs gitian build on Dec 3, 2019
  6. promag commented at 2:16 AM on December 4, 2019: member

    Any guess why those were included in the first place?

    Concept ACK.

  7. practicalswift commented at 9:09 AM on December 4, 2019: contributor

    Concept ACK: less cruft is better

  8. laanwj commented at 9:30 AM on December 4, 2019: member

    I think it's, in principle, nice to depend on fewer system libs but…

    Remove dylibs that are unreachable by the entry point or exported symbols.

    How risky is this option? Worded like this, it seems like quite an extensive analysis pass (checking the call tree all the way from the entry point?—does this take into account indirect/lazy dependencies through vtables, function pointers, threads, etc?).

    E.g. is there a chance of false negatives? what will happen?

  9. theuni approved
  10. theuni commented at 3:21 PM on December 4, 2019: member

    ACK bd44711e1bb2eee7646f2f8e2e8763d1c216bdb9. @laanwj I agree with the caution here, but I think this is a good idea. I believe Gnu ld/gold already work this way by default. I actually lost $1 to @fanquake on a bet about this at lunch yesterday, because I thought -dead_strip was already doing this.

    Note that we're already using -dead_strip, which goes pretty far:

    -dead_strip
                Remove functions and data that are unreachable by the entry point or exported symbols.

    This just goes a step further and doesn't add the dylib entry in the binary, so we only need to worry about potential startup side-effects. And if those do exist, I think we'd like to flesh them out.

    Related: Are there any parts of qt in depends that we can disable to prevent these from being added?

  11. DrahtBot commented at 5:09 PM on December 4, 2019: member

    <!--a722867cd34abeea1fadc8d60700f111-->

    Gitian builds

    File commit bce44089db27e2b21a3dc2954b170ecf0d6d998e<br>(master) commit ec037410754d07eb4cb7b1012d617a5357f0aa32<br>(master and this pull)
    bitcoin-0.19.99-aarch64-linux-gnu-debug.tar.gz 40caf742a2674966... 760aba924759c652...
    bitcoin-0.19.99-aarch64-linux-gnu.tar.gz 34d078b55cc81ffa... 2f49d30de054fc8b...
    bitcoin-0.19.99-arm-linux-gnueabihf-debug.tar.gz 0e4bfdc2db429350... 07241fd3f20d4986...
    bitcoin-0.19.99-arm-linux-gnueabihf.tar.gz 66f9553d61083c86... efc10188d84af908...
    bitcoin-0.19.99-i686-pc-linux-gnu-debug.tar.gz b94d6da73b0724fc... ebb12a6160a05aa5...
    bitcoin-0.19.99-i686-pc-linux-gnu.tar.gz 9a7eb5bfc03dc3c7... 8ca72c6582062d1f...
    bitcoin-0.19.99-osx-unsigned.dmg 080fc64ce42ac922... 11df1880e894c631...
    bitcoin-0.19.99-osx64.tar.gz 25c44e85f72a9718... 7a88927eaf77b9fa...
    bitcoin-0.19.99-riscv64-linux-gnu-debug.tar.gz ebf248bcad5d1362... 60284e9b7403ce94...
    bitcoin-0.19.99-riscv64-linux-gnu.tar.gz 90d60c22deb5c3d9... 1a3b6357ae77b887...
    bitcoin-0.19.99-win64-debug.zip 4b7041137b8551bb... b6299b1fcb569bb3...
    bitcoin-0.19.99-win64-setup-unsigned.exe fafa36315d943962... c109107172ceed8a...
    bitcoin-0.19.99-win64.zip 45fd276418a2e762... 3176d7f8f440a405...
    bitcoin-0.19.99-x86_64-linux-gnu-debug.tar.gz ad62fd169f3b94f0... ac37accb9fc2780b...
    bitcoin-0.19.99-x86_64-linux-gnu.tar.gz dcbdcfabbc11788d... a63bf5c01da603a4...
    bitcoin-0.19.99.tar.gz bb241ff718f90db7... f8f4bacfe4d45608...
    bitcoin-core-linux-0.20-res.yml f0e1f78f4c673bfb... da3737e3cb1edc25...
    bitcoin-core-osx-0.20-res.yml e7372ee66c33c5b6... f453ced912847847...
    bitcoin-core-win-0.20-res.yml b99b459febc7ce3a... 3d27c25efa0fa60f...
    linux-build.log 1d19bc4efecc2987... 0a4083ec9c4344eb...
    osx-build.log 05276d8599182586... 6da7423d4f13031b...
    win-build.log a1f5423cb7e486dc... 8e88920e8ac87f49...
    bitcoin-core-linux-0.20-res.yml.diff 72b308ceb1cec962...
    bitcoin-core-osx-0.20-res.yml.diff d274105d23eb9b74...
    bitcoin-core-win-0.20-res.yml.diff 6d57343059d853cf...
    linux-build.log.diff d40c8aa828fd6df2...
    osx-build.log.diff 71c66f8d79ce952e...
    win-build.log.diff eefa6f3e788ebddd...
  12. DrahtBot removed the label Needs gitian build on Dec 4, 2019
  13. fanquake commented at 6:33 PM on December 4, 2019: member

    Related: Are there any parts of qt in depends that we can disable to prevent these from being added?

    I'll look at this as a follow up.

  14. laanwj referenced this in commit c7c9c44278 on Dec 6, 2019
  15. laanwj merged this on Dec 6, 2019
  16. laanwj closed this on Dec 6, 2019

  17. fanquake deleted the branch on Dec 6, 2019
  18. sidhujag referenced this in commit 40151d7182 on Dec 6, 2019
  19. laanwj referenced this in commit 91559da683 on Dec 9, 2019
  20. sidhujag referenced this in commit 02db4dac0c on Dec 9, 2019
  21. sidhujag referenced this in commit a0cd01ef2a on Nov 10, 2020
  22. sidhujag referenced this in commit e04dc6170d on Nov 10, 2020
  23. PastaPastaPasta referenced this in commit 2bc266429c on Jun 27, 2021
  24. PastaPastaPasta referenced this in commit 8322cb9b76 on Jun 28, 2021
  25. PastaPastaPasta referenced this in commit 0d2d72db66 on Jun 29, 2021
  26. PastaPastaPasta referenced this in commit 6a0fb39de7 on Jul 1, 2021
  27. PastaPastaPasta referenced this in commit 15ee7670fc on Jul 1, 2021
  28. PastaPastaPasta referenced this in commit 5a5cfe514c on Jul 14, 2021
  29. 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: 2026-04-21 18:14 UTC

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