build --announce_rc

# TODO: Migrate for https://github.com/bazelbuild/bazel/issues/7260
# common --incompatible_enable_cc_toolchain_resolution
common --noincompatible_enable_cc_toolchain_resolution

common --@rules_ml_toolchain//common:enable_hermetic_cc=False
common --repo_env USE_HERMETIC_CC_TOOLCHAIN=0
common --experimental_repo_remote_exec
common --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
common --cxxopt=-w --host_cxxopt=-w
common --define=grpc_no_ares=true
common --noenable_bzlmod

build --copt=-DMLIR_CAPI_BUILDING_LIBRARY=1
build --copt=-DMLIR_CAPI_ENABLE_WINDOWS_DLL_DECLSPEC=1

build --repo_env=USE_PYWRAP_RULES=True
build --copt=-DGRPC_BAZEL_BUILD
build --host_copt=-DGRPC_BAZEL_BUILD
build --action_env=GRPC_BAZEL_RUNTIME=1
build --repo_env=PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=upb
build --action_env=PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=upb
build --repo_env=RULES_PYTHON_ENABLE_PYSTAR=0
# Do not do this. This is how gRPC builds itself by default, but we don't want
# that as it would link protobuf into its own set of dynamic libraries, which
# would conflict with our protobuf linkage.
#build --define=use_fast_cpp_protos=true

build -c opt

build:cuda --repo_env TF_NEED_CUDA=1
build:cuda --repo_env TF_NVCC_CLANG=1
build:cuda --repo_env TF_NCCL_USE_STUB=1
build:cuda --repo_env=HERMETIC_CUDA_VERSION="12.8.1"
build:cuda --repo_env=HERMETIC_CUDNN_VERSION="9.8.0"
build:cuda --repo_env=HERMETIC_NVSHMEM_VERSION="3.2.5"
# "sm" means we emit only cubin, which is forward compatible within a GPU generation.
# "compute" means we emit both cubin and PTX, which is larger but also forward compatible to future GPU generations.
build:cuda --repo_env HERMETIC_CUDA_COMPUTE_CAPABILITIES="sm_60,sm_70,sm_80,compute_90"
build:cuda --crosstool_top="@local_config_cuda//crosstool:toolchain"
build:cuda --@local_config_cuda//:enable_cuda
# Default hermetic CUDA and CUDNN versions.
build:cuda --@local_config_cuda//cuda:include_cuda_libs=true
build:cuda --@local_config_cuda//:cuda_compiler=nvcc
# build:cuda --@local_config_nvshmem//:override_include_nvshmem_libs=true
# build:cuda --@local_config_nvshmem//cuda:include_nvshmem_libs=true


build:rocm --crosstool_top=@local_config_rocm//crosstool:toolchain
build:rocm --define=using_rocm=true --define=using_rocm_hipcc=true
build:rocm --repo_env TF_NEED_ROCM=1
build:rocm --action_env TF_ROCM_AMDGPU_TARGETS="gfx900,gfx906,gfx908,gfx90a,gfx940,gfx941,gfx942,gfx1030,gfx1100,gfx1200,gfx1201"

# Build with hipcc for ROCm and clang for the host.
build:rocm --action_env=TF_ROCM_CLANG="1"
build:rocm --action_env=CLANG_COMPILER_PATH="/usr/lib/llvm-18/bin/clang"
build:rocm --copt=-Wno-gnu-offsetof-extensions
build:rocm --copt=-Qunused-arguments
build:rocm --action_env=TF_HIPCC_CLANG="1"
