https://github.com/aganea created https://github.com/llvm/llvm-project/pull/89950
Previously, since response (.rsp) files weren't expanded at the very beginning of clang-scan-deps, we only parsed the command-line as provided in the Clang .cdb file. Unfortunately, when using Unreal Engine, arguments are always generated in a .rsp file (ie. `/path/to/clang-cl.exe @/path/to/filename_args.rsp`). After this patch, `/Fo` can be parsed and added to the final command-line. Without this option, the make targets that are emitted are made up from the input file name alone. We have some cases where the same input in the project generates several output files, so we end up with duplicate make targets in the scan-deps emitted dependency file. >From f2340c98c95e0d72516fc240ff268fead9f15391 Mon Sep 17 00:00:00 2001 From: Alexandre Ganea <aga...@havenstudios.com> Date: Wed, 17 Apr 2024 16:28:21 -0400 Subject: [PATCH] [clang-scan-deps] Expand response files before the argument ajuster Previously, since response (.rsp) files weren't expanded, we only parsed the command-line as provided in the Clang CDB file. Unfortunately, when using Unreal Engine, arguments are always generated in a .rsp file. After this patch, /Fo can be parsed and added to the final command-line. Without this option, the make targets that are emitted are made up from the input file name alone. We have some cases where the same input in the project generates several output files, so we end up with duplicate make targets in the scan-deps emitted dependency file. --- clang/tools/clang-scan-deps/ClangScanDeps.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp b/clang/tools/clang-scan-deps/ClangScanDeps.cpp index f42af7e330e17a..7b7f10c4be7421 100644 --- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp +++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp @@ -792,10 +792,15 @@ int clang_scan_deps_main(int argc, char **argv, const llvm::ToolContext &) { llvm::cl::PrintOptionValues(); + // Expand response files in advance, so that we can "see" all the arguments + // when adjusting below. + auto ResponseExpander = expandResponseFiles(std::move(Compilations), + llvm::vfs::getRealFileSystem()); + // The command options are rewritten to run Clang in preprocessor only mode. auto AdjustingCompilations = std::make_unique<tooling::ArgumentsAdjustingCompilations>( - std::move(Compilations)); + std::move(ResponseExpander)); ResourceDirectoryCache ResourceDirCache; AdjustingCompilations->appendArgumentsAdjuster( _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits