2018-05-17 05:04:08 +08:00
|
|
|
; REQUIRES: x86
|
|
|
|
|
|
|
|
; Test to make sure the thinlto-object-suffix-replace option is handled
|
|
|
|
; correctly.
|
|
|
|
|
|
|
|
; Generate bitcode file with summary, as well as a minimized bitcode without
|
|
|
|
; the debug metadata for the thin link.
|
|
|
|
; RUN: opt -thinlto-bc %s -thin-link-bitcode-file=%t1.thinlink.bc -o %t1.o
|
|
|
|
|
|
|
|
; First perform the thin link on the normal bitcode file, and save the
|
|
|
|
; resulting index.
|
2018-05-31 01:57:08 +08:00
|
|
|
; RUN: ld.lld --plugin-opt=thinlto-index-only -shared %t1.o -o %t3
|
2018-05-17 05:04:08 +08:00
|
|
|
; RUN: cp %t1.o.thinlto.bc %t1.o.thinlto.bc.orig
|
|
|
|
|
|
|
|
; Next perform the thin link on the minimized bitcode file, and compare dump
|
|
|
|
; of the resulting index to the above dump to ensure they are identical.
|
|
|
|
; RUN: rm -f %t1.o.thinlto.bc
|
|
|
|
; Make sure it isn't inadvertently using the regular bitcode file.
|
|
|
|
; RUN: rm -f %t1.o
|
2018-05-31 01:57:08 +08:00
|
|
|
; RUN: ld.lld --plugin-opt=thinlto-index-only \
|
2018-05-17 05:04:08 +08:00
|
|
|
; RUN: --plugin-opt=thinlto-object-suffix-replace=".thinlink.bc;.o" \
|
|
|
|
; RUN: -shared %t1.thinlink.bc -o %t3
|
|
|
|
; RUN: diff %t1.o.thinlto.bc.orig %t1.o.thinlto.bc
|
[ELF] accept thinlto options without --plugin-opt= prefix
Summary:
When support for ThinLTO was first added to lld, the options that
control it were prefixed with --plugin-opt= for compatibility with
an existing implementation as a linker plugin. This change enables
shorter versions of the options to be used, as follows:
New Existing
-thinlto-emit-imports-files --plugin-opt=thinlto-emit-imports-files
-thinlto-index-only --plugin-opt=thinlto-index-only
-thinlto-index-only= --plugin-opt=thinlto-index-only=
-thinlto-object-suffix-replace= --plugin-opt=thinlto-object-suffix-replace=
-thinlto-prefix-replace= --plugin-opt=thinlto-prefix-replace=
-lto-obj-path= --plugin-opt=obj-path=
The options with the --plugin-opt= prefix have been retained as aliases
for the shorter variants so that they continue to be accepted.
Reviewers: tejohnson, ruiu, espindola
Reviewed By: ruiu
Subscribers: emaste, arichardson, MaskRay, steven_wu, dexonsmith, arphaman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67782
llvm-svn: 372798
2019-09-25 09:19:48 +08:00
|
|
|
; Also check that this works without the --plugin-opt= prefix.
|
|
|
|
; RUN: ld.lld -thinlto-index-only \
|
|
|
|
; RUN: -thinlto-object-suffix-replace=".thinlink.bc;.o" \
|
|
|
|
; RUN: -shared %t1.thinlink.bc -o %t3
|
|
|
|
; RUN: diff %t1.o.thinlto.bc.orig %t1.o.thinlto.bc
|
2018-05-17 05:04:08 +08:00
|
|
|
|
|
|
|
; Ensure lld generates error if object suffix replace option does not have 'old;new' format
|
|
|
|
; RUN: rm -f %t1.o.thinlto.bc
|
2018-05-31 01:57:08 +08:00
|
|
|
; RUN: not ld.lld --plugin-opt=thinlto-index-only \
|
2018-05-17 05:04:08 +08:00
|
|
|
; RUN: --plugin-opt=thinlto-object-suffix-replace="abc:def" -shared %t1.thinlink.bc \
|
|
|
|
; RUN: -o %t3 2>&1 | FileCheck %s --check-prefix=ERR1
|
2018-05-22 10:53:11 +08:00
|
|
|
; ERR1: --plugin-opt=thinlto-object-suffix-replace= expects 'old;new' format, but got abc:def
|
2018-05-17 05:04:08 +08:00
|
|
|
|
[ELF] -thinlto-object-suffix-replace=: don't error if the path does not end with old suffix
Summary:
For -thinlto-object-suffix-replace=old\;new, in
tools/gold/gold-plugin.cpp, the thinlto object filename is Path minus
optional old suffix.
static std::string getThinLTOObjectFileName(StringRef Path, StringRef OldSuffix,
StringRef NewSuffix) {
if (OldSuffix.empty() && NewSuffix.empty())
return Path;
StringRef NewPath = Path;
NewPath.consume_back(OldSuffix);
std::string NewNewPath = NewPath;
NewNewPath += NewSuffix;
return NewNewPath;
}
Currently lld will error that the path does not end with old suffix.
This patch makes lld accept such paths but only add new suffix if Path
ends with old suffix. This fixes a link error where bitcode members in
an archive are regular LTO objects without old suffix.
Acording to tejohnson, this will "enable supporting mix and match of
minimized ThinLTO bitcode files with normal ThinLTO bitcode files in a
single link (where we want to apply the suffix replacement to the
minimized files, and just ignore it for the normal ThinLTO files)."
Reviewers: ruiu, pcc, tejohnson, espindola
Reviewed By: tejohnson
Subscribers: emaste, inglorion, arichardson, eraman, steven_wu, dexonsmith, llvm-commits
Differential Revision: https://reviews.llvm.org/D51055
llvm-svn: 340364
2018-08-22 07:28:12 +08:00
|
|
|
; If filename does not end with old suffix, no suffix change should occur,
|
|
|
|
; so ".thinlto.bc" will simply be appended to the input file name.
|
|
|
|
; RUN: rm -f %t1.thinlink.bc.thinlto.bc
|
|
|
|
; RUN: ld.lld --plugin-opt=thinlto-index-only \
|
|
|
|
; RUN: --plugin-opt=thinlto-object-suffix-replace=".abc;.o" -shared %t1.thinlink.bc -o /dev/null
|
|
|
|
; RUN: ls %t1.thinlink.bc.thinlto.bc
|
2018-05-17 05:04:08 +08:00
|
|
|
|
2019-09-11 07:15:38 +08:00
|
|
|
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
2018-05-17 05:04:08 +08:00
|
|
|
target triple = "x86_64-unknown-linux-gnu"
|
|
|
|
|
|
|
|
define void @f() {
|
|
|
|
entry:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
!llvm.dbg.cu = !{}
|
|
|
|
|
|
|
|
!1 = !{i32 2, !"Debug Info Version", i32 3}
|
|
|
|
!llvm.module.flags = !{!1}
|