From 1aae55ddea92c9a0eb1024305b248f20653778a2 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Thu, 3 Jun 2021 15:29:22 -0400 Subject: [PATCH] [lld/mac] Add test coverage for --reproduce + -flat_namespace Works fine already, now it has a test too. Differential Revision: https://reviews.llvm.org/D103643 --- lld/test/MachO/flat-namespace.s | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/lld/test/MachO/flat-namespace.s b/lld/test/MachO/flat-namespace.s index f15bb96..2ac3b29 100644 --- a/lld/test/MachO/flat-namespace.s +++ b/lld/test/MachO/flat-namespace.s @@ -12,10 +12,10 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/main.o %t/main.s -# With flat_namespace, the linker automatically looks in foo.dylib and -# bar.dylib too, but it doesn't add a LC_LOAD_DYLIB for it. -# RUN: %lld -flat_namespace -lSystem %t/main.o %t/baz.dylib -o %t/out -t | \ -# RUN: FileCheck --check-prefix=T %s +## With flat_namespace, the linker automatically looks in foo.dylib and +## bar.dylib too, but it doesn't add a LC_LOAD_DYLIB for it. +# RUN: %lld -flat_namespace -lSystem %t/main.o %t/baz.dylib -o %t/out -t \ +# RUN: --reproduce %t/repro.tar | FileCheck --check-prefix=T %s ## FIXME: The `bar.dylib` line should use `T-NEXT`, but on Windows we load ## libSystem.tbd with different slash styles and end up loading it twice ## for that reason. @@ -29,6 +29,11 @@ # RUN: | FileCheck --check-prefix=FLAT %s # RUN: llvm-nm -m %t/out | FileCheck --check-prefix=FLATSYM %s # RUN: llvm-readobj --syms %t/out | FileCheck --check-prefix=FLATSYM-READOBJ %s +# RUN: cd %t +# RUN: tar -tf repro.tar | FileCheck -DPATH='%:t.dir' --check-prefix=REPRO %s +# RUN: tar -xf repro.tar repro/response.txt +# RUN: FileCheck --implicit-check-not=dylib --check-prefix=RESPONSE %s \ +# RUN: < %t/repro/response.txt # HEADERBITS-NOT: NOUNDEFS # HEADERBITS-NOT: TWOLEVEL @@ -43,15 +48,23 @@ # FLAT-DAG: __DATA __la_symbol_ptr 0x{{[0-9a-f]*}} flat-namespace _baz # FLAT-DAG: __DATA __la_symbol_ptr 0x{{[0-9a-f]*}} flat-namespace _foo -# No "(dynamically looked up)" because llvm-nm -m doesn't print that -# for files without MH_TWOLEVEL for some reason. +## No "(dynamically looked up)" because llvm-nm -m doesn't print that +## for files without MH_TWOLEVEL for some reason. # FLATSYM: (undefined) external _bar # FLATSYM: (undefined) external _baz # FLATSYM: (undefined) external _foo -# ...but `llvm-readobj --syms` does, so verify we put the right thing there. +## ...but `llvm-readobj --syms` does, so verify we put the right thing there. # FLATSYM-READOBJ: Flags [ (0xFE00) +## All 3 .dylibs should be in a --reproduce archive. +# REPRO: baz.dylib +# REPRO: bar.dylib +# REPRO: foo.dylib + +## ...but only baz.dylib should be in the response file: +# RESPONSE: baz.dylib + # Undefined symbols should still cause errors by default. # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos \ # RUN: -o %t/main-with-undef.o %t/main-with-undef.s -- 2.7.4