-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixed duplicate symbol with another lib #4093
Merged
satoshiotomakan
merged 8 commits into
trustwallet:master
from
ahaladok:fix-duplicate-symbol-with-another-lib
Nov 22, 2024
Merged
fixed duplicate symbol with another lib #4093
satoshiotomakan
merged 8 commits into
trustwallet:master
from
ahaladok:fix-duplicate-symbol-with-another-lib
Nov 22, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ahaladok
requested review from
Milerius,
satoshiotomakan and
ar-g
as code owners
November 2, 2024 10:29
satoshiotomakan
previously approved these changes
Nov 4, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
O código que eu forneceu é um exemplo de como receber pagamentos no Kwai
usando PayPal. Para usar esse código, você precisará fornecê-lo ao
desenvolvedor da sua plataforma ou integrá-lo diretamente no seu site ou
aplicativo.
Aqui estão algumas opções de quem pode receber o código:
1. Desenvolvedor da sua plataforma: Se você tem um desenvolvedor que cuida
da sua plataforma, você pode fornecer o código a ele.
2. Equipe de TI da sua empresa: Se você trabalha em uma empresa, você pode
fornecer o código à equipe de TI.
3. Agência de desenvolvimento: Se você contratou uma agência de
desenvolvimento para criar a sua plataforma, você pode fornecer o código a
eles.
4. Kwai Support: Se você precisa de ajuda para integrar o código, você pode
contatar o suporte do Kwai.
Antes de fornecer o código, certifique-se de:
1. Verificar se o código está correto e atualizado.
2. Remover qualquer informação sensível (como chaves de API).
3. Fornecer instruções claras sobre como integrar o código.
Lembre-se de que o código é apenas um exemplo e pode precisar ser adaptado
para a sua plataforma específica.
Ruy Eduardo
Em sáb., 2 de nov. de 2024, 7:30 AM, Andropulus ***@***.***>
escreveu:
… Description
This fix addresses the duplicate symbol issue related to the blake2b
function, which occurred when linking both libTrezorCrypto and libQt6Core.
The duplication involved symbols such as '_blake2b' and
'_blake2b_init_param'.
duplicate symbol '_blake2b' in:
/Users/andrei.haladok/Desktop/work_folder/Libraries/local/Qt-6.2.9/lib/libQt6Core_debug.a[x86_64][123](qcryptographichash.cpp.o)
/Users/andrei.haladok/Desktop/work_folder/Libraries/local/lib/libTrezorCrypto.a[43](blake2b.c.o)
duplicate symbol '_blake2b_init_param' in:
/Users/andrei.haladok/Desktop/work_folder/Libraries/local/Qt-6.2.9/lib/libQt6Core_debug.a[x86_64][123](qcryptographichash.cpp.o)
/Usersandrei.haladokDesktop/work_folder/Libraries/local/lib/libTrezorCrypto.a[43](blake2b.c.o)
ld: 2 duplicate symbols clang++: error: linker command failed with exit
code 1 (use -v to see invocation)
What was changed:
In the blake2b.h header file of the libTrezorCrypto library, a tc_ prefix
was added to blake2b-related function names to avoid symbol conflicts:
- blake2b_Init -> tc_blake2b_Init
- blake2b_InitKey -> tc_blake2b_InitKey
- blake2b_InitPersonal -> tc_blake2b_InitPersonal
- blake2b_Update -> tc_blake2b_Update
- blake2b_Final -> tc_blake2b_Final
- blake2b -> tc_blake2b
- blake2b_Personal -> tc_blake2b_Personal
- blake2b_Key -> tc_blake2b_Key
These changes were applied throughout the code to ensure the functions
align with the updated naming, thus preventing compilation conflicts.
Why this approach is better:
In my opinion, this change is a cleaner solution compared to using "dirty
hacks" that might lead to undefined behavior, security vulnerabilities, or
maintenance issues. Alternative workarounds, such as using the following
linker flags and hacks, can often obscure the underlying problem and
introduce other risks:
- -unexported_symbols_list
- -Xlinker -multiply_defined -Xlinker suppress
- -allow_multiply_defined_symbols
- -Wl,-dead_strip
- -Wl,-force_load
With this fix, we can avoid manipulating symbols and hiding them at the
linking stage, which ensures a more stable and maintainable codebase.
How to test
1. Navigate to samples/cpp/CMakeLists.txt, which is a sample project
configuration.
2. Add libQt6Core_debug as a dependency in the CMake configuration to
replicate the setup where libQt6Core and libTrezorCrypto are linked
together.
3. Build the project and check for any linker errors related to
duplicate symbols.
4. Ensure that the project compiles successfully without duplicate
symbol errors, confirming that the tc_ prefixes in libTrezorCrypto
resolve the conflict with libQt6Core.
Types of changes
- Bug fix (non-breaking change which fixes an issue)
Checklist
- Create pull request as draft initially, unless it's complete.
- Add tests to cover changes as needed.
- Update documentation as needed.
- If there is a related Issue, mention it in the description.
If you're adding a new blockchain
- I have read the guidelines
<https://developer.trustwallet.com/wallet-core/newblockchain#integration-criteria>
for adding a new blockchain.
------------------------------
You can view, comment on, or merge this pull request online at:
#4093
Commit Summary
- 6f9400f
<6f9400f>
fixed duplicate symbol with another lib
File Changes
(8 files <https://github.com/trustwallet/wallet-core/pull/4093/files>)
- *M* src/Nimiq/Address.cpp
<https://github.com/trustwallet/wallet-core/pull/4093/files#diff-db69249980c26795fd6b2b624c9387459b650ba40a05f7830aaeff04a3b7a28d>
(2)
- *M* src/interface/TWHash.cpp
<https://github.com/trustwallet/wallet-core/pull/4093/files#diff-53e6eebfb5f58e0c9d3cc429d00634df8a0fb0c946619eda6299983fd398fc91>
(2)
- *M* trezor-crypto/crypto/blake2b.c
<https://github.com/trustwallet/wallet-core/pull/4093/files#diff-de4092ab654350e2f297a94abceda0922ce5ab174730e07788f4f34f8c11e08b>
(40)
- *M* trezor-crypto/crypto/hasher.c
<https://github.com/trustwallet/wallet-core/pull/4093/files#diff-5330f1d88a5f5633583c22bbb832cc9a516cf9abc69b2a8f442150abb02de020>
(8)
- *M* trezor-crypto/crypto/nano.c
<https://github.com/trustwallet/wallet-core/pull/4093/files#diff-e5aeb0a3455a8165e47d1b95b53dbd054e8cd82fe25bed357e52598f3c965f7a>
(12)
- *M* trezor-crypto/crypto/tests/test_check.c
<https://github.com/trustwallet/wallet-core/pull/4093/files#diff-a3e44a3f49532f3a7d8df0b3fda168948c2debe48c1cca68e71220d0289094ee>
(22)
- *M* trezor-crypto/include/TrezorCrypto/blake2b.h
<https://github.com/trustwallet/wallet-core/pull/4093/files#diff-73dd3ab5f478633674baf882f60d9be3f91031e08da0c75007ff5d8ba2bb7c23>
(16)
- *M*
trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-hash-custom-blake2b.h
<https://github.com/trustwallet/wallet-core/pull/4093/files#diff-9abde32b09cdb5dd24518cb8cff8b72ef7820a0ea76cf9652fafb5a3b7b685e4>
(8)
Patch Links:
- https://github.com/trustwallet/wallet-core/pull/4093.patch
- https://github.com/trustwallet/wallet-core/pull/4093.diff
—
Reply to this email directly, view it on GitHub
<#4093>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A2PQQHDGL2NYK4WV6JDAOJTZ6SSTJAVCNFSM6AAAAABRBTKXFGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGYZTAMZXGEYTKOI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
…r-lib' into fix-duplicate-symbol-with-another-lib
satoshiotomakan
approved these changes
Nov 7, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This fix addresses the duplicate symbol issue related to the
blake2b
function, which occurred when linking bothlibTrezorCrypto
andlibQt6Core
. The duplication involved symbols such as'_blake2b'
and'_blake2b_init_param'
.duplicate symbol '_blake2b' in: /Users/andrei.haladok/Desktop/work_folder/Libraries/local/Qt-6.2.9/lib/libQt6Core_debug.a[x86_64][123](qcryptographichash.cpp.o) /Users/andrei.haladok/Desktop/work_folder/Libraries/local/lib/libTrezorCrypto.a[43](blake2b.c.o) duplicate symbol '_blake2b_init_param' in: /Users/andrei.haladok/Desktop/work_folder/Libraries/local/Qt-6.2.9/lib/libQt6Core_debug.a[x86_64][123](qcryptographichash.cpp.o) /Usersandrei.haladokDesktop/work_folder/Libraries/local/lib/libTrezorCrypto.a[43](blake2b.c.o) ld: 2 duplicate symbols clang++: error: linker command failed with exit code 1 (use -v to see invocation)
What was changed:
In the
blake2b.h
header file of thelibTrezorCrypto
library, atc_
prefix was added toblake2b
-related function names to avoid symbol conflicts:blake2b_Init
->tc_blake2b_Init
blake2b_InitKey
->tc_blake2b_InitKey
blake2b_InitPersonal
->tc_blake2b_InitPersonal
blake2b_Update
->tc_blake2b_Update
blake2b_Final
->tc_blake2b_Final
blake2b
->tc_blake2b
blake2b_Personal
->tc_blake2b_Personal
blake2b_Key
->tc_blake2b_Key
These changes were applied throughout the code to ensure the functions align with the updated naming, thus preventing compilation conflicts.
Why this approach is better:
In my opinion, this change is a cleaner solution compared to using "dirty hacks" that might lead to undefined behavior, security vulnerabilities, or maintenance issues. Alternative workarounds, such as using the following linker flags and hacks, can often obscure the underlying problem and introduce other risks:
-unexported_symbols_list
-Xlinker -multiply_defined -Xlinker suppress
-allow_multiply_defined_symbols
-Wl,-dead_strip
-Wl,-force_load
With this fix, we can avoid manipulating symbols and hiding them at the linking stage, which ensures a more stable and maintainable codebase.
How to test
samples/cpp/CMakeLists.txt
, which is a sample project configuration.libQt6Core_debug
as a dependency in the CMake configuration to replicate the setup wherelibQt6Core
andlibTrezorCrypto
are linked together.tc_
prefixes inlibTrezorCrypto
resolve the conflict withlibQt6Core
.Types of changes
Checklist
If you're adding a new blockchain