[PATCH] D15596: Add -L/path/to/cuda/lib if any of our inputs are CUDA files.
Artem Belevich via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 6 13:49:19 PST 2016
tra added inline comments.
================
Comment at: include/clang/Driver/Options.td:1636
@@ -1635,1 +1635,3 @@
+def nocudalib : Flag<["-"], "nocudalib">,
+ HelpText<"Don't include libraries necessary for running CUDA (-L/path/to/cuda/lib{,64} -lcudart_static -lrt -lpthread -ldl)">;
def nocudalibdevice : Flag<["-"], "nocudalibdevice">,
----------------
include -> link with
Perhaps less implementation details would be more appropriate for a help string.
"Don't link with default CUDA runtime library"?
================
Comment at: lib/Driver/ToolChains.cpp:4129-4137
@@ +4128,11 @@
+ LDArgs.push_back("-L");
+ LDArgs.push_back(DriverArgs.MakeArgString(CudaInstallation.getLibPath()));
+ auto AddIfNotPresent = [&](const char *Flag) {
+ llvm::StringRef FlagRef(Flag);
+ if (std::find_if(LDArgs.begin(), LDArgs.end(), [FlagRef](const char *A) {
+ return llvm::StringRef(A) == FlagRef;
+ }) == LDArgs.end()) {
+ LDArgs.push_back(DriverArgs.MakeArgString(Flag));
+ }
+ };
+ AddIfNotPresent("-lcudart_static");
----------------
Does this kick in before user's arguments have been added or after?
If user args have not been added yet, then you'll never find them and don't need this check at all.
Skipping -lFOO will also have problems if any of the libraries are static and one of preceding libraries needs extra symbols that were not linked in by this point yet.
Link with required libraries unconditionally. Make sure to add these libraries after user arguments have been added.
================
Comment at: lib/Driver/ToolChains.cpp:4139
@@ +4138,3 @@
+ AddIfNotPresent("-lcudart_static");
+ AddIfNotPresent("-lcuda");
+ AddIfNotPresent("-ldl");
----------------
-lcuda is not needed. As far as I can tell, cudart_static will open and use it via dlopen.
It would be needed only if user uses any of API calls from libcuda directly, but then it would be up to user to add -lcuda.
================
Comment at: lib/Driver/ToolChains.cpp:4142
@@ +4141,3 @@
+ AddIfNotPresent("-lrt");
+ AddIfNotPresent("-pthread");
+}
----------------
-lpthread
http://reviews.llvm.org/D15596
More information about the cfe-commits
mailing list