llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Joseph Huber (jhuber6) <details> <summary>Changes</summary> Summary: We need all inputs to `nvlink` to end in `.cubin` while the rest of the compiler toolchain wants `.o`. Previously we copied `.o` file to `.cubin` files, but this is wasteful. Instead, we can just create a link against it. This saves some disk space during link time. --- Full diff: https://github.com/llvm/llvm-project/pull/110139.diff 1 Files Affected: - (modified) clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp (+4-9) ``````````diff diff --git a/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp b/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp index 871fe5e4553ccb..19faef8dc07e45 100644 --- a/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp +++ b/clang/tools/clang-nvlink-wrapper/ClangNVLinkWrapper.cpp @@ -655,21 +655,16 @@ Expected<SmallVector<StringRef>> getInput(const ArgList &Args) { } } - // Copy all of the input files to a new file ending in `.cubin`. The 'nvlink' + // Create a link for each file to a new file ending in `.cubin`. The 'nvlink' // linker requires all NVPTX inputs to have this extension for some reason. for (auto &Input : LinkerInput) { auto TempFileOrErr = createTempFile( Args, sys::path::stem(Input->getBufferIdentifier()), "cubin"); if (!TempFileOrErr) return TempFileOrErr.takeError(); - Expected<std::unique_ptr<FileOutputBuffer>> OutputOrErr = - FileOutputBuffer::create(*TempFileOrErr, Input->getBuffer().size()); - if (!OutputOrErr) - return OutputOrErr.takeError(); - std::unique_ptr<FileOutputBuffer> Output = std::move(*OutputOrErr); - llvm::copy(Input->getBuffer(), Output->getBufferStart()); - if (Error E = Output->commit()) - return E; + if (std::error_code EC = + sys::fs::create_link(Input->getBufferIdentifier(), *TempFileOrErr)) + reportError(createFileError(*TempFileOrErr, EC)); Files.emplace_back(Args.MakeArgString(*TempFileOrErr)); } `````````` </details> https://github.com/llvm/llvm-project/pull/110139 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits