linking errors compiling on aarch64 lazarus / 1-Linux ---------------------------------------------------------------------- dieselnutjob · 2022-03-27 17:01 Hi I am trying to compile lazarus for my pinebook pro (KDE on Manjaro on aarch64). I used this file Code: [Select]wget https://gitlab.com/freepascal.org/lazarus/lazarus/- /archive/main/lazarus-main.zip This is what I got (the last bit) Code: [Select]make --assume-new=lazres.pp lazres make[2]: Entering directory '/home/philip/fpc/source/lazarus- main/tools' Makefile:2956: warning: overriding recipe for target '.' Makefile:2954: warning: ignoring old recipe for target '.' /usr/local/bin/ppca64 -gl -Fu. -Fu../components/lazutils/lib/aarch64-linux -Fu../lcl/units/aarch64-linux -Fu../lcl/units/aarch64-linux/nogui -Fu/usr/local/lib/fpc/3.2.2/units/aarch64-linux/rtl -FE. -FU. -Flinclude -Fl/etc/ld.so.conf.d/*.conf -daarch64 lazres.pp Free Pascal Compiler version 3.2.2 [2021/05/23] for aarch64 Copyright (c) 1993-2021 by Florian Klaempfl and others Target OS: Linux for AArch64 Compiling lazres.pp lazres.pp(65,9) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(81,3) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(95,11) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(98,9) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(109,11) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(112,9) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(121,5) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(124,3) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(261,3) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(275,3) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(257,5) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(231,7) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(233,7) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(208,5) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(180,11) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(306,5) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(308,5) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(321,9) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(348,9) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(361,7) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined Assembling lazres Linking ./lazres lazres.pp(395) Warning: "crtbegin.o" not found, this will probably cause a linking failure lazres.pp(395) Warning: "crtend.o" not found, this will probably cause a linking failure /bin/ld: /usr/local/lib/fpc/3.2.2/units/aarch64-linux/rtl/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' lazres.pp(395) Error: Error while linking lazres.pp(395) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted make[2]: *** [Makefile:2964: lazres] Error 1 make[2]: Leaving directory '/home/philip/fpc/source/lazarus- main/tools' make[1]: *** [Makefile:3394: all] Error 2 make[1]: Leaving directory '/home/philip/fpc/source/lazarus- main/tools' make: *** [Makefile:3803: lazbuild] Error 2 any help would be appreciated ---------------------------------------------------------------------- trev · 2022-03-27 22:34 1) Locate the missing object files (I'm assuming they exist in your file system) 2) Add -va as an option for details of where FPC is looking for the missing object files 3) Add the location of the missing object files -or- link them to where FPC is looking. If the missing object files do not exist, I'm told installing libgcc should resolve that one. ---------------------------------------------------------------------- dbannon · 2022-03-27 23:25 These files exist (assuming you have gcc installed, its a dependency of fpc, along with binutils, make) in places like Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i /usr/lib/gcc/x86_64-linux-gnu/9/crtbegin.oBut the '9' depends on the version of gcc you have and the "x86_64-linux-gnu" depends on your cpu and the "/usr/lib" depends on your distribution! Sigh ... So, find out where your (eg) crtbegin.o really is Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i find / -name "crtbegin.o" 2> /dev/null and either edit your fpc.cfg file or (better IMHO) add a symlink.  I have a line in my fpc.cfg that looks like this - Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i -Fl/usr/lib/gcc/x86_64-linux-gnu/9 You should have something vaguely similar. Davo ---------------------------------------------------------------------- dieselnutjob · 2022-03-28 11:13 Quote from: dbannon on March 28, 2022, 01:25:54 amThese files exist (assuming you have gcc installed, its a dependency of fpc, along with binutils, make) in places like Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i /usr/lib/gcc/x86_64-linux-gnu/9/crtbegin.oBut the '9' depends on the version of gcc you have and the "x86_64-linux-gnu" depends on your cpu and the "/usr/lib" depends on your distribution! Sigh ... So, find out where your (eg) crtbegin.o really is Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i find / -name "crtbegin.o" 2> /dev/null and either edit your fpc.cfg file or (better IMHO) add a symlink.  I have a line in my fpc.cfg that looks like this - Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i -Fl/usr/lib/gcc/x86_64-linux-gnu/9 You should have something vaguely similar. Davo Thanks.  Your answer got rid of some of the errors. Specifically, I added this line in /etc/fpc.cfg Code: [Select]# path to the gcclib -Fl/usr/lib/gcc/aarch64-unknown-linux-gnu/11.2.0 However I still have this:- Code: [Select]Free Pascal Compiler version 3.2.2 [2022/01/24] for aarch64 Copyright (c) 1993-2021 by Florian Klaempfl and others Target OS: Linux for AArch64 Compiling lazres.pp lazres.pp(65,9) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(81,3) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(95,11) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(98,9) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(109,11) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(112,9) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(121,5) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(124,3) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(261,3) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(275,3) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(257,5) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(231,7) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(233,7) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(208,5) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(180,11) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(306,5) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(308,5) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(321,9) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(348,9) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined lazres.pp(361,7) Note: Call to subroutine "function GetDebugLogger:TLazLogger;" marked as inline is not inlined Assembling lazres Linking ./lazres /bin/ld: /usr/local/lib/fpc/3.2.2/units/aarch64-linux/rtl/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' lazres.pp(395) Error: Error while linking lazres.pp(395) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted make[2]: *** [Makefile:2964: lazres] Error 1 make[2]: Leaving directory '/home/philip/fpc/source/lazarus- main/tools' make[1]: *** [Makefile:3394: all] Error 2 make[1]: Leaving directory '/home/philip/fpc/source/lazarus- main/tools' make: *** [Makefile:3803: lazbuild] Error 2 I have since discovered that lazarus and freepascal can now be installed from pacman.  When I first got my pinebook pro this wasn't the case and so I had to compile from source. So now I have two installations of fpc, one in /usr/local/bin which I installed using the install.sh from direct download of fpc, and one in /usr/bin which pacman put there. If there was an uninstall.sh I would probably run it.... ---------------------------------------------------------------------- dbannon · 2022-03-28 23:01 Quote from: dieselnutjob on March 28, 2022, 01:13:26 pm... However I still have this:- Code: [Select] /bin/ld: /usr/local/lib/fpc/3.2.2/units/aarch64-linux/rtl/cprt0.o: in function `_start': (.text+0x54): undefined reference to `__libc_csu_init' ... Just to be sure, you have installed the dependencies listed on, eg, ht tps://wiki.freepascal.org/Installing_the_Free_Pascal_Compiler#FPC_Tar_ Balls  ? QuoteIf there was an uninstall.sh I would probably run it.... Bit late to tell you now but when you install from the FPC Tarball, you do not have to install into /usr/ - I install into a dir in my home dir, set it all up in there and can easily blow it away when ever I feel like it. Thats what the example on the wiki shows ... Davo ---------------------------------------------------------------------- PascalDragon · 2022-03-29 08:21 Quote from: dieselnutjob on March 27, 2022, 07:01:15 pmany help would be appreciated This is a known problem. To solve it you need the source code for FPC 3.2.2 if you don't have it already. There you navigate to rtl/linux/aarch64 and edit the file cprt0.as (around line 40): Code: ASM  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i         /* __libc_start_main(main, argc, argv,                             init, fini, rtld_fini, stack_end) */        adrp    x0,:got:PASCALMAIN      ldr     x0,[x0,#:got_lo12:PASCALMAIN]        adrp    x3,:got:__libc_csu_init        ldr     x3,[x3,#:got_lo12:__libc_csu_init]        adrp    x4,:got:__libc_csu_fini        ldr     x4,[x4,#:got_lo12:__libc_csu_fini]        bl      __libc_start_main  Replace this with the following: Code: ASM  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i         /* __libc_start_main(main, argc, argv,                             init, fini, rtld_fini, stack_end) */        adrp    x0,:got:PASCALMAIN      ldr     x0,[x0,#:got_lo12:PASCALMAIN]        mov     x3,xzr        mov     x4,xzr        bl      __libc_start_main  And then go one directory up (to rtl/linux) and execute Code: [Select]make CPU_TARGET=aarch64 OS_TARGET=linux cprt0.o Finally copy the file rtl/units/aarch64-linux/cport0.o to /usr/local/lib/fpc/3.2.2/units/aarch64-linux/rtl/cprt0.o, replacing the original file there. ---------------------------------------------------------------------- dbannon · 2022-03-29 22:58 Wow, so that means that as the new glibc is rolled out, we can expect FPC to stop working on  aarch64, ppc64le and even poor old i386 ? Thats going to be interesting .... Davo ---------------------------------------------------------------------- PascalDragon · 2022-03-30 06:54 Quote from: dbannon on March 30, 2022, 12:58:51 amWow, so that means that as the new glibc is rolled out, we can expect FPC to stop working on  aarch64, ppc64le and even poor old i386 ? FPC itself will continue to work, cause it doesn't link to the C library on Linux. However anything that links in the C library will trigger this. This is something we'll have to fix before 3.2.4 is released. ---------------------------------------------------------------------- dieselnutjob · 2022-03-30 15:32 Quote from: PascalDragon on March 29, 2022, 10:21:45 amQuote from: dieselnutjob on March 27, 2022, 07:01:15 pmany help would be appreciated This is a known problem. To solve it you need the source code for FPC 3.2.2 if you don't have it already. There you navigate to rtl/linux/aarch64 and edit the file cprt0.as (around line 40): Code: ASM  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i         /* __libc_start_main(main, argc, argv,                             init, fini, rtld_fini, stack_end) */        adrp    x0,:got:PASCALMAIN      ldr     x0,[x0,#:got_lo12:PASCALMAIN]        adrp    x3,:got:__libc_csu_init        ldr     x3,[x3,#:got_lo12:__libc_csu_init]        adrp    x4,:got:__libc_csu_fini        ldr     x4,[x4,#:got_lo12:__libc_csu_fini]        bl      __libc_start_main  Replace this with the following: Code: ASM  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i         /* __libc_start_main(main, argc, argv,                             init, fini, rtld_fini, stack_end) */        adrp    x0,:got:PASCALMAIN      ldr     x0,[x0,#:got_lo12:PASCALMAIN]        mov     x3,xzr        mov     x4,xzr        bl      __libc_start_main  And then go one directory up (to rtl/linux) and execute Code: [Select]make CPU_TARGET=aarch64 OS_TARGET=linux cprt0.o Finally copy the file rtl/units/aarch64-linux/cport0.o to /usr/local/lib/fpc/3.2.2/units/aarch64-linux/rtl/cprt0.o, replacing the original file there. this worked thanks. The only note I would add for future victims is that in Manjaro that the source is in /usr/lib/fpc/src and that once the new cprt is compiled the command to actually install it is then (if you installed fpc, fpc-src and lazarus using the package manager):- Code: [Select]cp /usr/lib/fpc/src/rtl/units/aarch64-linux/cprt0.o /usr/lib/fpc/3.2.2/units/aarch64-linux/rtl/ ---------------------------------------------------------------------- dieselnutjob · 2022-03-30 16:54 I reported it as a bug here https://bugs.archlinux.org/task/74281 ---------------------------------------------------------------------- dieselnutjob · 2022-03-30 21:57 Quote from: dieselnutjob on March 30, 2022, 06:54:02 pmI reported it as a bug here https://bugs.archlinux.org/task/74281 Which looped right back round to here. Arch say that it's nothing to do with them because I'm running Manjaro, and Manjaro say that fpc isn't developed by them so they won't do anything. Basically I need to somehow find out who is the package maintainer for fpc on Manjaro. ---------------------------------------------------------------------- winni · 2022-03-30 22:44 Hi! The trouble with crtbegin.o and ctrend.o on Manjaro we had before: https://forum.lazarus.freepascal.org/index.php/topic,56114.msg417087.h tml#msg417087 Winni ---------------------------------------------------------------------- PascalDragon · 2022-03-31 07:02 Quote from: dieselnutjob on March 30, 2022, 11:57:01 pmBasically I need to somehow find out who is the package maintainer for fpc on Manjaro. There is nothing that the distros can do here. This needs to be fixed by us and then you'll need to wait for 3.2.4.