Skip to content

Bump bootgen to upstream Xilinx/bootgen xilinx_v2026.1, drop the jgmelber fork#3329

Queued
jgmelber wants to merge 15 commits into
mainfrom
bump-bootgen-2026.1
Queued

Bump bootgen to upstream Xilinx/bootgen xilinx_v2026.1, drop the jgmelber fork#3329
jgmelber wants to merge 15 commits into
mainfrom
bump-bootgen-2026.1

Conversation

@jgmelber

@jgmelber jgmelber commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • third_party/bootgen now tracks upstream Xilinx/bootgen directly (pinned to the xilinx_v2026.1 tag commit, e576e5e) instead of the jgmelber/bootgen fork. The fork existed only to carry two commits on top of upstream; both are reimplemented as mlir-aie-side build customizations instead, so there's nothing left to fork or rebase:
    • C API for exception-safe PDI generation (bootgen_c_api.cpp/.h): these only ever added new files and never touched upstream source, so they now live in tools/bootgen/ and compile/install from there — the same treatment as hss_thread_single.c below.
    • Print-statement removal: cdo-driver/cdo_driver.c's per-CDO-file printf("Generating: ...") (confirmed to matter: cdo_driver_mlir_aie's startCDOFileStream is called directly by lib/Targets/AIETargetCDODirect.cpp once per emitted CDO file, polluting aiecc's own output) is now stripped at configure time via the same file(READ)/REPLACE/WRITE pattern already used for the malloc.h/applink.c hacks.
  • Upstream restructured its entire source tree since the old fork's ~2023-era base (165/171 files moved into per-architecture common/, spartanup/, versal/, versal_2ve_2vm/, zynq/, zynqmp/, utils/ trees), and added a vendored lms-hash-sigs/ post-quantum signature library. tools/bootgen/CMakeLists.txt is rewritten to match: source lists are globbed per architecture directory (mirroring upstream's own Makefile), a new bootgen-lms-hash-sigs static library target is added, and tools/bootgen/hss_thread_single.c provides a single-threaded fallback for lms-hash-sigs' threading abstraction on platforms without pthreads (MSVC).
  • Fixes AIECC_HAS_BOOTGEN_LIBRARY never being defined: tools/CMakeLists.txt added tools/aiecc before tools/bootgen, so if(TARGET bootgen-lib) was always false at aiecc's configure time and the bootgen_generate_pdi() C API path was dead code. Swapped the order.
  • Includes Force PIE on bootgen to fix PDI-generation segfault #3327 (Force PIE on bootgen), already merged to main.
  • The old jgmelber/bootgen fork (branch c-api-support, backup tag c-api-support-pre-2026.1-rebase) is left in place but no longer referenced by anything.

Test plan

  • tools/bootgen/CMakeLists.txt rewrite builds bootgen, bootgen-lib, and aiecc cleanly against a real MLIR install
  • Ran an actual NPU2 (AIE2p) design (matrix_scalar_add) through aiecc end-to-end via the bootgen library path ("Using bootgen library for PDI generation" / "Generated PDI via library"), producing a valid PDI
  • bootgen -help / CDO generation no longer prints "Generating: ..." per file
  • A standalone call to bootgen_generate_pdi() against the same BIF (in isolation) produces a byte-identical PDI to the CLI-generated one
  • Fixed 2 real cross-platform build issues caught by CI: GCC 14's default-error -Wincompatible-pointer-types on vendored cdo-load.c, and a missing include dir for MSVC's non-pthread fallback
  • Not tested on real NPU hardware (dev box used for this change has no XRT/NPU device attached)

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings July 13, 2026 18:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the in-tree bootgen integration to match the upstream Xilinx/bootgen xilinx_v2026.1 source-tree restructure, including building the new vendored lms-hash-sigs dependency and updating the CMake build to discover sources per-architecture directory.

Changes:

  • Reworks tools/bootgen/CMakeLists.txt to glob sources from the new per-architecture */src layout and to use the relocated bison/flex outputs.
  • Adds a new static library target for the vendored lms-hash-sigs code and wires it into the bootgen build.
  • Updates the existing configure-time include-stripping hacks (malloc.h, applink.c) to the new upstream file locations, and pins PIC/PIE on the relevant targets.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tools/bootgen/CMakeLists.txt
