We have encountered an error when building FreeBSD with the latest binutils release. I did a bisection and it appears to be a regression caused by the commit: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=04b865dc2ede2b8ca8c60f0487a179eb97895fee Here's the relevant snippet from the build log: /usr/local/bin/riscv64-unknown-freebsd13.0-gcc --sysroot=/usr/home/mitchell/riscv/obj/usr/home/mitchell/freebsd/riscv.riscv64/tmp -B/usr/local/riscv64-unknown-freebsd13.0/bin/ -O2 -pipe -march=rv64imafdc -mabi=lp64d -I. -I/usr/home/mitchell/freebsd/usr.sbin/jail -DINET6 -DINET -g -std=gnu99 -Wno-format-zero-length -fstack-protector-strong -Wsystem-headers -Werror -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 -Wno-error=address -Wno-error=array-bounds -Wno-error=attributes -Wno-error=bool-compare -Wno-error=cast-align -Wno-error=clobbered -Wno-error=deprecated-declarations -Wno-error=enum-compare -Wno-error=extra -Wno-error=inline -Wno-error=logical-not-parentheses -Wno-error=strict-aliasing -Wno-error=uninitialized -Wno-error=unused-but-set-variable -Wno-error=unused-function -Wno-error=unused-value -Wno-error=misleading-indentation -Wno-error=nonnull-compare -Wno-error=shift-negative-value -Wno-error=tautological-compare -Wno-error=unused-const-variable -Wno-error=bool-operation -Wno-error=deprecated -Wno-error=expansion-to-defined -Wno-error=format-overflow -Wno-error=format-truncation -Wno-error=implicit-fallthrough -Wno-error=int-in-bool-context -Wno-error=memset-elt-size -Wno-error=noexcept-type -Wno-error=nonnull -Wno-error=pointer-compare -Wno-error=stringop-overflow -Wno-error=aggressive-loop-optimizations -Wno-error=cast-function-type -Wno-error=catch-value -Wno-error=multistatement-macros -Wno-error=restrict -Wno-error=sizeof-pointer-memaccess -Wno-error=stringop-truncation -o jail.full jail.o command.o config.o state.o jaillex.o jailparse.o -ljail -lkvm -lutil jailparse.o: in function `yyparse': /usr/home/mitchell/freebsd/usr.sbin/jail/jailparse.y:75:(.text+0xfe): relocation truncated to fit: R_RISCV_GPREL_I against `.LANCHOR2' collect2: error: ld returned 1 exit status *** Error code 1 Stop.
This is a code size optimization, primarily useful for deeply embedded targets that care the most about code size. It is OK to disable it for unix targets. There was one regression reported against linux that was fixed by this patch. 2019-08-01 Ilia Diachkov <ilia.diachkov@optimitech.com> * elfnn-riscv.c (_bfd_riscv_relax_lui): Set lui relax safety area to two pages in relro presence. Do you have this patch in your binutils release? This doesn't appear to be directly relevant to your problem, but maybe we need a similar fix elsewhere. Otherwise, I don't have a riscv freebsd system for testing, so I'm probably going to have trouble reproducing this. I will have to try to set up a usable riscv freebsd system, but I have a lot of other things to do, so it might take some time.
Hi Mitchell, Could this problem be reproduced for now? We get the similar report in the following PR recently, https://sourceware.org/bugzilla/show_bug.cgi?id=27566 And I'm working on this, just now interrupted by other things. Please let me know if the FreeBSD still fails, thanks!