[llvm-bugs] [Bug 49196] New: ARM 32 Bits Windows MSVC C compiler is Fixed in Version LLVM/Clang 11.0.1, But C++ Still Crash
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Feb 15 12:20:37 PST 2021
https://bugs.llvm.org/show_bug.cgi?id=49196
Bug ID: 49196
Summary: ARM 32 Bits Windows MSVC C compiler is Fixed in
Version LLVM/Clang 11.0.1, But C++ Still Crash
Product: clang
Version: 11.0
Hardware: PC
OS: Windows NT
Status: NEW
Severity: release blocker
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: falhumai96 at gmail.com
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
Created attachment 24531
--> https://bugs.llvm.org/attachment.cgi?id=24531&action=edit
Bug attachments
I am trying to compile a simple C++ code, as follows, using the LLVM/Clang
compiler that targets either of `armv4-pc-windows-msvc` or
`armv7-pc-windows-msvc` (basically any ARM, not ARM64, target for Windows
MSVC):
```
#include <iostream>
int main() {
std::cout << "Hello, world!\n";
}
```
Here's also a simple CXX script I used to cross compile the code to Windows
MSVC from Linux:
```
#!/usr/bin/env bash
export MSVC_CROSS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1
&& pwd )"
export MSVC_CROSS_DIR="$MSVC_CROSS_DIR/.."
if [ -z "$MSVC_CROSS_MSVC_DIR" ]; then
export MSVC_CROSS_MSVC_DIR="$MSVC_CROSS_DIR/MSVC/14.20.27508"
fi
if [ -z "$MSVC_CROSS_WINDOWS_KITS_DIR" ]; then
export MSVC_CROSS_WINDOWS_KITS_DIR="$MSVC_CROSS_DIR/WindowsKits/10"
fi
if [ -z "$MSVC_CROSS_WINDOWS_KITS_VER" ]; then
export MSVC_CROSS_WINDOWS_KITS_VER="10.0.18362.0"
fi
if [ -z "$MSVC_CROSS_MS_COMPATIBILITY_VERSION" ]; then
export MSVC_CROSS_MS_COMPATIBILITY_VERSION="19.20.27508"
fi
clang "$@" -target armv4-pc-windows-msvc \
-frtti \
-fuse-ld=lld \
-Wl,-machine:arm \
"-fms-compatibility-version=$MSVC_CROSS_MS_COMPATIBILITY_VERSION" \
-fms-extensions \
-fdelayed-template-parsing \
-fexceptions \
-fcxx-exceptions \
-mthread-model posix \
-fno-threadsafe-statics \
-Wno-overlength-strings \
-Wno-microsoft-enum-value \
-Wno-language-extension-token \
-Wno-unused-command-line-argument \
-Wno-msvc-not-found \
-Wno-pragma-pack \
-Wno-ignored-attributes \
-Wno-ignored-pragma-intrinsic \
-Wno-expansion-to-defined \
-Wno-microsoft-anon-tag \
-Wno-nonportable-include-path \
-Wno-void-pointer-to-int-cast \
-Wno-int-to-void-pointer-cast \
-Wno-pointer-type-mismatch \
-Wno-asm-operand-widths \
-DWIN32 \
-D_WIN32 \
-D_MT \
-D_DLL \
-Xclang -disable-llvm-verifier \
-Xclang '--dependent-lib=msvcrt' \
-Xclang '--dependent-lib=ucrt' \
-Xclang '--dependent-lib=oldnames' \
-Xclang '--dependent-lib=vcruntime' \
-D_CRT_SECURE_NO_WARNINGS \
-D_CRT_NONSTDC_NO_DEPRECATE \
-U__GNUC__ \
-U__gnu_linux__ \
-U__GNUC_MINOR__ \
-U__GNUC_PATCHLEVEL__ \
-U__GNUC_STDC_INLINE__ \
-idirafter "$MSVC_CROSS_MSVC_DIR/include" \
-idirafter
"$MSVC_CROSS_WINDOWS_KITS_DIR/Include/$MSVC_CROSS_WINDOWS_KITS_VER/ucrt" \
-idirafter
"$MSVC_CROSS_WINDOWS_KITS_DIR/Include/$MSVC_CROSS_WINDOWS_KITS_VER/shared" \
-idirafter
"$MSVC_CROSS_WINDOWS_KITS_DIR/Include/$MSVC_CROSS_WINDOWS_KITS_VER/um" \
-idirafter
"$MSVC_CROSS_WINDOWS_KITS_DIR/Include/$MSVC_CROSS_WINDOWS_KITS_VER/winrt" \
"-L$MSVC_CROSS_MSVC_DIR/lib/arm" \
"-L$MSVC_CROSS_WINDOWS_KITS_DIR/Lib/$MSVC_CROSS_WINDOWS_KITS_VER/um/arm" \
"-L$MSVC_CROSS_WINDOWS_KITS_DIR/Lib/$MSVC_CROSS_WINDOWS_KITS_VER/ucrt/arm" \
-lmsvcrt -lkernel32 -Wno-msvc-not-found -Xlinker /subsystem:console -x c++
```
I did build other simple C code, and it passes, while it wasn't passing back in
version 10 and earlier of LLVM/Clang. However, C++ still crash in the backend,
with the following example error (when running with `-v`):
```
clang version 11.0.1
Target: armv4-pc-windows-msvc
Thread model: posix
InstalledDir: /usr/bin
"/usr/bin/clang-11" -cc1 -triple thumbv7-pc-windows-msvc19.20.27508 -emit-obj
-mrelax-all -mincremental-linker-compatible -disable-free
-disable-llvm-verifier -discard-value-names -main-file-name hello.cpp
-mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math
-mconstructor-aliases -target-cpu cortex-a9 -target-feature +strict-align
-target-abi aapcs -mfloat-abi hard -fallow-half-arguments-and-returns -v
-resource-dir /usr/lib/clang/11.0.1 -idirafter
/home/falhumai96/Documents/WindowsMSVCCrossSDK/crossccshellscripts/../MSVC/14.20.27508/include
-idirafter
/home/falhumai96/Documents/WindowsMSVCCrossSDK/crossccshellscripts/../WindowsKits/10/Include/10.0.18362.0/ucrt
-idirafter
/home/falhumai96/Documents/WindowsMSVCCrossSDK/crossccshellscripts/../WindowsKits/10/Include/10.0.18362.0/shared
-idirafter
/home/falhumai96/Documents/WindowsMSVCCrossSDK/crossccshellscripts/../WindowsKits/10/Include/10.0.18362.0/um
-idirafter
/home/falhumai96/Documents/WindowsMSVCCrossSDK/crossccshellscripts/../WindowsKits/10/Include/10.0.18362.0/winrt
-D WIN32 -D _WIN32 -D _MT -D _DLL -D _CRT_SECURE_NO_WARNINGS -D
_CRT_NONSTDC_NO_DEPRECATE -U __GNUC__ -U __gnu_linux__ -U __GNUC_MINOR__ -U
__GNUC_PATCHLEVEL__ -U __GNUC_STDC_INLINE__ -internal-isystem
/usr/lib/clang/11.0.1/include -Wno-overlength-strings -Wno-microsoft-enum-value
-Wno-language-extension-token -Wno-unused-command-line-argument
-Wno-msvc-not-found -Wno-pragma-pack -Wno-ignored-attributes
-Wno-ignored-pragma-intrinsic -Wno-expansion-to-defined -Wno-microsoft-anon-tag
-Wno-nonportable-include-path -Wno-void-pointer-to-int-cast
-Wno-int-to-void-pointer-cast -Wno-pointer-type-mismatch
-Wno-asm-operand-widths -Wno-msvc-not-found -fdeprecated-macro
-fdebug-compilation-dir /home/falhumai96 -ferror-limit 19 -mllvm
-arm-restrict-it -fno-use-cxa-atexit -fms-extensions -fms-compatibility
-fms-compatibility-version=19.20.27508 -std=c++14 -fno-threadsafe-statics
-fdelayed-template-parsing -fcxx-exceptions -fexceptions -fcolor-diagnostics
-disable-llvm-verifier --dependent-lib=msvcrt --dependent-lib=ucrt
--dependent-lib=oldnames --dependent-lib=vcruntime -faddrsig -o
/tmp/hello-11dad0.o -x c++ hello.cpp
clang -cc1 version 11.0.1 based upon LLVM 11.0.1 default target
x86_64-pc-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/clang/11.0.1/include
/home/falhumai96/Documents/WindowsMSVCCrossSDK/crossccshellscripts/../MSVC/14.20.27508/include
/home/falhumai96/Documents/WindowsMSVCCrossSDK/crossccshellscripts/../WindowsKits/10/Include/10.0.18362.0/ucrt
/home/falhumai96/Documents/WindowsMSVCCrossSDK/crossccshellscripts/../WindowsKits/10/Include/10.0.18362.0/shared
/home/falhumai96/Documents/WindowsMSVCCrossSDK/crossccshellscripts/../WindowsKits/10/Include/10.0.18362.0/um
/home/falhumai96/Documents/WindowsMSVCCrossSDK/crossccshellscripts/../WindowsKits/10/Include/10.0.18362.0/winrt
End of search list.
fatal error: error in backend: Cannot select: 0x55b833e46688: ch = catchret
0x55b832cd2bf8, BasicBlock:ch< 0x55b833e43930>, BasicBlock:ch< 0x55b833e30a48>
In function:
??$?6U?$char_traits at D@std@@@std@@YAAAV?$basic_ostream at DU?$char_traits at D@std@@@0 at AAV10@PBD at Z
clang-11: error: clang frontend command failed with exit code 70 (use -v to see
invocation)
clang version 11.0.1
Target: armv4-pc-windows-msvc
Thread model: posix
InstalledDir: /usr/bin
clang-11: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-11: note: diagnostic msg: /tmp/hello-7ea7e2.cpp
clang-11: note: diagnostic msg: /tmp/hello-7ea7e2.sh
clang-11: note: diagnostic msg:
********************
```
I have attached the scripts I use for cross compilation (provided that you have
the Windows SDK and the MSVC SDK somewhere in your system, and the
`crossccshellscripts` exists in the same dir as SDKs folder), the sample C++
code `hello.cpp`, and the CPP `hello-7ea7e2.cpp` and SH `hello-7ea7e2.sh` files
generated when the bug happened. I also tried compiling on Windows directly
from the release files in your GitHub, and it still have the same crashes on
ARM target.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210215/32ed6810/attachment.html>
More information about the llvm-bugs
mailing list