From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 518813858C54 for ; Tue, 4 Apr 2023 13:30:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 518813858C54 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=ibm.com Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 334D8cF0001486; Tue, 4 Apr 2023 13:30:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : date : message-id : references : in-reply-to : content-type : mime-version : subject; s=pp1; bh=l7ylonXje+lMWp+yDphRGDWcTMOZwfKRLwl1HNkuzMM=; b=Y6xaKpLHvPsXaukCHDBfSfsEfrG/p5zFJpI9D7dh45w7K2Q64sRalgCEDUoxISjQwWd5 RlHxx9CPMR0iAxXg1l0U7/KZcu/q9Z9N1KmAOGZxox9QpzaVy7SqfCxfbSqWttTk543V Fw/GAo7mHn2+y13TZobNUxOCmsWlUGZpqRNpPu7BhMCZxWjpjWXNWAWpKWBDB3Hgrejb j0WAPi5abklg05hFo1ClyeOfxC3BrXc8noCWkeP4HaOtMcFYqbXux8MT2kNWUadufXNr k213ApA2G/822SzPjE7XafuNH22h4YEnqyoTScOqDEhbwcDRkVsDheH87RRSjConfiFW ew== Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2044.outbound.protection.outlook.com [104.47.51.44]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3prmh4gn9v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 04 Apr 2023 13:30:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SDkQQC3MsgJu5K1x8Fps3CV7Fxo93oC6vMU8xpZyW76H6FwLIrGw8saP7xYf3OWmRXRb0kFkYci7FtcR10h/AAusoaeP1kciedDuYM8F+Sx1/ZQWKxLlWSfZAK9Cl3iCS2vK440zT2tMSKCxk9YIb1wdAvpXF6QR9JITVzRtgLJR7fOW6/W6IkE/fegd9sXel9jn8u115bDtSdO5Xb6KCXYIQgQ55o7ShnsHYQiKtz3bSiaJjiNVZAgv8PFc16bmftoEDQLXwWrskJXHRTU8UzGrFwpmzoXVW3g8rmyJjrBkc99NNYVWFMLw11Iod5B6dUcPMz3KV8DdjlJhXfvauw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=l7ylonXje+lMWp+yDphRGDWcTMOZwfKRLwl1HNkuzMM=; b=fmQQ+BpTcu6/oXuxqwwqdGM9L+32aXfD0UF2bq38W55Ks95EXT2O9z+mKn23vYF25Il+bOuevDlpefD/t7DnCz/t1YR42Y1wqvPTb3i2WV3NnzVBBsHVq7GoshE/HaDeHIAEbyTvUKbu5EuiY8boGNZEKP4cgCipLxcWeAETVsX8jeaso7fBFLo+Ezb2nNyY5SSa9bGfOmZRgiqNrgXbBPEY2CWkQXOvn1+tBajajAN+Y2myKs9pLFy1A8BR5XShaCPhMk3LsYNRMIe9Lcr1L9FmtHPeSVvOOzCNYMwx8hlnF5+ICo1qd+aAbEAiYAXNMphs7dnJN9vs9HbMBZ2vOA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ibm.com; dmarc=pass action=none header.from=ibm.com; dkim=pass header.d=ibm.com; arc=none Received: from CH2PR15MB3544.namprd15.prod.outlook.com (2603:10b6:610:5::26) by SN7PR15MB4158.namprd15.prod.outlook.com (2603:10b6:806:105::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.35; Tue, 4 Apr 2023 13:24:59 +0000 Received: from CH2PR15MB3544.namprd15.prod.outlook.com ([fe80::fc4b:b8cb:1472:d50a]) by CH2PR15MB3544.namprd15.prod.outlook.com ([fe80::fc4b:b8cb:1472:d50a%6]) with mapi id 15.20.6254.033; Tue, 4 Apr 2023 13:24:59 +0000 From: Aditya Kamath1 To: Pedro Alves , Ulrich Weigand , "gdb-patches@sourceware.org" , "tom@tromey.com" CC: Sangamesh Mallayya , "simon.marchi@efficios.com" Thread-Topic: [EXTERNAL] RE: [PATCH] Modify align-c/align-c++ test case for AIX Thread-Index: AQHZXAEQQ9maDMU2LkakAv3jr+hZe68Rm2+FgAAzigCAAww/+YAGXiJe Date: Tue, 4 Apr 2023 13:24:59 +0000 Message-ID: References: <87edpwmzpz.fsf@tromey.com> <3636157c35660e96f2da98eb70cbac597d0a092c.camel@de.ibm.com> <87r0tqchea.fsf@tromey.com> <87zg8bave2.fsf@tromey.com> <61289f79c8c08ebe15112711954e1b05d49c92be.camel@de.ibm.com> <877cvagpeh.fsf@tromey.com> <82c24017291c399d58fc87d7ae7fc1b17c665295.camel@de.ibm.com> In-Reply-To: Accept-Language: en-IN, en-US Content-Language: en-IN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CH2PR15MB3544:EE_|SN7PR15MB4158:EE_ x-ms-office365-filtering-correlation-id: 4c6f2cbd-5135-43d1-df15-08db350ffd89 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: g3Rgb39iHNlWaEl65zyxSh+ScKWVxNTDl9rALIR5Mw4zrX4YHetG6AEbgkMUAxDJwjcy4J5qO0rfKSi6rkPaBdCBuAna4sGpvYfFHN4YRkJyOruB12fM0bMnkLgKRPpIL0Gc6bsYhs6dX4RH4+fiDjRxMM6GpqKbJXflgXBww3JOg5rf21bfqNdmnuWk2Ga1Wu1pzRa6va6jpRn7DxzYZzDIyEzX3EsO27OlfGMScB5B+PzzbtWNJeWtWl/bIJ6hD4d4z7Qw+lKN8jlWZH2Pc7FFwLPcz+HIxXZx8gvVJgTqJpvRk+bPuK6R3bBKA3pBIdJT7s3woSEDEx4SacO364RpV1ZAgmwj318xP2wnnCxTk2/285LMGbiuL7UH4ambT605isCzyBD5ZztYrKZLjIc0Bu/Y3zT3wdFDwOoUS9UqoKkjliCP4tNYSpaZW2EWYJe9o5Aa4/uEY9ayfKXgtqfMLQD1cu3OhTYNY1WPG84buMQBp5QhIcZDHLQDeG3PjHePPVB4vRJM9K11iFb3NXkuY63fHkKbW7NSQ4Bnu30LWlBhguMeICGCdZ4THJaRa4dXgWFULmLnMHlN1PgioidDTMqKjvhS9jdyzXRNt80= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH2PR15MB3544.namprd15.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(376002)(396003)(346002)(136003)(366004)(451199021)(83380400001)(91956017)(7696005)(478600001)(71200400001)(316002)(110136005)(186003)(26005)(54906003)(6506007)(53546011)(2906002)(9686003)(5660300002)(33656002)(38100700002)(122000001)(66556008)(66946007)(41300700001)(4326008)(64756008)(8676002)(66476007)(66446008)(8936002)(76116006)(86362001)(38070700005)(55016003)(52536014)(84970400001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?Windows-1252?Q?vOMeP/rrb3dOvNYgYGqbtb5OtEt+Kx4mMLJKz8qBzrWpXmz9L5DX8eOU?= =?Windows-1252?Q?gAnFWigXOrU0T3bEBxkKkFsgVwBpB8auLnrRKp1Uq4JY3zUb9PHVXgJX?= =?Windows-1252?Q?FBskKtrFeNv5JhWEc1h4mlyNUr91YqWizXYKenwVHBr6ZuiuviWIDgs9?= =?Windows-1252?Q?n2LSFb0h4Z3WeX3gHSBECcA3alWmOagbag70EAuhPGvv1RuU/CDkfizT?= =?Windows-1252?Q?vc7XfmnuQHA3apXzMwrkgprd7CODEIkaKchv8Dn9hynTLrvS0W53XJGa?= =?Windows-1252?Q?T7+ryL6NDKHQyWrl67O0WIqtPrV61epvgBlWakliNI/HXK4OTIvJAoZC?= =?Windows-1252?Q?dUMDGkR0yIiwEpprGzkFfr7F5s7507MOCE5S9PHdtpjnptR35cEsgGG8?= =?Windows-1252?Q?m8JTmdgyM6Ubn41jlsx77KSYzvvJkvlpB74HIgd9uBM3r8L9flvdy5rK?= =?Windows-1252?Q?eYofBX+TyD1FX/poEHDg3/o9QDfsPHTqPg0O5yoCBV9qF/XttrqVwZBo?= =?Windows-1252?Q?vY+BfoTwUM+BmVRW80gWFmL6mEbPV1hU+YlEHu9VKf3ajUqWYRXt4nIt?= =?Windows-1252?Q?5H96uCNic9NS2GFcKSXNsX1jdCtm68WmFI3v/v0CsryuNcXSCYo1B41P?= =?Windows-1252?Q?nzqg0Zz5OoMRn0cIKUH4KDqx/1W9aZc9LGS9N0Ecl39merYGkvOqTa9H?= =?Windows-1252?Q?ZaNCEMTZNeM/otvOIBkvv23ljLzzw2bDljGg/OUQgw6jj0SjMoLrZyxS?= =?Windows-1252?Q?WiqWSI3zXXOs9s3LZX/vfoUWVir+LKpQhOdXzb0tUn6EXEkj+DF6ICJO?= =?Windows-1252?Q?/LO8OVkiaLRKmVr6g02yLZiipmosiflAADPQq2kjSoAZm6V9F8dXJkxu?= =?Windows-1252?Q?/ZunUtaa5QR1mKOi6pC6JxZFvGKUj9cztjA3ysboWQLvtw8fbf8hqeDa?= =?Windows-1252?Q?ByInK+daG4OnVECLyENziKle9HUdCm1HAjIMWAlpDeJFS7gG4Crc9dJy?= =?Windows-1252?Q?EMxK4mi4hKgkxurV7hjGKxbEMi4Imer17BHFZYyQPkUgDh33XWCzGask?= =?Windows-1252?Q?x7wNYhjLC+VllMdO60KoPRmsh9+5ixhz/mi8A5/DQ9Z5TtGaJb5B6/k1?= =?Windows-1252?Q?5WhmJY20UPOnfdm/MhtP+K6LxVb+mRT3cw6g4j+ttmlLjB6NOLnWeRzc?= =?Windows-1252?Q?8pJT6cWtn0n+B2t0EmJnx4q+XSagsRxeyrX22/kSB9Tw/0SpQKKCfY4u?= =?Windows-1252?Q?uFFUedtkzMSqPCWRjKGlx6XaCKNlEhJIfIKGFGFVBwlvgKl/dY/6fKFQ?= =?Windows-1252?Q?Vfjonm3SS7ZF953jQgGE3ELae1RcWB01g2mI998XQDvD3DTP9iYlVY4l?= =?Windows-1252?Q?9dvsmnFbRKPCejL1axbeb9Ddj0FZsy2RicisxcvAH/ZEV7KAIYd8cfyN?= =?Windows-1252?Q?30sKcZlqC3nrm3qBquggNZU/V6v8ShFLdz3q382egi9PNOSluO5iZCVs?= =?Windows-1252?Q?x9y+riCwArWxG5qTWU2THZxLIeD13G4Gw4dZe+mJ/5zflO90dxmVskMa?= =?Windows-1252?Q?0v3LKVDVZI4Sb6xNpS52+QgpOKCxs43tWJ0vezoRzeC3Z3niM1emDxy+?= =?Windows-1252?Q?ULPvjAr4a6uUC9eHtJ3LesouIcoREUPyVCF1tow2ne1//ZjUQKvYfoN1?= =?Windows-1252?Q?bvWvuVmiuNceqwWxvJvxQH4tt3eu0UdhUmIjGNAGH1smjjKRdwBh1A?= =?Windows-1252?Q?=3D=3D?= Content-Type: multipart/alternative; boundary="_000_CH2PR15MB3544B9C994A2E52B36AD2CD1D6939CH2PR15MB3544namp_" MIME-Version: 1.0 X-OriginatorOrg: ibm.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CH2PR15MB3544.namprd15.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4c6f2cbd-5135-43d1-df15-08db350ffd89 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Apr 2023 13:24:59.6903 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: fcf67057-50c9-4ad4-98f3-ffca64add9e9 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Ow5irS2wDSCSB56Nh8M9EobXTfQdaf5Q5Hb/I1ElD5PCDtUi8+mHVU8xbolNr1AJH+6tmdlSyu+MBVVHp7gyJw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR15MB4158 X-Proofpoint-GUID: B2SHIetU6reBjDDcUx5fW9gGZ8-F9neA X-Proofpoint-ORIG-GUID: B2SHIetU6reBjDDcUx5fW9gGZ8-F9neA Subject: RE: [PATCH] Modify align-c/align-c++ test case for AIX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-04_05,2023-04-04_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 priorityscore=1501 bulkscore=0 spamscore=0 malwarescore=0 clxscore=1015 impostorscore=0 phishscore=0 suspectscore=0 adultscore=0 lowpriorityscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304040121 X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,HTML_MESSAGE,KAM_LOTSOFHASH,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --_000_CH2PR15MB3544B9C994A2E52B36AD2CD1D6939CH2PR15MB3544namp_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Hi all, Kindly update me on my patch in the previous email=85 Thanks and regards, Aditya. From: Gdb-patches on behalf of Aditya Kamath1 via Gdb-patches Date: Friday, 31 March 2023 at 5:59 PM To: Pedro Alves , Ulrich Weigand , gdb-patches@sourceware.org , tom@tromey.co= m Cc: Sangamesh Mallayya , simon.marchi@efficios.= com Subject: [EXTERNAL] RE: [PATCH] Modify align-c/align-c++ test case for AIX Hi Pedro, Ulrich, Tom and community members, Thank you for your feedback. Please find attached the patch. {See: 0001-Mod= ify-align-c-align-c-test-case-for-AIX.patch} >Like below. Does this work for AIX? Hi Pedro and Respected community members. Kindly allow me to disagree with = you all for the patch diff that was pasted in the previous email reply thre= ad. Consider a smaller piece of the test case pasted #include using namespace std; struct align_pair_char_x_char {char one; char two;}; struct align_pair_char_x_char item_char_x_char; char align_pair_char_x_char::one =3D 0; unsigned a_char_x_char =3D alignof (struct align_pair_char_x_char); int main() { printf ("%d \n", a_char_x_char); } So the line highlighted in bold is a problem. This line is also there in th= e patch diff that was pasted in the previous email reply thread. This is n= ot allowed. We are trying to access something we should not. In case we wan= t to initialise any data member, we need to do it via a constructor. In AIX, I can see 'char align_pair_char_x_unsigned_char::one' is not a stat= ic data member of 'struct align_pair_char_x_unsigned_char' error I did not try in PowerPc Linux or another Linux machine. But from the littl= e knowledge I have, it should not work there as well. Someone needs to chec= k this in Linux. May be you or Ulrich or Tom can confirm this from your exp= erience in Linux. Let me know. In my patch I have these lines. if { $lang =3D=3D "c++" } { + puts $outfile "{ T one =3D 0; U two; }" puts -nonewline $outfile "#define DEF_WITH_1_STATIC(T,U) str= uct align_pair_static_ ## T ## _x_ ## U " puts $outfile "{ static T one; U two; }" puts -nonewline $outfile "#define DEF_WITH_2_STATIC(T,U) str= uct align_pair_static_ ## T ## _x_static_ ## U " puts $outfile "{ static T one; static U two; }" } if { $lang =3D=3D "c" } { + puts $outfile "{ T one; U two; }" If the aim is to initialise, then this will work in C++. In C we will get a= n error saying for doing one =3D 0, 1 | define DEF(T,U) struct align_pair_ ## T ## _x_ ## U { T one =3D 0; U tw= o; } | ^ /home/aditya/latest_gdb/binutils-gdb/gdb/testsuite/outputs/gdb.base/align-c= /align.c:52:1: note: in expansion of macro 'DEF' 52 | DEF (char, char); | ^~~ /home/aditya/latest_gdb/binutils-gdb/gdb/testsuite/outputs/gdb.base/align-c= /align.c:1:62: error: expected ':', ',', ';', '}' or '__attribute__' before= '=3D' token 1 | define DEF(T,U) struct align_pair_ ## T ## _x_ ## U { T one =3D 0; = U two; } So I made those changes for respective languages such that only in c++ we m= ake one =3D 0. The patch attached works perfectly. You might wonder how when we do not use= the struct variables. In AIX atleast, if we access one of the garbage or u= nused variable we are able to access everything else. Kindly consider the attached patch in this email, if it works in all other = targets as well. If not let me know. Have a nice day ahead. Test case numbers of AIX after applying this patch : align-c =3D 406 and al= ign-c++ =3D 1134 Test case numbers of AIX before applying this patch : align-c =3D 0 and ali= gn-c++ =3D 0 Output of the below code is 1. #include using namespace std; struct align_pair_char_x_char {char one =3D 0; char two;}; struct align_pair_char_x_char item_char_x_char; unsigned a_char_x_char =3D alignof (struct align_pair_char_x_char); int main() { printf ("%d \n", a_char_x_char); } Thanks and regards, Aditya. From: Pedro Alves Date: Wednesday, 29 March 2023 at 7:06 PM To: Aditya Kamath1 , Ulrich Weigand , gdb-patches@sourceware.org , tom@= tromey.com Cc: Sangamesh Mallayya , simon.marchi@efficios.= com Subject: [EXTERNAL] Re: [PATCH] Modify align-c/align-c++ test case for AIX On 2023-03-29 12:28 p.m., Aditya Kamath1 wrote: >>I'm wondering whether __attribute__((used)) on the global variable makes = any >>difference. IIRC with LLVM it prevents link-time stripping on Mach-O and= PE/COFF, >>but I don't know about XCOFF + GCC. (It doesn't on ELF, you >>need 'retain' for that.) > > Hi Pedro. So thanks for this suggestion. I learnt something new from you.= But this __attribute__((used)) did not make any difference in our environm= ent. Thanks for checking. I also recalled that Clang with LTO has a similar issue, and there __attrib= ute__((used)) tends to help. Seems to me that it's best to tweak the code generator to j= ust emit uses for all variables then, instead of special casing some platform or some spe= cific variable. Like below. Does this work for AIX? =46rom 576c9c77ff3ac297a58662471fd0a2546a1d5f42 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Wed, 29 Mar 2023 13:21:20 +0100 Subject: [PATCH] Fix gdb.base/align-*.exp and Clang + LTO and AIX GCC Clang with LTO (clang -flto) garbage collects unused global variables, Thus, gdb.base/align-c.exp and gdb.base/align-c++.exp fail with hundreds of FAILs like so: $ make check \ TESTS=3D"gdb.*/align-*.exp" \ RUNTESTFLAGS=3D"CC_FOR_TARGET=3D'clang -flto' CXX_FOR_TARGET=3D'clang++= -flto'" ... FAIL: gdb.base/align-c.exp: get integer valueof "a_char" FAIL: gdb.base/align-c.exp: print _Alignof(char) FAIL: gdb.base/align-c.exp: get integer valueof "a_char_x_char" FAIL: gdb.base/align-c.exp: print _Alignof(struct align_pair_char_x_char) FAIL: gdb.base/align-c.exp: get integer valueof "a_char_x_unsigned_char" ... AIX GCC has the same issue, and there the easier way of adding __attribute__((used)) to globals does not help. So add explicit uses of all globals to the generated code. For the C++ test, that reveals that the static variable members of the generated structs are not defined anywhere, leading to undefined references. Fixed by emitting initialization for all static members. Lastly, I noticed that CXX_FOR_TARGET was being ignored -- that's because the align-c++.exp testcase is compiling with the C compiler driver. Fixed by passing "c++" as option to prepare_for_testing. Change-Id: I874b717afde7b6fb1e45e526912b518a20a12716 --- gdb/testsuite/gdb.base/align.exp.tcl | 49 ++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.base/align.exp.tcl b/gdb/testsuite/gdb.base/= align.exp.tcl index 6a75a14d887..550afe1c47d 100644 --- a/gdb/testsuite/gdb.base/align.exp.tcl +++ b/gdb/testsuite/gdb.base/align.exp.tcl @@ -94,12 +94,15 @@ proc prepare_test_source_file { lang } { puts $outfile "DEF_WITH_1_STATIC ($utype, $uinner);" set joined "static_${utype}_x_${uinner}" puts $outfile "struct align_pair_$joined item_${joined};" + puts $outfile "$utype align_pair_${joined}::one =3D 0;" puts $outfile "unsigned a_${joined}" puts $outfile " =3D ${align_func} (struct align_pair_${jo= ined});" puts $outfile "DEF_WITH_2_STATIC ($utype, $uinner);" set joined "static_${utype}_x_static_${uinner}" puts $outfile "struct align_pair_$joined item_${joined};" + puts $outfile "$utype align_pair_${joined}::one =3D 0;" + puts $outfile "$uinner align_pair_${joined}::two =3D 0;" puts $outfile "unsigned a_${joined}" puts $outfile " =3D ${align_func} (struct align_pair_${jo= ined});" } @@ -107,12 +110,53 @@ proc prepare_test_source_file { lang } { } # Epilogue. - puts $outfile { + puts $outfile " int main() { - return 0; + " + + # Clang with LTO garbage collects unused global variables, even at + # -O0. Likewise AIX GCC. Add uses to all global variables to + # prevent it. + + if { $lang =3D=3D "c" } { + puts $outfile "a_void++;" + } + + # First, add uses for single items. + foreach type $typelist { + set utype [join [split $type] _] + puts $outfile "item_$utype++;" + if { $lang =3D=3D "c" } { + puts $outfile "a_$utype++;" + } + } + + # Now add uses for all pairs. + foreach type $typelist { + set utype [join [split $type] _] + foreach inner $typelist { + set uinner [join [split $inner] _] + set joined "${utype}_x_${uinner}" + puts $outfile "item_${joined}.one++;" + puts $outfile "a_${joined}++;" + + if { $lang =3D=3D "c++" } { + set joined "static_${utype}_x_${uinner}" + puts $outfile "item_${joined}.one++;" + puts $outfile "a_${joined}++;" + + set joined "static_${utype}_x_static_${uinner}" + puts $outfile "item_${joined}.one++;" + puts $outfile "a_${joined}++;" + } } } + puts $outfile " + return 0; + } + " + close $outfile return $filename @@ -127,6 +171,7 @@ proc run_alignment_test { lang } { set flags {debug} if { "$lang" =3D=3D "c++" } { + lappend flags "c++" lappend flags "additional_flags=3D-std=3Dc++11" } standard_testfile $filename base-commit: b863b097ee7a79b1114b9dd386864bc3c23a51b0 -- 2.36.0 --_000_CH2PR15MB3544B9C994A2E52B36AD2CD1D6939CH2PR15MB3544namp_--