[PATCH] [Driver] Add -L and -l support.

Michael Spencer bigcheesegs at gmail.com
Tue Feb 5 22:50:14 PST 2013



================
Comment at: lib/Driver/CoreOptions.td:10
@@ -9,2 +9,3 @@
 def entry : Joined<["-"], "entry=">;
+def input_search_path : Joined<["-"], "input-search-path=">;
 def relocatable : Flag<["-"], "relocatable">;
----------------
Shankar Kalpathi Easwaran wrote:
> Should this be an alias option for -L ?
No, -core doesn't have -L.

================
Comment at: lib/Driver/Drivers.cpp:168
@@ +167,3 @@
+        StringRef libName = (*it)->getValue();
+        SmallString<128> p;
+        for (const auto &path : _inputSearchPaths) {
----------------
Shankar Kalpathi Easwaran wrote:
> This should use MAXPATHLEN, not sure if llvm has a value depending on the platform.
The size is just the amount stored within the object. If the dynamic size is greater, it gets moved to heap.

================
Comment at: lib/Driver/Drivers.cpp:171
@@ +170,3 @@
+          p = path;
+          llvm::sys::path::append(p, Twine("lib") + libName + ".a");
+          if (llvm::sys::fs::exists(p.str())) {
----------------
Shankar Kalpathi Easwaran wrote:
> This could be a problem when shared libraries are added for searching. Should the extension be queried with targetInfo, because archive libraries could use different extensions in different platforms
It's up to the driver how to search for inputs, and it can base this on the target. Also, there is no TargetInfo when the driver is created.

================
Comment at: lib/Driver/Drivers.cpp:172-174
@@ +171,5 @@
+          llvm::sys::path::append(p, Twine("lib") + libName + ".a");
+          if (llvm::sys::fs::exists(p.str())) {
+            inputPath = newArgs->MakeArgString(p);
+            break;
+          }
----------------
Shankar Kalpathi Easwaran wrote:
> Does this take care of symbolic links ?
It treats them as any other file. There's no need to fully resolve them.

================
Comment at: lib/Driver/Drivers.cpp:178
@@ +177,3 @@
+        if (inputPath.empty())
+          llvm_unreachable("Failed to lookup library!");
+      } else
----------------
Shankar Kalpathi Easwaran wrote:
> I think this should just be a error and not llvm_unreachable. It should also include library name here.
Yes, but this function isn't currently setup for error handling. I plan to handle this separately.


http://llvm-reviews.chandlerc.com/D365



More information about the llvm-commits mailing list