Skip to content

Delete EC2 build path from _linux-build, rename build-osdc to build - #189113

Closed
huydhn wants to merge 2 commits into
gh/huydhn/67/basefrom
gh/huydhn/67/head
Closed

huydhn wants to merge 2 commits into
gh/huydhn/67/basefrom
gh/huydhn/67/head

Conversation

@huydhn

@huydhn huydhn commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

The OSDC/EC2 shadow-traffic experiment is wrapped up, so drop the legacy EC2
build job and make the OSDC/ARC job the sole build job. The use-arc input
and its call sites are left for a follow-up cleanup; s390x was moved to
_s390x-build.yml earlier in the stack.

Authored with the assistance of Claude Code.

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/189113

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit dd35aad with merge base 9f9df93 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot Bot added the topic: not user facing topic category label Jul 7, 2026
[ghstack-poisoned]
huydhn added a commit that referenced this pull request Jul 7, 2026
The OSDC/EC2 shadow-traffic experiment (#185181) is wrapped up, so the
legacy EC2 build job is no longer needed. Remove it and promote the
OSDC/ARC job (build-osdc) to be the sole build job named `build`.

The `use-arc` input and its `use-arc: true` call sites are intentionally
left in place for a follow-up cleanup. s390x, which cannot run on ARC,
will be moved to a dedicated build workflow in a separate change; until
then its callers (s390.yml, s390x-periodic.yml) do not set use-arc and
so no longer trigger a build here.

Authored with the assistance of Claude Code.

Test Plan:
Static validation only (workflow change):

    python3 -c "import yaml; yaml.safe_load(open('.github/workflows/_linux-build.yml'))"
    grep -rn build-osdc .github/   # no matches

Full validation is via CI on the PR (ciflow tags exercising the OSDC build path).


ghstack-source-id: ada496c
Pull-Request: #189113
huydhn added a commit that referenced this pull request Jul 7, 2026
The OSDC/EC2 shadow-traffic experiment is wrapped up, so drop the legacy EC2
build job and make the OSDC/ARC job the sole `build` job. The use-arc input
and its call sites are left for a follow-up cleanup; s390x was moved to
_s390x-build.yml earlier in the stack.

Authored with the assistance of Claude Code.

ghstack-source-id: ada496c
Pull-Request: #189113
@huydhn
huydhn marked this pull request as ready for review July 7, 2026 02:04
@huydhn
huydhn requested a review from a team as a code owner July 7, 2026 02:04
@huydhn
huydhn requested a review from georgehong July 7, 2026 02:04

@malfet malfet left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Starting merge as part of PR stack under #189117

pytorchmergebot pushed a commit that referenced this pull request Jul 7, 2026
Mirror of the s390x build extraction, on the test side. s390x tests run on
the linux.s390x self-hosted runners and can't use the OSDC/ARC path, so
extract the s390x test path out of _linux-test.yml into its own workflow.
s390x-periodic.yml's test job now calls it. This lets _linux-test.yml drop
the EC2 path in the following commit.

Authored with the assistance of Claude Code.
Pull Request resolved: #189116
Approved by: https://github.com/malfet, https://github.com/atalman
ghstack dependencies: #189115, #189113
pytorchmergebot pushed a commit that referenced this pull request Jul 7, 2026
)

Test-side counterpart of the _linux-build EC2 removal. Drop the legacy EC2
test job and make the OSDC/ARC job the sole `test` job. use-arc and its
call sites are left for a follow-up cleanup; s390x test was moved to
_s390x-test.yml earlier in the stack.

