无法运行使用clang/lld/mingw编译的Windows二进制文件 [英] Unable to run windows binary compiled with clang/lld/mingw

查看:437
本文介绍了无法运行使用clang/lld/mingw编译的Windows二进制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已从 http://releases.llvm.org/download在Windows 10上下载并安装了clang. .html 和mingw来自 https://sourceforge.net/projects/mingw-w64/

我正在尝试使用clang/lld/mingw编译一个非常基本的C程序:

int main(int argc, char* argv[argc + 1])
{
  return 0;
}

要进行编译,我需要调用:

clang.exe -target x86_64-windows-gnu -fuse-ld=lld.exe -g -gcodeview -Wl,/debug,/pdb:example.pdb example.c -o example.exe

这将创建一个在mainCRTStartup(确切地说是__security_init_cookie)中启动时出错的exe.

但是,使用binutils的默认ld成功运行:

clang.exe -target x86_64-windows-gnu example.c -o example.exe

请注意,我希望使用mingw标头,而不是msvc.

我总共尝试过:

  • x86_64-8.1.0-posix-seh-rt_v6-rev0
  • x86_64-7.3.0-posix-seh-rt_v5-rev0
  • x86_64-8.1.0-win32-seh-rt_v6-rev0
  • x86_64-8.1.0-win32-sjlj-rt_v6-rev0

没有运气产生一个功能程序.

所以我想知道,在这里我做错了什么明显的事情吗?

编辑: 我也尝试了msys2无济于事.具体来说:

pacman -S mingw-w64-x86_64-clang mingw-w64-x86_64-lld

解决方案

根据 https ://bugs.llvm.org/show_bug.cgi?id = 40568

从正常的mingw安装链接到mingw导入库是一项新功能,最早出现在LLD 8中.

除非要编译lld的预发行版本,否则必须等待llvm 8.0.0的二进制发行.希望会在三月的某个时候.

I have downloaded and installed clang on windows 10 from http://releases.llvm.org/download.html and mingw from https://sourceforge.net/projects/mingw-w64/

I am trying to compile a very basic C program using clang/lld/mingw:

int main(int argc, char* argv[argc + 1])
{
  return 0;
}

To compile I invoke:

clang.exe -target x86_64-windows-gnu -fuse-ld=lld.exe -g -gcodeview -Wl,/debug,/pdb:example.pdb example.c -o example.exe

This creates an exe which faults on startup in mainCRTStartup (__security_init_cookie to be precise).

However, running with default ld from binutils is successful:

clang.exe -target x86_64-windows-gnu example.c -o example.exe

Please note that I wish to use mingw headers, not msvc.

In total I tried:

  • x86_64-8.1.0-posix-seh-rt_v6-rev0
  • x86_64-7.3.0-posix-seh-rt_v5-rev0
  • x86_64-8.1.0-win32-seh-rt_v6-rev0
  • x86_64-8.1.0-win32-sjlj-rt_v6-rev0

without any luck producing a functional program.

So I am wondering, is there something obvious I am doing wrong here?

EDIT: I have also tried with msys2 to no avail. Specifically:

pacman -S mingw-w64-x86_64-clang mingw-w64-x86_64-lld

解决方案

According to https://bugs.llvm.org/show_bug.cgi?id=40568

Linking against mingw import libraries from a normal mingw installation is a new feature, first present in LLD 8.

Unless wanting to compile a pre-release version of lld, have to wait for binary release of llvm 8.0.0. This will hopefully be sometime in March.

这篇关于无法运行使用clang/lld/mingw编译的Windows二进制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