eshard / obfuscator-llvm

Other
236 stars 42 forks source link

Backend error - inconsistency in registered commandline options #22

Closed net-cowboy closed 11 months ago

net-cowboy commented 11 months ago

Hi

I try to compile a test code:

#include <stdio.h>

int main(){
    printf("Test print\n");
    return 0;
}

The command line is the following:

LLVM_OBF_SCALAROPTIMIZERLATE_PASSES="split-basic-blocks" /usr/lib/llvm-14/bin/clang -v -fno-legacy-pass-manager -fpass-plugin=/home/user/obfuscator-llvm/build/libLLVMObfuscator.so test.c

I get the following error:

Debian clang version 14.0.6
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-14/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/13
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/13
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -v -fcoverage-compilation-dir=/home/user/Tools/clangtest -resource-dir /usr/lib/llvm-14/lib/clang/14.0.6 -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.6/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/13/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/home/Tools/clangtest -ferror-limit 19 -fgnuc-version=4.2.1 -fno-legacy-pass-manager -fcolor-diagnostics -fpass-plugin=/home/user/Tools/obfuscator-llvm/build/libLLVMObfuscator.so -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/test-1676a5.o -x c test.c
clang -cc1 version 14.0.6 based upon LLVM 14.0.6 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/13/../../../../x86_64-linux-gnu/include"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/llvm-14/lib/clang/14.0.6/include
 /usr/local/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
clang (LLVM option parsing): CommandLine Error: Option 'enable-fs-discriminator' registered more than once!
fatal error: error in backend: inconsistency in registered CommandLine options
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Debian clang version 14.0.6
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-14/bin
clang: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/test-6d6820.c
clang: note: diagnostic msg: /tmp/test-6d6820.sh
clang: note: diagnostic msg:

********************

I am on Debian 64 bits 6.5.0. I have tried with clang versions 14 to 17, resulting in the same issue. The only difference is that -fno-legacy-pass-manager is not supported after version 15.

I have also tried compiling different files for different architectures, still no difference. I guess the .so obfuscator needs to be compiled with specific flags ?

PatriceBlin commented 11 months ago

Hi, It's more or less due to the way clang was compiled. Some includes the libraries "Core" or "Support", other don't.

Try to edit the CMakeLists.txt and remove either LLVMCore or LLVMSupport or both.

target_link_libraries(LLVMObfuscator LLVMCore LLVMSupport)
net-cowboy commented 11 months ago

fixed, thanks!