fix(build): hoist GL_GLEXT_PROTOTYPES out of __APPLE__ branch#7
Open
DTW-Thalion wants to merge 1 commit into
Open
fix(build): hoist GL_GLEXT_PROTOTYPES out of __APPLE__ branch#7DTW-Thalion wants to merge 1 commit into
DTW-Thalion wants to merge 1 commit into
Conversation
CABackingStore.h only set GL_GLEXT_PROTOTYPES inside the __APPLE__ branch. On Linux (and every other non-Apple platform), <GL/gl.h> was imported without the define, then it transitively included <GL/glext.h> which set its include guard without emitting any OpenGL 2.0+ prototypes. CARenderer.m's later import of <GL/glext.h> was then a no-op, so glUseProgram and friends ended up as implicit declarations — an error under clang 16+. Move the define above the platform split so every backend gets prototypes emitted on first glext.h traversal. No behavioral change on Windows or macOS; Linux now compiles cleanly against Mesa. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.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
On Linux with clang 16+ (clang 18.1.3 on Ubuntu 24.04), building
Source/CARenderer.mfails with:and a handful of similar errors for other GL 2.0+ entry points.
Root cause
Source/CABackingStore.hsetsGL_GLEXT_PROTOTYPESonly inside the__APPLE__branch:On Linux,
<GL/gl.h>then transitively includes<GL/glext.h>— but sinceGL_GLEXT_PROTOTYPESisn't set at that point, glext.h sets its own include guard__gl_glext_h_without emitting any OpenGL 2.0+ prototype declarations. CARenderer.m's later#import <GL/glext.h>withGL_GLEXT_PROTOTYPESset is then a no-op because of the guard, andglUseProgramand friends end up as implicit declarations.Older clang (≤15) treated implicit declarations as a warning; clang 16 promoted it to an error by default, which is what finally surfaced the latent bug.
Fix
Move
#define GL_GLEXT_PROTOTYPES 1above the__APPLE__split, so every backend has it set before the first time any glext.h is traversed. All OpenGL 2.0+ prototypes are then emitted on first entry, and the later glext.h imports in CARenderer.m continue to work.Platform impact
#definewas already set on this path; hoisting it is a no-op.Test plan
libgl1-mesa-dev25.2:libs-quartzcoreframework builds cleanlyglUseProgram,glCreateShader,glLinkProgram,glGetUniformLocationetc. are all declared at the point of use