Mixing FullLTO and ThinLTO objects results in a backend crash in ld64

Originator:bertalan.daniel.laszlo
Number:rdar://FB10663394 Date Originated:
Status:Open Resolved:
Product:Developer tools Product Version:
Classification: Reproducible:
 
ld64 crashes when invoking clang with -flto and a mix of FullLTO and ThinLTO objects.

Create the following 3 files with the contents as described below:
$ cat a.c
int b();
int a() { return b(); }
$ cat b.c
int b() { return 0; }
$ cat main.c
int a();
int main() { return a(); }

Compile a.c in FullLTO mode, and b.c in ThinLTO mode:
$ clang -c -flto a.c
$ clang -c -flto=thin b.c

Compile main.c in FullLTO mode, and invoke the linker:
$ clang -flto main.c a.o b.o

Expected behavior:
The created executable is linked successfully, or an error message is shown if such a configuration isn’t expected to work.

What actually happens:
ld64 crashes in the LLVM backend because `-object_path_lto` points to a file, while the backend wants to save ThinLTO temp files into the *directory* specified with `-object_path_lto`.

This message is displayed:
$ clang -flto main.c a.o b.o
LLVM ERROR: Unexistent dir: '/var/folders/36/94h1n3rx1js05ry_50tclgs40000gn/T/cc-3024cb.o'
clang: error: unable to execute command: Abort trap: 6
clang: error: linker command failed due to signal (use -v to see invocation)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!