From bb2bafadbc44f4b1ef0b6cc26111093c335f8783 Mon Sep 17 00:00:00 2001 From: Harry Gillanders Date: Fri, 3 Jul 2026 22:07:24 +0100 Subject: [PATCH] Fix Issue #23356 - ImportC: The preprocessor is improperly invoked, on macOS, when cross-compiling. --- compiler/src/dmd/link.d | 2 +- compiler/test/compilable/test23356.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 compiler/test/compilable/test23356.c diff --git a/compiler/src/dmd/link.d b/compiler/src/dmd/link.d index a04d4401ae4c..99823757f632 100644 --- a/compiler/src/dmd/link.d +++ b/compiler/src/dmd/link.d @@ -1196,7 +1196,7 @@ public int runPreprocessor(Loc loc, const(char)[] cpp, const(char)[] filename, c // need to redefine some macros in importc.h argv.push("-Wno-builtin-macro-redefined"); - if (target.os == Target.OS.OSX) + version (OSX) { argv.push("-fno-blocks"); // disable clang blocks extension argv.push("-E"); // run preprocessor only for clang diff --git a/compiler/test/compilable/test23356.c b/compiler/test/compilable/test23356.c new file mode 100644 index 000000000000..e1fc0c63ea37 --- /dev/null +++ b/compiler/test/compilable/test23356.c @@ -0,0 +1,14 @@ +// DISABLED: win linux freebsd openbsd netbsd dragonflybsd hurd +// REQUIRED_ARGS: -os=linux +// If clang is invoked improperly as a preprocessor, +// then this will fail to compile and link due to `__check` being undefined. +// If clang is invoked properly as a preprocessor then this will succeed +// as clang won't attempt to compile nor link the file. + +// https://github.com/dlang/dmd/issues/23356 + +int main(void) +{ + __check(1); + return 0; +}