Skip to content

Add tools/build.sh to automatically apply XLA/GCC compatibility patches - #4144

Closed
Phoebus-Liu wants to merge 1 commit into
tensorflow:masterfrom
Phoebus-Liu:fix/issue-4108-Error-building-TF-Serving-from-source
Closed

Add tools/build.sh to automatically apply XLA/GCC compatibility patches#4144
Phoebus-Liu wants to merge 1 commit into
tensorflow:masterfrom
Phoebus-Liu:fix/issue-4108-Error-building-TF-Serving-from-source

Conversation

@Phoebus-Liu

@Phoebus-Liu Phoebus-Liu commented Aug 5, 2026

Copy link
Copy Markdown

Description

This PR fixes #4108 by adding a tools/build.sh convenience wrapper that automatically applies known compatibility patches before invoking run_in_docker.sh.

Problem

When building TF Serving from source with newer GCC versions (e.g., GCC 11/12/13), the build fails in external/local_xla/xla/shape.cc with:

error: function 'xla::Shape::Shape(xla::Shape&&)' defaulted on its redeclaration with an exception-specification that differs from the implicit exception-specification 'noexcept(false)'

This is caused by noexcept annotations on the move constructor/assignment that conflict with the implicit exception specification inferred by newer GCC/libstdc++.

Solution

  • Add tools/build.sh which:
    1. Runs bazel fetch inside Docker to ensure external/ dependencies are present
    2. Applies sed patches to xla/shape.cc and xla/shape.h to remove the conflicting noexcept on move operations
    3. Forwards to tools/run_in_docker.sh for the actual build

Usage

./tools/build.sh -c opt tensorflow_serving/model_servers:tensorflow_model_server

Why not patch run_in_docker.sh directly?

run_in_docker.sh is a generic command runner. Adding build-specific patches there would couple the general Docker launcher to a specific dependency workaround. A dedicated build.sh is cleaner and avoids surprising users who run non-build commands.
Fixes

Fixes #4108

### Commit Message

```bash
git add tools/build.sh
git commit -m "Add build.sh wrapper to fix XLA/GCC noexcept compatibility

Adds a dedicated build wrapper that automatically applies sed patches
for the XLA Shape move-ctor noexcept mismatch seen with GCC 11+.
This avoids modifying the generic run_in_docker.sh tool.

Fixes #4108"

@google-cla

google-cla Bot commented Aug 5, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@Phoebus-Liu Phoebus-Liu closed this Aug 5, 2026
@Phoebus-Liu
Phoebus-Liu deleted the fix/issue-4108-Error-building-TF-Serving-from-source branch August 5, 2026 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error building TF Serving from source

1 participant