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

Enable supports_params_file on macOS #97

Merged
merged 1 commit into from
Sep 22, 2021
Merged
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
4 changes: 0 additions & 4 deletions toolchain/internal/configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ filegroup(
""".format(sysroot_label = sysroot_label, toolchain_root = toolchain_root)

def _cc_toolchain_str(name, toolchain_config, darwin, use_absolute_paths):
supports_param_files = 0 if darwin else 1
extra_files = ", \":llvm\", \":cc_wrapper\""

if use_absolute_paths:
Expand All @@ -227,7 +226,6 @@ cc_toolchain(
linker_files = ":empty",
objcopy_files = ":empty",
strip_files = ":empty",
supports_param_files = {supports_param_files},
toolchain_config = "{toolchain_config}",
)
"""
Expand All @@ -251,14 +249,12 @@ cc_toolchain(
linker_files = "{name}-linker-files",
objcopy_files = ":objcopy",
strip_files = ":empty",
supports_param_files = {supports_param_files},
toolchain_config = "{toolchain_config}",
)
"""

return template.format(
name = name,
supports_param_files = supports_param_files,
toolchain_config = toolchain_config,
extra_files = extra_files,
)
28 changes: 20 additions & 8 deletions toolchain/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

# Call the C++ compiler.
Expand Down Expand Up @@ -114,4 +127,3 @@ for rpath in ${RPATHS}; do
fi
done
done