From a8304f67291b0182fb64f3afc621615288dd1d31 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Sat, 2 May 2009 20:14:53 +0000 Subject: [PATCH] Driver: Generate an error when trying to pass an LLVM bc input to a non-Darwin linker (sorry Gold + LTO-plugin users). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70641 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticDriverKinds.td | 2 ++ lib/Driver/Tools.cpp | 24 ++++++++++++++++++-- test/Driver/emit-llvm.c | 3 +++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 test/Driver/emit-llvm.c diff --git a/include/clang/Basic/DiagnosticDriverKinds.td b/include/clang/Basic/DiagnosticDriverKinds.td index ced7cea3b8..8a0616ba6d 100644 --- a/include/clang/Basic/DiagnosticDriverKinds.td +++ b/include/clang/Basic/DiagnosticDriverKinds.td @@ -41,6 +41,8 @@ def err_drv_argument_not_allowed_with : Error< "invalid argument '%0' not allowed with '%1'">; def err_drv_invalid_version_number : Error< "invalid version number in '%0'">; +def err_drv_no_linker_llvm_support : Error< + "'%0': unable to pass LLVM bit-code files to linker">; def warn_drv_input_file_unused : Warning< "%0: '%1' input unused when '%2' is present">; diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index c8622284fc..d79f850f07 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -608,6 +608,7 @@ void gcc::Common::ConstructJob(Compilation &C, const JobAction &JA, const InputInfoList &Inputs, const ArgList &Args, const char *LinkingOutput) const { + const Driver &D = getToolChain().getHost().getDriver(); ArgStringList CmdArgs; for (ArgList::const_iterator @@ -660,6 +661,12 @@ void gcc::Common::ConstructJob(Compilation &C, const JobAction &JA, for (InputInfoList::const_iterator it = Inputs.begin(), ie = Inputs.end(); it != ie; ++it) { const InputInfo &II = *it; + + // Don't try to pass LLVM inputs to a generic gcc. + if (II.getType() == types::TY_LLVMBC) + D.Diag(clang::diag::err_drv_no_linker_llvm_support) + << getToolChain().getTripleString().c_str(); + if (types::canTypeBeUserSpecified(II.getType())) { CmdArgs.push_back("-x"); CmdArgs.push_back(types::getTypeName(II.getType())); @@ -1726,8 +1733,8 @@ void freebsd::Link::ConstructJob(Compilation &C, const JobAction &JA, Job &Dest, const InputInfo &Output, const InputInfoList &Inputs, const ArgList &Args, - const char *LinkingOutput) const -{ + const char *LinkingOutput) const { + const Driver &D = getToolChain().getHost().getDriver(); ArgStringList CmdArgs; if (Args.hasArg(options::OPT_static)) { @@ -1778,6 +1785,12 @@ void freebsd::Link::ConstructJob(Compilation &C, const JobAction &JA, for (InputInfoList::const_iterator it = Inputs.begin(), ie = Inputs.end(); it != ie; ++it) { const InputInfo &II = *it; + + // Don't try to pass LLVM inputs to a generic gcc. + if (II.getType() == types::TY_LLVMBC) + D.Diag(clang::diag::err_drv_no_linker_llvm_support) + << getToolChain().getTripleString().c_str(); + if (II.isPipe()) CmdArgs.push_back("-"); else if (II.isFilename()) @@ -1871,6 +1884,7 @@ void dragonfly::Link::ConstructJob(Compilation &C, const JobAction &JA, const InputInfoList &Inputs, const ArgList &Args, const char *LinkingOutput) const { + const Driver &D = getToolChain().getHost().getDriver(); ArgStringList CmdArgs; if (Args.hasArg(options::OPT_static)) { @@ -1920,6 +1934,12 @@ void dragonfly::Link::ConstructJob(Compilation &C, const JobAction &JA, for (InputInfoList::const_iterator it = Inputs.begin(), ie = Inputs.end(); it != ie; ++it) { const InputInfo &II = *it; + + // Don't try to pass LLVM inputs to a generic gcc. + if (II.getType() == types::TY_LLVMBC) + D.Diag(clang::diag::err_drv_no_linker_llvm_support) + << getToolChain().getTripleString().c_str(); + if (II.isPipe()) CmdArgs.push_back("-"); else if (II.isFilename()) diff --git a/test/Driver/emit-llvm.c b/test/Driver/emit-llvm.c new file mode 100644 index 0000000000..a4aabe7256 --- /dev/null +++ b/test/Driver/emit-llvm.c @@ -0,0 +1,3 @@ +// RUN: not clang -ccc-host-triple i386-pc-linux-gnu -emit-llvm -o %t %s 2> %t.log && +// RUN: grep 'unable to pass LLVM bit-code files to linker' %t.log + -- 2.40.0