kern/52764: Impossible to build kernel with COPTFLAGS=-O0 and
without INET6
Yar Tikhiy
yar at comp.chem.msu.su
Wed May 28 10:10:14 PDT 2003
>Number: 52764
>Category: kern
>Synopsis: Impossible to build kernel with COPTFLAGS=-O0 and without INET6
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Wed May 28 10:10:11 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator: Yar Tikhiy
>Release: FreeBSD 5.1-BETA i386
>Organization:
Moscow State University
>Environment:
System: FreeBSD stylish.chem.msu.su 5.1-BETA FreeBSD 5.1-BETA #2: Tue May 27 01:50:01 MSD 2003 yar at stylish.chem.msu.su:/usr/obj/usr/src/sys/STYLISH i386
>Description:
Sometimes a kernel developer needs to build a kernel with
no optimizations at all, e.g., when he wants to see automatic
variables and function arguments in stack frames from a
debugger. To do so with gcc(1), the developer must compile
kernel files using a "-O0" option. (gcc(1) will optimize
on-stack variables in a way preventing debugging them even
if given no optimization options.)
It appears that the FreeBSD kernel will have unresolved
references to INET6 functions if its files are compiled
with "-O0", but without INET6.
The root of the problem is in tcp_input.c. There are places
in that file where a C if() operator is used as though it
were #if. That is, the condition in the operator will be
a compile-time constant depending on whether INET6 is
defined. In all optimization cases but "-O0", gcc(1) will
just ignore the code since it appears inside dead "if (0) {}"
blocks if INET6 is undefined. But with "-O0", gcc(1) will
include the code into the object file; and the linker will
consequently fail to link the kernel.
>How-To-Repeat:
Add "makeoptions COPTFLAGS=-O0" to a kernel configuration file
and make sure there is no "options INET6" in it. Try to build
such a kernel. Observe the following linker diagnostics:
linking kernel.debug
tcp_input.o: In function `tcp_input':
../../../netinet/tcp_input.c:400: undefined reference to `in6_cksum'
../../../netinet/tcp_input.c:480: undefined reference to `ip6stat'
../../../netinet/tcp_input.c:480: undefined reference to `ip6stat'
../../../netinet/tcp_input.c:480: undefined reference to `ip6stat'
../../../netinet/tcp_input.c:480: undefined reference to `ip6stat'
../../../netinet/tcp_input.c:480: undefined reference to `ip6stat'
tcp_input.o:../../../netinet/tcp_input.c:480: more undefined references to `ip6stat' follow
tcp_input.o: In function `tcp_input':
../../../netinet/tcp_input.c:480: undefined reference to `in6_ifstatmax'
../../../netinet/tcp_input.c:480: undefined reference to `in6_ifstat'
../../../netinet/tcp_input.c:480: undefined reference to `in6_ifstat'
../../../netinet/tcp_input.c:480: undefined reference to `in6_ifstat'
../../../netinet/tcp_input.c:559: undefined reference to `in6_pcblookup_hash'
../../../netinet/tcp_input.c:611: undefined reference to `ip6_sprintf'
../../../netinet/tcp_input.c:612: undefined reference to `ip6_sprintf'
tcp_input.o: In function `tcp_mss':
../../../netinet/tcp_input.c:2618: undefined reference to `tcp_rtlookup6'
../../../netinet/tcp_input.c:2622: undefined reference to `tcp_v6mssdflt'
../../../netinet/tcp_input.c:2641: undefined reference to `tcp_v6mssdflt'
../../../netinet/tcp_input.c:2688: undefined reference to `nd_ifinfo'
../../../netinet/tcp_input.c:2690: undefined reference to `in6_localaddr'
../../../netinet/tcp_input.c:2691: undefined reference to `tcp_v6mssdflt'
../../../netinet/tcp_input.c:2768: undefined reference to `in6_localaddr'
tcp_input.o: In function `tcp_mssopt':
../../../netinet/tcp_input.c:2805: undefined reference to `tcp_rtlookup6'
../../../netinet/tcp_input.c:2809: undefined reference to `tcp_v6mssdflt'
*** Error code 1
Stop in /usr/src/sys/i386/compile/TESTO0.
>Fix:
Left up to the developer who introduced such a bug.
As a workaround, "options INET6" needs to be included
in a kernel configuration file if the kernel will be
built with "-O0" for debugging purposes.
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list