build fails on undefined references in rtl/linux/arm/cprt0.as
Original Reporter info from Mantis: mavhw
-
Reporter name: Marco Voetberg
Original Reporter info from Mantis: mavhw
- Reporter name: Marco Voetberg
Description:
I'm using a Cubox with Ubuntu 12.10 (armhfp). There is a fp-compiler-2.6.0 package available that you can install with apt-get. But this version is unable to compile anything but pure pascal applications. The moment you try and dynamically link a library (for instance libmysqlclient) linking fails.
I also tried the fpc-2.6.2.arm-linux.tar. But this has the same issue.
So I tried to build a compiler myself. But again the same issue. This time while linking the compiler on the target device itself. Using svn revision 23856 build of the compiler fails on missing declarations (_init, _fini) in rtl/linux/arm/cprt0.as.
cprt0.o: In function _haltproc_eabi':<br/> (.text+0x88): undefined reference to
_fini'
cprt0.o: In function _haltproc_eabi':<br/> (.text+0x90): undefined reference to
_init'
SOLUTION
I investigated this problem and found a likely fix for this. I compared rtl/linux/arm/cprt0.as with rtl/linux/arm/ucprt0.as. These 2 files follow along similar lines but ucprt0.as contains the missing definitions.
I copied the missing lines from ucprt0.as and was able to build the compiler.
I can also report that my testapplication for libmysqlclient compiles and now works perfectly. Same for other testbenches that use libxml2, libxslt and a Synapse HTTPS testapplication (using libssl and libcrypto).
svn diff output:
--- rtl/linux/arm/cprt0.as (revision 23856)
+++ rtl/linux/arm/cprt0.as (working copy)
@@ -44,6 +44,11 @@
.text
.globl _start
.type _start,#function
+ .type _init,%function
+ .type _fini,%function
+ .weak _init
+ .weak _fini
+
_start:
/* Clear the frame pointer since this is the outermost frame. */
mov fp, #0
Steps to reproduce:
On another linux machine (i686)
svn checkout http://svn.freepascal.org/svn/fpc/trunk fpc
BINUTILS=binutils-2.23.1
wget http://ftp.gnu.org/gnu/binutils/$BINUTILS.tar.bz2
tar jxvf $BINUTILS.tar.bz2
cd $BINUTILS
./configure --prefix=/opt/binutils-arm-linux-gnueabihf --target=arm-linux-gnueabihf --with-gnu-as --with-gnu-ld
make
make install
ln -s /opt/binutils-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-as /opt/binutils-arm-linux-gnueabihf/bin/arm-linux-as
ln -s /opt/binutils-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-ld /opt/binutils-arm-linux-gnueabihf/bin/arm-linux-ld
cd ../fpc
export PATH=/opt/binutils-arm-linux-gnueabihf/bin:$PATH
make all PREFIX=/opt/fpc-arm OS_TARGET=linux CPU_TARGET=arm OPT="-dFPC_ARMHF"
Then copy the newly build ppcarm to the target device (a Cubox in my case)
On the target device:
svn checkout http://svn.freepascal.org/svn/fpc/trunk fpc-svn
cd fpc-svn
apt-get install make
ln -s /lib/arm-linux-gnueabihf/libpthread.so.0 /lib/arm-linux-gnueabihf/libpthread.so
ln -s /lib/arm-linux-gnueabihf/libdl.so.2 /lib/arm-linux-gnueabihf/libdl.so
ln -s /lib/arm-linux-gnueabihf/libc.so.6 /lib/arm-linux-gnueabihf/libc.so
make clean all OVERRIDEVERSIONCHECK=1 PP=/root/ppcarm PREFIX="/opt/fpc-svn" OPT="-dFPC_ARMHF -O-"
Linking fails here with:
cprt0.o: In function _haltproc_eabi':<br/> (.text+0x88): undefined reference to
_fini'
cprt0.o: In function _haltproc_eabi':<br/> (.text+0x90): undefined reference to
_init'
Fix the cprt0.as as described.
make clean all OVERRIDEVERSIONCHECK=1 PP=/root/src/ppcarm PREFIX="/usr/local" OPT="-dFPC_ARMHF -O-"
Gives error. __missing_command_DATA2INC: Command not found
data2inc has been build by this time... So copy it..
cp utils/data2inc /usr/local/bin/
try again
make all OVERRIDEVERSIONCHECK=1 PP=/root/src/ppcarm PREFIX="/usr/local" OPT="-dFPC_ARMHF -O-"
ok!
make install PP=/root/src/ppcarm PREFIX="/usr/local" OPT="-dFPC_ARMHF -O-"
ok!
make config file
/usr/local/bin/fpcmkcfg -d basepath=/usr/local/lib/fpc/2.7.1/ -o /etc/fpc.cfg
ok!
Mantis conversion info:
- Mantis ID: 24056
- OS: linux
- OS Build: 3.5.7
- Platform: Cubox
- Version: 2.7.1