Hikari-LLVM15 icon indicating copy to clipboard operation
Hikari-LLVM15 copied to clipboard

`constenc` is not compatible with LTO

Open yujincheng08 opened this issue 1 year ago • 5 comments

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.

yujincheng08 avatar Apr 05 '23 01:04 yujincheng08

.....What?

Naville avatar Apr 05 '23 03:04 Naville

@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.

yujincheng08 avatar Apr 08 '23 18:04 yujincheng08

@61bcdefg not working

yujincheng08 avatar Apr 09 '23 02:04 yujincheng08

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.

61bcdefg avatar Apr 09 '23 06:04 61bcdefg

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.

61bcdefg avatar Jul 05 '24 08:07 61bcdefg