|
[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
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. >> 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
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |