Skip to content

Conversation

@hebasto
Copy link
Member

@hebasto hebasto commented Jun 17, 2020

Fixes a link error on master (39bd9dd):

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

See:

@maflcko
Copy link
Member

maflcko commented Jun 17, 2020

How does the given patch fix this?

@achow101
Copy link
Member

ACK ef11f39

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

@Sjors
Copy link
Member

Sjors commented Jun 17, 2020

Could use some documentation as to why ef11f39 fixes the issue, but it does.

@hebasto
Copy link
Member Author

hebasto commented Jun 17, 2020

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.

@hebasto
Copy link
Member Author

hebasto commented Jun 17, 2020

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

$ ./configure CXXFLAGS=-O0

UPDATE: using GCC 7.5.0

@hebasto
Copy link
Member Author

hebasto commented Jun 17, 2020

The alternative approach is not using function aliasing at all:

diff --git a/src/ui_interface.cpp b/src/ui_interface.cpp
index 15795bd67..c6017e57a 100644
--- a/src/ui_interface.cpp
+++ b/src/ui_interface.cpp
@@ -59,6 +59,11 @@ bool InitError(const bilingual_str& str)
     return false;
 }
 
+bool AbortError(const bilingual_str& str)
+{
+    return InitError(str);
+}
+
 void InitWarning(const bilingual_str& str)
 {
     uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_WARNING);
diff --git a/src/ui_interface.h b/src/ui_interface.h
index 356d30eaf..bfa771a1b 100644
--- a/src/ui_interface.h
+++ b/src/ui_interface.h
@@ -122,7 +122,7 @@ void InitWarning(const bilingual_str& str);
 
 /** Show error message **/
 bool InitError(const bilingual_str& str);
-constexpr auto AbortError = InitError;
+bool AbortError(const bilingual_str& str);
 
 extern CClientUIInterface uiInterface;
 

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@hebasto
Copy link
Member Author

hebasto commented Jun 17, 2020

Updated ef11f39 -> b83cc0f (pr19309.01 -> pr19309.02, diff):

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

@dongcarl
Copy link
Contributor

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?

@maflcko
Copy link
Member

maflcko commented Jun 19, 2020

@dongcarl I don't think anyone has reduced the test case yet

@maflcko maflcko changed the title Fix link error with --enable-debug refactor: Fix link error with --enable-debug Jun 19, 2020
@achow101
Copy link
Member

Re-ACK b83cc0f

@maflcko maflcko merged commit f3d776b into bitcoin:master Jun 19, 2020
@maflcko
Copy link
Member

maflcko commented Jun 19, 2020

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

@hebasto hebasto deleted the 200617-fix branch June 20, 2020 08:35
@hebasto
Copy link
Member Author

hebasto commented Jun 20, 2020

@MarcoFalke

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

Thank you Marco!

Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Dec 11, 2020
Summary:
```
FatalError has been copied from AbortNode, so the two should use the
same style to avoid confusion.

Follow-up to #18927
```

Backport of core [[bitcoin/bitcoin#19295 | PR19295]], [[bitcoin/bitcoin#19309 | PR19309]] and [[bitcoin/bitcoin#19331 | PR19331]].
[[bitcoin/bitcoin#19295 | PR19295]] is the original intent
[[bitcoin/bitcoin#19309 | PR19309]] is a hacky bug fix
[[bitcoin/bitcoin#19331 | PR19331]] reverts [[bitcoin/bitcoin#19309 | PR19309]] and fixes [[bitcoin/bitcoin#19295 | PR19295]].

In the end the relevant commits are:
bitcoin/bitcoin@fa02b47
bitcoin/bitcoin@fac96e6
bitcoin/bitcoin@fa72ca6
bitcoin/bitcoin@cccc278

Depends on D8649.

Test Plan:
With debug:
  ninja all check-all

Reviewers: #bitcoin_abc, jasonbcox

Reviewed By: #bitcoin_abc, jasonbcox

Differential Revision: https://reviews.bitcoinabc.org/D8650
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants