From owner-freebsd-ppc@FreeBSD.ORG Wed Nov 20 17:09:06 2013 Return-Path: Delivered-To: powerpc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7D82E2A2; Wed, 20 Nov 2013 17:09:06 +0000 (UTC) Received: from st11p02mm-asmtp002.mac.com (st11p02mm-asmtp002.mac.com [17.172.220.237]) by mx1.freebsd.org (Postfix) with ESMTP id 583B829EF; Wed, 20 Nov 2013 17:09:06 +0000 (UTC) Received: from marcelm-sslvpn-nc.jnpr.net (unknown [66.129.239.13]) by st11p02mm-asmtp002.mac.com (Oracle Communications Messaging Server 7u4-27.08(7.0.4.27.7) 64bit (built Aug 22 2013)) with ESMTPSA id <0MWK00DCGNMIWN30@st11p02mm-asmtp002.mac.com>; Wed, 20 Nov 2013 17:08:44 +0000 (GMT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.10.8794,1.0.14,0.0.0000 definitions=2013-11-20_06:2013-11-20,2013-11-20,1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=1 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1308280000 definitions=main-1311200114 From: Marcel Moolenaar Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit Subject: RFC: compiler options to control what gets built and how Date: Wed, 20 Nov 2013 09:08:36 -0800 Message-id: <3D481595-1F61-4244-838F-5C13ABCB830D@mac.com> To: powerpc@freebsd.org MIME-version: 1.0 (Mac OS X Mail 7.0 \(1822\)) X-Mailer: Apple Mail (2.1822) Cc: Warner Losh X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Nov 2013 17:09:06 -0000 All, Background: Juniper is refocussing efforts towards PowerPC again. Primarily what this means for Juniper is that a select set of PowerPC- based Juniper products will migrate to the latest FreeBSD as the base OS underneath Junos. What this means for FreeBSD is that Juniper will be contributing a bunch of goodies :-) Problem at hand: Juniper builds kernel modules without any reference to a kernel configuration. This works great for architectures like x86, but for PowerPC, MIPS and ARM this isn't always that easy. The problem as far as I can see it is that we use kernel configurations to indicate for which CPU we're compiling. Let's call this the build setting for arguments sake. Complication: Many embedded CPU architectures have specific compiler behaviour you may have to tell the compiler for what CPU or ABI you're compiling. Let's call this the compiler setting. Having both a build setting and a compiler setting is, well, complicating. What I'd like to change is that we use compiler settings more than build settings, for where it's applicable of course and as a first stab, do it for PowerPC only. If it's successful then it should be fairly easy to apply to ARM and MIPS. Examples: 1. A compiler that generates 64-bit code can be assumed to compiler a 64-bit PowerPC kernel. There is no need to have a build option (like machine powerpc powerpc). Testing for __LP64__ or something like that will do just fine. 2. The difference between AIM and Book-E is (can) be handled by checking the appropriate compiler defines (__embedded__) and have us do the right thing in the kernel for modules and for user space. Particular use case: 1. Cross-tools aren't necessarily helped by the magical and automatic selection of appropriate definitions. This is not a problem that is in search of a solution though. Our ELF headers handle this adequately and the same scheme can work for things like trap frames and the likes. 2. The remote kernel debugger stub needs different register definitions for Book-E and AIM. These register definitions are controller by the compiler options used, yet our stub uses build settings. This has previously resulted in an inability to debug the kernel remotely due to a mismatch. 3. The buildbot I setup at Juniper builds a LINT kernel for each CPU architecture. For PowerPC this adds an avoidable complication that we actually need to use a different LINT kernel configuration for no other reach than that we need "machine powerpc powerpc64" rather than "machine powerpc powerpc" A distinction that is almost entirely unnecessary. What needs to change to make this work: 1. Since config(8) is the tool we use to pick up source files, and we use the abovementioned build options to select the right source files, we need a way to inject compiler defines into the process of configuring the kernel build. 2. We need well-defined built-in compiler defines for building AIM vs. Book-E and 32-bit vs 64-bit. What do people think of using the compiler to drive more of what and how we built so that the right thing happens with fewer manual setup? -- Marcel Moolenaar xcllnt@mac.com