Comment thread tools/bootgen/CMakeLists.txt Outdated
Comment thread tools/bootgen/CMakeLists.txt
Comment thread tools/bootgen/hss_thread_single.c Outdated
jgmelber and others added 6 commits July 13, 2026 13:38
Rebase the jgmelber/bootgen fork's two local commits (print-statement
removal, C API for exception-safe PDI generation) onto upstream
Xilinx/bootgen's xilinx_v2026.1 tag, 42 commits ahead of the fork's
previous base. The old c-api-support branch tip is preserved at tag
c-api-support-pre-2026.1-rebase in the fork for recovery.

Upstream restructured its entire source tree between the fork's old
base and 2026.1: 165 of 171 files moved from a single flat directory
into per-architecture common/, spartanup/, versal/, versal_2ve_2vm/,
zynq/, zynqmp/, and utils/ trees (each with src/ and include/
subdirs), and added a vendored lms-hash-sigs/ post-quantum hash-based
signature library for newer secure-boot support. The C API commit
(bootgen_c_api.cpp/.h) only adds new files and needed no source
changes to rebase cleanly; it's now relocated into common/src and
common/include to match the new layout.

Rewrite tools/bootgen/CMakeLists.txt to match:
- Source lists are now globbed per architecture directory (mirroring
  upstream's own Makefile) instead of a hand-maintained flat list.
- Add all of upstream's new include directories.
- Add a bootgen-lms-hash-sigs static library for the vendored LMS/HSS
  sources, linked into bootgen-lib, plus the new pthread dependency
  it introduces.
- Update the malloc.h/applink.c configure-time strip hacks to the new
  file paths.

Verified locally: the fork builds and runs standalone via its own
Makefile (`bootgen -help` reports v2026.1). The updated CMakeLists.txt
builds bootgen, bootgen-lib, and aiecc cleanly. Running an actual NPU2
(AIE2p) design (matrix_scalar_add) through aiecc's existing bootgen
subprocess path produces a valid PDI. A standalone test calling
bootgen_generate_pdi() directly against the same BIF produces a
byte-identical PDI, confirming the rebased C API still works
end-to-end.

Note: AIECC_HAS_BOOTGEN_LIBRARY is never actually defined today because
tools/CMakeLists.txt adds tools/aiecc before tools/bootgen, so
`if(TARGET bootgen-lib)` in tools/aiecc/CMakeLists.txt is always false
at configure time. This pre-existing ordering issue is unrelated to
this bump and is left for a follow-up.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
tools/aiecc/CMakeLists.txt gates the direct bootgen_generate_pdi() C
API integration on `if(TARGET bootgen-lib)`, but tools/CMakeLists.txt
added aiecc's subdirectory before bootgen's, so that target never
existed yet at aiecc's configure time. AIECC_HAS_BOOTGEN_LIBRARY was
therefore never defined and aiecc always fell back to shelling out to
the bootgen executable, silently defeating the whole point of the C
API added in the previous commit.

Swap the two add_subdirectory calls so bootgen-lib exists first.

Verified locally: aiecc now links against OpenSSL/bootgen-lib and
AIECC_HAS_BOOTGEN_LIBRARY shows up in its compile flags. Running the
matrix_scalar_add NPU2 example through aiecc now prints "Using
bootgen library for PDI generation" / "Generated PDI via library"
instead of falling back to the subprocess, and produces the same
valid PDI as before.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- Add CONFIGURE_DEPENDS to the per-architecture file(GLOB) calls, so
  CMake automatically reconfigures when upstream adds/removes source
  files instead of silently going stale until a manual reconfigure.
- Make bootgen-lib's and bootgen-lms-hash-sigs' library dependencies
  PUBLIC rather than PRIVATE. Both are static libraries, so PRIVATE
  usage requirements don't propagate to consumers by CMake's own
  usage-requirement rules; PUBLIC is the correct way to express that
  bootgen/aiecc genuinely need OpenSSL::Crypto/Threads::Threads
  transitively. (CMake does already thread the raw .a files for
  static-lib chains onto the final link line regardless of this
  keyword, which is why this wasn't an observed link failure, but
  PUBLIC is the semantically correct choice and matters if either
  library ever becomes SHARED.)
- Fix a real portability bug this exposed: the vendored lms-hash-sigs
  only ships a pthread-based implementation of its threading
  abstraction (hss_thread_pthread.c), which unconditionally
  #includes <pthread.h> and doesn't exist on MSVC. Add
  tools/bootgen/hss_thread_single.c, a small single-threaded
  implementation of the same documented API (hss_thread.h explicitly
  allows a 0/NULL thread collection as a valid non-threaded mode),
  and select it via CMAKE_USE_PTHREADS_INIT instead of assuming
  pthreads are always available.

Verified locally: bootgen/bootgen-lib/aiecc still build and link
(aiecc's link line now explicitly includes libbootgen-lms-hash-sigs.a
and libcrypto/libssl), and re-running the matrix_scalar_add NPU2
example through aiecc still prints "Using bootgen library for PDI
generation" and produces a valid PDI.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
No functional change; tighten the comments added in this branch to
be clear but concise.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
CI's clang-format-17 flagged the continuation-line indentation on
hss_thread_issue_work's declaration.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- ubuntu-24.04 gcc (all assert/rtti combos): GCC 14 makes
  -Wincompatible-pointer-types a hard error by default. Vendored
  bootgen code (utils/src/cdo-load.c) has a genuine char*/uint32_t*
  mismatch that only warned on older GCC. Add -Wno-incompatible-
  pointer-types to bootgen-lib's warning-ignore list, alongside the
  existing (Clang-only) -discards-qualifiers variant.

- windows-2022 msvc: hss_thread_single.c (in tools/bootgen/) does
  #include "hss_thread.h", but bootgen-lms-hash-sigs never had
  third_party/bootgen/lms-hash-sigs on its include path -- it worked
  by accident for hss_thread_pthread.c only because that file lives
  in the same directory as the header. Add the missing include dir.

Verified locally: reproduced the GCC 14 default-error behavior with
gcc-13 -Werror=incompatible-pointer-types and confirmed
-Wno-incompatible-pointer-types suppresses it; full bootgen/aiecc
rebuild still succeeds.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@jgmelber jgmelber force-pushed the bump-bootgen-2026.1 branch from bc51660 to acb0451 Compare July 13, 2026 19:40
@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Created: 2026-07-14 03:16

Click here for information about interpreting this report.

FilenameFunction CoverageLine CoverageRegion CoverageBranch Coverage
Totals- - - -
Generated by llvm-cov -- llvm version 18.1.3

The fork existed only to carry two commits: a print-statement removal
and the bootgen_c_api.cpp/.h C API. Neither actually needs to live in
bootgen's own source:

- bootgen_c_api.cpp/.h are pure new files that only consume bootgen's
  existing public headers (bootimage.h, options.h, bootgenexception.h)
  -- no upstream file is modified. Move them into tools/bootgen/ and
  compile/install them from there, the same way hss_thread_single.c
  already lives in mlir-aie rather than the submodule.
- The print statement in cdo-driver/cdo_driver.c is stripped at
  configure time instead, via the same file(READ)/REPLACE/WRITE
  pattern already used for the malloc.h/applink.c hacks below it.
  (Confirmed real: cdo_driver_mlir_aie's startCDOFileStream is called
  directly by lib/Targets/AIETargetCDODirect.cpp once per emitted CDO
  file, not just from the bootgen executable, so this does affect
  aiecc's own output.)

third_party/bootgen now points straight at Xilinx/bootgen's
xilinx_v2026.1 tag commit (e576e5e), with no fork and nothing left to
rebase going forward. The jgmelber/bootgen fork and its
c-api-support/c-api-support-pre-2026.1-rebase refs are left in place
but no longer used by anything.

Verified locally: bootgen/bootgen-lib/aiecc still build; `bootgen
-help` no longer prints "Generating: ..." per CDO file; the
matrix_scalar_add NPU2 example still produces a valid PDI via
aiecc's library path; a standalone call to bootgen_generate_pdi()
against the same BIF (run in isolation, avoiding stale output files
from earlier tests) is byte-identical to the CLI-generated PDI.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@jgmelber jgmelber changed the title Bump bootgen submodule fork to upstream xilinx_v2026.1 Bump bootgen to upstream Xilinx/bootgen xilinx_v2026.1, drop the jgmelber fork Jul 13, 2026
Comment thread tools/bootgen/bootgen_c_api.cpp
Comment thread tools/bootgen/bootgen_c_api.cpp Outdated
Comment thread tools/bootgen/bootgen_c_api.cpp Outdated
jgmelber and others added 2 commits July 13, 2026 13:59
Now that these files live in mlir-aie rather than the bootgen
submodule, use this repo's standard SPDX header (matching e.g.
tools/aiecc/aiecc.cpp) instead of the full Apache License boilerplate
carried over from upstream bootgen. Also fixes the clang-format
findings from CI (include ordering, line wrapping).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
AIECC_HAS_BOOTGEN_LIBRARY was never actually defined before this
branch's tools/CMakeLists.txt fix (bootgen was added after aiecc, so
`if(TARGET bootgen-lib)` was always false), so this test's PDI check
had only ever run against the subprocess fallback in practice. Now
that the library path is real, it prints "Generated PDI via library:
..." rather than "Generated PDI: ...", which doesn't literally
contain the checked substring.

