Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions clang/include/clang/Basic/DiagnosticDriverKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,6 @@ def err_drv_reduced_module_output_overrided : Warning<
"please consider use '-fmodule-output=' to specify the output file for reduced BMI explicitly">,
InGroup<DiagGroup<"reduced-bmi-output-overrided">>;

def err_drv_modules_driver_requires_reduced_bmi : Error<
"'-fmodules-driver' is currently incompatible with '-fno-modules-reduced-bmi'">;
def remark_performing_driver_managed_module_build : Remark<
"performing driver managed module build">, InGroup<ModulesDriver>;
def remark_modules_manifest_not_found : Remark<
Expand Down
4 changes: 0 additions & 4 deletions clang/include/clang/Driver/ModulesDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ class Compilation;

namespace clang::driver::modules {

/// Emits diagnostics for arguments incompatible with -fmodules-driver.
void diagnoseModulesDriverArgs(llvm::opt::DerivedArgList &DAL,
DiagnosticsEngine &Diags);

/// The parsed Standard library module manifest.
struct StdModuleManifest {
struct Module {
Expand Down
2 changes: 0 additions & 2 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1832,8 +1832,6 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
if (UseModulesDriver) {
Diags.Report(diag::remark_performing_driver_managed_module_build);

modules::diagnoseModulesDriverArgs(C->getArgs(), Diags);

// Read the Standard library module manifest and, if available, add all
// discovered modules to this Compilation. Jobs for modules specified in
// the manifest that are not required by any command-line input are pruned
Expand Down
100 changes: 11 additions & 89 deletions clang/lib/Driver/ModulesDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "clang/Driver/Job.h"
#include "clang/Driver/Tool.h"
#include "clang/Driver/ToolChain.h"
#include "clang/Driver/Types.h"
#include "clang/Frontend/StandaloneDiagnostic.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/DepthFirstIterator.h"
Expand All @@ -48,14 +47,6 @@ using namespace clang;
using namespace driver;
using namespace modules;

void driver::modules::diagnoseModulesDriverArgs(llvm::opt::DerivedArgList &DAL,
DiagnosticsEngine &Diags) {
if (!DAL.hasFlag(options::OPT_fmodules_reduced_bmi,
options::OPT_fno_modules_reduced_bmi, true)) {
Diags.Report(diag::err_drv_modules_driver_requires_reduced_bmi);
}
}

namespace clang::driver::modules {
static bool fromJSON(const llvm::json::Value &Params,
StdModuleManifest::Module::LocalArguments &LocalArgs,
Expand Down Expand Up @@ -1261,16 +1252,6 @@ static SmallVector<JobNode *> createNodesForUnusedStdlibModuleJobs(
return StdlibModuleNodesToPrune;
}

// Returns the derived argument list for the tool chain responsible
// for creating \p Job.
static const DerivedArgList &getToolChainArgs(Compilation &C,
const Command &Job) {
const auto &TC = Job.getCreator().getToolChain();
const auto &SourceAction = Job.getSource();
return C.getArgsForToolChain(&TC, SourceAction.getOffloadingArch(),
SourceAction.getOffloadingDeviceKind());
}

/// Creates a job for the Clang module described by \p MD.
static std::unique_ptr<Command>
createClangModulePrecompileJob(Compilation &C, const Command &ImportingJob,
Expand All @@ -1282,7 +1263,9 @@ createClangModulePrecompileJob(Compilation &C, const Command &ImportingJob,
Action *PA = C.MakeAction<PrecompileJobAction>(IA, types::ID::TY_ModuleFile);
PA->propagateOffloadInfo(&ImportingJob.getSource());

const auto &TCArgs = getToolChainArgs(C, ImportingJob);
const auto &TC = ImportingJob.getCreator().getToolChain();
const auto &TCArgs = C.getArgsForToolChain(&TC, PA->getOffloadingArch(),
PA->getOffloadingDeviceKind());

const auto &BuildArgs = MD.getBuildArguments();
ArgStringList JobArgs;
Expand Down Expand Up @@ -1336,7 +1319,12 @@ installScanCommandLines(Compilation &C,
ArgStringList JobArgs;
JobArgs.reserve(BuildArgs.size());

auto &TCArgs = getToolChainArgs(C, Job);
const auto &SourceAction = Job.getSource();
const auto &TC = Job.getCreator().getToolChain();
auto &TCArgs =
C.getArgsForToolChain(&TC, SourceAction.getOffloadingArch(),
SourceAction.getOffloadingDeviceKind());

for (const auto &Arg : BuildArgs)
JobArgs.push_back(TCArgs.MakeArgString(Arg));

Expand Down Expand Up @@ -1539,73 +1527,6 @@ static void createAndConnectRoot(CompilationGraph &Graph) {
}
}

/// Creates a temporary output path for \p ModuleName.
static std::string createModuleOutputPath(const Compilation &C,
StringRef ModuleName) {
// Sanitize the ':' included in parition names. It is illegal for filenames on
// Windows.
SmallString<32> SanitizedModuleName(ModuleName);
llvm::replace(SanitizedModuleName, ':', '-');
auto ModuleOutputPath = C.getDriver().GetTemporaryPath(
SanitizedModuleName, types::getTypeTempSuffix(types::TY_ModuleFile));
return ModuleOutputPath;
}

/// Adds the '-fmodule-output=' argument for the module produced by \p Node.
static void configureNamedModuleOutputArg(Compilation &C,
NamedModuleJobNode &Node,
StringRef ModuleOutputPath) {
auto &Job = *Node.Job;
const auto &TCArgs = getToolChainArgs(C, Job);
auto JobArgs = Job.getArguments();
JobArgs.push_back(
TCArgs.MakeArgString("-fmodule-output=" + ModuleOutputPath));
Job.replaceArguments(std::move(JobArgs));
}

/// Propagates the '-fmodule-file=' mapping for the named module described by
/// \p Node to each dependent job.
static void propagateModuleFileMappingArg(Compilation &C,
NamedModuleJobNode &Node,
StringRef ModuleOutputPath) {
const StringRef ModuleName = Node.InputDeps.ModuleName;

auto DependentNodes = llvm::drop_begin(llvm::depth_first<CGNode *>(&Node));
auto DependentScannedNodes = llvm::map_range(
llvm::make_filter_range(DependentNodes, llvm::IsaPred<ScannedJobNode>),
llvm::CastTo<ScannedJobNode>);

for (ScannedJobNode *DependentNode : DependentScannedNodes) {
auto &DependentJob = *DependentNode->Job;
const auto &TCArgs = getToolChainArgs(C, DependentJob);
auto JobArgs = DependentJob.getArguments();
JobArgs.push_back(TCArgs.MakeArgString("-fmodule-file=" + ModuleName + "=" +
ModuleOutputPath));
DependentJob.replaceArguments(std::move(JobArgs));
}
}

/// Finalizes command lines for C++20 named module dependencies.
///
/// The command lines produced by dependency scanning are only adjusted to
/// handle discovered Clang modules. For C++20 named modules, we update the
/// command-lines here.
static void fixupNamedModuleCommandLines(Compilation &C,
CompilationGraph &Graph) {
const auto NamedModuleNodes = llvm::map_range(
llvm::make_filter_range(Graph, llvm::IsaPred<NamedModuleJobNode>),
llvm::CastTo<NamedModuleJobNode>);

for (NamedModuleJobNode *Node : NamedModuleNodes) {
const StringRef ModuleName = Node->InputDeps.ModuleName;
const auto ModuleOutputPath = createModuleOutputPath(C, ModuleName);
C.addTempFile(C.getArgs().MakeArgString(ModuleOutputPath));

configureNamedModuleOutputArg(C, *Node, ModuleOutputPath);
propagateModuleFileMappingArg(C, *Node, ModuleOutputPath);
}
}

/// Moves jobs from \p Graph into \p C in the graph's topological order.
static void feedJobsBackIntoCompilation(Compilation &C,
CompilationGraph &&Graph) {
Expand Down Expand Up @@ -1679,6 +1600,7 @@ void driver::modules::runModulesDriver(
if (!Diags.isLastDiagnosticIgnored())
llvm::WriteGraph<const CompilationGraph *>(llvm::errs(), &Graph);

fixupNamedModuleCommandLines(C, Graph);
// TODO: Fix-up command-lines for named module imports.

feedJobsBackIntoCompilation(C, std::move(Graph));
}
111 changes: 0 additions & 111 deletions clang/test/Driver/modules-driver-both-modules-types.cpp

This file was deleted.

88 changes: 0 additions & 88 deletions clang/test/Driver/modules-driver-cxx-modules-only.cpp

This file was deleted.

Loading
Loading