Bug 23614 – ImportC: __int128 not supported

Status
RESOLVED
Resolution
FIXED
Severity
blocker
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Mac OS X
Creation time
2023-01-09T17:55:14Z
Last change time
2023-01-14T14:39:44Z
Keywords
ImportC, pull
Assigned to
No Owner
Creator
Jacob Carlborg

Comments

Comment #0 by doob — 2023-01-09T17:55:14Z
Compiling the following C code: unsigned long long _mulx_u64(unsigned long long __X, unsigned long long __Y, unsigned long long *__P) { unsigned __int128 __res = (unsigned __int128) __X * __Y; *__P = (unsigned long long) (__res >> 64); return (unsigned long long) __res; } Results in the following errors: foo.c(3): Error: missing comma or semicolon after declaration of `extern ()`, found `__res` instead I'm using macOS 13.0.1, DMD v2.101.1 and Xcode 14.2.
Comment #1 by bugzilla — 2023-01-09T21:11:51Z
At least a better error message: https://github.com/dlang/dmd/pull/14797
Comment #2 by bugzilla — 2023-01-09T21:13:05Z
Do you really need this function, or is it just something in the header? Does the header have an #if alternative path in it?
Comment #3 by doob — 2023-01-10T06:35:02Z
(In reply to Walter Bright from comment #2) > Do you really need this function, or is it just something in the header? > Does the header have an #if alternative path in it? No, I see now that it's guarded with __SIZEOF_INT128__. Adding `#undef __SIZEOF_INT128__` in "importc.h" works.
Comment #4 by doob — 2023-01-10T06:37:07Z
Here's the full preprocessor logic: #if !defined BR_INT128 && !defined BR_UMUL128 #ifdef __SIZEOF_INT128__ #define BR_INT128 1 #elif _M_X64 #define BR_UMUL128 1 #endif #endif Then rest of the code checks for "BR_INT128" and "BR_UMUL128". Perhaps "_M_X64" should be undefined as well.
Comment #5 by doob — 2023-01-10T06:41:50Z
(In reply to Jacob Carlborg from comment #4) > Here's the full preprocessor logic: > > #if !defined BR_INT128 && !defined BR_UMUL128 > #ifdef __SIZEOF_INT128__ > #define BR_INT128 1 > #elif _M_X64 > #define BR_UMUL128 1 > #endif > #endif > > Then rest of the code checks for "BR_INT128" and "BR_UMUL128". Perhaps > "_M_X64" should be undefined as well. It's available here [1]. I'm trying to compile BearSSL [2]. I'm just running DMD on the files in the "src" directory and reporting issues as I find them. It's quite a bit problematic that the Clang preprocessor is used, which supports a bunch of extensions that DMD doesn't support. [1] https://bearssl.org/gitweb/?p=BearSSL;a=blob;f=src/inner.h;h=07e1d0a478e801a91580658918130fb8b595e407;hb=HEAD#l403 [2] https://bearssl.org/#download-and-installation
Comment #6 by bugzilla — 2023-01-12T02:00:04Z
Thanks, this is what I need to know.
Comment #7 by dlang-bot — 2023-01-12T02:10:50Z
@WalterBright created dlang/dmd pull request #14805 "fix Issue 23614 - ImportC: __int128 not supported" fixing this issue: - fix Issue 23614 - ImportC: __int128 not supported https://github.com/dlang/dmd/pull/14805
Comment #8 by dlang-bot — 2023-01-14T12:17:45Z
dlang/dmd pull request #14805 "fix Issue 23614 - ImportC: __int128 not supported" was merged into stable: - 2e02e183729d6648130b4fbcbf73b64f5d5cd080 by Walter Bright: fix Issue 23614 - ImportC: __int128 not supported https://github.com/dlang/dmd/pull/14805
Comment #9 by dlang-bot — 2023-01-14T14:39:44Z
dlang/dmd pull request #14815 "Merge stable" was merged into master: - ee3176917dc4edc466ce10676f1f8336267341ba by Walter Bright: fix Issue 23614 - ImportC: __int128 not supported (#14805) https://github.com/dlang/dmd/pull/14815