Skip to content

support building with clang #9061

Open
@zhanyong-wan

Description

@zhanyong-wan

🚀 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildBuild process related matters (e.g. build system).enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions