* Made code layout more verbose: no more '{' on a line by itself
* Pruned extra whitespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8748
91177308-0d34-0410-b5e6-
96231b3b80d8
//
//===----------------------------------------------------------------------===//
//
//===----------------------------------------------------------------------===//
-#include "llvm/Transforms/Utils/Linker.h"
#include "llvm/Module.h"
#include "llvm/PassManager.h"
#include "llvm/Bytecode/Reader.h"
#include "llvm/Module.h"
#include "llvm/PassManager.h"
#include "llvm/Bytecode/Reader.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Scalar.h"
-#include "Support/FileUtilities.h"
-#include "Support/SystemUtils.h"
+#include "llvm/Transforms/Utils/Linker.h"
#include "Support/CommandLine.h"
#include "Support/CommandLine.h"
+#include "Support/FileUtilities.h"
#include "Support/Signals.h"
#include "Support/Signals.h"
+#include "Support/SystemUtils.h"
#include "Config/stdlib.h"
#include "Config/stdlib.h"
#include <fstream>
#include <memory>
#include <set>
#include <fstream>
#include <memory>
#include <set>
//
// Function: FileExists ()
//
// Function: FileExists ()
// TRUE - The file exists and is readable.
// FALSE - The file does not exist or is unreadable.
//
// TRUE - The file exists and is readable.
// FALSE - The file does not exist or is unreadable.
//
-static inline bool
-FileExists(const std::string &FN)
-{
+static inline bool FileExists(const std::string &FN) {
return access(FN.c_str(), R_OK | F_OK) != -1;
}
return access(FN.c_str(), R_OK | F_OK) != -1;
}
// TRUE - The file is an archive.
// FALSE - The file is not an archive.
//
// TRUE - The file is an archive.
// FALSE - The file is not an archive.
//
-static inline bool
-IsArchive (const std::string &filename)
+static inline bool IsArchive (const std::string &filename)
{
std::string ArchiveMagic("!<arch>\012");
char buf[1 + ArchiveMagic.size()];
{
std::string ArchiveMagic("!<arch>\012");
char buf[1 + ArchiveMagic.size()];
std::ifstream f(filename.c_str());
f.read(buf, ArchiveMagic.size());
buf[ArchiveMagic.size()] = '\0';
std::ifstream f(filename.c_str());
f.read(buf, ArchiveMagic.size());
buf[ArchiveMagic.size()] = '\0';
static std::string
FindLib (const std::string & Filename, const std::vector<std::string> & Paths)
{
static std::string
FindLib (const std::string & Filename, const std::vector<std::string> & Paths)
{
// Determine if the pathname can be found as it stands.
// Determine if the pathname can be found as it stands.
if (FileExists (Filename))
if (FileExists (Filename))
// If that doesn't work, convert the name into a library name.
// If that doesn't work, convert the name into a library name.
std::string LibName = "lib" + Filename;
std::string LibName = "lib" + Filename;
// Iterate over the directories in Paths to see if we can find the library
// there.
// Iterate over the directories in Paths to see if we can find the library
// there.
- //
- for (unsigned Index = 0; Index != Paths.size(); ++Index)
- {
+ for (unsigned Index = 0; Index != Paths.size(); ++Index) {
std::string Directory = Paths[Index] + "/";
if (FileExists (Directory + LibName + ".bc"))
std::string Directory = Paths[Index] + "/";
if (FileExists (Directory + LibName + ".bc"))
return Directory + LibName + ".bc";
return Directory + LibName + ".bc";
if (FileExists (Directory + LibName + ".so"))
if (FileExists (Directory + LibName + ".so"))
return Directory + LibName + ".so";
return Directory + LibName + ".so";
if (FileExists (Directory + LibName + ".a"))
if (FileExists (Directory + LibName + ".a"))
return Directory + LibName + ".a";
return Directory + LibName + ".a";
// One last hope: Check LLVM_LIB_SEARCH_PATH.
// One last hope: Check LLVM_LIB_SEARCH_PATH.
char *SearchPath = getenv("LLVM_LIB_SEARCH_PATH");
if (SearchPath == NULL)
char *SearchPath = getenv("LLVM_LIB_SEARCH_PATH");
if (SearchPath == NULL)
- {
- return std::string();
- }
LibName = std::string(SearchPath) + "/" + LibName;
if (FileExists (LibName))
LibName = std::string(SearchPath) + "/" + LibName;
if (FileExists (LibName))
// If an error occurs, the pointer is 0.
//
std::auto_ptr<Module>
// If an error occurs, the pointer is 0.
//
std::auto_ptr<Module>
-LoadObject (const std::string & FN, std::string &OutErrorMessage)
-{
+LoadObject (const std::string & FN, std::string &OutErrorMessage) {
std::string ErrorMessage;
Module *Result = ParseBytecodeFile(FN, &ErrorMessage);
if (Result) return std::auto_ptr<Module>(Result);
std::string ErrorMessage;
Module *Result = ParseBytecodeFile(FN, &ErrorMessage);
if (Result) return std::auto_ptr<Module>(Result);
OutErrorMessage = "Bytecode file '" + FN + "' corrupt!";
if (ErrorMessage.size()) OutErrorMessage += ": " + ErrorMessage;
return std::auto_ptr<Module>();
OutErrorMessage = "Bytecode file '" + FN + "' corrupt!";
if (ErrorMessage.size()) OutErrorMessage += ": " + ErrorMessage;
return std::auto_ptr<Module>();
// FALSE - No errors.
//
static bool
// FALSE - No errors.
//
static bool
-LinkInArchive (Module * M,
- const std::string & Filename,
- std::string & ErrorMessage,
+LinkInArchive (Module *M,
+ const std::string &Filename,
+ std::string &ErrorMessage,
//
std::set<std::string> UndefinedSymbols;
GetAllUndefinedSymbols (M, UndefinedSymbols);
//
std::set<std::string> UndefinedSymbols;
GetAllUndefinedSymbols (M, UndefinedSymbols);
- if (UndefinedSymbols.empty())
- {
+ if (UndefinedSymbols.empty()) {
if (Verbose) std::cerr << " No symbols undefined, don't link library!\n";
return false; // No need to link anything in!
}
if (Verbose) std::cerr << " No symbols undefined, don't link library!\n";
return false; // No need to link anything in!
}
if (Verbose) std::cerr << " Loading '" << Filename << "'\n";
std::vector<Module*> Objects;
if (ReadArchiveFile (Filename, Objects, &ErrorMessage))
if (Verbose) std::cerr << " Loading '" << Filename << "'\n";
std::vector<Module*> Objects;
if (ReadArchiveFile (Filename, Objects, &ErrorMessage))
//
// Figure out which symbols are defined by all of the modules in the archive.
//
std::vector<std::set<std::string> > DefinedSymbols;
DefinedSymbols.resize (Objects.size());
//
// Figure out which symbols are defined by all of the modules in the archive.
//
std::vector<std::set<std::string> > DefinedSymbols;
DefinedSymbols.resize (Objects.size());
- for (unsigned i = 0; i != Objects.size(); ++i)
- {
+ for (unsigned i = 0; i != Objects.size(); ++i) {
GetAllDefinedSymbols(Objects[i], DefinedSymbols[i]);
}
// While we are linking in object files, loop.
bool Linked = true;
GetAllDefinedSymbols(Objects[i], DefinedSymbols[i]);
}
// While we are linking in object files, loop.
bool Linked = true;
Linked = false;
for (unsigned i = 0; i != Objects.size(); ++i) {
Linked = false;
for (unsigned i = 0; i != Objects.size(); ++i) {
// FALSE - No errors.
//
static bool
// FALSE - No errors.
//
static bool
-LinkInFile (Module * HeadModule,
- const std::string & Filename,
- std::string & ErrorMessage,
+LinkInFile (Module *HeadModule,
+ const std::string &Filename,
+ std::string &ErrorMessage,
bool Verbose)
{
std::auto_ptr<Module> M(LoadObject(Filename, ErrorMessage));
bool Verbose)
{
std::auto_ptr<Module> M(LoadObject(Filename, ErrorMessage));
- if (M.get() == 0)
- {
- return true;
- }
-
+ if (M.get() == 0) return true;
if (Verbose) std::cerr << "Linking in '" << Filename << "'\n";
if (Verbose) std::cerr << "Linking in '" << Filename << "'\n";
return (LinkModules (HeadModule, M.get(), &ErrorMessage));
}
return (LinkModules (HeadModule, M.get(), &ErrorMessage));
}
// FALSE - No errors.
// TRUE - Some error occurred.
//
// FALSE - No errors.
// TRUE - Some error occurred.
//
-bool
-LinkFiles (const char * progname,
- Module * HeadModule,
- const std::vector<std::string> & Files,
- bool Verbose)
+bool LinkFiles(const char *progname,
+ Module *HeadModule,
+ const std::vector<std::string> &Files,
+ bool Verbose)
{
// String in which to receive error messages.
std::string ErrorMessage;
{
// String in which to receive error messages.
std::string ErrorMessage;
// Get the library search path from the environment
char *SearchPath = getenv("LLVM_LIB_SEARCH_PATH");
// Get the library search path from the environment
char *SearchPath = getenv("LLVM_LIB_SEARCH_PATH");
- for (unsigned i = 1; i < Files.size(); ++i)
- {
- //
+ for (unsigned i = 1; i < Files.size(); ++i) {
// Determine where this file lives.
// Determine where this file lives.
- //
- if (FileExists (Files[i]))
- {
+ if (FileExists (Files[i])) {
- }
- else
- {
- if (SearchPath == NULL)
- {
+ } else {
+ if (SearchPath == NULL) {
std::cerr << "Cannot find " << Files[i];
return true;
}
Pathname = std::string(SearchPath)+"/"+Files[i];
std::cerr << "Cannot find " << Files[i];
return true;
}
Pathname = std::string(SearchPath)+"/"+Files[i];
- if (!FileExists (Pathname))
- {
+ if (!FileExists (Pathname)) {
std::cerr << "Cannot find " << Files[i];
return true;
}
std::cerr << "Cannot find " << Files[i];
return true;
}
// A user may specify an ar archive without -l, perhaps because it
// is not installed as a library. Detect that and link the library.
//
// A user may specify an ar archive without -l, perhaps because it
// is not installed as a library. Detect that and link the library.
//
- if (IsArchive(Pathname))
- {
+ if (IsArchive(Pathname)) {
std::cerr << "Linking archive '" << Files[i] << "'\n";
std::cerr << "Linking archive '" << Files[i] << "'\n";
- if (LinkInArchive (HeadModule, Pathname, ErrorMessage, Verbose))
- {
+ if (LinkInArchive (HeadModule, Pathname, ErrorMessage, Verbose)) {
PrintAndReturn(progname, ErrorMessage,
": Error linking in '" + Files[i] + "'");
return true;
}
PrintAndReturn(progname, ErrorMessage,
": Error linking in '" + Files[i] + "'");
return true;
}
std::cerr << "Linking file '" << Files[i] << "'\n";
std::cerr << "Linking file '" << Files[i] << "'\n";
- if (LinkInFile (HeadModule, Pathname, ErrorMessage, Verbose))
- {
+ if (LinkInFile (HeadModule, Pathname, ErrorMessage, Verbose)) {
PrintAndReturn(progname, ErrorMessage,
": error linking in '" + Files[i] + "'");
return true;
PrintAndReturn(progname, ErrorMessage,
": error linking in '" + Files[i] + "'");
return true;
// FALSE - No error.
// TRUE - Error.
//
// 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)
+bool 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;
{
// String in which to receive error messages.
std::string ErrorMessage;
- for (unsigned i = 1; i < Libraries.size(); ++i)
- {
- //
+ for (unsigned i = 1; i < Libraries.size(); ++i) {
// Determine where this library lives.
// Determine where this library lives.
- //
- std::string Pathname = FindLib (Libraries[i], LibPaths);
- if (Pathname.empty())
- {
- //
+ std::string Pathname = FindLib(Libraries[i], LibPaths);
+ if (Pathname.empty()) {
// If the pathname does not exist, then continue to the next one if
// we're doing a native link and give an error if we're doing a bytecode
// link.
// If the pathname does not exist, then continue to the next one if
// we're doing a native link and give an error if we're doing a bytecode
// link.
- //
- if (Native)
- {
- continue;
- }
- else
- {
- PrintAndReturn (progname, "Cannot find " + Libraries[i]);
+ if (!Native) {
+ PrintAndReturn(progname, "Cannot find " + Libraries[i]);
// A user may specify an ar archive without -l, perhaps because it
// is not installed as a library. Detect that and link the library.
//
// A user may specify an ar archive without -l, perhaps because it
// is not installed as a library. Detect that and link the library.
//
- if (IsArchive(Pathname))
- {
+ if (IsArchive(Pathname)) {
std::cerr << "Linking archive '" << Libraries[i] << "'\n";
std::cerr << "Linking archive '" << Libraries[i] << "'\n";
- if (LinkInArchive (HeadModule, Pathname, ErrorMessage, Verbose))
- {
+ if (LinkInArchive(HeadModule, Pathname, ErrorMessage, Verbose)) {
PrintAndReturn(progname, ErrorMessage,
PrintAndReturn(progname, ErrorMessage,
- ": Error linking in '" + Libraries[i] + "'");
+ ": Error linking in '" + Libraries[i] + "'");
std::cerr << "Linking file '" << Libraries[i] << "'\n";
std::cerr << "Linking file '" << Libraries[i] << "'\n";
- if (LinkInFile (HeadModule, Pathname, ErrorMessage, Verbose))
- {
+ if (LinkInFile(HeadModule, Pathname, ErrorMessage, Verbose)) {
PrintAndReturn(progname, ErrorMessage,
PrintAndReturn(progname, ErrorMessage,
- ": error linking in '" + Libraries[i] + "'");
+ ": error linking in '" + Libraries[i] + "'");
//
//===----------------------------------------------------------------------===//
//
//===----------------------------------------------------------------------===//
-#include "llvm/Transforms/Utils/Linker.h"
#include "llvm/Module.h"
#include "llvm/PassManager.h"
#include "llvm/Bytecode/Reader.h"
#include "llvm/Module.h"
#include "llvm/PassManager.h"
#include "llvm/Bytecode/Reader.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Scalar.h"
-#include "Support/FileUtilities.h"
-#include "Support/SystemUtils.h"
+#include "llvm/Transforms/Utils/Linker.h"
#include "Support/CommandLine.h"
#include "Support/CommandLine.h"
+#include "Support/FileUtilities.h"
#include "Support/Signals.h"
#include "Support/Signals.h"
+#include "Support/SystemUtils.h"
#include "Config/stdlib.h"
#include "Config/stdlib.h"
#include <fstream>
#include <memory>
#include <set>
#include <fstream>
#include <memory>
#include <set>
//
// Function: FileExists ()
//
// Function: FileExists ()
// TRUE - The file exists and is readable.
// FALSE - The file does not exist or is unreadable.
//
// TRUE - The file exists and is readable.
// FALSE - The file does not exist or is unreadable.
//
-static inline bool
-FileExists(const std::string &FN)
-{
+static inline bool FileExists(const std::string &FN) {
return access(FN.c_str(), R_OK | F_OK) != -1;
}
return access(FN.c_str(), R_OK | F_OK) != -1;
}
// TRUE - The file is an archive.
// FALSE - The file is not an archive.
//
// TRUE - The file is an archive.
// FALSE - The file is not an archive.
//
-static inline bool
-IsArchive (const std::string &filename)
+static inline bool IsArchive (const std::string &filename)
{
std::string ArchiveMagic("!<arch>\012");
char buf[1 + ArchiveMagic.size()];
{
std::string ArchiveMagic("!<arch>\012");
char buf[1 + ArchiveMagic.size()];
std::ifstream f(filename.c_str());
f.read(buf, ArchiveMagic.size());
buf[ArchiveMagic.size()] = '\0';
std::ifstream f(filename.c_str());
f.read(buf, ArchiveMagic.size());
buf[ArchiveMagic.size()] = '\0';
static std::string
FindLib (const std::string & Filename, const std::vector<std::string> & Paths)
{
static std::string
FindLib (const std::string & Filename, const std::vector<std::string> & Paths)
{
// Determine if the pathname can be found as it stands.
// Determine if the pathname can be found as it stands.
if (FileExists (Filename))
if (FileExists (Filename))
// If that doesn't work, convert the name into a library name.
// If that doesn't work, convert the name into a library name.
std::string LibName = "lib" + Filename;
std::string LibName = "lib" + Filename;
// Iterate over the directories in Paths to see if we can find the library
// there.
// Iterate over the directories in Paths to see if we can find the library
// there.
- //
- for (unsigned Index = 0; Index != Paths.size(); ++Index)
- {
+ for (unsigned Index = 0; Index != Paths.size(); ++Index) {
std::string Directory = Paths[Index] + "/";
if (FileExists (Directory + LibName + ".bc"))
std::string Directory = Paths[Index] + "/";
if (FileExists (Directory + LibName + ".bc"))
return Directory + LibName + ".bc";
return Directory + LibName + ".bc";
if (FileExists (Directory + LibName + ".so"))
if (FileExists (Directory + LibName + ".so"))
return Directory + LibName + ".so";
return Directory + LibName + ".so";
if (FileExists (Directory + LibName + ".a"))
if (FileExists (Directory + LibName + ".a"))
return Directory + LibName + ".a";
return Directory + LibName + ".a";
// One last hope: Check LLVM_LIB_SEARCH_PATH.
// One last hope: Check LLVM_LIB_SEARCH_PATH.
char *SearchPath = getenv("LLVM_LIB_SEARCH_PATH");
if (SearchPath == NULL)
char *SearchPath = getenv("LLVM_LIB_SEARCH_PATH");
if (SearchPath == NULL)
- {
- return std::string();
- }
LibName = std::string(SearchPath) + "/" + LibName;
if (FileExists (LibName))
LibName = std::string(SearchPath) + "/" + LibName;
if (FileExists (LibName))
// If an error occurs, the pointer is 0.
//
std::auto_ptr<Module>
// If an error occurs, the pointer is 0.
//
std::auto_ptr<Module>
-LoadObject (const std::string & FN, std::string &OutErrorMessage)
-{
+LoadObject (const std::string & FN, std::string &OutErrorMessage) {
std::string ErrorMessage;
Module *Result = ParseBytecodeFile(FN, &ErrorMessage);
if (Result) return std::auto_ptr<Module>(Result);
std::string ErrorMessage;
Module *Result = ParseBytecodeFile(FN, &ErrorMessage);
if (Result) return std::auto_ptr<Module>(Result);
OutErrorMessage = "Bytecode file '" + FN + "' corrupt!";
if (ErrorMessage.size()) OutErrorMessage += ": " + ErrorMessage;
return std::auto_ptr<Module>();
OutErrorMessage = "Bytecode file '" + FN + "' corrupt!";
if (ErrorMessage.size()) OutErrorMessage += ": " + ErrorMessage;
return std::auto_ptr<Module>();
// FALSE - No errors.
//
static bool
// FALSE - No errors.
//
static bool
-LinkInArchive (Module * M,
- const std::string & Filename,
- std::string & ErrorMessage,
+LinkInArchive (Module *M,
+ const std::string &Filename,
+ std::string &ErrorMessage,
//
std::set<std::string> UndefinedSymbols;
GetAllUndefinedSymbols (M, UndefinedSymbols);
//
std::set<std::string> UndefinedSymbols;
GetAllUndefinedSymbols (M, UndefinedSymbols);
- if (UndefinedSymbols.empty())
- {
+ if (UndefinedSymbols.empty()) {
if (Verbose) std::cerr << " No symbols undefined, don't link library!\n";
return false; // No need to link anything in!
}
if (Verbose) std::cerr << " No symbols undefined, don't link library!\n";
return false; // No need to link anything in!
}
if (Verbose) std::cerr << " Loading '" << Filename << "'\n";
std::vector<Module*> Objects;
if (ReadArchiveFile (Filename, Objects, &ErrorMessage))
if (Verbose) std::cerr << " Loading '" << Filename << "'\n";
std::vector<Module*> Objects;
if (ReadArchiveFile (Filename, Objects, &ErrorMessage))
//
// Figure out which symbols are defined by all of the modules in the archive.
//
std::vector<std::set<std::string> > DefinedSymbols;
DefinedSymbols.resize (Objects.size());
//
// Figure out which symbols are defined by all of the modules in the archive.
//
std::vector<std::set<std::string> > DefinedSymbols;
DefinedSymbols.resize (Objects.size());
- for (unsigned i = 0; i != Objects.size(); ++i)
- {
+ for (unsigned i = 0; i != Objects.size(); ++i) {
GetAllDefinedSymbols(Objects[i], DefinedSymbols[i]);
}
// While we are linking in object files, loop.
bool Linked = true;
GetAllDefinedSymbols(Objects[i], DefinedSymbols[i]);
}
// While we are linking in object files, loop.
bool Linked = true;
Linked = false;
for (unsigned i = 0; i != Objects.size(); ++i) {
Linked = false;
for (unsigned i = 0; i != Objects.size(); ++i) {
// FALSE - No errors.
//
static bool
// FALSE - No errors.
//
static bool
-LinkInFile (Module * HeadModule,
- const std::string & Filename,
- std::string & ErrorMessage,
+LinkInFile (Module *HeadModule,
+ const std::string &Filename,
+ std::string &ErrorMessage,
bool Verbose)
{
std::auto_ptr<Module> M(LoadObject(Filename, ErrorMessage));
bool Verbose)
{
std::auto_ptr<Module> M(LoadObject(Filename, ErrorMessage));
- if (M.get() == 0)
- {
- return true;
- }
-
+ if (M.get() == 0) return true;
if (Verbose) std::cerr << "Linking in '" << Filename << "'\n";
if (Verbose) std::cerr << "Linking in '" << Filename << "'\n";
return (LinkModules (HeadModule, M.get(), &ErrorMessage));
}
return (LinkModules (HeadModule, M.get(), &ErrorMessage));
}
// FALSE - No errors.
// TRUE - Some error occurred.
//
// FALSE - No errors.
// TRUE - Some error occurred.
//
-bool
-LinkFiles (const char * progname,
- Module * HeadModule,
- const std::vector<std::string> & Files,
- bool Verbose)
+bool LinkFiles(const char *progname,
+ Module *HeadModule,
+ const std::vector<std::string> &Files,
+ bool Verbose)
{
// String in which to receive error messages.
std::string ErrorMessage;
{
// String in which to receive error messages.
std::string ErrorMessage;
// Get the library search path from the environment
char *SearchPath = getenv("LLVM_LIB_SEARCH_PATH");
// Get the library search path from the environment
char *SearchPath = getenv("LLVM_LIB_SEARCH_PATH");
- for (unsigned i = 1; i < Files.size(); ++i)
- {
- //
+ for (unsigned i = 1; i < Files.size(); ++i) {
// Determine where this file lives.
// Determine where this file lives.
- //
- if (FileExists (Files[i]))
- {
+ if (FileExists (Files[i])) {
- }
- else
- {
- if (SearchPath == NULL)
- {
+ } else {
+ if (SearchPath == NULL) {
std::cerr << "Cannot find " << Files[i];
return true;
}
Pathname = std::string(SearchPath)+"/"+Files[i];
std::cerr << "Cannot find " << Files[i];
return true;
}
Pathname = std::string(SearchPath)+"/"+Files[i];
- if (!FileExists (Pathname))
- {
+ if (!FileExists (Pathname)) {
std::cerr << "Cannot find " << Files[i];
return true;
}
std::cerr << "Cannot find " << Files[i];
return true;
}
// A user may specify an ar archive without -l, perhaps because it
// is not installed as a library. Detect that and link the library.
//
// A user may specify an ar archive without -l, perhaps because it
// is not installed as a library. Detect that and link the library.
//
- if (IsArchive(Pathname))
- {
+ if (IsArchive(Pathname)) {
std::cerr << "Linking archive '" << Files[i] << "'\n";
std::cerr << "Linking archive '" << Files[i] << "'\n";
- if (LinkInArchive (HeadModule, Pathname, ErrorMessage, Verbose))
- {
+ if (LinkInArchive (HeadModule, Pathname, ErrorMessage, Verbose)) {
PrintAndReturn(progname, ErrorMessage,
": Error linking in '" + Files[i] + "'");
return true;
}
PrintAndReturn(progname, ErrorMessage,
": Error linking in '" + Files[i] + "'");
return true;
}
std::cerr << "Linking file '" << Files[i] << "'\n";
std::cerr << "Linking file '" << Files[i] << "'\n";
- if (LinkInFile (HeadModule, Pathname, ErrorMessage, Verbose))
- {
+ if (LinkInFile (HeadModule, Pathname, ErrorMessage, Verbose)) {
PrintAndReturn(progname, ErrorMessage,
": error linking in '" + Files[i] + "'");
return true;
PrintAndReturn(progname, ErrorMessage,
": error linking in '" + Files[i] + "'");
return true;
// FALSE - No error.
// TRUE - Error.
//
// 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)
+bool 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;
{
// String in which to receive error messages.
std::string ErrorMessage;
- for (unsigned i = 1; i < Libraries.size(); ++i)
- {
- //
+ for (unsigned i = 1; i < Libraries.size(); ++i) {
// Determine where this library lives.
// Determine where this library lives.
- //
- std::string Pathname = FindLib (Libraries[i], LibPaths);
- if (Pathname.empty())
- {
- //
+ std::string Pathname = FindLib(Libraries[i], LibPaths);
+ if (Pathname.empty()) {
// If the pathname does not exist, then continue to the next one if
// we're doing a native link and give an error if we're doing a bytecode
// link.
// If the pathname does not exist, then continue to the next one if
// we're doing a native link and give an error if we're doing a bytecode
// link.
- //
- if (Native)
- {
- continue;
- }
- else
- {
- PrintAndReturn (progname, "Cannot find " + Libraries[i]);
+ if (!Native) {
+ PrintAndReturn(progname, "Cannot find " + Libraries[i]);
// A user may specify an ar archive without -l, perhaps because it
// is not installed as a library. Detect that and link the library.
//
// A user may specify an ar archive without -l, perhaps because it
// is not installed as a library. Detect that and link the library.
//
- if (IsArchive(Pathname))
- {
+ if (IsArchive(Pathname)) {
std::cerr << "Linking archive '" << Libraries[i] << "'\n";
std::cerr << "Linking archive '" << Libraries[i] << "'\n";
- if (LinkInArchive (HeadModule, Pathname, ErrorMessage, Verbose))
- {
+ if (LinkInArchive(HeadModule, Pathname, ErrorMessage, Verbose)) {
PrintAndReturn(progname, ErrorMessage,
PrintAndReturn(progname, ErrorMessage,
- ": Error linking in '" + Libraries[i] + "'");
+ ": Error linking in '" + Libraries[i] + "'");
std::cerr << "Linking file '" << Libraries[i] << "'\n";
std::cerr << "Linking file '" << Libraries[i] << "'\n";
- if (LinkInFile (HeadModule, Pathname, ErrorMessage, Verbose))
- {
+ if (LinkInFile(HeadModule, Pathname, ErrorMessage, Verbose)) {
PrintAndReturn(progname, ErrorMessage,
PrintAndReturn(progname, ErrorMessage,
- ": error linking in '" + Libraries[i] + "'");
+ ": error linking in '" + Libraries[i] + "'");