简体   繁体   English

使用 MSYS2 中的 LLVM-C api 返回退出代码 1,但使用 WSL 工作正常

[英]using LLVM-C api from MSYS2 returns exit code 1, but using WSL works fine

i installed llvm+clang using MSYS2, and all the tools work fine for me, but the LLVM-C always returns exit code 1, here is my sample code:我使用 MSYS2 安装了 llvm+clang,所有工具对我来说都可以正常工作,但是 LLVM-C 总是返回退出代码 1,这是我的示例代码:

#include <llvm-c/Core.h>
#include <stdlib.h>

int main(int argc, char const *argv[]) {
    LLVMModuleRef mod = LLVMModuleCreateWithName("my_module");

    LLVMPrintModuleToFile(mod, "my_module.ll", NULL);

    LLVMDisposeModule(mod);
    return 0;
}

it compiles on MSYS2, but it returns exit code 1, and does not write the module to the file,它在 MSYS2 上编译,但它返回退出代码 1,并且不将模块写入文件,

but when compiled using WSL, it returns exit code 0 and writes to the file.但是当使用 WSL 编译时,它返回退出代码 0 并写入文件。

i am using these MSYS2 packages:我正在使用这些 MSYS2 包:
https://packages.msys2.org/package/mingw-w64-x86_64-clang?repo=mingw64 https://packages.msys2.org/package/mingw-w64-x86_64-clang?repo=mingw64
https://packages.msys2.org/package/mingw-w64-x86_64-llvm?repo=mingw64 https://packages.msys2.org/package/mingw-w64-x86_64-llvm?repo=mingw64

i did not try the C++ LLVM api, but i am assuming that does not work as well.我没有尝试 C++ LLVM api,但我假设它也不起作用。

here are the commands i run:这是我运行的命令:
powershell:电源外壳:

$x = llvm-config --cflags --ldflags core --system-libs --libs
clang $x hello.c -fuse-ld=lld
./a.exe
echo $lastExitCode # returns 1

bash:重击:

clang `llvm-config --cflags --ldflags core --system-libs --libs` hello.c
./a.out
cat my_module.ll

nvm 我修复了它,我的解决方案是我没有使用 powershell,而是使用了 MSYS2 (MinGW-w64) shell。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM