Skip to content
Draft
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
1 change: 1 addition & 0 deletions .bazelrc.local
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
common --repo_env=HERMETIC_PYTHON_VERSION=3.12
6 changes: 6 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ use_repo(sycl_configure, "local_config_sycl", "oneapi", "level_zero", "zero_load
hipcc_configure = use_extension("//extensions:hipcc_configure.bzl", "hipcc_configure_ext")
use_repo(hipcc_configure, "config_rocm_hipcc")

##############################################################
# ROCm configuration

hipcc_configure = use_extension("//extensions:hipcc_configure.bzl", "hipcc_configure_ext")
use_repo(hipcc_configure, "config_rocm_hipcc")

##############################################################
# Hermetic toolchain configuration

Expand Down
6 changes: 0 additions & 6 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,3 @@ load("//gpu/rocm:hipcc_configure.bzl", "hipcc_configure")

hipcc_configure(name = "config_rocm_hipcc")

##############################################################
# Local sysroot configuration

load("//cc/sysroots:local_sysroot_configure.bzl", "local_sysroot_configure")

local_sysroot_configure(name = "local_sysroot_config")
60 changes: 29 additions & 31 deletions cc/features/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -84,35 +84,11 @@ cc_feature(

cc_toolchain_sysroot_feature(
name = "sysroot_linux_x86_64",
enabled = True,
enabled = True, # Always enabled for hermetic toolchain
sysroot = "@sysroot_linux_x86_64//:sysroot",
target = "x86_64-linux-gnu",
)

# Local sysroot feature - use system root instead of hermetic sysroot
# Generic for all Linux architectures
cc_feature(
name = "local_sysroot_linux",
enabled = True,
compiler_flags = ["--sysroot=/"],
linker_flags = ["--sysroot=/"],
env_sets = {
"HOST_SYSROOT": "/",
},
)

# When using local sysroot, we need to explicitly link default system libraries
# since we don't use hermetic_libraries feature
cc_feature(
name = "local_sysroot_default_libs",
enabled = True,
linker_flags = [
"-lstdc++",
"-lm",
"-lpthread",
"-ldl",
],
)

cc_toolchain_sysroot_feature(
name = "sysroot_linux_aarch64",
Expand Down Expand Up @@ -190,9 +166,9 @@ cc_feature(
compiler_flags = [
"-O0",
],
expand_if_not_available = "opt",
#implies = ["generate_pdb_file"],
provides = ["compilation_mode"],
expand_if_not_available = "opt",
)

cc_feature(
Expand All @@ -214,15 +190,37 @@ cc_feature(
provides = ["compilation_mode"],
)

# Use hermetic libstdc++ instead of libc++
# Provides GLIBCXX_3.4.25 (GCC 8) from hermetic sysroot
cc_feature(
name = "libc++",
name = "use_libstdcxx",
compiler_flags = [
# Allows the use of GNU-specific extension keywords that are not part of the standard C or C++ specifications
"-fgnu-keywords",
"-stdlib=libstdc++",
],
enabled = select({
"//cc/sysroots:libstdcxx_enabled": True,
"//conditions:default": False,
}),
linker_flags = [
"-stdlib=libc++",
"-stdlib=libstdc++",
],
)

# Statically link hermetic libstdc++ to avoid C++ ABI issues
# Use this when you need to isolate from system libstdc++ (e.g., ROCm compatibility)
# When enabled, also enables use_libstdcxx
cc_feature(
name = "static_libstdcxx",
compiler_flags = [
"-stdlib=libstdc++",
],
enabled = select({
"//cc/sysroots:static_libstdcxx_enabled": True,
"//conditions:default": False,
}),
linker_flags = [
"-stdlib=libstdc++",
"-static-libstdc++",
],
enabled = True,
)

2 changes: 2 additions & 0 deletions cc/impls/linux_x86_64_linux_x86_64/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ FEATURES_ESSENTIAL = [
"//third_party/rules_cc_toolchain/features:language",
"//third_party/rules_cc_toolchain/features:use_lld",
"//cc/features:sysroot_linux_x86_64",
"//cc/features:use_libstdcxx",
"//cc/features:static_libstdcxx",
":startup_libs_feature",
"//third_party/rules_cc_toolchain/features:coverage",
#"//cc/features:clang19", # TODO: Add a selection mechanism based on the Clang version
Expand Down
Loading