Skip to content

Commit a3df351

Browse files
author
Reid Spencer
committed
Fix PR139: \
Add support for ordered linking with the LinkItems function llvm-svn: 18546
1 parent e96b620 commit a3df351

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

llvm/include/llvm/Linker.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#ifndef LLVM_LINKER_H
1515
#define LLVM_LINKER_H
1616

17+
#include "llvm/Support/CommandLine.h"
1718
#include <string>
1819
#include <vector>
1920
#include <set>
@@ -22,6 +23,42 @@ namespace llvm {
2223

2324
class Module;
2425

26+
/// This type is used to pass the linkage items (libraries and files) to
27+
/// the LinkItems function. It is composed of string/bool pairs. The string
28+
/// provides the name of the file or library (as with the -l option). The bool
29+
/// should be true for libraries, false for files, signifying "isLibrary".
30+
/// @brief A list of string/bool pairs
31+
typedef std::vector<std::pair<std::string,bool> > LinkItemList;
32+
33+
/// This function can be used to link a set of linkage items into a module. A
34+
/// linkage item is one of the three things identified by the LinkItemKind
35+
/// enumeration. This function allows linking to preserve the order of
36+
/// specification associated with a command line, or for other purposes. Each
37+
/// item will be linked in turn as it occurs in \p Items. Note that library
38+
/// path items will only be in effect after they have been processed.
39+
/// @returns The aggregated/linked Module.
40+
/// @throws nothing
41+
Module* LinkItems (
42+
const char * progname, ///< Name of the program being linked (for output)
43+
const LinkItemList& Items, // Set of libraries/files to link in
44+
const std::vector<std::string>& LibPaths, // Paths to search for libraries
45+
bool Verbose, ///< Link verbosely, indicating each action
46+
bool Native ///< Linking is for a native executable
47+
);
48+
49+
/// This function provides some utility for tools that need to build the list
50+
/// of link items from a triplet of command line options: Files, Libraries, and
51+
/// LibraryPaths. The command line ordering is preserved by this function even
52+
/// though the options are split into three separate cl::list<std::string>. The
53+
/// resulting \p OutList is suitable for use with LinkItems.
54+
/// @see LinkItems
55+
/// @throws nothing
56+
void BuildLinkItems(
57+
LinkItemList& OutList,
58+
const cl::list<std::string>& Files, ///< List of files to put in list
59+
const cl::list<std::string>& Libs ///< List of libraries to put in list
60+
);
61+
2562
/// This is the heart of the linker. The \p Src module is linked into the \p
2663
/// Dest module. If an error occurs, true is returned, otherwise false. If \p
2764
/// ErrorMsg is not null and an error occurs, \p *ErrorMsg will be set to a

0 commit comments

Comments
 (0)