Skip to content
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
2 changes: 0 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ git_repository(
"@//patches:0003-original_dst_cluster-Avoid-multiple-hosts-for-the-sa.patch",
"@//patches:0004-thread_local-reset-slot-in-worker-threads-first.patch",
"@//patches:0005-http-header-expose-attribute.patch",
"@//patches:0006-build-Fix-arm-build-for-liburing.patch",
"@//patches:0007-Add-latomic-back-for-arm-build.patch",
],
# // clang-format off: Envoy's format check: Only repository_locations.bzl may contains URL references
remote = "https://github.com/envoyproxy/envoy.git",
Expand Down
21 changes: 19 additions & 2 deletions bazel/toolchains/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ cc_toolchain_config(
],
cxx_flags = ["-std=c++0x"],
dbg_compile_flags = ["-g"],
# Cross-compilation flags exported as environment variables for foreign_cc
# rules (e.g. liburing's configure_make). This ensures foreign build systems
# see the correct --target when they use CFLAGS/CPPFLAGS from the environment.
foreign_cc_env = {
"CFLAGS": "--target=aarch64-unknown-linux-gnu -fuse-ld=lld",
"CPPFLAGS": "--target=aarch64-unknown-linux-gnu -fuse-ld=lld",
# -lc is needed because liburing builds a shared library with -Wl,-z,defs
# which requires all symbols (including memset from libc) to be resolved.
# The cross-compiler driver doesn't implicitly add -lc for shared libraries.
"LDFLAGS": "--target=aarch64-unknown-linux-gnu -fuse-ld=lld -lc",
},
host_system_name = "local",
link_flags = [
"--target=aarch64-unknown-linux-gnu",
Expand All @@ -63,7 +74,10 @@ cc_toolchain_config(
"-Wl,-z,relro,-z,now",
"-lm",
],
link_libs = ["-l:libstdc++.a"],
link_libs = [
"-l:libstdc++.a",
"-latomic",
],
opt_compile_flags = [
"-g0",
"-O2",
Expand Down Expand Up @@ -162,7 +176,10 @@ cc_toolchain_config(
"-Wl,-z,relro,-z,now",
"-lm",
],
link_libs = ["-l:libstdc++.a"],
link_libs = [
"-l:libstdc++.a",
"-latomic",
],
opt_compile_flags = [
"-g0",
"-O2",
Expand Down
25 changes: 25 additions & 0 deletions bazel/toolchains/cc_toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
load(
"@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl",
"env_entry",
"env_set",
"feature",
"feature_set",
"flag_group",
Expand Down Expand Up @@ -1145,6 +1147,26 @@ def _impl(ctx):
],
)

# Export cross-compilation flags as environment variables for foreign_cc rules
# (e.g. rules_foreign_cc's configure_make). These env vars are picked up by
# cc_common.get_environment_variables() and exported globally in the build
# script prelude, making them available to both configure and make steps.
# This is needed because some foreign build systems (like liburing) override
# CFLAGS internally, losing the --target flag from the toolchain's compile_flags.
foreign_cc_env_feature = feature(
name = "foreign_cc_env",
enabled = bool(ctx.attr.foreign_cc_env),
env_sets = [
env_set(
actions = all_compile_actions + all_link_actions,
env_entries = [
env_entry(key = key, value = value)
for key, value in ctx.attr.foreign_cc_env.items()
],
),
] if ctx.attr.foreign_cc_env else [],
)

is_linux = ctx.attr.target_libc != "macosx"

# TODO(#8303): Mac crosstool should also declare every feature.
Expand Down Expand Up @@ -1194,6 +1216,7 @@ def _impl(ctx):
user_compile_flags_feature,
sysroot_feature,
unfiltered_compile_flags_feature,
foreign_cc_env_feature,
] + layering_check_features(ctx.attr.compiler)
else:
features = [
Expand All @@ -1213,6 +1236,7 @@ def _impl(ctx):
user_compile_flags_feature,
sysroot_feature,
unfiltered_compile_flags_feature,
foreign_cc_env_feature,
] + layering_check_features(ctx.attr.compiler)

return cc_common.create_cc_toolchain_config_info(
Expand Down Expand Up @@ -1257,6 +1281,7 @@ cc_toolchain_config = rule(
"coverage_link_flags": attr.string_list(),
"supports_start_end_lib": attr.bool(),
"builtin_sysroot": attr.string(),
"foreign_cc_env": attr.string_dict(),
},
provides = [CcToolchainConfigInfo],
)
37 changes: 0 additions & 37 deletions patches/0006-build-Fix-arm-build-for-liburing.patch

This file was deleted.

25 changes: 0 additions & 25 deletions patches/0007-Add-latomic-back-for-arm-build.patch

This file was deleted.

Loading