Bug 2034 - Autoconf and -flto
Autoconf and -flto
Product: unbound
Classification: Unclassified
Component: server
x86_64 Linux
: P5 enhancement
Assigned To: unbound team
Depends on:
  Show dependency treegraph
Reported: 2017-10-25 21:46 CEST by Дилян Палаузов
Modified: 2017-11-03 11:54 CET (History)
2 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Дилян Палаузов 2017-10-25 21:46:38 CEST
unbound used Autoconf and users of Autoconf have certain expectations of what Autoconf does not do.

Users who regularly compile software (with Autoconf) put in their /usr/local/etc/config.site "export CFLAGS="-flto -O3 -pipe -fno-fact-lto-objects -fuse-ld=gold" LDFLAGS="-flto=4 -Wl,-s,-O1" and such things in order to get optimized code.  At the same time, such users expect, that not touching CFLAGS will not add any optimization making debugging surprising.

unbound/configure by default includes -flto to CFLAGS and this is not the way to do it.  When I wanted to debug libunbound I was surpized to find symbols containing lto in their names, even thought I have compiled unbound without stating explicitly -flto.

If any source code should generally be compiled with -flto, then it it not up to unbound to solve this, people need to be educated how to teach autoconf to include -O3 -flto on every compilation (or change the default impoded by autoconf).

Users who do not know about -O3 -flto -Wl,-s,-O1 do not notice anyway a difference, if only some of the code they compile is with LTO.

That said please delete the ACX_CHECK_FLTO macro and its definition.
Comment 1 Wouter Wijngaards 2017-10-30 16:10:49 CET

Could I somehow solve this by detecting your use-case and adjusting the flto default for that use-case?

For users that use the defaults, and that is lots, it does help a lot by enabling optimization across modules.

Best regards, Wouter
Comment 2 Дилян Палаузов 2017-10-30 16:31:42 CET
My use case is that I want consistent behaviour between all autoconf software, even when i compile 300+ different .tag.gz.  E.g. if I put LDFLAGS in /usr/local/etc/config.site I expect that ./configure respects that value, but php/configure does not.  Likewise if I put there CFLAGS="-O3" I expect that ./configure will respect that value, but postgresql/configure does not.

It also means, that if CFLAGS in /usr/local/etc/config.site does not include optimizations, then configure does not insert such.

Do users who use the defaults, compile also other software that uses the default, and do the other software by default include -flto optimization?

Yes, users compile also other software.  No, the other software doesn't add -flto.

Does it make sense, when some software by default (running ./configure without parameters) includes -flto or -O3 in CFLAGS and others don't?
Comment 3 Wouter Wijngaards 2017-11-03 11:54:31 CET

So I made it so that if you override the CFLAGS, it doesn't add flags.  If the user specifies nothing, and CFLAGS="" then it adds default flags (because without any flags is not that sensible as default).

Best regards, Wouter