[fpc-pascal] Cannot build fpc on Raspberry Pi4B running PiOS 64 bit (aarch64 Linux)

Bo Berglund bo.berglund at gmail.com
Sat Nov 18 11:32:30 CET 2023


On Fri, 17 Nov 2023 11:27:53 +0100, Sven Barth via fpc-pascal
<fpc-pascal at lists.freepascal.org> wrote:

>Bo Berglund via fpc-pascal <fpc-pascal at lists.freepascal.org> schrieb am
>Do., 16. Nov. 2023, 08:19:
>
>> From the Lazarus list:
>>
>> >Just a quick follow-up here:
>> >It seems like the fpc sources have not been updated with the solution to
>> the bug
>> >discussed here:
>> >
>> >https://gitlab.com/freepascal.org/fpc/source/-/issues/39295
>> >
>> >This causes the build of Lazarus using fpcupdeluxe with the latest fpc
>> 3.2.2 to
>> >fail because of a problem with __libc_csu_init during linking.
>> >
>> >Apparently it is fixed in non-released sources of fpc which we are waiting
>> >for...
>>
>> The GitLab ticket was opened 2 years ago:
>> https://gitlab.com/freepascal.org/fpc/source/-/issues/39295
>>
>> According to a post on the Lazarus forum the fix that solves the fatal
>> error
>> during fpc build on 64 bit aarch64 Linux (like on Raspberry Pi4B with
>> Pi-OS 64
>> bit) has *not* been ported to the target aarch64 Linux, only to powerpc.
>>
>>
>> https://forum.lazarus.freepascal.org/index.php/topic,34645.msg496883.html#msg496883
>
>
>Wrong. Who said that the solution consisted only of a single commit?
>
>
>>
>> So I am sitting here unable to run Lazarus/FPC on the RPi4B with the
>> latest 64
>> bit Pi-OS...
>>
>> Is any solution to this problem in the works?
>> I have tried every fpc source release from 3.2.2 up to trunk with the
>> exact same
>> result (here from a build try on trunk):
>>
>> /bin/ld:
>> /home/bosse/devtools/lazarus/2.2.6/fpcsrc/rtl/units/aarch64-linux/cprt0.o:
>> in
>> function `_start':
>> (.text+0x54): undefined reference to `__libc_csu_init'
>> /bin/ld: (.text+0x58): undefined reference to `__libc_csu_init'
>> /bin/ld: (.text+0x5c): undefined reference to `__libc_csu_fini'
>> /bin/ld: (.text+0x60): undefined reference to `__libc_csu_fini'
>> make[1]: *** [Makefile:2682: packages_smart] Error 2
>> make: *** [Makefile:2837: build-stamp.aarch64-linux] Error 2
>> fpmake.pp(60) Error: Error while linking
>> fpmake.pp(60) Fatal: There were 1 errors compiling module, stopping
>> Fatal: Compilation aborted
>>
>> I believe that a lot of people will experience this since the 64 bit OS on
>> RPi4
>> has been recently released as the *recommended* version on that popular
>> platform...
>>
>
>I can not reproduce. On a Raspberry OS 10 64-bit I downloaded FPC 3.2.2 for
>aarch64-linux from SourceForge as well as the sources of both 3.2.3 and
>3.3.1 from GitLab.
>I install 3.2.2, setup PATH to find the compiler and simply do the
>following for each 3.2.3 and 3.3.1 (in their corresponding source
>directories):
>
>make all FPMAKEOPT="-T 4" -j 4
>make install INSTALL_PREFIX=/path/for/fpc/<version> - j 4
>cd /path/for/fpc/<version>/bin
>ln -s .. /lib/fpc/<version>/ppca64 ppca64
>
>(the -T and -j are simply for parallel compilation)
>
>Both 3.2.3 and 3.3.1 (don't forget to set PATH correctly!) can successfully
>compile a hello world program that links against the C library (in my case
>by using the cthreads unit) while 3.2.2 can not (as expected).
>

Hi Sven,
I realized that my tests were not really isolating the problem tp fpc...
I was using fpcupdeluxe for aarch64 to install the Lazarus environment.
That always failed with the error I showed.


Today after realizing that I did the following on an RPi4B where I have used apt
to install the fpc compiler so I could use that as the seed compiuler to build
from sources.

Then I retrieved the fpc 3.2.2 sources from GitLab and extracted them into dir
$home/devtools/fpc/3.2.2

Next I ran these two commands in the 3.2.2 directory:
make clean FPC="/usr/bin/ppca64"  This succeeeded
time make all FPC="/usr/bin/ppca64" This ran for 5m23s and then displayed:

make[3]: Leaving directory '/home/bosse/devtools/fpc/3.2.2/packages/fpmkunit'
/home/bosse/devtools/fpc/3.2.2/compiler/ppca64 fpmake.pp
-Fu/home/bosse/devtools/fpc/3.2.2/packages/fpmkunit/units_bs/aarch64-linux
-Fu/home/bosse/devtools/fpc/3.2.2/rtl/units/aarch64-linux
Free Pascal Compiler version 3.2.2 [2023/11/18] for aarch64
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Linux for AArch64
Compiling fpmake.pp
fpmake.pp(16,3) Note: Local variable "T" is assigned but never used
Assembling fpmake
Linking fpmake
/usr/bin/ld: /home/bosse/devtools/fpc/3.2.2/rtl/units/aarch64-linux/cprt0.o: in
function `_start':
(.text+0x54): undefined reference to `__libc_csu_init'
/usr/bin/ld: (.text+0x58): undefined reference to `__libc_csu_init'
/usr/bin/ld: (.text+0x5c): undefined reference to `__libc_csu_fini'
/usr/bin/ld: (.text+0x60): undefined reference to `__libc_csu_fini'
fpmake.pp(60) Error: Error while linking
fpmake.pp(60) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
make[2]: *** [Makefile:1719: fpmake] Error 1
make[2]: Leaving directory '/home/bosse/devtools/fpc/3.2.2/packages'
make[1]: *** [Makefile:2682: packages_smart] Error 2
make[1]: Leaving directory '/home/bosse/devtools/fpc/3.2.2'
make: *** [Makefile:2837: build-stamp.aarch64-linux] Error 2

