//
// The LLVM Compiler Infrastructure
//
-// This file was developed by Reid Spencer and is distributed under the
-// University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
#define LLVM_LINKER_H
#include "llvm/System/Path.h"
+#include <memory>
#include <vector>
namespace llvm {
/// In this case the Linker still retains ownership of the Module. If the
/// releaseModule() method is used, the ownership of the Module is transferred
/// to the caller and the Linker object is only suitable for destruction.
-/// The Linker can link Modules from memory, bytecode files, or bytecode
+/// The Linker can link Modules from memory, bitcode files, or bitcode
/// archives. It retains a set of search paths in which to find any libraries
/// presented to it. By default, the linker will generate error and warning
/// messages to std::cerr but this capability can be turned off with the
/// linker.
enum ControlFlags {
Verbose = 1, ///< Print to std::cerr what steps the linker is taking
- QuietWarnings = 2, ///< Don't print errors and warnings to std::cerr.
- QuietErrors = 4, ///< Indicate that this link is for a native executable
+ QuietWarnings = 2, ///< Don't print warnings to std::cerr.
+ QuietErrors = 4 ///< Don't print errors to std::cerr.
};
/// @}
/// @see getLastError
/// @throws nothing
bool LinkInItems (
- const ItemList& Items // Set of libraries/files to link in
+ const ItemList& Items, ///< Set of libraries/files to link in
+ ItemList& NativeItems ///< Output list of native files/libs
);
- /// This function links the bytecode \p Files into the composite module.
+ /// This function links the bitcode \p Files into the composite module.
/// Note that this does not do any linking of unresolved symbols. The \p
/// Files are all completely linked into \p HeadModule regardless of
- /// unresolved symbols. This function just loads each bytecode file and
+ /// unresolved symbols. This function just loads each bitcode file and
/// calls LinkInModule on them.
/// @returns true if an error occurs, false otherwise
/// @see getLastError
const std::vector<sys::Path> & Files ///< Files to link in
);
- /// This function links a single bytecode file, \p File, into the composite
+ /// This function links a single bitcode file, \p File, into the composite
/// module. Note that this does not attempt to resolve symbols. This method
- /// just loads the bytecode file and calls LinkInModule on it. If an error
+ /// just loads the bitcode file and calls LinkInModule on it. If an error
/// occurs, the Linker's error string is set.
/// @returns true if an error occurs, false otherwise
/// @see getLastError
/// @brief Link in a single file.
bool LinkInFile(
- const sys::Path& File ///< File to link in.
+ const sys::Path& File, ///< File to link in.
+ bool &is_native ///< Indicates if the file is native object file
);
/// This function provides a way to selectively link in a set of modules,
/// found in one library, based on the unresolved symbols in the composite
/// module.The \p Library should be the base name of a library, as if given
/// with the -l option of a linker tool. The Linker's LibPaths are searched
- /// for the \P Library and if found, it will be linked in with via the
+ /// for the \p Library and if found, it will be linked in with via the
/// LinkInArchive method. If an error occurs, the Linker's error string is
/// set.
/// @see LinkInArchive
/// @returns true if an error occurs, false otherwise
/// @brief Link one library into the module
bool LinkInLibrary (
- const std::string& Library ///< The library to link in
+ const std::string& Library, ///< The library to link in
+ bool& is_native ///< Indicates if lib a native library
);
- /// This function links one bytecode archive, \p Filename, into the module.
+ /// This function links one bitcode archive, \p Filename, into the module.
/// The archive is searched to resolve outstanding symbols. Any modules in
/// the archive that resolve outstanding symbols will be linked in. The
/// library is searched repeatedly until no more modules that resolve
/// @returns true if an error occurs, otherwise false.
/// @brief Link in one archive.
bool LinkInArchive(
- const sys::Path& Filename ///< Filename of the archive to link
+ const sys::Path& Filename, ///< Filename of the archive to link
+ bool& is_native ///< Indicates if archive is a native archive
);
/// This method links the \p Src module into the Linker's Composite module
/// @returns True if an error occurs, false otherwise.
/// @brief Link in a module.
bool LinkInModule(
- Module* Src ///< Module linked into \p Dest
- ) { return LinkModules(Composite, Src, &Error); }
+ Module* Src, ///< Module linked into \p Dest
+ std::string* ErrorMsg = 0 /// Error/diagnostic string
+ ) {
+ return LinkModules(Composite, Src, ErrorMsg );
+ }
/// This is the heart of the linker. This method will take unconditional
/// control of the \p Src module and link it into the \p Dest module. The
/// @name Implementation
/// @{
private:
- /// Read in and parse the bytecode file named by FN and return the
+ /// Read in and parse the bitcode file named by FN and return the
/// Module it contains (wrapped in an auto_ptr), or 0 if an error occurs.
std::auto_ptr<Module> LoadObject(const sys::Path& FN);