【发布时间】:2019-11-18 20:02:02
【问题描述】:
我附上的makefile来自一个平滑粒子流体动力学代码的源目录。当我将粒子数固定为 128**3 个粒子时,我的代码编译得很好。现在我需要使用 256**3 我得到一个relocation truncated to fit: R_X86_64_PC32 against symbol ... defined in COMMON section in ...。
我已经尝试了一些我在网上找到的东西:
- 使用 set stacksize unlimited 命令
- 添加
-mcmodel=large标志 - 添加
-fPIC标志
这些似乎都不起作用。我也知道https://www.technovelty.org/c/relocation-truncated-to-fit-wtf.html 的文章,但我不明白我应该做什么。
我的makefile:(我附上一部分)
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
我的标志文件:(我附上一部分)
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)
我知道这是一些内存问题,由于某种原因,我上面描述的选项无法解决这个问题。请记住,我不能弄乱代码中的变量定义(例如更改 COMMON 块等),因为它们链接到许多程序,这将导致编译的整体失败。我收到的确切错误是:
/home/user/Downloads/Stage/hydra4.0/src/hydra.F:1:(.text+0x14):重定位被截断以适应:R_X86_64_PC32 针对 hydra.o 中 COMMON 部分中定义的符号“param_”
对于许多组件程序,不仅仅是hydra.o。
【问题讨论】:
标签: fortran relocation