Skip to content
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

clang: "expected relocatable expression" when compiling large inline asm with -O0 and address sanitizer #92182

Open
theuni opened this issue May 14, 2024 · 0 comments

Comments

@theuni
Copy link

theuni commented May 14, 2024

As in title: Bitcoin Core's sha256 Transform function in hand-written sse4 asm (implementing the algorithm from Intel's whitepaper) is unable to compile with optimizations disabled and address sanitizer enabled: sha256_sse4.cpp. The file is standalone and requires no other files.

Compile with: clang++ -std=c++20 -fPIC -O0 -fsanitize=address -c crypto/sha256_sse4.cpp -o out.o

crypto/sha256_sse4.cpp:44:9: error: expected relocatable expression
"shl $0x6,%2;"
^
:1:1882: note: instantiated into assembly here
crypto/sha256_sse4.cpp:44:9: error: expected relocatable expression
"shl $0x6,%2;"
^
:1:2580: note: instantiated into assembly here
crypto/sha256_sse4.cpp:44:9: error: expected relocatable expression
"shl $0x6,%2;"
^
<snip>

It's no problem with optimizations at >= -O1 or with asan off. gcc is able to compile it fine with the same options.

We intend to work around it by disabling asan for clang with no optimizations: bitcoin/bitcoin#30097

@github-actions github-actions bot added the clang Clang issues not falling into any other category label May 14, 2024
@EugeneZelenko EugeneZelenko added inline-asm and removed clang Clang issues not falling into any other category labels May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants