From owner-freebsd-toolchain@freebsd.org Sun Jan 10 11:55:42 2016 Return-Path: Delivered-To: freebsd-toolchain@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A69FAA6B992 for ; Sun, 10 Jan 2016 11:55:42 +0000 (UTC) (envelope-from markmi@dsl-only.net) Received: from asp.reflexion.net (outbound-mail-210-4.reflexion.net [208.70.210.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 669EC1CD7 for ; Sun, 10 Jan 2016 11:55:41 +0000 (UTC) (envelope-from markmi@dsl-only.net) Received: (qmail 5083 invoked from network); 10 Jan 2016 11:55:44 -0000 Received: from unknown (HELO rtc-sm-01.app.dca.reflexion.local) (10.81.150.1) by 0 (rfx-qmail) with SMTP; 10 Jan 2016 11:55:44 -0000 Received: by rtc-sm-01.app.dca.reflexion.local (Reflexion email security v7.80.0) with SMTP; Sun, 10 Jan 2016 06:55:37 -0500 (EST) Received: (qmail 26680 invoked from network); 10 Jan 2016 11:55:37 -0000 Received: from unknown (HELO iron2.pdx.net) (69.64.224.71) by 0 (rfx-qmail) with SMTP; 10 Jan 2016 11:55:37 -0000 X-No-Relay: not in my network X-No-Relay: not in my network X-No-Relay: not in my network X-No-Relay: not in my network Received: from [192.168.1.8] (c-76-115-7-162.hsd1.or.comcast.net [76.115.7.162]) by iron2.pdx.net (Postfix) with ESMTPSA id 58FCD1C43AE; Sun, 10 Jan 2016 03:55:33 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) Subject: Re: Bug 205663 Clang getting Bus Errors (arm SCLTR Bit[12]==1 context): Reported fixed on llvm's trunk From: Mark Millard In-Reply-To: <1452365750.1523.9.camel@freebsd.org> Date: Sun, 10 Jan 2016 03:55:34 -0800 Cc: freebsd-arm , FreeBSD Toolchain Content-Transfer-Encoding: quoted-printable Message-Id: <831D8A96-51D6-4E34-B422-A20857B6769E@dsl-only.net> References: <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> <1452365750.1523.9.camel@freebsd.org> To: Dimitry Andric , Ian Lepore X-Mailer: Apple Mail (2.2104) X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Jan 2016 11:55:42 -0000 On 2016-Jan-9, at 10:55 AM, Ian Lepore wrote: >=20 > On Sat, 2016-01-09 at 15:03 +0100, Dimitry Andric wrote: >> On 09 Jan 2016, at 04:46, Mark Millard wrote: >>>=20 >>> On 2016-Jan-7, at 2:57 PM, Dimitry Andric >>> 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. >>>>=20 >>>> -Dimitry >>>=20 >>> 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. >>=20 >> 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. :-) >>=20 >> -Dimitry >>=20 >=20 > 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. >=20 > -- Ian Context: When I build I normally build lldb and the like as well, even = using WITH_CLANG_EXTRAS=3D . In trying to get lldb to link I eventually get to the point that libc++ = is getting relocation truncations. Before getting to that I deal with = /usr/src/usr.bin/clang/lldb/Makefile to cover what is initially reported = during buildworld for lldb relocation truncations. Then with that in = place and retrying I get reports from libc++.a for a couple of the = contained .o files having relocations that are truncated (before it = reports "additional relocation overflows omitted from the output"): /usr/obj/clang/arm.armv6/usr/src/tmp/usr/lib/libc++.a(thread.o) /usr/obj/clang/arm.armv6/usr/src/tmp/usr/lib/libc++.a(locale.o) (Both have messages from multiple places in each .o file.) As far as I can tell for general use -long-calls is going to be needed = for at least some system level .a library content if the .a's are to be = used. Which leaves me wondering if STATIC_CXXFLAGS having -mlong-calls for arm = system libraries fairly generally is appropriate for those intending on = building the arm-native clang toolchain and related material in = buildworld. (STATIC_CFLAGS too?) A significant case analysis of what = happens to currently be too far apart would be fragile as things grow = even more later. This sort of issue may well not be limited to TARGET=3Darm contexts. The detailed libc++.a relocation truncation complaints that I got were: > --- all_subdir_lldb --- > /usr/obj/clang/arm.armv6/usr/src/tmp/usr/lib/libc++.a(thread.o): In = function = `_ZNSt3__16vectorINS_4pairIPNS_18condition_variableEPNS_5mutexEEENS_18__hi= dden_allocatorIS6_EEE21__push_back_slow_pathIS6_EEvOT_': > = /usr/src/lib/libc++/../../contrib/libc++/src/thread.cpp:(.text._ZNSt3__16v= ectorINS_4pairIPNS_18condition_variableEPNS_5mutexEEENS_18__hidden_allocat= orIS6_EEE21__push_back_slow_pathIS6_EEvOT_[_ZNSt3__16vectorINS_4pairIPNS_1= 8condition_variableEPNS_5mutexEEENS_18__hidden_allocatorIS6_EEE21__push_ba= ck_slow_pathIS6_EEvOT_]+0x30): relocation truncated to fit: R_ARM_CALL = against symbol = `std::__1::__vector_base_common::__throw_length_error() const' = defined in = .text._ZNKSt3__120__vector_base_commonILb1EE20__throw_length_errorEv[_ZNKS= t3__120__vector_base_commonILb1EE20__throw_length_errorEv] section in = /usr/obj/clang/arm.armv6/usr/src/usr.bin/clang/lldb/../../../lib/clang/lib= lldbCore/liblldbCore.a(CxaDemangle.o) > /usr/obj/clang/arm.armv6/usr/src/tmp/usr/lib/libc++.a(thread.o): In = function = `_ZNSt3__16vectorIPNS_17__assoc_sub_stateENS_18__hidden_allocatorIS2_EEE21= __push_back_slow_pathIRKS2_EEvOT_': > = /usr/src/lib/libc++/../../contrib/libc++/src/thread.cpp:(.text._ZNSt3__16v= ectorIPNS_17__assoc_sub_stateENS_18__hidden_allocatorIS2_EEE21__push_back_= slow_pathIRKS2_EEvOT_[_ZNSt3__16vectorIPNS_17__assoc_sub_stateENS_18__hidd= en_allocatorIS2_EEE21__push_back_slow_pathIRKS2_EEvOT_]+0x30): = relocation truncated to fit: R_ARM_CALL against symbol = `std::__1::__vector_base_common::__throw_length_error() const' = defined in = .text._ZNKSt3__120__vector_base_commonILb1EE20__throw_length_errorEv[_ZNKS= t3__120__vector_base_commonILb1EE20__throw_length_errorEv] section in = /usr/obj/clang/arm.armv6/usr/src/usr.bin/clang/lldb/../../../lib/clang/lib= lldbCore/liblldbCore.a(CxaDemangle.o) . . . > --- all_subdir_clang --- > /usr/obj/clang/arm.armv6/usr/src/tmp/usr/lib/libc++.a(locale.o): In = function `std::__1::collate_byname::do_compare(char const*, char = const*, char const*, char const*) const': . . . > --- all_subdir_clang --- > = /usr/src/lib/libc++/../../contrib/libc++/src/locale.cpp:(.text+0x81ec): = relocation truncated to fit: R_ARM_CALL against symbol = `std::__1::__basic_string_common::__throw_length_error() const' = defined in = .text._ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv[_ZNK= St3__121__basic_string_commonILb1EE20__throw_length_errorEv] section in = /usr/obj/clang/arm.armv6/usr/src/usr.bin/clang/lldb/../../../lib/clang/lib= lldbCore/liblldbCore.a(CxaDemangle.o) . . . > --- all_subdir_clang --- > = /usr/src/lib/libc++/../../contrib/libc++/src/locale.cpp:(.text+0x82c0): = relocation truncated to fit: R_ARM_CALL against symbol = `std::__1::__basic_string_common::__throw_length_error() const' = defined in = .text._ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv[_ZNK= St3__121__basic_string_commonILb1EE20__throw_length_errorEv] section in = /usr/obj/clang/arm.armv6/usr/src/usr.bin/clang/lldb/../../../lib/clang/lib= lldbCore/liblldbCore.a(CxaDemangle.o) > /usr/obj/clang/arm.armv6/usr/src/tmp/usr/lib/libc++.a(locale.o): In = function `std::__1::collate_byname::do_transform(char const*, char = const*) const': > = /usr/src/lib/libc++/../../contrib/libc++/src/locale.cpp:(.text+0x8430): = relocation truncated to fit: R_ARM_CALL against symbol = `std::__1::__basic_string_common::__throw_length_error() const' = defined in = .text._ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv[_ZNK= St3__121__basic_string_commonILb1EE20__throw_length_errorEv] section in = /usr/obj/clang/arm.armv6/usr/src/usr.bin/clang/lldb/../../../lib/clang/lib= lldbCore/liblldbCore.a(CxaDemangle.o) > /usr/obj/clang/arm.armv6/usr/src/tmp/usr/lib/libc++.a(locale.o): In = function `std::__1::collate_byname::do_compare(wchar_t const*, = wchar_t const*, wchar_t const*, wchar_t const*) const': > --- all_subdir_clang --- > = /usr/src/lib/libc++/../../contrib/libc++/src/locale.cpp:(.text+0x88a8): = relocation truncated to fit: R_ARM_CALL against symbol = `std::__1::__basic_string_common::__throw_length_error() const' = defined in = .text._ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv[_ZNK= St3__121__basic_string_commonILb1EE20__throw_length_errorEv] section in = /usr/obj/clang/arm.armv6/usr/src/usr.bin/clang/lldb/../../../lib/clang/lib= lldbCore/liblldbCore.a(CxaDemangle.o) > = /usr/src/lib/libc++/../../contrib/libc++/src/locale.cpp:(.text+0x899c): = relocation truncated to fit: R_ARM_CALL against symbol = `std::__1::__basic_string_common::__throw_length_error() const' = defined in = .text._ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv[_ZNK= St3__121__basic_string_commonILb1EE20__throw_length_errorEv] section in = /usr/obj/clang/arm.armv6/usr/src/usr.bin/clang/lldb/../../../lib/clang/lib= lldbCore/liblldbCore.a(CxaDemangle.o) > /usr/obj/clang/arm.armv6/usr/src/tmp/usr/lib/libc++.a(locale.o): In = function `std::__1::collate_byname::do_transform(wchar_t = const*, wchar_t const*) const': > = /usr/src/lib/libc++/../../contrib/libc++/src/locale.cpp:(.text+0x8b34): = relocation truncated to fit: R_ARM_CALL against symbol = `std::__1::__basic_string_common::__throw_length_error() const' = defined in = .text._ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv[_ZNK= St3__121__basic_string_commonILb1EE20__throw_length_errorEv] section in = /usr/obj/clang/arm.armv6/usr/src/usr.bin/clang/lldb/../../../lib/clang/lib= lldbCore/liblldbCore.a(CxaDemangle.o) > /usr/obj/clang/arm.armv6/usr/src/tmp/usr/lib/libc++.a(locale.o): In = function `std::__1::collate::do_transform(char const*, char = const*) const': > = /usr/src/lib/libc++/../../contrib/libc++/src/locale.cpp:(.text._ZNKSt3__17= collateIcE12do_transformEPKcS3_[_ZNKSt3__17collateIcE12do_transformEPKcS3_= ]+0x34): relocation truncated to fit: R_ARM_CALL against symbol = `std::__1::__basic_string_common::__throw_length_error() const' = defined in = .text._ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv[_ZNK= St3__121__basic_string_commonILb1EE20__throw_length_errorEv] section in = /usr/obj/clang/arm.armv6/usr/src/usr.bin/clang/lldb/../../../lib/clang/lib= lldbCore/liblldbCore.a(CxaDemangle.o) > /usr/obj/clang/arm.armv6/usr/src/tmp/usr/lib/libc++.a(locale.o): In = function `std::__1::collate::do_transform(wchar_t const*, = wchar_t const*) const': > = /usr/src/lib/libc++/../../contrib/libc++/src/locale.cpp:(.text._ZNKSt3__17= collateIwE12do_transformEPKwS3_[_ZNKSt3__17collateIwE12do_transformEPKwS3_= ]+0x38): relocation truncated to fit: R_ARM_CALL against symbol = `std::__1::__basic_string_common::__throw_length_error() const' = defined in = .text._ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv[_ZNK= St3__121__basic_string_commonILb1EE20__throw_length_errorEv] section in = /usr/obj/clang/arm.armv6/usr/src/usr.bin/clang/lldb/../../../lib/clang/lib= lldbCore/liblldbCore.a(CxaDemangle.o) > /usr/obj/clang/arm.armv6/usr/src/tmp/usr/lib/libc++.a(locale.o): In = function `std::__1::num_put > = >::do_put(std::__1::ostreambuf_iterator >, std::__1::ios_base&, char, long) const': > = /usr/src/lib/libc++/../../contrib/libc++/src/locale.cpp:(.text._ZNKSt3__17= num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_putES4_RNS_8= ios_baseEcl[_ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traits= IcEEEEE6do_putES4_RNS_8ios_baseEcl]+0x16c): additional relocation = overflows omitted from the output Ian's/Andy's original patch is listed below for reference. > Index: lib/clang/clang.lib.mk > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- lib/clang/clang.lib.mk (revision 293584) > +++ lib/clang/clang.lib.mk (working copy) > @@ -6,4 +6,8 @@ LLVM_SRCS=3D ${.CURDIR}/../../../contrib/llvm >=20 > INTERNALLIB=3D >=20 > +.if ${MACHINE_CPUARCH} =3D=3D "arm" > +STATIC_CXXFLAGS+=3D-mlong-calls > +.endif > + > .include > Index: lib/csu/arm/Makefile > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- lib/csu/arm/Makefile (revision 293584) > +++ lib/csu/arm/Makefile (working copy) > @@ -23,7 +23,7 @@ CLEANFILES+=3D crt1.s gcrt1.s Scrt1.s > # directly compiled to .o files. >=20 > 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} >=20 > crt1.o: crt1.s > @@ -30,7 +30,7 @@ crt1.o: crt1.s > ${CC} ${ACFLAGS} -c -o ${.TARGET} crt1.s >=20 > 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} >=20 > gcrt1.o: gcrt1.s > Index: usr.bin/clang/clang/Makefile > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- usr.bin/clang/clang/Makefile (revision 293584) > +++ usr.bin/clang/clang/Makefile (working copy) > @@ -11,7 +11,11 @@ SRCS=3D cc1_main.cpp \ >=20 > .if ${MK_SHARED_TOOLCHAIN} =3D=3D "no" > NO_SHARED?=3D yes > + > +.if ${MACHINE_CPUARCH} =3D=3D "arm" > +CFLAGS+=3D-mlong-calls > .endif > +.endif >=20 > LINKS=3D ${BINDIR}/clang ${BINDIR}/clang++ \ > ${BINDIR}/clang ${BINDIR}/clang-cpp >=20