Hikari-LLVM15
Hikari-LLVM15 copied to clipboard
`constenc` is not compatible with LTO
When enabling constenc
and LTO, the linker crashes with:
ld.lld: error: Invalid record (Producer: 'LLVM16.0.0' Reader: 'LLVM 16.0.0')
I am trying to make a reproducible example.
.....What?
@Naville @61bcdefg
Reproducible example:
namespace {
bool do_check() {
return true;
}
void test2(int client) {
switch (client) {
case 0: {
static auto check = do_check();
}
case 1: {
}
}
}
}
void test(int client) { test2(client); }
Compile with clang++ -shared -flto -fuse-ld=lld -mllvm -enable-constenc
will crash the linker.
@61bcdefg not working
That's kind of a weird problem. After I reproduce this error, I found it emited on https://github.com/61bcdefg/Hikari-LLVM15/blob/llvm-16.0.0rel/llvm/lib/IR/Verifier.cpp#L647, The Verifier considers the function to be a declaration, and the declared linkage must be external, which causes this error. I have yet to find out why the Verifier considers the function to be a declaration.
https://github.com/61bcdefg/Hikari-LLVM15/tree/llvm-16.0.0rel or https://github.com/61bcdefg/Hikari-LLVM15/tree/llvm-17.0.6rel should works now, and if you enable LTO, you need to pass -Wl,-mllvm,-enable-xxx
to enable obfuscations.