Recent

Author Topic: Problems with libraries for cross x86_64-linux to aarch64-freebsd  (Read 7081 times)

regs

  • Jr. Member
  • **
  • Posts: 99

Cross is made with fpcupdeluxe. But it's installing very old libraries and there are some libraries are missing. There are newer FreeBSD 14 libraries for x86_64, and they are linking, but no for aarch64.
https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/download/crosslibs_all/FreeBSD_AMD64_FreeBSD_14.zip

So I made a comprehensive set of libraries:
https://drive.google.com/file/d/1VwHRspOw6qwzBAFqiA3fd_OmyPwFhjYA/view?usp=sharing

But.. they still won't link with a errors:
Error: /opt/fpcupdeluxe/cross/bin/aarch64-freebsd/aarch64-freebsd13-ld.bfd: /opt/fpcupdeluxe/fpc/units/aarch64-freebsd/rtl/system.o: undefined reference to symbol 'atan@@FBSD_1.0'
Error: /opt/fpcupdeluxe/cross/bin/aarch64-freebsd/aarch64-freebsd13-ld.bfd: /opt/fpcupdeluxe/cross/lib/aarch64-freebsd//libm.so.5: error adding symbols: DSO missing from command line


What possibly could be missing?

Thaddy

  • Hero Member
  • *****
  • Posts: 19171
  • Glad to be alive.
Re: Problems with libraries for cross x86_64-linux to aarch64-freebsd
« Reply #1 on: July 15, 2025, 11:50:34 am »
That aarch64-freebsd is NOT yet an officially supported platform?
Supported are Linux, Android and iOS, not FreeBSD.
Although fpcupdeluxe makes an effort, I still think it is not official.
Note I am able to build a cross-compiler with fpcupdeluxe from both Windows64-x86_64 and linux64-x86_64 to aarch64-freebsd. The starting compilers are 3.3.1.

I can't test and will not test them though: I have not freebsd installed on aarch64 anywhere and am not prepared to use one of my raspberry pi's for it, nor a vm.
The cross-compilers just compile.

I can add a binary for helloworld, though, for you to test if you want.
That said: with the cross compiler you can also build fpc itself for your platform.
« Last Edit: July 15, 2025, 12:15:52 pm by Thaddy »
objects are fine constructs. You can even initialize them with constructors.

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1877
Re: Problems with libraries for cross x86_64-linux to aarch64-freebsd
« Reply #2 on: July 15, 2025, 12:36:56 pm »
Fpcupdeluxe has a tool to extract all needed libraries from your system.

https://github.com/LongDirtyAnimAlf/fpcupdeluxe/tree/master/fpcuptools/libraryscanner

Compile and run (takes some time) on your system and you should end up with all libraries needed to cross-compile towards your system.

Thaddy

  • Hero Member
  • *****
  • Posts: 19171
  • Glad to be alive.
Re: Problems with libraries for cross x86_64-linux to aarch64-freebsd
« Reply #3 on: July 15, 2025, 01:43:06 pm »
Yes, that works for the cross-compiler at least.
objects are fine constructs. You can even initialize them with constructors.

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1877
Re: Problems with libraries for cross x86_64-linux to aarch64-freebsd
« Reply #4 on: July 15, 2025, 01:57:13 pm »
Good. But always check the contents of the libc.so file.
Must contain relative path when it is a stub.
Code: Pascal  [Select][+][-]
  1. GROUP ( libc.so.7 libc_nonshared.a libssp_nonshared.a )

regs

  • Jr. Member
  • **
  • Posts: 99
Re: Problems with libraries for cross x86_64-linux to aarch64-freebsd
« Reply #5 on: July 15, 2025, 08:23:36 pm »
I can't test and will not test them though: I have not freebsd installed on aarch64 anywhere and am not prepared to use one of my raspberry pi's for it, nor a vm.
The cross-compilers just compile.

I can add a binary for helloworld, though, for you to test if you want.
That said: with the cross compiler you can also build fpc itself for your platform.

An empty app does compile and link, but library pack is missing a lot of libraries and it's old. FreebSD 10 packages are no longer available on pkg.freebsd.org.

Fpcupdeluxe has a tool to extract all needed libraries from your system.

https://github.com/LongDirtyAnimAlf/fpcupdeluxe/tree/master/fpcuptools/libraryscanner

Compile and run (takes some time) on your system and you should end up with all libraries needed to cross-compile towards your system.


Well, unfortunately I don't have a space for free system on my VM drive. I just collected all the same files from that are in crosslibs_all FreeBSD AMD64 set, which is working, from pkg.freebsd.org (and a help of freebsd.pkgs.org). And even more - all libraries that are in packages of those libraries. It's not complaining on missing files, but something else. Could be ld issue?
Cross tools i guess are installed from here
https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/download/linux_amd64_crossbins_all/FreeBSD_AArch64_FreeBSD13_V240.zip


Good. But always check the contents of the libc.so file.
Must contain relative path when it is a stub.
Code: Pascal  [Select][+][-]
  1. GROUP ( libc.so.7 libc_nonshared.a libssp_nonshared.a )
I did fix libc.so, so as libncursesw.so and libc++.so and all symlinks.
« Last Edit: July 15, 2025, 09:30:59 pm by regs »

myisjwj

  • Full Member
  • ***
  • Posts: 104