Drop the trailing colon so the check matches both "Generated PDI:"
(subprocess) and "Generated PDI via library:" (library) -- the test's
own docstring already says it should cover both.

Verified locally: FileCheck passes against real aiecc --verbose
output through the library path.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Comment thread tools/bootgen/bootgen_c_api.cpp
Comment thread tools/bootgen/CMakeLists.txt Outdated
jgmelber and others added 3 commits July 13, 2026 15:10
- bootgen_generate_pdi collapsed both bif_path and pdi_path NULL checks
  into BOOTGEN_ERROR_INVALID_BIF, leaving BOOTGEN_ERROR_INVALID_OUTPUT
  unused and giving callers no way to distinguish which argument was
  missing. Split into two checks returning the matching error code.

- -Wno-incompatible-pointer-types(-discards-qualifiers) are C-only
  diagnostics; passing them while compiling bootgen-lib's .cpp sources
  is an unused command-line argument, which -Werror=unused (enabled at
  the top level) turns into a hard error. Gate both to C compilation
  only via $<$<COMPILE_LANGUAGE:C>:...>. Verified in an isolated CMake
  sandbox with -Werror=unused-command-line-argument: the flag reaches
  the .c compile line and is dropped from the .cpp one.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…e CMake property

Same fix as #3333 (against main), carried forward here since this branch
replaces bootgen's CMakeLists.txt with the 2026.1 upstream-source layout.

