Skip to content

documentation: tell users to link with -Wl,--gc-sections - #616

Merged
amontoison merged 2 commits into
developfrom
docs/gc-sections
Oct 21, 2026
Merged

amontoison merged 2 commits into
developfrom
docs/gc-sections

Conversation

@amontoison

@amontoison amontoison commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Since #615 each backend archive is compiled with one section per procedure, but nothing outside the CHANGELOG told users to link with -Wl,--gc-sections. Each module compiles to one object and a linker takes whole objects from an archive, so without it:

  • a program that calls one rocBLAS routine links every rocBLAS wrapper;
  • a hipFORT newer than the installed ROCm (for example develop, derived from ROCm 10.1.0, built against an older 10.x) fails every link of a library as soon as one wrapper names a routine that ROCm does not export, whether or not the program calls it.

Changes:

  • docs/how-to/using-hipfort.rst: new subsection "Linking only the routines you call", with the CMake form (target_link_options(... -Wl,--gc-sections) on non-Apple, non-Windows), why to spell it -Wl, rather than LINKER: (CMake 3.27 passes the latter to amdflang bare), the command-line form, and, for a shared library, -Wl,--exclude-libs,libhipfort-amdgcn.a: the wrappers stay in the library and keep working, but are no longer exported, so --gc-sections can remove the unused ones. The "derived from ROCm 10.1.0" sentence now points to it.
  • docs/install/install.rst and README.md: a short pointer in "Linking against hipFORT", and in the README's supported-API section.

The option is documented, not added to the exported hipfort::* targets: it would change the user's whole link, and does nothing for a shared library without --exclude-libs.

Test plan

  • Sphinx text build of docs/how-to and docs/install: no warning, and the :ref: from install.rst resolves to the new subsection.
  • Built a shared library linking an archive split into sections, where an unused wrapper calls a missing C symbol (gfortran and amdflang): with --gc-sections alone the link fails; with -Wl,--exclude-libs,<archive> it links, the used wrapper is called, and another archive's symbols stay exported; several archives separated by : also work.

Since #615 each backend archive is compiled with one section per
procedure, but the docs never told users to link with --gc-sections.
Without it a program that calls one rocBLAS routine links every rocBLAS
wrapper, and a hipFORT newer than the installed ROCm fails every link of
a library as soon as one wrapper names a routine that ROCm does not
export. Explain this in using-hipfort, with the CMake form, the -Wl,
spelling, and the shared-library case, and point to it from install,
the README and the ROCm version of the interfaces.
@amontoison
amontoison requested a review from a team as a code owner October 20, 2026 23:06
…ipFORT's archive

--exclude-libs,ALL hid the symbols of every static archive the shared
library links, not only hipFORT's, and the note did not say that the
wrappers stay in the library and keep working, only unexported. Name
libhipfort-amdgcn.a and explain both.
@amontoison amontoison changed the title docs: tell users to link with -Wl,--gc-sections documentation: tell users to link with -Wl,--gc-sections Oct 20, 2026
@amontoison
amontoison merged commit eca02b2 into develop Oct 21, 2026
2 of 3 checks passed
@amontoison
amontoison deleted the docs/gc-sections branch October 21, 2026 00:42
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.

1 participant