Thin archives' contents are copied verbatim into the repro tarballs; absolute paths to members don't get changed to be relative to the tarball's root.
I've only come across this problem because I was writing a test, and %t/foo.o expanded to an absolute path. Not sure if this could cause an issue in realistic cases.
This is a small test for it; modified from lld/test/MachO/reproduce-thin-archives.s (ld.lld is likely similarly affected by looking at the code):
# REQUIRES: x86
# RUN: rm -rf %t.dir
# RUN: mkdir -p %t.dir
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos %s -o %t.dir/foo.o
# RUN: llvm-ar rcsT %t.dir/foo.a %t.dir/foo.o
# RUN: cd %t.dir
# RUN: %lld foo.a -o /dev/null --reproduce repro.tar
## Remove the original object to make sure we are not using it.
# RUN: rm foo.o
# RUN: tar xf repro.tar
# RUN: cd repro
# RUN: %lld @response.txt
.globl _main
_main:
nop
Running it gives:
ld64.lld: error: /Users/dani/Source/llvm-project/build/tools/lld/test/MachO/Output/reproduce-thin-archives.s.tmp.dir/foo.a: could not get the member defining symbol _main: '/Users/dani/Source/llvm-project/build/tools/lld/test/MachO/Output/reproduce-thin-archives.s.tmp.dir/foo.o': No such file or directory
When inspecting the archive in the repro file, indeed, the member is referred to by an absolute path:
$ llvm-ar t build/tools/lld/test/MachO/Output/reproduce-thin-archives.s.tmp.dir/repro/Users/dani/Source/llvm-project/build/tools/lld/test/MachO/Output/reproduce-thin-archives.s.tmp.dir/foo.a
/Users/dani/Source/llvm-project/build/tools/lld/test/MachO/Output/reproduce-thin-archives.s.tmp.dir/foo.o
Thin archives' contents are copied verbatim into the repro tarballs; absolute paths to members don't get changed to be relative to the tarball's root.
I've only come across this problem because I was writing a test, and `%t/foo.o` expanded to an absolute path. Not sure if this could cause an issue in realistic cases.
This is a small test for it; modified from `lld/test/MachO/reproduce-thin-archives.s` (`ld.lld` is likely similarly affected by looking at the code):
```asm
# REQUIRES: x86
# RUN: rm -rf %t.dir; mkdir -p %t.dir
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos %s -o %t.dir/foo.o
# RUN: llvm-ar rcsT %t.dir/foo.a %t.dir/foo.o
# RUN: cd %t.dir
# RUN: %lld foo.a -o /dev/null --reproduce repro.tar
## Remove the original object to make sure we are not using it.
# RUN: rm foo.o
# RUN: tar xf repro.tar
# RUN: cd repro
# RUN: %lld @response.txt
.globl _main
_main:
nop
```
Running it gives:
```console
ld64.lld: error: /Users/dani/Source/llvm-project/build/tools/lld/test/MachO/Output/reproduce-thin-archives.s.tmp.dir/foo.a: could not get the member defining symbol _main: '/Users/dani/Source/llvm-project/build/tools/lld/test/MachO/Output/reproduce-thin-archives.s.tmp.dir/foo.o': No such file or directory
```
When inspecting the archive in the repro file, indeed, the member is referred to by an absolute path:
```console
$ llvm-ar t build/tools/lld/test/MachO/Output/reproduce-thin-archives.s.tmp.dir/repro/Users/dani/Source/llvm-project/build/tools/lld/test/MachO/Output/reproduce-thin-archives.s.tmp.dir/foo.a
/Users/dani/Source/llvm-project/build/tools/lld/test/MachO/Output/reproduce-thin-archives.s.tmp.dir/foo.o
```
Thin archives' contents are copied verbatim into the repro tarballs; absolute paths to members don't get changed to be relative to the tarball's root.
I've only come across this problem because I was writing a test, and `%t/foo.o` expanded to an absolute path. Not sure if this could cause an issue in realistic cases.
This is a small test for it; modified from `lld/test/MachO/reproduce-thin-archives.s` (`ld.lld` is likely similarly affected by looking at the code):
```asm
# REQUIRES: x86
# RUN: rm -rf %t.dir; mkdir -p %t.dir
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos %s -o %t.dir/foo.o
# RUN: llvm-ar rcsT %t.dir/foo.a %t.dir/foo.o
# RUN: cd %t.dir
# RUN: %lld foo.a -o /dev/null --reproduce repro.tar
## Remove the original object to make sure we are not using it.
# RUN: rm foo.o
# RUN: tar xf repro.tar
# RUN: cd repro
# RUN: %lld @response.txt
.globl _main
_main:
nop
```
Running it gives:
```console
ld64.lld: error: /Users/dani/Source/llvm-project/build/tools/lld/test/MachO/Output/reproduce-thin-archives.s.tmp.dir/foo.a: could not get the member defining symbol _main: '/Users/dani/Source/llvm-project/build/tools/lld/test/MachO/Output/reproduce-thin-archives.s.tmp.dir/foo.o': No such file or directory
```
When inspecting the archive in the repro file, indeed, the member is referred to by an absolute path:
```console
$ llvm-ar t build/tools/lld/test/MachO/Output/reproduce-thin-archives.s.tmp.dir/repro/Users/dani/Source/llvm-project/build/tools/lld/test/MachO/Output/reproduce-thin-archives.s.tmp.dir/foo.a
/Users/dani/Source/llvm-project/build/tools/lld/test/MachO/Output/reproduce-thin-archives.s.tmp.dir/foo.o
```
Thin archives' contents are copied verbatim into the repro tarballs; absolute paths to members don't get changed to be relative to the tarball's root.
I've only come across this problem because I was writing a test, and
%t/foo.o
expanded to an absolute path. Not sure if this could cause an issue in realistic cases.This is a small test for it; modified from
lld/test/MachO/reproduce-thin-archives.s
(ld.lld
is likely similarly affected by looking at the code):Running it gives:
When inspecting the archive in the repro file, indeed, the member is referred to by an absolute path: