Issue 92182
Summary clang: "expected relocatable _expression_" when compiling large inline asm with -O0 and address sanitizer
Labels clang
Assignees
Reporter theuni
    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](https://github.com/bitcoin/bitcoin/blob/master/src/crypto/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;"
>         ^
> <inline asm>:1:1882: note: instantiated into assembly here
> crypto/sha256_sse4.cpp:44:9: error: expected relocatable _expression_
> "shl    $0x6,%2;"
>         ^
> <inline asm>: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: https://github.com/bitcoin/bitcoin/pull/30097
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to