From owner-freebsd-ports@FreeBSD.ORG Fri May 10 17:15:20 2013 Return-Path: Delivered-To: ports@FreeBSD.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 1D2E49EE; Fri, 10 May 2013 17:15:20 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (tensor.andric.com [IPv6:2001:7b8:3a7:1:2d0:b7ff:fea0:8c26]) by mx1.freebsd.org (Postfix) with ESMTP id DC0F8AC1; Fri, 10 May 2013 17:15:19 +0000 (UTC) Received: from [IPv6:2001:7b8:3a7::453a:d557:dd31:2750] (unknown [IPv6:2001:7b8:3a7:0:453a:d557:dd31:2750]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 75A275C44; Fri, 10 May 2013 19:15:16 +0200 (CEST) Content-Type: text/plain; charset=iso-8859-1 Mime-Version: 1.0 (Mac OS X Mail 6.3 \(1503\)) Subject: Re: Why can't lang/gcc4X compilers build kernel modules? From: Dimitry Andric In-Reply-To: <518D2773.40504@aldan.algebra.com> Date: Fri, 10 May 2013 19:15:03 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <89AD564E-A6BA-4EEC-B3D0-04C18AF5F1D8@FreeBSD.org> References: <518D2773.40504@aldan.algebra.com> To: Mikhail T. X-Mailer: Apple Mail (2.1503) Cc: ports@FreeBSD.org, gerald@FreeBSD.org X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 May 2013 17:15:20 -0000 On May 10, 2013, at 18:59, Mikhail T. wrote: > It seems, none of the gcc-ports have the FreeBSD-extensions, that are = worked into the base cc. This is fine for regular ports, but the = consumers of bsd.kmod.mk (such as print/acroreadwrapper or = multimedia/cuse4bsd-kmod) all choke. For example: > gcc46 -O2 -pipe -march=3Dprescott -fno-strict-aliasing -Werror = -D_KERNEL -DKLD_MODULE -nostdinc -I. -I@ -I@/contrib/altq = -finline-limit=3D8000 --param inline-unit-growth=3D100 --param = large-function-growth=3D1000 -fno-common -mno-align-long-strings = -mpreferred-stack-boundary=3D2 -mno-mmx -mno-3dnow -mno-sse -mno-sse2 = -mno-sse3 -ffreestanding -std=3Diso9899:1999 -Wall -Wredundant-decls = -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes = -Wpointer-arith -Winline -Wcast-qual -Wundef -Wno-pointer-sign = -fformat-extensions -c linux_adobe.c > cc1: error: unrecognized command line option '-mno-align-long-strings' > cc1: error: unrecognized command line option '-fformat-extensions' > *** Error code 1 > Would it be too much work to extend the port-installed compilers the = same way gcc-4.2.1 in the base is extended? May be not for gcc4[89], = which are complete rewrites, but for 4.[4-7]? If not too difficult, = should it be done? In my opinion, this is a fruitless direction. Neither upstream gcc, nor upstream clang will ever accept an option called "-fformat-extensions", which enables FreeBSD kernel-specific format extensions (which might also change in the future, so you do not really gain anything). I think the best solution is to get rid of all non-standard printf format specifiers in the kernel, and use custom formatters for our specialized needs. For replacing the %b specifier, for example, we could use NetBSD's snprintb() (see ). Getting rid of non-standard extensions in general is really the way to go. This would enable compiling with any standards-compliant compiler, even commercial ones. > Once implemented, it would become easier to build the entire kernel = using a newer compiler. And dim@ (CC-ed) has already demonstrated = non-trivial speed-ups obtained by building the kernel with gcc-4.7 over = gcc-4.2: > = http://lists.freebsd.org/pipermail/freebsd-current/2012-November/037842.ht= ml > http://www.andric.com/freebsd/perftest/perftest-kernel-2012-09-25b.txt Of course recent versions of gcc will be more feature-complete, result in faster code, etc. But please be reminded of the GPLv3 licensing issues with them. The license is not acceptable for everybody. (And yes, I know the license does not apply to the generated code, that is not the point. :) -Dimitry