Skip to content

Commit bcca77c

Browse files
nitins17Google-ML-Automation
authored andcommitted
Enable --config=clang only on newer Clang versions
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
1 parent 6a03ea3 commit bcca77c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

build/build.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -475,20 +475,20 @@ async def main():
475475
wheel_build_command.append(f"--action_env=CLANG_COMPILER_PATH=\"{clang_path}\"")
476476
wheel_build_command.append(f"--repo_env=CC=\"{clang_path}\"")
477477
wheel_build_command.append(f"--repo_env=BAZEL_COMPILER=\"{clang_path}\"")
478+
479+
if clang_major_version >= 16:
480+
# Enable clang settings that are needed for the build to work with newer
481+
# versions of Clang.
482+
wheel_build_command.append("--config=clang")
478483
else:
479484
logging.debug("Use Clang: False")
480485

481-
# Do not apply --config=clang on Mac as these settings do not apply to
482-
# Apple Clang.
483-
if os_name != "darwin":
484-
wheel_build_command.append("--config=clang")
485-
486486
if not args.disable_mkl_dnn:
487487
logging.debug("Enabling MKL DNN")
488488
if target_cpu == "aarch64":
489-
wheel_build_command.append("--config=mkl_aarch64_threadpool")
489+
wheel_build_command.append("--config=mkl_aarch64_threadpool")
490490
else:
491-
wheel_build_command.append("--config=mkl_open_source_only")
491+
wheel_build_command.append("--config=mkl_open_source_only")
492492

493493
if args.target_cpu_features == "release":
494494
if arch in ["x86_64", "AMD64"]:
@@ -501,7 +501,7 @@ async def main():
501501
if os_name == "windows"
502502
else "--config=avx_posix"
503503
)
504-
elif wheel_build_command == "native":
504+
elif args.target_cpu_features == "native":
505505
if os_name == "windows":
506506
logger.warning(
507507
"--target_cpu_features=native is not supported on Windows;"

0 commit comments

Comments
 (0)