Skip to content

fix: build the full image's C++ libraries like AtCoder and test the images with ojt in CI - #20

Merged
haiiro2gou merged 8 commits into
masterfrom
worktree-full-cxx-link
Sep 24, 2026
Merged

haiiro2gou merged 8 commits into
masterfrom
worktree-full-cxx-link

Conversation

@carbon-nil

Copy link
Copy Markdown
Owner

Summary

Make the full image's C++ libraries usable through ojt exactly as AtCoder links them, and test the images in CI.

  • Abseil (9800ad7): install only 20250512.1.
    • apt's 20220623 sat in /usr/lib/<triplet>, which the linker searches before /usr/local/lib.
    • So programs got the old libraries with the new headers.
  • ojt linking (d75969e):
    • ojt passed none of AtCoder's defines or libraries, so OR-Tools headers did not even compile, and Abseil / LightGBM / LibTorch did not link.
    • It now adds -fopenmp -DNOMINMAX -lstdc++exp like the judge.
    • In full, it also reads cxx/full-flags.txt: AtCoder's defines and -l list, with libraries the image lacks dropped at build time.
    • LightGBM is installed as a static library like AtCoder's.
    • LibTorch gets an rpath (and rpath-link for arm64's vendored libs).
  • Abseil + OR-Tools from source (3c912b4, 1123a21, 815cd4e):
    • The prebuilt arm64 OR-Tools is an AlmaLinux build that re-exports libstdc++ symbols. Together with LibTorch it crashed before main (Abseil flag registration).
    • Both are now built from source with AtCoder's options (including GLPK) in a separate cxx-libs-build stage.
    • That stage is cached independently of the rest of full. It needs apt's Eigen, and its man pages are dropped so it can be copied into /usr/local.
    • GCC 15 moves into its own gcc stage so edits to light do not invalidate it.
  • amd64 libtorch's protobuf (f6916df): delete the libprotobuf*.a bundled with libtorch, as AtCoder does. -L/opt/libtorch/lib made -lprotobuf pick that older copy.
  • Tests in CI (450ed1b):
    • The build job loads the image it just built and runs test/light.sh (C++, Python, PyPy and Rust through ojt) or test/full.sh (the same, plus one program that uses Abseil, Boost, GMP, LightGBM, OR-Tools, LibTorch, Z3 and OpenMP together).
    • This replaces running ojt inside the Dockerfile. That tested an unfinished image, hit PyPI through oj's update check, and invalidated the cache below it.

Still different from AtCoder: 4 Boost libraries (charconv, contract, process, stacktrace_from_exception) are missing from Ubuntu's Boost 1.83 and are skipped. A follow-up PR moves to Boost 1.88.

Test

CI, all four builds including the new test step: https://github.com/carbon-nil/atcoder-docker/actions/runs/35998419705

  • light (amd64 / arm64): ojt AC for C++, Python, PyPy, Rust
  • full (amd64 / arm64): the same plus the combined library program

Earlier runs on this branch caught, in order:

  • the arm64 OR-Tools + LibTorch crash
  • the missing Eigen target
  • the /usr/local/man symlink conflict
  • the amd64 protobuf mix-up

🤖 Generated with Claude Code

https://claude.ai/code/session_01VQaZJRoT1k7VZ8ThsuLdFa

carbon-nil and others added 7 commits September 24, 2026 19:39
apt's libabsl-dev (20220623) sat in /usr/lib/<triplet>, which the linker
searches before /usr/local/lib, so programs compiled against the 20250512
headers linked the old libraries. AtCoder only has 20250512.1.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VQaZJRoT1k7VZ8ThsuLdFa
…der does

ojt passed none of AtCoder's defines or libraries, so OR-Tools headers did not
compile and Abseil, LightGBM, LibTorch and friends did not link. ojt now adds
-fopenmp, -DNOMINMAX and -lstdc++exp like the judge, and in the full image
reads cxx/full-flags.txt (AtCoder's defines and -l list, dropping libraries
the image lacks). LightGBM is installed as a static library like AtCoder's,
LibTorch gets an rpath, and libstdc++ is resolved before OR-Tools, whose arm64
build re-exports standard library symbols and otherwise gets linked into
every program (crashing together with LibTorch). A smoke test builds and runs
a program using all of them with ojt.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VQaZJRoT1k7VZ8ThsuLdFa
…tCoder

The prebuilt arm64 OR-Tools is an AlmaLinux build that re-exports libstdc++
symbols; linked together with LibTorch it crashed before main during
Abseil's flag registration. Build Abseil 20250512.1 and OR-Tools 9.14 (with
GLPK) from source with AtCoder's options in a separate cxx-libs-build stage,
cached independently of full. GCC 15 moves to its own gcc stage so edits to
light do not invalidate it. The -lstdc++ workaround is no longer needed and
-lGLPK is back in ojt's flags.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VQaZJRoT1k7VZ8ThsuLdFa
…the Dockerfile

Running ojt mid-build tested an unfinished image, reached PyPI through oj's
update check, and invalidated the cache below it whenever the check changed.
The build job now loads the image it just built and runs test/light.sh or
test/full.sh (C++, Python, PyPy and Rust through ojt, plus the full image's
C++ libraries together).

Co-Authored-By: Claude Code <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VQaZJRoT1k7VZ8ThsuLdFa
…d into /usr/local

Co-Authored-By: Claude Code <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VQaZJRoT1k7VZ8ThsuLdFa
…orch, like AtCoder

-L/opt/libtorch/lib made -lprotobuf pick libtorch's older copy instead of the
one built with OR-Tools, so OR-Tools programs failed to link on amd64.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VQaZJRoT1k7VZ8ThsuLdFa
@haiiro2gou
haiiro2gou merged commit f24fda8 into master Sep 24, 2026
5 checks passed
@haiiro2gou
haiiro2gou deleted the worktree-full-cxx-link branch September 24, 2026 14:14
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.

2 participants