The NTP package has long had a configure test for in6addr_any availability, forked from BIND 9's configure script, which provides a bunch of IPv6-related gap-filling in portability library libisc. In the recent ntp-dev tarballs (4.2.7p142 is the latest) it lives in sntp/m4/ntp_ipv6.m4 [1]. Stefan ollson recently reported NTP failing to compile on his ARM-based Linux NAS using gcc 4.1.3 [2]. NTP's configure script mistakenly was finding his system provided "struct in6_addr in6addr_any;" at configure time, then failed to link ntpd with unresolved external in6addr_any. With a little help along the way, he discovered the problem went away if compiler optimization was dialed back using -O0. I had predicted it would not make a difference, which he thankfully did not put too much faith in. The test is basically AC_LINK_IFELSE of struct in6_addr in6; in6 = in6addr_any; and the optimizer (quite rightly) noticed the value of in6 goes out of scope without being referenced again and eliminated the assignment, thereby eliminating all references to in6addr_any, undermining the intent of the test. What surprises me is why this didn't come up sooner. The NTP reference implementation package is routinely built on a wide variety of gcc versions and on quite a few older systems lacking IPv6. Similarly BIND 9. I searched the autoconf mailing list archives for a variety of keywords like "-O2 breaks test" but didn't manage to find any similar reports of configure tests being broken by optimization. Have you hit a similar problem in the past? Please share what you recall or can dig up! We have a solution, changing the test to assign the address of in6addr_any to a global variable preserves the reference: #include <...> struct in6_addr * pin6addr_any = &in6addr_any; int main() { return 0; } But as I commented in the NTP bug report, I find this a bit scary, and in his position, I'd be tempted to use -O1 or -O0 routinely with that compiler to avoid triggering similar configure test failures in other software. Shooting from the hip, I expect there are a lot of similarly simple, apparently dead references lurking in other configure tests in the wild. Apparently most gcc version/arch combinations in the wild do _not_ optimize away the external reference to in6addr_any at -O2, as evidenced by NTP and BIND 9 relying on similar tests for years. Is our fix the best you can imagine? Is this particular gcc version an outlier, or have we just been lucky or had less coverage than I thought? Thanks for your time, Dave Hart [1] AC_CACHE_CHECK( [for in6addr_any], [isc_cv_have_in6addr_any], [AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> $isc_netinetin6_hack $isc_netinet6in6_hack ]], [[ ]] )], [isc_cv_have_in6addr_any=yes], [isc_cv_have_in6addr_any=no] )] ) case "$isc_cv_have_in6addr_any" in no) AC_DEFINE([ISC_PLATFORM_NEEDIN6ADDRANY], [1], [missing in6addr_any?]) esac [2] gcc_dumpspecs.txt 0000644 0000000 0003717 00000011163 11544200132 012244 0 ustar root Using built-in specs. Target: arm-unknown-linux-uclibc Configured with: /mnt/HD_a2/home/bob/funplug/work/gcc-4.1/gcc-4_1-branch/configure --enable-languages=c,c++ --enable-__cxa_atexit --with-local-prefix=/ffp --disable-multilib --disable-libssp --disable-libgomp --disable-libmudflap --disable-tls --with-float=soft --disable-bootstrap Thread model: posix gcc version 4.1.3 20080414 (prerelease) *asm: %{mbig-endian:-EB} %{mlittle-endian:-EL} %{mcpu=*:-mcpu=%*} %{march=*:-march=%*} %{mapcs-*:-mapcs-%*} %(subtarget_asm_float_spec) %{mthumb-interwork:-mthumb-interwork} %{msoft-float:-mfloat-abi=soft} %{mhard-float:-mfloat-abi=hard} %{mfloat-abi=*} %{mfpu=*} %(subtarget_extra_asm_spec) *asm_debug: %{gstabs*:--gstabs}%{!gstabs*:%{g*:--gdwarf2}} *asm_final: *asm_options: %a %Y %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O} *invoke_as: %{!S:-o %|.s | as %(asm_options) %m.s %A } *cpp: %(subtarget_cpp_spec) %{msoft-float:%{mhard-float: %e-msoft-float and -mhard_float may not be used together}} %{mbig-endian:%{mlittle-endian: %e-mbig-endian and -mlittle-endian may not be used together}} *cpp_options: %(cpp_unique_options) %1 %{m*} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w} %{f*} %{g*:%{!g0:%{!fno-working-directory:-fworking-directory}}} %{O*} %{undef} %{save-temps:-fpch-preprocess} *cpp_debug_options: %{d*} *cpp_unique_options: %{C|CC:%{!E:%eGCC does not support -C or -CC without -E}} %{!Q:-quiet} %{nostdinc*} %{C} %{CC} %{v} %{I*&F*} %{P} %I %{MD:-MD %{!o:%b.d}%{o*:%.d%*}} %{MMD:-MMD %{!o:%b.d}%{o*:%.d%*}} %{M} %{MM} %{MF*} %{MG} %{MP} %{MQ*} %{MT*} %{!E:%{!M:%{!MM:%{MD|MMD:%{o*:-MQ %*}}}}} %{remap} %{g3:-dD} %{H} %C %{D*&U*&A*} %{i*} %Z %i %{fmudflap:-D_MUDFLAP -include mf-runtime.h} %{fmudflapth:-D_MUDFLAP -D_MUDFLAPTH -include mf-runtime.h} %{E|M|MM:%W{o*}} *trad_capable_cpp: cc1 -E %{traditional|ftraditional|traditional-cpp:-traditional-cpp} *cc1: %{profile:-p} *cc1_options: %{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}} %1 %{!Q:-quiet} -dumpbase %B %{d*} %{m*} %{a*} %{c|S:%{o*:-auxbase-strip %*}%{!o*:-auxbase %b}}%{!c:%{!S:-auxbase %b}} %{g*} %{O*} %{W*&pedantic*} %{w} %{std*&ansi&trigraphs} %{v:-version} %{pg:-p} %{p} %{f*} %{undef} %{Qn:-fno-ident} %{--help:--help} %{--target-help:--target-help} %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %b.s}}} %{fsyntax-only:-o %j} %{-param*} %{fmudflap|fmudflapth:-fno-builtin -fno-merge-constants} %{coverage:-fprofile-arcs -ftest-coverage} *cc1plus: *link_gcc_c_sequence: %{static:--start-group} %G %L %{static:--end-group}%{!static:%G} *link_ssp: %{fstack-protector|fstack-protector-all:-lssp_nonshared -lssp} *endfile: %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s *link: %{!static:--eh-frame-hdr} %{h*} %{version:-v} %{b} %{static:-Bstatic} %{shared:-shared} %{symbolic:-Bsymbolic} %{rdynamic:-export-dynamic} %{!dynamic-linker:-dynamic-linker /ffp/lib/ld-uClibc.so.0} -X %{mbig-endian:-EB} %{mlittle-endian:-EL} -m armelf_linux -p *lib: %{pthread:-lpthread} %{shared:-lc} %{!shared:%{profile:-lc_p}%{!profile:-lc}} *mfwrap: %{static: %{fmudflap|fmudflapth: --wrap=malloc --wrap=free --wrap=calloc --wrap=realloc --wrap=mmap --wrap=munmap --wrap=alloca} %{fmudflapth: --wrap=pthread_create}} %{fmudflap|fmudflapth: --wrap=main} *mflib: %{fmudflap|fmudflapth: -export-dynamic} *libgcc: %{static|static-libgcc:-lgcc -lgcc_eh}%{!static:%{!static-libgcc:%{!shared-libgcc:-lgcc --as-needed -lgcc_s --no-as-needed}%{shared-libgcc:-lgcc_s%{!shared: -lgcc}}}} *startfile: %{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s} *switches_need_spaces: *cross_compile: 0 *version: 4.1.3 *multilib: . ; *multilib_defaults: marm mlittle-endian mhard-float mno-thumb-interwork *multilib_extra: *multilib_matches: *multilib_exclusions: *multilib_options: *linker: collect2 *link_libgcc: %D *md_exec_prefix: *md_startfile_prefix: *md_startfile_prefix_1: *startfile_prefix_spec: /ffp/lib/ *sysroot_spec: --sysroot=%R *sysroot_suffix_spec: *sysroot_hdrs_suffix_spec: *subtarget_cpp_spec: %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT} *subtarget_extra_asm_spec: *subtarget_asm_float_spec: %{mapcs-float:-mfloat} *link_command: %{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S: %(linker) %l %{pie:-pie} %X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r} %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}} %{static:} %{L*} %(mfwrap) %(link_libgcc) %o %(mflib) %{fprofile-arcs|fprofile-generate|coverage:-lgcov} %{!nostdlib:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}} %{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} }}}}}} _______________________________________________ Autoconf mailing list Autoconf@xxxxxxx http://lists.gnu.org/mailman/listinfo/autoconf