<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Clang -cc1 crashes if an unknown -target-cpu is passed for -triple arm"
href="https://llvm.org/bugs/show_bug.cgi?id=26839">26839</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Clang -cc1 crashes if an unknown -target-cpu is passed for -triple arm
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.8
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>david.cab+llvmbug@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Steps to Reproduce:
touch main.c
clang -cc1 -triple arm -target-cpu xyz main.c -emit-obj
Actual Results:
The application crashed.
$ ./clang+llvm-3.8.0-rc3-x86_64-linux-gnu-ubuntu-15.10/bin/clang -cc1 -triple
arm -target-cpu xyz main.c -emit-obj
#0 0x0000000001594268 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/score/clang+llvm-3.8.0-rc3-x86_64-linux-gnu-ubuntu-15.10/bin/clang-3.8+0x1594268)
#1 0x00000000015948e7 SignalHandler(int)
(/home/score/clang+llvm-3.8.0-rc3-x86_64-linux-gnu-ubuntu-15.10/bin/clang-3.8+0x15948e7)
#2 0x00007f8c41763d10 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10d10)
#3 0x00007f8c40a3c8f0
/build/glibc-ryFjv0/glibc-2.21/string/../sysdeps/x86_64/multiarch/memcmp-sse4.S:878:0
#4 0x000000000156bff2 llvm::ARM::getCanonicalArchName(llvm::StringRef)
(/home/score/clang+llvm-3.8.0-rc3-x86_64-linux-gnu-ubuntu-15.10/bin/clang-3.8+0x156bff2)
#5 0x000000000156cc76 llvm::ARM::parseArchProfile(llvm::StringRef)
(/home/score/clang+llvm-3.8.0-rc3-x86_64-linux-gnu-ubuntu-15.10/bin/clang-3.8+0x156cc76)
#6 0x0000000002965a77 (anonymous
namespace)::ARMTargetInfo::setArchInfo(unsigned int)
(/home/score/clang+llvm-3.8.0-rc3-x86_64-linux-gnu-ubuntu-15.10/bin/clang-3.8+0x2965a77)
#7 0x0000000002962973 (anonymous
namespace)::ARMTargetInfo::setCPU(std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&)
(/home/score/clang+llvm-3.8.0-rc3-x86_64-linux-gnu-ubuntu-15.10/bin/clang-3.8+0x2962973)
#8 0x0000000002957183
clang::TargetInfo::CreateTargetInfo(clang::DiagnosticsEngine&,
std::shared_ptr<clang::TargetOptions> const&)
(/home/score/clang+llvm-3.8.0-rc3-x86_64-linux-gnu-ubuntu-15.10/bin/clang-3.8+0x2957183)
#9 0x000000000193056d
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/score/clang+llvm-3.8.0-rc3-x86_64-linux-gnu-ubuntu-15.10/bin/clang-3.8+0x193056d)
#10 0x00000000019d9b0f
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/score/clang+llvm-3.8.0-rc3-x86_64-linux-gnu-ubuntu-15.10/bin/clang-3.8+0x19d9b0f)
#11 0x0000000000742b9d cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
(/home/score/clang+llvm-3.8.0-rc3-x86_64-linux-gnu-ubuntu-15.10/bin/clang-3.8+0x742b9d)
#12 0x0000000000741ed1 main
(/home/score/clang+llvm-3.8.0-rc3-x86_64-linux-gnu-ubuntu-15.10/bin/clang-3.8+0x741ed1)
#13 0x00007f8c408eea40 __libc_start_main
/build/glibc-ryFjv0/glibc-2.21/csu/libc-start.c:323:0
#14 0x000000000073eeb9 _start
(/home/score/clang+llvm-3.8.0-rc3-x86_64-linux-gnu-ubuntu-15.10/bin/clang-3.8+0x73eeb9)
Stack dump:
0. Program arguments:
./clang+llvm-3.8.0-rc3-x86_64-linux-gnu-ubuntu-15.10/bin/clang -cc1 -triple arm
-target-cpu xyz main.c -emit-obj
Segmentation fault (core dumped)
Expected results:
No crash and print an error message.
Build Date & Platform:
Clang 3.8.0-rc3 prebuilt binaries for Ubuntu 15.10 available at llvm.org.
Additional Information:
This is a regression with respect to clang 3.7.1.
Using clang 3.7.1 results in normal behaviour.
$ ./clang+llvm-3.7.1-x86_64-linux-gnu-ubuntu-15.10/bin/clang -cc1 -triple arm
-target-cpu xyz main.c -emit-obj
'xyz' is not a recognized processor for this target (ignoring processor)
[repeats 13 times]
$ ./clang+llvm-3.7.1-x86_64-linux-gnu-ubuntu-15.10/bin/clang -cc1 -target-cpu
xyz main.c -emit-obj
error: unknown target CPU 'xyz'
With clang 3.8.0-rc3 the results are expected for x86-64 but a crash for
-triple arm.
$ ./clang+llvm-3.8.0-rc3-x86_64-linux-gnu-ubuntu-15.10/bin/clang -cc1
-target-cpu xyz main.c -emit-obj
error: unknown target CPU 'xyz'
$ ./clang+llvm-3.8.0-rc3-x86_64-linux-gnu-ubuntu-15.10/bin/clang -cc1 -triple
arm -target-cpu xyz main.c -emit-obj
#0 0x0000000001594268 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/score/clang+llvm-3.8.0-rc3-x86_64-linux-gnu-ubuntu-15.10/bin/clang-3.8+0x1594268)
[...]</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>