Support option -plugin-opt=dwo_dir=

Summary:
This adds support to option -plugin-opt=dwo_dir=${DIR}. This option is used to specify the directory to store the .dwo files when LTO and debug fission is used
at the same time.

Reviewers: ruiu, espindola, pcc

Reviewed By: pcc

Subscribers: eraman, dexonsmith, mehdi_amini, emaste, arichardson, steven_wu, llvm-commits

Differential Revision: https://reviews.llvm.org/D47904

llvm-svn: 337195
This commit is contained in:
Yunlian Jiang 2018-07-16 17:55:48 +00:00
parent 8a5083df53
commit 496fb3e7a0
5 changed files with 26 additions and 0 deletions

View File

@ -80,6 +80,7 @@ struct Configuration {
llvm::StringMap<uint64_t> SectionStartMap;
llvm::StringRef Chroot;
llvm::StringRef DynamicLinker;
llvm::StringRef DwoDir;
llvm::StringRef Entry;
llvm::StringRef Emulation;
llvm::StringRef Fini;

View File

@ -727,6 +727,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) {
Config->Demangle = Args.hasFlag(OPT_demangle, OPT_no_demangle, true);
Config->DisableVerify = Args.hasArg(OPT_disable_verify);
Config->Discard = getDiscard(Args);
Config->DwoDir = Args.getLastArgValue(OPT_plugin_opt_dwo_dir_eq);
Config->DynamicLinker = getDynamicLinker(Args);
Config->EhFrameHdr =
Args.hasFlag(OPT_eh_frame_hdr, OPT_no_eh_frame_hdr, false);

View File

@ -99,6 +99,7 @@ static lto::Config createConfig() {
C.SampleProfile = Config->LTOSampleProfile;
C.UseNewPM = Config->LTONewPassManager;
C.DebugPassManager = Config->LTODebugPassManager;
C.DwoDir = Config->DwoDir;
if (Config->SaveTemps)
checkError(C.addSaveTemps(Config->OutputFile.str() + ".",

View File

@ -432,6 +432,8 @@ def: J<"plugin-opt=O">, Alias<lto_O>, HelpText<"Alias for -lto-O">;
def: F<"plugin-opt=debug-pass-manager">,
Alias<lto_debug_pass_manager>, HelpText<"Alias for -lto-debug-pass-manager">;
def: F<"plugin-opt=disable-verify">, Alias<disable_verify>, HelpText<"Alias for -disable-verify">;
def plugin_opt_dwo_dir_eq: J<"plugin-opt=dwo_dir=">,
HelpText<"Directory to store .dwo files when LTO and debug fission are used">;
def: J<"plugin-opt=jobs=">, Alias<thinlto_jobs>, HelpText<"Alias for -thinlto-jobs">;
def: J<"plugin-opt=lto-partitions=">, Alias<lto_partitions>, HelpText<"Alias for -lto-partitions">;
def plugin_opt_mcpu_eq: J<"plugin-opt=mcpu=">;

View File

@ -0,0 +1,21 @@
; REQUIRES: x86
; RUN: opt %s -o %t1.o
; Test to ensure that --plugin-opt=dwo_dir=$DIR creates .dwo files under $DIR
; RUN: ld.lld --plugin-opt=dwo_dir=%T/dwo -shared %t1.o -o /dev/null
; RUN: llvm-readobj -h %T/dwo/0.dwo | FileCheck %s
; RUN: rm -rf %T/dwo
; CHECK: Format: ELF64-x86-64
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
declare void @g(...)
define void @f() {
entry:
call void (...) @g()
ret void
}