Next I downloaded sources for fpc 3.2.3 and repeated the above only to get the
same result:

Linking fpmake
/usr/bin/ld: /home/bosse/devtools/fpc/3.2.3/rtl/units/aarch64-linux/cprt0.o: in
function `_start':
(.text+0x54): undefined reference to `__libc_csu_init'
/usr/bin/ld: (.text+0x58): undefined reference to `__libc_csu_init'
/usr/bin/ld: (.text+0x5c): undefined reference to `__libc_csu_fini'
/usr/bin/ld: (.text+0x60): undefined reference to `__libc_csu_fini'
fpmake.pp(60) Error: Error while linking
fpmake.pp(60) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
make[2]: *** [Makefile:1719: fpmake] Error 1
make[2]: Leaving directory '/home/bosse/devtools/fpc/3.2.3/packages'
make[1]: *** [Makefile:2682: packages_smart] Error 2
make[1]: Leaving directory '/home/bosse/devtools/fpc/3.2.3'
make: *** [Makefile:2837: build-stamp.aarch64-linux] Error 2


So it seems like the error I described is there also with a command line build
as shown. Something in my envoronment might be off, but I don't know what. I
have just installed the operating system and used apt to get a working fpc
compiler so I could install the latest Lazarus, but I really usually want to
have both fpc and lazarus in my user space rather as system wide tools.
That is why I want to build fpc from sources. I have done this for 10 years or
so...

What do you mean exactly when you say "don't forget to set PATH correctly!"

PATH is usually set by the system, right?
But I specified to use the apt installed compiler as the seed for compiling fpc,
is that incorrect?

Currently it looks like this:
/home/bosse/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games


-- 
Bo Berglund
Developer in Sweden



More information about the fpc-pascal mailing list