projects
/
oota-llvm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
include/llvm/Config/config.h.cmake: Unbreak CMake build to tweak LLVM_HAS_ATOMICS.
[oota-llvm.git]
/
include
/
llvm
/
Linker.h
diff --git
a/include/llvm/Linker.h
b/include/llvm/Linker.h
index 60227a724d837746518b95e48de954c2f29c526b..b402a6090e2cf387743036c01f7c41689ecda8f7 100644
(file)
--- a/
include/llvm/Linker.h
+++ b/
include/llvm/Linker.h
@@
-2,8
+2,8
@@
//
// The LLVM Compiler Infrastructure
//
//
// The LLVM Compiler Infrastructure
//
-// This file
was developed by Reid Spencer and is distributed under th
e
-//
University of Illinois Open Source
License. See LICENSE.TXT for details.
+// This file
is distributed under the University of Illinois Open Sourc
e
+// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
//
//===----------------------------------------------------------------------===//
//
@@
-14,12
+14,15
@@
#ifndef LLVM_LINKER_H
#define LLVM_LINKER_H
#ifndef LLVM_LINKER_H
#define LLVM_LINKER_H
-#include
"llvm/System/Path.h"
+#include
<memory>
#include <vector>
#include <vector>
+#include "llvm/ADT/StringRef.h"
namespace llvm {
namespace llvm {
+ namespace sys { class Path; }
class Module;
class Module;
+class LLVMContext;
/// This class provides the core functionality of linking in LLVM. It retains a
/// Module object which is the composite of the modules and libraries linked
/// This class provides the core functionality of linking in LLVM. It retains a
/// Module object which is the composite of the modules and libraries linked
@@
-27,10
+30,10
@@
class Module;
/// 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.
/// 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, b
ytecode files, or byte
code
+/// The Linker can link Modules from memory, b
itcode files, or bit
code
/// 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
/// 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
::c
err but this capability can be turned off with the
+/// messages to stderr but this capability can be turned off with the
/// QuietWarnings and QuietErrors flags. It can also be instructed to verbosely
/// print out the linking actions it is taking with the Verbose flag.
/// @brief The LLVM Linker.
/// QuietWarnings and QuietErrors flags. It can also be instructed to verbosely
/// print out the linking actions it is taking with the Verbose flag.
/// @brief The LLVM Linker.
@@
-50,9
+53,9
@@
class Linker {
/// This enumeration is used to control various optional features of the
/// linker.
enum ControlFlags {
/// This enumeration is used to control various optional features of the
/// linker.
enum ControlFlags {
- Verbose = 1, ///< Print to std
::c
err what steps the linker is taking
- QuietWarnings = 2, ///< Don't print
errors and warnings to std::c
err.
- QuietErrors = 4
, ///< Indicate that this link is for a native executable
+ Verbose = 1, ///< Print to stderr what steps the linker is taking
+ QuietWarnings = 2, ///< Don't print
warnings to std
err.
+ QuietErrors = 4
///< Don't print errors to stderr.
};
/// @}
};
/// @}
@@
-62,12
+65,16
@@
class Linker {
/// Construct the Linker with an empty module which will be given the
/// name \p progname. \p progname will also be used for error messages.
/// @brief Construct with empty module
/// Construct the Linker with an empty module which will be given the
/// name \p progname. \p progname will also be used for error messages.
/// @brief Construct with empty module
- Linker(const std::string& progname, unsigned Flags = 0 );
+ Linker(StringRef progname, ///< name of tool running linker
+ StringRef modulename, ///< name of linker's end-result module
+ LLVMContext &C, ///< Context for global info
+ unsigned Flags = 0 ///< ControlFlags (one or more |'d together)
+ );
/// Construct the Linker with a previously defined module, \p aModule. Use
/// \p progname for the name of the program in error messages.
/// @brief Construct with existing module
/// Construct the Linker with a previously defined module, \p aModule. Use
/// \p progname for the name of the program in error messages.
/// @brief Construct with existing module
- Linker(
const std::string&
progname, Module* aModule, unsigned Flags = 0);
+ Linker(
StringRef
progname, Module* aModule, unsigned Flags = 0);
/// Destruct the Linker.
/// @brief Destructor
/// Destruct the Linker.
/// @brief Destructor
@@
-107,9
+114,9
@@
class Linker {
/// true, indicating an error occurred. At most one error is retained so
/// this function always returns the last error that occurred. Note that if
/// the Quiet control flag is not set, the error string will have already
/// true, indicating an error occurred. At most one error is retained so
/// this function always returns the last error that occurred. Note that if
/// the Quiet control flag is not set, the error string will have already
- /// been printed to std
::c
err.
+ /// been printed to stderr.
/// @brief Get the text of the last error that occurred.
/// @brief Get the text of the last error that occurred.
- const std::string
&
getLastError() const { return Error; }
+ const std::string
&
getLastError() const { return Error; }
/// @}
/// @name Mutators
/// @}
/// @name Mutators
@@
-151,15
+158,15
@@
class Linker {
/// @returns true if an error occurred, false otherwise
/// @see LinkItemKind
/// @see getLastError
/// @returns true if an error occurred, false otherwise
/// @see LinkItemKind
/// @see getLastError
- /// @throws nothing
bool LinkInItems (
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 b
yte
code \p Files into the composite module.
+ /// This function links the b
it
code \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
/// 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 b
yte
code file and
+ /// unresolved symbols. This function just loads each b
it
code file and
/// calls LinkInModule on them.
/// @returns true if an error occurs, false otherwise
/// @see getLastError
/// calls LinkInModule on them.
/// @returns true if an error occurs, false otherwise
/// @see getLastError
@@
-168,15
+175,16
@@
class Linker {
const std::vector<sys::Path> & Files ///< Files to link in
);
const std::vector<sys::Path> & Files ///< Files to link in
);
- /// This function links a single b
yte
code file, \p File, into the composite
+ /// This function links a single b
it
code file, \p File, into the composite
/// module. Note that this does not attempt to resolve symbols. This method
/// module. Note that this does not attempt to resolve symbols. This method
- /// just loads the b
yte
code file and calls LinkInModule on it. If an error
+ /// just loads the b
it
code 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(
/// 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,
);
/// This function provides a way to selectively link in a set of modules,
@@
-197,7
+205,7
@@
class Linker {
/// 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
/// 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
/// LinkInArchive method. If an error occurs, the Linker's error string is
/// set.
/// @see LinkInArchive
@@
-205,15
+213,16
@@
class Linker {
/// @returns true if an error occurs, false otherwise
/// @brief Link one library into the module
bool LinkInLibrary (
/// @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
+ StringRef Library, ///< The library to link in
+ bool& is_native ///< Indicates if lib a native library
);
);
- /// This function links one b
yte
code archive, \p Filename, into the module.
+ /// This function links one b
it
code 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
/// symbols can be found. If an error occurs, the error string is set.
/// 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
/// symbols can be found. If an error occurs, the error string is set.
- /// To speed up this function, ensure the
the
archive has been processed
+ /// To speed up this function, ensure the archive has been processed
/// llvm-ranlib or the S option was given to llvm-ar when the archive was
/// created. These tools add a symbol table to the archive which makes the
/// search for undefined symbols much faster.
/// llvm-ranlib or the S option was given to llvm-ar when the archive was
/// created. These tools add a symbol table to the archive which makes the
/// search for undefined symbols much faster.
@@
-221,7
+230,8
@@
class Linker {
/// @returns true if an error occurs, otherwise false.
/// @brief Link in one archive.
bool LinkInArchive(
/// @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
);
/// This method links the \p Src module into the Linker's Composite module
@@
-232,8
+242,11
@@
class Linker {
/// @returns True if an error occurs, false otherwise.
/// @brief Link in a module.
bool LinkInModule(
/// @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
/// 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
@@
-253,24
+266,25
@@
class Linker {
/// will be empty (i.e. sys::Path::isEmpty() will return true).
/// @returns A sys::Path to the found library
/// @brief Find a library from its short name.
/// will be empty (i.e. sys::Path::isEmpty() will return true).
/// @returns A sys::Path to the found library
/// @brief Find a library from its short name.
- sys::Path FindLib(
const std::string &
Filename);
+ sys::Path FindLib(
StringRef
Filename);
/// @}
/// @name Implementation
/// @{
private:
/// @}
/// @name Implementation
/// @{
private:
- /// Read in and parse the b
yte
code file named by FN and return the
+ /// Read in and parse the b
it
code 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);
/// Module it contains (wrapped in an auto_ptr), or 0 if an error occurs.
std::auto_ptr<Module> LoadObject(const sys::Path& FN);
- bool warning(
const std::string&
message);
- bool error(
const std::string&
message);
- void verbose(
const std::string&
message);
+ bool warning(
StringRef
message);
+ bool error(
StringRef
message);
+ void verbose(
StringRef
message);
/// @}
/// @name Data
/// @{
private:
/// @}
/// @name Data
/// @{
private:
+ LLVMContext& Context; ///< The context for global information
Module* Composite; ///< The composite module linked together
std::vector<sys::Path> LibPaths; ///< The library search paths
unsigned Flags; ///< Flags to control optional behavior.
Module* Composite; ///< The composite module linked together
std::vector<sys::Path> LibPaths; ///< The library search paths
unsigned Flags; ///< Flags to control optional behavior.