docs: note lean_exe libstdc++ link failure on Linux (see #196) - #197
Closed
ide-developer wants to merge 1 commit into
Closed
docs: note lean_exe libstdc++ link failure on Linux (see #196)#197ide-developer wants to merge 1 commit into
ide-developer wants to merge 1 commit into
Conversation
A lean_exe target in a downstream project can fail to link with undefined libstdc++ symbols even when a lean_lib target in the same project builds and works fine, because Lean's executable link recipe statically links libc++/libc++abi and never links libstdc++, while Lean Copilot's native code is built against system libstdc++. Add a Caveats entry pointing to the full root-cause analysis and working moreLinkArgs workaround in lean-dojo#196.
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
Caveatsentry documenting a real, reproducible link failure hit when a downstream project has alean_exetarget (not just alean_lib) depending on Lean Copilot.Context
Filed and fully root-caused in #196: a
lean_libtarget that imports Lean Copilot and callssuggest_tacticsbuilds and runs correctly, but alean_exetarget in the same project fails to link with ~15 distinctundefined symbolerrors for libstdc++ types (vtable for std::basic_ifstream,std::filesystem::path, etc.), all originating fromct2.cppinsidelibleanffi.a.Root cause (confirmed against Lean's own executable link command and clang's driver source): Lean's
lean_exelink recipe statically linkslibc++/libc++abiand never linkslibstdc++at all, while Lean Copilot's native code is built by systemg++againstlibstdc++. The library target works because its.soresolveslibstdc++transitively at runtime vialibctranslate2.so.4; the executable's from-scratch link never gets that chance.#196 also documents a working per-project
moreLinkArgsworkaround (including a subtlety where a literal-lstdc++is silently rewritten by clang's driver and needs-Wl,-lstdc++instead, plus a second, distinct glibc-version-mismatch issue this can expose once libstdc++ is actually linked).This PR
This is a documentation-only change — a
Caveatsbullet pointing to #196, so anyone hitting this (likely as a confusing library-works-but-exe-fails discrepancy) can find the explanation and workaround quickly. I didn't attempt alakefile.leanbuild-system change here, since:-Lpath is distro-specific (found viagcc -print-file-name=libstdc++.soor equivalent), so baking it in generically needs more design thought than a doc fix.Happy to follow up with an actual
lakefile.leanchange (e.g. auto-detecting the GCC lib dir and applying-Wl,-lstdc+++ the glibc-compat stub automatically for Linux executable consumers) if a maintainer thinks that's the right direction — wanted to start with the lower-risk, purely-additive doc fix first.Test plan
4.32.0-rc1, Lean Copilotv4.31.0) — alean_exetarget with themoreLinkArgsworkaround from lean_exe link fails with undefined libstdc++ symbols from libleanffi.a (lean_lib works fine) #196 builds and the resulting binary runs successfully.