Solved Unable to compile custom kernel cam_iosched error recompile with -fPIC

Whenever I try to compile my custom kernel (I have commented out some useless things from GENERIC) I get:

Code:
ld: error: relocation R_X86_64_32S cannot be used against local symbol; recompile with -fPIC
>>> defined in cam_iosched.o
>>> referenced by cam_iosched.c:1171 (/usr/src/sys/cam/cam_iosched.c:1171)
>>>                        cam_iosched.o:(cam_iosched_sysctl_init)

ld: error: too many errors emitted, stopping now
*** Error code 1

Stop.
make: stopped in /usr/src

I have appended the following to /etc/make.conf
Code:
CFLAGS+= -fPIC
CXXFLAGS+= -fPIC

I have also tried appending the following to /etc/make.conf
Code:
CFLAGS+= -PIC
CXXFLAGS+= -PIC

and I still get the same error as before. I tried to append
Code:
LDFLAGS+= -fPIC
and I also tried
Code:
LDFLAGS+= -PIC
but when I reached the same point where I got the original error, ld did not recognise that argument/option.

Anybody got any idea?
 
I set make.conf flags yesterday and I realised now that they were not default generated. I removed PIE flags and it compiled perfectly! In a perfect world I'd like to compile the kernel with pie flag enabled but I guess that will be for some other time or post :)
 
Does the kernel need special flags ?
For the default kernel you set in sysctl.conf
Code:
kern.elf64.aslr.pie_enable=1
kern.elf32.aslr.pie_enable=1
 
Back
Top