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...
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
 
_______________________________________________
freebsd-toolchain@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "freebsd-toolchain-unsubscr...@freebsd.org"

Reply via email to