[llvm-bugs] [Bug 33533] New: clang errors out if .h file is specified as an input along with .c/.cpp
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Jun 20 14:39:59 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=33533
Bug ID: 33533
Summary: clang errors out if .h file is specified as an input
along with .c/.cpp
Product: clang
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Driver
Assignee: unassignedclangbugs at nondot.org
Reporter: manojgupta at google.com
CC: george.burgess.iv at gmail.com, llozano at chromium.org,
llvm-bugs at lists.llvm.org
$ 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;
}
}
--
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/20170620/1acc4892/attachment.html>
More information about the llvm-bugs
mailing list