-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[lld][test] Precommit test for ld -r links with FatLTO PIC objects #92817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
7ae4266
c09de94
44140c1
f02bd6e
cded743
8318fad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,23 @@ | |
; RUN: rm -rf %t && split-file %s %t | ||
|
||
;; Ensure that input files contain .llvm.lto section. | ||
; RUN: llc %t/a-LTO.ll --filetype=obj -o %t/a-fatLTO.o | ||
; RUN: llc %t/a-LTO.ll --filetype=obj -o %t/a-fatLTO.o --relocation-model=pic | ||
; RUN: opt < %t/a-LTO.ll --module-summary -o %t/a-fatLTO.bc | ||
; RUN: llvm-objcopy --add-section=.llvm.lto=%t/a-fatLTO.bc --set-section-flags=.llvm.lto=exclude %t/a-fatLTO.o | ||
; RUN: llvm-objcopy --add-section=.llvm.lto=%t/a-fatLTO.bc --set-section-flags=.llvm.lto=exclude --set-section-type=.llvm.lto=0x6fff4c0c %t/a-fatLTO.o | ||
|
||
; RUN: llc %t/main-LTO.ll --filetype=obj -o %t/main-fatLTO.o | ||
|
||
; RUN: llc %t/main-LTO.ll --filetype=obj -o %t/main-fatLTO.o --relocation-model=pic | ||
; RUN: opt < %t/main-LTO.ll --module-summary -o %t/main-fatLTO.bc | ||
; RUN: llvm-objcopy --add-section=.llvm.lto=%t/main-fatLTO.bc --set-section-flags=.llvm.lto=exclude %t/main-fatLTO.o | ||
; RUN: llvm-objcopy --add-section=.llvm.lto=%t/main-fatLTO.bc --set-section-flags=.llvm.lto=exclude --set-section-type=.llvm.lto=0x6fff4c0c %t/main-fatLTO.o | ||
|
||
; RUN: llvm-readobj -S %t/a-fatLTO.o | FileCheck --check-prefix=HAS_LLVM_LTO %s | ||
; RUN: llvm-readobj -S %t/main-fatLTO.o | FileCheck --check-prefix=HAS_LLVM_LTO %s | ||
|
||
;; Make sure that the section flags are set correctly | ||
; HAS_LLVM_LTO: Name: .llvm.lto | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, newer tests probably should consider There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That seems to work fine, so I've updated the checks in this file. |
||
; HAS_LLVM_LTO-NEXT: Type: SHT_LLVM_LTO | ||
; HAS_LLVM_LTO-NEXT: Flags | ||
; HAS_LLVM_LTO-NEXT: SHF_EXCLUDE | ||
|
||
;; Final executable should not have .llvm.lto section no matter what the target is. | ||
; RUN: ld.lld -o %t/foo-fatLTO %t/a-fatLTO.o %t/main-fatLTO.o --fat-lto-objects | ||
|
@@ -49,6 +59,17 @@ | |
; RUN: ld.lld -o %t/foo-fatLTO.archive %t/a.a %t/main-LTO.bc --fat-lto-objects | ||
; RUN: cmp %t/foo-fatLTO.archive %t/foo-LTO | ||
|
||
;; Test FatLTO works with relocatable links using PIC objects | ||
;; Currently, with PIC relocatable links, FatLTO sections are treated as | ||
;; orphan sections and incorrectly concatenated together. This test verifies | ||
;; the current behavior, but should be fixed to either merge those sections | ||
;; correctly, or to drop them altogether. | ||
; RUN: llvm-ar rcs %t/fatLTO-pic.a %t/a-fatLTO.o %t/main-fatLTO.o | ||
; RUN: llvm-readobj -S %t/fatLTO-pic.a | FileCheck --check-prefix=HAS_LLVM_LTO %s | ||
|
||
; RUN: ld.lld --whole-archive %t/fatLTO-pic.a -r -o %t/fatLTO-pic-reolcatable.o | ||
; RUN: llvm-readobj -S %t/fatLTO-pic-reolcatable.o | FileCheck --check-prefix=HAS_LLVM_LTO %s | ||
|
||
;--- a-LTO.ll | ||
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-unknown-linux-gnu" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The number of
%t
occurrences is large now.Perhaps we should switch to
; RUN: rm -rf %t && split-file %s %t && cd %t
and remove these%t/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that you prefer the
cd
approach, but I find it hard to re-run commands that require acd
into a temp directory when iterating on tests. Leaving%t/
in the paths allow me to easily copy the failing command and run it from the build directory. If you feel strongly, I can still change it, but my preference is to leave this as is.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MaskRay , just double checking that you're OK with this as is before I land this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the test is complex enough that removing some
%t/
occurrences will help readability...I don't use llvm-lit for one-shot test invocation. I use
ff fatlto.test
and it's quite straightforward to copy & paste one single command...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, while I'm going to change the test to your preferred format,
LIT_FILTER=
has been a great way to run some subset of tests, and when it fails, I can examine the intermediate outputs by just copying the printedRUN: ...
command. In the case where there is a directory change at the top of the test, I can't just grab that command and run it without either figuring out which directory to CD into or prepending the correct prefix to every path in the command. To me the directory change is an anti-pattern that blocks a workflow used extensivly by other developers. It was even mentioned recently on discourse when the output from LIT was modified, https://discourse.llvm.org/t/rfc-improving-lits-debug-output/72839.For me getting something I can copy, like:
is really convenient. While the script you provided seems useful, I'd rather not have to use a script just to run a single shell command that I often want to edit by adding different flags or capturing its output.