feat(cli): add -C link-sysroot option and custom linker validation#311
Merged
LunaStev merged 1 commit intoApr 1, 2026
Conversation
This commit introduces a new `-C link-sysroot=<path>` option to explicitly pass a sysroot argument to the linking stage. It also adds a safety validation check to the build request: when both a custom linker (`-C linker=...`) and a general sysroot (`--sysroot=...`) are specified, the CLI now requires the user to explicitly define the linker's sysroot. This prevents confusing build failures where the general sysroot is applied only to the compile stage but ignored during the link stage by the custom linker. [Details] - Added `-C link-sysroot=<path>` to `parse_llvm_codegen_spec`. - Added validation in `validate_build_request` to enforce explicit link sysroot when using a custom linker alongside a general sysroot. - Added helper functions (`is_link_sysroot_arg`, `has_explicit_link_sysroot_arg`, `set_link_sysroot_arg`) to safely manage, check, and deduplicate sysroot link arguments. - Updated the CLI help output (`print_help`) to document the new option. Signed-off-by: LunaStev <luna@lunastev.org>
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 PR enhances the Wave compiler's CLI by introducing fine-grained control over the sysroot during the linking stage. It adds the
-C link-sysroot=<path>option and implements a safety validation check to prevent common configuration errors when using custom linkers alongside general sysroots.Key Changes
1. New Linker Option:
-C link-sysroot-C link-sysroot=<path>to the codegen specification parser.2. Custom Linker Safety Validation
--sysrootwould apply to the compilation stage, but might be ignored by a custom linker specified via-C linker. This led to confusing "file not found" or "incompatible library" errors during the final link phase.validate_build_requestto enforce a new safety rule: if both a custom linker and a general sysroot are provided, the user must now explicitly provide a-C link-sysroot. This ensures the developer is consciously aware of where the linker is searching for libraries.3. Argument Management Helpers
is_link_sysroot_arg: Identifies sysroot-related strings.has_explicit_link_sysroot_arg: Checks if the sysroot has already been set in the build plan.set_link_sysroot_arg: Safely updates or appends the sysroot argument while avoiding duplication.4. Documentation
wavec --help) to include and describe the new-C link-sysrootoption.Rationale
In systems programming and OS development, the compiler's view of the "system" (headers/core logic) and the linker's view (standard libraries/start files) can sometimes diverge. By requiring explicit link sysroots when a custom linker is involved, Wave prevents "silent" linking failures where the compiler assumes the linker inherited the general sysroot.
Example Usage
Explicitly providing a link sysroot for a custom cross-linker:
wavec build main.wave \ --sysroot /path/to/compiled/headers \ -C linker=aarch64-linux-gnu-ld \ -C link-sysroot=/path/to/target/libs