From: Douglas Gregor Date: Wed, 14 Sep 2011 20:28:46 +0000 (+0000) Subject: Teach the driver to always pass down a module cache path. If none is X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8ee51ef211bfed9ce04bc93835e19aee014f2fae;p=clang Teach the driver to always pass down a module cache path. If none is supplied, use something derived from the system's temporary directory. Depends on LLVM r139725. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139726 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td index 9969abb600..acc53a038a 100644 --- a/include/clang/Driver/CC1Options.td +++ b/include/clang/Driver/CC1Options.td @@ -605,7 +605,7 @@ def nostdincxx : Flag<"-nostdinc++">, HelpText<"Disable standard #include directories for the C++ standard library">; def nobuiltininc : Flag<"-nobuiltininc">, HelpText<"Disable builtin #include directories">; -def fmodule_cache_path : JoinedOrSeparate<"-fmodule-cache-path">, +def fmodule_cache_path : Separate<"-fmodule-cache-path">, MetaVarName<"">, HelpText<"Specify the module cache path">; def fdisable_module_hash : Flag<"-fdisable-module-hash">, diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index d1040adfc9..55bf2e9db3 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -342,6 +342,8 @@ def fmessage_length_EQ : Joined<"-fmessage-length=">, Group; def fms_extensions : Flag<"-fms-extensions">, Group; def fmsc_version : Joined<"-fmsc-version=">, Group; def fdelayed_template_parsing : Flag<"-fdelayed-template-parsing">, Group; +def fmodule_cache_path : Separate<"-fmodule-cache-path">, Group, + Flags<[NoForward]>; def fmudflapth : Flag<"-fmudflapth">, Group; def fmudflap : Flag<"-fmudflap">, Group; def fnested_functions : Flag<"-fnested-functions">, Group; diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 691e96cb11..28a14a2970 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -375,6 +375,21 @@ void Clang::AddPreprocessingOptions(const Driver &D, CmdArgs.push_back(A->getValue(Args)); } } + + // If a module path was provided, pass it along. Otherwise, use a temporary + // directory. + if (Arg *A = Args.getLastArg(options::OPT_fmodule_cache_path)) { + CmdArgs.push_back(A->getValue(Args)); + A->claim(); + A->render(Args, CmdArgs); + } else { + llvm::SmallString<128> DefaultModuleCache; + llvm::sys::path::system_temp_directory(/*erasedOnReboot=*/false, + DefaultModuleCache); + llvm::sys::path::append(DefaultModuleCache, "clang-module-cache"); + CmdArgs.push_back("-fmodule-cache-path"); + CmdArgs.push_back(Args.MakeArgString(DefaultModuleCache)); + } } /// getARMTargetCPU - Get the (LLVM) name of the ARM cpu we are targeting.