Hi,
While trying to add a flag to BOOT_CFLAGS in Debian, I ended up with
some mysterious build failures with PGO+LTO enabled at -fprofile-use
stage. The investigation took some time. Eventually I discovered that by
setting my flag in BOOT_CFLAGS, I was accidentally overriding the
default (-g -O2). Hence I was building with no optimizations at all, and
that didn't play well with PGO+LTO because of the fact that Ada's
a-except.o is built with -O1. From Make-lang.in:
ada/libgnat/a-except.o : ada/libgnat/a-except.adb ada/libgnat/a-except.ads
ada/libgnat/s-excmac.ads ada/libgnat/s-excmac.adb
$(CC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -O1 -fno-inline \
The mismatch between the implicit -O0 and the hardcoded -O1 seem to be
the cause of the PGO problem I encountered. The build is fine with -O1
(or -O2) explicitly added to BOOT_CFLAGS.
Now, I suppose there's no valid reason for a PGO build with -O0.
However, I am now curious about the reason behind forcing -O1 for
building a-except.o. What's the reason behind it? Similarly, s-excdeb.o
is built with explicit -O0. Why is this needed?
Thanks,
Emanuele