Skip to content

support building with clang #9061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
zhanyong-wan opened this issue Apr 29, 2025 · 3 comments · May be fixed by #9169
Open

support building with clang #9061

zhanyong-wan opened this issue Apr 29, 2025 · 3 comments · May be fixed by #9169
Assignees
Labels
build Build process related matters (e.g. build system). enhancement New feature or request

Comments

@zhanyong-wan
Copy link
Collaborator

🚀 Feature

Support building PyTorch/XLA with clang as the C/C++ compiler.

Motivation

Currently the PyTorch/XLA build uses gcc as the C/C++ compiler. Switching to clang gives us several benefits:

  • Consistency with PyTorch, which uses clang.
  • Faster build - experience shows that clang often is 2-3x faster than gcc.
  • Smaller memory usage by the compiler - clang typically uses ~1/3 of the RAM as gcc when compiling.
  • Consistency with other tooling we use, like clang-format.

Pitch

  1. Add a configuration for building with clang, so that we can add --config=clang to the bazel commandline to select clang.
  2. Fix incompatibilities with clang.
  3. Measure the compilation performance of clang vs gcc.
  4. If the result of 3 is favorable, switch the build to use clang by default.

Alternatives

Do nothing - support gcc only.

@zhanyong-wan zhanyong-wan self-assigned this Apr 29, 2025
@ysiraichi ysiraichi added enhancement New feature or request build Build process related matters (e.g. build system). labels Apr 30, 2025
@ysiraichi
Copy link
Collaborator

This will be actually the case after #8665.

@zhanyong-wan
Copy link
Collaborator Author

Thanks, @ysiraichi ! I think it'd be good to make incremental progress.

@zhanyong-wan
Copy link
Collaborator Author

@bfolie reported that the build is much slower after we switch the default bazel spawn strategy to sandboxed, which is needed by clang. I'll revert the change for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Build process related matters (e.g. build system). enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants