Building FreeBSD with LTO

KPECT kpect at protonmail.com
Tue Feb 5 14:11:48 UTC 2019


Hello guys.

I've a question regarding building the world with LTO enabled on FreeBSD/amd64 12.0-STABLE. Has anyone managed to to that?
At the moment I'm unable to build neither apps nor kernel. Here's what I have set up:

$ ll /usr/bin/ld
lrwxr-xr-x  1 root  wheel  uarch 6 14 янв.  12:53 /usr/bin/ld -> ld.lld

$ cat /etc/make.conf
CPUTYPE?=ivybridge
CFLAGS+=-O2 -fomit-frame-pointer -momit-leaf-frame-pointer -flto
COPTFLAGS+=-O2 -fomit-frame-pointer -momit-leaf-frame-pointer -flto
AR=/usr/bin/llvm-ar
ARFLAGS=cr
NM=/usr/bin/llvm-nm
RANLIB=/usr/bin/llvm-ranlib
RANLIBFLAGS=

During the linking of kernel I get following error:
linking kernel
ld: error: ld-temp.o:(function dmu_get_recursive_snaps_nvl): relocation R_X86_64_32 out of range: 18446744071575402064 is not in [0, 4294967295]
ld: error: ld-temp.o:(function dmu_get_recursive_snaps_nvl): relocation R_X86_64_32 out of range: 18446744071565769200 is not in [0, 4294967295]
ld: error: ld-temp.o:(function init_TSC): relocation R_X86_64_32 out of range: 18446744071573270148 is not in [0, 4294967295]
ld: error: ld-temp.o:(function dmu_get_recursive_snaps_nvl): relocation R_X86_64_32 out of range: 18446744071575402064 is not in [0, 4294967295]
ld: error: ld-temp.o:(function dsl_check_snap_cb): relocation R_X86_64_32 out of range: 18446744071573558911 is not in [0, 4294967295]
ld: error: ld-temp.o:(function dsl_check_snap_cb): relocation R_X86_64_32 out of range: 18446744071575402064 is not in [0, 4294967295]
ld: error: ld-temp.o:(function init_TSC): relocation R_X86_64_32 out of range: 18446744071573308189 is not in [0, 4294967295]
...
ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
*** [kernel] Error code 1

If I build the kernel with -fPIC option and LDFLAGS+=--pie -z notext , kernel does compile, but is not bootable. AFAIK it shouldn't be built like that.
Someone knows how to solve the issue?

Best regards,
Sergey P.

Mail: kpect at protonmail.com
Skype: l0st_in_0blivi0n


More information about the freebsd-amd64 mailing list