Bug 24124 – ImportC: gcc simd intrinsics not supported by dmd

Status
RESOLVED
Resolution
WONTFIX
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2023-08-31T15:13:26Z
Last change time
2023-11-07T13:58:22Z
Keywords
ImportC
Assigned to
No Owner
Creator
Steven Schveighoffer

Comments

Comment #0 by schveiguy — 2023-08-31T15:13:26Z
Building `stb_image.h` from here: https://github.com/schveiguy/draylib/blob/master/raylibc/external/stb_image.h Using the C file: ```c #include "../config.h" #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" ``` produces a lot of errors for missing intrinsics: ``` /usr/lib/gcc/x86_64-linux-gnu/11/include/mmintrin.h(66): Error: undefined identifier `__builtin_ia32_emms` /usr/lib/gcc/x86_64-linux-gnu/11/include/mmintrin.h(79): Error: undefined identifier `__builtin_ia32_vec_init_v2si` /usr/lib/gcc/x86_64-linux-gnu/11/include/mmintrin.h(122): Error: undefined identifier `__builtin_ia32_vec_ext_v2si` /usr/lib/gcc/x86_64-linux-gnu/11/include/mmintrin.h(161): Error: undefined identifier `__builtin_ia32_packsswb` /usr/lib/gcc/x86_64-linux-gnu/11/include/mmintrin.h(176): Error: undefined identifier `__builtin_ia32_packssdw` /usr/lib/gcc/x86_64-linux-gnu/11/include/mmintrin.h(191): Error: undefined identifier `__builtin_ia32_packuswb` /usr/lib/gcc/x86_64-linux-gnu/11/include/mmintrin.h(205): Error: undefined identifier `__builtin_ia32_punpckhbw` /usr/lib/gcc/x86_64-linux-gnu/11/include/mmintrin.h(219): Error: undefined identifier `__builtin_ia32_punpckhwd` /usr/lib/gcc/x86_64-linux-gnu/11/include/mmintrin.h(233): Error: undefined identifier `__builtin_ia32_punpckhdq` /usr/lib/gcc/x86_64-linux-gnu/11/include/mmintrin.h(247): Error: undefined identifier `__builtin_ia32_punpcklbw` /usr/lib/gcc/x86_64-linux-gnu/11/include/mmintrin.h(261): Error: undefined identifier `__builtin_ia32_punpcklwd` /usr/lib/gcc/x86_64-linux-gnu/11/include/mmintrin.h(275): Error: undefined identifier `__builtin_ia32_punpckldq` /usr/lib/gcc/x86_64-linux-gnu/11/include/mmintrin.h(288): Error: undefined identifier `__builtin_ia32_paddb` /usr/lib/gcc/x86_64-linux-gnu/11/include/mmintrin.h(301): Error: undefined identifier `__builtin_ia32_paddw` /usr/lib/gcc/x86_64-linux-gnu/11/include/mmintrin.h(314): Error: undefined identifier `__builtin_ia32_paddd` /usr/lib/gcc/x86_64-linux-gnu/11/include/mmintrin.h(337): Error: undefined identifier `__builtin_ia32_paddq` /usr/lib/gcc/x86_64-linux-gnu/11/include/mmintrin.h(349): Error: undefined identifier `__builtin_ia32_paddsb` /usr/lib/gcc/x86_64-linux-gnu/11/include/mmintrin.h(363): Error: undefined identifier `__builtin_ia32_paddsw` /usr/lib/gcc/x86_64-linux-gnu/11/include/mmintrin.h(377): Error: undefined identifier `__builtin_ia32_paddusb` /usr/lib/gcc/x86_64-linux-gnu/11/include/mmintrin.h(391): Error: undefined identifier `__builtin_ia32_paddusw` ``` This is not the full list, once I "undefined" these, there were pages and pages more. Basically these are all the SIMD builtins for gcc.
Comment #1 by bugzilla — 2023-09-12T06:11:28Z
Is there a path through the headers that does not rely on the gcc SIMD intrinsics?
Comment #2 by schveiguy — 2023-09-12T08:28:51Z
Yes, I can define STBI_NO_SIMD and it will not use the SIMD calls. But this might not be a general solution for projects which don't have that configuration option. Note that I believe LDC has fixed this: https://github.com/ldc-developers/ldc/commit/798f73bd37308abc7aaef21e411f1615c4422022 But DMD may not have that luxury.
Comment #3 by bugzilla — 2023-11-06T18:37:28Z
Supporting gcc's instrinsic builtins would be a major project to add to dmd. If your project needs them, pragmatically you'll need to use gdc/ldc.
Comment #4 by dlang-bot — 2023-11-06T18:49:33Z
@WalterBright created dlang/dmd pull request #15779 "Issue 24124 - ImportC: gcc simd intrinsics not supported by dmd" mentioning this issue: - Issue 24124 - ImportC: gcc simd intrinsics not supported by dmd https://github.com/dlang/dmd/pull/15779
Comment #5 by bugzilla — 2023-11-06T18:54:53Z
BTW, dmd supports all the x86 SIMD instructions in the inline assembler.
Comment #6 by maxhaton — 2023-11-06T23:57:48Z
Guillaume has implemented most of the library of intel intrinsics in his library if they are genuinely required (I have been saying this should be pinched for druntime for a while alas he isn't keen)
Comment #7 by bugzilla — 2023-11-07T03:23:43Z
(In reply to mhh from comment #6) > Guillaume has implemented most of the library of intel intrinsics in his > library if they are genuinely required (I have been saying this should be > pinched for druntime for a while alas he isn't keen) Can you link to it here, please?
Comment #8 by bugzilla — 2023-11-07T03:27:27Z
1. dmd does not support gcc simd intrinsics, and is not likely to 2. the library in question has a #define for disabling use of those intrinsics, and it's a 3rd party library Hence, I'm going to resolve this as WONTFIX.
Comment #9 by schveiguy — 2023-11-07T13:58:22Z
In general, I agree with this result. The unfortunate reality is, many C libraries are going to use the definitions from the local c preprocessor (which is not related to DMD) to make decisions, which means that code simply won't compile with DMD. The only real solution would be for DMD to require a specific set of C headers and C preprocessor that goes with it, and code to that. ImportC with system headers might be a LDC/GDC-only thing.