how do i cross build world/kernel with clang?

David Chisnall theraven at FreeBSD.org
Mon Sep 16 08:01:47 UTC 2013


On 15 Sep 2013, at 23:28, "Joe Holden" <lists at rewt.org.uk> wrote:

> Are you still playing with this?  Reason I ask is that I tried to build
> world with clang for the crack and it bails with:
> 
> /usr/obj/mips.mips64/pseudosrc/tmp/usr/bin/ld:
> /usr/obj/mips.mips64/pseudosrc/tmp/usr/lib/crtn.o: warning: linking PIC
> files with non-PIC files

This is an old bug in LLVM, where it didn't set the cpic bit in the e_flags field of the ELF header.  We fixed it a little while ago, but it hasn't been imported into head yet.

> exect.So: In function `exect':
> (.text+0x18): relocation truncated to fit: R_MIPS_PC16 against `__cerror'
> setjmp.So: In function `botch':
> (.text+0x124): relocation truncated to fit: R_MIPS_PC16 against `abort'
> _setjmp.So: In function `botch':
> (.text+0xac): relocation truncated to fit: R_MIPS_PC16 against `abort'
> _sigwait.So: In function `err':
> (.text+0x18): relocation truncated to fit: R_MIPS_PC16 against `__cerror'
> _getlogin.So: In function `err':
> (.text+0x18): relocation truncated to fit: R_MIPS_PC16 against `__cerror'
> aio_mlock.So: In function `err':
> (.text+0x18): relocation truncated to fit: R_MIPS_PC16 against `__cerror'
> pipe2.So: In function `err':
> (.text+0x18): relocation truncated to fit: R_MIPS_PC16 against `__cerror'
> accept4.So: In function `err':
> (.text+0x18): relocation truncated to fit: R_MIPS_PC16 against `__cerror'
> chflagsat.So: In function `err':
> (.text+0x18): relocation truncated to fit: R_MIPS_PC16 against `__cerror'
> connectat.So: In function `err':
> (.text+0x18): relocation truncated to fit: R_MIPS_PC16 against `__cerror'
> bindat.So: In function `err':
> (.text+0x18): additional relocation overflows omitted from the output

Most of these are due to our linker not being able to correctly insert PLT entries on MIPS (recent GNU binutils doesn't have this problem, but unfortunately also can't target FreeBSD.  I believe Warner is working on forward-porting our patches to a new binutils).  We might be able to hack LLVM to always emit 24-bit relocations, but that seems a bit of a hack.  I'm inclined to wait until we import MCLinker, which now has MIPS32/64 support, and should be much easier to fix if it has this kind of issue.

David



More information about the freebsd-mips mailing list