The POSITION_INDEPENDENT_CODE property set on bootgen-lib/bootgen doesn't
actually force PIE: this project never calls check_pie_supported(), which
CMake's CMP0083 needs to turn that property into real -fPIE/-pie flags for
an executable target. Confirmed via readelf + strace that the wheel built
from #3327's own commit (main's earlier attempt at this) still ships a
non-PIE `bootgen` and segfaults (SIGSEGV/SEGV_ACCERR jumping into its own
non-executable DYNAMIC segment) once auditwheel repair patches in an RPATH
for vendored OpenSSL -- manylinux_2_28's gcc-toolset doesn't default to
PIE the way a distro's system gcc does.

Pass -fPIC/-fPIE/-pie explicitly, last, so they win over any inherited
-fno-pie/-fno-PIC via ordinary last-flag-wins compiler semantics. Verified
locally under a forced -fno-pie -fno-PIC -no-pie global configuration that
this reliably produces a true PIE (ET_DYN) bootgen, unlike the
property-only approach.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- Guard the new -fPIC/-fPIE blocks with NOT MSVC too: clang-cl reports
  CMAKE_CXX_COMPILER_ID "Clang" but uses the MSVC-style driver, which
  doesn't accept these GNU-style flags.
- Drop -fPIE from target_link_options(bootgen ...); it's a compile-only
  flag, and passing it at link time can break toolchains where linking
  doesn't go through the compiler driver. Only -pie belongs there.

Re-verified locally under the same forced -fno-pie -fno-PIC -no-pie
global configuration as before: bootgen still links as a true PIE
(ET_DYN) binary and runs correctly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
jgmelber added 2 commits July 13, 2026 15:45
Refactor comments for clarity and remove unnecessary lines.
@jgmelber jgmelber added this pull request to the merge queue Jul 14, 2026
Any commits made after this event will not be merged.
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.

4 participants