Commit 437f65d0 authored by Scott Little's avatar Scott Little Committed by Commit Bot

Revert "mac: Use response files instead of -filelist, but just a little bit."

This reverts commit 9912841b.

Reason for revert: The linker has started segfaulting consistently: https://ci.chromium.org/p/chromium/builders/ci/Mac%20Builder/124684

Original change's description:
> mac: Use response files instead of -filelist, but just a little bit.
>
> This is a partial reland of
> https://chromium-review.googlesource.com/c/chromium/src/+/2530350
>
> For reasons not yet understood, that change sometimes makes the
> linker segfault -- but only hours after it goes in. But once it
> happens, it's sticky.
>
> So reland a smaller version of this change to see if it still happens.
> - Use `-Wl,@rsp` instead of `@rsp` so that the clang driver doesn't
>   read the response file just to write it out again -- instead we
>   pass the response file to the linker directly for now.
> - Only put {{inputs}} in the response file for now, not yet
>   {{frameworks}} {{swiftmodules}} {{solibs}} {{libs}}
>
> Bug: 1147968
> Change-Id: If5c03c881e2469fa2a3c1d3297975ef4c3d19587
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2538011
> Commit-Queue: Nico Weber <thakis@chromium.org>
> Auto-Submit: Nico Weber <thakis@chromium.org>
> Reviewed-by: Mark Mentovai <mark@chromium.org>
> Reviewed-by: Brett Wilson <brettw@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#827424}

TBR=thakis@chromium.org,brettw@chromium.org,mark@chromium.org

