Date: Tue, 23 Aug 2011 09:23:01 +0000 From: Alexander Best <arundel@freebsd.org> To: Dimitry Andric <dim@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 Message-ID: <20110823092301.GA45910@freebsd.org> In-Reply-To: <4E50551D.9020104@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>
next in thread | previous in thread | raw e-mail | index | archive | help
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 > >><http://wiki.freebsd.org/BuildingFreeBSDWithClang>: > >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... any chance this patch can be committed? 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 >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110823092301.GA45910>