Failed to build with external toolchain
Warner Losh
imp at bsdimp.com
Wed Mar 25 03:39:33 UTC 2015
> On Mar 24, 2015, at 9:18 PM, Craig Rodrigues <rodrigc at FreeBSD.org> wrote:
>
> On Sat, Mar 7, 2015 at 3:48 PM, Dimitry Andric <dim at freebsd.org> wrote:
>
>> On 07 Mar 2015, at 21:12, Craig Rodrigues <rodrigc at FreeBSD.org> wrote:
>>> I ran the build again and this time I am getting errors about undefined
>>> symbol utimensat():
>>>
>>>
>> https://jenkins.freebsd.org/job/FreeBSD_HEAD_external_toolchain_gcc/14/console
>>>
>>> Any ideas?
>>
>> It's linking against the wrong libc, the one from the FreeBSD-10 host
>> system, which does not have utimensat():
>>
>> --- cp ---
>> /usr/local/bin/x86_64-portbld-freebsd10.0-gcc -isystem
>> /builds/FreeBSD_HEAD_external_toolchain_gcc/obj/builds/FreeBSD_HEAD_external_toolchain_gcc/tmp/usr/include
>> -L/builds/FreeBSD_HEAD_external_toolchain_gcc/obj/builds/FreeBSD_HEAD_external_toolchain_gcc/tmp/usr/lib
>> -O2 -pipe -DVM_AND_BUFFER_CACHE_SYNCHRONIZED -D_ACL_PRIVATE -std=gnu99
>> -fstack-protector -Wsystem-headers -Wall -Wno-format-y2k -W
>> -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes
>> -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow
>> -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wnested-externs
>> -Wredundant-decls -Wold-style-definition -Wno-pointer-sign -o cp cp.o
>> utils.o
>> [...]
>> utils.o: In function `setfile':
>> utils.c:(.text+0x83): undefined reference to `utimensat'
>> utils.c:(.text+0x1ce): undefined reference to `utimensat'
>> utils.c:(.text+0x38c): undefined reference to `utimensat'
>> collect2: error: ld returned 1 exit status
>>
>> There should probably be a --sysroot flag in there, pointing to the
>> ${WORLDTMP} built during the earlier stages.
>>
>> For some reason, this flag is not added for gcc, in Makefile.inc1. No
>> idea why that was done.
>>
>> -Dimitry
>>
>> I eliminated the problem with this patch:
>
> Index: Makefile.inc1
> ===================================================================
> --- Makefile.inc1 (revision 280353)
> +++ Makefile.inc1 (working copy)
> @@ -381,9 +381,9 @@
> TARGET_ABI?= unknown
> TARGET_TRIPLE?=
> ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
> XCFLAGS+= -target ${TARGET_TRIPLE}
> +.endif
> XCFLAGS+= --sysroot=${WORLDTMP} ${BFLAGS}
> XCXXFLAGS+= --sysroot=${WORLDTMP} ${BFLAGS}
> -.endif
> .else
> .if defined(CROSS_BINUTILS_PREFIX) && exists(${CROSS_BINUTILS_PREFIX})
> BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
>
>
> This sets --sysroot when doing CROSS_TOOLCHAIN for both clang *or* gcc.
> Right now, --sysroot is only set for clang.
>
> I did a "make universe" and "make buildworld
> CROSS_TOOLCHAIN_PREFIX=/usr/bin/"
>
> Is it OK if I commit it?
No. The in-tree gcc doesn’t grok —sysroot.
We assume that version gcc 4.2.1 is special and our in-tree compiler elsewhere,
so please add a check for that and just go ahead and duplicate those two lines.
Eg
+.else if ${COMPILER_VERSION} > 40201
+XCFLAGS+= --sysroot=${WORLDTMP} ${BFLAGS}
+XCXXFLAGS+= --sysroot=${WORLDTMP} ${BFLAGS}
.endif
Warner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/freebsd-toolchain/attachments/20150324/c31dd6a8/attachment.sig>
More information about the freebsd-toolchain
mailing list