[{"id":3678878,"web_url":"http://patchwork.ozlabs.org/comment/3678878/","msgid":"<59d6cf51-db06-4153-afe8-9a7d7d618ba1@gmx.de>","list_archive_url":null,"date":"2026-04-17T20:10:39","subject":"Re: [PATCH] fortran: Enable target preprocessor macros with -cpp\n [PR42954]","submitter":{"id":21263,"url":"http://patchwork.ozlabs.org/api/people/21263/","name":"Harald Anlauf","email":"anlauf@gmx.de"},"content":"Hi Chris,\n\nthanks for attacking this!\n\nI briefly tested this.\n\nAm 16.04.26 um 7:16 PM schrieb Christopher Albert:\n> The Fortran preprocessor has never defined target-specific macros such as\n> __linux__, __unix__, __ELF__, __x86_64__, or __amd64__ that the C\n> preprocessor provides.  This was caused by the TARGET_OS_CPP_BUILTINS,\n> TARGET_OBJFMT_CPP_BUILTINS, and TARGET_CPU_CPP_BUILTINS hooks being\n> disabled since 2008 (marked as \"Pandora's Box\") because several target\n> config headers use C-family-only functions.\n> \n> Fix by providing Fortran-compatible local helpers for\n> builtin_define_std, builtin_define_with_value, and\n> builtin_define_with_int_value (which in the C frontend live in\n> c-family/c-cppbuiltin.cc and use the C-family-only globals parse_in\n> and flag_iso), plus wrapper macros for c_dialect_cxx, flag_iso, and\n> other C-family identifiers referenced by target config headers.  This\n> allows TARGET_OS_CPP_BUILTINS and TARGET_OBJFMT_CPP_BUILTINS to\n> execute in the Fortran frontend.\n> \n> Unlike the C frontend default (flag_iso=0, GNU extensions mode), the\n> Fortran wrapper sets flag_iso=1 to suppress user-namespace macros like\n> bare \"unix\" and \"linux\" that would conflict with Fortran identifiers.\n> Only the reserved-namespace forms (__unix__, __linux__, etc.) are\n> defined.  Fortran has no -std=cNN equivalent to control this, so the\n> conservative choice avoids silent identifier replacement.\n> \n> For TARGET_CPU_CPP_BUILTINS, which on most architectures expands to a\n> function in a C-family-only object file (e.g., ix86_target_macros in\n> i386-c.cc), provide an x86 implementation directly in fortran/cpp.cc\n> that covers architecture identification and float-size macros.\n> ISA feature macros (__SSE__, __AVX__, etc.) are not included; if\n> needed, they could be factored out of i386-c.cc into a shared object.\n\nI noticed that the latter are missing.  Can you estimate how much\nwork it would be to also provide the essential ISA feature macros?\n(__AVX__/__AVX2__/... are likely more important than the __SSE*__\ncounterparts; maybe the __FMA__ family might be of interest.\nI also consider the other arch/tune settings less important.)\n\nOtherwise it looks good to me so far, and we should get this into\nmainline early in stage 1.\n\nCan anybody else test this on a non-linux or non-x86 platform?\n\nThanks,\nHarald\n\n> Remove the dead __attribute__((target(...))) block from\n> gfortran.dg/gomp/declare-variant-10.f90: it was guarded by\n> #if defined(__x86_64__) which was previously always false because\n> gfortran never defined these macros, and gfortran does not support\n> C-style __attribute__ syntax.\n> \n> Co-authored-by: Kai Tietz <ktietz@gcc.gnu.org>\n> \n> \tPR fortran/42954\n> \n> gcc/fortran/ChangeLog:\n> \n> \t* cpp.cc (gfc_builtin_define_std): New helper mirroring\n> \tbuiltin_define_std from c-family/c-cppbuiltin.cc.\n> \t(gfc_builtin_define_with_value): New helper mirroring\n> \tbuiltin_define_with_value from c-family/c-cppbuiltin.cc.\n> \t(gfc_define_ix86_target_macros): New function providing x86 CPU\n> \tidentification macros for the Fortran preprocessor.\n> \t(gfc_darwin_cpp_builtins): New function providing Darwin platform\n> \tmacros.\n> \t(cpp_define_builtins): Remove Pandora's Box FIXME.  Add wrapper\n> \tmacros for C-family functions and variables used in target config\n> \theaders.  Set flag_iso=1 to suppress bare-name macros.  Enable\n> \tTARGET_OS_CPP_BUILTINS and TARGET_OBJFMT_CPP_BUILTINS.  Call\n> \tgfc_define_ix86_target_macros on x86 targets.\n> \n> gcc/testsuite/ChangeLog:\n> \n> \t* gfortran.dg/gomp/declare-variant-10.f90: Remove dead\n> \t__attribute__((target)) block that is now exposed by newly\n> \tdefined target macros.\n> \t* gfortran.dg/pr42954-linux.f90: New test.\n> \t* gfortran.dg/pr42954-x86.f90: New test.\n> \n> Signed-off-by: Christopher Albert <albert@tugraz.at>\n> ---\n>   gcc/fortran/cpp.cc                            | 178 ++++++++++++++++--\n>   .../gfortran.dg/gomp/declare-variant-10.f90   |   3 -\n>   gcc/testsuite/gfortran.dg/pr42954-linux.f90   |  24 +++\n>   gcc/testsuite/gfortran.dg/pr42954-x86.f90     |  10 +\n>   4 files changed, 194 insertions(+), 21 deletions(-)\n>   create mode 100644 gcc/testsuite/gfortran.dg/pr42954-linux.f90\n>   create mode 100644 gcc/testsuite/gfortran.dg/pr42954-x86.f90\n> \n> diff --git a/gcc/fortran/cpp.cc b/gcc/fortran/cpp.cc\n> index 6b5f136e4f3..ada1bc1a211 100644\n> --- a/gcc/fortran/cpp.cc\n> +++ b/gcc/fortran/cpp.cc\n> @@ -157,6 +157,126 @@ void pp_dir_change (cpp_reader *, const char *);\n>   static int dump_macro (cpp_reader *, cpp_hashnode *, void *);\n>   static void dump_queued_macros (cpp_reader *);\n>   \n> +/* Fortran-local helpers that mirror builtin_define_std,\n> +   builtin_define_with_value, and builtin_define_with_int_value from\n> +   c-family/c-cppbuiltin.cc.  Those functions use the C-family-only\n> +   globals parse_in and flag_iso, so they cannot be called directly\n> +   from the Fortran frontend.  */\n> +\n> +/* Given \"unix\", define __unix, __unix__, and (if DEFINE_USER) unix.  */\n> +\n> +static void\n> +gfc_builtin_define_std (cpp_reader *pfile, const char *macro,\n> +\t\t\tbool define_user)\n> +{\n> +  size_t len = strlen (macro);\n> +  char *buff = (char *) alloca (len + 5);\n> +  char *p = buff + 2;\n> +  char *q = p + len;\n> +\n> +  memcpy (p, macro, len + 1);\n> +  if (!(*p == '_' && (p[1] == '_' || ISUPPER (p[1]))))\n> +    {\n> +      if (*p != '_')\n> +\t*--p = '_';\n> +      if (p[1] != '_')\n> +\t*--p = '_';\n> +    }\n> +  cpp_define (pfile, p);\n> +\n> +  if (p != buff + 2)\n> +    {\n> +      if (q[-1] != '_')\n> +\t*q++ = '_';\n> +      if (q[-2] != '_')\n> +\t*q++ = '_';\n> +      *q = '\\0';\n> +      cpp_define (pfile, p);\n> +      if (define_user)\n> +\tcpp_define (pfile, macro);\n> +    }\n> +}\n> +\n> +/* Define MACRO to EXPANSION; if IS_STR, quote the expansion.  */\n> +\n> +static void\n> +gfc_builtin_define_with_value (cpp_reader *pfile, const char *macro,\n> +\t\t\t       const char *expansion, int is_str)\n> +{\n> +  size_t mlen = strlen (macro);\n> +  size_t elen = strlen (expansion);\n> +  char *buf = (char *) alloca (mlen + elen + 4);\n> +  if (is_str)\n> +    sprintf (buf, \"%s=\\\"%s\\\"\", macro, expansion);\n> +  else\n> +    sprintf (buf, \"%s=%s\", macro, expansion);\n> +  cpp_define (pfile, buf);\n> +}\n> +\n> +/* Provide x86 CPU identification macros for the Fortran preprocessor.\n> +   TARGET_CPU_CPP_BUILTINS() cannot be called directly because it expands\n> +   to ix86_target_macros() in i386-c.cc, which is only linked into\n> +   C-family frontends.  This covers architecture identification and\n> +   float-size macros.  ISA feature macros (__SSE__, __AVX__, etc.) and\n> +   arch/tune macros (__znver4__, __skylake__, etc.) from\n> +   ix86_target_macros_internal() are not included; if needed, they could\n> +   be factored out of i386-c.cc into a shared object.  */\n> +\n> +#ifdef TARGET_80387\n> +static void\n> +gfc_define_ix86_target_macros (cpp_reader *pfile)\n> +{\n> +  if (TARGET_64BIT)\n> +    {\n> +      cpp_assert (pfile, \"cpu=x86_64\");\n> +      cpp_assert (pfile, \"machine=x86_64\");\n> +      cpp_define (pfile, \"__amd64\");\n> +      cpp_define (pfile, \"__amd64__\");\n> +      cpp_define (pfile, \"__x86_64\");\n> +      cpp_define (pfile, \"__x86_64__\");\n> +      if (TARGET_X32)\n> +\t{\n> +\t  cpp_define (pfile, \"_ILP32\");\n> +\t  cpp_define (pfile, \"__ILP32__\");\n> +\t}\n> +    }\n> +  else\n> +    {\n> +      cpp_assert (pfile, \"cpu=i386\");\n> +      cpp_assert (pfile, \"machine=i386\");\n> +      gfc_builtin_define_std (pfile, \"i386\", false);\n> +      cpp_define (pfile, \"_ILP32\");\n> +      cpp_define (pfile, \"__ILP32__\");\n> +    }\n> +\n> +  if (!TARGET_80387)\n> +    cpp_define (pfile, \"_SOFT_FLOAT\");\n> +\n> +  if (TARGET_LONG_DOUBLE_64)\n> +    cpp_define (pfile, \"__LONG_DOUBLE_64__\");\n> +\n> +  if (TARGET_LONG_DOUBLE_128)\n> +    cpp_define (pfile, \"__LONG_DOUBLE_128__\");\n> +\n> +  cpp_define_formatted (pfile, \"__SIZEOF_FLOAT80__=%d\",\n> +\t\t\tGET_MODE_SIZE (XFmode));\n> +  cpp_define (pfile, \"__SIZEOF_FLOAT128__=16\");\n> +}\n> +#endif\n> +\n> +/* Provide essential Darwin platform macros for the Fortran preprocessor.\n> +   The full darwin_cpp_builtins() in darwin-c.cc also defines\n> +   __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ and\n> +   __CONSTANT_CFSTRINGS__, but those depend on functions only linked\n> +   into C-family frontends.  */\n> +\n> +static void ATTRIBUTE_UNUSED\n> +gfc_darwin_cpp_builtins (cpp_reader *pfile)\n> +{\n> +  cpp_define (pfile, \"__MACH__\");\n> +  cpp_define (pfile, \"__APPLE__\");\n> +  gfc_builtin_define_with_value (pfile, \"__APPLE_CC__\", \"1\", false);\n> +}\n>   \n>   static void\n>   cpp_define_builtins (cpp_reader *pfile)\n> @@ -177,33 +297,55 @@ cpp_define_builtins (cpp_reader *pfile)\n>     if (flag_openmp)\n>       cpp_define (pfile, \"_OPENMP=202111\");\n>   \n> -  /* The defines below are necessary for the TARGET_* macros.\n> -\n> -     FIXME:  Note that builtin_define_std() actually is a function\n> -     in c-cppbuiltin.cc which uses flags undefined for Fortran.\n> -     Let's skip this for now. If needed, one needs to look into it\n> -     once more.  */\n> +  /* Wrapper macros for C-family identifiers used in target config\n> +     headers.  These allow TARGET_OS_CPP_BUILTINS and\n> +     TARGET_OBJFMT_CPP_BUILTINS to compile in the Fortran frontend.  */\n>   \n>   # define builtin_define(TXT) cpp_define (pfile, TXT)\n> -# define builtin_define_std(TXT)\n> +# define builtin_define_std(TXT) gfc_builtin_define_std (pfile, TXT, !flag_iso)\n> +# define builtin_define_with_value(MACRO, EXPANSION, IS_STR) \\\n> +  gfc_builtin_define_with_value (pfile, MACRO, EXPANSION, IS_STR)\n> +# define builtin_define_with_int_value(MACRO, VALUE) \\\n> +  cpp_define_formatted (pfile, \"%s=\" HOST_WIDE_INT_PRINT_DEC, \\\n> +\t\t\tMACRO, (HOST_WIDE_INT) (VALUE))\n>   # define builtin_assert(TXT) cpp_assert (pfile, TXT)\n> +# define c_dialect_cxx() 0\n> +# define c_dialect_objc() 0\n> +# define preprocessing_asm_p() 0\n> +# define preprocessing_trad_p() 0\n> +  /* Fortran has no -std=cNN flag to control this.  Set to 1 (ISO mode)\n> +     so that builtin_define_std() only defines reserved-namespace macros\n> +     like __unix__ and __linux__, not bare \"unix\" or \"linux\" which are\n> +     valid Fortran identifiers and would cause silent replacement.  */\n> +# define flag_iso 1\n> +# define flag_isoc94 0\n> +# define flag_isoc99 0\n> +# define flag_isoc11 0\n> +# define flag_isoc23 0\n> +# define darwin_cpp_builtins(PFILE) gfc_darwin_cpp_builtins (PFILE)\n>   \n> -  /* FIXME: Pandora's Box\n> -    Using the macros below results in multiple breakages:\n> -     - mingw will fail to compile this file as dependent macros\n> -       assume to be used in c-cppbuiltin.cc only. Further, they use\n> -       flags only valid/defined in C (same as noted above).\n> -       [config/i386/mingw32.h, config/i386/cygming.h]\n> -     - other platforms (not as popular) break similarly\n> -       [grep for 'builtin_define_with_int_value' in gcc/config/]\n> -\n> -  TARGET_CPU_CPP_BUILTINS ();\n>     TARGET_OS_CPP_BUILTINS ();\n> -  TARGET_OBJFMT_CPP_BUILTINS (); */\n> +  TARGET_OBJFMT_CPP_BUILTINS ();\n> +\n> +#ifdef TARGET_80387\n> +  gfc_define_ix86_target_macros (pfile);\n> +#endif\n>   \n>   #undef builtin_define\n>   #undef builtin_define_std\n> +#undef builtin_define_with_value\n> +#undef builtin_define_with_int_value\n>   #undef builtin_assert\n> +#undef c_dialect_cxx\n> +#undef c_dialect_objc\n> +#undef preprocessing_asm_p\n> +#undef preprocessing_trad_p\n> +#undef flag_iso\n> +#undef flag_isoc94\n> +#undef flag_isoc99\n> +#undef flag_isoc11\n> +#undef flag_isoc23\n> +#undef darwin_cpp_builtins\n>   }\n>   \n>   bool\n> diff --git a/gcc/testsuite/gfortran.dg/gomp/declare-variant-10.f90 b/gcc/testsuite/gfortran.dg/gomp/declare-variant-10.f90\n> index 0e0ab518010..115195e1194 100644\n> --- a/gcc/testsuite/gfortran.dg/gomp/declare-variant-10.f90\n> +++ b/gcc/testsuite/gfortran.dg/gomp/declare-variant-10.f90\n> @@ -64,9 +64,6 @@ contains\n>       call f18 ()\t  ! { dg-final { scan-tree-dump-times \"f18 \\\\\\(\\\\\\);\" 1 \"gimple\" } } */\n>     end subroutine\n>   \n> -#if defined(__i386__) || defined(__x86_64__)\n> -  __attribute__((target (\"avx512f,avx512bw\")))\n> -#endif\n>     subroutine test2 ()\n>       !$omp target\n>         call f04 () ! { dg-final { scan-tree-dump-times \"f03 \\\\\\(\\\\\\);\" 1 \"gimple\" { target { { i?86-*-* x86_64-*-* } && { ! ilp32 } } } } }\n> diff --git a/gcc/testsuite/gfortran.dg/pr42954-linux.f90 b/gcc/testsuite/gfortran.dg/pr42954-linux.f90\n> new file mode 100644\n> index 00000000000..bd5efe7a237\n> --- /dev/null\n> +++ b/gcc/testsuite/gfortran.dg/pr42954-linux.f90\n> @@ -0,0 +1,24 @@\n> +! { dg-do preprocess { target *-*-linux* } }\n> +! { dg-options \"-cpp\" }\n> +!\n> +! PR fortran/42954 - target macros missing in gfortran -cpp\n> +\n> +#ifndef __linux__\n> +# error __linux__ not defined\n> +#endif\n> +\n> +#ifndef __linux\n> +# error __linux not defined\n> +#endif\n> +\n> +#ifndef __unix__\n> +# error __unix__ not defined\n> +#endif\n> +\n> +#ifndef __unix\n> +# error __unix not defined\n> +#endif\n> +\n> +#ifndef __ELF__\n> +# error __ELF__ not defined\n> +#endif\n> diff --git a/gcc/testsuite/gfortran.dg/pr42954-x86.f90 b/gcc/testsuite/gfortran.dg/pr42954-x86.f90\n> new file mode 100644\n> index 00000000000..0a3b7eac8a2\n> --- /dev/null\n> +++ b/gcc/testsuite/gfortran.dg/pr42954-x86.f90\n> @@ -0,0 +1,10 @@\n> +! { dg-do preprocess { target { i?86-*-* x86_64-*-* } } }\n> +! { dg-options \"-cpp\" }\n> +!\n> +! PR fortran/42954 - target macros missing in gfortran -cpp\n> +\n> +#if !defined(__i386__) && !defined(__i386) \\\n> +    && !defined(__x86_64__) && !defined(__x86_64) \\\n> +    && !defined(__amd64__) && !defined(__amd64)\n> +# error x86 target macros not defined\n> +#endif","headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=38.145.34.32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n dmarc=fail (p=quarantine dis=none) header.from=gmx.de","sourceware.org; spf=pass smtp.mailfrom=m.gmane-mx.org","server2.sourceware.org;\n arc=none smtp.remote-ip=116.202.254.214"],"Received":["from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fy5cV54CMz1yD3\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 18 Apr 2026 06:11:21 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 58C054CD2023\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 17 Apr 2026 20:11:19 +0000 (GMT)","from ciao.gmane.io (ciao.gmane.io [116.202.254.214])\n by sourceware.org (Postfix) with ESMTPS id F0C824D108FB\n for <gcc-patches@gcc.gnu.org>; Fri, 17 Apr 2026 20:10:49 +0000 (GMT)","from list by ciao.gmane.io with local (Exim 4.92)\n (envelope-from <gcc-patches@m.gmane-mx.org>) id 1wDpWX-00019U-Uc\n for gcc-patches@gcc.gnu.org; Fri, 17 Apr 2026 22:10:45 +0200"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 58C054CD2023","OpenDKIM Filter v2.11.0 sourceware.org F0C824D108FB"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org F0C824D108FB","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org F0C824D108FB","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776456650; cv=none;\n b=UjpbFwtTSa2R0eAj8Ghyfm35veY9AcXjcW5/PZhkhdfKdQXprQo2ZMcWuNlSXZnvljpDOwSQvpFnwmGckvIVNiciB5N1U3HCunZb9W0SMrw/UqXhVWYMJPpj2F8bONOvnoRdqjv0hArUKHTpmGxnx8DsWiufV4x9E2vU69G36g0=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776456650; c=relaxed/simple;\n bh=OCIgDki3Cn//VKg35eYkNSbYhF32A15HVkocTC9NJR4=;\n h=To:From:Subject:Date:Message-ID:Mime-Version;\n b=rEEaFk97RSHn5gadalQLt5+PJ46hLgiVyfA8cEyxNlw/DQZ8EDWt0FsMO6GCaZ1UCMgSw5G2UAhgLo/6IJzKvb4lJcMwmOQY901eIfEpc3UTKZ7DYvACKMCQO6t9J6Ax3ZmeexTT+cWovAN5Cr85FmRKWdu2JB/Q2xMdPEi3Adk=","ARC-Authentication-Results":"i=1; server2.sourceware.org","X-Injected-Via-Gmane":"http://gmane.org/","To":"gcc-patches@gcc.gnu.org","From":"Harald Anlauf <anlauf@gmx.de>","Subject":"Re: [PATCH] fortran: Enable target preprocessor macros with -cpp\n [PR42954]","Date":"Fri, 17 Apr 2026 22:10:39 +0200","Message-ID":"<59d6cf51-db06-4153-afe8-9a7d7d618ba1@gmx.de>","References":"<20260416171656.2901675-1-albert@tugraz.at>","Mime-Version":"1.0","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","User-Agent":"Mozilla Thunderbird","Content-Language":"en-US","In-Reply-To":"<20260416171656.2901675-1-albert@tugraz.at>","Cc":"fortran@gcc.gnu.org","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>","List-Archive":"<https://gcc.gnu.org/pipermail/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-request@gcc.gnu.org?subject=help>","List-Subscribe":"<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"}},{"id":3682870,"web_url":"http://patchwork.ozlabs.org/comment/3682870/","msgid":"<5ee053f2-b4bb-4f9b-ae6a-3999cf17d70c@gmx.de>","list_archive_url":null,"date":"2026-04-27T18:30:24","subject":"Re: [PATCH] fortran: Enable target preprocessor macros with -cpp\n [PR42954]","submitter":{"id":21263,"url":"http://patchwork.ozlabs.org/api/people/21263/","name":"Harald Anlauf","email":"anlauf@gmx.de"},"content":"Hi Chris, all,\n\nas there have been no further comments, and since trunk is open\nafter 16-release, I will commit the patch as-is.\n\nThanks,\nHarald\n\nAm 17.04.26 um 10:10 PM schrieb Harald Anlauf:\n> Hi Chris,\n> \n> thanks for attacking this!\n> \n> I briefly tested this.\n> \n> Am 16.04.26 um 7:16 PM schrieb Christopher Albert:\n>> The Fortran preprocessor has never defined target-specific macros such as\n>> __linux__, __unix__, __ELF__, __x86_64__, or __amd64__ that the C\n>> preprocessor provides.  This was caused by the TARGET_OS_CPP_BUILTINS,\n>> TARGET_OBJFMT_CPP_BUILTINS, and TARGET_CPU_CPP_BUILTINS hooks being\n>> disabled since 2008 (marked as \"Pandora's Box\") because several target\n>> config headers use C-family-only functions.\n>>\n>> Fix by providing Fortran-compatible local helpers for\n>> builtin_define_std, builtin_define_with_value, and\n>> builtin_define_with_int_value (which in the C frontend live in\n>> c-family/c-cppbuiltin.cc and use the C-family-only globals parse_in\n>> and flag_iso), plus wrapper macros for c_dialect_cxx, flag_iso, and\n>> other C-family identifiers referenced by target config headers.  This\n>> allows TARGET_OS_CPP_BUILTINS and TARGET_OBJFMT_CPP_BUILTINS to\n>> execute in the Fortran frontend.\n>>\n>> Unlike the C frontend default (flag_iso=0, GNU extensions mode), the\n>> Fortran wrapper sets flag_iso=1 to suppress user-namespace macros like\n>> bare \"unix\" and \"linux\" that would conflict with Fortran identifiers.\n>> Only the reserved-namespace forms (__unix__, __linux__, etc.) are\n>> defined.  Fortran has no -std=cNN equivalent to control this, so the\n>> conservative choice avoids silent identifier replacement.\n>>\n>> For TARGET_CPU_CPP_BUILTINS, which on most architectures expands to a\n>> function in a C-family-only object file (e.g., ix86_target_macros in\n>> i386-c.cc), provide an x86 implementation directly in fortran/cpp.cc\n>> that covers architecture identification and float-size macros.\n>> ISA feature macros (__SSE__, __AVX__, etc.) are not included; if\n>> needed, they could be factored out of i386-c.cc into a shared object.\n> \n> I noticed that the latter are missing.  Can you estimate how much\n> work it would be to also provide the essential ISA feature macros?\n> (__AVX__/__AVX2__/... are likely more important than the __SSE*__\n> counterparts; maybe the __FMA__ family might be of interest.\n> I also consider the other arch/tune settings less important.)\n> \n> Otherwise it looks good to me so far, and we should get this into\n> mainline early in stage 1.\n> \n> Can anybody else test this on a non-linux or non-x86 platform?\n> \n> Thanks,\n> Harald\n> \n>> Remove the dead __attribute__((target(...))) block from\n>> gfortran.dg/gomp/declare-variant-10.f90: it was guarded by\n>> #if defined(__x86_64__) which was previously always false because\n>> gfortran never defined these macros, and gfortran does not support\n>> C-style __attribute__ syntax.\n>>\n>> Co-authored-by: Kai Tietz <ktietz@gcc.gnu.org>\n>>\n>>     PR fortran/42954\n>>\n>> gcc/fortran/ChangeLog:\n>>\n>>     * cpp.cc (gfc_builtin_define_std): New helper mirroring\n>>     builtin_define_std from c-family/c-cppbuiltin.cc.\n>>     (gfc_builtin_define_with_value): New helper mirroring\n>>     builtin_define_with_value from c-family/c-cppbuiltin.cc.\n>>     (gfc_define_ix86_target_macros): New function providing x86 CPU\n>>     identification macros for the Fortran preprocessor.\n>>     (gfc_darwin_cpp_builtins): New function providing Darwin platform\n>>     macros.\n>>     (cpp_define_builtins): Remove Pandora's Box FIXME.  Add wrapper\n>>     macros for C-family functions and variables used in target config\n>>     headers.  Set flag_iso=1 to suppress bare-name macros.  Enable\n>>     TARGET_OS_CPP_BUILTINS and TARGET_OBJFMT_CPP_BUILTINS.  Call\n>>     gfc_define_ix86_target_macros on x86 targets.\n>>\n>> gcc/testsuite/ChangeLog:\n>>\n>>     * gfortran.dg/gomp/declare-variant-10.f90: Remove dead\n>>     __attribute__((target)) block that is now exposed by newly\n>>     defined target macros.\n>>     * gfortran.dg/pr42954-linux.f90: New test.\n>>     * gfortran.dg/pr42954-x86.f90: New test.\n>>\n>> Signed-off-by: Christopher Albert <albert@tugraz.at>\n>> ---\n>>   gcc/fortran/cpp.cc                            | 178 ++++++++++++++++--\n>>   .../gfortran.dg/gomp/declare-variant-10.f90   |   3 -\n>>   gcc/testsuite/gfortran.dg/pr42954-linux.f90   |  24 +++\n>>   gcc/testsuite/gfortran.dg/pr42954-x86.f90     |  10 +\n>>   4 files changed, 194 insertions(+), 21 deletions(-)\n>>   create mode 100644 gcc/testsuite/gfortran.dg/pr42954-linux.f90\n>>   create mode 100644 gcc/testsuite/gfortran.dg/pr42954-x86.f90\n>>\n>> diff --git a/gcc/fortran/cpp.cc b/gcc/fortran/cpp.cc\n>> index 6b5f136e4f3..ada1bc1a211 100644\n>> --- a/gcc/fortran/cpp.cc\n>> +++ b/gcc/fortran/cpp.cc\n>> @@ -157,6 +157,126 @@ void pp_dir_change (cpp_reader *, const char *);\n>>   static int dump_macro (cpp_reader *, cpp_hashnode *, void *);\n>>   static void dump_queued_macros (cpp_reader *);\n>> +/* Fortran-local helpers that mirror builtin_define_std,\n>> +   builtin_define_with_value, and builtin_define_with_int_value from\n>> +   c-family/c-cppbuiltin.cc.  Those functions use the C-family-only\n>> +   globals parse_in and flag_iso, so they cannot be called directly\n>> +   from the Fortran frontend.  */\n>> +\n>> +/* Given \"unix\", define __unix, __unix__, and (if DEFINE_USER) unix.  */\n>> +\n>> +static void\n>> +gfc_builtin_define_std (cpp_reader *pfile, const char *macro,\n>> +            bool define_user)\n>> +{\n>> +  size_t len = strlen (macro);\n>> +  char *buff = (char *) alloca (len + 5);\n>> +  char *p = buff + 2;\n>> +  char *q = p + len;\n>> +\n>> +  memcpy (p, macro, len + 1);\n>> +  if (!(*p == '_' && (p[1] == '_' || ISUPPER (p[1]))))\n>> +    {\n>> +      if (*p != '_')\n>> +    *--p = '_';\n>> +      if (p[1] != '_')\n>> +    *--p = '_';\n>> +    }\n>> +  cpp_define (pfile, p);\n>> +\n>> +  if (p != buff + 2)\n>> +    {\n>> +      if (q[-1] != '_')\n>> +    *q++ = '_';\n>> +      if (q[-2] != '_')\n>> +    *q++ = '_';\n>> +      *q = '\\0';\n>> +      cpp_define (pfile, p);\n>> +      if (define_user)\n>> +    cpp_define (pfile, macro);\n>> +    }\n>> +}\n>> +\n>> +/* Define MACRO to EXPANSION; if IS_STR, quote the expansion.  */\n>> +\n>> +static void\n>> +gfc_builtin_define_with_value (cpp_reader *pfile, const char *macro,\n>> +                   const char *expansion, int is_str)\n>> +{\n>> +  size_t mlen = strlen (macro);\n>> +  size_t elen = strlen (expansion);\n>> +  char *buf = (char *) alloca (mlen + elen + 4);\n>> +  if (is_str)\n>> +    sprintf (buf, \"%s=\\\"%s\\\"\", macro, expansion);\n>> +  else\n>> +    sprintf (buf, \"%s=%s\", macro, expansion);\n>> +  cpp_define (pfile, buf);\n>> +}\n>> +\n>> +/* Provide x86 CPU identification macros for the Fortran preprocessor.\n>> +   TARGET_CPU_CPP_BUILTINS() cannot be called directly because it \n>> expands\n>> +   to ix86_target_macros() in i386-c.cc, which is only linked into\n>> +   C-family frontends.  This covers architecture identification and\n>> +   float-size macros.  ISA feature macros (__SSE__, __AVX__, etc.) and\n>> +   arch/tune macros (__znver4__, __skylake__, etc.) from\n>> +   ix86_target_macros_internal() are not included; if needed, they could\n>> +   be factored out of i386-c.cc into a shared object.  */\n>> +\n>> +#ifdef TARGET_80387\n>> +static void\n>> +gfc_define_ix86_target_macros (cpp_reader *pfile)\n>> +{\n>> +  if (TARGET_64BIT)\n>> +    {\n>> +      cpp_assert (pfile, \"cpu=x86_64\");\n>> +      cpp_assert (pfile, \"machine=x86_64\");\n>> +      cpp_define (pfile, \"__amd64\");\n>> +      cpp_define (pfile, \"__amd64__\");\n>> +      cpp_define (pfile, \"__x86_64\");\n>> +      cpp_define (pfile, \"__x86_64__\");\n>> +      if (TARGET_X32)\n>> +    {\n>> +      cpp_define (pfile, \"_ILP32\");\n>> +      cpp_define (pfile, \"__ILP32__\");\n>> +    }\n>> +    }\n>> +  else\n>> +    {\n>> +      cpp_assert (pfile, \"cpu=i386\");\n>> +      cpp_assert (pfile, \"machine=i386\");\n>> +      gfc_builtin_define_std (pfile, \"i386\", false);\n>> +      cpp_define (pfile, \"_ILP32\");\n>> +      cpp_define (pfile, \"__ILP32__\");\n>> +    }\n>> +\n>> +  if (!TARGET_80387)\n>> +    cpp_define (pfile, \"_SOFT_FLOAT\");\n>> +\n>> +  if (TARGET_LONG_DOUBLE_64)\n>> +    cpp_define (pfile, \"__LONG_DOUBLE_64__\");\n>> +\n>> +  if (TARGET_LONG_DOUBLE_128)\n>> +    cpp_define (pfile, \"__LONG_DOUBLE_128__\");\n>> +\n>> +  cpp_define_formatted (pfile, \"__SIZEOF_FLOAT80__=%d\",\n>> +            GET_MODE_SIZE (XFmode));\n>> +  cpp_define (pfile, \"__SIZEOF_FLOAT128__=16\");\n>> +}\n>> +#endif\n>> +\n>> +/* Provide essential Darwin platform macros for the Fortran \n>> preprocessor.\n>> +   The full darwin_cpp_builtins() in darwin-c.cc also defines\n>> +   __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ and\n>> +   __CONSTANT_CFSTRINGS__, but those depend on functions only linked\n>> +   into C-family frontends.  */\n>> +\n>> +static void ATTRIBUTE_UNUSED\n>> +gfc_darwin_cpp_builtins (cpp_reader *pfile)\n>> +{\n>> +  cpp_define (pfile, \"__MACH__\");\n>> +  cpp_define (pfile, \"__APPLE__\");\n>> +  gfc_builtin_define_with_value (pfile, \"__APPLE_CC__\", \"1\", false);\n>> +}\n>>   static void\n>>   cpp_define_builtins (cpp_reader *pfile)\n>> @@ -177,33 +297,55 @@ cpp_define_builtins (cpp_reader *pfile)\n>>     if (flag_openmp)\n>>       cpp_define (pfile, \"_OPENMP=202111\");\n>> -  /* The defines below are necessary for the TARGET_* macros.\n>> -\n>> -     FIXME:  Note that builtin_define_std() actually is a function\n>> -     in c-cppbuiltin.cc which uses flags undefined for Fortran.\n>> -     Let's skip this for now. If needed, one needs to look into it\n>> -     once more.  */\n>> +  /* Wrapper macros for C-family identifiers used in target config\n>> +     headers.  These allow TARGET_OS_CPP_BUILTINS and\n>> +     TARGET_OBJFMT_CPP_BUILTINS to compile in the Fortran frontend.  */\n>>   # define builtin_define(TXT) cpp_define (pfile, TXT)\n>> -# define builtin_define_std(TXT)\n>> +# define builtin_define_std(TXT) gfc_builtin_define_std (pfile, \n>> TXT, !flag_iso)\n>> +# define builtin_define_with_value(MACRO, EXPANSION, IS_STR) \\\n>> +  gfc_builtin_define_with_value (pfile, MACRO, EXPANSION, IS_STR)\n>> +# define builtin_define_with_int_value(MACRO, VALUE) \\\n>> +  cpp_define_formatted (pfile, \"%s=\" HOST_WIDE_INT_PRINT_DEC, \\\n>> +            MACRO, (HOST_WIDE_INT) (VALUE))\n>>   # define builtin_assert(TXT) cpp_assert (pfile, TXT)\n>> +# define c_dialect_cxx() 0\n>> +# define c_dialect_objc() 0\n>> +# define preprocessing_asm_p() 0\n>> +# define preprocessing_trad_p() 0\n>> +  /* Fortran has no -std=cNN flag to control this.  Set to 1 (ISO mode)\n>> +     so that builtin_define_std() only defines reserved-namespace macros\n>> +     like __unix__ and __linux__, not bare \"unix\" or \"linux\" which are\n>> +     valid Fortran identifiers and would cause silent replacement.  */\n>> +# define flag_iso 1\n>> +# define flag_isoc94 0\n>> +# define flag_isoc99 0\n>> +# define flag_isoc11 0\n>> +# define flag_isoc23 0\n>> +# define darwin_cpp_builtins(PFILE) gfc_darwin_cpp_builtins (PFILE)\n>> -  /* FIXME: Pandora's Box\n>> -    Using the macros below results in multiple breakages:\n>> -     - mingw will fail to compile this file as dependent macros\n>> -       assume to be used in c-cppbuiltin.cc only. Further, they use\n>> -       flags only valid/defined in C (same as noted above).\n>> -       [config/i386/mingw32.h, config/i386/cygming.h]\n>> -     - other platforms (not as popular) break similarly\n>> -       [grep for 'builtin_define_with_int_value' in gcc/config/]\n>> -\n>> -  TARGET_CPU_CPP_BUILTINS ();\n>>     TARGET_OS_CPP_BUILTINS ();\n>> -  TARGET_OBJFMT_CPP_BUILTINS (); */\n>> +  TARGET_OBJFMT_CPP_BUILTINS ();\n>> +\n>> +#ifdef TARGET_80387\n>> +  gfc_define_ix86_target_macros (pfile);\n>> +#endif\n>>   #undef builtin_define\n>>   #undef builtin_define_std\n>> +#undef builtin_define_with_value\n>> +#undef builtin_define_with_int_value\n>>   #undef builtin_assert\n>> +#undef c_dialect_cxx\n>> +#undef c_dialect_objc\n>> +#undef preprocessing_asm_p\n>> +#undef preprocessing_trad_p\n>> +#undef flag_iso\n>> +#undef flag_isoc94\n>> +#undef flag_isoc99\n>> +#undef flag_isoc11\n>> +#undef flag_isoc23\n>> +#undef darwin_cpp_builtins\n>>   }\n>>   bool\n>> diff --git a/gcc/testsuite/gfortran.dg/gomp/declare-variant-10.f90 b/ \n>> gcc/testsuite/gfortran.dg/gomp/declare-variant-10.f90\n>> index 0e0ab518010..115195e1194 100644\n>> --- a/gcc/testsuite/gfortran.dg/gomp/declare-variant-10.f90\n>> +++ b/gcc/testsuite/gfortran.dg/gomp/declare-variant-10.f90\n>> @@ -64,9 +64,6 @@ contains\n>>       call f18 ()      ! { dg-final { scan-tree-dump-times \"f18 \\\\\\(\\\\ \n>> \\);\" 1 \"gimple\" } } */\n>>     end subroutine\n>> -#if defined(__i386__) || defined(__x86_64__)\n>> -  __attribute__((target (\"avx512f,avx512bw\")))\n>> -#endif\n>>     subroutine test2 ()\n>>       !$omp target\n>>         call f04 () ! { dg-final { scan-tree-dump-times \"f03 \\\\\\(\\\\ \n>> \\);\" 1 \"gimple\" { target { { i?86-*-* x86_64-*-* } && { ! ilp32 } } } } }\n>> diff --git a/gcc/testsuite/gfortran.dg/pr42954-linux.f90 b/gcc/ \n>> testsuite/gfortran.dg/pr42954-linux.f90\n>> new file mode 100644\n>> index 00000000000..bd5efe7a237\n>> --- /dev/null\n>> +++ b/gcc/testsuite/gfortran.dg/pr42954-linux.f90\n>> @@ -0,0 +1,24 @@\n>> +! { dg-do preprocess { target *-*-linux* } }\n>> +! { dg-options \"-cpp\" }\n>> +!\n>> +! PR fortran/42954 - target macros missing in gfortran -cpp\n>> +\n>> +#ifndef __linux__\n>> +# error __linux__ not defined\n>> +#endif\n>> +\n>> +#ifndef __linux\n>> +# error __linux not defined\n>> +#endif\n>> +\n>> +#ifndef __unix__\n>> +# error __unix__ not defined\n>> +#endif\n>> +\n>> +#ifndef __unix\n>> +# error __unix not defined\n>> +#endif\n>> +\n>> +#ifndef __ELF__\n>> +# error __ELF__ not defined\n>> +#endif\n>> diff --git a/gcc/testsuite/gfortran.dg/pr42954-x86.f90 b/gcc/ \n>> testsuite/gfortran.dg/pr42954-x86.f90\n>> new file mode 100644\n>> index 00000000000..0a3b7eac8a2\n>> --- /dev/null\n>> +++ b/gcc/testsuite/gfortran.dg/pr42954-x86.f90\n>> @@ -0,0 +1,10 @@\n>> +! { dg-do preprocess { target { i?86-*-* x86_64-*-* } } }\n>> +! { dg-options \"-cpp\" }\n>> +!\n>> +! PR fortran/42954 - target macros missing in gfortran -cpp\n>> +\n>> +#if !defined(__i386__) && !defined(__i386) \\\n>> +    && !defined(__x86_64__) && !defined(__x86_64) \\\n>> +    && !defined(__amd64__) && !defined(__amd64)\n>> +# error x86 target macros not defined\n>> +#endif\n> \n> \n>","headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n secure) header.d=gmx.de header.i=anlauf@gmx.de header.a=rsa-sha256\n header.s=s31663417 header.b=aGhLA8LT;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=38.145.34.32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n\tdkim=pass (2048-bit key,\n secure) header.d=gmx.de header.i=anlauf@gmx.de header.a=rsa-sha256\n header.s=s31663417 header.b=aGhLA8LT","sourceware.org;\n dmarc=pass (p=quarantine dis=none) header.from=gmx.de","sourceware.org; spf=pass smtp.mailfrom=gmx.de","server2.sourceware.org;\n arc=none smtp.remote-ip=212.227.15.15"],"Received":["from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g4Bw24J4Pz1xvV\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 04:30:58 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 961464BB58EC\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 27 Apr 2026 18:30:56 +0000 (GMT)","from mout.gmx.net (mout.gmx.net [212.227.15.15])\n by sourceware.org (Postfix) with ESMTPS id B04014BAE7DC;\n Mon, 27 Apr 2026 18:30:26 +0000 (GMT)","from client.hidden.invalid by mail.gmx.net (mrgmx005\n [212.227.17.190]) with ESMTPSA (Nemesis) id 1MvbFs-1vOuvf0UUA-00zlRv; Mon, 27\n Apr 2026 20:30:25 +0200"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 961464BB58EC","OpenDKIM Filter v2.11.0 sourceware.org B04014BAE7DC"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org B04014BAE7DC","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org B04014BAE7DC","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777314627; cv=none;\n b=qpZ4y+/qtzSHZ0US8DZodrEMyWQQoodUxk6bkaoJcPpmEL59xwN0lU72S8gm5M4PIi4/rKtg+dzOI0jYhlRhGiN4GX/AU2+dFj+McSGL6yfte1Mbx0qTJ0SZEZtNW2Vq9rpP4NsZTt4iZYslCQFFT8xckjkLBulkav+y/dMOIvg=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1777314627; c=relaxed/simple;\n bh=xnpKIKm9+8yYWrIrfL937iULUeda5NVald1jtn6WZUo=;\n h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:From:To;\n b=WrCWnVAOw/rOiH+ZyhACj7zkQpzScbkj90yFoZj50FHSho4HD9SAxH8kmsl1UBiMHcp7Fkg2JkCHeBcX0TC9EnRikqRSpnJp6pTzg2Ub/ad+KM1lUo71AyRbOi+KYEjxq/qL5MJKfWrScUU44/UiV6NLh+/xSHPb6sS4Wbqnxgg=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de;\n s=s31663417; t=1777314625; x=1777919425; i=anlauf@gmx.de;\n bh=xnpKIKm9+8yYWrIrfL937iULUeda5NVald1jtn6WZUo=;\n h=X-UI-Sender-Class:Message-ID:Date:MIME-Version:Subject:From:To:\n Cc:References:In-Reply-To:Content-Type:Content-Transfer-Encoding:\n cc:content-transfer-encoding:content-type:date:from:message-id:\n mime-version:reply-to:subject:to;\n b=aGhLA8LTczXf+ZmK27JF399xQsjYt3ZEM8VzA8wUp/sJzsSqHAURNvqj29gs8TsM\n szp6Gt5NINhaHHEG1COw1clIMhHG1DD6lFGVukJHcyJWM5Hv52htk9UDFUElmY9iM\n PuGmbLBiZ0oIwkasIXAcxE5lagtdRBh5FUPP5YAXgxNHYw+wDEyoc5XfAlYlCQz87\n T+RpDnPiD9lI+/Rl0aKuCs1jRVspODqjtpEmWWj9m52YO1ViE+CzIH3PD6H7azkC6\n Wt1VLuGvt1tW2EmwPFMm12TLtQM98uhwBrHMcDyXHGLYoOrUqjhgKE798Ee5qFekL\n AFxw9oa2xhlgjf8DqQ==","X-UI-Sender-Class":"724b4f7f-cbec-4199-ad4e-598c01a50d3a","Message-ID":"<5ee053f2-b4bb-4f9b-ae6a-3999cf17d70c@gmx.de>","Date":"Mon, 27 Apr 2026 20:30:24 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH] fortran: Enable target preprocessor macros with -cpp\n [PR42954]","From":"Harald Anlauf <anlauf@gmx.de>","To":"gcc-patches@gcc.gnu.org","Cc":"fortran@gcc.gnu.org","Newsgroups":"gmane.comp.gcc.patches,gmane.comp.gcc.fortran","References":"<20260416171656.2901675-1-albert@tugraz.at>\n <59d6cf51-db06-4153-afe8-9a7d7d618ba1@gmx.de>","Content-Language":"en-US","In-Reply-To":"<59d6cf51-db06-4153-afe8-9a7d7d618ba1@gmx.de>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"quoted-printable","X-Provags-ID":"V03:K1:Wkx/CCGPJ42J94pXY/jVdnaGf36JlAYiJzPEJGSoK6vTyl8L5kK\n 8Ei0+tn58C9DC9gCTHC2LULsGFWofNNTQR0KHcH77DGDp7K3Wp0R71iecWZfY34nC7nB8LQ\n kO66TyBWBLAg8jJE5fmI519NMI41HoxGVOb80HUjZ3PCp0uqP4U7FsbYkTJgs4/3lq2LvMu\n FwjfvEoZlqHE7IsQJNY6A==","UI-OutboundReport":"notjunk:1;M01:P0:Osh3KVbTwEg=;cHMB1DqnvHfbx5ug1LxBBm8JGpJ\n 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\n KgAw6EKzYaSBx0cWZM7mIdCiiPo=","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>","List-Archive":"<https://gcc.gnu.org/pipermail/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-request@gcc.gnu.org?subject=help>","List-Subscribe":"<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"}},{"id":3682875,"web_url":"http://patchwork.ozlabs.org/comment/3682875/","msgid":"<CALvbMcBdyw8LbKn=ZQ0o=-=Qd2N7n9uZa5mGhV-r+SRac4=jyg@mail.gmail.com>","list_archive_url":null,"date":"2026-04-27T18:37:32","subject":"Re: [PATCH] fortran: Enable target preprocessor macros with -cpp\n [PR42954]","submitter":{"id":91428,"url":"http://patchwork.ozlabs.org/api/people/91428/","name":"Andrew Pinski","email":"andrew.pinski@oss.qualcomm.com"},"content":"On Thu, Apr 16, 2026 at 10:18 AM Christopher Albert <albert@tugraz.at> wrote:\n>\n> The Fortran preprocessor has never defined target-specific macros such as\n> __linux__, __unix__, __ELF__, __x86_64__, or __amd64__ that the C\n> preprocessor provides.  This was caused by the TARGET_OS_CPP_BUILTINS,\n> TARGET_OBJFMT_CPP_BUILTINS, and TARGET_CPU_CPP_BUILTINS hooks being\n> disabled since 2008 (marked as \"Pandora's Box\") because several target\n> config headers use C-family-only functions.\n>\n> Fix by providing Fortran-compatible local helpers for\n> builtin_define_std, builtin_define_with_value, and\n> builtin_define_with_int_value (which in the C frontend live in\n> c-family/c-cppbuiltin.cc and use the C-family-only globals parse_in\n> and flag_iso), plus wrapper macros for c_dialect_cxx, flag_iso, and\n> other C-family identifiers referenced by target config headers.  This\n> allows TARGET_OS_CPP_BUILTINS and TARGET_OBJFMT_CPP_BUILTINS to\n> execute in the Fortran frontend.\n>\n> Unlike the C frontend default (flag_iso=0, GNU extensions mode), the\n> Fortran wrapper sets flag_iso=1 to suppress user-namespace macros like\n> bare \"unix\" and \"linux\" that would conflict with Fortran identifiers.\n> Only the reserved-namespace forms (__unix__, __linux__, etc.) are\n> defined.  Fortran has no -std=cNN equivalent to control this, so the\n> conservative choice avoids silent identifier replacement.\n>\n> For TARGET_CPU_CPP_BUILTINS, which on most architectures expands to a\n> function in a C-family-only object file (e.g., ix86_target_macros in\n> i386-c.cc), provide an x86 implementation directly in fortran/cpp.cc\n> that covers architecture identification and float-size macros.\n> ISA feature macros (__SSE__, __AVX__, etc.) are not included; if\n> needed, they could be factored out of i386-c.cc into a shared object.\n>\n> Remove the dead __attribute__((target(...))) block from\n> gfortran.dg/gomp/declare-variant-10.f90: it was guarded by\n> #if defined(__x86_64__) which was previously always false because\n> gfortran never defined these macros, and gfortran does not support\n> C-style __attribute__ syntax.\n>\n> Co-authored-by: Kai Tietz <ktietz@gcc.gnu.org>\n>\n>         PR fortran/42954\n>\n> gcc/fortran/ChangeLog:\n>\n>         * cpp.cc (gfc_builtin_define_std): New helper mirroring\n>         builtin_define_std from c-family/c-cppbuiltin.cc.\n>         (gfc_builtin_define_with_value): New helper mirroring\n>         builtin_define_with_value from c-family/c-cppbuiltin.cc.\n>         (gfc_define_ix86_target_macros): New function providing x86 CPU\n>         identification macros for the Fortran preprocessor.\n>         (gfc_darwin_cpp_builtins): New function providing Darwin platform\n>         macros.\n>         (cpp_define_builtins): Remove Pandora's Box FIXME.  Add wrapper\n>         macros for C-family functions and variables used in target config\n>         headers.  Set flag_iso=1 to suppress bare-name macros.  Enable\n>         TARGET_OS_CPP_BUILTINS and TARGET_OBJFMT_CPP_BUILTINS.  Call\n>         gfc_define_ix86_target_macros on x86 targets.\n\nTHIS is all wrong and causes too many issues. Please revert this.\n\n>\n> gcc/testsuite/ChangeLog:\n>\n>         * gfortran.dg/gomp/declare-variant-10.f90: Remove dead\n>         __attribute__((target)) block that is now exposed by newly\n>         defined target macros.\n>         * gfortran.dg/pr42954-linux.f90: New test.\n>         * gfortran.dg/pr42954-x86.f90: New test.\n>\n> Signed-off-by: Christopher Albert <albert@tugraz.at>\n> ---\n>  gcc/fortran/cpp.cc                            | 178 ++++++++++++++++--\n>  .../gfortran.dg/gomp/declare-variant-10.f90   |   3 -\n>  gcc/testsuite/gfortran.dg/pr42954-linux.f90   |  24 +++\n>  gcc/testsuite/gfortran.dg/pr42954-x86.f90     |  10 +\n>  4 files changed, 194 insertions(+), 21 deletions(-)\n>  create mode 100644 gcc/testsuite/gfortran.dg/pr42954-linux.f90\n>  create mode 100644 gcc/testsuite/gfortran.dg/pr42954-x86.f90\n>\n> diff --git a/gcc/fortran/cpp.cc b/gcc/fortran/cpp.cc\n> index 6b5f136e4f3..ada1bc1a211 100644\n> --- a/gcc/fortran/cpp.cc\n> +++ b/gcc/fortran/cpp.cc\n> @@ -157,6 +157,126 @@ void pp_dir_change (cpp_reader *, const char *);\n>  static int dump_macro (cpp_reader *, cpp_hashnode *, void *);\n>  static void dump_queued_macros (cpp_reader *);\n>\n> +/* Fortran-local helpers that mirror builtin_define_std,\n> +   builtin_define_with_value, and builtin_define_with_int_value from\n> +   c-family/c-cppbuiltin.cc.  Those functions use the C-family-only\n> +   globals parse_in and flag_iso, so they cannot be called directly\n> +   from the Fortran frontend.  */\n> +\n> +/* Given \"unix\", define __unix, __unix__, and (if DEFINE_USER) unix.  */\n> +\n> +static void\n> +gfc_builtin_define_std (cpp_reader *pfile, const char *macro,\n> +                       bool define_user)\n> +{\n> +  size_t len = strlen (macro);\n> +  char *buff = (char *) alloca (len + 5);\n> +  char *p = buff + 2;\n> +  char *q = p + len;\n> +\n> +  memcpy (p, macro, len + 1);\n> +  if (!(*p == '_' && (p[1] == '_' || ISUPPER (p[1]))))\n> +    {\n> +      if (*p != '_')\n> +       *--p = '_';\n> +      if (p[1] != '_')\n> +       *--p = '_';\n> +    }\n> +  cpp_define (pfile, p);\n> +\n> +  if (p != buff + 2)\n> +    {\n> +      if (q[-1] != '_')\n> +       *q++ = '_';\n> +      if (q[-2] != '_')\n> +       *q++ = '_';\n> +      *q = '\\0';\n> +      cpp_define (pfile, p);\n> +      if (define_user)\n> +       cpp_define (pfile, macro);\n> +    }\n> +}\n> +\n> +/* Define MACRO to EXPANSION; if IS_STR, quote the expansion.  */\n> +\n> +static void\n> +gfc_builtin_define_with_value (cpp_reader *pfile, const char *macro,\n> +                              const char *expansion, int is_str)\n> +{\n> +  size_t mlen = strlen (macro);\n> +  size_t elen = strlen (expansion);\n> +  char *buf = (char *) alloca (mlen + elen + 4);\n> +  if (is_str)\n> +    sprintf (buf, \"%s=\\\"%s\\\"\", macro, expansion);\n> +  else\n> +    sprintf (buf, \"%s=%s\", macro, expansion);\n> +  cpp_define (pfile, buf);\n> +}\n> +\n> +/* Provide x86 CPU identification macros for the Fortran preprocessor.\n> +   TARGET_CPU_CPP_BUILTINS() cannot be called directly because it expands\n> +   to ix86_target_macros() in i386-c.cc, which is only linked into\n> +   C-family frontends.  This covers architecture identification and\n> +   float-size macros.  ISA feature macros (__SSE__, __AVX__, etc.) and\n> +   arch/tune macros (__znver4__, __skylake__, etc.) from\n> +   ix86_target_macros_internal() are not included; if needed, they could\n> +   be factored out of i386-c.cc into a shared object.  */\n> +\n> +#ifdef TARGET_80387\n\nPlease DON'T add target defines directly to the front-end.\nPlease instead use a config file from the target instead. Like what is\ndone for d, rust, etc. front-ends.\nEach target should have their a source file which does the cpp_\ninstead of inlining it in the fortran front-end.\n\nThanks,\nAndrea\n\n> +static void\n> +gfc_define_ix86_target_macros (cpp_reader *pfile)\n> +{\n> +  if (TARGET_64BIT)\n> +    {\n> +      cpp_assert (pfile, \"cpu=x86_64\");\n> +      cpp_assert (pfile, \"machine=x86_64\");\n> +      cpp_define (pfile, \"__amd64\");\n> +      cpp_define (pfile, \"__amd64__\");\n> +      cpp_define (pfile, \"__x86_64\");\n> +      cpp_define (pfile, \"__x86_64__\");\n> +      if (TARGET_X32)\n> +       {\n> +         cpp_define (pfile, \"_ILP32\");\n> +         cpp_define (pfile, \"__ILP32__\");\n> +       }\n> +    }\n> +  else\n> +    {\n> +      cpp_assert (pfile, \"cpu=i386\");\n> +      cpp_assert (pfile, \"machine=i386\");\n> +      gfc_builtin_define_std (pfile, \"i386\", false);\n> +      cpp_define (pfile, \"_ILP32\");\n> +      cpp_define (pfile, \"__ILP32__\");\n> +    }\n> +\n> +  if (!TARGET_80387)\n> +    cpp_define (pfile, \"_SOFT_FLOAT\");\n> +\n> +  if (TARGET_LONG_DOUBLE_64)\n> +    cpp_define (pfile, \"__LONG_DOUBLE_64__\");\n> +\n> +  if (TARGET_LONG_DOUBLE_128)\n> +    cpp_define (pfile, \"__LONG_DOUBLE_128__\");\n> +\n> +  cpp_define_formatted (pfile, \"__SIZEOF_FLOAT80__=%d\",\n> +                       GET_MODE_SIZE (XFmode));\n> +  cpp_define (pfile, \"__SIZEOF_FLOAT128__=16\");\n> +}\n> +#endif\n> +\n> +/* Provide essential Darwin platform macros for the Fortran preprocessor.\n> +   The full darwin_cpp_builtins() in darwin-c.cc also defines\n> +   __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ and\n> +   __CONSTANT_CFSTRINGS__, but those depend on functions only linked\n> +   into C-family frontends.  */\n> +\n> +static void ATTRIBUTE_UNUSED\n> +gfc_darwin_cpp_builtins (cpp_reader *pfile)\n> +{\n> +  cpp_define (pfile, \"__MACH__\");\n> +  cpp_define (pfile, \"__APPLE__\");\n> +  gfc_builtin_define_with_value (pfile, \"__APPLE_CC__\", \"1\", false);\n> +}\n>\n>  static void\n>  cpp_define_builtins (cpp_reader *pfile)\n> @@ -177,33 +297,55 @@ cpp_define_builtins (cpp_reader *pfile)\n>    if (flag_openmp)\n>      cpp_define (pfile, \"_OPENMP=202111\");\n>\n> -  /* The defines below are necessary for the TARGET_* macros.\n> -\n> -     FIXME:  Note that builtin_define_std() actually is a function\n> -     in c-cppbuiltin.cc which uses flags undefined for Fortran.\n> -     Let's skip this for now. If needed, one needs to look into it\n> -     once more.  */\n> +  /* Wrapper macros for C-family identifiers used in target config\n> +     headers.  These allow TARGET_OS_CPP_BUILTINS and\n> +     TARGET_OBJFMT_CPP_BUILTINS to compile in the Fortran frontend.  */\n>\n>  # define builtin_define(TXT) cpp_define (pfile, TXT)\n> -# define builtin_define_std(TXT)\n> +# define builtin_define_std(TXT) gfc_builtin_define_std (pfile, TXT, !flag_iso)\n> +# define builtin_define_with_value(MACRO, EXPANSION, IS_STR) \\\n> +  gfc_builtin_define_with_value (pfile, MACRO, EXPANSION, IS_STR)\n> +# define builtin_define_with_int_value(MACRO, VALUE) \\\n> +  cpp_define_formatted (pfile, \"%s=\" HOST_WIDE_INT_PRINT_DEC, \\\n> +                       MACRO, (HOST_WIDE_INT) (VALUE))\n>  # define builtin_assert(TXT) cpp_assert (pfile, TXT)\n> +# define c_dialect_cxx() 0\n> +# define c_dialect_objc() 0\n> +# define preprocessing_asm_p() 0\n> +# define preprocessing_trad_p() 0\n> +  /* Fortran has no -std=cNN flag to control this.  Set to 1 (ISO mode)\n> +     so that builtin_define_std() only defines reserved-namespace macros\n> +     like __unix__ and __linux__, not bare \"unix\" or \"linux\" which are\n> +     valid Fortran identifiers and would cause silent replacement.  */\n> +# define flag_iso 1\n> +# define flag_isoc94 0\n> +# define flag_isoc99 0\n> +# define flag_isoc11 0\n> +# define flag_isoc23 0\n> +# define darwin_cpp_builtins(PFILE) gfc_darwin_cpp_builtins (PFILE)\n>\n> -  /* FIXME: Pandora's Box\n> -    Using the macros below results in multiple breakages:\n> -     - mingw will fail to compile this file as dependent macros\n> -       assume to be used in c-cppbuiltin.cc only. Further, they use\n> -       flags only valid/defined in C (same as noted above).\n> -       [config/i386/mingw32.h, config/i386/cygming.h]\n> -     - other platforms (not as popular) break similarly\n> -       [grep for 'builtin_define_with_int_value' in gcc/config/]\n> -\n> -  TARGET_CPU_CPP_BUILTINS ();\n>    TARGET_OS_CPP_BUILTINS ();\n> -  TARGET_OBJFMT_CPP_BUILTINS (); */\n> +  TARGET_OBJFMT_CPP_BUILTINS ();\n> +\n> +#ifdef TARGET_80387\n> +  gfc_define_ix86_target_macros (pfile);\n> +#endif\n>\n>  #undef builtin_define\n>  #undef builtin_define_std\n> +#undef builtin_define_with_value\n> +#undef builtin_define_with_int_value\n>  #undef builtin_assert\n> +#undef c_dialect_cxx\n> +#undef c_dialect_objc\n> +#undef preprocessing_asm_p\n> +#undef preprocessing_trad_p\n> +#undef flag_iso\n> +#undef flag_isoc94\n> +#undef flag_isoc99\n> +#undef flag_isoc11\n> +#undef flag_isoc23\n> +#undef darwin_cpp_builtins\n>  }\n>\n>  bool\n> diff --git a/gcc/testsuite/gfortran.dg/gomp/declare-variant-10.f90 b/gcc/testsuite/gfortran.dg/gomp/declare-variant-10.f90\n> index 0e0ab518010..115195e1194 100644\n> --- a/gcc/testsuite/gfortran.dg/gomp/declare-variant-10.f90\n> +++ b/gcc/testsuite/gfortran.dg/gomp/declare-variant-10.f90\n> @@ -64,9 +64,6 @@ contains\n>      call f18 ()          ! { dg-final { scan-tree-dump-times \"f18 \\\\\\(\\\\\\);\" 1 \"gimple\" } } */\n>    end subroutine\n>\n> -#if defined(__i386__) || defined(__x86_64__)\n> -  __attribute__((target (\"avx512f,avx512bw\")))\n> -#endif\n>    subroutine test2 ()\n>      !$omp target\n>        call f04 () ! { dg-final { scan-tree-dump-times \"f03 \\\\\\(\\\\\\);\" 1 \"gimple\" { target { { i?86-*-* x86_64-*-* } && { ! ilp32 } } } } }\n> diff --git a/gcc/testsuite/gfortran.dg/pr42954-linux.f90 b/gcc/testsuite/gfortran.dg/pr42954-linux.f90\n> new file mode 100644\n> index 00000000000..bd5efe7a237\n> --- /dev/null\n> +++ b/gcc/testsuite/gfortran.dg/pr42954-linux.f90\n> @@ -0,0 +1,24 @@\n> +! { dg-do preprocess { target *-*-linux* } }\n> +! { dg-options \"-cpp\" }\n> +!\n> +! PR fortran/42954 - target macros missing in gfortran -cpp\n> +\n> +#ifndef __linux__\n> +# error __linux__ not defined\n> +#endif\n> +\n> +#ifndef __linux\n> +# error __linux not defined\n> +#endif\n> +\n> +#ifndef __unix__\n> +# error __unix__ not defined\n> +#endif\n> +\n> +#ifndef __unix\n> +# error __unix not defined\n> +#endif\n> +\n> +#ifndef __ELF__\n> +# error __ELF__ not defined\n> +#endif\n> diff --git a/gcc/testsuite/gfortran.dg/pr42954-x86.f90 b/gcc/testsuite/gfortran.dg/pr42954-x86.f90\n> new file mode 100644\n> index 00000000000..0a3b7eac8a2\n> --- /dev/null\n> +++ b/gcc/testsuite/gfortran.dg/pr42954-x86.f90\n> @@ -0,0 +1,10 @@\n> +! { dg-do preprocess { target { i?86-*-* x86_64-*-* } } }\n> +! { dg-options \"-cpp\" }\n> +!\n> +! PR fortran/42954 - target macros missing in gfortran -cpp\n> +\n> +#if !defined(__i386__) && !defined(__i386) \\\n> +    && !defined(__x86_64__) && !defined(__x86_64) \\\n> +    && !defined(__amd64__) && !defined(__amd64)\n> +# error x86 target macros not defined\n> +#endif\n> --\n> 2.53.0\n>","headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256\n header.s=qcppdkim1 header.b=auVP47/Z;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com\n header.a=rsa-sha256 header.s=google header.b=jVVtGcCU;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n\tdkim=pass (2048-bit key,\n unprotected) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256\n header.s=qcppdkim1 header.b=auVP47/Z;\n\tdkim=pass (2048-bit key,\n unprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com\n header.a=rsa-sha256 header.s=google header.b=jVVtGcCU","sourceware.org; dmarc=none (p=none dis=none)\n header.from=oss.qualcomm.com","sourceware.org;\n spf=pass smtp.mailfrom=oss.qualcomm.com","server2.sourceware.org;\n arc=pass smtp.remote-ip=205.220.180.131"],"Received":["from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g4C4m3Tphz1yHv\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 04:38:31 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 116EE4B99F53\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 27 Apr 2026 18:38:27 +0000 (GMT)","from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com\n [205.220.180.131])\n by sourceware.org (Postfix) with ESMTPS id 56EEC4B9DB49\n for <gcc-patches@gcc.gnu.org>; Mon, 27 Apr 2026 18:37:47 +0000 (GMT)","from pps.filterd (m0279868.ppops.net [127.0.0.1])\n by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 63RCYP9t429020\n for <gcc-patches@gcc.gnu.org>; Mon, 27 Apr 2026 18:37:46 GMT","from mail-dy1-f200.google.com (mail-dy1-f200.google.com\n [74.125.82.200])\n by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dt7x31d73-1\n (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT)\n for <gcc-patches@gcc.gnu.org>; Mon, 27 Apr 2026 18:37:46 +0000 (GMT)","by mail-dy1-f200.google.com with SMTP id\n 5a478bee46e88-2de07c12745so33661969eec.1\n for <gcc-patches@gcc.gnu.org>; Mon, 27 Apr 2026 11:37:46 -0700 (PDT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 116EE4B99F53","OpenDKIM Filter v2.11.0 sourceware.org 56EEC4B9DB49"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 56EEC4B9DB49","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 56EEC4B9DB49","ARC-Seal":["i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1777315067; cv=pass;\n b=L7r1aRoRXS6XFgAYNn4Hm4xA7sLzPb3e24zEXxk8XGvQ8gKov8JBxs95hd+YPs94Lh07HuXyNN8+HBf/ntq0MyyKi8X9NhEXvpGmDij/N95EikW6WwzZVcS36wmk95JhrntOtRpjdLkLPRWvhB5ABqk0xXnZbJqVPmD2ztGOBSg=","i=1; a=rsa-sha256; t=1777315065; cv=none;\n d=google.com; s=arc-20240605;\n b=DgfJJaqpy9X/4m7S6FPdEd5fF4GGPsH8nwgBowiNRP0Wcsw7H/XJAlWOcsiOjUCZB8\n lDWLE0H7qPd4S9fy2XovdNjjsX0r6gapovImXLsO7xYj++qk7Cgqt412WdwxNibGsAEl\n AsBGY0rxR5s9KuXACygAjAnU5vCXo7UUJmsCuZJ3ph6mbS4+emXyRlPOWgKbRV7twdev\n Rc+ZOrNCTv0O8YrM71horBsQc7KYibH7jP9aZCRIWa6CQYRPkwH3YqMtHxmED4SKM9Mn\n Up+DYb4Z4sJO3H95asdprgJT0nZxogRky5OH0FsEHbwqRJ4C7cPVVjx9AGM3lCLt46d+\n 2U7A=="],"ARC-Message-Signature":["i=2; a=rsa-sha256; d=sourceware.org; s=key;\n t=1777315067; c=relaxed/simple;\n bh=0YlNE53JlqYp+p8lBS+FXZ4eMwAzxQ7ea3CI0Ahx4lo=;\n h=DKIM-Signature:DKIM-Signature:MIME-Version:From:Date:Message-ID:\n Subject:To;\n b=CY4dLse0cMZ4t0x9gBapXPvH+dfVtmLqG8Z0w92fRQPK2jN45EF2pIuyRZ15guFsEUZSoM+6CvFFlyKYHszW4TRu0g7+5SoXC8mGTzdiRRa6T0FSS4i1peLVQn6aYRMft45MBDQKor0xqEEgPv4++CDvRyIHI17yAYvVqwHiCt8=","i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n s=arc-20240605;\n h=content-transfer-encoding:cc:to:subject:message-id:date:from\n :in-reply-to:references:mime-version:dkim-signature;\n bh=CRT90orziBH/4kASwA584/kNGTun4AGtdSCwapT7ukQ=;\n fh=9BHalzoz/K9UoUSh2Cn0UxRblgtwYVWgmPWQDByMd6A=;\n b=fyccVLJQAqSt2s+OQBfJv/9QVN2OyIFgMxC6kpVklIuNz3VyKOmCmJneSV8L4tJZYc\n QPLd4yBTFHRc9aV6iwcLlK/ppv2Kd3v7I2oA7JGCnGdaz3r1w2EufOkhakpTdRrMec3o\n yAcfgd2W/buPGpdOCp5Ymghn0twwMMn1PEejENY5XZJANQ6BnX7wN6sQPaTsVSh/zqqG\n tADtIdNCAf/Lsh6iYh/5Peul02E86KC1Cb+VYcPnCFFLFkfDiTk2Th5H4W+69w+LWKkG\n t/mISFXpZ2boZdzyr6eTep/1CvggFsx7gLVUwOxiTz6TDyluOlAWyeSnD0saVbWzbkU0\n 2EWA==; darn=gcc.gnu.org"],"ARC-Authentication-Results":["i=2; server2.sourceware.org","i=1; mx.google.com; arc=none"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h=\n cc:content-transfer-encoding:content-type:date:from:in-reply-to\n :message-id:mime-version:references:subject:to; s=qcppdkim1; bh=\n CRT90orziBH/4kASwA584/kNGTun4AGtdSCwapT7ukQ=; b=auVP47/ZHUPVpi87\n TvzGy2VzlWNy+9RulDDYt2KWiuNp6n0pjrvFe88BQkCMm6kE9xEpEATVZp0Z37NA\n tij6Injs/lXNLa4Hy5FabCmvJk2158E4Y2wYino14XnE+zEcBRSjfgt6/SjFYsIg\n flbCayhpdCkRvA4CYBA47cujulsYllkzB+04lhXRAkd/5+WK2rmdVvoev16QYPXK\n as2SFZTObQj2k7/yU44tsX4fltY/e3ocoSTrZxuJtDEN7IjrZMqskH1qzKDCtMGw\n NKORUWZA7BtoQCW8PqYnWGd49IVPHlniy0SI/zh80bVoGPik4gTGxSJgqjJb5WFA\n HRaHgA==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=oss.qualcomm.com; s=google; t=1777315065; x=1777919865; darn=gcc.gnu.org;\n h=content-transfer-encoding:cc:to:subject:message-id:date:from\n :in-reply-to:references:mime-version:from:to:cc:subject:date\n :message-id:reply-to;\n bh=CRT90orziBH/4kASwA584/kNGTun4AGtdSCwapT7ukQ=;\n b=jVVtGcCUtdsCB+2lpd9eUOXUuYFDkyQbxoTGmlqlqGUb5KlfcGuVTLGnCBJ9qHnikj\n wm/i0D3ZBqxZ04rAj2fdes8Vt0I5HtVqI3LMvhZyVtF2lOJb00B8EfDswBbQH0m9OmSz\n S2b4DxhRWvXzpElBc3i1ErqxU0vz2D3EtYtDCzA8iFO/X3NXPPUijLX/UHZxxxulejTG\n 4twiCcL8Une+LPu8EBo+r6TTUgtg6sfszm2pAuhJmd/VsrtgBX+Gdmlc1GmzR/p1gVSm\n Au4wVTfgDWyji6jD3VDIL8e1lfi/hOB59CZtmy/YLBiPOzqiE4muu5t33FQh0K+85+zH\n YkaA=="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1777315065; x=1777919865;\n h=content-transfer-encoding:cc:to:subject:message-id:date:from\n :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=CRT90orziBH/4kASwA584/kNGTun4AGtdSCwapT7ukQ=;\n b=Z44fqp2AoE/M/XzpB6hyxZQtOyTmiUn53OwOW9xALGw5G7SJzzJoxc4+t9UPTMev+3\n BMwbqIFMpnTbztqU2Eq11X3TAylLqe4EbwD9UfmPn2ft2AOmLeo8o2mqZ+nOEA80jWoa\n zgGdH8w9wspMFimZZZCRERoDtqD/a0Kie9E8CV5J5aR9M7NcBGDbv10MQdsYCFpsvgN5\n iL59ug4ExbYtWr7etkuZivlUf5g2jX9u+se7tgPzmHZvoxKxXM91m+tQhzaKlj50T8If\n VDUbSsFNJHRd/2r0WX/HirR15KnbqIuZvKTaXmkyHqtui3DpehkTadCT17yxqki349WH\n 8TmA==","X-Gm-Message-State":"AOJu0YxV32PV1OyEW2NCVNiopGXJ+2I8yv4uiWfTboQCdF/H6jnAEAFw\n wm2klg3sS1QvECm7LE8DogRhx/O7FG/r7Nc7ZnunhtA/EFscBcHGa3ihOs2WKFbwQsE2uAIPlXn\n a5EAE8xyxLb+lZJ8v3DJC2hp6usESXomTl5CVqx+SBVO6eIT9Du8VqRqOsGzhV3XJow+2XEutRX\n urzcH7zM+P5r0+dECITQw2IF0MynVl7rZKSdY=","X-Gm-Gg":"AeBDievee1B0NfDsBjMjD0u6eVENMlr+/WG3amjomXwXv250XU5RDL14jy/xdG4bHoK\n vAuRHYcVklheo3REY/Y4gfndgPIHB6Je1XUgy3JmmNYI/YAUpWOJi2gQNmeD7TtApx/ClLnCYV2\n 5B9szUr5t3/mJpLZbVdkO1sSE1sWC3gU5M6P/XOfPik+qagWHjmZRro/ykX+B+6rQ+Kf8Fk6L8S\n bDei1TzW3oV2BI=","X-Received":["by 2002:a05:7301:128d:b0:2bd:c285:2fe with SMTP id\n 5a478bee46e88-2ed0a03bb9bmr25273eec.9.1777315065075;\n Mon, 27 Apr 2026 11:37:45 -0700 (PDT)","by 2002:a05:7301:128d:b0:2bd:c285:2fe with SMTP id\n 5a478bee46e88-2ed0a03bb9bmr25250eec.9.1777315064412; Mon, 27 Apr 2026\n 11:37:44 -0700 (PDT)"],"MIME-Version":"1.0","References":"<20260416171656.2901675-1-albert@tugraz.at>","In-Reply-To":"<20260416171656.2901675-1-albert@tugraz.at>","From":"Andrew Pinski <andrew.pinski@oss.qualcomm.com>","Date":"Mon, 27 Apr 2026 11:37:32 -0700","X-Gm-Features":"AVHnY4KjVX_UdX20Yoy4TtutCyYKw-GMRMbCWGI5aGLqNfZcb8kqZ46NBqWT9Wg","Message-ID":"\n <CALvbMcBdyw8LbKn=ZQ0o=-=Qd2N7n9uZa5mGhV-r+SRac4=jyg@mail.gmail.com>","Subject":"Re: [PATCH] fortran: Enable target preprocessor macros with -cpp\n [PR42954]","To":"Christopher Albert <albert@tugraz.at>","Cc":"gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org,\n Kai Tietz <ktietz@gcc.gnu.org>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","X-Proofpoint-Spam-Details-Enc":"AW1haW4tMjYwNDI3MDE5OCBTYWx0ZWRfXzqz+Je3YVSan\n LxeG2CnhriGr5c6xS4sK1wjpHG3nysEj7WWbjyfYTWUOJPf+fZaf6wOvAsxkNHqgsIM6ZTSaUjO\n OZoT+0PlRL21WpVi9POmZWeNPU1+x0PM4KfIBUoKFJYvSgnEsiOeggSY82y7YowtdXAh6TY6Kql\n LEVA3yAOfuVteybuL8Z2rb01T/u59U5ehW9bcMzYtCBIObRShM68S83pBUDUdwXHw2KCRG3QrjC\n XzGvVGByUb+OcEZ0EMhePl/BmtE4JCvuj4/fwjOelW6/tKGLDQ2rp46bNoXK0LgUsBTXdfnUF6w\n 5sQB2nSBhtAHu77ipK7UaF5cBAP9gPvjcUcrt0hd8O9XA8ohuSOeEMcnRPdJiHFUreRLw8zrMf/\n EThQt3Jr/Xv/WtWdi/jRL6c6BV9YTE3dsyAf7KeDte52ddr90nxxYZmp2/hOQvg7xKVQU6mnKTt\n bNWm6CYNfA9gVRa/snw==","X-Proofpoint-ORIG-GUID":"D2E4f38Xz9-Y33pGrAxQWrEJ7h3c_yoz","X-Authority-Analysis":"v=2.4 cv=AJEsYPsu c=1 sm=1 tr=0 ts=69efacfa cx=c_pps\n a=PfFC4Oe2JQzmKTvty2cRDw==:117 a=IkcTkHD0fZMA:10 a=A5OVakUREuEA:10\n a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22\n a=ZpdpYltYx_vBUK5n70dp:22 a=mDV3o1hIAAAA:8 a=0C_Vxo3LWXgvD0t5XqQA:9\n a=QEXdDO2ut3YA:10 a=6Ab_bkdmUrQuMsNx7PHu:22","X-Proofpoint-GUID":"D2E4f38Xz9-Y33pGrAxQWrEJ7h3c_yoz","X-Proofpoint-Virus-Version":"vendor=baseguard\n engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49\n definitions=2026-04-27_04,2026-04-21_02,2025-10-01_01","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n phishscore=0 impostorscore=0 priorityscore=1501 suspectscore=0 bulkscore=0\n malwarescore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 spamscore=0\n classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0\n reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604270198","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>","List-Archive":"<https://gcc.gnu.org/pipermail/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-request@gcc.gnu.org?subject=help>","List-Subscribe":"<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"}},{"id":3682884,"web_url":"http://patchwork.ozlabs.org/comment/3682884/","msgid":"<c8ddca76-cc4a-49ed-8b77-13967ab195e0@gmx.de>","list_archive_url":null,"date":"2026-04-27T18:47:46","subject":"Re: [PATCH] fortran: Enable target preprocessor macros with -cpp\n [PR42954]","submitter":{"id":21263,"url":"http://patchwork.ozlabs.org/api/people/21263/","name":"Harald Anlauf","email":"anlauf@gmx.de"},"content":"Am 27.04.26 um 8:37 PM schrieb Andrew Pinski:\n> On Thu, Apr 16, 2026 at 10:18 AM Christopher Albert <albert@tugraz.at> wrote:\n>>\n>> The Fortran preprocessor has never defined target-specific macros such as\n>> __linux__, __unix__, __ELF__, __x86_64__, or __amd64__ that the C\n>> preprocessor provides.  This was caused by the TARGET_OS_CPP_BUILTINS,\n>> TARGET_OBJFMT_CPP_BUILTINS, and TARGET_CPU_CPP_BUILTINS hooks being\n>> disabled since 2008 (marked as \"Pandora's Box\") because several target\n>> config headers use C-family-only functions.\n>>\n>> Fix by providing Fortran-compatible local helpers for\n>> builtin_define_std, builtin_define_with_value, and\n>> builtin_define_with_int_value (which in the C frontend live in\n>> c-family/c-cppbuiltin.cc and use the C-family-only globals parse_in\n>> and flag_iso), plus wrapper macros for c_dialect_cxx, flag_iso, and\n>> other C-family identifiers referenced by target config headers.  This\n>> allows TARGET_OS_CPP_BUILTINS and TARGET_OBJFMT_CPP_BUILTINS to\n>> execute in the Fortran frontend.\n>>\n>> Unlike the C frontend default (flag_iso=0, GNU extensions mode), the\n>> Fortran wrapper sets flag_iso=1 to suppress user-namespace macros like\n>> bare \"unix\" and \"linux\" that would conflict with Fortran identifiers.\n>> Only the reserved-namespace forms (__unix__, __linux__, etc.) are\n>> defined.  Fortran has no -std=cNN equivalent to control this, so the\n>> conservative choice avoids silent identifier replacement.\n>>\n>> For TARGET_CPU_CPP_BUILTINS, which on most architectures expands to a\n>> function in a C-family-only object file (e.g., ix86_target_macros in\n>> i386-c.cc), provide an x86 implementation directly in fortran/cpp.cc\n>> that covers architecture identification and float-size macros.\n>> ISA feature macros (__SSE__, __AVX__, etc.) are not included; if\n>> needed, they could be factored out of i386-c.cc into a shared object.\n>>\n>> Remove the dead __attribute__((target(...))) block from\n>> gfortran.dg/gomp/declare-variant-10.f90: it was guarded by\n>> #if defined(__x86_64__) which was previously always false because\n>> gfortran never defined these macros, and gfortran does not support\n>> C-style __attribute__ syntax.\n>>\n>> Co-authored-by: Kai Tietz <ktietz@gcc.gnu.org>\n>>\n>>          PR fortran/42954\n>>\n>> gcc/fortran/ChangeLog:\n>>\n>>          * cpp.cc (gfc_builtin_define_std): New helper mirroring\n>>          builtin_define_std from c-family/c-cppbuiltin.cc.\n>>          (gfc_builtin_define_with_value): New helper mirroring\n>>          builtin_define_with_value from c-family/c-cppbuiltin.cc.\n>>          (gfc_define_ix86_target_macros): New function providing x86 CPU\n>>          identification macros for the Fortran preprocessor.\n>>          (gfc_darwin_cpp_builtins): New function providing Darwin platform\n>>          macros.\n>>          (cpp_define_builtins): Remove Pandora's Box FIXME.  Add wrapper\n>>          macros for C-family functions and variables used in target config\n>>          headers.  Set flag_iso=1 to suppress bare-name macros.  Enable\n>>          TARGET_OS_CPP_BUILTINS and TARGET_OBJFMT_CPP_BUILTINS.  Call\n>>          gfc_define_ix86_target_macros on x86 targets.\n> \n> THIS is all wrong and causes too many issues. Please revert this.\n\nI haven't pushed yet, so all should be fine.\n\n>>\n>> gcc/testsuite/ChangeLog:\n>>\n>>          * gfortran.dg/gomp/declare-variant-10.f90: Remove dead\n>>          __attribute__((target)) block that is now exposed by newly\n>>          defined target macros.\n>>          * gfortran.dg/pr42954-linux.f90: New test.\n>>          * gfortran.dg/pr42954-x86.f90: New test.\n>>\n>> Signed-off-by: Christopher Albert <albert@tugraz.at>\n>> ---\n>>   gcc/fortran/cpp.cc                            | 178 ++++++++++++++++--\n>>   .../gfortran.dg/gomp/declare-variant-10.f90   |   3 -\n>>   gcc/testsuite/gfortran.dg/pr42954-linux.f90   |  24 +++\n>>   gcc/testsuite/gfortran.dg/pr42954-x86.f90     |  10 +\n>>   4 files changed, 194 insertions(+), 21 deletions(-)\n>>   create mode 100644 gcc/testsuite/gfortran.dg/pr42954-linux.f90\n>>   create mode 100644 gcc/testsuite/gfortran.dg/pr42954-x86.f90\n>>\n>> diff --git a/gcc/fortran/cpp.cc b/gcc/fortran/cpp.cc\n>> index 6b5f136e4f3..ada1bc1a211 100644\n>> --- a/gcc/fortran/cpp.cc\n>> +++ b/gcc/fortran/cpp.cc\n>> @@ -157,6 +157,126 @@ void pp_dir_change (cpp_reader *, const char *);\n>>   static int dump_macro (cpp_reader *, cpp_hashnode *, void *);\n>>   static void dump_queued_macros (cpp_reader *);\n>>\n>> +/* Fortran-local helpers that mirror builtin_define_std,\n>> +   builtin_define_with_value, and builtin_define_with_int_value from\n>> +   c-family/c-cppbuiltin.cc.  Those functions use the C-family-only\n>> +   globals parse_in and flag_iso, so they cannot be called directly\n>> +   from the Fortran frontend.  */\n>> +\n>> +/* Given \"unix\", define __unix, __unix__, and (if DEFINE_USER) unix.  */\n>> +\n>> +static void\n>> +gfc_builtin_define_std (cpp_reader *pfile, const char *macro,\n>> +                       bool define_user)\n>> +{\n>> +  size_t len = strlen (macro);\n>> +  char *buff = (char *) alloca (len + 5);\n>> +  char *p = buff + 2;\n>> +  char *q = p + len;\n>> +\n>> +  memcpy (p, macro, len + 1);\n>> +  if (!(*p == '_' && (p[1] == '_' || ISUPPER (p[1]))))\n>> +    {\n>> +      if (*p != '_')\n>> +       *--p = '_';\n>> +      if (p[1] != '_')\n>> +       *--p = '_';\n>> +    }\n>> +  cpp_define (pfile, p);\n>> +\n>> +  if (p != buff + 2)\n>> +    {\n>> +      if (q[-1] != '_')\n>> +       *q++ = '_';\n>> +      if (q[-2] != '_')\n>> +       *q++ = '_';\n>> +      *q = '\\0';\n>> +      cpp_define (pfile, p);\n>> +      if (define_user)\n>> +       cpp_define (pfile, macro);\n>> +    }\n>> +}\n>> +\n>> +/* Define MACRO to EXPANSION; if IS_STR, quote the expansion.  */\n>> +\n>> +static void\n>> +gfc_builtin_define_with_value (cpp_reader *pfile, const char *macro,\n>> +                              const char *expansion, int is_str)\n>> +{\n>> +  size_t mlen = strlen (macro);\n>> +  size_t elen = strlen (expansion);\n>> +  char *buf = (char *) alloca (mlen + elen + 4);\n>> +  if (is_str)\n>> +    sprintf (buf, \"%s=\\\"%s\\\"\", macro, expansion);\n>> +  else\n>> +    sprintf (buf, \"%s=%s\", macro, expansion);\n>> +  cpp_define (pfile, buf);\n>> +}\n>> +\n>> +/* Provide x86 CPU identification macros for the Fortran preprocessor.\n>> +   TARGET_CPU_CPP_BUILTINS() cannot be called directly because it expands\n>> +   to ix86_target_macros() in i386-c.cc, which is only linked into\n>> +   C-family frontends.  This covers architecture identification and\n>> +   float-size macros.  ISA feature macros (__SSE__, __AVX__, etc.) and\n>> +   arch/tune macros (__znver4__, __skylake__, etc.) from\n>> +   ix86_target_macros_internal() are not included; if needed, they could\n>> +   be factored out of i386-c.cc into a shared object.  */\n>> +\n>> +#ifdef TARGET_80387\n> \n> Please DON'T add target defines directly to the front-end.\n> Please instead use a config file from the target instead. Like what is\n> done for d, rust, etc. front-ends.\n> Each target should have their a source file which does the cpp_\n> instead of inlining it in the fortran front-end.\n> \n> Thanks,\n> Andrea\n\nAlright, back to Chris...\n\nThanks for stepping in quickly!\n\nHarald\n\n>> +static void\n>> +gfc_define_ix86_target_macros (cpp_reader *pfile)\n>> +{\n>> +  if (TARGET_64BIT)\n>> +    {\n>> +      cpp_assert (pfile, \"cpu=x86_64\");\n>> +      cpp_assert (pfile, \"machine=x86_64\");\n>> +      cpp_define (pfile, \"__amd64\");\n>> +      cpp_define (pfile, \"__amd64__\");\n>> +      cpp_define (pfile, \"__x86_64\");\n>> +      cpp_define (pfile, \"__x86_64__\");\n>> +      if (TARGET_X32)\n>> +       {\n>> +         cpp_define (pfile, \"_ILP32\");\n>> +         cpp_define (pfile, \"__ILP32__\");\n>> +       }\n>> +    }\n>> +  else\n>> +    {\n>> +      cpp_assert (pfile, \"cpu=i386\");\n>> +      cpp_assert (pfile, \"machine=i386\");\n>> +      gfc_builtin_define_std (pfile, \"i386\", false);\n>> +      cpp_define (pfile, \"_ILP32\");\n>> +      cpp_define (pfile, \"__ILP32__\");\n>> +    }\n>> +\n>> +  if (!TARGET_80387)\n>> +    cpp_define (pfile, \"_SOFT_FLOAT\");\n>> +\n>> +  if (TARGET_LONG_DOUBLE_64)\n>> +    cpp_define (pfile, \"__LONG_DOUBLE_64__\");\n>> +\n>> +  if (TARGET_LONG_DOUBLE_128)\n>> +    cpp_define (pfile, \"__LONG_DOUBLE_128__\");\n>> +\n>> +  cpp_define_formatted (pfile, \"__SIZEOF_FLOAT80__=%d\",\n>> +                       GET_MODE_SIZE (XFmode));\n>> +  cpp_define (pfile, \"__SIZEOF_FLOAT128__=16\");\n>> +}\n>> +#endif\n>> +\n>> +/* Provide essential Darwin platform macros for the Fortran preprocessor.\n>> +   The full darwin_cpp_builtins() in darwin-c.cc also defines\n>> +   __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ and\n>> +   __CONSTANT_CFSTRINGS__, but those depend on functions only linked\n>> +   into C-family frontends.  */\n>> +\n>> +static void ATTRIBUTE_UNUSED\n>> +gfc_darwin_cpp_builtins (cpp_reader *pfile)\n>> +{\n>> +  cpp_define (pfile, \"__MACH__\");\n>> +  cpp_define (pfile, \"__APPLE__\");\n>> +  gfc_builtin_define_with_value (pfile, \"__APPLE_CC__\", \"1\", false);\n>> +}\n>>\n>>   static void\n>>   cpp_define_builtins (cpp_reader *pfile)\n>> @@ -177,33 +297,55 @@ cpp_define_builtins (cpp_reader *pfile)\n>>     if (flag_openmp)\n>>       cpp_define (pfile, \"_OPENMP=202111\");\n>>\n>> -  /* The defines below are necessary for the TARGET_* macros.\n>> -\n>> -     FIXME:  Note that builtin_define_std() actually is a function\n>> -     in c-cppbuiltin.cc which uses flags undefined for Fortran.\n>> -     Let's skip this for now. If needed, one needs to look into it\n>> -     once more.  */\n>> +  /* Wrapper macros for C-family identifiers used in target config\n>> +     headers.  These allow TARGET_OS_CPP_BUILTINS and\n>> +     TARGET_OBJFMT_CPP_BUILTINS to compile in the Fortran frontend.  */\n>>\n>>   # define builtin_define(TXT) cpp_define (pfile, TXT)\n>> -# define builtin_define_std(TXT)\n>> +# define builtin_define_std(TXT) gfc_builtin_define_std (pfile, TXT, !flag_iso)\n>> +# define builtin_define_with_value(MACRO, EXPANSION, IS_STR) \\\n>> +  gfc_builtin_define_with_value (pfile, MACRO, EXPANSION, IS_STR)\n>> +# define builtin_define_with_int_value(MACRO, VALUE) \\\n>> +  cpp_define_formatted (pfile, \"%s=\" HOST_WIDE_INT_PRINT_DEC, \\\n>> +                       MACRO, (HOST_WIDE_INT) (VALUE))\n>>   # define builtin_assert(TXT) cpp_assert (pfile, TXT)\n>> +# define c_dialect_cxx() 0\n>> +# define c_dialect_objc() 0\n>> +# define preprocessing_asm_p() 0\n>> +# define preprocessing_trad_p() 0\n>> +  /* Fortran has no -std=cNN flag to control this.  Set to 1 (ISO mode)\n>> +     so that builtin_define_std() only defines reserved-namespace macros\n>> +     like __unix__ and __linux__, not bare \"unix\" or \"linux\" which are\n>> +     valid Fortran identifiers and would cause silent replacement.  */\n>> +# define flag_iso 1\n>> +# define flag_isoc94 0\n>> +# define flag_isoc99 0\n>> +# define flag_isoc11 0\n>> +# define flag_isoc23 0\n>> +# define darwin_cpp_builtins(PFILE) gfc_darwin_cpp_builtins (PFILE)\n>>\n>> -  /* FIXME: Pandora's Box\n>> -    Using the macros below results in multiple breakages:\n>> -     - mingw will fail to compile this file as dependent macros\n>> -       assume to be used in c-cppbuiltin.cc only. Further, they use\n>> -       flags only valid/defined in C (same as noted above).\n>> -       [config/i386/mingw32.h, config/i386/cygming.h]\n>> -     - other platforms (not as popular) break similarly\n>> -       [grep for 'builtin_define_with_int_value' in gcc/config/]\n>> -\n>> -  TARGET_CPU_CPP_BUILTINS ();\n>>     TARGET_OS_CPP_BUILTINS ();\n>> -  TARGET_OBJFMT_CPP_BUILTINS (); */\n>> +  TARGET_OBJFMT_CPP_BUILTINS ();\n>> +\n>> +#ifdef TARGET_80387\n>> +  gfc_define_ix86_target_macros (pfile);\n>> +#endif\n>>\n>>   #undef builtin_define\n>>   #undef builtin_define_std\n>> +#undef builtin_define_with_value\n>> +#undef builtin_define_with_int_value\n>>   #undef builtin_assert\n>> +#undef c_dialect_cxx\n>> +#undef c_dialect_objc\n>> +#undef preprocessing_asm_p\n>> +#undef preprocessing_trad_p\n>> +#undef flag_iso\n>> +#undef flag_isoc94\n>> +#undef flag_isoc99\n>> +#undef flag_isoc11\n>> +#undef flag_isoc23\n>> +#undef darwin_cpp_builtins\n>>   }\n>>\n>>   bool\n>> diff --git a/gcc/testsuite/gfortran.dg/gomp/declare-variant-10.f90 b/gcc/testsuite/gfortran.dg/gomp/declare-variant-10.f90\n>> index 0e0ab518010..115195e1194 100644\n>> --- a/gcc/testsuite/gfortran.dg/gomp/declare-variant-10.f90\n>> +++ b/gcc/testsuite/gfortran.dg/gomp/declare-variant-10.f90\n>> @@ -64,9 +64,6 @@ contains\n>>       call f18 ()          ! { dg-final { scan-tree-dump-times \"f18 \\\\\\(\\\\\\);\" 1 \"gimple\" } } */\n>>     end subroutine\n>>\n>> -#if defined(__i386__) || defined(__x86_64__)\n>> -  __attribute__((target (\"avx512f,avx512bw\")))\n>> -#endif\n>>     subroutine test2 ()\n>>       !$omp target\n>>         call f04 () ! { dg-final { scan-tree-dump-times \"f03 \\\\\\(\\\\\\);\" 1 \"gimple\" { target { { i?86-*-* x86_64-*-* } && { ! ilp32 } } } } }\n>> diff --git a/gcc/testsuite/gfortran.dg/pr42954-linux.f90 b/gcc/testsuite/gfortran.dg/pr42954-linux.f90\n>> new file mode 100644\n>> index 00000000000..bd5efe7a237\n>> --- /dev/null\n>> +++ b/gcc/testsuite/gfortran.dg/pr42954-linux.f90\n>> @@ -0,0 +1,24 @@\n>> +! { dg-do preprocess { target *-*-linux* } }\n>> +! { dg-options \"-cpp\" }\n>> +!\n>> +! PR fortran/42954 - target macros missing in gfortran -cpp\n>> +\n>> +#ifndef __linux__\n>> +# error __linux__ not defined\n>> +#endif\n>> +\n>> +#ifndef __linux\n>> +# error __linux not defined\n>> +#endif\n>> +\n>> +#ifndef __unix__\n>> +# error __unix__ not defined\n>> +#endif\n>> +\n>> +#ifndef __unix\n>> +# error __unix not defined\n>> +#endif\n>> +\n>> +#ifndef __ELF__\n>> +# error __ELF__ not defined\n>> +#endif\n>> diff --git a/gcc/testsuite/gfortran.dg/pr42954-x86.f90 b/gcc/testsuite/gfortran.dg/pr42954-x86.f90\n>> new file mode 100644\n>> index 00000000000..0a3b7eac8a2\n>> --- /dev/null\n>> +++ b/gcc/testsuite/gfortran.dg/pr42954-x86.f90\n>> @@ -0,0 +1,10 @@\n>> +! { dg-do preprocess { target { i?86-*-* x86_64-*-* } } }\n>> +! { dg-options \"-cpp\" }\n>> +!\n>> +! PR fortran/42954 - target macros missing in gfortran -cpp\n>> +\n>> +#if !defined(__i386__) && !defined(__i386) \\\n>> +    && !defined(__x86_64__) && !defined(__x86_64) \\\n>> +    && !defined(__amd64__) && !defined(__amd64)\n>> +# error x86 target macros not defined\n>> +#endif\n>> --\n>> 2.53.0\n>>\n>","headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=38.145.34.32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n dmarc=fail (p=quarantine dis=none) header.from=gmx.de","sourceware.org; spf=pass smtp.mailfrom=m.gmane-mx.org","server2.sourceware.org;\n arc=none smtp.remote-ip=116.202.254.214"],"Received":["from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g4CJ912Fxz1xvV\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 04:48:23 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id D65E24BAE7CD\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 27 Apr 2026 18:48:21 +0000 (GMT)","from ciao.gmane.io (ciao.gmane.io [116.202.254.214])\n by sourceware.org (Postfix) with ESMTPS id 2381A4BAD158\n for <gcc-patches@gcc.gnu.org>; Mon, 27 Apr 2026 18:47:53 +0000 (GMT)","from list by ciao.gmane.io with local (Exim 4.92)\n (envelope-from <gcc-patches@m.gmane-mx.org>) id 1wHQzn-0006qV-AR\n for gcc-patches@gcc.gnu.org; Mon, 27 Apr 2026 20:47:51 +0200"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org D65E24BAE7CD","OpenDKIM Filter v2.11.0 sourceware.org 2381A4BAD158"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 2381A4BAD158","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 2381A4BAD158","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777315673; cv=none;\n b=BYcIQFmKb5skbKXog/64uwNmTnpTcxYZwRuFKQcN26olo3QYtigXsaBJd8gdlHMRV+Xo6D0L8R+2/jYtp7JUIJou7OT4L3oQvbIEQpoeiF1+vlO0bu6TvEJrjxwMfBETZ+A9yHMKaJm8KZLotJY5oREVqZb/VxvckMPRs2hV49I=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1777315673; c=relaxed/simple;\n bh=wiPdl9RmyOKqnEMds50axAmrpT0yH8qi7+SpI7UZKAg=;\n h=To:From:Subject:Date:Message-ID:Mime-Version;\n b=cmGfX/Ob0UkcoO4do401hgJFOrmQCzeOh2vlzZASxm5ylEkCvV5P72IeoayDVMSqnpEs6NhavKO36hkyB5t6xv1efiv6JNXVC7Ngml5UsoPbM1escQ+FreGeJiYo4kkeSd78gEMKzuFu/OI2Ox0qYaxTV64edD0+dBWJP0nnBf8=","ARC-Authentication-Results":"i=1; server2.sourceware.org","X-Injected-Via-Gmane":"http://gmane.org/","To":"gcc-patches@gcc.gnu.org","From":"Harald Anlauf <anlauf@gmx.de>","Subject":"Re: [PATCH] fortran: Enable target preprocessor macros with -cpp\n [PR42954]","Date":"Mon, 27 Apr 2026 20:47:46 +0200","Message-ID":"<c8ddca76-cc4a-49ed-8b77-13967ab195e0@gmx.de>","References":"<20260416171656.2901675-1-albert@tugraz.at>\n <CALvbMcBdyw8LbKn=ZQ0o=-=Qd2N7n9uZa5mGhV-r+SRac4=jyg@mail.gmail.com>","Mime-Version":"1.0","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","User-Agent":"Mozilla Thunderbird","Content-Language":"en-US","In-Reply-To":"\n <CALvbMcBdyw8LbKn=ZQ0o=-=Qd2N7n9uZa5mGhV-r+SRac4=jyg@mail.gmail.com>","Cc":"fortran@gcc.gnu.org","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>","List-Archive":"<https://gcc.gnu.org/pipermail/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-request@gcc.gnu.org?subject=help>","List-Subscribe":"<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"}},{"id":3683698,"web_url":"http://patchwork.ozlabs.org/comment/3683698/","msgid":"<0831bcb0c6234b4882cb668bd247502d@tugraz.at>","list_archive_url":null,"date":"2026-04-28T19:51:21","subject":"Re: [PATCH] fortran: Enable target preprocessor macros with -cpp\n [PR42954]","submitter":{"id":92019,"url":"http://patchwork.ozlabs.org/api/people/92019/","name":"Albert, Christopher","email":"albert@tugraz.at"},"content":"On Mon, 27 Apr 2026 at 20:48, Harald Anlauf wrote:\n> Am 27.04.26 um 8:37 PM schrieb Andrew Pinski:\n>> On Thu, Apr 16, 2026 at 10:18 AM Christopher Albert <albert@tugraz.at> wrote:\n>>>\n>>> The Fortran preprocessor has never defined target-specific macros such as\n>>> __linux__, __unix__, __ELF__, __x86_64__, or __amd64__ that the C\n>>> preprocessor provides.  This was caused by the TARGET_OS_CPP_BUILTINS,\n>>> TARGET_OBJFMT_CPP_BUILTINS, and TARGET_CPU_CPP_BUILTINS hooks being\n>>> disabled since 2008 (marked as \"Pandora's Box\") because several target\n>>> config headers use C-family-only functions.\n>>>\n>>> Fix by providing Fortran-compatible local helpers for\n>>> builtin_define_std, builtin_define_with_value, and\n>>> builtin_define_with_int_value (which in the C frontend live in\n>>> c-family/c-cppbuiltin.cc and use the C-family-only globals parse_in\n>>> and flag_iso), plus wrapper macros for c_dialect_cxx, flag_iso, and\n>>> other C-family identifiers referenced by target config headers.  This\n>>> allows TARGET_OS_CPP_BUILTINS and TARGET_OBJFMT_CPP_BUILTINS to\n>>> execute in the Fortran frontend.\n>>>\n>>> Unlike the C frontend default (flag_iso=0, GNU extensions mode), the\n>>> Fortran wrapper sets flag_iso=1 to suppress user-namespace macros like\n>>> bare \"unix\" and \"linux\" that would conflict with Fortran identifiers.\n>>> Only the reserved-namespace forms (__unix__, __linux__, etc.) are\n>>> defined.  Fortran has no -std=cNN equivalent to control this, so the\n>>> conservative choice avoids silent identifier replacement.\n>>>\n>>> For TARGET_CPU_CPP_BUILTINS, which on most architectures expands to a\n>>> function in a C-family-only object file (e.g., ix86_target_macros in\n>>> i386-c.cc), provide an x86 implementation directly in fortran/cpp.cc\n>>> that covers architecture identification and float-size macros.\n>>> ISA feature macros (__SSE__, __AVX__, etc.) are not included; if\n>>> needed, they could be factored out of i386-c.cc into a shared object.\n>>>\n>>> Remove the dead __attribute__((target(...))) block from\n>>> gfortran.dg/gomp/declare-variant-10.f90: it was guarded by\n>>> #if defined(__x86_64__) which was previously always false because\n>>> gfortran never defined these macros, and gfortran does not support\n>>> C-style __attribute__ syntax.\n>>>\n>>> Co-authored-by: Kai Tietz <ktietz@gcc.gnu.org>\n>>>\n>>>          PR fortran/42954\n>>>\n>>> gcc/fortran/ChangeLog:\n>>>\n>>>          * cpp.cc (gfc_builtin_define_std): New helper mirroring\n>>>          builtin_define_std from c-family/c-cppbuiltin.cc.\n>>>          (gfc_builtin_define_with_value): New helper mirroring\n>>>          builtin_define_with_value from c-family/c-cppbuiltin.cc.\n>>>          (gfc_define_ix86_target_macros): New function providing x86 CPU\n>>>          identification macros for the Fortran preprocessor.\n>>>          (gfc_darwin_cpp_builtins): New function providing Darwin platform\n>>>          macros.\n>>>          (cpp_define_builtins): Remove Pandora's Box FIXME.  Add wrapper\n>>>          macros for C-family functions and variables used in target config\n>>>          headers.  Set flag_iso=1 to suppress bare-name macros.  Enable\n>>>          TARGET_OS_CPP_BUILTINS and TARGET_OBJFMT_CPP_BUILTINS.  Call\n>>>          gfc_define_ix86_target_macros on x86 targets.\n>> \n>> THIS is all wrong and causes too many issues. Please revert this.\n>\n> I haven't pushed yet, so all should be fine.\n>\n>>>\n>>> gcc/testsuite/ChangeLog:\n>>>\n>>>          * gfortran.dg/gomp/declare-variant-10.f90: Remove dead\n>>>          __attribute__((target)) block that is now exposed by newly\n>>>          defined target macros.\n>>>          * gfortran.dg/pr42954-linux.f90: New test.\n>>>          * gfortran.dg/pr42954-x86.f90: New test.\n>>>\n>>> Signed-off-by: Christopher Albert <albert@tugraz.at>\n>>> ---\n>>>   gcc/fortran/cpp.cc                            | 178 ++++++++++++++++--\n>>>   .../gfortran.dg/gomp/declare-variant-10.f90   |   3 -\n>>>   gcc/testsuite/gfortran.dg/pr42954-linux.f90   |  24 +++\n>>>   gcc/testsuite/gfortran.dg/pr42954-x86.f90     |  10 +\n>>>   4 files changed, 194 insertions(+), 21 deletions(-)\n>>>   create mode 100644 gcc/testsuite/gfortran.dg/pr42954-linux.f90\n>>>   create mode 100644 gcc/testsuite/gfortran.dg/pr42954-x86.f90\n>>>\n>>> diff --git a/gcc/fortran/cpp.cc b/gcc/fortran/cpp.cc\n>>> index 6b5f136e4f3..ada1bc1a211 100644\n>>> --- a/gcc/fortran/cpp.cc\n>>> +++ b/gcc/fortran/cpp.cc\n>>> @@ -157,6 +157,126 @@ void pp_dir_change (cpp_reader *, const char *);\n>>>   static int dump_macro (cpp_reader *, cpp_hashnode *, void *);\n>>>   static void dump_queued_macros (cpp_reader *);\n>>>\n>>> +/* Fortran-local helpers that mirror builtin_define_std,\n>>> +   builtin_define_with_value, and builtin_define_with_int_value from\n>>> +   c-family/c-cppbuiltin.cc.  Those functions use the C-family-only\n>>> +   globals parse_in and flag_iso, so they cannot be called directly\n>>> +   from the Fortran frontend.  */\n>>> +\n>>> +/* Given \"unix\", define __unix, __unix__, and (if DEFINE_USER) unix.  */\n>>> +\n>>> +static void\n>>> +gfc_builtin_define_std (cpp_reader *pfile, const char *macro,\n>>> +                       bool define_user)\n>>> +{\n>>> +  size_t len = strlen (macro);\n>>> +  char *buff = (char *) alloca (len + 5);\n>>> +  char *p = buff + 2;\n>>> +  char *q = p + len;\n>>> +\n>>> +  memcpy (p, macro, len + 1);\n>>> +  if (!(*p == '_' && (p[1] == '_' || ISUPPER (p[1]))))\n>>> +    {\n>>> +      if (*p != '_')\n>>> +       *--p = '_';\n>>> +      if (p[1] != '_')\n>>> +       *--p = '_';\n>>> +    }\n>>> +  cpp_define (pfile, p);\n>>> +\n>>> +  if (p != buff + 2)\n>>> +    {\n>>> +      if (q[-1] != '_')\n>>> +       *q++ = '_';\n>>> +      if (q[-2] != '_')\n>>> +       *q++ = '_';\n>>> +      *q = '\\0';\n>>> +      cpp_define (pfile, p);\n>>> +      if (define_user)\n>>> +       cpp_define (pfile, macro);\n>>> +    }\n>>> +}\n>>> +\n>>> +/* Define MACRO to EXPANSION; if IS_STR, quote the expansion.  */\n>>> +\n>>> +static void\n>>> +gfc_builtin_define_with_value (cpp_reader *pfile, const char *macro,\n>>> +                              const char *expansion, int is_str)\n>>> +{\n>>> +  size_t mlen = strlen (macro);\n>>> +  size_t elen = strlen (expansion);\n>>> +  char *buf = (char *) alloca (mlen + elen + 4);\n>>> +  if (is_str)\n>>> +    sprintf (buf, \"%s=\\\"%s\\\"\", macro, expansion);\n>>> +  else\n>>> +    sprintf (buf, \"%s=%s\", macro, expansion);\n>>> +  cpp_define (pfile, buf);\n>>> +}\n>>> +\n>>> +/* Provide x86 CPU identification macros for the Fortran preprocessor.\n>>> +   TARGET_CPU_CPP_BUILTINS() cannot be called directly because it expands\n>>> +   to ix86_target_macros() in i386-c.cc, which is only linked into\n>>> +   C-family frontends.  This covers architecture identification and\n>>> +   float-size macros.  ISA feature macros (__SSE__, __AVX__, etc.) and\n>>> +   arch/tune macros (__znver4__, __skylake__, etc.) from\n>>> +   ix86_target_macros_internal() are not included; if needed, they could\n>>> +   be factored out of i386-c.cc into a shared object.  */\n>>> +\n>>> +#ifdef TARGET_80387\n>> \n>> Please DON'T add target defines directly to the front-end.\n>> Please instead use a config file from the target instead. Like what is\n>> done for d, rust, etc. front-ends.\n>> Each target should have their a source file which does the cpp_\n>> instead of inlining it in the fortran front-end.\n>> \n>> Thanks,\n>> Andrea\n>\n> Alright, back to Chris...\n>\n> Thanks for stepping in quickly!\n>\n> Harald\n>\n>>> +static void\n>>> +gfc_define_ix86_target_macros (cpp_reader *pfile)\n>>> +{\n>>> +  if (TARGET_64BIT)\n>>> +    {\n>>> +      cpp_assert (pfile, \"cpu=x86_64\");\n>>> +      cpp_assert (pfile, \"machine=x86_64\");\n>>> +      cpp_define (pfile, \"__amd64\");\n>>> +      cpp_define (pfile, \"__amd64__\");\n>>> +      cpp_define (pfile, \"__x86_64\");\n>>> +      cpp_define (pfile, \"__x86_64__\");\n>>> +      if (TARGET_X32)\n>>> +       {\n>>> +         cpp_define (pfile, \"_ILP32\");\n>>> +         cpp_define (pfile, \"__ILP32__\");\n>>> +       }\n>>> +    }\n>>> +  else\n>>> +    {\n>>> +      cpp_assert (pfile, \"cpu=i386\");\n>>> +      cpp_assert (pfile, \"machine=i386\");\n>>> +      gfc_builtin_define_std (pfile, \"i386\", false);\n>>> +      cpp_define (pfile, \"_ILP32\");\n>>> +      cpp_define (pfile, \"__ILP32__\");\n>>> +    }\n>>> +\n>>> +  if (!TARGET_80387)\n>>> +    cpp_define (pfile, \"_SOFT_FLOAT\");\n>>> +\n>>> +  if (TARGET_LONG_DOUBLE_64)\n>>> +    cpp_define (pfile, \"__LONG_DOUBLE_64__\");\n>>> +\n>>> +  if (TARGET_LONG_DOUBLE_128)\n>>> +    cpp_define (pfile, \"__LONG_DOUBLE_128__\");\n>>> +\n>>> +  cpp_define_formatted (pfile, \"__SIZEOF_FLOAT80__=%d\",\n>>> +                       GET_MODE_SIZE (XFmode));\n>>> +  cpp_define (pfile, \"__SIZEOF_FLOAT128__=16\");\n>>> +}\n>>> +#endif\n>>> +\n>>> +/* Provide essential Darwin platform macros for the Fortran preprocessor.\n>>> +   The full darwin_cpp_builtins() in darwin-c.cc also defines\n>>> +   __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ and\n>>> +   __CONSTANT_CFSTRINGS__, but those depend on functions only linked\n>>> +   into C-family frontends.  */\n>>> +\n>>> +static void ATTRIBUTE_UNUSED\n>>> +gfc_darwin_cpp_builtins (cpp_reader *pfile)\n>>> +{\n>>> +  cpp_define (pfile, \"__MACH__\");\n>>> +  cpp_define (pfile, \"__APPLE__\");\n>>> +  gfc_builtin_define_with_value (pfile, \"__APPLE_CC__\", \"1\", false);\n>>> +}\n>>>\n>>>   static void\n>>>   cpp_define_builtins (cpp_reader *pfile)\n>>> @@ -177,33 +297,55 @@ cpp_define_builtins (cpp_reader *pfile)\n>>>     if (flag_openmp)\n>>>       cpp_define (pfile, \"_OPENMP=202111\");\n>>>\n>>> -  /* The defines below are necessary for the TARGET_* macros.\n>>> -\n>>> -     FIXME:  Note that builtin_define_std() actually is a function\n>>> -     in c-cppbuiltin.cc which uses flags undefined for Fortran.\n>>> -     Let's skip this for now. If needed, one needs to look into it\n>>> -     once more.  */\n>>> +  /* Wrapper macros for C-family identifiers used in target config\n>>> +     headers.  These allow TARGET_OS_CPP_BUILTINS and\n>>> +     TARGET_OBJFMT_CPP_BUILTINS to compile in the Fortran frontend.  */\n>>>\n>>>   # define builtin_define(TXT) cpp_define (pfile, TXT)\n>>> -# define builtin_define_std(TXT)\n>>> +# define builtin_define_std(TXT) gfc_builtin_define_std (pfile, TXT, !flag_iso)\n>>> +# define builtin_define_with_value(MACRO, EXPANSION, IS_STR) \\\n>>> +  gfc_builtin_define_with_value (pfile, MACRO, EXPANSION, IS_STR)\n>>> +# define builtin_define_with_int_value(MACRO, VALUE) \\\n>>> +  cpp_define_formatted (pfile, \"%s=\" HOST_WIDE_INT_PRINT_DEC, \\\n>>> +                       MACRO, (HOST_WIDE_INT) (VALUE))\n>>>   # define builtin_assert(TXT) cpp_assert (pfile, TXT)\n>>> +# define c_dialect_cxx() 0\n>>> +# define c_dialect_objc() 0\n>>> +# define preprocessing_asm_p() 0\n>>> +# define preprocessing_trad_p() 0\n>>> +  /* Fortran has no -std=cNN flag to control this.  Set to 1 (ISO mode)\n>>> +     so that builtin_define_std() only defines reserved-namespace macros\n>>> +     like __unix__ and __linux__, not bare \"unix\" or \"linux\" which are\n>>> +     valid Fortran identifiers and would cause silent replacement.  */\n>>> +# define flag_iso 1\n>>> +# define flag_isoc94 0\n>>> +# define flag_isoc99 0\n>>> +# define flag_isoc11 0\n>>> +# define flag_isoc23 0\n>>> +# define darwin_cpp_builtins(PFILE) gfc_darwin_cpp_builtins (PFILE)\n>>>\n>>> -  /* FIXME: Pandora's Box\n>>> -    Using the macros below results in multiple breakages:\n>>> -     - mingw will fail to compile this file as dependent macros\n>>> -       assume to be used in c-cppbuiltin.cc only. Further, they use\n>>> -       flags only valid/defined in C (same as noted above).\n>>> -       [config/i386/mingw32.h, config/i386/cygming.h]\n>>> -     - other platforms (not as popular) break similarly\n>>> -       [grep for 'builtin_define_with_int_value' in gcc/config/]\n>>> -\n>>> -  TARGET_CPU_CPP_BUILTINS ();\n>>>     TARGET_OS_CPP_BUILTINS ();\n>>> -  TARGET_OBJFMT_CPP_BUILTINS (); */\n>>> +  TARGET_OBJFMT_CPP_BUILTINS ();\n>>> +\n>>> +#ifdef TARGET_80387\n>>> +  gfc_define_ix86_target_macros (pfile);\n>>> +#endif\n>>>\n>>>   #undef builtin_define\n>>>   #undef builtin_define_std\n>>> +#undef builtin_define_with_value\n>>> +#undef builtin_define_with_int_value\n>>>   #undef builtin_assert\n>>> +#undef c_dialect_cxx\n>>> +#undef c_dialect_objc\n>>> +#undef preprocessing_asm_p\n>>> +#undef preprocessing_trad_p\n>>> +#undef flag_iso\n>>> +#undef flag_isoc94\n>>> +#undef flag_isoc99\n>>> +#undef flag_isoc11\n>>> +#undef flag_isoc23\n>>> +#undef darwin_cpp_builtins\n>>>   }\n>>>\n>>>   bool\n>>> diff --git a/gcc/testsuite/gfortran.dg/gomp/declare-variant-10.f90 b/gcc/testsuite/gfortran.dg/gomp/declare-variant-10.f90\n>>> index 0e0ab518010..115195e1194 100644\n>>> --- a/gcc/testsuite/gfortran.dg/gomp/declare-variant-10.f90\n>>> +++ b/gcc/testsuite/gfortran.dg/gomp/declare-variant-10.f90\n>>> @@ -64,9 +64,6 @@ contains\n>>>       call f18 ()          ! { dg-final { scan-tree-dump-times \"f18 \\\\\\(\\\\\\);\" 1 \"gimple\" } } */\n>>>     end subroutine\n>>>\n>>> -#if defined(__i386__) || defined(__x86_64__)\n>>> -  __attribute__((target (\"avx512f,avx512bw\")))\n>>> -#endif\n>>>     subroutine test2 ()\n>>>       !$omp target\n>>>         call f04 () ! { dg-final { scan-tree-dump-times \"f03 \\\\\\(\\\\\\);\" 1 \"gimple\" { target { { i?86-*-* x86_64-*-* } && { ! ilp32 } } } } }\n>>> diff --git a/gcc/testsuite/gfortran.dg/pr42954-linux.f90 b/gcc/testsuite/gfortran.dg/pr42954-linux.f90\n>>> new file mode 100644\n>>> index 00000000000..bd5efe7a237\n>>> --- /dev/null\n>>> +++ b/gcc/testsuite/gfortran.dg/pr42954-linux.f90\n>>> @@ -0,0 +1,24 @@\n>>> +! { dg-do preprocess { target *-*-linux* } }\n>>> +! { dg-options \"-cpp\" }\n>>> +!\n>>> +! PR fortran/42954 - target macros missing in gfortran -cpp\n>>> +\n>>> +#ifndef __linux__\n>>> +# error __linux__ not defined\n>>> +#endif\n>>> +\n>>> +#ifndef __linux\n>>> +# error __linux not defined\n>>> +#endif\n>>> +\n>>> +#ifndef __unix__\n>>> +# error __unix__ not defined\n>>> +#endif\n>>> +\n>>> +#ifndef __unix\n>>> +# error __unix not defined\n>>> +#endif\n>>> +\n>>> +#ifndef __ELF__\n>>> +# error __ELF__ not defined\n>>> +#endif\n>>> diff --git a/gcc/testsuite/gfortran.dg/pr42954-x86.f90 b/gcc/testsuite/gfortran.dg/pr42954-x86.f90\n>>> new file mode 100644\n>>> index 00000000000..0a3b7eac8a2\n>>> --- /dev/null\n>>> +++ b/gcc/testsuite/gfortran.dg/pr42954-x86.f90\n>>> @@ -0,0 +1,10 @@\n>>> +! { dg-do preprocess { target { i?86-*-* x86_64-*-* } } }\n>>> +! { dg-options \"-cpp\" }\n>>> +!\n>>> +! PR fortran/42954 - target macros missing in gfortran -cpp\n>>> +\n>>> +#if !defined(__i386__) && !defined(__i386) \\\n>>> +    && !defined(__x86_64__) && !defined(__x86_64) \\\n>>> +    && !defined(__amd64__) && !defined(__amd64)\n>>> +# error x86 target macros not defined\n>>> +#endif\n>>> --\n>>> 2.53.0\n>>>\n>>\n\nDear Andrea,\n\nthanks for checking this.\n\nI tried to keep the first version inside the Fortran frontend and overlooked the D/Rust frontend pattern you pointed out. I attached a smaller patch that adds a Fortran target hook and keeps the target-specific macro definitions in target config files.\n\nCould you check whether this structure looks right? If yes, I can extend it toward the fuller scope Harald asked for in the Bugzilla thread.\n\nThanks,\nChris","headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=tugraz.at header.i=@tugraz.at header.a=rsa-sha256\n header.s=mailrelay header.b=FNCSyvd8;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=38.145.34.32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n\tdkim=pass (1024-bit key,\n unprotected) header.d=tugraz.at header.i=@tugraz.at header.a=rsa-sha256\n header.s=mailrelay header.b=FNCSyvd8","sourceware.org; dmarc=pass (p=quarantine dis=none)\n header.from=tugraz.at","sourceware.org; spf=pass smtp.mailfrom=tugraz.at","server2.sourceware.org;\n arc=none smtp.remote-ip=129.27.2.202"],"Received":["from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g4rgX3ZTpz1yHv\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 29 Apr 2026 05:52:24 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 7C67B4BBC0AE\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 19:52:22 +0000 (GMT)","from mailrelay.tugraz.at (mailrelay.tugraz.at [129.27.2.202])\n by sourceware.org (Postfix) with ESMTPS id AC04D4BAE7DB;\n Tue, 28 Apr 2026 19:51:44 +0000 (GMT)","from exchange.tugraz.at (exchange.tugraz.at [129.27.2.221])\n by mailrelay.tugraz.at (Postfix) with ESMTPS id 4g4rfd2ps1z9ryy;\n Tue, 28 Apr 2026 21:51:37 +0200 (CEST)","from MBX003.tugraz.local (129.27.48.71) by MBX001.tugraz.local\n (129.27.48.68) with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.37; Tue, 28 Apr\n 2026 21:51:21 +0200","from MBX003.tugraz.local ([fe80::bbed:5113:6a1d:17bb]) by\n MBX003.tugraz.local ([fe80::bbed:5113:6a1d:17bb%5]) with mapi id\n 15.02.2562.035; Tue, 28 Apr 2026 21:51:21 +0200"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 7C67B4BBC0AE","OpenDKIM Filter v2.11.0 sourceware.org AC04D4BAE7DB"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org AC04D4BAE7DB","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org AC04D4BAE7DB","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777405905; cv=none;\n b=CsG4epx8vYO44A5i0EkcoYtYQKk1rBIrcFRlnmwUc9NUwVVNPdWTGJWNGMqmGDSTda727xQ8bAzEIR6MmEI+Ujl+PTjjlJ/Rnzv4GCpKcZ0iXQ/Ig3xX6g/qQgmvH3Dgbn9P8gu3yh2a1SUdGp0ybOPnfO+sAAAOH3I41ZSziOE=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1777405905; c=relaxed/simple;\n bh=ZurKADuml4cEpq1a10TLGTuJB2egtJajw9IRzLFjONM=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=wVgZ3JuiTl5B3P0OjV7jcZ7QST1QqYXqOpON4S7AgMMYyeqMSK+LOwHuH8qBdvBMdIq5HD7E1K7T2+qYFnI/NzKstl0t2GuTcyXjaT4kzh+z+bPaDO20h6e/hh5E5m3GqEqM34CO3YCpmI89N4u1bbjg3C2zTuIEYvT9ekozwWs=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=tugraz.at;\n s=mailrelay; t=1777405897;\n bh=8fbs0nlSba+lTPGvU1N/aZZbIvf7qWXoBZ//hEB0KLI=;\n h=From:To:CC:Subject:Date:References:In-Reply-To;\n b=FNCSyvd8NV3RD0NXp1sr2s1oGbjmLnbyioiD6d/qFtBNR1FFtFpUMKct+R2IO3k4Q\n l7XzTiEKtiXhd5sbAfeQMv8NniWDamLL5+2RIdT9RMvyIJu8pESHehc9agv1rXzeti\n yA7uc+jUxIMkq3an+6ok6SSgj6FH57AcRm5FFKck=","From":"\"Albert, Christopher\" <albert@tugraz.at>","To":"\"andrew.pinski@oss.qualcomm.com\" <andrew.pinski@oss.qualcomm.com>","CC":"\"anlauf@gmx.de\" <anlauf@gmx.de>, \"gcc-patches@gcc.gnu.org\"\n <gcc-patches@gcc.gnu.org>, \"fortran@gcc.gnu.org\" <fortran@gcc.gnu.org>,\n \"ktietz@gcc.gnu.org\" <ktietz@gcc.gnu.org>","Subject":"Re: [PATCH] fortran: Enable target preprocessor macros with -cpp\n [PR42954]","Thread-Topic":"[PATCH] fortran: Enable target preprocessor macros with -cpp\n [PR42954]","Thread-Index":"AQHc1nUX5iVXmP5nCUSH5VRP2dQx67XzHjsAgAGjq4A=","Date":"Tue, 28 Apr 2026 19:51:21 +0000","Message-ID":"<0831bcb0c6234b4882cb668bd247502d@tugraz.at>","References":"<c8ddca76-cc4a-49ed-8b77-13967ab195e0@gmx.de>","In-Reply-To":"<c8ddca76-cc4a-49ed-8b77-13967ab195e0@gmx.de>","Accept-Language":"de-AT, en-US","Content-Language":"de-AT","X-MS-Has-Attach":"yes","X-MS-TNEF-Correlator":"","x-originating-ip":"[129.27.48.252]","Content-Type":"multipart/mixed;\n boundary=\"_002_0831bcb0c6234b4882cb668bd247502dtugrazat_\"","MIME-Version":"1.0","X-TUG-Backscatter-control":"M8C9d6vb7ybI0LFLVdluXg","X-Scanned-By":"MIMEDefang 2.74 on 129.27.10.117","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>","List-Archive":"<https://gcc.gnu.org/pipermail/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-request@gcc.gnu.org?subject=help>","List-Subscribe":"<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"}}]