Skip to content

Conversation

@florolf
Copy link
Contributor

@florolf florolf commented Aug 16, 2025

Commit 3cba6b1 ("Use _Float16 for half conversions if available") added support for using half-width float support in the compiler to perform encoding operations, using the FLT16_MANT_DIG macro to check for support on the given target.

However, on x86 GCC only supports this when SSE2 is enabled[1]. Unlike clang and the other architectures where support for this is conditional, GCC does define those macros even without SSE2 support, causing a build failure:

  In file included from cborencoder_float.c:29:
  cborinternal_p.h: In function ‘encode_half’:
  cborinternal_p.h:56:5: error: invalid conversion to type ‘_Float16’ without option ‘-msse2’
     56 |     _Float16 f = (_Float16)x;
        |     ^~~~~~~~
  cborinternal_p.h: In function ‘decode_half’:
  cborinternal_p.h:65:5: error: invalid conversion from type ‘_Float16’ without option ‘-msse2’
     65 |     return (float)f;
        |

Work around this by additionally checking for this specific condition.

[1] https://gcc.gnu.org/onlinedocs/gcc/Half-Precision.html

Commit 3cba6b1 ("Use _Float16 for half conversions if available") added
support for using half-width float support in the compiler to perform
encoding operations, using the FLT16_MANT_DIG macro to check for
support on the given target.

However, on x86 GCC only supports this when SSE2 is enabled[1]. Unlike
clang and the other architectures where support for this is conditional,
GCC *does* define those macros even without SSE2 support, causing a
build failure:

  In file included from cborencoder_float.c:29:
  cborinternal_p.h: In function ‘encode_half’:
  cborinternal_p.h:56:5: error: invalid conversion to type ‘_Float16’ without option ‘-msse2’
     56 |     _Float16 f = (_Float16)x;
        |     ^~~~~~~~
  cborinternal_p.h: In function ‘decode_half’:
  cborinternal_p.h:65:5: error: invalid conversion from type ‘_Float16’ without option ‘-msse2’
     65 |     return (float)f;
        |

Work around this by additionally checking for this specific condition.

[1] https://gcc.gnu.org/onlinedocs/gcc/Half-Precision.html

Signed-off-by: Florian Larysch <[email protected]>
@thiagomacieira
Copy link
Member

Thank you for the patch.

@thiagomacieira thiagomacieira enabled auto-merge (rebase) August 19, 2025 20:46
@thiagomacieira thiagomacieira merged commit 48a22bd into intel:main Aug 19, 2025
9 checks passed
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