From owner-freebsd-toolchain@FreeBSD.ORG Sun Aug 21 15:41:24 2011 Return-Path: Delivered-To: freebsd-toolchain@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 1233) id 6FC931065672; Sun, 21 Aug 2011 15:41:24 +0000 (UTC) Date: Sun, 21 Aug 2011 15:41:24 +0000 From: Alexander Best To: Dimitry Andric Message-ID: <20110821154124.GA12064@freebsd.org> References: <20110818050142.GA96873@freebsd.org> <4E4CB59B.3000005@FreeBSD.org> <20110818173508.GA92360@freebsd.org> <4E4D6E01.40905@FreeBSD.org> <20110819080105.GA92201@freebsd.org> <4E50551D.9020104@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4E50551D.9020104@FreeBSD.org> 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 15:41:24 -0000 On Sun Aug 21 11, Dimitry Andric wrote: > 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... thanks a bunch. both buildworld and buildkernel succeeded with CC, CXX and CPP set explicitly to the absolute clang location. :) cheers. alex > 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 >