]> granicus.if.org Git - clang/commitdiff
Introduce '-fmodules-user-build-path' which accepts the "canonical" path to a user...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 3 Mar 2014 08:12:05 +0000 (08:12 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 3 Mar 2014 08:12:05 +0000 (08:12 +0000)
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

include/clang/Driver/Options.td
include/clang/Lex/HeaderSearchOptions.h
lib/Driver/Tools.cpp
lib/Frontend/CompilerInvocation.cpp
lib/Serialization/ASTReader.cpp
lib/Serialization/ASTWriter.cpp

index 6b7bfe77f1a9e20d3a91654b2680c5a5e82601d6..4b90e43754ffd1eb310f3b21c637cde1b243b959 100644 (file)
@@ -575,6 +575,9 @@ def fms_memptr_rep_EQ : Joined<["-"], "fms-memptr-rep=">, Group<f_Group>, Flags<
 def fmodules_cache_path : Joined<["-"], "fmodules-cache-path=">, Group<i_Group>,
   Flags<[DriverOption, CC1Option]>, MetaVarName<"<directory>">,
   HelpText<"Specify the module cache path">;
+def fmodules_user_build_path : Separate<["-"], "fmodules-user-build-path">, Group<i_Group>,
+  Flags<[DriverOption, CC1Option]>, MetaVarName<"<directory>">,
+  HelpText<"Specify the module user build path">;
 def fmodules_prune_interval : Joined<["-"], "fmodules-prune-interval=">, Group<i_Group>,
   Flags<[CC1Option]>, MetaVarName<"<seconds>">,
   HelpText<"Specify the interval (in seconds) between attempts to prune the module cache">;
index 5abcdad2d579a9db1357d72400e4ff89bada742c..53b4bdc4c9f142d5b4e06616e75df858c97ba79b 100644 (file)
@@ -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.
   ///
index 50ad7e65eb36bd6e3d3605e04bbd844f09a9dd1f..911b6a02aee9456cf6266b5c5b968047f208efc1 100644 (file)
@@ -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);
index 85aae236b8afbc1103b7a3b40d6ced0756e2e0f8..f8cb938866154ca0ad30c7325e2e9c59bb8471f5 100644 (file)
@@ -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
index 458d9ec95cfbc8260f38b0bba51c4785550acf0c..41c532ec274ee0ed4818b8151abb1d7df4bf0ee7 100644 (file)
@@ -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++];
index c9c339eaee8c1eb31fcd046d20d2968d33252a7a..3365d1ee0c54aabe7c959b434746bf603ab5823f 100644 (file)
@@ -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);