Merge pull request #88 from greenhouse-org:fix-llvm-version
PiperOrigin-RevId: 341810986
Change-Id: Ieb85da0b1c25d095cd48b6cadcf6a5c825d24a48
diff --git a/cc/private/toolchain/osx_cc_wrapper.sh b/cc/private/toolchain/osx_cc_wrapper.sh
index 207bcef..8c9c111 100755
--- a/cc/private/toolchain/osx_cc_wrapper.sh
+++ b/cc/private/toolchain/osx_cc_wrapper.sh
@@ -34,20 +34,33 @@
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
@@ -101,4 +114,3 @@
fi
done
done
-
diff --git a/cc/private/toolchain/osx_cc_wrapper.sh.tpl b/cc/private/toolchain/osx_cc_wrapper.sh.tpl
index 4c85cd9..28bd47b 100644
--- a/cc/private/toolchain/osx_cc_wrapper.sh.tpl
+++ b/cc/private/toolchain/osx_cc_wrapper.sh.tpl
@@ -33,20 +33,33 @@
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
diff --git a/examples/my_c_archive/my_c_archive.bzl b/examples/my_c_archive/my_c_archive.bzl
index 476fdd6..86cebe9 100644
--- a/examples/my_c_archive/my_c_archive.bzl
+++ b/examples/my_c_archive/my_c_archive.bzl
@@ -30,14 +30,19 @@
unsupported_features = ctx.disabled_features,
)
- library_to_link = cc_common.create_library_to_link(
- actions = ctx.actions,
- feature_configuration = feature_configuration,
- cc_toolchain = cc_toolchain,
- static_library = output_file,
+ linker_input = cc_common.create_linker_input(
+ owner = ctx.label,
+ libraries = depset(direct = [
+ cc_common.create_library_to_link(
+ actions = ctx.actions,
+ feature_configuration = feature_configuration,
+ cc_toolchain = cc_toolchain,
+ static_library = output_file,
+ ),
+ ]),
)
compilation_context = cc_common.create_compilation_context()
- linking_context = cc_common.create_linking_context(libraries_to_link = [library_to_link])
+ linking_context = cc_common.create_linking_context(linker_inputs = depset(direct = [linker_input]))
archiver_path = cc_common.get_tool_for_action(
feature_configuration = feature_configuration,