Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use -target instead of -arch in compiling commands in Apple
Browse files Browse the repository at this point in the history
crosstool

This allows using this crosstool file for cross-compiling from non-Apple
host platforms. On macOS, `-arch <arch>`  and
`-m<platform>-version-min=<version_min>` will be expanded to `-triple
<arch>-apple-<platform><version_min>` in the frontend invocation, but on
a Linux host, without `-target`, the expanded triple flags would be
`-triple <arch>-pc-linux-gnu`.
thii committed Feb 24, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent b228497 commit bdcdfac
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions tools/osx/crosstool/cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
@@ -69,11 +69,11 @@ def _impl(ctx):
elif (ctx.attr.cpu == "watchos_armv7k"):
target_system_name = "armv7k-apple-watchos"
elif (ctx.attr.cpu == "ios_i386"):
target_system_name = "i386-apple-ios"
target_system_name = "i386-apple-ios-simulator"
elif (ctx.attr.cpu == "watchos_i386"):
target_system_name = "i386-apple-watchos"
target_system_name = "i386-apple-watchos-simulator"
elif (ctx.attr.cpu == "ios_x86_64"):
target_system_name = "x86_64-apple-ios"
target_system_name = "x86_64-apple-ios-simulator"
elif (ctx.attr.cpu == "ios_sim_arm64"):
target_system_name = "arm64-apple-ios-simulator"
elif (ctx.attr.cpu == "tvos_sim_arm64"):
@@ -87,9 +87,9 @@ def _impl(ctx):
elif (ctx.attr.cpu == "darwin_arm64e"):
target_system_name = "arm64e-apple-macosx"
elif (ctx.attr.cpu == "tvos_x86_64"):
target_system_name = "x86_64-apple-tvos"
target_system_name = "x86_64-apple-tvos-simulator"
elif (ctx.attr.cpu == "watchos_x86_64"):
target_system_name = "x86_64-apple-watchos"
target_system_name = "x86_64-apple-watchos-simulator"
else:
fail("Unreachable")

@@ -206,7 +206,7 @@ def _impl(ctx):
action_name = ACTION_NAMES.objc_compile,
flag_sets = [
flag_set(
flag_groups = [flag_group(flags = ["-arch", arch])],
flag_groups = [flag_group(flags = ["-target", target_system_name])],
),
],
implies = [
@@ -241,7 +241,7 @@ def _impl(ctx):
flag_set(
flag_groups = [
flag_group(flags = ["-stdlib=libc++", "-std=gnu++11"]),
flag_group(flags = ["-arch", arch]),
flag_group(flags = ["-target", target_system_name]),
flag_group(
flags = [
"-Xlinker",
@@ -395,8 +395,8 @@ def _impl(ctx):
flag_groups = [
flag_group(
flags = [
"-arch",
arch,
"-target",
target_system_name,
"-stdlib=libc++",
"-std=gnu++11",
],
@@ -526,7 +526,7 @@ def _impl(ctx):
),
flag_set(
flag_groups = [
flag_group(flags = ["-arch", arch]),
flag_group(flags = ["-target", target_system_name]),
flag_group(
flags = ["-framework", "%{framework_names}"],
iterate_over = "framework_names",

0 comments on commit bdcdfac

Please sign in to comment.