From yar@stylish.chem.msu.su  Wed May 28 10:09:13 2003
Return-Path: <yar@stylish.chem.msu.su>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 95B7A37B404
	for <FreeBSD-gnats-submit@freebsd.org>; 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 <FreeBSD-gnats-submit@freebsd.org>; 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 <FreeBSD-gnats-submit@freebsd.org>; 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 <yar@comp.chem.msu.su>
To: FreeBSD-gnats-submit@freebsd.org
Subject: Impossible to build kernel with COPTFLAGS=-O0 and without INET6
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         52764
>Category:       kern
>Synopsis:       Impossible to build kernel with COPTFLAGS=-O0 and without INET6
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    yar
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed May 28 10:10:11 PDT 2003
>Closed-Date:    Thu Jun 14 13:29:13 GMT 2007
>Last-Modified:  Thu Jun 14 13:29:13 GMT 2007
>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:

From: "Artem 'Zazoobr' Ignatjev" <timon@memphis.mephi.ru>
To: freebsd-gnats-submit@freebsd.org
Cc:  
Subject: Re: kern/52764: Impossible to build kernel with COPTFLAGS=-O0 and
	without INET6
Date: 09 Jun 2003 22:57:45 +0400

 --=-HpuLBCbRsckjuxTS3YTY
 Content-Type: text/plain
 Content-Transfer-Encoding: 7bit
 
 Yar Tikhiy wrote:
 > >Synopsis:       Impossible to build kernel with COPTFLAGS=-O0 and without INET6
 > >Description:
 > 	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.  
 Yesterday I've cvsupped to RELENG_5, and I'm confirming the bug is still
 there.
 Below are my kernel config and make.conf
 
 
 --=-HpuLBCbRsckjuxTS3YTY
 Content-Disposition: inline; filename=TIMON
 Content-Type: text/plain; name=TIMON; charset=KOI8-R
 Content-Transfer-Encoding: 7bit
 
 #
 # GENERIC -- Generic kernel configuration file for FreeBSD/i386
 #
 # For more information on this file, please read the handbook section on
 # Kernel Configuration Files:
 #
 #    http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html
 #
 # The handbook is also available locally in /usr/share/doc/handbook
 # if you've installed the doc distribution, otherwise always see the
 # FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the
 # latest information.
 #
 # An exhaustive list of options and more detailed explanations of the
 # device lines is also present in the ../../conf/NOTES and NOTES files. 
 # If you are in doubt as to the purpose or necessity of a line, check first 
 # in NOTES.
 #
 # $FreeBSD: src/sys/i386/conf/GENERIC,v 1.369 2002/10/19 16:54:07 rwatson Exp $
 
 machine		i386
 cpu		I586_CPU
 cpu		I686_CPU
 ident		TIMON
 maxusers	0
 
 #To statically compile in device wiring instead of /boot/device.hints
 #hints		"GENERIC.hints"		#Default places to look for devices.
 
 #makeoptions	DEBUG=-g		#Build kernel with gdb(1) debug symbols
 
 options 	INET			#InterNETworking
 options 	FFS			#Berkeley Fast Filesystem
 options 	SOFTUPDATES		#Enable FFS soft updates support
 options 	UFS_ACL			#Support for access control lists
 options 	UFS_DIRHASH		#Improve performance on big directories
 options 	NFSCLIENT		#Network Filesystem Client
 options 	NFSSERVER		#Network Filesystem Server
 options 	MSDOSFS			#MSDOS Filesystem
 options 	CD9660			#ISO 9660 Filesystem
 options 	PROCFS			#Process filesystem (requires PSEUDOFS)
 options 	PSEUDOFS		#Pseudo-filesystem framework
 options 	COMPAT_43		#Compatible with BSD 4.3 [KEEP THIS!]
 options 	COMPAT_FREEBSD4		#Compatible with FreeBSD4
 options 	SCSI_DELAY=15000	#Delay (in ms) before probing SCSI
 options 	KTRACE			#ktrace(1) support
 options 	SYSVSHM			#SYSV-style shared memory
 options 	SYSVMSG			#SYSV-style message queues
 options 	SYSVSEM			#SYSV-style semaphores
 options 	_KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
 options 	KBD_INSTALL_CDEV	# install a CDEV entry in /dev
 #options		SCHED_ULE
 options		SCHED_4BSD
 
 # Debugging for use in -current
 #options 	DDB			#Enable the kernel debugger
 #options 	INVARIANTS		#Enable calls of extra sanity checking
 #options 	INVARIANT_SUPPORT	#Extra sanity checks of internal structures, required by INVARIANTS
 #options 	WITNESS			#Enable checks to detect deadlocks and cycles
 #options 	WITNESS_SKIPSPIN	#Don't run witness on spinlocks for speed
 
 
 device		isa
 device		pci
 
 # Floppy drives
 device		fdc
 
 # ATA and ATAPI devices
 device		ata
 device		atadisk			# ATA disk drives
 device		atapicd			# ATAPI CDROM drives
 options 	ATA_STATIC_ID		#Static device numbering
 
 # SCSI peripherals
 device		scbus		# SCSI bus (required)
 device		da		# Direct Access (disks)
 device		pass		# Passthrough device (direct SCSI access)
 #device		ses		# SCSI Environmental Services (and SAF-TE)
 
 device		atkbdc		# AT keyboard controller
 device		atkbd		# AT keyboard
 device		psm		# PS/2 mouse
 
 device		vga		# VGA video card driver
 
 device		splash		# Splash screen and screen saver support
 
 # syscons is the default console driver, resembling an SCO console
 device		sc
 
 #device		agp		# support several AGP chipsets
 
 # Floating point support - do not disable.
 device		npx
 
 # Power management support (see NOTES for more options)
 device		apm
 # Add suspend/resume support for the i8254.
 device		pmtimer
 
 # Serial (COM) ports
 device		sio		# 8250, 16[45]50 based serial ports
 
 # Parallel port
 #device		ppc
 #device		ppbus		# Parallel port bus (required)
 #device		lpt		# Printer
 #device		plip		# TCP/IP over parallel
 #device		ppi		# Parallel port interface device
 #device		vpo		# Requires scbus and da
 
 
 device		miibus		# MII bus support
 device		fxp		# Intel EtherExpress PRO/100B (82557, 82558)
 device		rl		# RealTek 8129/8139
 
 # Pseudo devices - the number indicates how many units to allocate.
 device		random		# Entropy device
 device		loop		# Network loopback
 device		ether		# Ethernet support
 device		tun		# Packet tunnel.
 device		pty		# Pseudo-ttys (telnet etc)
 device		md		# Memory "disks"
 device		gif		# IPv6 and IPv4 tunneling
 
 # The `bpf' device enables the Berkeley Packet Filter.
 # Be aware of the administrative consequences of enabling this!
 device		bpf		# Berkeley packet filter
 
 # USB support
 device		uhci		# UHCI PCI->USB interface
 device		ohci		# OHCI PCI->USB interface
 device		usb		# USB Bus (required)
 device		udbp		# USB Double Bulk Pipe devices
 device		ugen		# Generic
 #device		uhid		# "Human Interface Devices"
 #device		ukbd		# Keyboard
 #device		ulpt		# Printer
 device		umass		# Disks/Mass storage - Requires scbus and da
 device		ums		# Mouse
 device		pcm
 device		midi
 device		seq
 options NETGRAPH
 options NETSMB
 options NETSMBCRYPTO
 options LIBMCHAIN
 options LIBICONV
 options SMBFS
 options FB_INSTALL_CDEV
 options	NTFS
 options EXT2FS
 options SC_PIXEL_MODE
 options SC_MOUSE_CHAR="0x03"
 options VESA
 options UFS_EXTATTR
 options	UFS_EXTATTR_AUTOSTART
 
 device	smbus
 device	iicbb
 device	iicbus
 device	bktr
 options 	NETGRAPH
 options 	NETGRAPH_BPF
 options 	NETGRAPH_ECHO
 options 	NETGRAPH_ETHER
 options 	NETGRAPH_GIF
 options 	NETGRAPH_GIF_DEMUX
 options 	NETGRAPH_HOLE
 options 	NETGRAPH_IFACE
 options 	NETGRAPH_IP_INPUT
 options 	NETGRAPH_KSOCKET
 options 	NETGRAPH_L2TP
 options 	NETGRAPH_LMI
 options 	NETGRAPH_MPPC_ENCRYPTION
 options 	NETGRAPH_ONE2MANY
 options 	NETGRAPH_PPP
 options 	NETGRAPH_PPPOE
 options 	NETGRAPH_PPTPGRE
 options 	NETGRAPH_RFC1490
 options 	NETGRAPH_SOCKET
 options 	NETGRAPH_SPLIT
 options 	NETGRAPH_TEE
 options 	GEOM_BSD
 options 	GEOM_MBR
 #options 	GEOM_SUNLABEL
 #options 	GEOM_SUNLABEL_X86
 device		ichsmb
 device		acpi
 device		ic
 device		iic
 device		iicsmb
 
 --=-HpuLBCbRsckjuxTS3YTY
 Content-Disposition: inline; filename=make.conf
 Content-Type: text/plain; name=make.conf; charset=KOI8-R
 Content-Transfer-Encoding: 7bit
 
 CPUTYPE=i686
 MASTER_SITES_OVERRIDE=ftp://ftp.gamma.ru/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}/ ftp://ftp.chg.ru/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}/
 FETCH_CMD="/usr/local/bin/portfetch"
 NO_FORTRAN=	true
 NO_I4B= true
 NO_IPFILTER= true
 NO_PERL= true
 NOUUCP=	true
 MAKE_KERBEROS4= false
 MAKE_KERBEROS5= false
 #NO_CPU_CFLAGS=true
 #NO_CPU_COPTFLAGS=true
 COPTFLAGS=
 NO_KERBEROS5=true
 #NO_SHAREDOCS=	true	# do not build the 4.4BSD legacy docs
 # -- use.perl generated deltas -- #
 # Created: Mon May 19 21:12:51 2003
 # Setting to use base perl from ports:
 PERL_VER=5.6.1
 PERL_VERSION=5.6.1
 PERL_ARCH=mach
 NOPERL=yo
 NO_PERL=yo
 NO_PERL_WRAPPER=yo
 KERNCONF=TIMON
 
 --=-HpuLBCbRsckjuxTS3YTY--
 
State-Changed-From-To: open->feedback 
State-Changed-By: gavin 
State-Changed-When: Wed Jun 13 13:03:39 UTC 2007 
State-Changed-Why:  

To submitter: I can't recreate this on RELENG_6.  Is this still a 
problem for you? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=52764 
State-Changed-From-To: feedback->closed 
State-Changed-By: yar 
State-Changed-When: Thu Jun 14 13:25:12 UTC 2007 
State-Changed-Why:  
I can't reproduce this problem either.  Changes by andre@ 
to tcp_input.c seem to have resolved it as a side effect. 
Thank you, Andre! 


Responsible-Changed-From-To: freebsd-bugs->yar 
Responsible-Changed-By: yar 
Responsible-Changed-When: Thu Jun 14 13:25:12 UTC 2007 
Responsible-Changed-Why:  
I closed this PR. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=52764 
>Unformatted:
