This is an archive of the discontinued LLVM Phabricator instance.

clang/darwin: Don't use response files with ld64
ClosedPublic

Authored by thakis on Nov 30 2020, 5:13 PM.

Details

Summary

This morally reverts D82777 -- turns out that ld64 crashes with many
response files, so we must stop passing them to it until the crash is
fixed.

Diff Detail

Event Timeline

thakis requested review of this revision.Nov 30 2020, 5:13 PM
thakis created this revision.
keith added a subscriber: keith.Nov 30 2020, 5:21 PM

Note in your repro case the issue is that the response file doesn't end in a trailing newline

Note in your repro case the issue is that the response file doesn't end in a trailing newline

Hm, we also see crashes if we let clang write the response file that's passed to ld64 though. (ie we see this both with clang @foo.rsp -o a.out and clang -Wl,@foo.rsp -o a.out.

keith added a comment.Nov 30 2020, 6:19 PM

It looks like at least in the -Wl case clang passes the file through directly, so I'm not surprises that it repros there:

% clang -Wl,@shell_dialogs_unittests.rsp -v
Apple clang version 12.0.0 (clang-1200.0.32.27)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode-12.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
 "/Applications/Xcode-12.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -lto_library /Applications/Xcode-12.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib -dynamic -arch x86_64 -platform_version macos 10.15.0 10.15.6 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -o a.out -L/usr/local/lib @shell_dialogs_unittests.rsp -lSystem /Applications/Xcode-12.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/lib/darwin/libclang_rt.osx.a
clang: error: unable to execute command: Segmentation fault: 11
clang: error: linker command failed due to signal (use -v to see invocation)

I _don't_ actually see this reproing when using clang @shell_dialogs_unittests.rsp:

% /Users/ksmiley/dev/llvm-project/build/bin/clang-12 @shell_dialogs_unittests.rsp
clang version 12.0.0 (https://github.com/llvm/llvm-project bbf02e18f53681c079f7a88b2726d0714d92e1a0)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Users/ksmiley/dev/llvm-project/build/bin
 "/usr/bin/ld" @/var/folders/h6/6btvg47n7y1f5xxz4_n9rsd40000gn/T/response-5a15ec.txt

Which I believe makes sense because clang is processing each argument and writing the response file itself.

Is there any other case you've hit besides the missing trailing newline that causes this issue? While I'm sure Apple will fix that in due time I wonder if that's considered a "valid enough" response to warrant the revert here.

It looks like at least in the -Wl case clang passes the file through directly,

Right, that's my point: We see crashes around response files even if we let clang write it.

I _don't_ actually see this reproing when using clang @shell_dialogs_unittests.rsp:

Yes, it's much more fickle to repro . See https://bugs.chromium.org/p/chromium/issues/detail?id=1147968 (linked to from the openrdar): We tried passing response files to clang instead of -Wl,-filelist like we currently do in Chromium and after a while (within about a day after the change landing; after hours after 2nd attempt) ld64 started crashing. I failed to repro this locally. With -Wl,@foo.rsp the crash reprod locally immediately (and appeared on the bots immediately), so that's what I used for filing the rdar. But even with clang writing the response file, we found ld64 to be unusuably crashy.

thakis added a comment.Dec 1 2020, 8:48 AM

Extracted the darwinnew bits to D92399. Will rebase this once that's in.

thakis updated this revision to Diff 308684.Dec 1 2020, 9:10 AM
thakis edited the summary of this revision. (Show Details)

rebase

thakis retitled this revision from clang/darwin: Don't use response files with ld64, do use them with ld64.lld.darwinnew to clang/darwin: Don't use response files with ld64.Dec 1 2020, 9:10 AM
hans accepted this revision.Dec 1 2020, 9:59 AM
hans added a subscriber: hans.

lgtm

This revision is now accepted and ready to land.Dec 1 2020, 9:59 AM
keith added a comment.Dec 1 2020, 10:01 AM

I'm a bit worried that without a repro case (outside of the missing newline) Apple won't get around to fixing this, and in the meantime I'm wondering if outside of the chromium build system folks will experience this. I wonder if there's an acceptable alternative here such as adding a (ideally temporary) flag to force the old behavior?

I'm a bit worried that without a repro case (outside of the missing newline) Apple won't get around to fixing this, and in the meantime I'm wondering if outside of the chromium build system folks will experience this. I wonder if there's an acceptable alternative here such as adding a (ideally temporary) flag to force the old behavior?

Chromium just lets ninja write the rsp file, like many projects.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptDec 3 2020, 6:00 AM