Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for params files for darwin #12265

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,10 @@ boolean canSplitCommandLine() {
case PIC_STATIC_LIBRARY:
case ALWAYS_LINK_STATIC_LIBRARY:
case ALWAYS_LINK_PIC_STATIC_LIBRARY:
case OBJC_ARCHIVE:
case OBJC_FULLY_LINKED_ARCHIVE:
case OBJC_EXECUTABLE:
case OBJCPP_EXECUTABLE:
return true;

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,7 @@ CompilationSupport registerLinkActions(
ruleContext,
ruleContext.getLabel(),
binaryToLink,
ruleContext.getConfiguration(),
buildConfiguration,
toolchain,
toolchain.getFdoContext(),
getFeatureConfiguration(ruleContext, toolchain, buildConfiguration),
Expand Down Expand Up @@ -1358,7 +1358,7 @@ CompilationSupport registerFullyLinkAction(ObjcProvider objcProvider, Artifact o
ruleContext,
ruleContext.getLabel(),
outputArchive,
ruleContext.getConfiguration(),
buildConfiguration,
toolchain,
toolchain.getFdoContext(),
getFeatureConfiguration(ruleContext, toolchain, buildConfiguration),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,18 @@ public void testCommandLineSplitting() throws Exception {
builder.setLinkType(LinkTargetType.STATIC_LIBRARY);
assertThat(builder.canSplitCommandLine()).isTrue();

builder.setLinkType(LinkTargetType.OBJC_ARCHIVE);
assertThat(builder.canSplitCommandLine()).isTrue();

builder.setLinkType(LinkTargetType.OBJC_EXECUTABLE);
assertThat(builder.canSplitCommandLine()).isTrue();

builder.setLinkType(LinkTargetType.OBJCPP_EXECUTABLE);
assertThat(builder.canSplitCommandLine()).isTrue();

builder.setLinkType(LinkTargetType.OBJC_FULLY_LINKED_ARCHIVE);
assertThat(builder.canSplitCommandLine()).isTrue();

builder.setLinkType(LinkTargetType.NODEPS_DYNAMIC_LIBRARY);
assertThat(builder.canSplitCommandLine()).isTrue();

Expand Down
12 changes: 0 additions & 12 deletions src/test/shell/integration/aquery_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -711,10 +711,6 @@ EOF
}

function test_aquery_include_param_file_cc_binary() {
if is_darwin; then
return 0
fi

local pkg="${FUNCNAME[0]}"
mkdir -p "$pkg" || fail "mkdir -p $pkg"
cat > "$pkg/BUILD" <<'EOF'
Expand All @@ -739,10 +735,6 @@ EOF
}

function test_aquery_include_param_file_starlark_rule() {
if is_darwin; then
return 0
fi

local pkg="${FUNCNAME[0]}"
mkdir -p "$pkg" || fail "mkdir -p $pkg"
cat > "$pkg/test_rule.bzl" <<'EOF'
Expand Down Expand Up @@ -793,10 +785,6 @@ EOF
}

function test_aquery_include_param_file_not_enabled_by_default() {
if is_darwin; then
return 0
fi

local pkg="${FUNCNAME[0]}"
mkdir -p "$pkg" || fail "mkdir -p $pkg"
cat > "$pkg/BUILD" <<'EOF'
Expand Down
2 changes: 1 addition & 1 deletion tools/cpp/BUILD.tools
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ cc_toolchain(
linker_files = ":osx_wrapper",
objcopy_files = ":empty",
strip_files = ":empty",
supports_param_files = 0,
supports_param_files = 1,
toolchain_config = ":local_darwin",
toolchain_identifier = "local_darwin",
)
Expand Down
2 changes: 1 addition & 1 deletion tools/cpp/BUILD.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ cc_toolchain(
linker_files = ":compiler_deps",
objcopy_files = ":empty",
strip_files = ":empty",
supports_param_files = %{supports_param_files},
keith marked this conversation as resolved.
Show resolved Hide resolved
supports_param_files = 1,
module_map = %{modulemap},
)

Expand Down
27 changes: 20 additions & 7 deletions tools/cpp/osx_cc_wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,33 @@ LIBS=
LIB_DIRS=
RPATHS=
OUTPUT=
# let parse the option list
for i in "$@"; do

function parse_option() {
local -r opt="$1"
if [[ "${OUTPUT}" = "1" ]]; then
OUTPUT=$i
elif [[ "$i" =~ ^-l(.*)$ ]]; then
OUTPUT=$opt
elif [[ "$opt" =~ ^-l(.*)$ ]]; then
LIBS="${BASH_REMATCH[1]} $LIBS"
elif [[ "$i" =~ ^-L(.*)$ ]]; then
elif [[ "$opt" =~ ^-L(.*)$ ]]; then
LIB_DIRS="${BASH_REMATCH[1]} $LIB_DIRS"
elif [[ "$i" =~ ^-Wl,-rpath,\@loader_path/(.*)$ ]]; then
elif [[ "$opt" =~ ^-Wl,-rpath,\@loader_path/(.*)$ ]]; then
RPATHS="${BASH_REMATCH[1]} ${RPATHS}"
elif [[ "$i" = "-o" ]]; then
elif [[ "$opt" = "-o" ]]; then
# output is coming
OUTPUT=1
fi
}

# let parse the option list
for i in "$@"; do
if [[ "$i" = @* ]]; then
while IFS= read -r opt
do
parse_option "$opt"
done < "${i:1}" || exit 1
else
parse_option "$i"
fi
done

# Call gcc
Expand Down
27 changes: 20 additions & 7 deletions tools/cpp/osx_cc_wrapper.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,33 @@ LIBS=
LIB_DIRS=
RPATHS=
OUTPUT=
# let parse the option list
for i in "$@"; do

function parse_option() {
local -r opt="$1"
if [[ "${OUTPUT}" = "1" ]]; then
OUTPUT=$i
elif [[ "$i" =~ ^-l(.*)$ ]]; then
OUTPUT=$opt
elif [[ "$opt" =~ ^-l(.*)$ ]]; then
LIBS="${BASH_REMATCH[1]} $LIBS"
elif [[ "$i" =~ ^-L(.*)$ ]]; then
elif [[ "$opt" =~ ^-L(.*)$ ]]; then
LIB_DIRS="${BASH_REMATCH[1]} $LIB_DIRS"
elif [[ "$i" =~ ^-Wl,-rpath,\@loader_path/(.*)$ ]]; then
elif [[ "$opt" =~ ^-Wl,-rpath,\@loader_path/(.*)$ ]]; then
RPATHS="${BASH_REMATCH[1]} ${RPATHS}"
elif [[ "$i" = "-o" ]]; then
elif [[ "$opt" = "-o" ]]; then
# output is coming
OUTPUT=1
fi
}

# let parse the option list
for i in "$@"; do
if [[ "$i" = @* ]]; then
while IFS= read -r opt
do
parse_option "$opt"
done < "${i:1}" || exit 1
else
parse_option "$i"
fi
done

# Set-up the environment
Expand Down
1 change: 0 additions & 1 deletion tools/cpp/unix_cc_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,6 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools):
"%{cc_toolchain_identifier}": cc_toolchain_identifier,
"%{name}": cpu_value,
"%{modulemap}": ("\":module.modulemap\"" if is_clang else "None"),
"%{supports_param_files}": "0" if darwin else "1",
"%{cc_compiler_deps}": get_starlark_list([":builtin_include_directory_paths"] + (
[":cc_wrapper"] if darwin else []
)),
Expand Down
2 changes: 1 addition & 1 deletion tools/osx/crosstool/BUILD.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ cc_toolchain_suite(
linker_files = ":osx_tools_" + arch,
objcopy_files = ":empty",
strip_files = ":osx_tools_" + arch,
supports_param_files = 0,
supports_param_files = 1,
toolchain_config = ":" + (
arch if arch != "armeabi-v7a" else "stub_armeabi-v7a"
),
Expand Down
15 changes: 6 additions & 9 deletions tools/osx/crosstool/cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5198,16 +5198,13 @@ def _impl(ctx):
name = "linker_param_file",
flag_sets = [
flag_set(
actions = all_link_actions,
flag_groups = [
flag_group(
flags = ["-Wl,@%{linker_param_file}"],
expand_if_available = "linker_param_file",
),
actions = all_link_actions + [
ACTION_NAMES.cpp_link_static_library,
ACTION_NAMES.objc_archive,
ACTION_NAMES.objc_fully_link,
ACTION_NAMES.objc_executable,
ACTION_NAMES.objcpp_executable,
],
),
flag_set(
actions = [ACTION_NAMES.cpp_link_static_library],
flag_groups = [
flag_group(
flags = ["@%{linker_param_file}"],
Expand Down
Loading