[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 1/1] tools/tests/x86_emulator: avoid duplicate symbol error with clang: use -O0


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Edwin Torok <edwin.torok@xxxxxxxxxx>
  • Date: Mon, 9 Mar 2026 10:46:10 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=pWuuO0DE7JddmloIvsWoWHqdKWz5S3CurWOhGgZGUO8=; b=Cd8CH1GK6WzGFLFqQ/ciNUhWyTNgUgcjmUU9uprasiegP4MBPLKJsHgg73a4qS09ZMBVGeY9a3u8u7bBk6jSO46at36HwrFqFcPgd/Z2a8KghBDL01nB8Z++4DqPmO2K1cFY5jqivwc/Gq9t0DGYIHd6Y/ppDaqoJ4BklCyb6B7ZbUJIi8bU1ID0I+PZBtYRV5TMOkd6/sO6cbQ5m41BpfuVRnwUIEAf/qNiSo145jhR58Yx3f+A1MvalB1eBRL+HDR6s3TNeLXAa08aMnqZ7ffeR2FcAUJ2ilmmT8lFxPdMvKSwHrkSfdHx3CRDZjhw1L8ibV3cQkBzbuH67/17UA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TWGq8Ma3vVepB5jdjxODd//+uBbVBwQj/GMwIlLfFmCYCSeX5tD6YtwQgymPWT4FE2rWWbEEexP1fmT9rZrhwQL7RLZnIwzVYGBzMr88/GhkXEjrbEfOSiDCW0TlwU2FnrZRTSPwXCfutygZS1RRmdjf38fXl3nJqcFeMUERFwcwb6DrUEdooq8dWNWPJyS0aLnzt6rTTWSoD6BRmk7yGiALvbJdog2kB58gYZOiip+9Xq4JzMieFPxEJfKdRKvERccR7vYQOWYyezWcgaBh+SQIbDETIORsbNndAzRBdhiTWzkV0qsDRTr5BGtNzd5G+DRsb8onRcTfkumADbrm+A==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 09 Mar 2026 10:46:23 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHcrYXnXQSbfSYkDE2XRiS+3V/VSLWl1toAgAAhtYCAAAj/gIAABzwA
  • Thread-topic: [PATCH v3 1/1] tools/tests/x86_emulator: avoid duplicate symbol error with clang: use -O0


> On 9 Mar 2026, at 10:20, Jan Beulich <jbeulich@xxxxxxxx> wrote:
> 
> On 09.03.2026 10:49, Edwin Torok wrote:
>>> On 9 Mar 2026, at 07:47, Jan Beulich <jbeulich@xxxxxxxx> wrote:
>>> There's
>>> one other question though: Isn't -O0 the default? Where would any other
>>> optimization setting come from in HOSTCFLAGS? Ah, I see ./Config.mk does
>>> this, for an unclear to me reason.
>> 
>> One possible reason I’d enable optimisations (even for non-performance 
>> critical code) is to get better warnings.
>> I looked this up, and I see it is actually documented in the GCC manual:
>> "The effectiveness of some warnings depends on optimizations also being 
>> enabled.
>> For example, -Wsuggest-final-types is more effective with link-time 
>> optimization. 
>> Some other warnings may not be issued at all unless optimization is enabled.
>> While optimization in general improves the efficacy of warnings about 
>> control and data-flow problems,
>> in some cases it may also cause false positives.”
>> 
>> In fact warnings rely on optimisations even more than I thought, didn’t know 
>> about link time optimisations having an effect
>> (from the example that warning is only relevant for C++ for now)
>> 
>> I can see why in general a compiler would decide to implement it that way 
>> (if you run an analysis to get more accurate
>> information for showing warnings then you might as well use it to emit 
>> better code), but I wish that wasn’t the case. 
>> E.g. you may want to use a low optimisation level to get better debugging, 
>> without giving up on the better warnings.
>> The only way to do that currently is to build it twice (or rely on a CI that 
>> builds with different flags).
>> 
>> If you want to change it I’d suggest setting it at least to -Og, which is 
>> recommended over O0:
>> "In contrast to -O0, this enables -fvar-tracking-assignments and 
>> -fvar-tracking which handle debug information in the prologue and epilogue 
>> of functions better than -O0."
> 
> And did you check that -Og works for the purposes here? I'd indeed prefer to
> use that, if we can.


It avoids the duplicate symbol error with version of Clang that I have, so I 
have sent a V4 that uses -Og and the updated comments.
Was a bit worried this might not work with old GCCs, but AFAICT Og is supported 
since 4.8, and the minimum is 5.1.

Best regards,
—Edwin

> 
>>> Perhaps that would want mentioning
>>> here then as well.
>> 
>> How about:
>> 
>> # The default HOSTCFLAGS from $(XEN_ROOT)/Config.mk would set
>> # a non-zero optimisation level
>> 
>> I’d avoid mentioning -O2, in case that changes.
> 
> Of course.
> 
> Jan


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.