I’m on Ubuntu 24.04 and I’ve found that I need to recompile gcc/gfortan to use position independent code to compile the code of another library (not publicly available).
I’ve found that:
../gcc/configure CFLAGS="-g -O2 -fPIC" --disable-bootstrap --enable-languages=c,c++,fortran --disable-multilib
Works. However, using:
../gcc/configure --disable-bootstrap --enable-languages=c,c++,fortran --disable-multilib --enable-host-shared --enable-host-pie
Causes the problem compiling the other software project
/usr/bin/ld: /usr/local/lib64/libgfortran.a(transfer.o): relocation R_X86_64_32S against `.rodata.bswap_array' can not be used when making a shared object; recompile with -fPIC
I’m confused because I thought the —enable-host-shared would have the effect that setting CFLAGS has. What have I misunderstood?