[PATCH] D37336: [clang-cl] Explicitly set object format to COFF in CL mode
Oleg Ranevskyy via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 31 07:59:14 PDT 2017
iid_iunknown created this revision.
Herald added subscribers: kristof.beyls, aemerson.
Currently object format is taken from the default target triple. For toolchains with a non-COFF default target this may result in an object format inappropriate for pc-windows and lead to compilation issues.
For example, the default triple `aarch64-linux-elf` may produce something like `aarch64-pc-windows-msvc19.0.24215-elf` in CL mode. Clang creates `MicrosoftARM64TargetInfo` for such triple with data layout `e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128`. On the other hand, the AArch64 backend in `computeDataLayout` detects a non-COFF target and selects `e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128` as data layout for little endian. Different layouts used by clang and the backend cause an error:
error: backend data layout 'e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128'
does not match expected target description 'e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128'
This can be observed on the clang's Driver/cl-pch.c test with AArch64 as a default target.
This patch enforces COFF in CL mode.
Repository:
rL LLVM
https://reviews.llvm.org/D37336
Files:
lib/Driver/Driver.cpp
Index: lib/Driver/Driver.cpp
===================================================================
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -663,6 +663,7 @@
T.setOS(llvm::Triple::Win32);
T.setVendor(llvm::Triple::PC);
T.setEnvironment(llvm::Triple::MSVC);
+ T.setObjectFormat(llvm::Triple::COFF);
DefaultTargetTriple = T.str();
}
if (const Arg *A = Args.getLastArg(options::OPT_target))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37336.113405.patch
Type: text/x-patch
Size: 435 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170831/e45d69ae/attachment.bin>
More information about the cfe-commits
mailing list