From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id 625ED3852A4E; Tue, 13 Dec 2022 21:41:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 625ED3852A4E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.96,242,1665475200"; d="scan'208";a="89572842" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 13 Dec 2022 13:41:51 -0800 IronPort-SDR: Yn3n1p6sNy92PN+reZnbdQg5N1fkK7KpbGCyTgZWSUAHULEDOodg7978GWFQdDTMwnCxjw50LZ haeEZlQWFH5u4Y38T3zBSGDmMN18not84AeVJSvYUGhHsmBZyy3MVlMLCG2zSBYDH+R43y5aKu GBnedBd8wjLTSmMVOWh8HcKuHO4CfmAhjRBnXwsiNXFehFE32LCGlY/ASmUWfVa3mxaFT8dcG9 FqRvhid65GPvgE+cazmwsRHFG5Q4ACDa5nB2HbZ+WulIu7Sow6BZapW8MRQSq2t7Doko0g6Q+5 Nts= Message-ID: <1faf5680-9f5a-1f9d-4a9d-4eaff8982056@codesourcery.com> Date: Tue, 13 Dec 2022 22:41:44 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [Patch, Fortran] libgfortran's ISO_Fortran_binding.c: Use GCC11 version for backward-only code [PR108056] Content-Language: en-US To: Harald Anlauf , gcc-patches , fortran References: From: Tobias Burnus In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: quoted-printable X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-13.mgc.mentorg.com (139.181.222.13) To svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,KAM_SHORT,NICE_REPLY_A,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Harald, On 13.12.22 21:53, Harald Anlauf via Gcc-patches wrote: >> I now did so - except for three fixes (cf. changelog). See also >> PR: https://gcc.gnu.org/PR108056 >> >> There is no testcase as it needs to be compiled by GCC <=3D 11 and then >> run with linking (dynamically) to a GCC 12 or 13 libgfortran. > > I've looked at the resulting ISO_Fortran_binding.c vs. the 11-branch > version and am still trying to understand the resulting differences > in the code, in what respect they might be relevant or not. Hmm, if I run a diff, I do not see much differences. Note: We only talk about those two functions, the other functions are used by both GCC <=3D 11 and GCC >=3D 12. Fortunately, these functions matter most as they map GFC internals to CFI internals or vice versa. Most other functions are user callable and there incompatibilities are less likely to show up and GCC 11 users also could profit from fixes there. It looks as if CFI_section and CFI_select_part had some larger changes, likewise CFI_setpointer. Back to differences: 'diff -U0 -p -w' against the last GCC 11 branch shows: ... @@ -35,0 +37,2 @@ export_proto(cfi_desc_to_gfc_desc); +/* NOTE: Since GCC 12, the FE generates code to do the conversion + directly without calling this function. */ @@ -63 +66 @@ cfi_desc_to_gfc_desc (gfc_array_void *d, - d->dtype.version =3D s->version; + d->dtype.version =3D 0; @@ -76,0 +80 @@ cfi_desc_to_gfc_desc (gfc_array_void *d, + if (GFC_DESCRIPTOR_DATA (d)) @@ -79,3 +83,7 @@ cfi_desc_to_gfc_desc (gfc_array_void *d, - GFC_DESCRIPTOR_LBOUND(d, n) =3D (index_type)s->dim[n].lower_bound; - GFC_DESCRIPTOR_UBOUND(d, n) =3D (index_type)(s->dim[n].extent - + s->dim[n].lower_bound - 1= ); + CFI_index_t lb =3D 1; + + if (s->attribute !=3D CFI_attribute_other) + lb =3D s->dim[n].lower_bound; + + GFC_DESCRIPTOR_LBOUND(d, n) =3D (index_type)lb; + GFC_DESCRIPTOR_UBOUND(d, n) =3D (index_type)(s->dim[n].extent + lb = - 1); @@ -89,0 +98,2 @@ export_proto(gfc_desc_to_cfi_desc); +/* NOTE: Since GCC 12, the FE generates code to do the conversion + directly without calling this function. */ @@ -100,2 +110,2 @@ gfc_desc_to_cfi_desc (CFI_cdesc_t **d_pt - d =3D malloc (sizeof (CFI_cdesc_t) - + (CFI_type_t)(CFI_MAX_RANK * sizeof (CFI_dim_t))); + d =3D calloc (1, (sizeof (CFI_cdesc_t) + + (CFI_type_t)(CFI_MAX_RANK * sizeof (CFI_dim_t)))); @@ -107 +117 @@ gfc_desc_to_cfi_desc (CFI_cdesc_t **d_pt - d->version =3D s->dtype.version; + d->version =3D CFI_VERSION; @@ -153 +163 @@ void *CFI_address (const CFI_cdesc_t *dv ... > Given that this is a somewhat delicate situation we're in, is there > a set of tests that I could run *manually* (i.e. compile with gcc-11 > and link with gcc-12/13) to verify that this best-effort fix should > be good enough for the common user? > > Just a suggestion of a few "randomly" chosen tests? Probably yes. I don't have a better suggestion. The problem is that it usually only matters in some corner cases, like in the PR where a not some argument is passed to the GFC=E2=86=92CFI conversion but first a Fortr= an function is called with TYPE(*) any only then it is passed on. =E2=80=93 Su= ch cases are usually not in the testsuite. (With GCC 12 we have a rather complex testsuite, but obviously it also does not cover everything.) >> Note: It is strongly recommended to use GCC 12 (or 13) with >> array-descriptor >> C interop as many issues were fixed. [...] > > Well, in the real world there are larger installations with large > software stacks, and it is easier said to "compile each component > with the same compiler version" than done... I concur =E2=80=93 but there were really many fixes for the array descripto= r / TS29113 in GCC 12. It is simply not possible to fix tons of bugs and be 100% compatible with the working bits of the old version =E2=80=93 especially if they only = work if one does not look sharply at the result. (Like here, were 'type' is wrong, which does not matter unless in programs which use them.) Thanks, Tobias ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstra=C3=9Fe 201= , 80634 M=C3=BCnchen; Gesellschaft mit beschr=C3=A4nkter Haftung; Gesch=C3= =A4ftsf=C3=BChrer: Thomas Heurung, Frank Th=C3=BCrauf; Sitz der Gesellschaf= t: M=C3=BCnchen; Registergericht M=C3=BCnchen, HRB 106955