clang: fix dlltool default target

Fixes msys2/CLANG-packages#43
This commit is contained in:
Mateusz Mikuła
2021-06-08 02:15:53 +02:00
committed by Jeremy Drake
parent 6d9a40d924
commit 60d506bbfe
3 changed files with 74 additions and 1 deletions

View File

@@ -0,0 +1,69 @@
From 3355670c60fc819a8c173a71335e3c7542346b0d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= <mati865@gmail.com>
Date: Tue, 8 Jun 2021 01:22:31 +0200
Subject: [PATCH] Dlltool: use default LLVM target unless specified
---
.../llvm-dlltool/DlltoolDriver.cpp | 25 +++++++++++++------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp b/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
index a4fd62e5557f..4a86f9a17306 100644
--- a/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
+++ b/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
@@ -17,6 +17,7 @@
#include "llvm/Option/Arg.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Option/Option.h"
+#include "llvm/Support/Host.h"
#include "llvm/Support/Path.h"
#include <vector>
@@ -74,6 +75,22 @@ static MachineTypes getEmulation(StringRef S) {
.Default(IMAGE_FILE_MACHINE_UNKNOWN);
}
+MachineTypes getDefaultEmulation() {
+ std::string TripleStr = sys::getDefaultTargetTriple();
+ switch (Triple(TripleStr).getArch()) {
+ case Triple::x86:
+ return COFF::IMAGE_FILE_MACHINE_I386;
+ case Triple::x86_64:
+ return COFF::IMAGE_FILE_MACHINE_AMD64;
+ case Triple::arm:
+ return COFF::IMAGE_FILE_MACHINE_ARMNT;
+ case Triple::aarch64:
+ return COFF::IMAGE_FILE_MACHINE_ARM64;
+ default:
+ return COFF::IMAGE_FILE_MACHINE_UNKNOWN;
+ }
+}
+
int llvm::dlltoolDriverMain(llvm::ArrayRef<const char *> ArgsArr) {
DllOptTable Table;
unsigned MissingIndex;
@@ -94,12 +111,6 @@ int llvm::dlltoolDriverMain(llvm::ArrayRef<const char *> ArgsArr) {
return 1;
}
- if (!Args.hasArgNoClaim(OPT_m) && Args.hasArgNoClaim(OPT_d)) {
- llvm::errs() << "error: no target machine specified\n"
- << "supported targets: i386, i386:x86-64, arm, arm64\n";
- return 1;
- }
-
for (auto *Arg : Args.filtered(OPT_UNKNOWN))
llvm::errs() << "ignoring unknown argument: " << Arg->getAsString(Args)
<< "\n";
@@ -119,7 +130,7 @@ int llvm::dlltoolDriverMain(llvm::ArrayRef<const char *> ArgsArr) {
return 1;
}
- COFF::MachineTypes Machine = IMAGE_FILE_MACHINE_UNKNOWN;
+ COFF::MachineTypes Machine = getDefaultEmulation();
if (auto *Arg = Args.getLastArg(OPT_m))
Machine = getEmulation(Arg->getValue());
--
2.31.1.windows.1

View File

@@ -75,6 +75,7 @@ source=("https://github.com/llvm/llvm-project/releases/download/llvmorg-${pkgver
"0010-mbig-obj-for-all.patch"
"0011-nm-version-option.patch"
"0012-windres.patch"
"0013-Dlltool-use-default-LLVM-target-unless-specified.patch"
"0101-Disable-fPIC-errors.patch"
"0103-Use-posix-style-path-separators-with-MinGW.patch"
"0104-link-pthread-with-mingw.patch"
@@ -117,6 +118,7 @@ sha256sums=('9ed1688943a4402d7c904cc4515798cdb20080066efa010fe7e1f2551b423628'
'b38c502a113018b934d607d4c92c3e907f92b418c6da1d4425c3fa614f983f10'
'5d0d8653c95a2d74a4ae531370c3d0584054d15cfef16eb4c45b1d8e5c0fcb4c'
'e8a6c9e32848dcb9bc16e509516556ced4a5fe888d9b92929e83d0b55c05647b'
'567307cb8d2a9072ba521b9daaf448d73ca213d9a4f2f4e07485f4be4ac9881d'
'63b2bda6a487ec69e257c3b7a14d71f6bec649fca058a5a54804f213d45c7c70'
'2d1dc7f7cd6bd61f275cd0be6650f3086aee622074ac786ff5a921bf8ecaada2'
'715cb8862753854b2d9256e0b70003e2d1f57083d83eaeaf5a095fc72b8a4e26'
@@ -163,7 +165,8 @@ prepare() {
"0004-llvm-config-look-for-unversioned-shared-lib-on-win32.patch" \
"0010-mbig-obj-for-all.patch" \
"0011-nm-version-option.patch" \
"0012-windres.patch"
"0012-windres.patch" \
"0013-Dlltool-use-default-LLVM-target-unless-specified.patch"
if (( ! _clangprefix )); then
apply_patch_with_msg \

View File

@@ -16,6 +16,7 @@ Legend:
- `"0010-mbig-obj-for-all.patch"` :arrow_up_small:
- `"0011-nm-version-option.patch"` :arrow_down_small:
- `"0012-windres.patch"` :arrow_down_small:
- `"0013-Dlltool-use-default-LLVM-target-unless-specified.patch"` :x:
- `"0101-Disable-fPIC-errors.patch"` :x:
- `"0103-Use-posix-style-path-separators-with-MinGW.patch"` :x::x::x: - this one is really imporant
- `"0104-link-pthread-with-mingw.patch"` :grey_exclamation: