首页
社区
课程
招聘
Windows 平台下编译llvm pass报错

编译环境:

1
2
3
4
5
6
7
8
9
10
11
> clang -v
clang version 12.0.1
Target: i686-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files (x86)\LLVM\bin
 
> cmake -version
cmake version 3.20.21032501-MSVC_2
 
> Ninja --version
1.10.2

项目:
https://github.com/bluesadi/Pluto-Obfuscator.git
报错日志:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
PS C:\Users\xxx\Desktop\Pluto-Obfuscator\Build> cmake -G "Ninja" ..\Transforms
-- The C compiler identification is Clang 12.0.1 with GNU-like command-line
-- The CXX compiler identification is Clang 12.0.1 with GNU-like command-line
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/Program Files (x86)/LLVM/bin/clang.exe
-- Check for working C compiler: C:/Program Files (x86)/LLVM/bin/clang.exe - broken
CMake Error at C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.20/Modules/CMakeTestCCompiler.cmake:66 (message):
  The C compiler
 
    "C:/Program Files (x86)/LLVM/bin/clang.exe"
 
  is not able to compile a simple test program.
 
  It fails with the following output:
 
    Change Dir: C:/Users/xxx/Desktop/Pluto-Obfuscator/Build/CMakeFiles/CMakeTmp
 
    Run Build Command(s):C:/PROGRA~2/MICROS~2/2019/COMMUN~1/Common7/IDE/COMMON~1/MICROS~1/CMake/Ninja/ninja.exe cmTC_5c887 && [1/2] Building C object CMakeFiles/cmTC_5c887.dir/testCCompiler.c.obj
    [2/2] Linking C executable cmTC_5c887.exe
    FAILED: cmTC_5c887.exe
    cmd.exe /C "cd . && C:\PROGRA~2\LLVM\bin\clang.exe -fuse-ld=lld-link -nostartfiles -nostdlib -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd -Xlinker /subsystem:console CMakeFiles/cmTC_5c887.dir/testCCompiler.c.obj -o cmTC_5c887.exe -Xlinker /implib:cmTC_5c887.lib -Xlinker /pdb:cmTC_5c887.pdb -Xlinker /version:0.0   -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames && cd ."
    clang: error: unable to execute command: program not executable
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    ninja: build stopped: subcommand failed.
 
 
 
 
 
  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:1 (project)
 
 
-- Configuring incomplete, errors occurred!
See also "C:/Users/xxx/Desktop/Pluto-Obfuscator/Build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/xxx/Desktop/Pluto-Obfuscator/Build/CMakeFiles/CMakeError.log".

在官方社区找到了个老的帖子,但他们也没有给具体方案:
https://gitlab.kitware.com/cmake/cmake/-/issues/18476

收藏
3条回答
34r7hm4n 2023-1-3

下面这个报错的意思是:无法用C编译器 "C:/Program Files (x86)/LLVM/bin/clang.exe" 编译一个测试文件。

1
2
3
4
The C compiler
 
"C:/Program Files (x86)/LLVM/bin/clang.exe"
is not able to compile a simple test program.

原因可能是"C:/Program Files (x86)/LLVM/bin/clang.exe"这个路径有问题。

 

也可能是是clang.exe本身有问题,你可以用clang.exe编译一个简单的程序试试。

回复
Rixo_叶默: 是可以编译的,但是通不过cmake的测试用例,我注释掉好像就能通过了,但还有其他的错,哎。
回复 2023-1-4
34r7hm4n: @Rixo_叶默 我也不太清楚了,用gcc编译试试?cmake加上选项  -DCMAKE_C_COMPILER=gcc  -DCMAKE_CXX_COMPILER=g++
回复 2023-1-5
mb_hgrhclks 2023-1-5

CMake无法执行C编译器clang.exe。
可能有几个原因造成这个错误。
尝试的方法:
确保C编译器的路径是正确的。你可以通过检查错误消息中指定的路径是否存在文件clang.exe来验证这一点:C:/Program Files (x86)/LLVM/bin/clang.exe。
检查C编译器是否被你的防病毒软件或Windows Defender阻止。如果是,你可能需要在你的防病毒设置中为C编译器添加一个例外。

1
2
3
尝试重新安装C编译器,并确保在你的系统上正确设置。
 
检查C编译器是否有任何缺少的依赖项,这些依赖项是C编译器正常工作所必需的。
回复
酋长哥 2023-2-12

看到您的错误日志,似乎 CMake 在检测编译器是否能够正常工作时遇到了问题。具体来说,编译程序在运行的过程中遇到了 "unable to execute command: program not executable" 错误,并且编译失败了。

 

根据您找到的帖子,这个问题可能是由于 Clang 和 Visual Studio 的冲突造成的。请尝试以下解决方案:

1
2
3
安装 Visual Studio 的 Clang/C2 组件,以解决 CMake 与 Visual Studio 的兼容性问题。
 
在 CMake 命令行中指定编译器路径:

python

 

cmake -G "Ninja" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ..\Transforms

1
尝试使用不同版本的 Clang 和 Visual Studio 解决兼容性问题。

如果仍然无法解决问题,请尝试搜索关于 Clang 与 Visual Studio 兼容性问题的其他解决方案,或者在相关的社区中寻求帮助。

回复
LLVM与代码混淆技术
  参与学习     315 人
  提问次数     12 个
《LLVM与代码混淆技术》详解3种经典代码混淆方式+2种变体
我的问答 领取收益
0
我的提问
0
我的回答
0
学习收益