Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 09 Jan 2016 11:55:50 -0700
From:      Ian Lepore <ian@freebsd.org>
To:        Dimitry Andric <dim@FreeBSD.org>, Mark Millard <markmi@dsl-only.net>
Cc:        freebsd-arm <freebsd-arm@freebsd.org>, FreeBSD Toolchain <freebsd-toolchain@freebsd.org>
Subject:   Re: Bug 205663 Clang getting Bus Errors (arm SCLTR Bit[12]==1 context): Reported fixed on llvm's trunk
Message-ID:  <1452365750.1523.9.camel@freebsd.org>
In-Reply-To: <39774562-F76E-41E9-85E7-ABE257B013D6@FreeBSD.org>
References:  <C90F0ABA-3C59-4FE1-AAB4-99F8FF32FB24@dsl-only.net> <CANCZdfoWDg_ZX8zxqRV2-Q6teYf_Ef4f3VKB0fhb0sikcW3hUA@mail.gmail.com> <1452020032.1320.21.camel@freebsd.org> <7EE8F65E-7485-4FA9-A136-F22090DB107F@FreeBSD.org> <92264003-CF0E-4624-A28A-8AFB7C663BFB@dsl-only.net> <39774562-F76E-41E9-85E7-ABE257B013D6@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--=-l6GbdNs55QDkue5/IPHe
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit

On Sat, 2016-01-09 at 15:03 +0100, Dimitry Andric wrote:
> On 09 Jan 2016, at 04:46, Mark Millard <markmi@dsl-only.net> wrote:
> > 
> > On 2016-Jan-7, at 2:57 PM, Dimitry Andric <dim at FreeBSD.org>
> > wrote:
> ...
> > > FYI, I have added a -mno-movt option for this purpose upstream,
> > > and
> > > imported a newer snapshot into the clang380-import branch.  As of
> > > r293384, it now uses the new option spelling for modules, if your
> > > clang
> > > is 3.8.0 or higher.
> > > 
> > > -Dimitry
> > 
> > I've not been able to get to the point of running clang++ 3.8 on
> > the rpi2 yet: R_ARM_CALL and R_ARM_JUMP24 relocation truncations
> > during the cross build's buildworld interfere.
> 
> Yes, this is caused by too large call distances.  In other words, the
> clang executable is getting to big to link.  Apparently we need to do
> some tricks with -mlongcall to fix this.  As I am no arm expert, I
> welcome any patch submissions. :-)
> 
> -Dimitry
> 

Here's the patch I got from Andy for the clang380 branch, modified with
Warner's suggestion to use MACHINE_CPUARCH instead of MACHINE.  With
this I can get a working arm world that will build a runnable
helloworld.c (and .cc) on a dreamplug.  (I.e., it appears clang 3.8.0
fixes the problem we had with clang 3.7.x where it wouldn't run at all
on armv4/5 systems).  I have not tried compling anything complex yet.

-- Ian

--=-l6GbdNs55QDkue5/IPHe
Content-Disposition: inline; filename="arm_clang_longcall.diff"
Content-Type: text/x-patch; name="arm_clang_longcall.diff"; charset="us-ascii"
Content-Transfer-Encoding: 7bit

Index: lib/clang/clang.lib.mk
===================================================================
--- lib/clang/clang.lib.mk	(revision 293584)
+++ lib/clang/clang.lib.mk	(working copy)
@@ -6,4 +6,8 @@ LLVM_SRCS= ${.CURDIR}/../../../contrib/llvm
 
 INTERNALLIB=
 
+.if ${MACHINE_CPUARCH} == "arm"
+STATIC_CXXFLAGS+=-mlong-calls
+.endif
+
 .include <bsd.lib.mk>
Index: lib/csu/arm/Makefile
===================================================================
--- lib/csu/arm/Makefile	(revision 293584)
+++ lib/csu/arm/Makefile	(working copy)
@@ -23,7 +23,7 @@ CLEANFILES+=	crt1.s gcrt1.s Scrt1.s
 # directly compiled to .o files.
 
 crt1.s: crt1.c
-	${CC} ${CFLAGS} -S -o ${.TARGET} ${.CURDIR}/crt1.c
+	${CC} ${CFLAGS} -mlong-calls -S -o ${.TARGET} ${.CURDIR}/crt1.c
 	sed ${SED_FIX_NOTE} ${.TARGET}
 
 crt1.o: crt1.s
@@ -30,7 +30,7 @@ crt1.o: crt1.s
 	${CC} ${ACFLAGS} -c -o ${.TARGET} crt1.s
 
 gcrt1.s: crt1.c
-	${CC} ${CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1.c
+	${CC} ${CFLAGS} -mlong-calls -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1.c
 	sed ${SED_FIX_NOTE} ${.TARGET}
 
 gcrt1.o: gcrt1.s
Index: usr.bin/clang/clang/Makefile
===================================================================
--- usr.bin/clang/clang/Makefile	(revision 293584)
+++ usr.bin/clang/clang/Makefile	(working copy)
@@ -11,7 +11,11 @@ SRCS=	cc1_main.cpp \
 
 .if ${MK_SHARED_TOOLCHAIN} == "no"
 NO_SHARED?= yes
+
+.if ${MACHINE_CPUARCH} == "arm"
+CFLAGS+=-mlong-calls
 .endif
+.endif
 
 LINKS=	${BINDIR}/clang ${BINDIR}/clang++ \
 	${BINDIR}/clang ${BINDIR}/clang-cpp

--=-l6GbdNs55QDkue5/IPHe--




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1452365750.1523.9.camel>