Bug 205663 Clang getting Bus Errors (arm SCLTR Bit[12]==1 context): Reported fixed on llvm's trunk
Mark Millard
markmi at dsl-only.net
Mon Jan 11 12:56:09 UTC 2016
Quick top post of a correction to a mistake of mine about the ports issue:
The notes about -fpic/-fPIC issues with ports are wrong and the issue was self inflicted: using -v on the clang or clang++ command lines messes up autoconf/libtool by them not handling the extra output text well. Many ports depend on those tools.
===
Mark Millard
markmi at dsl-only.net
On 2016-Jan-11, at 2:51 AM, Mark Millard <markmi at dsl-only.net> wrote:
>
>
> On 2016-Jan-10, at 9:59 AM, Mark Millard <markmi at dsl-only.net> wrote:
>>
>> [A top post of my so far successful experiment. . .]
>>
>> amd64 -> rpi2 cross build: buildworld buildkernel installkernel installworld mergemaster delete-old then boot the result on an rpi2 worked ( -march=armv7a -mcpu=cortex-a7 -mfloat-abi=softfp -mno-unaligned-access used ).
>>
>> In order to also build lldb I used the following beyond what Ian sent out for -mlong-calls usage:
>> (I make no claim to have tested the lldb build.)
>> (Tabs likely not preserved in the copy/paste operations.)
>>
>>> # more lib_libc++_Makfile.diff
>>> Index: /usr/src/lib/libc++/Makefile
>>> ===================================================================
>>> --- /usr/src/lib/libc++/Makefile (revision 293430)
>>> +++ /usr/src/lib/libc++/Makefile (working copy)
>>> @@ -57,6 +57,9 @@
>>> .endfor
>>>
>>> WARNS= 0
>>> +.if ${MACHINE_CPUARCH} == "arm"
>>> +STATIC_CXXFLAGS+=-mlong-calls
>>> +.endif
>>> CFLAGS+= -I${HDRDIR} -I${_LIBCXXRTDIR} -nostdlib -DLIBCXXRT
>>> .if empty(CXXFLAGS:M-std=*)
>>> CXXFLAGS+= -std=c++11
>>
>>> # more usr_bin_clang_lldb_Makefile.diff
>>> Index: /usr/src/usr.bin/clang/lldb/Makefile
>>> ===================================================================
>>> --- /usr/src/usr.bin/clang/lldb/Makefile (revision 293430)
>>> +++ /usr/src/usr.bin/clang/lldb/Makefile (working copy)
>>> @@ -6,6 +6,10 @@
>>>
>>> LLDB_SRCS=${.CURDIR}/../../../contrib/llvm/tools/lldb
>>>
>>> +.if ${MACHINE_CPUARCH} == "arm"
>>> +CFLAGS+=-mlong-calls
>>> +.endif
>>> +
>>> CFLAGS+= -I${LLDB_SRCS}/include
>>> CXXFLAGS+= -std=c++11
>>
>>
>>
>> The rpi2 is now attempting buildworld buildkernel targeting itself. It is way beyond where clang 3.7.1 crashed.
>
>
>
> The rpi2 finished buildworld buildkernel. To build:
>
>> WITH_FAST_DEPEND=
>> WITH_LIBCPLUSPLUS=
>> WITH_BINUTILS_BOOTSTRAP=
>> WITH_CLANG=
>> WITH_CLANG_IS_CC=
>> WITH_CLANG_FULL=
>> WITH_LLDB=
>> WITH_CLANG_EXTRAS=
>> WITH_BOOT=
>> #
>> WITHOUT_ELFTOOLCHAIN_BOOTSTRAP=
>> WITHOUT_CLANG_BOOTSTRAP=
>> WITHOUT_GCC_BOOTSTRAP=
>> WITHOUT_LIB32=
>> WITHOUT_GCC=
>> WITHOUT_GNUCXX=
>> #
>> NO_WERROR=
>> MALLOC_PRODUCTION=
>> #
>> WITH_DEBUG=
>> WITH_DEBUG_FILES=
>
> based on -target armv6--freebsd11.0-gnueabi -march=armv7a -mcpu=cortex-a7 -mfloat-abi=softfp -mno-unaligned-access it took the rpi2 14 hours 26 min or so.
>
> Then: installkernel; install world; shutdown -r now . . .
>
> . . . It boots and operates as hoped. For this rpi2 context clang 3.8.0 seems to be working fine for such activity.
>
>> # freebsd-version -ku; uname -aKU
>> 11.0-CURRENT
>> 11.0-CURRENT
>> FreeBSD rpi2 11.0-CURRENT FreeBSD 11.0-CURRENT #2 r293579M: Mon Jan 11 07:36:21 UTC 2016 markmi at rpi2:/usr/obj/clang/arm.armv6/usr/src/sys/RPI2-NODBG arm 1100093 1100093
>> make.conf empty.
>
> src.conf (make.conf empty):
>
>> TO_TYPE=armv6
>> #
>> KERNCONF=RPI2-NODBG
>> TARGET=arm
>> .if ${.MAKE.LEVEL} == 0
>> TARGET_ARCH=${TO_TYPE}
>> .export TARGET_ARCH
>> .endif
>> #
>> WITH_FAST_DEPEND=
>> WITH_LIBCPLUSPLUS=
>> WITH_BINUTILS_BOOTSTRAP=
>> WITH_CLANG=
>> WITH_CLANG_IS_CC=
>> WITH_CLANG_FULL=
>> WITH_LLDB=
>> WITH_CLANG_EXTRAS=
>> WITH_BOOT=
>> #
>> WITHOUT_ELFTOOLCHAIN_BOOTSTRAP=
>> WITHOUT_CLANG_BOOTSTRAP=
>> WITHOUT_GCC_BOOTSTRAP=
>> WITHOUT_LIB32=
>> WITHOUT_GCC=
>> WITHOUT_GNUCXX=
>> #
>> NO_WERROR=
>> MALLOC_PRODUCTION=
>> #
>> WITH_DEBUG=
>> WITH_DEBUG_FILES=
>> #
>> .if ${.MAKE.LEVEL} == 0
>> XCC=/usr/bin/clang -v -target ${TO_TYPE}--freebsd11.0-gnueabi -march=armv7a -mcpu=cortex-a7 -mfloat-abi=softfp -mno-unaligned-access
>> XCXX=/usr/bin/clang++ -v -target ${TO_TYPE}--freebsd11.0-gnueabi -march=armv7a -mcpu=cortex-a7 -mfloat-abi=softfp -mno-unaligned-access
>> XCPP=/usr/bin/clang-cpp -v -target ${TO_TYPE}--freebsd11.0-gnueabi -march=armv7a -mcpu=cortex-a7 -mfloat-abi=softfp -mno-unaligned-access
>> .export XCC
>> .export XCXX
>> .export XCPP
>> .endif
>> #
>> .if ${.MAKE.LEVEL} == 0
>> CC=/usr/bin/clang -v -march=armv7a -mcpu=cortex-a7 -mfloat-abi=softfp -mno-unaligned-access
>> CXX=/usr/bin/clang++ -v -march=armv7a -mcpu=cortex-a7 -mfloat-abi=softfp -mno-unaligned-access
>> CPP=/usr/bin/clang-cpp -v -march=armv7a -mcpu=cortex-a7 -mfloat-abi=softfp -mno-unaligned-access
>> .export CC
>> .export CXX
>> .export CPP
>> .endif
>
> This vintage of src.conf presumes Ian Lepore's updates to the system's binutils that allow them to handle armv7a movt instruction usage and the like.
>
>
> RPI2-NODBG:
>
>> ident RPI2-NODBG
>>
>> include "RPI2"
>>
>> makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
>> options ALT_BREAK_TO_DEBUGGER
>> #options VERBOSE_SYSINIT # Enable verbose sysinit messages
>>
>> options KDB # Enable kernel debugger support
>>
>> # For minimum debugger support (stable branch) use:
>> #options KDB_TRACE # Print a stack trace for a panic
>> options DDB # Enable the kernel debugger
>>
>> nooptions INVARIANTS # Enable calls of extra sanity checking
>> nooptions INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS
>> nooptions WITNESS # Enable checks to detect deadlocks and cycles
>> nooptions WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
>> nooptions DIAGNOSTIC
>
>
> Where I've got somewhat variant source code is listed below:
> (This includes the recent changes to various Makefiles for arm -mlong-call use for clang 3.8.0 .)
>
>> # svnlite status /usr/src/
>> M /usr/src/contrib/libcxxrt/guard.cc
>> M /usr/src/lib/clang/clang.lib.mk
>> M /usr/src/lib/csu/arm/Makefile
>> M /usr/src/lib/csu/powerpc64/Makefile
>> M /usr/src/lib/libc++/Makefile
>> ? /usr/src/sys/arm/conf/RPI2-NODBG
>> M /usr/src/sys/boot/ofw/Makefile.inc
>> M /usr/src/sys/boot/powerpc/Makefile.inc
>> M /usr/src/sys/boot/uboot/Makefile.inc
>> ? /usr/src/sys/powerpc/conf/GENERIC64vtsc
>> ? /usr/src/sys/powerpc/conf/GENERIC64vtsc-NODEBUG
>> ? /usr/src/sys/powerpc/conf/GENERICvtsc
>> ? /usr/src/sys/powerpc/conf/GENERICvtsc-NODEBUG
>> M /usr/src/sys/powerpc/ofw/ofw_machdep.c
>> M /usr/src/usr.bin/clang/clang/Makefile
>> M /usr/src/usr.bin/clang/lldb/Makefile
>
> (Most of the above is powerpc64 or powerpc specific, some even PowerMac G5 specific.)
>
>
> Confirming that lldb does something:
>
>> # more main.c
>> int
>> main ()
>> {
>> return 0;
>> }
>> # clang main.c
>> # lldb a.out
>> (lldb) target create "a.out"
>> Current executable set to 'a.out' (arm).
>> (lldb) run
>> Process 744 launching
>> Process 744 launched: '/root/c_tests/a.out' (arm)
>> Process 744 exited with status = 0 (0x00000000)
>> (lldb) quit
>
> So the 2 additional Makefiles with -mlong-calls usage for arm was sufficient.
>
>
>
> It does look like that for -march=armv7a there will be an issue of needing more use of -fpic/-fPIC and the like in ports. Otherwise things like "unresolvable R_ARM_MOVW_ABS_NC relocation against symbol `g_free'" tend to occur in producing -Bsharable files.
>
> For -march=armv7a -mcpu=cortex-a7 there is the example of .libs/gdkcairo.o being rejected with that message:
>
>> /bin/sh ../libtool --tag=CC --mode=link /usr/bin/clang -v -target armv6--freebsd11.0-gnueabi -march=armv7-a -mcpu=cortex-a7 -mfloat-abi=softfp -mno-unaligned-access -pipe -mfloat-abi=softfp -g -fno-strict-aliasing -Wall -version-info 2400:29:2400 -export-dynamic -rpath /usr/local/lib -export-symbols-regex "^[^_].*" -L/usr/local/lib -o libgdk-x11-2.0.la gdk.lo gdkapplaunchcontext.lo gdkcairo.lo gdkcolor.lo gdkcursor.lo gdkdisplay.lo gdkdisplaymanager.lo gdkdnd.lo gdkdraw.lo gdkevents.lo gdkfont.lo gdkgc.lo gdkglobals.lo gdkimage.lo gdkkeys.lo gdkkeyuni.lo gdkoffscreenwindow.lo gdkpango.lo gdkpixbuf-drawable.lo gdkpixbuf-render.lo gdkpixmap.lo gdkpolyreg-generic.lo gdkrectangle.lo gdkregion-generic.lo gdkrgb.lo gdkscreen.lo gdkselection.lo gdkvisual.lo gdkwindow.lo gdkwindowimpl.lo gdkenumtypes.lo gdkmarshalers.lo x11/libgdk-x11.la -L/usr/local/lib -lpangocairo-1.0 -lpango-1.0 -lgio-2.0 -lfontconfig -lfreetype -lXrender -lXinerama -lXi -lXrandr -lXcursor -lXcomposite -lXdamage -lXfixes -lgdk_pixbuf-2.0 -lgobject-2.0 -lglib-2.0 -lintl -lcairo -lpthread -lX11 -lXext -lm
> . . .
>> libtool: link: /usr/bin/clang -v -target armv6--freebsd11.0-gnueabi -march=armv7-a -mcpu=cortex-a7 -mfloat-abi=softfp -mno-unaligned-access -shared .libs/gdk.o .libs/gdkapplaunchcontext.o .libs/gdkcairo.o .libs/gdkcolor.o .libs/gdkcursor.o .libs/gdkdisplay.o .libs/gdkdisplaymanager.o .libs/gdkdnd.o .libs/gdkdraw.o .libs/gdkevents.o .libs/gdkfont.o .libs/gdkgc.o .libs/gdkglobals.o .libs/gdkimage.o .libs/gdkkeys.o .libs/gdkkeyuni.o .libs/gdkoffscreenwindow.o .libs/gdkpango.o .libs/gdkpixbuf-drawable.o .libs/gdkpixbuf-render.o .libs/gdkpixmap.o .libs/gdkpolyreg-generic.o .libs/gdkrectangle.o .libs/gdkregion-generic.o .libs/gdkrgb.o .libs/gdkscreen.o .libs/gdkselection.o .libs/gdkvisual.o .libs/gdkwindow.o .libs/gdkwindowimpl.o .libs/gdkenumtypes.o .libs/gdkmarshalers.o -Wl,--whole-archive x11/.libs/libgdk-x11.a -Wl,--no-whole-archive -L/usr/local/lib -lpangocairo-1.0 -lpango-1.0 -lgio-2.0 -lfontconfig -lfreetype -lXrender -lXinerama -lXi -lXrandr -lXcursor -lXcomposite -lXdamage -lXfixes -lgdk_pixbuf-2.0 -lgobject-2.0 -lglib-2.0 -lintl -lcairo -lpthread -lX11 -lXext -lm -march=armv7-a -mcpu=cortex-a7 -mfloat-abi=softfp -mno-unaligned-access -mfloat-abi=softfp -g -Wl,-soname -Wl,libgdk-x11-2.0.so.0 -Wl,-version-script -Wl,.libs/libgdk-x11-2.0.so.0.2400.29-ver -o .libs/libgdk-x11-2.0.so.0.2400.29
>> FreeBSD clang version 3.8.0 (trunk 256945) (based on LLVM 3.8.0svn)
>> Target: armv6--freebsd11.0-gnueabi
>> Thread model: posix
>> InstalledDir: /usr/bin
>> "/usr/bin/ld" --eh-frame-hdr -Bshareable --hash-style=both --enable-new-dtags -o .libs/libgdk-x11-2.0.so.0.2400.29 /usr/lib/crti.o /usr/lib/crtbeginS.o -L/usr/local/lib -L/usr/lib .libs/gdk.o .libs/gdkapplaunchcontext.o .libs/gdkcairo.o .libs/gdkcolor.o .libs/gdkcursor.o .libs/gdkdisplay.o .libs/gdkdisplaymanager.o .libs/gdkdnd.o .libs/gdkdraw.o .libs/gdkevents.o .libs/gdkfont.o .libs/gdkgc.o .libs/gdkglobals.o .libs/gdkimage.o .libs/gdkkeys.o .libs/gdkkeyuni.o .libs/gdkoffscreenwindow.o .libs/gdkpango.o .libs/gdkpixbuf-drawable.o .libs/gdkpixbuf-render.o .libs/gdkpixmap.o .libs/gdkpolyreg-generic.o .libs/gdkrectangle.o .libs/gdkregion-generic.o .libs/gdkrgb.o .libs/gdkscreen.o .libs/gdkselection.o .libs/gdkvisual.o .libs/gdkwindow.o .libs/gdkwindowimpl.o .libs/gdkenumtypes.o .libs/gdkmarshalers.o --whole-archive x11/.libs/libgdk-x11.a --no-whole-archive -lpangocairo-1.0 -lpango-1.0 -lgio-2.0 -lfontconfig -lfreetype -lXrender -lXinerama -lXi -lXrandr -lXcursor -lXcomposite -lXdamage -lXfixes -lgdk_pixbuf-2.0 -lgobject-2.0 -lglib-2.0 -lintl -lcairo -lpthread -lX11 -lXext -lm -soname libgdk-x11-2.0.so.0 -version-script .libs/libgdk-x11-2.0.so.0.2400.29-ver -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtendS.o /usr/lib/crtn.o
>> /usr/bin/ld: .libs/gdkcairo.o(.text+0x61c): unresolvable R_ARM_MOVW_ABS_NC relocation against symbol `g_free'
>> /usr/bin/ld: final link failed: Nonrepresentable section on output
>> clang: error: linker command failed with exit code 1 (use -v to see invocation)
>> Makefile:1098: recipe for target 'libgdk-x11-2.0.la' failed
>> gmake[6]: *** [libgdk-x11-2.0.la] Error 1
>> gmake[6]: Leaving directory '/usr/obj/portswork/usr/ports/x11-toolkits/gtk20/work/gtk+-2.24.29/gdk'
>> Makefile:1238: recipe for target 'all-recursive' failed
>> gmake[5]: *** [all-recursive] Error 1
>> gmake[5]: Leaving directory '/usr/obj/portswork/usr/ports/x11-toolkits/gtk20/work/gtk+-2.24.29/gdk'
>> Makefile:1018: recipe for target 'all' failed
>> gmake[4]: *** [all] Error 2
>> gmake[4]: Leaving directory '/usr/obj/portswork/usr/ports/x11-toolkits/gtk20/work/gtk+-2.24.29/gdk'
>> Makefile:729: recipe for target 'all-recursive' failed
>> gmake[3]: *** [all-recursive] Error 1
>> gmake[3]: Leaving directory '/usr/obj/portswork/usr/ports/x11-toolkits/gtk20/work/gtk+-2.24.29'
>> Makefile:621: recipe for target 'all' failed
>> gmake[2]: *** [all] Error 2
>> gmake[2]: Leaving directory '/usr/obj/portswork/usr/ports/x11-toolkits/gtk20/work/gtk+-2.24.29'
>> ===> Compilation failed unexpectedly.
>> Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
>> the maintainer.
>> *** Error code 1
>
>
> Where the prior activity to produce .libs/gdkcairo.o was:
>
>> /bin/sh ../libtool --tag=CC --mode=compile /usr/bin/clang -v -target armv6--freebsd11.0-gnueabi -march=armv7-a -mcpu=cortex-a7 -mfloat-abi=softfp -mno-unaligned-access -DHAVE_CONFIG_H -I. -I.. -DG_LOG_DOMAIN=\"Gdk\" -DGDK_COMPILATION -I.. -I.. -I../gdk -DG_DISABLE_CAST_CHECKS -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -I/usr/local/include -I/usr/local/include/pango-1.0 -I/usr/local/include/cairo -I/usr/local/include/pixman-1 -I/usr/local/include/freetype2 -I/usr/local/include/libdrm -I/usr/local/include/libpng16 -I/usr/local/include/gio-unix-2.0/ -I/usr/local/include/gdk-pixbuf-2.0 -pthread -D_THREAD_SAFE -I/usr/local/include -DG_DISABLE_SINGLE_INCLUDES -DATK_DISABLE_SINGLE_INCLUDES -DGDK_PIXBUF_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_SINGLE_INCLUDES -I/usr/local/include -D_THREAD_SAFE -pipe -mfloat-abi=softfp -g -fno-strict-aliasing -Wall -MT gdkcairo.lo -MD -MP -MF .deps/gdkcairo.Tpo -c -o gdkcairo.lo gdkcairo.c
>
> . . .
>> "/usr/bin/clang" -cc1 -triple armv7--freebsd11.0-gnueabi -emit-obj -mrelax-all -disable-free -main-file-name gdkcairo.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -relaxed-alias
>> ing -masm-verbose -mconstructor-aliases -target-cpu cortex-a7 -target-feature +soft-float-abi -target-feature +strict-align -target-abi aapcs-linux -mfloat-abi soft -v -dwarf-column-info -debug-info-k
>> ind=standalone -dwarf-version=2 -debugger-tuning=gdb -coverage-file /usr/obj/portswork/usr/ports/x11-toolkits/gtk20/work/gtk+-2.24.29/gdk/gdkcairo.c -resource-dir /usr/bin/../lib/clang/3.8.0 -dependen
>> cy-file .deps/gdkcairo.Tpo -sys-header-deps -MP -MT gdkcairo.lo -D HAVE_CONFIG_H -I . -I .. -D "G_LOG_DOMAIN=\"Gdk\"" -D GDK_COMPILATION -I .. -I .. -I ../gdk -D G_DISABLE_CAST_CHECKS -I /usr/local/in
>> clude/glib-2.0 -I /usr/local/lib/glib-2.0/include -I /usr/local/include -I /usr/local/include/pango-1.0 -I /usr/local/include/cairo -I /usr/local/include/pixman-1 -I /usr/local/include/freetype2 -I /u
>> sr/local/include/libdrm -I /usr/local/include/libpng16 -I /usr/local/include/gio-unix-2.0/ -I /usr/local/include/gdk-pixbuf-2.0 -D _THREAD_SAFE -I /usr/local/include -D G_DISABLE_SINGLE_INCLUDES -D AT
>> K_DISABLE_SINGLE_INCLUDES -D GDK_PIXBUF_DISABLE_SINGLE_INCLUDES -D GTK_DISABLE_SINGLE_INCLUDES -I /usr/local/include -D _THREAD_SAFE -Wall -fdebug-compilation-dir /usr/obj/portswork/usr/ports/x11-tool
>> kits/gtk20/work/gtk+-2.24.29/gdk -ferror-limit 19 -fmessage-length 200 -pthread -fallow-half-arguments-and-returns -fno-signed-char -fobjc-runtime=gnustep -fdiagnostics-show-option -fcolor-diagnostics
>> -o gdkcairo.o -x c gdkcairo.c
> . . .
>> libtool: compile: mv -f "gdkcairo.o" ".libs/gdkcairo.o"
>
>
===
Mark Millard
markmi at dsl-only.net
On 2016-Jan-10, at 3:55 AM, Mark Millard <markmi at dsl-only.net> wrote:
>
>
> On 2016-Jan-9, at 10:55 AM, Ian Lepore <ian at freebsd.org> wrote:
>>
>> On Sat, 2016-01-09 at 15:03 +0100, Dimitry Andric wrote:
>>> On 09 Jan 2016, at 04:46, Mark Millard <markmi at 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
>
>
> Context: When I build I normally build lldb and the like as well, even using WITH_CLANG_EXTRAS= .
>
> 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=arm 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__hidden_allocatorIS6_EEE21__push_back_slow_pathIS6_EEvOT_':
>> /usr/src/lib/libc++/../../contrib/libc++/src/thread.cpp:(.text._ZNSt3__16vectorINS_4pairIPNS_18condition_variableEPNS_5mutexEEENS_18__hidden_allocatorIS6_EEE21__push_back_slow_pathIS6_EEvOT_[_ZNSt3__16vectorINS_4pairIPNS_18condition_variableEPNS_5mutexEEENS_18__hidden_allocatorIS6_EEE21__push_back_slow_pathIS6_EEvOT_]+0x30): relocation truncated to fit: R_ARM_CALL against symbol `std::__1::__vector_base_common<true>::__throw_length_error() const' defined in .text._ZNKSt3__120__vector_base_commonILb1EE20__throw_length_errorEv[_ZNKSt3__120__vector_base_commonILb1EE20__throw_length_errorEv] section in /usr/obj/clang/arm.armv6/usr/src/usr.bin/clang/lldb/../../../lib/clang/liblldbCore/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__16vectorIPNS_17__assoc_sub_stateENS_18__hidden_allocatorIS2_EEE21__push_back_slow_pathIRKS2_EEvOT_[_ZNSt3__16vectorIPNS_17__assoc_sub_stateENS_18__hidden_allocatorIS2_EEE21__push_back_slow_pathIRKS2_EEvOT_]+0x30): relocation truncated to fit: R_ARM_CALL against symbol `std::__1::__vector_base_common<true>::__throw_length_error() const' defined in .text._ZNKSt3__120__vector_base_commonILb1EE20__throw_length_errorEv[_ZNKSt3__120__vector_base_commonILb1EE20__throw_length_errorEv] section in /usr/obj/clang/arm.armv6/usr/src/usr.bin/clang/lldb/../../../lib/clang/liblldbCore/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<char>::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<true>::__throw_length_error() const' defined in .text._ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv[_ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv] section in /usr/obj/clang/arm.armv6/usr/src/usr.bin/clang/lldb/../../../lib/clang/liblldbCore/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<true>::__throw_length_error() const' defined in .text._ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv[_ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv] section in /usr/obj/clang/arm.armv6/usr/src/usr.bin/clang/lldb/../../../lib/clang/liblldbCore/liblldbCore.a(CxaDemangle.o)
>
>> /usr/obj/clang/arm.armv6/usr/src/tmp/usr/lib/libc++.a(locale.o): In function `std::__1::collate_byname<char>::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<true>::__throw_length_error() const' defined in .text._ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv[_ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv] section in /usr/obj/clang/arm.armv6/usr/src/usr.bin/clang/lldb/../../../lib/clang/liblldbCore/liblldbCore.a(CxaDemangle.o)
>
>> /usr/obj/clang/arm.armv6/usr/src/tmp/usr/lib/libc++.a(locale.o): In function `std::__1::collate_byname<wchar_t>::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<true>::__throw_length_error() const' defined in .text._ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv[_ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv] section in /usr/obj/clang/arm.armv6/usr/src/usr.bin/clang/lldb/../../../lib/clang/liblldbCore/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<true>::__throw_length_error() const' defined in .text._ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv[_ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv] section in /usr/obj/clang/arm.armv6/usr/src/usr.bin/clang/lldb/../../../lib/clang/liblldbCore/liblldbCore.a(CxaDemangle.o)
>
>> /usr/obj/clang/arm.armv6/usr/src/tmp/usr/lib/libc++.a(locale.o): In function `std::__1::collate_byname<wchar_t>::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<true>::__throw_length_error() const' defined in .text._ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv[_ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv] section in /usr/obj/clang/arm.armv6/usr/src/usr.bin/clang/lldb/../../../lib/clang/liblldbCore/liblldbCore.a(CxaDemangle.o)
>
>> /usr/obj/clang/arm.armv6/usr/src/tmp/usr/lib/libc++.a(locale.o): In function `std::__1::collate<char>::do_transform(char const*, char const*) const':
>> /usr/src/lib/libc++/../../contrib/libc++/src/locale.cpp:(.text._ZNKSt3__17collateIcE12do_transformEPKcS3_[_ZNKSt3__17collateIcE12do_transformEPKcS3_]+0x34): relocation truncated to fit: R_ARM_CALL against symbol `std::__1::__basic_string_common<true>::__throw_length_error() const' defined in .text._ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv[_ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv] section in /usr/obj/clang/arm.armv6/usr/src/usr.bin/clang/lldb/../../../lib/clang/liblldbCore/liblldbCore.a(CxaDemangle.o)
>
>> /usr/obj/clang/arm.armv6/usr/src/tmp/usr/lib/libc++.a(locale.o): In function `std::__1::collate<wchar_t>::do_transform(wchar_t const*, wchar_t const*) const':
>> /usr/src/lib/libc++/../../contrib/libc++/src/locale.cpp:(.text._ZNKSt3__17collateIwE12do_transformEPKwS3_[_ZNKSt3__17collateIwE12do_transformEPKwS3_]+0x38): relocation truncated to fit: R_ARM_CALL against symbol `std::__1::__basic_string_common<true>::__throw_length_error() const' defined in .text._ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv[_ZNKSt3__121__basic_string_commonILb1EE20__throw_length_errorEv] section in /usr/obj/clang/arm.armv6/usr/src/usr.bin/clang/lldb/../../../lib/clang/liblldbCore/liblldbCore.a(CxaDemangle.o)
>
>> /usr/obj/clang/arm.armv6/usr/src/tmp/usr/lib/libc++.a(locale.o): In function `std::__1::num_put<char, std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > >::do_put(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, std::__1::ios_base&, char, long) const':
>> /usr/src/lib/libc++/../../contrib/libc++/src/locale.cpp:(.text._ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_putES4_RNS_8ios_baseEcl[_ZNKSt3__17num_putIcNS_19ostreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_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
>> ===================================================================
>> --- 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
>>
>
More information about the freebsd-toolchain
mailing list