fix: refactor linker scripts for mold compatibility#347
Open
wallentx wants to merge 1 commit intoNVIDIA:mainfrom
Open
fix: refactor linker scripts for mold compatibility#347wallentx wants to merge 1 commit intoNVIDIA:mainfrom
wallentx wants to merge 1 commit intoNVIDIA:mainfrom
Conversation
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.
This pull request solves #226, and updates the build system to support the mold linker while maintaining full backward compatibility with the default GNU
ld.moldimposes stricter requirements on linker scripts than GNUld. Specifically, it does not supportENTRY,EXTERN, orSECTIONStokens inside scripts passed via standard flags, and it expects version scripts to contain raw symbol maps (without the wrappingVERSION { ... }block).Updates were made to the build configuration and linker scripts for both the library and CLI binary, moving away from custom linker scripts and adopting version scripts for symbol management. The changes streamline the build process and improve compatibility with standard linker features.
Build system and linker script improvements:
src/libnvidia-container.ldswith a version scriptsrc/libnvidia-container.verfor the library, updatingMakefileto use-Wl,--version-scriptfor symbol visibility control. This removes manual section and entrypoint definitions in favor of standard symbol versioning. [1] [2] [3]src/cli/nvidia-container-cli.ldsand updates theMakefileto use linker flags (-Wl,-u,<symbol>) to ensure required symbols are included, rather than relying onEXTERNdirectives in a linker script. [1] [2]Makefilefor the library build to explicitly set the entrypoint and include required symbols (-Wl,-e,nvc_entrypoint,-Wl,-u,interpreter,-Wl,-u,abitag), replacing previous script-based configuration.Verification
Build Environment
moldand GNUldTests Performed
nvidia-container-cli infoexecutes correctly../libnvidia-container.so.1executes and prints version info (verifiedPT_INTERPsegment existence).ldsucceeds (no regression).nvidia-container-cli infoexecutes correctly../libnvidia-container.so.1executes and prints version info.