Skip to content

Link the GCC rows with lld as well (measured: no-op, images lack lld) - #6562

Closed
Fedr wants to merge 3 commits into
masterfrom
gcc-lld
Closed

Link the GCC rows with lld as well (measured: no-op, images lack lld)#6562
Fedr wants to merge 3 commits into
masterfrom
gcc-lld

Conversation

@Fedr

@Fedr Fedr commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

GCC rows on Linux still link with ld.bfd, so they get none of the folding from #6547 / #6550. This relaxes the compiler-ID gate on the lld selection while leaving the ICF and padding flags Clang-only: --icf=safe reads Clang's .llvm_addrsig, which GCC does not emit, and -z separate-loadable-segments only pays on the patchelf-ed AppImage path.

Measured: a no-op, because the ubuntu images have no lld

One ubuntu24 / GCC 13 / Release leg, three variants on a throwaway branch:

unstripped stripped link s
baseline (ld.bfd) 69,267,672 53,304,504 7
this PR (GCC on lld) 69,267,672 53,304,504 6
plus --icf=all for GCC 69,267,672 53,304,504 7

Byte-identical, all three. The configure log says it plainly: Performing Test MESHLIB_HAVE_LLD - Failed. Neither ubuntu image installs lld — ubuntu22Dockerfile has g++-12 clang-14, ubuntu24Dockerfile has g++-13 gcc-14 g++-14 clang-18, and lld-21* appears only in rockylinux8-vcpkgDockerfile. So every flag in the block is inert on ubuntu today, for the Clang rows as much as the GCC ones, and the whole ICF series only ever applied to the rockylinux8-vcpkg builds (the linux-vcpkg package and the manylinux wheels).

Making this actually do something needs lld added to both ubuntu Dockerfiles plus an image rebuild — a heavier change than a CMake gate. And it would still not shrink the .debs:

  • --icf=safe folds nothing on GCC output (no address-significance table), which the --icf=all row above cannot demonstrate here but Fold identical functions at link time with --icf=safe #6547's measurements did.
  • --icf=all would fold, but it folds functions whose addresses are taken, so &f == &g can become true — the semantic we deliberately rejected for a public library. Shipping .debs with different folding rules from the wheels would be worse than shipping them unfolded.

So the honest options for the .debs are: install lld and take the link-time win only, or build them with Clang. Neither is this PR.

Recommendation

Close, unless we want the link-time angle — in which case this should be reopened together with the Dockerfile change, and justified on build time rather than size.

The Clang-only parts stay Clang-only: --icf=safe needs .llvm_addrsig, which
GCC does not emit, and separate-loadable-segments only pays on the patchelf-ed
AppImage path.
@Fedr Fedr changed the title Link the GCC rows with lld as well Link the GCC rows with lld as well (measured: no-op, images lack lld) Aug 7, 2026
Without it the lld selection in CMakeLists is inert on every ubuntu row --
lld-21 only exists in the rockylinux8-vcpkg image.
lld-$CLANG_VER is already installed by scripts/mrbind/install_deps_ubuntu.sh;
only the PATH symlink was missing, and hardcoding a version could dangle.
@Fedr

Fedr commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Closing as measured-marginal: linking gets 57% faster (3.46s -> 1.48s, ~2s of a 20-40 min build), stripped size is neutral (+10.6 KB), but unstripped grows +446 KB and the .deb ships unstripped, so the artifact would get slightly bigger. Worth noting for the record: the ubuntu Clang rows already had lld (installed by scripts/mrbind/install_deps_ubuntu.sh) and were already folding -- only GCC failed the check, because it resolves -fuse-ld=lld through PATH while Clang finds ld.lld in its own llvm-*/bin. Stripping the .deb is the better lever and goes in its own PR.

@Fedr Fedr closed this Aug 7, 2026
@Fedr
Fedr deleted the gcc-lld branch August 7, 2026 20:32
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.

1 participant