[ntp:bugs] [Bug 1862] Compilation error, ntp_io.c:1678: undefined reference to `in6addr_any'
bugzilla-daemon at ntp.org
bugzilla-daemon at ntp.org
Tue Mar 29 07:03:20 UTC 2011
http://bugs.ntp.org/show_bug.cgi?id=1862
--- Comment #13 from Stefan olsson <misca at hotmail.com> 2011-03-29 07:03:20 UTC ---
Hi
> Next step (and I'm working on another bug right now...) is to find
> the minimum changes to the test needed to make it not optimize away the reference.
One idea could be to force ./configure to use avoid optimization flags for it's
internal tests, such as the ac_fn_c_try_link and ac_fn_c_try_run, like this
my_ac_link=$(echo $ac_link | sed 's:-O[0-9]*::g')
and then use my_ac_link instead of ac_link when compiling/linking the test
code.
In this way the user can use CFLAGS, LDFLAGS as usual but there will be a
slight difference in how ./configure "works" and how make "works".
Also, I tried a number of different use cases to find a small one and here is
the result
------- Use cases that the compiler will "optimize" away
The following constructions will be "optimized away"
#1
struct in6_addr in6;
in6 = in6addr_any;
#2
struct in6_addr in6;
struct in6_addr in61;
in6 = in6addr_any;
in61 = in6addr_any;
#3
struct in6_addr in6;
struct in6_addr in61;
in6 = in6addr_any;
in61 = in6;
#4
This one have information about the internal structure of struct in6_addr
struct in6_addr in6;
in6 = in6addr_any;
if (in6.s6_addr[0] == 0);
#5
This one have information about the internal structure of struct in6_addr
struct in6_addr in6;
in6 = in6addr_any;
if (in6.s6_addr[0] == 0)
return 0;
#6
This one have information about the internal structure of struct in6_addr
struct in6_addr in6;
in6 = in6addr_any;
if (in6.s6_addr[0] == 0)
in6.s6_addr[0] = 1;
------- Use cases that the compiler will NOT "optimize" away
The following constructions will NOT be "optimized away"
#7
This one is trapped
This one have information about the internal structure of struct in6_addr
But it will return '1', which ./configure will identify as an error and this is
not correct in the case that the test program actually works
struct in6_addr in6;
in6 = in6addr_any;
if (in6.s6_addr[0] == 0)
return 1;
#8
This one is trapped
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
int
main ()
{
struct in6_addr in6;
in6 = in6addr_any;
memcpy(&in6, &in6addr_any, sizeof(in6addr_any));
;
return 0;
}
#9
This one is trapped
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
int
main ()
{
struct in6_addr in6;
in6 = in6addr_any;
if (memcmp(&in6, &in6addr_any, sizeof(in6addr_any)) == 0)
return(1);
;
return 0;
}
> I'm a little frightened, though,
> because this sort of simple test is extremely common for configure,
> including for tests I can't so easily modify as they're part of autoconf.
I feel uncomfortable too, I have just installed some 50 different software's or
so on the system.
> If I were you'd I'd be tempted to stick with -O1 or whatever works with the tests as written.
I will for now on have a modified in6addr_any test in the ./configure
> Thanks for tracking this down.
No problem, glad to help and it is fun to help things to become more generic
in order to spread it more.
Live well
/Stefan
--
Configure bugmail: http://bugs.ntp.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the bugs
mailing list