refactor: Fix link error with –enable-debug #19309

pull hebasto wants to merge 1 commits into bitcoin:master from hebasto:200617-fix changing 1 files +1 −1
  1. hebasto commented at 4:43 pm on June 17, 2020: member

    Fixes a link error on master (39bd9ddb8783807b9cde6288233e86ad7c85d61f):

    0$ ./configure --enable-debug
    1$ make
    2...
    3bitcoin_wallet-bitcoin-wallet.o:(.data.rel.ro+0x0): undefined reference to `InitError(bilingual_str const&)'
    4libbitcoin_wallet_tool.a(libbitcoin_wallet_tool_a-wallettool.o):(.data.rel.ro+0x8): undefined reference to `InitError(bilingual_str const&)'
    5libbitcoin_wallet.a(libbitcoin_wallet_a-salvage.o):(.data.rel.ro+0x8): undefined reference to `InitError(bilingual_str const&)'
    6libbitcoin_wallet.a(libbitcoin_wallet_a-wallet.o):(.data.rel.ro+0x8): undefined reference to `InitError(bilingual_str const&)'
    7libbitcoin_wallet.a(libbitcoin_wallet_a-walletdb.o):(.data.rel.ro+0x8): undefined reference to `InitError(bilingual_str const&)'
    8libbitcoin_wallet.a(libbitcoin_wallet_a-wallet.o):(.data.rel.ro+0x8): more undefined references to `InitError(bilingual_str const&)' follow
    9collect2: error: ld returned 1 exit status
    

    See:

  2. MarcoFalke commented at 4:51 pm on June 17, 2020: member
    How does the given patch fix this?
  3. achow101 commented at 4:55 pm on June 17, 2020: member

    ACK ef11f39c7371898b99182ea92899e2c9698d7391

    Tested that I can compile with --enable-debug. Also no idea why this works.

  4. Sjors commented at 4:58 pm on June 17, 2020: member
    Could use some documentation as to why ef11f39 fixes the issue, but it does.
  5. hebasto commented at 4:58 pm on June 17, 2020: member

    How does the given patch fix this?

    Not sure ((

    It seems related to instantiating of the FatalError() template function, and all used symbols should be in the same translation unit. But don’t know how this depends on --enable-debug.

  6. hebasto commented at 5:17 pm on June 17, 2020: member

    FWIW, I’ve managed to reproduce the initial issue with the only flag:

    0$ ./configure CXXFLAGS=-O0
    

    UPDATE: using GCC 7.5.0

  7. hebasto commented at 5:48 pm on June 17, 2020: member

    The alternative approach is not using function aliasing at all:

     0diff --git a/src/ui_interface.cpp b/src/ui_interface.cpp
     1index 15795bd67..c6017e57a 100644
     2--- a/src/ui_interface.cpp
     3+++ b/src/ui_interface.cpp
     4@@ -59,6 +59,11 @@ bool InitError(const bilingual_str& str)
     5     return false;
     6 }
     7 
     8+bool AbortError(const bilingual_str& str)
     9+{
    10+    return InitError(str);
    11+}
    12+
    13 void InitWarning(const bilingual_str& str)
    14 {
    15     uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_WARNING);
    16diff --git a/src/ui_interface.h b/src/ui_interface.h
    17index 356d30eaf..bfa771a1b 100644
    18--- a/src/ui_interface.h
    19+++ b/src/ui_interface.h
    20@@ -122,7 +122,7 @@ void InitWarning(const bilingual_str& str);
    21 
    22 /** Show error message **/
    23 bool InitError(const bilingual_str& str);
    24-constexpr auto AbortError = InitError;
    25+bool AbortError(const bilingual_str& str);
    26 
    27 extern CClientUIInterface uiInterface;
    28 
    
  8. DrahtBot added the label UTXO Db and Indexes on Jun 17, 2020
  9. in src/ui_interface.h:126 in ef11f39c73 outdated
    121@@ -122,7 +122,6 @@ void InitWarning(const bilingual_str& str);
    122 
    123 /** Show error message **/
    124 bool InitError(const bilingual_str& str);
    125-constexpr auto AbortError = InitError;
    126 
    


    MarcoFalke commented at 6:44 pm on June 17, 2020:
    0inline bool AbortError(const bilingual_str& str) { return InitError(str); }
    

    Sjors commented at 6:47 pm on June 17, 2020:
    Which is more readable too.

    hebasto commented at 7:41 pm on June 17, 2020:
  10. MarcoFalke commented at 6:44 pm on June 17, 2020: member
    A smaller patch would be to write the verbose version of the alias?
  11. MarcoFalke removed the label UTXO Db and Indexes on Jun 17, 2020
  12. MarcoFalke added the label Utils/log/libs on Jun 17, 2020
  13. Fix link error with --enable-debug b83cc0fc94
  14. hebasto force-pushed on Jun 17, 2020
  15. hebasto commented at 7:41 pm on June 17, 2020: member

    Updated ef11f39c7371898b99182ea92899e2c9698d7391 -> b83cc0fc94df99f0334430e63e8c9fa6ae3790e1 (pr19309.01 -> pr19309.02, diff):

    A smaller patch would be to write the verbose version of the alias?

  16. dongcarl commented at 4:03 pm on June 19, 2020: member
    Is there an upstream GCC bug for this? If we decide to go with this workaround, perhaps leave a comment with some context and we can revert in the future?
  17. MarcoFalke commented at 4:05 pm on June 19, 2020: member
    @dongcarl I don’t think anyone has reduced the test case yet
  18. MarcoFalke renamed this:
    Fix link error with --enable-debug
    refactor: Fix link error with --enable-debug
    on Jun 19, 2020
  19. MarcoFalke added the label Refactoring on Jun 19, 2020
  20. achow101 commented at 6:28 pm on June 19, 2020: member
    Re-ACK b83cc0fc94df99f0334430e63e8c9fa6ae3790e1
  21. MarcoFalke merged this on Jun 19, 2020
  22. MarcoFalke closed this on Jun 19, 2020

  23. MarcoFalke commented at 10:15 pm on June 19, 2020: member
    This is not a gcc bug, but a Bitcoin Core bug. Proper fix is here: #19331
  24. hebasto deleted the branch on Jun 20, 2020
  25. hebasto commented at 10:58 am on June 20, 2020: member

    @MarcoFalke

    This is not a gcc bug, but a Bitcoin Core bug. Proper fix is here: #19331

    Thank you Marco!

  26. Fabcien referenced this in commit 978bd5b488 on Dec 11, 2020
  27. DrahtBot locked this on Feb 15, 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-11-23 18:12 UTC

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