================ @@ -2942,6 +2942,65 @@ void tools::addHIPRuntimeLibArgs(const ToolChain &TC, Compilation &C, } } +void tools::addOpenCLBuiltinsLib(const Driver &D, + const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args) { + // Check whether user specifies a libclc bytecode library + if (const Arg *A = DriverArgs.getLastArg(options::OPT_libclc_lib_EQ)) { + SmallVector<StringRef, 8> LibraryPaths; + + // Add user defined library paths from LIBRARY_PATH. + std::optional<std::string> LibPath = + llvm::sys::Process::GetEnv("LIBRARY_PATH"); + if (LibPath) { + SmallVector<StringRef, 8> Frags; + const char EnvPathSeparatorStr[] = {llvm::sys::EnvPathSeparator, '\0'}; + llvm::SplitString(*LibPath, Frags, EnvPathSeparatorStr); + for (StringRef Path : Frags) + LibraryPaths.emplace_back(Path.trim()); + } + + // Find device libraries in <LLVM_DIR>/lib/clang/<ver>/lib/libclc/ + SmallString<128> LibclcPath(D.ResourceDir); + llvm::sys::path::append(LibclcPath, "lib", "libclc"); + LibraryPaths.emplace_back(LibclcPath); + + bool FoundBCLibrary = false; + StringRef LibclcNamespec(A->getValue()); + + // If the namespec is of the form :filename, search for that file. + bool FilenameSearch = LibclcNamespec.starts_with(":"); + SmallString<128> LibclcTargetFile( + LibclcNamespec.drop_front(FilenameSearch ? 1 : 0)); ---------------- arsenm wrote:
consume_front https://github.com/llvm/llvm-project/pull/146503 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits