Recent

Author Topic: Build failure in Fedora 35 due to glibc 2.34 code hardening  (Read 5242 times)

sparebit

  • Newbie
  • Posts: 2
Build failure in Fedora 35 due to glibc 2.34 code hardening
« on: August 07, 2021, 05:17:11 pm »
Fedora has recently moved to using glibc 2.34. That caused Free Pascal Compiler to stop building with the following output:

Code: [Select]
/usr/bin/ld:
/builddir/build/BUILD/fpcbuild-3.2.2/fpcsrc/rtl/units/powerpc64-linux/si_c.o:(.data.n_TC_$SI_C_$$_START_ADDRESSES+0x10):
undefined reference to `__libc_csu_init'
/usr/bin/ld:
/builddir/build/BUILD/fpcbuild-3.2.2/fpcsrc/rtl/units/powerpc64-linux/si_c.o:(.data.n_TC_$SI_C_$$_START_ADDRESSES+0x18):
undefined reference to `__libc_csu_fini'
Error: Error while linking

One of the guys responsible for glibc in Fedora gave this explanation:

Quote
It's related to startup code hardening in glibc.  In general, it's not forward-compatible to call internal glibc functions this way.
__libc_csu_init and __libc_csu_fini where never part of any header file.
It's not clear to me why fpc needs to replace the startup code.  They could supply a C main function and call Pascall code from that.  Or compile the main program in such a way that it has a compatible interface with the C main program.

I'm not the maintainer of fpc package in Fedora, but hopefully the real maintainer will add themselves in this discussion. Do you have any hint on how we can make fpc build again?

Mattia

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11351
  • FPC developer.
Re: Build failure in Fedora 35 due to glibc 2.34 code hardening
« Reply #1 on: August 07, 2021, 07:19:17 pm »
Difficult. Even if what he suggests is the best way (and that is still to be established), it is a long term project. If only because, unlike most *nix compilers, FPC also has a libcless mode, exactly to isolate of these constant unnecessary incompatibilities.

Short solution is that you simply maintain a patch with the proper new functions called, and hope they don't changed the signature only the name.

« Last Edit: August 07, 2021, 10:40:35 pm by marcov »

sparebit

  • Newbie
  • Posts: 2
Re: Build failure in Fedora 35 due to glibc 2.34 code hardening
« Reply #2 on: August 08, 2021, 09:13:42 am »
One suggestion a glibc guy has made was:

Quote
To adjust to the glibc 2.34 changes without fixing the underlying
problem, use this:

-    .quad   __libc_csu_init
-    .quad   __libc_csu_fini
+    .quad   0
+    .quad   0

Similarly for the other architectures.

What do you think?
(see also https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/RLTQ5CJ7F2FAFYVPBZZHVRJK2LZX7D36/)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11351
  • FPC developer.
Re: Build failure in Fedora 35 due to glibc 2.34 code hardening
« Reply #3 on: April 06, 2022, 03:45:23 pm »
The question is what will that break wrt initializers and finalizers?

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
Re: Build failure in Fedora 35 due to glibc 2.34 code hardening
« Reply #4 on: April 07, 2022, 09:13:20 am »
The question is what will that break wrt initializers and finalizers?

Anything that relies on __attribute__(constructor) or __attribute__(destructor) would be the problem here (the destructors will be called by a more or less up ot date libc itself already, but this might lead to problems, because the constructors weren't called). But the thing is that we didn't ensure that the initializers are called on all supported Linux platforms anyway. So if we want them to work we should work on a solution in main, but for now ensure that 3.2.4 works at all.

 

TinyPortal © 2005-2018