无法使用lld-link.exe(Windows)链接C运行时库(libcmt.lib) [英] Unable to link C runtime library (libcmt.lib) using lld-link.exe (Windows)
问题描述
我正在使用LLVM编写语言.我想避免打包clang并仅使用LLVM工具(例如lld,lld-link).我一直在尝试从我的简单IR代码(testinput.ll
)调用printf
函数:
I'm writing a language using LLVM. I'd like to avoid having to package clang and simply use the LLVM tools (ex. lld, lld-link). I've been trying to invoke the printf
function from my simple IR code (testinput.ll
):
; ModuleID = 'Test2'
source_filename = "entry"
@str_0 = private unnamed_addr constant [13 x i8] c"Hello world!\00"
declare i32 @printf(i8*, ...)
define i32 @main() {
entry:
%anonymous_10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str_0, i32 0, i32 0))
ret i32 1234
}
但是无论我尝试什么,我都会收到错误消息:
But I keep receiving errors no matter what I try:
$ clang-cl -fuse-ld=lld-link testinput.ll "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\spectre\x64\libcmt.lib"
注意:我只是通过在系统上搜索libcmt.lib
来随机选择链接"... spectre \ x64 \ libcmt.lib ...".
Note: I've chosen the link randomly "... spectre\x64\libcmt.lib ..." by simply searching for libcmt.lib
on the system.
错误:
C:\Program Files\LLVM\bin\lld-link: warning: libcmt.lib(loadcfg.obj): undefined symbol: __enclave_config
error: link failed
clang-cl.exe: error: linker command failed with exit code 1 (use -v to see invocation)
我正在使用Windows 10(x64)和LLVM 5.0.有趣的是,使用link.exe
(Windows VS工具的链接器),一切都可以正常工作(在我的情况下,这是clang所使用的).
I'm using Windows 10 (x64) with LLVM 5.0. Interestingly, using link.exe
(Windows' VS tools' linker) everything works fine (which is what clang uses under the hood in my case).