The makefile I attach comes from the source directory of a smooth particle hydrodynamics code. When I fix the number of particles to 128**3 particles, my code compiles fine. Now that I need to use 256**3 I get a relocation truncated to fit: R_X86_64_PC32 against symbol ... defined in COMMON section in ...
.
I have tried several things I found online:
- using the set stacksize unlimited command
- adding the
-mcmodel=large
flag - adding the
-fPIC
flag
none of these seem to work. I am also aware of the https://www.technovelty.org/c/relocation-truncated-to-fit-wtf.html article, but I do not understand what I am supposed to do.
My makefile: (I attach part of it)
include ../makeflags
CPP=g++
CPPFLAGS = $(OPTIONS) -D$(SYS) -mcmodel=large -traceback
.SUFFIXES: .F
OBJ = hydra.o accel.o ahtime.o clist.o cool.o createcool.o dumpdata.o
.f.o:
$(F77) $(FLAGS) -c $<
.F.o:
@ if test $(SYS) = ibm ; then \
echo "$(CPP) -P -C $(CPPFLAGS) $< > tmp/$*.f";\
$(CPP) -P -C $(CPPFLAGS) $< > tmp/$*.f;\
echo "$(F77) $(FLAGS) -c tmp/$*.f";\
$(F77) $(FLAGS) -c tmp/$*.f;\
elif test $(SYS) = f2c ; then \
echo "$(CPP) -P -C $(CPPFLAGS) $< > tmp/$*.f";\
$(CPP) -P -C $(CPPFLAGS) $< > tmp/$*.f;\
echo "$(F77) $(FLAGS) -c tmp/$*.f";\
$(F77) $(FLAGS) -c tmp/$*.f;\
else \
echo "$(F77) $(FLAGS) $(CPPFLAGS) -c $<";\
$(F77) $(FLAGS) $(CPPFLAGS) -c $<;\
fi
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
hydra: tmp $(OBJ)
echo $(FLAGS)
$(F77) -o hydra $(FLAGS) $(OBJ) $(LIBS)
mv hydra $(RUNDIR)
new_options:
touch *.F
make
clean:
/bin/rm -rf *.o tmp
system.o: system.$(SYS)
@ if test $(SYS) = f2c ; then \
cp system.f2c system.c; \
$(CC) -c $(CPPFLAGS) $(CFLAGS) system.c; \
else \
cp system.$(SYS) system.f; \
$(F77) $(FLAGS) -c system.f; \
fi
tmp:
@ test -d $@ || mkdir $@
@ for i in `ls *.inc` ; do \
(cd tmp ; ln -s ../$$i $$i ) ; \
done
My flags file: (I attach part of it)
SHELL = /bin/sh
# set SYS to one of: sun, dec, cray, sgi, ibm, hpux, f2c, g77
SYS = g77
# choose appropriate names for compilers
F77 = /usr/bin/f77
CC = cc
CPP = /lib/cpp
# compilation flags for linux box
FLAGS= -O2
FLAGS= -O2 -fomit-frame-pointer -m486
FLAGS= -Wall -g
FLAGS= -mcmodel=large
# For cosmic test use
UNITS_OPTIONS =
OTHER_OPTIONS =
OPTIONS = $(FORCE_OPTIONS) $(UNITS_OPTIONS) $(OTHER_OPTIONS)
I understand this is some memory problem, which, for some reason is not resolved with the options I have described above. Please bare in mind I cannot mess with the variable definitions in the code (e.g. change COMMON blocks etc.), because they are linked to many programs and this will cause an overall failure of compilation. The exact error I am receiving is:
/home/user/Downloads/Stage/hydra4.0/src/hydra.F:1:(.text+0x14): relocation truncated to fit: R_X86_64_PC32 against symbol `param_' defined in COMMON section in hydra.o
for many component programs, not only for hydra.o
.