From owner-freebsd-arch@FreeBSD.ORG Mon Aug 30 16:05:26 2010 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 39D5C1065694 for ; Mon, 30 Aug 2010 16:05:26 +0000 (UTC) (envelope-from pluknet@gmail.com) Received: from mail-qw0-f54.google.com (mail-qw0-f54.google.com [209.85.216.54]) by mx1.freebsd.org (Postfix) with ESMTP id E0A1C8FC16 for ; Mon, 30 Aug 2010 16:05:23 +0000 (UTC) Received: by qwg5 with SMTP id 5so112452qwg.13 for ; Mon, 30 Aug 2010 09:05:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=wYi4nea8a/LjtaeGmecQjLYf6RnbyZVJdKEtpm+0yG8=; b=Ewf3C8f7nvnaNJXwP4cx1FAQcodVolSEDz7cxJlU5rOSXGGDHkAqgSNc7D/XIeTTFE MtEBgg+LSq+flATnPk6x7kCnGEqmBb4Zaqp+Gcofz6m0pENphbd9YmKiA8MzTIYPycUD 0vTRqjlA5PvIpp5o8Z2bgw2MzCgH0wBm7OIrQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=IO/L4xO/XmTBKUN+B/0r8Ib2ZF2lw+7AkbaUXY+k+KBRl8KBnBvg2PyCrGcQdWcEY7 Kj3awYG5ozT5DbfRpMsU7jzsYmAhIz8cY4Qyya5V0jW/7yo/mZnCQZV5p/SjlvJPLSyu Jjw3+WjsxNEUTMOofQ03fqPDHuJJoOGDLPOHw= MIME-Version: 1.0 Received: by 10.224.79.170 with SMTP id p42mr3061278qak.81.1283182801993; Mon, 30 Aug 2010 08:40:01 -0700 (PDT) Received: by 10.229.26.81 with HTTP; Mon, 30 Aug 2010 08:40:01 -0700 (PDT) In-Reply-To: <201008301731.19074.tijl@coosemans.org> References: <201007291718.12687.tijl@coosemans.org> <201008301731.19074.tijl@coosemans.org> Date: Mon, 30 Aug 2010 19:40:01 +0400 Message-ID: From: pluknet To: Tijl Coosemans Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-arch@freebsd.org Subject: Re: Support for cc -m32 X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Aug 2010 16:05:26 -0000 On 30 August 2010 19:31, Tijl Coosemans wrote: > On Thursday 29 July 2010 17:18:03 Tijl Coosemans wrote: >> I've put the initial version of some patches online to support cross >> compilation of 32 bit binaries on amd64. It's modelled after how NetBSD >> does this. >> >> With these patches something like "cc -m32 -o test test.c -pthread -lm" >> generates a program that runs on FreeBSD/i386. >> >> http://people.freebsd.org/~tijl/cc-m32-1.diff >> http://people.freebsd.org/~tijl/cc-m32-2.diff >> http://people.freebsd.org/~tijl/cc-m32-3.diff >> >> *cc-m32-1.diff* : Let ld and cc find 32 bit libraries. >> >> *cc-m32-2.diff* : Install i386 headers on amd64. >> >> With this patch headers for a particular $arch are always installed >> under /usr/include/$arch and /usr/include/machine becomes a symlink. >> >> A question I have here is how best to clean up the old machine >> directory. The patch currently uses 'rm -rf'. >> >> Another problem I encountered was that during the build of >> usr.bin/kdump all headers are searched for definitions of ioctl >> requests and a C source code file is generated that includes all those >> headers. This fails when both i386 and amd64 headers are installed >> because they can't both be included at the same time. For now the patch >> simply blacklists /usr/include/i386, but actually all $arch should be >> excluded. The ioctl requests can still be found through the machine >> symlink. If someone has a better idea... >> >> *cc-m32-3.diff* : Modify amd64 headers to include i386 headers when >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 __i386__ is defined. >> >> This patch modifies the amd64 headers to follow this format: >> >> =A0 #ifndef _AMD64_HEADER_H >> =A0 #define _AMD64_HEADER_H >> >> =A0 #ifdef __i386__ >> =A0 #include >> =A0 #else >> >> =A0 ... >> >> =A0 #endif /* __i386__ */ >> =A0 #endif /* !_AMD64_HEADER_H */ >> >> This way including works for -m32. There are a few >> i386 headers which don't exist for amd64: >> >> apm_segments.h >> bootinfo.h >> cserial.h >> elan_mmcr.h >> if_wl_wavelan.h >> ioctl_bt848.h >> ioctl_meteor.h >> npx.h >> pcaudioio.h >> pcb_ext.h >> perfmon.h >> privatespace.h >> smapi.h >> speaker.h >> vm86.h >> xbox.h >> >> Theoretically a dummy amd64 header should be created for each of them >> that just includes the i386 header. The patch does this for npx.h. The >> other headers seem to be really i386 specific or even outdated. If it >> were ever necessary to cross-compile code that uses them, it would be >> easy to modify that code to directly include . >> >> >> Feel free to test the patches and to comment on any part of them. > > I'd like to move forward with this now. I've rebased the patches above > against today's CURRENT. If there are no further objections I'd like to > commit them a few days from now, let's say Saturday. > Hi. The trouble I faced while was playing with my -m32 work was a cross buildworld error on amd64 with TARGET set to i386. Have you checked there is no such an issue? --=20 wbr, pluknet