[nanvix] fix(z): sanitize in-source libc headers for C++ runtimes#34
Merged
Conversation
The stage-1 build (PR #33 merge) got past configure and then failed compiling libunwind against the in-source Nanvix libc headers, which are C-only and break C++ parsing: stdio.h:113 error: invalid parameter name: 'new' is a keyword stdlib.h:92 error: expected ')' (the C99 'restrict' keyword) stdlib.h:163 error: invalid parameter name: 'template' is a keyword libunwind, libc++ and libc++abi include these C headers from C++, so they must parse as C++. Sanitize the staged sysroot copy right after staging: - map 'restrict' (C99, not a C++ keyword) to '__restrict' (valid in C and C++); - drop C++-keyword parameter names ('new', 'template'); parameter names in prototypes are optional, so this is purely syntactic. Scope is tiny (restrict: 2 files; new: 1 decl; template: 4 decls) and the rewrite is harmless for compiler-rt's C consumers. Verified with clang++ that the sanitized declarations parse cleanly while the originals reproduce the exact CI errors. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Problem
The #33 merge cleared the stage-1 configure stage; the build then failed compiling libunwind against the in-source Nanvix libc headers, which are C-only and don't parse as C++:
libunwind,libc++andlibc++abiinclude these C headers from C++, so they must parse as C++.Fix
Sanitize the staged sysroot copy of the headers right after staging (in
z'sdownload_steps):restrict(C99, not a C++ keyword) →__restrict(valid in both C and C++);new,template) — parameter names in prototypes are optional, so this is purely syntactic.Scope is tiny —
restrict: 2 files;new: 1 decl;template: 4 decls — and harmless for compiler-rt's C consumers (both forms are valid in C).Validation
bash -n zclean.clang++ -fsyntax-onlythat the sanitized declarations parse cleanly, while the originals reproduce the exact CI errors.Caveat
Iterative stage-1 bring-up: this clears the
libunwindheader blocker. The remaining libc++/libc++abi compile + link against the in-source libc may surface further issues, which I'll fix in follow-up iterations. Validated on merge (PR CI verifies stage 0 only).