From 7b05724ac81c3262ce8aded5578326ecec327ae4 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sun, 2 Jul 2023 16:06:53 -0400 Subject: cmCxxModuleMapper: give transitive usages to Clang as well In the future, Clang plans to require transitive module usage to be specified on the command line. This is in order to keep BMI files more reproducible. Handily, MSVC has already required this, so the logic can be reused for Clang easily. See: https://github.com/llvm/llvm-project/commit/e22fa1d4c6152d36cf1342ab9029adc97c79a310 See: https://github.com/llvm/llvm-project/issues/62707 See: https://discourse.llvm.org/t/c-20-modules-should-the-bmis-contain-paths-to-their-dependent-bmis/70422 --- Source/cmCxxModuleMapper.cxx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/cmCxxModuleMapper.cxx b/Source/cmCxxModuleMapper.cxx index 63e6702..e6c10c6 100644 --- a/Source/cmCxxModuleMapper.cxx +++ b/Source/cmCxxModuleMapper.cxx @@ -128,7 +128,8 @@ std::vector GetTransitiveUsages( } std::string CxxModuleMapContentClang(CxxModuleLocations const& loc, - cmScanDepInfo const& obj) + cmScanDepInfo const& obj, + CxxModuleUsage const& usages) { std::stringstream mm; @@ -151,12 +152,11 @@ std::string CxxModuleMapContentClang(CxxModuleLocations const& loc, break; } } - for (auto const& r : obj.Requires) { - auto bmi_loc = loc.BmiGeneratorPathForModule(r.LogicalName); - if (bmi_loc.IsKnown()) { - mm << "-fmodule-file=" << r.LogicalName << "=" << bmi_loc.Location() - << '\n'; - } + + auto all_usages = GetTransitiveUsages(loc, obj.Requires, usages); + for (auto const& usage : all_usages) { + mm << "-fmodule-file=" << usage.LogicalName << '=' << usage.Location + << '\n'; } return mm.str(); @@ -420,7 +420,7 @@ std::string CxxModuleMapContent(CxxModuleMapFormat format, { switch (format) { case CxxModuleMapFormat::Clang: - return CxxModuleMapContentClang(loc, obj); + return CxxModuleMapContentClang(loc, obj, usages); case CxxModuleMapFormat::Gcc: return CxxModuleMapContentGcc(loc, obj); case CxxModuleMapFormat::Msvc: -- cgit v0.12