@@ -2989,57 +2989,36 @@ void tools::addOpenCLBuiltinsLib(const Driver &D,
2989
2989
const llvm::opt::ArgList &DriverArgs,
2990
2990
llvm::opt::ArgStringList &CC1Args) {
2991
2991
// Check whether user specifies a libclc bytecode library
2992
- if (const Arg *A = DriverArgs.getLastArg (options::OPT_libclc_lib_EQ)) {
2993
- SmallVector<StringRef, 8 > LibraryPaths;
2992
+ const Arg *A = DriverArgs.getLastArg (options::OPT_libclc_lib_EQ);
2993
+ if (!A)
2994
+ return ;
2994
2995
2995
- // Add user defined library paths from LIBRARY_PATH.
2996
- std::optional<std::string> LibPath =
2997
- llvm::sys::Process::GetEnv (" LIBRARY_PATH" );
2998
- if (LibPath) {
2999
- SmallVector<StringRef, 8 > Frags;
3000
- const char EnvPathSeparatorStr[] = {llvm::sys::EnvPathSeparator, ' \0 ' };
3001
- llvm::SplitString (*LibPath, Frags, EnvPathSeparatorStr);
3002
- for (StringRef Path : Frags)
3003
- LibraryPaths.emplace_back (Path.trim ());
3004
- }
2996
+ // Find device libraries in <LLVM_DIR>/lib/clang/<ver>/lib/libclc/
2997
+ SmallString<128 > LibclcPath (D.ResourceDir );
2998
+ llvm::sys::path::append (LibclcPath, " lib" , " libclc" );
3005
2999
3006
- // Find device libraries in <LLVM_DIR>/lib/clang/<ver>/lib/libclc/
3007
- SmallString< 128 > LibclcPath (D. ResourceDir );
3008
- llvm::sys::path::append (LibclcPath, " lib " , " libclc " );
3009
- LibraryPaths. emplace_back (LibclcPath );
3000
+ // If the namespec is of the form :filename, search for that file.
3001
+ StringRef LibclcNamespec (A-> getValue () );
3002
+ bool FilenameSearch = LibclcNamespec. consume_front ( " : " );
3003
+ SmallString< 128 > LibclcTargetFile (LibclcNamespec );
3010
3004
3011
- bool FoundBCLibrary = false ;
3012
- StringRef LibclcNamespec (A->getValue ());
3013
-
3014
- // If the namespec is of the form :filename, search for that file.
3015
- bool FilenameSearch = LibclcNamespec.consume_front (" :" );
3016
- SmallString<128 > LibclcTargetFile (LibclcNamespec);
3005
+ if (FilenameSearch && llvm::sys::fs::exists (LibclcTargetFile)) {
3006
+ CC1Args.push_back (" -mlink-builtin-bitcode" );
3007
+ CC1Args.push_back (DriverArgs.MakeArgString (LibclcTargetFile));
3008
+ } else {
3009
+ // Search the library paths for the file
3010
+ if (!FilenameSearch)
3011
+ LibclcTargetFile += " .bc" ;
3017
3012
3018
- if (FilenameSearch && llvm::sys::fs::exists ( LibclcTargetFile)) {
3019
- FoundBCLibrary = true ;
3013
+ llvm::sys::path::append (LibclcPath, LibclcTargetFile);
3014
+ if ( llvm::sys::fs::exists (LibclcPath)) {
3020
3015
CC1Args.push_back (" -mlink-builtin-bitcode" );
3021
- CC1Args.push_back (DriverArgs.MakeArgString (LibclcTargetFile ));
3016
+ CC1Args.push_back (DriverArgs.MakeArgString (LibclcPath ));
3022
3017
} else {
3023
- // Search the library paths for the file
3024
- if (!FilenameSearch)
3025
- LibclcTargetFile += " .bc" ;
3026
-
3027
- for (StringRef LibraryPath : LibraryPaths) {
3028
- SmallString<128 > LibclcPath (LibraryPath);
3029
- llvm::sys::path::append (LibclcPath, LibclcTargetFile);
3030
- if (llvm::sys::fs::exists (LibclcPath)) {
3031
- FoundBCLibrary = true ;
3032
- CC1Args.push_back (" -mlink-builtin-bitcode" );
3033
- CC1Args.push_back (DriverArgs.MakeArgString (LibclcPath));
3034
- break ;
3035
- }
3036
- }
3037
- }
3038
-
3039
- // Since the user requested a library, if we haven't one then report an
3040
- // error.
3041
- if (!FoundBCLibrary)
3018
+ // Since the user requested a library, if we haven't one then report an
3019
+ // error.
3042
3020
D.Diag (diag::err_drv_libclc_not_found) << LibclcTargetFile;
3021
+ }
3043
3022
}
3044
3023
}
3045
3024
0 commit comments