llvm.org GIT mirror llvm / 978d498
Add a --linker command-line option, make all tests pass. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50755 91177308-0d34-0410-b5e6-96231b3b80d8 Mikhail Glushenkov 11 years ago
5 changed file(s) with 29 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
0 // Test that we can compile .c files as C++ and vice versa
1 // RUN: llvmc2 -x c++ %s -x c %p/false.cpp -x lisp -x whatnot -x none %p/false2.cpp -o %t
1 // RUN: llvmc2 --linker=c++ -x c++ %s -x c %p/false.cpp -x lisp -x whatnot -x none %p/false2.cpp -o %t
22 // RUN: ./%t | grep hello
33
44 #include
99 int main() {
1010 std::cout << "h";
1111 test();
12 std::cout << test2() << '\n';
12 std::cout << test2() << '\n';
1313 }
0 // Test that we can compile C++ code.
1 // RUN: llvmc2 %s -o %t
1 // RUN: llvmc2 --linker=c++ %s -o %t
22 // RUN: ./%t | grep hello
33 #include
44
3232
3333 Edge,
3434 Edge,
35 OptionalEdge
36 [(parameter_equals "linker", "g++"),
37 (parameter_equals "linker", "c++")]>,
3538
36 Edge
39
40 Edge,
41 OptionalEdge
42 [(parameter_equals "linker", "g++"),
43 (parameter_equals "linker", "c++")]>
3744 ]>;
8080 ]>;
8181
8282 // Alternative linker for C++
83 // TOTHINK: how to implement this best?
84 // Something like input_file_language can only choose between two languages.
85 // def llvm_gcc_cpp_linker : Tool<
86 // [(in_language "object-code"),
87 // (out_language "executable"),
88 // (output_suffix "out"),
89 // (cmd_line "llvm-g++ $INFILE -o $OUTFILE"),
90 // (join),
91 // //(input_file_language "c++"),
92 // (prefix_list_option "L", (forward)),
93 // (prefix_list_option "l", (forward)),
94 // (prefix_list_option "Wl", (unpack_values))
95 // ]>;
83 def llvm_gcc_cpp_linker : Tool<
84 [(in_language "object-code"),
85 (out_language "executable"),
86 (output_suffix "out"),
87 (cmd_line "llvm-g++ $INFILE -o $OUTFILE"),
88 (join),
89 (parameter_option "linker",
90 (help "Choose linker (possible values: gcc, g++)")),
91 (prefix_list_option "L", (forward)),
92 (prefix_list_option "l", (forward)),
93 (prefix_list_option "Wl", (unpack_values))
94 ]>;
9695
9796 // Language map
9897
174174 if (other.Type != Type)
175175 throw "Conflicting definitions for the option " + Name + "!";
176176
177 if (Help.empty() && !other.Help.empty())
177 if (Help == DefaultHelpString)
178178 Help = other.Help;
179 else if (!Help.empty() && !other.Help.empty())
180 cerr << "Warning: more than one help string defined for option "
179 else if (other.Help != DefaultHelpString) {
180 llvm::cerr << "Warning: more than one help string defined for option "
181181 + Name + "\n";
182 }
182183
183184 Flags |= other.Flags;
184185 }
289290
290291 // Default ctor here is needed because StringMap can only store
291292 // DefaultConstructible objects
292 ToolProperties() {}
293 ToolProperties (const std::string& n) : Name(n) {}
293 ToolProperties() : Flags(0) {}
294 ToolProperties (const std::string& n) : Name(n), Flags(0) {}
294295 };
295296
296297