================ @@ -76,8 +79,75 @@ class HIPUndefinedFatBinSymbols { return GPUBinHandleSymbols; } + // Collect symbols from static libraries specified by -l options. + void processStaticLibraries() { + llvm::SmallVector<llvm::StringRef, 16> LibNames; + llvm::SmallVector<llvm::StringRef, 16> LibPaths; + llvm::SmallVector<llvm::StringRef, 16> ExactLibNames; + llvm::Triple Triple(C.getDriver().getTargetTriple()); + bool IsMSVC = Triple.isWindowsMSVCEnvironment(); + llvm::StringRef Ext = IsMSVC ? ".lib" : ".a"; + + for (const auto *Arg : Args.filtered(options::OPT_l)) { + llvm::StringRef Value = Arg->getValue(); + if (Value.starts_with(":")) + ExactLibNames.push_back(Value.drop_front()); + else + LibNames.push_back(Value); + } + for (const auto *Arg : Args.filtered(options::OPT_L)) { + auto Path = Arg->getValue(); + LibPaths.push_back(Path); + if (Verbose) + llvm::errs() << "HIP fatbin symbol search uses library path: " << Path + << "\n"; + } + + auto ProcessLib = [&](llvm::StringRef LibName, bool IsExact) { + llvm::SmallString<256> FullLibName; + if (IsExact) + FullLibName = LibName; + else { + if (IsMSVC) + (llvm::Twine(LibName) + Ext).toVector(FullLibName); + else + (llvm::Twine("lib") + LibName + Ext).toVector(FullLibName); + } ---------------- yxsamliu wrote:
will use the first suggestion. with minor change Twine("lib") for it to work https://github.com/llvm/llvm-project/pull/104638 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits