Add a --linker command-line option, make all tests pass.
authorMikhail Glushenkov <foldr@codedgers.com>
Tue, 6 May 2008 18:13:00 +0000 (18:13 +0000)
committerMikhail Glushenkov <foldr@codedgers.com>
Tue, 6 May 2008 18:13:00 +0000 (18:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50755 91177308-0d34-0410-b5e6-96231b3b80d8

test/LLVMC/false.c
test/LLVMC/hello.cpp
tools/llvmc2/Example.td
tools/llvmc2/Tools.td
utils/TableGen/LLVMCConfigurationEmitter.cpp

index 80e9e03b5436f026185a7a78b28782f669fd2e94..8319036c363b366c8f6ec45146c12237c9eac9e4 100644 (file)
@@ -1,5 +1,5 @@
 // Test that we can compile .c files as C++ and vice versa
-// RUN: llvmc2 -x c++ %s -x c %p/false.cpp -x lisp -x whatnot -x none %p/false2.cpp -o %t
+// RUN: llvmc2 --linker=c++ -x c++ %s -x c %p/false.cpp -x lisp -x whatnot -x none %p/false2.cpp -o %t
 // RUN: ./%t | grep hello
 
 #include <iostream>
@@ -10,5 +10,5 @@ extern std::string test2();
 int main() {
     std::cout << "h";
     test();
-    std::cout << test2() << '\n'; 
+    std::cout << test2() << '\n';
 }
index a3148c3c164f1facaf6cc2ab5bcf34547a67d486..4b45ea945e0134c05176d8454d08a2fc5e67917b 100644 (file)
@@ -1,5 +1,5 @@
 // Test that we can compile C++ code.
-// RUN: llvmc2 %s -o %t
+// RUN: llvmc2 --linker=c++ %s -o %t
 // RUN: ./%t | grep hello
 #include <iostream>
 
index 57629904d18dca75424c8d75dd90da2a09f67ec5..227090258a9d97aa0699b96486351044cfe5e72b 100644 (file)
@@ -33,6 +33,13 @@ def CompilationGraph : CompilationGraph<[
 
     Edge<llc, llvm_gcc_assembler>,
     Edge<llvm_gcc_assembler, llvm_gcc_linker>,
+    OptionalEdge<llvm_gcc_assembler, llvm_gcc_cpp_linker,
+                 [(parameter_equals "linker", "g++"),
+                  (parameter_equals "linker", "c++")]>,
 
-    Edge<root, llvm_gcc_linker>
+
+    Edge<root, llvm_gcc_linker>,
+    OptionalEdge<root, llvm_gcc_cpp_linker,
+                 [(parameter_equals "linker", "g++"),
+                  (parameter_equals "linker", "c++")]>
     ]>;
index 897892415ebd2028bbf0ae6fa935a6567406bb07..e803915da65c87fb2363136215ebd3749d5c1a34 100644 (file)
@@ -81,19 +81,18 @@ def llvm_gcc_linker : Tool<
 ]>;
 
 // Alternative linker for C++
-// TOTHINK: how to implement this best?
-// Something like input_file_language can only choose between two languages.
-// def llvm_gcc_cpp_linker : Tool<
-// [(in_language "object-code"),
-//  (out_language "executable"),
-//  (output_suffix "out"),
-//  (cmd_line "llvm-g++ $INFILE -o $OUTFILE"),
-//  (join),
-//  //(input_file_language "c++"),
-//  (prefix_list_option "L", (forward)),
-//  (prefix_list_option "l", (forward)),
-//  (prefix_list_option "Wl", (unpack_values))
-// ]>;
+def llvm_gcc_cpp_linker : Tool<
+[(in_language "object-code"),
+ (out_language "executable"),
+ (output_suffix "out"),
+ (cmd_line "llvm-g++ $INFILE -o $OUTFILE"),
+ (join),
+ (parameter_option "linker",
+                   (help "Choose linker (possible values: gcc, g++)")),
+ (prefix_list_option "L", (forward)),
+ (prefix_list_option "l", (forward)),
+ (prefix_list_option "Wl", (unpack_values))
+]>;
 
 // Language map
 
index aaa10992d99e357ab9a0d0e75c2954a4cad47459..32b6d3832888872f8684bf9c0e20e56f5cb53f99 100644 (file)
@@ -175,11 +175,12 @@ struct GlobalOptionDescription : public OptionDescription {
     if (other.Type != Type)
       throw "Conflicting definitions for the option " + Name + "!";
 
-    if (Help.empty() && !other.Help.empty())
+    if (Help == DefaultHelpString)
       Help = other.Help;
-    else if (!Help.empty() && !other.Help.empty())
-      cerr << "Warning: more than one help string defined for option "
+    else if (other.Help != DefaultHelpString) {
+      llvm::cerr << "Warning: more than one help string defined for option "
         + Name + "\n";
+    }
 
     Flags |= other.Flags;
   }
@@ -290,8 +291,8 @@ struct ToolProperties : public RefCountedBase<ToolProperties> {
 
   // Default ctor here is needed because StringMap can only store
   // DefaultConstructible objects
-  ToolProperties() {}
-  ToolProperties (const std::string& n) : Name(n) {}
+  ToolProperties() : Flags(0) {}
+  ToolProperties (const std::string& n) : Name(n), Flags(0) {}
 };