Recent

Author Topic: Problems with /i386-linux/rtl/si_c21  (Read 1125 times)

Fred vS

  • Hero Member
  • *****
  • Posts: 3716
    • StrumPract is the musicians best friend
Problems with /i386-linux/rtl/si_c21
« on: May 11, 2023, 01:33:14 am »
Hello.

After upgrade to XUbuntu 23.04, I have problems when compiling-linking using fpc 3.2.2 i386 on the multiarch OS.

At linking there is that error:

Code: Pascal  [Select][+][-]
  1. /usr/bin/ld: /home/fred/fpc-i386-linux/units/i386-linux/rtl/si_c21.o: in function `SI_C21_$$__FPC_LIBC21_START':
  2. si_c21.pp:(.text.n_si_c21_$$__fpc_libc21_start+0x27): undefined reference to `__libc_csu_fini'
  3. /usr/bin/ld: si_c21.pp:(.text.n_si_c21_$$__fpc_libc21_start+0x2c): undefined reference to `__libc_csu_init'
  4. test.pas(12,1) Error: Error while linking
  5. test.pas(12,1) Fatal: There were 1 errors compiling module, stopping
  6. Fatal: Compilation aborted

I suppose it is related with this:
https://gitlab.com/freepascal.org/fpc/source/-/issues/39295

Is there a cure for this, maybe using fpc 3.2.3 ?
Strange that before upgrade, there was no problem to link using  fpc 3.2.2 i386 on the multiarch OS.
I have also a old VM Debian 10 and there no problem with  fpc 3.2.2 i386 on the multiarch OS.

Or I miss something as usual?

Thanks.

Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Fred vS

  • Hero Member
  • *****
  • Posts: 3716
    • StrumPract is the musicians best friend
Re: Problems with /i386-linux/rtl/si_c21
« Reply #1 on: May 11, 2023, 02:04:23 am »
Hello.

OK, compiling fpc from branch /source-fixes_3_2/ for i386 and using it fixe the problems.
Linking is ok now.  ;D

Code: Bash  [Select][+][-]
  1. Free Pascal Compiler version 3.2.3 [2023/05/11] for i386
  2. Copyright (c) 1993-2021 by Florian Klaempfl and others
  3. Target OS: Linux for i386
  4. Compiling test.pas
  5. ...
  6. Linking test
  7. 10 lines compiled, 0.1 sec

Sorry for the noise.

Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

neuro

  • Jr. Member
  • **
  • Posts: 94
Re: Problems with /i386-linux/rtl/si_c21
« Reply #2 on: October 08, 2025, 10:03:52 am »
I found a way to install Lazarus 3.4 on Debian 12 (i386):
1) Run fpcupdeluxe v2.4.0f.
2) Click the "Setup+" button.
3) Click the "Add FPC patch" button.
4) Select the “fpc-3.2.0--glibc-2.34.patch” file and click “Ok”.
5) Click the “Install/update FPC+Lazarus” button.

Source code of file “fpc-3.2.0--glibc-2.34.patch”:
Quote
From a6c82b6642871e1c68f3839e090b055bee4254b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
Date: Tue, 21 Sep 2021 12:47:28 +0200
Subject: [PATCH] update startup data structs for glibc >= 2.34

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2005910
Fixes: https://gitlab.com/freepascal.org/fpc/source/-/issues/39295
---
 rtl/linux/aarch64/cprt0.as   | 6 ++----
 rtl/linux/i386/si_c21.inc    | 7 +++----
 rtl/linux/powerpc64/cprt0.as | 4 ++--
 rtl/linux/powerpc64/gprt0.as | 4 ++--
 rtl/linux/powerpc64/si_c.inc | 7 ++-----
 rtl/linux/powerpc64/si_g.inc | 7 ++-----
 6 files changed, 13 insertions(+), 22 deletions(-)

diff --git a/rtl/linux/aarch64/cprt0.as b/rtl/linux/aarch64/cprt0.as
index fd83610fbc..c8f2ca4baa 100644
--- a/rtl/linux/aarch64/cprt0.as
+++ b/rtl/linux/aarch64/cprt0.as
@@ -41,10 +41,8 @@ _start:
                         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]
+   mov   x3, #0      /* Used to be init.  */
+   mov   x4, #0      /* Used to be fini.  */
    bl   __libc_start_main
 
    /* This should never happen */
diff --git a/rtl/linux/i386/si_c21.inc b/rtl/linux/i386/si_c21.inc
index 71df29b6ef..084cdcf3ce 100644
--- a/rtl/linux/i386/si_c21.inc
+++ b/rtl/linux/i386/si_c21.inc
@@ -35,8 +35,6 @@
 
 {$asmmode att}
 
-procedure __libc_csu_init; cdecl; external;
-procedure __libc_csu_fini; cdecl; external;
 procedure libc_start_main; external name '__libc_start_main';
 procedure libc_exit(code: longint); cdecl; external name 'exit';
 
@@ -93,8 +91,9 @@ procedure _FPC_libc21_start; assembler; nostackframe; public name '_start';
         pushl %esp            { stack_end }
         pushl %edx            { function to be registered with
                                  atexit(), passed by loader }
-        pushl $__libc_csu_fini
-        pushl $__libc_csu_init
+        { This used to be the addresses of .fini and .init.  }
+        pushl $0
+        pushl $0
         pushl %esi                      { Push second argument: argv.  }
         pushl %ecx                      { Push first argument: argc.  }
 
diff --git a/rtl/linux/powerpc64/cprt0.as b/rtl/linux/powerpc64/cprt0.as
index 2b8309d4bf..3eace2813d 100644
--- a/rtl/linux/powerpc64/cprt0.as
+++ b/rtl/linux/powerpc64/cprt0.as
@@ -351,8 +351,8 @@ _restvr_31: addi r12,r0,-16
 start_addresses:
     .quad   0 /* was _SDA_BASE_  but not in 64-bit ABI*/
     .quad   main_stub
-    .quad   __libc_csu_init
-    .quad   __libc_csu_fini
+    .quad   0 /* Used to be init. */
+    .quad   0 /* Used to be fini. */
     .size   start_adresses, .-start_addresses
 
 /*
diff --git a/rtl/linux/powerpc64/gprt0.as b/rtl/linux/powerpc64/gprt0.as
index de31b6b08d..6b6fc9011b 100644
--- a/rtl/linux/powerpc64/gprt0.as
+++ b/rtl/linux/powerpc64/gprt0.as
@@ -351,8 +351,8 @@ _restvr_31: addi r12,r0,-16
 start_addresses:
     .quad   0 /* was _SDA_BASE_  but not in 64-bit ABI*/
     .quad   main_stub
-    .quad   __libc_csu_init
-    .quad   __libc_csu_fini
+    .quad   0 /* Used to be init. */
+    .quad   0 /* Used to be fini. */
     .size   start_adresses, .-start_addresses
 
 /*
diff --git a/rtl/linux/powerpc64/si_c.inc b/rtl/linux/powerpc64/si_c.inc
index c7e5e353a0..2833258c93 100644
--- a/rtl/linux/powerpc64/si_c.inc
+++ b/rtl/linux/powerpc64/si_c.inc
@@ -657,9 +657,6 @@ procedure _restfpr_30; cdecl; public; assembler; nostackframe;
                           Process start/halt
  ******************************************************************************}
 
-procedure __libc_csu_init; cdecl; external;
-procedure __libc_csu_fini; cdecl; external;
-
 procedure __libc_start_main(r3,r4,r5,r6,r7,r8,r9: pointer); cdecl; external;
 
 var
@@ -724,8 +721,8 @@ procedure main_stub(argc: longint; argv, envp: ppchar); cdecl; assembler; nostac
   end
   = (sda_base: nil; {* was _SDA_BASE_  but not in 64-bit ABI }
      main: @main_stub;
-     libc_csu_init: @__libc_csu_init;
-     libc_csu_fini: @__libc_csu_fini
+     libc_csu_init: nil;
+     libc_csu_fini: nil
     );
 
 
diff --git a/rtl/linux/powerpc64/si_g.inc b/rtl/linux/powerpc64/si_g.inc
index 8c99a39bc6..58cdf19f9c 100644
--- a/rtl/linux/powerpc64/si_g.inc
+++ b/rtl/linux/powerpc64/si_g.inc
@@ -657,9 +657,6 @@ procedure _restfpr_30; cdecl; public; assembler; nostackframe;
                           Process start/halt
  ******************************************************************************}
 
-procedure __libc_csu_init; cdecl; external;
-procedure __libc_csu_fini; cdecl; external;
-
 procedure __libc_start_main(r3,r4,r5,r6,r7,r8,r9: pointer); cdecl; external;
 
 type
@@ -745,8 +742,8 @@ procedure main_stub(argc: longint; argv, envp: ppchar); cdecl; assembler; nostac
   end
   = (sda_base: nil; {* was _SDA_BASE_  but not in 64-bit ABI }
      main: @main_stub;
-     libc_csu_init: @__libc_csu_init;
-     libc_csu_fini: @__libc_csu_fini
+     libc_csu_init: nil;
+     libc_csu_fini: nil
     );
 
 procedure call_libc_start_main(r3,r4,r5,r6,r7,r8,r9: pointer); cdecl;
--
2.31.1
« Last Edit: October 11, 2025, 12:47:43 am by neuro »

 

TinyPortal © 2005-2018