首頁
社區(qū)
課程
招聘
Windows 平臺下編譯llvm pass報錯

編譯環(huán)境:

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

在官方社區(qū)找到了個老的帖子,但他們也沒有給具體方案:
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無法執(zhí)行C編譯器clang.exe。
可能有幾個原因造成這個錯誤。
嘗試的方法:
確保C編譯器的路徑是正確的。你可以通過檢查錯誤消息中指定的路徑是否存在文件clang.exe來驗證這一點:C:/Program Files (x86)/LLVM/bin/clang.exe。
檢查C編譯器是否被你的防病毒軟件或Windows Defender阻止。如果是,你可能需要在你的防病毒設置中為C編譯器添加一個例外。

1
2
3
嘗試重新安裝C編譯器,并確保在你的系統(tǒng)上正確設置。
 
檢查C編譯器是否有任何缺少的依賴項,這些依賴項是C編譯器正常工作所必需的。
回復
酋長哥 2023-2-12

看到您的錯誤日志,似乎 CMake 在檢測編譯器是否能夠正常工作時遇到了問題。具體來說,編譯程序在運行的過程中遇到了 "unable to execute command: program not executable" 錯誤,并且編譯失敗了。

 

根據(jù)您找到的帖子,這個問題可能是由于 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 兼容性問題的其他解決方案,或者在相關的社區(qū)中尋求幫助。

回復
LLVM與代碼混淆技術
  參與學習     320 人
  提問次數(shù)     12 個
《LLVM與代碼混淆技術》詳解3種經(jīng)典代碼混淆方式+2種變體
我的問答 領取收益
0
我的提問
0
我的回答
0
學習收益