From: Argyrios Kyrtzidis Date: Mon, 3 Mar 2014 08:12:05 +0000 (+0000) Subject: Introduce '-fmodules-user-build-path' which accepts the "canonical" path to a user... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=977d67c59b37da172304bcda668101152324e8cb;p=clang Introduce '-fmodules-user-build-path' which accepts the "canonical" path to a user workspace build. This is used to avoid conflicts with user modules with the same name from different workspaces. rdar://16042513 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202683 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 6b7bfe77f1..4b90e43754 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -575,6 +575,9 @@ def fms_memptr_rep_EQ : Joined<["-"], "fms-memptr-rep=">, Group, Flags< def fmodules_cache_path : Joined<["-"], "fmodules-cache-path=">, Group, Flags<[DriverOption, CC1Option]>, MetaVarName<"">, HelpText<"Specify the module cache path">; +def fmodules_user_build_path : Separate<["-"], "fmodules-user-build-path">, Group, + Flags<[DriverOption, CC1Option]>, MetaVarName<"">, + HelpText<"Specify the module user build path">; def fmodules_prune_interval : Joined<["-"], "fmodules-prune-interval=">, Group, Flags<[CC1Option]>, MetaVarName<"">, HelpText<"Specify the interval (in seconds) between attempts to prune the module cache">; diff --git a/include/clang/Lex/HeaderSearchOptions.h b/include/clang/Lex/HeaderSearchOptions.h index 5abcdad2d5..53b4bdc4c9 100644 --- a/include/clang/Lex/HeaderSearchOptions.h +++ b/include/clang/Lex/HeaderSearchOptions.h @@ -89,6 +89,9 @@ public: /// \brief The directory used for the module cache. std::string ModuleCachePath; + /// \brief The directory used for a user build. + std::string ModuleUserBuildPath; + /// \brief Whether we should disable the use of the hash string within the /// module cache. /// diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 50ad7e65eb..911b6a02ae 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -3366,6 +3366,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back(Args.MakeArgString(DefaultModuleCache)); } + if (Arg *A = Args.getLastArg(options::OPT_fmodules_user_build_path)) { + A->claim(); + if (HaveModules) { + A->render(Args, CmdArgs); + } + } + // Pass through all -fmodules-ignore-macro arguments. Args.AddAllArgs(CmdArgs, options::OPT_fmodules_ignore_macro); Args.AddLastArg(CmdArgs, options::OPT_fmodules_prune_interval); diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 85aae236b8..f8cb938866 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -918,6 +918,7 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args) { Opts.UseLibcxx = (strcmp(A->getValue(), "libc++") == 0); Opts.ResourceDir = Args.getLastArgValue(OPT_resource_dir); Opts.ModuleCachePath = Args.getLastArgValue(OPT_fmodules_cache_path); + Opts.ModuleUserBuildPath = Args.getLastArgValue(OPT_fmodules_user_build_path); Opts.DisableModuleHash = Args.hasArg(OPT_fdisable_module_hash); // -fmodules implies -fmodule-maps Opts.ModuleMaps = Args.hasArg(OPT_fmodule_maps) || Args.hasArg(OPT_fmodules); @@ -1821,6 +1822,9 @@ std::string CompilerInvocation::getModuleHash() const { hsOpts.UseStandardCXXIncludes, hsOpts.UseLibcxx); + // Extend the signature with the user build path. + code = hash_combine(code, hsOpts.ModuleUserBuildPath); + // Darwin-specific hack: if we have a sysroot, use the contents and // modification time of // $sysroot/System/Library/CoreServices/SystemVersion.plist diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 458d9ec95c..41c532ec27 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -4297,6 +4297,7 @@ bool ASTReader::ParseHeaderSearchOptions(const RecordData &Record, HSOpts.ResourceDir = ReadString(Record, Idx); HSOpts.ModuleCachePath = ReadString(Record, Idx); + HSOpts.ModuleUserBuildPath = ReadString(Record, Idx); HSOpts.DisableModuleHash = Record[Idx++]; HSOpts.UseBuiltinIncludes = Record[Idx++]; HSOpts.UseStandardSystemIncludes = Record[Idx++]; diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index c9c339eaee..3365d1ee0c 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -1161,6 +1161,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context, AddString(HSOpts.ResourceDir, Record); AddString(HSOpts.ModuleCachePath, Record); + AddString(HSOpts.ModuleUserBuildPath, Record); Record.push_back(HSOpts.DisableModuleHash); Record.push_back(HSOpts.UseBuiltinIncludes); Record.push_back(HSOpts.UseStandardSystemIncludes);