Change-Id: Ibdb3f64f745e89d63ab5df2dec2c6bda55bdf7d7
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1147968
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2538177Reviewed-by: default avatarScott Little <sclittle@chromium.org>
Commit-Queue: Scott Little <sclittle@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827437}
parent ed34bf95
...@@ -310,21 +310,14 @@ template("mac_toolchain") { ...@@ -310,21 +310,14 @@ template("mac_toolchain") {
link_command += " -Wl,-install_name,@rpath/\"{{target_output_name}}{{output_extension}}\" " link_command += " -Wl,-install_name,@rpath/\"{{target_output_name}}{{output_extension}}\" "
} }
link_command += dsym_switch link_command += dsym_switch
link_command += "{{ldflags}} -o \"$dylib\" -Wl,-filelist,\"$rspfile\" {{frameworks}} {{swiftmodules}} {{solibs}} {{libs}}"
# TODO(https://crbug.com/1147968): Try replacing -Wl,@ with just @ here,
# or use -L,@ in gcc_toolchain.gni too. With -Wl,@, the linker reads
# the response file and the compiler driver just passes on the flag
# verbatim. With @ without -Wl, the compiler driver reads the response
# file and then writes the arguments to the linker to a separate response
# file if the contents are long enough.
link_command += "{{ldflags}} -o \"$dylib\" -Wl,@\"$rspfile\" {{frameworks}} {{swiftmodules}} {{solibs}} {{libs}}"
replace_command = "if ! cmp -s \"$temporary_tocname\" \"$tocname\"; then mv \"$temporary_tocname\" \"$tocname\"" replace_command = "if ! cmp -s \"$temporary_tocname\" \"$tocname\"; then mv \"$temporary_tocname\" \"$tocname\""
extract_toc_command = "{ $otool -l \"$dylib\" | grep LC_ID_DYLIB -A 5; $nm -gPp \"$dylib\" | cut -f1-2 -d' ' | grep -v U\$\$; true; }" extract_toc_command = "{ $otool -l \"$dylib\" | grep LC_ID_DYLIB -A 5; $nm -gPp \"$dylib\" | cut -f1-2 -d' ' | grep -v U\$\$; true; }"
command = "if $does_reexport_command ; then $link_command && $extract_toc_command > \"$tocname\"; else $link_command && $extract_toc_command > \"$temporary_tocname\" && $replace_command ; fi; fi" command = "if $does_reexport_command ; then $link_command && $extract_toc_command > \"$tocname\"; else $link_command && $extract_toc_command > \"$temporary_tocname\" && $replace_command ; fi; fi"
rspfile_content = "{{inputs}}" rspfile_content = "{{inputs_newline}}"
description = "SOLINK {{output}}" description = "SOLINK {{output}}"
...@@ -364,13 +357,7 @@ template("mac_toolchain") { ...@@ -364,13 +357,7 @@ template("mac_toolchain") {
rspfile = sofile + ".rsp" rspfile = sofile + ".rsp"
pool = "//build/toolchain:link_pool($default_toolchain)" pool = "//build/toolchain:link_pool($default_toolchain)"
# TODO(https://crbug.com/1147968): Try replacing -Wl,@ with just @ here, link_command = "$linker_driver $ld -bundle {{ldflags}} -o \"$sofile\" -Wl,-filelist,\"$rspfile\""
# or use -L,@ in gcc_toolchain.gni too. With -Wl,@, the linker reads
# the response file and the compiler driver just passes on the flag
# verbatim. With @ without -Wl, the compiler driver reads the response
# file and then writes the arguments to the linker to a separate response
# file if the contents are long enough.
link_command = "$linker_driver $ld -bundle {{ldflags}} -o \"$sofile\" -Wl,@\"$rspfile\""
if (is_component_build) { if (is_component_build) {
link_command += " -Wl,-install_name,@rpath/{{target_output_name}}{{output_extension}}" link_command += " -Wl,-install_name,@rpath/{{target_output_name}}{{output_extension}}"
} }
...@@ -378,7 +365,7 @@ template("mac_toolchain") { ...@@ -378,7 +365,7 @@ template("mac_toolchain") {
link_command += " {{frameworks}} {{swiftmodules}} {{solibs}} {{libs}}" link_command += " {{frameworks}} {{swiftmodules}} {{solibs}} {{libs}}"
command = link_command command = link_command
rspfile_content = "{{inputs}}" rspfile_content = "{{inputs_newline}}"
description = "SOLINK_MODULE {{output}}" description = "SOLINK_MODULE {{output}}"
...@@ -403,15 +390,17 @@ template("mac_toolchain") { ...@@ -403,15 +390,17 @@ template("mac_toolchain") {
rspfile = "$outfile.rsp" rspfile = "$outfile.rsp"
pool = "//build/toolchain:link_pool($default_toolchain)" pool = "//build/toolchain:link_pool($default_toolchain)"
# TODO(https://crbug.com/1147968): Try replacing -Wl,@ with just @ here, # Note about -filelist: Apple's linker reads the file list file and
# or use -L,@ in gcc_toolchain.gni too. With -Wl,@, the linker reads # interprets each newline-separated chunk of text as a file name. It
# the response file and the compiler driver just passes on the flag # doesn't do the things one would expect from the shell like unescaping
# verbatim. With @ without -Wl, the compiler driver reads the response # or handling quotes. In contrast, when Ninja finds a file name with
# file and then writes the arguments to the linker to a separate response # spaces, it single-quotes them in $inputs_newline as it would normally
# file if the contents are long enough. # do for command-line arguments. Thus any source names with spaces, or
command = "$linker_driver $ld $dsym_switch {{ldflags}} -o \"$outfile\" -Wl,@\"$rspfile\" {{frameworks}} {{swiftmodules}} {{solibs}} {{libs}}" # label names with spaces (which GN bases the output paths on) will be
# corrupted by this process. Don't use spaces for source files or labels.
command = "$linker_driver $ld $dsym_switch {{ldflags}} -o \"$outfile\" -Wl,-filelist,\"$rspfile\" {{frameworks}} {{swiftmodules}} {{solibs}} {{libs}}"
description = "LINK $outfile" description = "LINK $outfile"
rspfile_content = "{{inputs}}" rspfile_content = "{{inputs_newline}}"
outputs = [ outfile ] outputs = [ outfile ]
if (_enable_dsyms) { if (_enable_dsyms) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment