Repository navigation
build: compile each backend archive with one section per procedure - #615
Merged
Merged
Conversation
Each module compiles to one object, and a linker extracts whole objects from an archive, so a program calling one rocBLAS wrapper linked all of them, and a wrapper naming a C function the installed library does not export broke every link of that library. Compile libhipfort-amdgcn.a and libhipfort-nvptx.a with -ffunction-sections -fdata-sections (GNU, LLVMFlang, Flang, NVHPC; the Intel compilers do not split the sections), and link the tests with -Wl,--gc-sections, spelled -Wl, because CMake 3.27 passes LINKER:--gc-sections to LLVMFlang as a bare flag.
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
Each hipfort module compiles to one object, and a linker extracts whole objects from an archive, not single symbols. A program that calls one rocBLAS wrapper therefore links all of them, and a wrapper naming a C function the installed library does not export (bindings generated from headers newer than the library) breaks every link of that library, whatever the program calls.
lib/CMakeLists.txt: compilelibhipfort-amdgcn.aandlibhipfort-nvptx.awith-ffunction-sections -fdata-sections, for the compilers that split the sections (GNU, LLVMFlang, Flang, NVHPC). The Intel compilers accept the flags but emit a single section, so they are left out. Without--gc-sectionsat link time this changes nothing.test/CMakeLists.txt: link the tests with-Wl,--gc-sections(not on Apple or Windows). Spelled-Wl,rather thanLINKER:, which CMake 3.27 passes to LLVMFlang as a bare--gc-sections.CHANGELOG.md: note the change, and that a shared library linking an archive also needs-Wl,--exclude-libs,ALL.The same change is in the per-library sandbox (#540), where it lets the tests link against a ROCm older than the develop headers.