Skip to content

Comments

Fix build failure with glibc 2.43 due to C11 threads.h conflicts#2262

Open
cary-ilm wants to merge 3 commits intoAcademySoftwareFoundation:mainfrom
cary-ilm:once_flag-fix
Open

Fix build failure with glibc 2.43 due to C11 threads.h conflicts#2262
cary-ilm wants to merge 3 commits intoAcademySoftwareFoundation:mainfrom
cary-ilm:once_flag-fix

Conversation

@cary-ilm
Copy link
Member

Fix conflicting once_flag, ONCE_FLAG_INIT, and call_once definitions when building with glibc 2.43, which now includes C11 <threads.h> support

Detect <threads.h> availability and use standard C11 thread primitives when present, falling back to pthread or Windows implementations otherwise CI

This also adds a new Linux build (#12) using a Fedora Rawhide container to test against glibc 2.43

Fix conflicting once_flag, ONCE_FLAG_INIT, and call_once definitions
when building with glibc 2.43, which now includes C11 <threads.h>
support

Detect <threads.h> availability and use standard C11 thread primitives
when present, falling back to pthread or Windows implementations
otherwise CI

This also adds a new Linux build (AcademySoftwareFoundation#12) using a Fedora Rawhide container to
test against glibc 2.43

Signed-off-by: Cary Phillips <cary@ilm.com>
@cary-ilm cary-ilm requested a review from kdt3rd February 23, 2026 02:59
Signed-off-by: Cary Phillips <cary@ilm.com>
Copy link
Contributor

@meshula meshula left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think the check could be simplified.


// Check for C11 threads.h availability.
// Exclude MSVC - its threads.h has compatibility issues with C++ compilation.
# if !defined(_MSC_VER) && !defined(_WIN32)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this check for has include necessary at all? Elsewhere we rely on the version macros, which have been reliable as of, IIRC VS >= 2019, and the old versions of msvc don't support c threads at all.

# endif
# endif
// Also check via __STDC_NO_THREADS__ (defined when threads.h is NOT available)
# if !defined(EXR_HAS_C11_THREADS) && defined(__STDC_VERSION__) && \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I argue that this check within the MSVC block is sufficient all by itself.

Signed-off-by: Cary Phillips <cary@ilm.com>
@cary-ilm
Copy link
Member Author

Indeed, I simplified it significantly, it's actually quite simple after all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants