summaryrefslogtreecommitdiff
path: root/tools/gccld
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-11-28 07:44:09 +0000
committerChris Lattner <sabre@nondot.org>2003-11-28 07:44:09 +0000
commit6cc8ca92291c8b18d8aa88d43c50dd25d0740ca4 (patch)
tree13bdcf8678e866c935c496d3d81bfc7281d04f52 /tools/gccld
parentd423fb5cbfdf9268899039ee49a0b3e09f661ca9 (diff)
downloadllvm-6cc8ca92291c8b18d8aa88d43c50dd25d0740ca4.tar.gz
llvm-6cc8ca92291c8b18d8aa88d43c50dd25d0740ca4.tar.bz2
llvm-6cc8ca92291c8b18d8aa88d43c50dd25d0740ca4.tar.xz
* The return value of LinkLibraries is ignored, so remove it.
* Finegrainify namespacification of Linker.cpp * If linking a library in fails, do not STOP LINKING IN LIBRARIES AND CONTINUE ANYWAY! Instead, just output the warning, and keep going. :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10249 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/gccld')
-rw-r--r--tools/gccld/Linker.cpp63
-rw-r--r--tools/gccld/gccld.h11
2 files changed, 31 insertions, 43 deletions
diff --git a/tools/gccld/Linker.cpp b/tools/gccld/Linker.cpp
index a009cf59d6..c230206d7e 100644
--- a/tools/gccld/Linker.cpp
+++ b/tools/gccld/Linker.cpp
@@ -29,8 +29,7 @@
#include <fstream>
#include <memory>
#include <set>
-
-namespace llvm {
+using namespace llvm;
/// FindLib - Try to convert Filename into the name of a file that we can open,
/// if it does not already name a file we can open, by first trying to open
@@ -39,9 +38,9 @@ namespace llvm {
/// named by the value of the environment variable LLVM_LIB_SEARCH_PATH. Returns
/// an empty string if no matching file can be found.
///
-std::string FindLib(const std::string &Filename,
- const std::vector<std::string> &Paths,
- bool SharedObjectOnly) {
+std::string llvm::FindLib(const std::string &Filename,
+ const std::vector<std::string> &Paths,
+ bool SharedObjectOnly) {
// Determine if the pathname can be found as it stands.
if (FileOpenable(Filename))
return Filename;
@@ -79,7 +78,8 @@ std::string FindLib(const std::string &Filename,
/// GetAllDefinedSymbols - Modifies its parameter DefinedSymbols to contain the
/// name of each externally-visible symbol defined in M.
///
-void GetAllDefinedSymbols(Module *M, std::set<std::string> &DefinedSymbols) {
+void llvm::GetAllDefinedSymbols(Module *M,
+ std::set<std::string> &DefinedSymbols) {
for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
if (I->hasName() && !I->isExternal() && !I->hasInternalLinkage())
DefinedSymbols.insert(I->getName());
@@ -101,7 +101,8 @@ void GetAllDefinedSymbols(Module *M, std::set<std::string> &DefinedSymbols) {
/// undefined symbols.
///
void
-GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) {
+llvm::GetAllUndefinedSymbols(Module *M,
+ std::set<std::string> &UndefinedSymbols) {
std::set<std::string> DefinedSymbols;
UndefinedSymbols.clear(); // Start out empty
@@ -134,8 +135,8 @@ GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) {
/// module it contains (wrapped in an auto_ptr), or 0 and set ErrorMessage if an
/// error occurs.
///
-std::auto_ptr<Module> LoadObject(const std::string &FN,
- std::string &ErrorMessage) {
+std::auto_ptr<Module> llvm::LoadObject(const std::string &FN,
+ std::string &ErrorMessage) {
std::string ParserErrorMessage;
Module *Result = ParseBytecodeFile(FN, &ParserErrorMessage);
if (Result) return std::auto_ptr<Module>(Result);
@@ -280,11 +281,8 @@ static bool LinkInFile(Module *HeadModule,
/// FALSE - No errors.
/// TRUE - Some error occurred.
///
-bool LinkFiles(const char *progname,
- Module *HeadModule,
- const std::vector<std::string> &Files,
- bool Verbose)
-{
+bool llvm::LinkFiles(const char *progname, Module *HeadModule,
+ const std::vector<std::string> &Files, bool Verbose) {
// String in which to receive error messages.
std::string ErrorMessage;
@@ -359,13 +357,10 @@ bool LinkFiles(const char *progname,
/// FALSE - No error.
/// TRUE - Error.
///
-bool LinkLibraries(const char *progname,
- Module *HeadModule,
- const std::vector<std::string> &Libraries,
- const std::vector<std::string> &LibPaths,
- bool Verbose,
- bool Native)
-{
+void llvm::LinkLibraries(const char *progname, Module *HeadModule,
+ const std::vector<std::string> &Libraries,
+ const std::vector<std::string> &LibPaths,
+ bool Verbose, bool Native) {
// String in which to receive error messages.
std::string ErrorMessage;
@@ -377,9 +372,9 @@ bool LinkLibraries(const char *progname,
// we're doing a native link and give an error if we're doing a bytecode
// link.
if (!Native) {
- PrintAndReturn(progname, "Cannot find library -l" + Libraries[i]
- + "\n");
- return true;
+ std::cerr << progname << ": WARNING: Cannot find library -l"
+ << Libraries[i] << "\n";
+ continue;
}
}
@@ -391,10 +386,10 @@ bool LinkLibraries(const char *progname,
<< Libraries[i] << ")\n";
if (LinkInArchive(HeadModule, Pathname, ErrorMessage, Verbose)) {
- PrintAndReturn(progname, ErrorMessage,
- ": Error linking in archive '" + Pathname
- + "' (-l" + Libraries[i] + ")");
- return true;
+ std::cerr << progname << ": " << ErrorMessage
+ << ": Error linking in archive '" << Pathname << "' (-l"
+ << Libraries[i] << ")\n";
+ exit(1);
}
} else if (IsBytecode(Pathname)) {
if (Verbose)
@@ -402,15 +397,11 @@ bool LinkLibraries(const char *progname,
<< "' (-l" << Libraries[i] << ")\n";
if (LinkInFile(HeadModule, Pathname, ErrorMessage, Verbose)) {
- PrintAndReturn(progname, ErrorMessage,
- ": error linking in bytecode file '" + Pathname
- + "' (-l" + Libraries[i] + ")");
- return true;
+ std::cerr << progname << ": " << ErrorMessage
+ << ": error linking in bytecode file '" << Pathname << "' (-l"
+ << Libraries[i] << ")\n";
+ exit(1);
}
}
}
-
- return false;
}
-
-} // End llvm namespace
diff --git a/tools/gccld/gccld.h b/tools/gccld/gccld.h
index a2d2eb8d6a..e5b865e3a4 100644
--- a/tools/gccld/gccld.h
+++ b/tools/gccld/gccld.h
@@ -62,13 +62,10 @@ std::string FindLib(const std::string &Filename,
const std::vector<std::string> &Paths,
bool SharedObjectOnly = false);
-bool
-LinkLibraries (const char * progname,
- Module * HeadModule,
- const std::vector<std::string> & Libraries,
- const std::vector<std::string> & LibPaths,
- bool Verbose,
- bool Native);
+void LinkLibraries (const char * progname, Module* HeadModule,
+ const std::vector<std::string> & Libraries,
+ const std::vector<std::string> & LibPaths,
+ bool Verbose, bool Native);
bool
LinkFiles (const char * progname,
Module * HeadModule,