<html>
<head>
<base href="https://bugs.llvm.org/">
</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 errors out if .h file is specified as an input along with .c/.cpp"
href="https://bugs.llvm.org/show_bug.cgi?id=33533">33533</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang errors out if .h file is specified as an input along with .c/.cpp
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Driver
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>manojgupta@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>george.burgess.iv@gmail.com, llozano@chromium.org, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>$ cat test.c
int foo()
{
return 0;
}
$ cat test.h
#include <stdlib.h>
$ clang -fpic -std=gnu99 -Wall -Werror -pedantic -Wall -g -o libtemp.so -shared
-Wl,-soname,libtemp.so test.c test.h
clang-5.0: error: cannot specify -o when generating multiple output files
This works with GCC however.
$ gcc -fpic -std=gnu99 -Wall -Werror -pedantic -Wall -g -o libtemp.so -shared
-Wl,-soname,libtemp.so test.c test.h => Produces libtemp.so
Interestingly, clang does understand that this is a header file and tries to
compiler it to a pch file.
"/usr/bin/clang-5.0" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-pch"
"-disable-free" "-disable-llvm-verifier" "-discard-value-names"
"-main-file-name" "d.h" "-mrelocation-model" "pic" "-pic-level" "1"
"-mthread-model" "posix" "-mdisable-fp-elim" "-fmath-errno" "-masm-verbose"
"-mconstructor-aliases" "-munwind-tables" "-fuse-init-array" "-target-cpu"
"x86-64" "-dwarf-column-info" "-debug-info-kind=limited" "-dwarf-version=4"
"-debugger-tuning=gdb" "-resource-dir" "/usr/lib64/clang/5.0.0"
"-internal-isystem" "/usr/local/include" "-internal-isystem"
"/usr/lib64/clang/5.0.0/include" "-internal-externc-isystem" "/include"
"-internal-externc-isystem" "/usr/include" "-Wall" "-Werror" "-Wall"
"-pedantic" "-std=gnu99" "-fdebug-compilation-dir" "/tmp" "-ferror-limit" "19"
"-fmessage-length" "140" "-fobjc-runtime=gcc" "-fdiagnostics-show-option"
"-fcolor-diagnostics" "-o" "libtemp.so" "-x" "c-header" "d.h"
So this is most likely an unhandled case in the lib/Driver/Driver.cpp
void Driver::BuildJobs(Compilation &C) const {
// It is an error to provide a -o option if we are making multiple output
// files.
if (FinalOutput) {
unsigned NumOutputs = 0;
for (const Action *A : C.getActions())
if (A->getType() != types::TY_Nothing) // => Should handle header
compilations here .
++NumOutputs;
if (NumOutputs > 1) {
Diag(clang::diag::err_drv_output_argument_with_multiple_files);
FinalOutput = nullptr;
}
}</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>