Date: Mon, 28 Jul 2014 19:48:26 -0500 From: Stacey Son <sson@FreeBSD.org> To: freebsd-mips@FreeBSD.org Subject: Re: mips64 ld GOT problem Message-ID: <35DBC8E0-45AB-470A-B554-85445FBBF8E4@FreeBSD.org> In-Reply-To: <A2A47455-537A-4782-8B45-AB6544571AA5@FreeBSD.org> References: <77F1DDA2-A4E5-4D64-AA43-F8CBC55249C4@me.com> <48935A3D-0387-42F1-ACF0-14EB7D8F9A06@bsdimp.com> <C7869A0A-8CE6-4764-9AFD-A49C93E680C1@FreeBSD.org> <2021F70B-2AA4-412C-8D1B-A8D38A3E031C@FreeBSD.org> <37D1F27C-B595-43AA-A0F8-6B48AE4D7C69@FreeBSD.org> <A2A47455-537A-4782-8B45-AB6544571AA5@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
FWIIW, here is a tarball of my native clang/llvm 3.5.0 bootstrap build = for anyone interested: = http://people.freebsd.org/~sson/mips/clang/clang-3.5.0-r213872.tgz Untar in /usr/local on a mips64 box (in my case an Ubiquiti EdgeRouter = Lite) running -current, set CC, CXX to use clang, clang++ in = /usr/local/clang-3.5.0/bin, and maybe add "-integrated-as" to your = CFLAGS depending on the maturity of your binutils. -stacey. On Jul 28, 2014, at 10:58 AM, Stacey Son <sson@FreeBSD.org> wrote: >=20 > OK, I found that if I simply add "-O" to the cmake "-DCMAKE_C_FLAGS" = and "-DCMAKE_CXX_FLAGS" (and setting -DCMAKE_BUILD_TYPE to None) = everything will bootstrap and link. If I am brave enough I may try a = "Stage 3" compile. >=20 >=20 > On Jul 27, 2014, at 2:39 PM, Stacey Son <sson@FreeBSD.ORG> wrote: >=20 >> Hi David: >>=20 >> Compiling with the cmake option "-DBUILD_SHARED_LIBS=3DTrue" does get = it pass linking 'opt' but it later fails later on... >>=20 >> [ 73%] Building CXX object = tools/clang/lib/AST/CMakeFiles/clangAST.dir/VTTBuilder.cpp.o >> Linking CXX shared library ../../../../lib/libclangAST.so >> [...] >> /home/sson/llvm/tools/clang/lib/AST/ASTContext.cpp:(.text+0x710): = relocation truncated to fit: R_MIPS_CALL16 against `bool = llvm::isa<clang::ObjCPropertyDecl, clang::Decl const*>(clang::Decl = const* const&)' >> [...] >> /home/sson/llvm/tools/clang/lib/AST/ASTContext.cpp:(.text+0x5a98): = additional relocation overflows omitted from the output >> clang-3.5: error: linker command failed with exit code 1 (use -v to = see invocation) >> *** Error code 1 >>=20 >> As for enabling optimization, when I use "-DCMAKE_BUILD_TYPE=3DRelease"= or "-DCMAKE_BUILD_TYPE=3DMinSizeRel" with the cmake I get an = "EmitRawText called on an MCStreamer that doesn't support it, something = must not be fully mc'ized" abort. Only "-DCMAKE_BUILD_TYPE=3DDebug" or = "-DCMAKE_BUILD_TYPE=3DNone" seems to work. Maybe I am not enabling the = optimization correctly? >>=20 >> I have been able to get ld from binutils 2.24 to mostly work. It = will link binaries with "-static" but dynamic binaries are still a = problem. It seems the default ldscript is not quite right or something. >>=20 >> -stacey. >>=20 >> On Jul 26, 2014, at 6:46 AM, David Chisnall <theraven@FreeBSD.org> = wrote: >>=20 >>> The only way that I've ever got llvm to compile for MIPS has been by = enabling shared libraries, enabling optimisation, and disabling debug = info. This gave each shared lib a small enough GOT for our binutils = linker to work. >>>=20 >>> Newer binutils supports multi-GOT (GOT is split and different GOTs = are installed by some calls) and large-GOT (GOT accesses use register = offsets) modes. >>>=20 >>> David >>>=20 >>> On 25 Jul 2014, at 23:27, Stacey Son <sson@FreeBSD.org> wrote: >>>=20 >>>>=20 >>>> Hi Warner... >>>>=20 >>>> On Jul 25, 2014, at 11:26 AM, Warner Losh <imp@bsdimp.com> wrote: >>>>=20 >>>>>=20 >>>>> On Jul 25, 2014, at 9:24 AM, Stacey Son <sson@me.com> wrote: >>>>>=20 >>>>>> Hi all: >>>>>>=20 >>>>>> I have been trying to bootstrap clang/llvm 3.5 for mips64 (i.e. = cross build clang/llvm 3.5 for mips64 using clang/llvm 3.5) but run into = the following linker problem (see below) in about the midway point as it = is trying to link 'opt'. The assertions that fail are the following: >>>>>>=20 >>>>>> BFD 2.17.50 [FreeBSD] 2007-07-03 assertion fail = /usr/home/sson/freebsd/gnu/usr.bin/binutils/libbfd/../../../../contrib/bin= utils/bfd/elfxx-mips.c:7455 >>>>>>=20 >>>>>> BFD_ASSERT (g->assigned_gotno - g->local_gotno >>>>>> <=3D g->global_gotno); >>>>>>=20 >>>>>> BFD 2.17.50 [FreeBSD] 2007-07-03 assertion fail = /usr/home/sson/freebsd/gnu/usr.bin/binutils/libbfd/../../../../contrib/bin= utils/bfd/elfxx-mips.c:2767 >>>>>>=20 >>>>>> /* There should have been enough room in the symbol table to >>>>>> accommodate both the GOT and non-GOT symbols. */ >>>>>> BFD_ASSERT (hsd.max_non_got_dynindx <=3D hsd.min_got_dynindx); >>>>>>=20 >>>>>> BFD 2.17.50 [FreeBSD] 2007-07-03 assertion fail = /usr/home/sson/freebsd/gnu/usr.bin/binutils/libbfd/../../../../contrib/bin= utils/bfd/elfxx-mips.c:10282 >>>>>>=20 >>>>>> /* Make sure we didn't grow the global .got region. */ >>>>>> dynobj =3D elf_hash_table (info)->dynobj; >>>>>> got =3D mips_elf_got_section (dynobj, FALSE); >>>>>> g =3D mips_elf_section_data (got)->u.got_info; >>>>>>=20 >>>>>> if (g->global_gotsym !=3D NULL) >>>>>> BFD_ASSERT ((elf_hash_table (info)->dynsymcount >>>>>> - g->global_gotsym->dynindx) >>>>>> <=3D g->global_gotno); >>>>>>=20 >>>>>> Does anyone have an idea for a work around or fix? >>>>>=20 >>>>> Silly question: does using the latest binutils fix this problem? >>>>=20 >>>> Is there a stable port of the latest binutils to mips? Does = someone have some patches? I did tried TheRaven's port of the 2.18 = binutils but it seemed that 'ld' wasn't very happy. It didn't like any = of the object files I offered it. >>>>=20 >>>>> Failing that, perhaps we need to specify a larger GOT region that = we do today? IIRC, that=92s specified with -g on the linker line, Try = adding =93-G0=94. I have a vague recollection we always used to do this, = but moved it to be a default (or maybe other systems have the default = and we still need to add it). It doesn=92t look like it is being added = from the output that you=92ve posted. IIRC, it has to be specified on = all the compiler invocations as well. >>>>=20 >>>> Reading the man page implies -Gvalue/--gpsize=3Dvalue is only for = ECOFF binaries. I tried it anyway and it didn't seem to help. >>>>=20 >>>> -stacey. >>>=20 >>=20 >> _______________________________________________ >> freebsd-mips@freebsd.org mailing list >> http://lists.freebsd.org/mailman/listinfo/freebsd-mips >> To unsubscribe, send any mail to = "freebsd-mips-unsubscribe@freebsd.org" >=20
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?35DBC8E0-45AB-470A-B554-85445FBBF8E4>