Index: include/clang/Driver/Options.td =================================================================== --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -770,6 +770,10 @@ Flags<[DriverOption]>; def fimplicit_modules : Flag <["-"], "fimplicit-modules">, Group, Flags<[DriverOption]>; +def fmodule_file_deps : Flag <["-"], "fmodule-file-deps">, Group, + Flags<[DriverOption]>; +def fno_module_file_deps : Flag <["-"], "fno-module-file-deps">, Group, + Flags<[DriverOption]>; def fno_ms_extensions : Flag<["-"], "fno-ms-extensions">, Group; def fno_ms_compatibility : Flag<["-"], "fno-ms-compatibility">, Group; def fno_delayed_template_parsing : Flag<["-"], "fno-delayed-template-parsing">, Group; Index: lib/Driver/Tools.cpp =================================================================== --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -324,8 +324,9 @@ if (A->getOption().matches(options::OPT_M) || A->getOption().matches(options::OPT_MD)) CmdArgs.push_back("-sys-header-deps"); - - if (isa(JA)) + if ((isa(JA) && + !Args.hasArg(options::OPT_fno_module_file_deps)) || + Args.hasArg(options::OPT_fmodule_file_deps)) CmdArgs.push_back("-module-file-deps"); } Index: test/Driver/pch-deps.c =================================================================== --- test/Driver/pch-deps.c +++ test/Driver/pch-deps.c @@ -8,3 +8,13 @@ // RUN: FileCheck %s -check-prefix=CHECK-NOPCH -input-file=%t // CHECK-NOPCH: -dependency-file // CHECK-NOPCH-NOT: -module-file-deps + +// RUN: %clang -x c-header %s -o %t.pch -MMD -MT dependencies -MF %t.d -fno-module-file-deps -### 2> %t +// RUN: FileCheck %s -check-prefix=CHECK-EXPLICIT -input-file=%t +// CHECK-EXPLICIT: -dependency-file +// CHECK-EXPLICIT-NOT: -module-file-deps + +// RUN: %clang -x c++ %s -o %t.o -MMD -MT dependencies -MF %t.d -fmodule-file-deps -### 2> %t +// RUN: FileCheck %s -check-prefix=CHECK-EXPLICIT-NOPCH -input-file=%t +// CHECK-EXPLICIT-NOPCH: -dependency-file +// CHECK-EXPLICIT-NOPCH: -module-file-deps