Skip to content

Commit

Permalink
Enable --config=clang only on newer Clang versions
Browse files Browse the repository at this point in the history
These flags disable Clang extensions that do things such as reject type definitions within offsetof or reject unknown arguments which does not seem to be needed on versions older than Clang 16

Also, fix a syntax error

Fixes #25530

PiperOrigin-RevId: 707555651
  • Loading branch information
nitins17 authored and Google-ML-Automation committed Dec 18, 2024
1 parent 6a03ea3 commit bcca77c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,20 +475,20 @@ async def main():
wheel_build_command.append(f"--action_env=CLANG_COMPILER_PATH=\"{clang_path}\"")
wheel_build_command.append(f"--repo_env=CC=\"{clang_path}\"")
wheel_build_command.append(f"--repo_env=BAZEL_COMPILER=\"{clang_path}\"")

if clang_major_version >= 16:
# Enable clang settings that are needed for the build to work with newer
# versions of Clang.
wheel_build_command.append("--config=clang")
else:
logging.debug("Use Clang: False")

# Do not apply --config=clang on Mac as these settings do not apply to
# Apple Clang.
if os_name != "darwin":
wheel_build_command.append("--config=clang")

if not args.disable_mkl_dnn:
logging.debug("Enabling MKL DNN")
if target_cpu == "aarch64":
wheel_build_command.append("--config=mkl_aarch64_threadpool")
wheel_build_command.append("--config=mkl_aarch64_threadpool")
else:
wheel_build_command.append("--config=mkl_open_source_only")
wheel_build_command.append("--config=mkl_open_source_only")

if args.target_cpu_features == "release":
if arch in ["x86_64", "AMD64"]:
Expand All @@ -501,7 +501,7 @@ async def main():
if os_name == "windows"
else "--config=avx_posix"
)
elif wheel_build_command == "native":
elif args.target_cpu_features == "native":
if os_name == "windows":
logger.warning(
"--target_cpu_features=native is not supported on Windows;"
Expand Down

0 comments on commit bcca77c

Please sign in to comment.