Re: Problems with libraries for cross x86_64-linux to aarch64-freebsd
« Reply #6 on: July 16, 2025, 01:41:38 pm »

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1877
Re: Problems with libraries for cross x86_64-linux to aarch64-freebsd
« Reply #7 on: July 16, 2025, 03:03:27 pm »
Two things you need to do:
1:
You are missing libinotify; so add it to your libs.

2:
Your libc.so must contain
Quote
GROUP ( libc.so.7 libc_nonshared.a libm.a)

regs

  • Jr. Member
  • **
  • Posts: 99
Re: Problems with libraries for cross x86_64-linux to aarch64-freebsd
« Reply #8 on: July 17, 2025, 11:43:14 pm »
Spent whole day yesterday trying to get FreeBSD 14.3 running with qemu-system-aarch64 to no avail. Video driver seem to be broken, so Xorg is not possible under aarch64 Qemu.

Two things you need to do:
1:
You are missing libinotify; so add it to your libs.

2:
Your libc.so must contain
Quote
GROUP ( libc.so.7 libc_nonshared.a libm.a)
Adding libm.a to libc.so and libinotify actually worked. Links now.

Here is full compilation of libraries
aarch64-freebsd.txz
https://drive.google.com/file/d/10outbK05_ERAzb86ZvOWQhKqJlwxL0Hc/view?usp=sharing

regs

  • Jr. Member
  • **
  • Posts: 99
Re: Problems with libraries for cross x86_64-linux to aarch64-freebsd
« Reply #9 on: July 19, 2025, 02:31:56 am »
Also aarch64-linux.txz. Taken from Ubuntu 25.04. But those are not compatible with ld coming with fpCupDeluxe. Requires up to date ld. Some symlinks could be missing in some conditions, but i was able to compile and link my apps with gtk2, gtk3, qt5 and qt6 from x86_64.

https://drive.google.com/file/d/1Vx49zOh_i_pCkAgM4KgG8yGyYTq9RHyF/view?usp=sharing

Thaddy

  • Hero Member
  • *****
  • Posts: 19171
  • Glad to be alive.
Re: Problems with libraries for cross x86_64-linux to aarch64-freebsd
« Reply #10 on: July 19, 2025, 06:01:13 am »
FreeBSD also changed to wayland? then for Xorg to work you must set a compatibility mode and I don't know what that is for FreeBSD,
Similar exists in RaspberryPi OS, which is Debian derived.
« Last Edit: July 19, 2025, 01:06:32 pm by Thaddy »
objects are fine constructs. You can even initialize them with constructors.

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1877
Re: Problems with libraries for cross x86_64-linux to aarch64-freebsd
« Reply #11 on: July 19, 2025, 09:40:44 am »
@regs
It would be good if you extract the libs with my previous mentioned library scanner.
It will copy only the needed libs, making the size of the all the libs smaller.

Thaddy

  • Hero Member
  • *****
  • Posts: 19171
  • Glad to be alive.
Re: Problems with libraries for cross x86_64-linux to aarch64-freebsd
« Reply #12 on: July 19, 2025, 01:08:50 pm »
lazaurs自建库文件系统
https://www.cnblogs.com/jwjss/p/17920165.html
Yes, it can be successfully compiled as a cross-compiler. I did that and mentioned that. That doesn't mean it works, although all is compiled including all the standard libraries.
From the freeBSD website:
Code: Text  [Select][+][-]
  1. Because Wayland does not provide the X server, and expects compositors to provide that support,
  2. X11 window managers that do not yet support Wayland will require that Xwayland is not started with
  3. the -rootless parameter.
  4. The -rootless parameter, when removed, will restore X11 window manager support.
So there's something similar to what I mentioned before for Debian derivatives.

https://docs.freebsd.org/en/books/handbook/wayland/

For good measure, this really isn't a Lazarus issue, but a platform issue.
« Last Edit: July 19, 2025, 01:36:30 pm by Thaddy »
objects are fine constructs. You can even initialize them with constructors.

regs

  • Jr. Member
  • **
  • Posts: 99
Re: Problems with libraries for cross x86_64-linux to aarch64-freebsd
« Reply #13 on: July 19, 2025, 01:54:59 pm »
@regs
It would be good if you extract the libs with my previous mentioned library scanner.
It will copy only the needed libs, making the size of the all the libs smaller.

But libraries from different versions would be just incompatible. Adding missing libraries was first step to attempt. It's just ends up in lots of references errors. So ended up taking all libs from same distro.

Quote
That doesn't mean it works, although all is compiled including all the standard libraries.
Original libraries missing xkbcommon, qt6 libs, qt5 libs and something else, don't rememeber.

I tested compiled apps with gtk2, qt5 and qt6 on FreeBSD 14.3 x86_64. They work. But i use X11. I'm not a fan of Wayland. And the app i was working is for X11. At least for now, until Wayland is more developer and user friendly. I can't test AArch64. Graphics won't run under Qemu emulation.
« Last Edit: July 19, 2025, 02:26:27 pm by regs »

regs

  • Jr. Member
  • **
  • Posts: 99
Re: Problems with libraries for cross x86_64-linux to aarch64-freebsd
« Reply #14 on: July 19, 2025, 02:00:04 pm »
riscv64-linux.txz
Compiles and links with gtk2, gtk3 and qt6. There is no libqt5pas in Debian, and therefore Ubuntu, for riscv64.
https://drive.google.com/file/d/1SegEKdz9KUcBTkbcHkCVpBiZ2wvMi_gF/view?usp=sharing

On assembler errors
https://gitlab.com/freepascal.org/fpc/source/-/issues/40880


 

TinyPortal © 2005-2018