From owner-freebsd-toolchain@FreeBSD.ORG Sun Aug 21 00:46:35 2011 Return-Path: Delivered-To: freebsd-toolchain@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CC3EF1065670; Sun, 21 Aug 2011 00:46:35 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (cl-327.ede-01.nl.sixxs.net [IPv6:2001:7b8:2ff:146::2]) by mx1.freebsd.org (Postfix) with ESMTP id 88A418FC08; Sun, 21 Aug 2011 00:46:35 +0000 (UTC) Received: from [IPv6:2001:7b8:3a7:0:55e9:5579:6ddd:60ab] (unknown [IPv6:2001:7b8:3a7:0:55e9:5579:6ddd:60ab]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id C8A025C37; Sun, 21 Aug 2011 02:46:34 +0200 (CEST) Message-ID: <4E50551D.9020104@FreeBSD.org> Date: Sun, 21 Aug 2011 02:45:17 +0200 From: Dimitry Andric Organization: The FreeBSD Project User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20110812 Thunderbird/6.0 MIME-Version: 1.0 To: Alexander Best References: <20110818050142.GA96873@freebsd.org> <4E4CB59B.3000005@FreeBSD.org> <20110818173508.GA92360@freebsd.org> <4E4D6E01.40905@FreeBSD.org> <20110819080105.GA92201@freebsd.org> In-Reply-To: <20110819080105.GA92201@freebsd.org> Content-Type: multipart/mixed; boundary="------------020507060807000600080109" Cc: freebsd-toolchain@freebsd.org Subject: Re: Relocatable linking with relocations from format elf64-x86-64-freebsd (crt1_s.o) to format elf32-i386-freebsd (gcrt1.o) is not supported X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Aug 2011 00:46:35 -0000 This is a multi-part message in MIME format. --------------020507060807000600080109 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 2011-08-19 10:01, Alexander Best wrote: > On Thu Aug 18 11, Dimitry Andric wrote: ... >> Please use the following fragment instead, which is recommended on >> : > thanks. that fixed the issue. seeing forward to simply setting CC/CXX/CPP to > clang or gcc directly and also to using "/", so one can use absolute paths. Please try the attached patch, which makes it possible to set CC and CXX in make.conf, while allowing the build32 stage to still override them. Explanation: 1) The build32 stage sets environment variables CC, CXX, AS and LD for its sub-make, to add 32-bit specific flags (-m32 and such). 2) The sub-make reads sys.mk, encounters CC?= and CXX?= assignments, so does not alter them. 3) After some other stuff, sys.mk reads /etc/make.conf. When you have "CC=xxx" and "CXX=yyy" statements in there, they will *override* the build32-supplied CC/CXX values, nullifying the 32-bit specific flags. 4) Thus all objects get built as 64-bit anyway, and since LD is usually not set in make.conf, it still has the 32-bit flags! 5) Now, whenever something is linked, you will get a "ld: Relocatable linking with relocations from format elf64-x86-64-freebsd (foo.o) to format elf32-i386-freebsd (bar.o) is not supported" error. The patch fixes this by adding "-ECC -ECXX -EAS -ELD" to the build32 sub-make invocation, which forces those environment variables to always override any assignment in makefiles. It makes it possible to simply do: CC=clang CXX=clang++ in your make.conf, or specify a path, even: CC=/usr/local/bin/gcc46 CXX=/usr/local/bin/g++46 Note this was already possible on i386, but not yet on amd64. Also, strange things might happen if you set CC but not CXX, or vice versa... --------------020507060807000600080109 Content-Type: text/plain; name="build32-override-cc-cxx-as-ld-1.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="build32-override-cc-cxx-as-ld-1.diff" Index: Makefile.inc1 =================================================================== --- Makefile.inc1 (revision 224934) +++ Makefile.inc1 (working copy) @@ -313,7 +313,8 @@ LIB32WMAKE= ${LIB32WMAKEENV} ${MAKE} -DNO_CPU_CFLAGS -DCOMPAT_32BIT \ -DWITHOUT_BIND -DWITHOUT_MAN -DWITHOUT_INFO \ - -DWITHOUT_HTML -DNO_CTF -DNO_LINT DESTDIR=${LIB32TMP} + -DWITHOUT_HTML -DNO_CTF -DNO_LINT -ECC -ECXX -EAS -ELD \ + DESTDIR=${LIB32TMP} LIB32IMAKE= ${LIB32WMAKE:NINSTALL=*:NDESTDIR=*} -DNO_INCS .endif --------------020507060807000600080109--