Hotfix: Fix RHEL patch for C11 non-RHEL builds#97
Merged
Conversation
Signed-off-by: Vlad-Gabriel Serbu <Vlad-Gabriel.Serbu@amd.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.
Summary
scripts/package-ami.shrewrites theeventfd_signal()version gate insubmodules/AVED/sw/AMI/driver/ami_program.cso the void-arg form is also selected on RHEL 9.5+, where Red Hat backported the upstream 6.8 simplification into the 5.14-based kernel.The current rewrite uses a single composite
#if:This works on RHEL but breaks the build on other distros with kernel >= 5.18 (Ubuntu 24.04, Ubuntu 22.04 HWE), if the kernel is compiled under C11 (
-std=gnu11, the default since v5.18).Why it breaks
Per C11, in a
#ifcontrolling expression all identifiers remaining after macro expansion (other than the operand ofdefined) are replaced with the pp-number0, including function-like macro names. On a non-RHEL kernelRHEL_RELEASE_VERSIONis undefined, so the preprocessor ends up parsing:i.e.
MACRO(a, b)becomes0(a, b), which is not a valid constant expression. Thedefined(RHEL_RELEASE_CODE)short-circuit doesn't help, the rule applies during expression parsing, before evaluation.Fix
Replace the
sedrewrite with apatchthat guards the RHEL check behind#ifdef RHEL_RELEASE_CODE, so non-RHEL translation units never tokenizeRHEL_RELEASE_VERSIONin a#ifat all:Applied via
patch --no-backup-if-mismatch -p1 -d "${AVED_DIR}"; the existingtrapalreadygit checkoutsami_program.con exit, so revert semantics are unchanged.