Commit 5e46febb authored by Nico Weber's avatar Nico Weber Committed by Commit Bot

mac/ios: Use real response files instead of -filelist.

Xcode 12 added support for real response files, so let's use them.
Allows making response file contents more like on other systems
(libs, solibs, frameworks, swiftmodules now go in the rsp file too),
and makes it theoretically possible to have object files with spaces
in their name.

No intentional behavior change.

Bug: none
Change-Id: I8c2d6ff1abd47261bf7674dc7bf4506814681ad4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2527621
Auto-Submit: Nico Weber <thakis@chromium.org>
Commit-Queue: Brett Wilson <brettw@chromium.org>
Reviewed-by: default avatarBrett Wilson <brettw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825480}
parent afa86174
...@@ -266,20 +266,12 @@ template("mac_toolchain") { ...@@ -266,20 +266,12 @@ template("mac_toolchain") {
script = script =
rebase_path("//build/toolchain/mac/filter_libtool.py", root_build_dir) rebase_path("//build/toolchain/mac/filter_libtool.py", root_build_dir)
# Note about -filelist: Apple's linker reads the file list file and
# interprets each newline-separated chunk of text as a file name. It
# doesn't do the things one would expect from the shell like unescaping
# or handling quotes. In contrast, when Ninja finds a file name with
# spaces, it single-quotes them in $inputs_newline as it would normally
# do for command-line arguments. Thus any source names with spaces, or
# 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.
rspfile = "{{output}}.rsp" rspfile = "{{output}}.rsp"
rspfile_content = "{{inputs_newline}}" rspfile_content = "{{inputs}}"
# Specify explicit path for libtool. # Specify explicit path for libtool.
libtool = mac_bin_path + "libtool" libtool = mac_bin_path + "libtool"
command = "rm -f {{output}} && TOOL_VERSION=${tool_versions.filter_libtool} python $script $libtool -static -D {{arflags}} -o {{output}} -filelist $rspfile" command = "rm -f {{output}} && TOOL_VERSION=${tool_versions.filter_libtool} python $script $libtool -static -D {{arflags}} -o {{output}} \"@$rspfile\""
description = "LIBTOOL-STATIC {{output}}" description = "LIBTOOL-STATIC {{output}}"
outputs = [ "{{output_dir}}/{{target_output_name}}{{output_extension}}" ] outputs = [ "{{output_dir}}/{{target_output_name}}{{output_extension}}" ]
default_output_dir = "{{target_out_dir}}" default_output_dir = "{{target_out_dir}}"
...@@ -318,14 +310,15 @@ template("mac_toolchain") { ...@@ -318,14 +310,15 @@ 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}}" link_command += "{{ldflags}} -o \"$dylib\" @\"$rspfile\""
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_newline}}" rspfile_content =
"{{inputs}} {{frameworks}} {{swiftmodules}} {{solibs}} {{libs}}"
description = "SOLINK {{output}}" description = "SOLINK {{output}}"
...@@ -365,15 +358,16 @@ template("mac_toolchain") { ...@@ -365,15 +358,16 @@ template("mac_toolchain") {
rspfile = sofile + ".rsp" rspfile = sofile + ".rsp"
pool = "//build/toolchain:link_pool($default_toolchain)" pool = "//build/toolchain:link_pool($default_toolchain)"
link_command = "$linker_driver $ld -bundle {{ldflags}} -o \"$sofile\" -Wl,-filelist,\"$rspfile\"" link_command =
"$linker_driver $ld -bundle {{ldflags}} -o \"$sofile\" @\"$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}}"
} }
link_command += dsym_switch link_command += dsym_switch
link_command += " {{frameworks}} {{swiftmodules}} {{solibs}} {{libs}}"
command = link_command command = link_command
rspfile_content = "{{inputs_newline}}" rspfile_content =
"{{inputs}} {{frameworks}} {{swiftmodules}} {{solibs}} {{libs}}"
description = "SOLINK_MODULE {{output}}" description = "SOLINK_MODULE {{output}}"
...@@ -398,17 +392,10 @@ template("mac_toolchain") { ...@@ -398,17 +392,10 @@ template("mac_toolchain") {
rspfile = "$outfile.rsp" rspfile = "$outfile.rsp"
pool = "//build/toolchain:link_pool($default_toolchain)" pool = "//build/toolchain:link_pool($default_toolchain)"
# Note about -filelist: Apple's linker reads the file list file and command = "$linker_driver $ld $dsym_switch {{ldflags}} -o \"$outfile\" @\"$rspfile\""
# interprets each newline-separated chunk of text as a file name. It
# doesn't do the things one would expect from the shell like unescaping
# or handling quotes. In contrast, when Ninja finds a file name with
# spaces, it single-quotes them in $inputs_newline as it would normally
# do for command-line arguments. Thus any source names with spaces, or
# 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_newline}}" rspfile_content =
"{{inputs}} {{frameworks}} {{swiftmodules}} {{solibs}} {{libs}}"
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