Authored with the assistance of Claude Code.
Pull Request resolved: #189117
Approved by: https://github.com/malfet, https://github.com/atalman
ghstack dependencies: #189115, #189113, #189116
zxiiro added a commit that referenced this pull request Jul 13, 2026
_runner-determinator.yml checked out .github/scripts/runner_determinator.py
from github.event.pull_request.head.sha, so PRs whose branch predates a
change to the script (e.g. the "lf." -> "lf-" prefix rename, or the EC2
build-path removal in #189113/#189171) run a stale copy. That stale copy
can emit a runner-label prefix main's build workflow no longer knows how
to route (e.g. "lf.l-x86iavx512-8-64" - a dead EC2-era dotted prefix
glued onto a post-#189113 ARC-only label), leaving the job stuck
unroutable instead of just landing on the wrong fleet.

The PR-head ref was introduced in #182579 only so ci-docker-hash reflects
the PR's own .ci/docker tree, not to let PRs self-test determinator
changes. Split the checkout in two: the script now comes from the
default ref (main, or the merge commit for pull_request events, which
still includes the PR's own edits to the script), while .ci/docker
keeps using head.sha via a separate sparse checkout under pr-head/.

This also removes the --help probing for --workflow-name, since the
script is no longer stale relative to main and always supports the flag.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Signed-off-by: Thanh Ha <[email protected]>
pytorchmergebot pushed a commit that referenced this pull request Jul 14, 2026
_runner-determinator.yml checked out .github/scripts/runner_determinator.py from github.event.pull_request.head.sha, so PRs whose branch predates a change to the script (e.g. the "lf." -> "lf-" prefix rename, or the EC2 build-path removal in #189113/#189171) run a stale copy. That stale copy can emit a runner-label prefix main's build workflow no longer knows how to route (e.g. "lf.l-x86iavx512-8-64" - a dead EC2-era dotted prefix glued onto a post-#189113 ARC-only label), leaving the job stuck unroutable instead of just landing on the wrong fleet.

The PR-head ref was introduced in #182579 only so ci-docker-hash reflects the PR's own .ci/docker tree, not to let PRs self-test determinator changes. Split the checkout in two: the script now comes from the default ref (main, or the merge commit for pull_request events, which still includes the PR's own edits to the script), while .ci/docker keeps using head.sha via a separate sparse checkout under pr-head/.

This also removes the --help probing for --workflow-name, since the script is no longer stale relative to main and always supports the flag.
Pull Request resolved: #189782
Approved by: https://github.com/huydhn, https://github.com/jeanschmidt

Co-authored-by: Claude Sonnet 5 <[email protected]>
vishalgoyal316 pushed a commit to vishalgoyal316/pytorch that referenced this pull request Jul 16, 2026
…ytorch#189113)

The OSDC/EC2 shadow-traffic experiment is wrapped up, so drop the legacy EC2
build job and make the OSDC/ARC job the sole `build` job. The use-arc input
and its call sites are left for a follow-up cleanup; s390x was moved to
_s390x-build.yml earlier in the stack.

Authored with the assistance of Claude Code.
Pull Request resolved: pytorch#189113
Approved by: https://github.com/malfet, https://github.com/atalman
ghstack dependencies: pytorch#189115
vishalgoyal316 pushed a commit to vishalgoyal316/pytorch that referenced this pull request Jul 16, 2026
…9116)

Mirror of the s390x build extraction, on the test side. s390x tests run on
the linux.s390x self-hosted runners and can't use the OSDC/ARC path, so
extract the s390x test path out of _linux-test.yml into its own workflow.
s390x-periodic.yml's test job now calls it. This lets _linux-test.yml drop
the EC2 path in the following commit.

Authored with the assistance of Claude Code.
Pull Request resolved: pytorch#189116
Approved by: https://github.com/malfet, https://github.com/atalman
ghstack dependencies: pytorch#189115, pytorch#189113
vishalgoyal316 pushed a commit to vishalgoyal316/pytorch that referenced this pull request Jul 16, 2026
…rch#189117)

Test-side counterpart of the _linux-build EC2 removal. Drop the legacy EC2
test job and make the OSDC/ARC job the sole `test` job. use-arc and its
call sites are left for a follow-up cleanup; s390x test was moved to
_s390x-test.yml earlier in the stack.

Authored with the assistance of Claude Code.
Pull Request resolved: pytorch#189117
Approved by: https://github.com/malfet, https://github.com/atalman
ghstack dependencies: pytorch#189115, pytorch#189113, pytorch#189116
vishalgoyal316 pushed a commit to vishalgoyal316/pytorch that referenced this pull request Jul 16, 2026
_runner-determinator.yml checked out .github/scripts/runner_determinator.py from github.event.pull_request.head.sha, so PRs whose branch predates a change to the script (e.g. the "lf." -> "lf-" prefix rename, or the EC2 build-path removal in pytorch#189113/pytorch#189171) run a stale copy. That stale copy can emit a runner-label prefix main's build workflow no longer knows how to route (e.g. "lf.l-x86iavx512-8-64" - a dead EC2-era dotted prefix glued onto a post-pytorch#189113 ARC-only label), leaving the job stuck unroutable instead of just landing on the wrong fleet.

The PR-head ref was introduced in pytorch#182579 only so ci-docker-hash reflects the PR's own .ci/docker tree, not to let PRs self-test determinator changes. Split the checkout in two: the script now comes from the default ref (main, or the merge commit for pull_request events, which still includes the PR's own edits to the script), while .ci/docker keeps using head.sha via a separate sparse checkout under pr-head/.

This also removes the --help probing for --workflow-name, since the script is no longer stale relative to main and always supports the flag.
Pull Request resolved: pytorch#189782
Approved by: https://github.com/huydhn, https://github.com/jeanschmidt

Co-authored-by: Claude Sonnet 5 <[email protected]>
DamJanusz pushed a commit to DamJanusz/pytorch that referenced this pull request Jul 21, 2026
…ytorch#189113)

The OSDC/EC2 shadow-traffic experiment is wrapped up, so drop the legacy EC2
build job and make the OSDC/ARC job the sole `build` job. The use-arc input
and its call sites are left for a follow-up cleanup; s390x was moved to
_s390x-build.yml earlier in the stack.

Authored with the assistance of Claude Code.
Pull Request resolved: pytorch#189113
Approved by: https://github.com/malfet, https://github.com/atalman
ghstack dependencies: pytorch#189115
DamJanusz pushed a commit to DamJanusz/pytorch that referenced this pull request Jul 21, 2026
…9116)

Mirror of the s390x build extraction, on the test side. s390x tests run on
the linux.s390x self-hosted runners and can't use the OSDC/ARC path, so
extract the s390x test path out of _linux-test.yml into its own workflow.
s390x-periodic.yml's test job now calls it. This lets _linux-test.yml drop
the EC2 path in the following commit.

Authored with the assistance of Claude Code.
Pull Request resolved: pytorch#189116
Approved by: https://github.com/malfet, https://github.com/atalman
ghstack dependencies: pytorch#189115, pytorch#189113
DamJanusz pushed a commit to DamJanusz/pytorch that referenced this pull request Jul 21, 2026
…rch#189117)

Test-side counterpart of the _linux-build EC2 removal. Drop the legacy EC2
test job and make the OSDC/ARC job the sole `test` job. use-arc and its
call sites are left for a follow-up cleanup; s390x test was moved to
_s390x-test.yml earlier in the stack.

Authored with the assistance of Claude Code.
Pull Request resolved: pytorch#189117
Approved by: https://github.com/malfet, https://github.com/atalman
ghstack dependencies: pytorch#189115, pytorch#189113, pytorch#189116
DamJanusz pushed a commit to DamJanusz/pytorch that referenced this pull request Jul 21, 2026
_runner-determinator.yml checked out .github/scripts/runner_determinator.py from github.event.pull_request.head.sha, so PRs whose branch predates a change to the script (e.g. the "lf." -> "lf-" prefix rename, or the EC2 build-path removal in pytorch#189113/pytorch#189171) run a stale copy. That stale copy can emit a runner-label prefix main's build workflow no longer knows how to route (e.g. "lf.l-x86iavx512-8-64" - a dead EC2-era dotted prefix glued onto a post-pytorch#189113 ARC-only label), leaving the job stuck unroutable instead of just landing on the wrong fleet.

The PR-head ref was introduced in pytorch#182579 only so ci-docker-hash reflects the PR's own .ci/docker tree, not to let PRs self-test determinator changes. Split the checkout in two: the script now comes from the default ref (main, or the merge commit for pull_request events, which still includes the PR's own edits to the script), while .ci/docker keeps using head.sha via a separate sparse checkout under pr-head/.

This also removes the --help probing for --workflow-name, since the script is no longer stale relative to main and always supports the flag.
Pull Request resolved: pytorch#189782
Approved by: https://github.com/huydhn, https://github.com/jeanschmidt

Co-authored-by: Claude Sonnet 5 <[email protected]>
youlituao pushed a commit to youlituao/pytorch that referenced this pull request Jul 28, 2026
…ytorch#189113)

The OSDC/EC2 shadow-traffic experiment is wrapped up, so drop the legacy EC2
build job and make the OSDC/ARC job the sole `build` job. The use-arc input
and its call sites are left for a follow-up cleanup; s390x was moved to
_s390x-build.yml earlier in the stack.

Authored with the assistance of Claude Code.
Pull Request resolved: pytorch#189113
Approved by: https://github.com/malfet, https://github.com/atalman
ghstack dependencies: pytorch#189115
youlituao pushed a commit to youlituao/pytorch that referenced this pull request Jul 28, 2026
…9116)

Mirror of the s390x build extraction, on the test side. s390x tests run on
the linux.s390x self-hosted runners and can't use the OSDC/ARC path, so
extract the s390x test path out of _linux-test.yml into its own workflow.
s390x-periodic.yml's test job now calls it. This lets _linux-test.yml drop
the EC2 path in the following commit.

Authored with the assistance of Claude Code.
Pull Request resolved: pytorch#189116
Approved by: https://github.com/malfet, https://github.com/atalman
ghstack dependencies: pytorch#189115, pytorch#189113
youlituao pushed a commit to youlituao/pytorch that referenced this pull request Jul 28, 2026
…rch#189117)

Test-side counterpart of the _linux-build EC2 removal. Drop the legacy EC2
test job and make the OSDC/ARC job the sole `test` job. use-arc and its
call sites are left for a follow-up cleanup; s390x test was moved to
_s390x-test.yml earlier in the stack.

Authored with the assistance of Claude Code.
Pull Request resolved: pytorch#189117
Approved by: https://github.com/malfet, https://github.com/atalman
ghstack dependencies: pytorch#189115, pytorch#189113, pytorch#189116
youlituao pushed a commit to youlituao/pytorch that referenced this pull request Jul 28, 2026
_runner-determinator.yml checked out .github/scripts/runner_determinator.py from github.event.pull_request.head.sha, so PRs whose branch predates a change to the script (e.g. the "lf." -> "lf-" prefix rename, or the EC2 build-path removal in pytorch#189113/pytorch#189171) run a stale copy. That stale copy can emit a runner-label prefix main's build workflow no longer knows how to route (e.g. "lf.l-x86iavx512-8-64" - a dead EC2-era dotted prefix glued onto a post-pytorch#189113 ARC-only label), leaving the job stuck unroutable instead of just landing on the wrong fleet.

The PR-head ref was introduced in pytorch#182579 only so ci-docker-hash reflects the PR's own .ci/docker tree, not to let PRs self-test determinator changes. Split the checkout in two: the script now comes from the default ref (main, or the merge commit for pull_request events, which still includes the PR's own edits to the script), while .ci/docker keeps using head.sha via a separate sparse checkout under pr-head/.

This also removes the --help probing for --workflow-name, since the script is no longer stale relative to main and always supports the flag.
Pull Request resolved: pytorch#189782
Approved by: https://github.com/huydhn, https://github.com/jeanschmidt

Co-authored-by: Claude Sonnet 5 <[email protected]>
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…ytorch#189113)

The OSDC/EC2 shadow-traffic experiment is wrapped up, so drop the legacy EC2
build job and make the OSDC/ARC job the sole `build` job. The use-arc input
and its call sites are left for a follow-up cleanup; s390x was moved to
_s390x-build.yml earlier in the stack.

Authored with the assistance of Claude Code.
Pull Request resolved: pytorch#189113
Approved by: https://github.com/malfet, https://github.com/atalman
ghstack dependencies: pytorch#189115
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…9116)

Mirror of the s390x build extraction, on the test side. s390x tests run on
the linux.s390x self-hosted runners and can't use the OSDC/ARC path, so
extract the s390x test path out of _linux-test.yml into its own workflow.
s390x-periodic.yml's test job now calls it. This lets _linux-test.yml drop
the EC2 path in the following commit.

Authored with the assistance of Claude Code.
Pull Request resolved: pytorch#189116
Approved by: https://github.com/malfet, https://github.com/atalman
ghstack dependencies: pytorch#189115, pytorch#189113
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…rch#189117)

Test-side counterpart of the _linux-build EC2 removal. Drop the legacy EC2
test job and make the OSDC/ARC job the sole `test` job. use-arc and its
call sites are left for a follow-up cleanup; s390x test was moved to
_s390x-test.yml earlier in the stack.

Authored with the assistance of Claude Code.
Pull Request resolved: pytorch#189117
Approved by: https://github.com/malfet, https://github.com/atalman
ghstack dependencies: pytorch#189115, pytorch#189113, pytorch#189116
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
_runner-determinator.yml checked out .github/scripts/runner_determinator.py from github.event.pull_request.head.sha, so PRs whose branch predates a change to the script (e.g. the "lf." -> "lf-" prefix rename, or the EC2 build-path removal in pytorch#189113/pytorch#189171) run a stale copy. That stale copy can emit a runner-label prefix main's build workflow no longer knows how to route (e.g. "lf.l-x86iavx512-8-64" - a dead EC2-era dotted prefix glued onto a post-pytorch#189113 ARC-only label), leaving the job stuck unroutable instead of just landing on the wrong fleet.

The PR-head ref was introduced in pytorch#182579 only so ci-docker-hash reflects the PR's own .ci/docker tree, not to let PRs self-test determinator changes. Split the checkout in two: the script now comes from the default ref (main, or the merge commit for pull_request events, which still includes the PR's own edits to the script), while .ci/docker keeps using head.sha via a separate sparse checkout under pr-head/.

This also removes the --help probing for --workflow-name, since the script is no longer stale relative to main and always supports the flag.
Pull Request resolved: pytorch#189782
Approved by: https://github.com/huydhn, https://github.com/jeanschmidt

Co-authored-by: Claude Sonnet 5 <[email protected]>
@github-actions
github-actions Bot deleted the gh/huydhn/67/head branch August 7, 2026 02:28
zklaus added a commit to zklaus/pytorch that referenced this pull request Aug 27, 2026
With the cross toolchain restored, the build reaches onnx codegen and stops:

    /bin/sh: 1: /__w/pytorch/pytorch/build/bin/protoc-3.21.12.0: Exec format error

protoc is a build-time code generator. Cross-compiling third_party/protobuf
produces a riscv64 protoc, and the x86_64 build host cannot run it.

This used to work by emulation. The riscv64 job ran on the EC2 path of
_linux-build.yml, which mounted binfmt_misc, registered qemu-riscv64 via
multiarch/qemu-user-static, and ran the build container privileged. pytorch#189113
deleted that path on 2026-07-06 when the OSDC/ARC migration was wrapped up, and
the OSDC path it left behind has no equivalent -- no binfmt, qemu or privileged
anywhere in the workflow today. That is also what the image's QEMU_LD_PREFIX and
this block's SLEEF_TARGET_EXEC_USE_QEMU have always been assuming: the image has
never installed qemu itself, because the host used to provide it.

Rather than restore emulation, which needs privileged containers that may not be
available on OSDC at all, supply a protoc built for the host. cmake/ProtoBuf.cmake
documents CAFFE2_CUSTOM_PROTOC_EXECUTABLE for precisely this case, and
Dependencies.cmake forwards it to ONNX_CUSTOM_PROTOC_EXECUTABLE, so it covers the
codegen that fails here. conda-forge solves the same problem the same way: their
recipe repoints protobuf's imported target at the build-prefix protoc, with the
comment "It helps cross compiled builds without emulation support to complete".

The version has to track third_party/protobuf, currently v21.12, since generated
sources must stay compatible with the libprotobuf built for the target. conda-forge
publishes libprotobuf 3.21.12, which is an exact match.

The variable needs the passthrough entry to have any effect. It does not start with
BUILD_, USE_ or CMAKE_, so without being listed it would never reach the CMake
cache, and ProtoBuf.cmake gates on if(EXISTS ...) -- an unforwarded value would
silently fall back to the vendored protoc and fail exactly as before. It is a
genuine cross-compilation knob, so forwarding it helps any cross build, not only
this job.

The pixi bootstrap is deliberately temporary, and stage 2 replaces it. Ubuntu noble
ships protobuf-compiler at 3.21.12, the same version, so the eventual form is an
apt install in .ci/docker/ubuntu-cross-riscv/Dockerfile with no bootstrap at all.
It is not done here because any change under .ci/docker rehashes the directory and
rebuilds every CI image, and this build has more unexplored ground ahead of it --
SLEEF_TARGET_EXEC_USE_QEMU=ON still asks to execute target binaries, so protoc is
unlikely to be the last thing emulation was covering.

This commit was authored with the assistance of an AI coding assistant.

Test Plan:

Needs a ciflow/riscv64 run; the job is opt-in and cannot be exercised locally.

Run 33059855491, on the parent commit, is the failure above. It configured with
riscv64-linux-gnu-gcc-14, compiled cpuinfo's RISC-V backend, and reached 395 of
2351 targets before protoc stopped it -- the furthest since 2025-07.

Verified locally that the pinned package supplies a matching protoc, using an
isolated PIXI_HOME so as not to touch an existing pixi installation:

```
PIXI_HOME=$(mktemp -d) pixi global install "libprotobuf==3.21.12"
"$PIXI_HOME/bin/protoc" --version
```

prints `libprotoc 3.21.12`, against `git -C third_party/protobuf describe --tags`
reporting `v21.12`.

Checked the bootstrap's requirements against the image: the pixi installer accepts
either curl or wget and unpacks a tar.gz on Linux, and the image provides wget and
tar but no curl. PIXI_HOME is kept outside the checkout because build.sh runs
assert_git_not_dirty, and PIXI_NO_PATH_UPDATE stops the installer rewriting shell
profiles.

Confirmed conda-forge publishes the matching version:

```
curl -sS https://api.anaconda.org/package/conda-forge/libprotobuf \
  | python3 -c "import json,sys; print([v for v in json.load(sys.stdin)['versions'] if v.startswith('3.21')])"
```

lists 3.21.1 through 3.21.12.

Lint:

```
lintrunner --paths-cmd='git diff --name-only origin/viable/strict'
bash -n .ci/pytorch/build.sh
```
zklaus added a commit to zklaus/pytorch that referenced this pull request Aug 27, 2026
With protoc supplied from the host, the build clears onnx and reaches 701 of
2351 targets before SLEEF stops it the same way:

    /bin/sh: 1: /__w/pytorch/pytorch/build/sleef/bin/mkrename: Exec format error
    FAILED: sleef/src/libm/include/renamervvm1nofma.h

mkrename and its siblings are code generators that run during the build, so
cross-compiling them produces binaries the x86_64 host cannot execute.

Unlike protoc, this one is self-inflicted. SLEEF already has a cross path that
needs no emulation -- add_host_executable in third_party/sleef/CMakeLists.txt
imports the tools from NATIVE_BUILD_DIR when cross-compiling. It is not taken
here because SLEEF_TARGET_EXEC_USE_QEMU is set, which selects an earlier branch
that builds the tools for the target and runs them under emulation:

    if (NOT CMAKE_CROSSCOMPILING)
      add_executable(${TARGETNAME} ${ARGN})
    elseif (DEFINED ENV{SLEEF_TARGET_EXEC_USE_QEMU})
      if($ENV{SLEEF_TARGET_EXEC_USE_QEMU})
        add_executable(${TARGETNAME} ${ARGN})
      endif()
    else()
      add_executable(${TARGETNAME} IMPORTED GLOBAL)
      set_property(TARGET ${TARGETNAME} PROPERTY
                   IMPORTED_LOCATION ${NATIVE_BUILD_DIR}/bin/${TARGETNAME})
    endif()

That variable was correct when the workflow registered qemu-riscv64 with
binfmt_misc, and has been wrong since pytorch#189113 removed it along with the EC2 build
path. Drop it and provide NATIVE_BUILD_DIR instead, which is the same trade this
job already makes for protoc: substitute a host tool rather than emulate a target
one.

The native configure mirrors the option set in aten/src/ATen/CMakeLists.txt rather
than using SLEEF's defaults. SLEEF_BUILD_TESTS, SLEEF_BUILD_DFT and
SLEEF_BUILD_GNUABI_LIBS change which host executables exist at all, so a mismatch
between the two configurations would not fail here; it would surface much later as
an IMPORTED_LOCATION pointing at a binary that was never built.

NATIVE_BUILD_DIR is passed as a CMake define rather than added to _ENV_PASSTHROUGH
in cmake/EnvVarForwarding.cmake, unlike CAFFE2_CUSTOM_PROTOC_EXECUTABLE in the
preceding commit. The protoc variable is a documented PyTorch cross-compilation
knob that any cross build benefits from having forwarded; NATIVE_BUILD_DIR is a
generic SLEEF-internal name, and claiming it in PyTorch's environment namespace
seems worse than passing it explicitly. Happy to move it if reviewers disagree.

This commit was authored with the assistance of an AI coding assistant.

Test Plan:

Needs a ciflow/riscv64 run; the job is opt-in and cannot be exercised locally.

Run 33062775136, on the parent commit, is the failure above. It also confirms the
protoc change worked: the vendored protoc is still linked
(`[237/2351] Linking CXX executable bin/protoc-3.21.12.0`) but never executed, and
the build passed onnx codegen to reach SLEEF.

The native SLEEF build was exercised locally with the same options, against the
checked-out submodule:

```
cmake -S third_party/sleef -B /tmp/sleef-native -G Ninja \
    -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc \
    -DSLEEF_BUILD_SHARED_LIBS=OFF -DSLEEF_BUILD_DFT=OFF \
    -DSLEEF_BUILD_GNUABI_LIBS=OFF -DSLEEF_BUILD_TESTS=OFF \
    -DSLEEF_BUILD_SCALAR_LIB=OFF -DSLEEF_DISABLE_OPENMP=ON
cmake --build /tmp/sleef-native
ls /tmp/sleef-native/bin/
```

completes in 99 targets and produces addSuffix, mkalias, mkdisp, mkmasked_gnuabi,
mkrename and mkrename_gnuabi; `/tmp/sleef-native/bin/mkrename` runs and prints its
usage. CMAKE_CXX_COMPILER is deliberately not passed, since SLEEF is C-only and
CMake warns that the variable is unused.

Lint:

```
lintrunner --paths-cmd='git diff --name-only origin/viable/strict'
bash -n .ci/pytorch/build.sh
```
zklaus added a commit to zklaus/pytorch that referenced this pull request Aug 29, 2026
With the cross toolchain restored, the build reaches onnx codegen and stops:

    /bin/sh: 1: /__w/pytorch/pytorch/build/bin/protoc-3.21.12.0: Exec format error

protoc is a build-time code generator. Cross-compiling third_party/protobuf
produces a riscv64 protoc, and the x86_64 build host cannot run it.

This used to work by emulation. The riscv64 job ran on the EC2 path of
_linux-build.yml, which mounted binfmt_misc, registered qemu-riscv64 via
multiarch/qemu-user-static, and ran the build container privileged. pytorch#189113
deleted that path on 2026-07-06 when the OSDC/ARC migration was wrapped up, and
the OSDC path it left behind has no equivalent -- no binfmt, qemu or privileged
anywhere in the workflow today. That is also what the image's QEMU_LD_PREFIX and
this block's SLEEF_TARGET_EXEC_USE_QEMU have always been assuming: the image has
never installed qemu itself, because the host used to provide it.

Rather than restore emulation, which needs privileged containers that may not be
available on OSDC at all, supply a protoc built for the host. cmake/ProtoBuf.cmake
documents CAFFE2_CUSTOM_PROTOC_EXECUTABLE for precisely this case, and
Dependencies.cmake forwards it to ONNX_CUSTOM_PROTOC_EXECUTABLE, so it covers the
codegen that fails here. conda-forge solves the same problem the same way: their
recipe repoints protobuf's imported target at the build-prefix protoc, with the
comment "It helps cross compiled builds without emulation support to complete".

The version has to track third_party/protobuf, currently v21.12, since generated
sources must stay compatible with the libprotobuf built for the target. conda-forge
publishes libprotobuf 3.21.12, which is an exact match.

The variable needs the passthrough entry to have any effect. It does not start with
BUILD_, USE_ or CMAKE_, so without being listed it would never reach the CMake
cache, and ProtoBuf.cmake gates on if(EXISTS ...) -- an unforwarded value would
silently fall back to the vendored protoc and fail exactly as before. It is a
genuine cross-compilation knob, so forwarding it helps any cross build, not only
this job.

The pixi bootstrap is deliberately temporary, and stage 2 replaces it. Ubuntu noble
ships protobuf-compiler at 3.21.12, the same version, so the eventual form is an
apt install in .ci/docker/ubuntu-cross-riscv/Dockerfile with no bootstrap at all.
It is not done here because any change under .ci/docker rehashes the directory and
rebuilds every CI image, and this build has more unexplored ground ahead of it --
SLEEF_TARGET_EXEC_USE_QEMU=ON still asks to execute target binaries, so protoc is
unlikely to be the last thing emulation was covering.

This commit was authored with the assistance of an AI coding assistant.

Test Plan:

Needs a ciflow/riscv64 run; the job is opt-in and cannot be exercised locally.

Run 33059855491, on the parent commit, is the failure above. It configured with
riscv64-linux-gnu-gcc-14, compiled cpuinfo's RISC-V backend, and reached 395 of
2351 targets before protoc stopped it -- the furthest since 2025-07.

Verified locally that the pinned package supplies a matching protoc, using an
isolated PIXI_HOME so as not to touch an existing pixi installation:

```
PIXI_HOME=$(mktemp -d) pixi global install "libprotobuf==3.21.12"
"$PIXI_HOME/bin/protoc" --version
```

prints `libprotoc 3.21.12`, against `git -C third_party/protobuf describe --tags`
reporting `v21.12`.

Checked the bootstrap's requirements against the image: the pixi installer accepts
either curl or wget and unpacks a tar.gz on Linux, and the image provides wget and
tar but no curl. PIXI_HOME is kept outside the checkout because build.sh runs
assert_git_not_dirty, and PIXI_NO_PATH_UPDATE stops the installer rewriting shell
profiles.

Confirmed conda-forge publishes the matching version:

```
curl -sS https://api.anaconda.org/package/conda-forge/libprotobuf \
  | python3 -c "import json,sys; print([v for v in json.load(sys.stdin)['versions'] if v.startswith('3.21')])"
```

lists 3.21.1 through 3.21.12.

Lint:

```
lintrunner --paths-cmd='git diff --name-only origin/viable/strict'
bash -n .ci/pytorch/build.sh
```
zklaus added a commit to zklaus/pytorch that referenced this pull request Aug 29, 2026
With protoc supplied from the host, the build clears onnx and reaches 701 of
2351 targets before SLEEF stops it the same way:

    /bin/sh: 1: /__w/pytorch/pytorch/build/sleef/bin/mkrename: Exec format error
    FAILED: sleef/src/libm/include/renamervvm1nofma.h

mkrename and its siblings are code generators that run during the build, so
cross-compiling them produces binaries the x86_64 host cannot execute.

Unlike protoc, this one is self-inflicted. SLEEF already has a cross path that
needs no emulation -- add_host_executable in third_party/sleef/CMakeLists.txt
imports the tools from NATIVE_BUILD_DIR when cross-compiling. It is not taken
here because SLEEF_TARGET_EXEC_USE_QEMU is set, which selects an earlier branch
that builds the tools for the target and runs them under emulation:

    if (NOT CMAKE_CROSSCOMPILING)
      add_executable(${TARGETNAME} ${ARGN})
    elseif (DEFINED ENV{SLEEF_TARGET_EXEC_USE_QEMU})
      if($ENV{SLEEF_TARGET_EXEC_USE_QEMU})
        add_executable(${TARGETNAME} ${ARGN})
      endif()
    else()
      add_executable(${TARGETNAME} IMPORTED GLOBAL)
      set_property(TARGET ${TARGETNAME} PROPERTY
                   IMPORTED_LOCATION ${NATIVE_BUILD_DIR}/bin/${TARGETNAME})
    endif()

That variable was correct when the workflow registered qemu-riscv64 with
binfmt_misc, and has been wrong since pytorch#189113 removed it along with the EC2 build
path. Drop it and provide NATIVE_BUILD_DIR instead, which is the same trade this
job already makes for protoc: substitute a host tool rather than emulate a target
one.

The native configure mirrors the option set in aten/src/ATen/CMakeLists.txt rather
than using SLEEF's defaults. SLEEF_BUILD_TESTS, SLEEF_BUILD_DFT and
SLEEF_BUILD_GNUABI_LIBS change which host executables exist at all, so a mismatch
between the two configurations would not fail here; it would surface much later as
an IMPORTED_LOCATION pointing at a binary that was never built.

NATIVE_BUILD_DIR is passed as a CMake define rather than added to _ENV_PASSTHROUGH
in cmake/EnvVarForwarding.cmake, unlike CAFFE2_CUSTOM_PROTOC_EXECUTABLE in the
preceding commit. The protoc variable is a documented PyTorch cross-compilation
knob that any cross build benefits from having forwarded; NATIVE_BUILD_DIR is a
generic SLEEF-internal name, and claiming it in PyTorch's environment namespace
seems worse than passing it explicitly. Happy to move it if reviewers disagree.

This commit was authored with the assistance of an AI coding assistant.

Test Plan:

Needs a ciflow/riscv64 run; the job is opt-in and cannot be exercised locally.

Run 33062775136, on the parent commit, is the failure above. It also confirms the
protoc change worked: the vendored protoc is still linked
(`[237/2351] Linking CXX executable bin/protoc-3.21.12.0`) but never executed, and
the build passed onnx codegen to reach SLEEF.

The native SLEEF build was exercised locally with the same options, against the
checked-out submodule:

```
cmake -S third_party/sleef -B /tmp/sleef-native -G Ninja \
    -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc \
    -DSLEEF_BUILD_SHARED_LIBS=OFF -DSLEEF_BUILD_DFT=OFF \
    -DSLEEF_BUILD_GNUABI_LIBS=OFF -DSLEEF_BUILD_TESTS=OFF \
    -DSLEEF_BUILD_SCALAR_LIB=OFF -DSLEEF_DISABLE_OPENMP=ON
cmake --build /tmp/sleef-native
ls /tmp/sleef-native/bin/
```

completes in 99 targets and produces addSuffix, mkalias, mkdisp, mkmasked_gnuabi,
mkrename and mkrename_gnuabi; `/tmp/sleef-native/bin/mkrename` runs and prints its
usage. CMAKE_CXX_COMPILER is deliberately not passed, since SLEEF is C-only and
CMake warns that the variable is unused.

Lint:

```
lintrunner --paths-cmd='git diff --name-only origin/viable/strict'
bash -n .ci/pytorch/build.sh
```
zklaus added a commit to zklaus/pytorch that referenced this pull request Sep 14, 2026
With the cross toolchain restored, the build reaches onnx codegen and stops:

    /bin/sh: 1: /__w/pytorch/pytorch/build/bin/protoc-3.21.12.0: Exec format error

protoc is a build-time code generator. Cross-compiling third_party/protobuf
produces a riscv64 protoc, and the x86_64 build host cannot run it.

This used to work by emulation. The riscv64 job ran on the EC2 path of
_linux-build.yml, which mounted binfmt_misc, registered qemu-riscv64 via
multiarch/qemu-user-static, and ran the build container privileged. pytorch#189113
deleted that path on 2026-07-06 when the OSDC/ARC migration was wrapped up, and
the OSDC path it left behind has no equivalent -- no binfmt, qemu or privileged
anywhere in the workflow today. That is also what the image's QEMU_LD_PREFIX and
this block's SLEEF_TARGET_EXEC_USE_QEMU have always been assuming: the image has
never installed qemu itself, because the host used to provide it.

Rather than restore emulation, which needs privileged containers that may not be
available on OSDC at all, supply a protoc built for the host. cmake/ProtoBuf.cmake
documents CAFFE2_CUSTOM_PROTOC_EXECUTABLE for precisely this case, and
Dependencies.cmake forwards it to ONNX_CUSTOM_PROTOC_EXECUTABLE, so it covers the
codegen that fails here. conda-forge solves the same problem the same way: their
recipe repoints protobuf's imported target at the build-prefix protoc, with the
comment "It helps cross compiled builds without emulation support to complete".

The version has to track third_party/protobuf, currently v21.12, since generated
sources must stay compatible with the libprotobuf built for the target. conda-forge
publishes libprotobuf 3.21.12, which is an exact match.

The variable needs the passthrough entry to have any effect. It does not start with
BUILD_, USE_ or CMAKE_, so without being listed it would never reach the CMake
cache, and ProtoBuf.cmake gates on if(EXISTS ...) -- an unforwarded value would
silently fall back to the vendored protoc and fail exactly as before. It is a
genuine cross-compilation knob, so forwarding it helps any cross build, not only
this job.

The pixi bootstrap is deliberately temporary, and stage 2 replaces it. Ubuntu noble
ships protobuf-compiler at 3.21.12, the same version, so the eventual form is an
apt install in .ci/docker/ubuntu-cross-riscv/Dockerfile with no bootstrap at all.
It is not done here because any change under .ci/docker rehashes the directory and
rebuilds every CI image, and this build has more unexplored ground ahead of it --
SLEEF_TARGET_EXEC_USE_QEMU=ON still asks to execute target binaries, so protoc is
unlikely to be the last thing emulation was covering.

This commit was authored with the assistance of an AI coding assistant.

Test Plan:

Needs a ciflow/riscv64 run; the job is opt-in and cannot be exercised locally.

Run 33059855491, on the parent commit, is the failure above. It configured with
riscv64-linux-gnu-gcc-14, compiled cpuinfo's RISC-V backend, and reached 395 of
2351 targets before protoc stopped it -- the furthest since 2025-07.

Verified locally that the pinned package supplies a matching protoc, using an
isolated PIXI_HOME so as not to touch an existing pixi installation:

```
PIXI_HOME=$(mktemp -d) pixi global install "libprotobuf==3.21.12"
"$PIXI_HOME/bin/protoc" --version
```

prints `libprotoc 3.21.12`, against `git -C third_party/protobuf describe --tags`
reporting `v21.12`.

Checked the bootstrap's requirements against the image: the pixi installer accepts
either curl or wget and unpacks a tar.gz on Linux, and the image provides wget and
tar but no curl. PIXI_HOME is kept outside the checkout because build.sh runs
assert_git_not_dirty, and PIXI_NO_PATH_UPDATE stops the installer rewriting shell
profiles.

Confirmed conda-forge publishes the matching version:

```
curl -sS https://api.anaconda.org/package/conda-forge/libprotobuf \
  | python3 -c "import json,sys; print([v for v in json.load(sys.stdin)['versions'] if v.startswith('3.21')])"
```

lists 3.21.1 through 3.21.12.

Lint:

```
lintrunner --paths-cmd='git diff --name-only origin/viable/strict'
bash -n .ci/pytorch/build.sh
```
zklaus added a commit to zklaus/pytorch that referenced this pull request Sep 14, 2026
With protoc supplied from the host, the build clears onnx and reaches 701 of
2351 targets before SLEEF stops it the same way:

    /bin/sh: 1: /__w/pytorch/pytorch/build/sleef/bin/mkrename: Exec format error
    FAILED: sleef/src/libm/include/renamervvm1nofma.h

mkrename and its siblings are code generators that run during the build, so
cross-compiling them produces binaries the x86_64 host cannot execute.

Unlike protoc, this one is self-inflicted. SLEEF already has a cross path that
needs no emulation -- add_host_executable in third_party/sleef/CMakeLists.txt
imports the tools from NATIVE_BUILD_DIR when cross-compiling. It is not taken
here because SLEEF_TARGET_EXEC_USE_QEMU is set, which selects an earlier branch
that builds the tools for the target and runs them under emulation:

    if (NOT CMAKE_CROSSCOMPILING)
      add_executable(${TARGETNAME} ${ARGN})
    elseif (DEFINED ENV{SLEEF_TARGET_EXEC_USE_QEMU})
      if($ENV{SLEEF_TARGET_EXEC_USE_QEMU})
        add_executable(${TARGETNAME} ${ARGN})
      endif()
    else()
      add_executable(${TARGETNAME} IMPORTED GLOBAL)
      set_property(TARGET ${TARGETNAME} PROPERTY
                   IMPORTED_LOCATION ${NATIVE_BUILD_DIR}/bin/${TARGETNAME})
    endif()

That variable was correct when the workflow registered qemu-riscv64 with
binfmt_misc, and has been wrong since pytorch#189113 removed it along with the EC2 build
path. Drop it and provide NATIVE_BUILD_DIR instead, which is the same trade this
job already makes for protoc: substitute a host tool rather than emulate a target
one.

The native configure mirrors the option set in aten/src/ATen/CMakeLists.txt rather
than using SLEEF's defaults. SLEEF_BUILD_TESTS, SLEEF_BUILD_DFT and
SLEEF_BUILD_GNUABI_LIBS change which host executables exist at all, so a mismatch
between the two configurations would not fail here; it would surface much later as
an IMPORTED_LOCATION pointing at a binary that was never built.

NATIVE_BUILD_DIR is passed as a CMake define rather than added to _ENV_PASSTHROUGH
in cmake/EnvVarForwarding.cmake, unlike CAFFE2_CUSTOM_PROTOC_EXECUTABLE in the
preceding commit. The protoc variable is a documented PyTorch cross-compilation
knob that any cross build benefits from having forwarded; NATIVE_BUILD_DIR is a
generic SLEEF-internal name, and claiming it in PyTorch's environment namespace
seems worse than passing it explicitly. Happy to move it if reviewers disagree.

This commit was authored with the assistance of an AI coding assistant.

Test Plan:

Needs a ciflow/riscv64 run; the job is opt-in and cannot be exercised locally.

Run 33062775136, on the parent commit, is the failure above. It also confirms the
protoc change worked: the vendored protoc is still linked
(`[237/2351] Linking CXX executable bin/protoc-3.21.12.0`) but never executed, and
the build passed onnx codegen to reach SLEEF.

The native SLEEF build was exercised locally with the same options, against the
checked-out submodule:

```
cmake -S third_party/sleef -B /tmp/sleef-native -G Ninja \
    -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc \
    -DSLEEF_BUILD_SHARED_LIBS=OFF -DSLEEF_BUILD_DFT=OFF \
    -DSLEEF_BUILD_GNUABI_LIBS=OFF -DSLEEF_BUILD_TESTS=OFF \
    -DSLEEF_BUILD_SCALAR_LIB=OFF -DSLEEF_DISABLE_OPENMP=ON
cmake --build /tmp/sleef-native
ls /tmp/sleef-native/bin/
```

completes in 99 targets and produces addSuffix, mkalias, mkdisp, mkmasked_gnuabi,
mkrename and mkrename_gnuabi; `/tmp/sleef-native/bin/mkrename` runs and prints its
usage. CMAKE_CXX_COMPILER is deliberately not passed, since SLEEF is C-only and
CMake warns that the variable is unused.

Lint:

```
lintrunner --paths-cmd='git diff --name-only origin/viable/strict'
bash -n .ci/pytorch/build.sh
```
zklaus added a commit to zklaus/pytorch that referenced this pull request Sep 29, 2026
With the cross toolchain restored, the build reaches onnx codegen and stops:

    /bin/sh: 1: /__w/pytorch/pytorch/build/bin/protoc-3.21.12.0: Exec format error

protoc is a build-time code generator. Cross-compiling third_party/protobuf
produces a riscv64 protoc, and the x86_64 build host cannot run it.

This used to work by emulation. The riscv64 job ran on the EC2 path of
_linux-build.yml, which mounted binfmt_misc, registered qemu-riscv64 via
multiarch/qemu-user-static, and ran the build container privileged. pytorch#189113
deleted that path on 2026-07-06 when the OSDC/ARC migration was wrapped up, and
the OSDC path it left behind has no equivalent -- no binfmt, qemu or privileged
anywhere in the workflow today. That is also what the image's QEMU_LD_PREFIX and
this block's SLEEF_TARGET_EXEC_USE_QEMU have always been assuming: the image has
never installed qemu itself, because the host used to provide it.

Rather than restore emulation, which needs privileged containers that may not be
available on OSDC at all, supply a protoc built for the host. cmake/ProtoBuf.cmake
documents CAFFE2_CUSTOM_PROTOC_EXECUTABLE for precisely this case, and
Dependencies.cmake forwards it to ONNX_CUSTOM_PROTOC_EXECUTABLE, so it covers the
codegen that fails here. conda-forge solves the same problem the same way: their
recipe repoints protobuf's imported target at the build-prefix protoc, with the
comment "It helps cross compiled builds without emulation support to complete".

The version has to track third_party/protobuf, currently v21.12, since generated
sources must stay compatible with the libprotobuf built for the target. conda-forge
publishes libprotobuf 3.21.12, which is an exact match.

The variable needs the passthrough entry to have any effect. It does not start with
BUILD_, USE_ or CMAKE_, so without being listed it would never reach the CMake
cache, and ProtoBuf.cmake gates on if(EXISTS ...) -- an unforwarded value would
silently fall back to the vendored protoc and fail exactly as before. It is a
genuine cross-compilation knob, so forwarding it helps any cross build, not only
this job.

The pixi bootstrap is deliberately temporary, and stage 2 replaces it. Ubuntu noble
ships protobuf-compiler at 3.21.12, the same version, so the eventual form is an
apt install in .ci/docker/ubuntu-cross-riscv/Dockerfile with no bootstrap at all.
It is not done here because any change under .ci/docker rehashes the directory and
rebuilds every CI image, and this build has more unexplored ground ahead of it --
SLEEF_TARGET_EXEC_USE_QEMU=ON still asks to execute target binaries, so protoc is
unlikely to be the last thing emulation was covering.

This commit was authored with the assistance of an AI coding assistant.

Test Plan:

Needs a ciflow/riscv64 run; the job is opt-in and cannot be exercised locally.

Run 33059855491, on the parent commit, is the failure above. It configured with
riscv64-linux-gnu-gcc-14, compiled cpuinfo's RISC-V backend, and reached 395 of
2351 targets before protoc stopped it -- the furthest since 2025-07.

Verified locally that the pinned package supplies a matching protoc, using an
isolated PIXI_HOME so as not to touch an existing pixi installation:

```
PIXI_HOME=$(mktemp -d) pixi global install "libprotobuf==3.21.12"
"$PIXI_HOME/bin/protoc" --version
```

prints `libprotoc 3.21.12`, against `git -C third_party/protobuf describe --tags`
reporting `v21.12`.

Checked the bootstrap's requirements against the image: the pixi installer accepts
either curl or wget and unpacks a tar.gz on Linux, and the image provides wget and
tar but no curl. PIXI_HOME is kept outside the checkout because build.sh runs
assert_git_not_dirty, and PIXI_NO_PATH_UPDATE stops the installer rewriting shell
profiles.

Confirmed conda-forge publishes the matching version:

```
curl -sS https://api.anaconda.org/package/conda-forge/libprotobuf \
  | python3 -c "import json,sys; print([v for v in json.load(sys.stdin)['versions'] if v.startswith('3.21')])"
```

lists 3.21.1 through 3.21.12.

Lint:

```
lintrunner --paths-cmd='git diff --name-only origin/viable/strict'
bash -n .ci/pytorch/build.sh
```
zklaus added a commit to zklaus/pytorch that referenced this pull request Sep 29, 2026
With protoc supplied from the host, the build clears onnx and reaches 701 of
2351 targets before SLEEF stops it the same way:

    /bin/sh: 1: /__w/pytorch/pytorch/build/sleef/bin/mkrename: Exec format error
    FAILED: sleef/src/libm/include/renamervvm1nofma.h

mkrename and its siblings are code generators that run during the build, so
cross-compiling them produces binaries the x86_64 host cannot execute.

Unlike protoc, this one is self-inflicted. SLEEF already has a cross path that
needs no emulation -- add_host_executable in third_party/sleef/CMakeLists.txt
imports the tools from NATIVE_BUILD_DIR when cross-compiling. It is not taken
here because SLEEF_TARGET_EXEC_USE_QEMU is set, which selects an earlier branch
that builds the tools for the target and runs them under emulation:

    if (NOT CMAKE_CROSSCOMPILING)
      add_executable(${TARGETNAME} ${ARGN})
    elseif (DEFINED ENV{SLEEF_TARGET_EXEC_USE_QEMU})
      if($ENV{SLEEF_TARGET_EXEC_USE_QEMU})
        add_executable(${TARGETNAME} ${ARGN})
      endif()
    else()
      add_executable(${TARGETNAME} IMPORTED GLOBAL)
      set_property(TARGET ${TARGETNAME} PROPERTY
                   IMPORTED_LOCATION ${NATIVE_BUILD_DIR}/bin/${TARGETNAME})
    endif()

That variable was correct when the workflow registered qemu-riscv64 with
binfmt_misc, and has been wrong since pytorch#189113 removed it along with the EC2 build
path. Drop it and provide NATIVE_BUILD_DIR instead, which is the same trade this
job already makes for protoc: substitute a host tool rather than emulate a target
one.

The native configure mirrors the option set in aten/src/ATen/CMakeLists.txt rather
than using SLEEF's defaults. SLEEF_BUILD_TESTS, SLEEF_BUILD_DFT and
SLEEF_BUILD_GNUABI_LIBS change which host executables exist at all, so a mismatch
between the two configurations would not fail here; it would surface much later as
an IMPORTED_LOCATION pointing at a binary that was never built.

NATIVE_BUILD_DIR is passed as a CMake define rather than added to _ENV_PASSTHROUGH
in cmake/EnvVarForwarding.cmake, unlike CAFFE2_CUSTOM_PROTOC_EXECUTABLE in the
preceding commit. The protoc variable is a documented PyTorch cross-compilation
knob that any cross build benefits from having forwarded; NATIVE_BUILD_DIR is a
generic SLEEF-internal name, and claiming it in PyTorch's environment namespace
seems worse than passing it explicitly. Happy to move it if reviewers disagree.

This commit was authored with the assistance of an AI coding assistant.

Test Plan:

Needs a ciflow/riscv64 run; the job is opt-in and cannot be exercised locally.

Run 33062775136, on the parent commit, is the failure above. It also confirms the
protoc change worked: the vendored protoc is still linked
(`[237/2351] Linking CXX executable bin/protoc-3.21.12.0`) but never executed, and
the build passed onnx codegen to reach SLEEF.

The native SLEEF build was exercised locally with the same options, against the
checked-out submodule:

```
cmake -S third_party/sleef -B /tmp/sleef-native -G Ninja \
    -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc \
    -DSLEEF_BUILD_SHARED_LIBS=OFF -DSLEEF_BUILD_DFT=OFF \
    -DSLEEF_BUILD_GNUABI_LIBS=OFF -DSLEEF_BUILD_TESTS=OFF \
    -DSLEEF_BUILD_SCALAR_LIB=OFF -DSLEEF_DISABLE_OPENMP=ON
cmake --build /tmp/sleef-native
ls /tmp/sleef-native/bin/
```

completes in 99 targets and produces addSuffix, mkalias, mkdisp, mkmasked_gnuabi,
mkrename and mkrename_gnuabi; `/tmp/sleef-native/bin/mkrename` runs and prints its
usage. CMAKE_CXX_COMPILER is deliberately not passed, since SLEEF is C-only and
CMake warns that the variable is unused.

Lint:

```
lintrunner --paths-cmd='git diff --name-only origin/viable/strict'
bash -n .ci/pytorch/build.sh
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants