From owner-freebsd-bugs@FreeBSD.ORG Wed May 28 10:10:13 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C1D6E37B401 for ; Wed, 28 May 2003 10:10:13 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id BBB4B43FA3 for ; Wed, 28 May 2003 10:10:12 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h4SHACUp005019 for ; Wed, 28 May 2003 10:10:12 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h4SHACsq005018; Wed, 28 May 2003 10:10:12 -0700 (PDT) Resent-Date: Wed, 28 May 2003 10:10:12 -0700 (PDT) Resent-Message-Id: <200305281710.h4SHACsq005018@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Yar Tikhiy Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 95B7A37B404 for ; Wed, 28 May 2003 10:09:13 -0700 (PDT) Received: from stylish.chem.msu.su (stylish.chem.msu.su [158.250.32.111]) by mx1.FreeBSD.org (Postfix) with ESMTP id D769E43F93 for ; Wed, 28 May 2003 10:09:11 -0700 (PDT) (envelope-from yar@stylish.chem.msu.su) Received: from stylish.chem.msu.su (localhost [127.0.0.1]) by stylish.chem.msu.su (8.12.9/8.12.9) with ESMTP id h4SH8FW4006112 for ; Wed, 28 May 2003 21:08:15 +0400 (MSD) (envelope-from yar@stylish.chem.msu.su) Received: (from yar@localhost) by stylish.chem.msu.su (8.12.9/8.12.9/Submit) id h4SH8DFj006111; Wed, 28 May 2003 21:08:13 +0400 (MSD) Message-Id: <200305281708.h4SH8DFj006111@stylish.chem.msu.su> Date: Wed, 28 May 2003 21:08:13 +0400 (MSD) From: Yar Tikhiy To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: kern/52764: Impossible to build kernel with COPTFLAGS=-O0 and without INET6 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 May 2003 17:10:14 -0000 >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@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: