Index: docs/ClangCommandLineReference.rst =================================================================== --- docs/ClangCommandLineReference.rst +++ docs/ClangCommandLineReference.rst @@ -2587,6 +2587,8 @@ .. option:: -gstrict-dwarf, -gno-strict-dwarf +.. option:: -glto-dwo-dir= + .. option:: -gz DWARF debug sections compression type Index: include/clang/Driver/Options.td =================================================================== --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1700,6 +1700,7 @@ def gcolumn_info : Flag<["-"], "gcolumn-info">, Group, Flags<[CoreOption]>; def gno_column_info : Flag<["-"], "gno-column-info">, Group, Flags<[CoreOption]>; def gsplit_dwarf : Flag<["-"], "gsplit-dwarf">, Group; +def glto_dwo_dir_EQ : Joined<["-"], "glto-dwo-dir=">, Group; def ggnu_pubnames : Flag<["-"], "ggnu-pubnames">, Group, Flags<[CC1Option]>; def gdwarf_aranges : Flag<["-"], "gdwarf-aranges">, Group; def gmodules : Flag <["-"], "gmodules">, Group, Index: lib/Driver/ToolChains/CommonArgs.cpp =================================================================== --- lib/Driver/ToolChains/CommonArgs.cpp +++ lib/Driver/ToolChains/CommonArgs.cpp @@ -415,6 +415,16 @@ if (IsThinLTO) CmdArgs.push_back("-plugin-opt=thinlto"); + if (Arg *A = Args.getLastArg(options::OPT_glto_dwo_dir_EQ)) { + const char *Objcopy = + Args.MakeArgString(ToolChain.GetProgramPath(CLANG_DEFAULT_OBJCOPY)); + CmdArgs.push_back( + Args.MakeArgString(Twine("-plugin-opt=objcopy=") + Objcopy)); + StringRef DWO_Dir = A->getValue(); + CmdArgs.push_back( + Args.MakeArgString(Twine("-plugin-opt=dwo_dir=") + DWO_Dir)); + } + if (unsigned Parallelism = getLTOParallelism(Args, D)) CmdArgs.push_back( Args.MakeArgString("-plugin-opt=jobs=" + Twine(Parallelism))); Index: test/Driver/lto-dwo.c =================================================================== --- /dev/null +++ test/Driver/lto-dwo.c @@ -0,0 +1,8 @@ +// Confirm that -glto-dwo-dir=DIR is passed to linker + +// RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -glto-dwo-dir=DIR 2> %t +// RUN: FileCheck -check-prefix=CHECK-LINK-DWO-DIR < %t %s +// RUN: FileCheck -check-prefix=CHECK-LINK-OBJCOPY < %t %s +// +// CHECK-LINK-DWO-DIR: "-plugin-opt=dwo_dir=DIR" +// CHECK-LINK-OBJCOPY: "-plugin-opt=objcopy={{.*}}objcopy"