Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building FPCDELUXE native in Termux shows erroneous build system at startup.. #715

Open
PTz0uAH opened this issue Oct 14, 2024 · 12 comments

Comments

@PTz0uAH
Copy link

PTz0uAH commented Oct 14, 2024

Hoi Devs, I managed to port/build FPCDELUXE with native LAZBUILD for Termux on Android 13..

After some minor changes the build succeeded and the GUI started seemingly normal..

I haven't tested the program functionality yet but at least it runs on the XFCE4 desktop..

The first "bug" I see is the erroneous message the program was build with FPC 3.3.1 on Win11 X86_64..

I expected to see: build with FPC 3.3.1 on Android AARCH64 as the project is a native build on Android 13/Termux X11 with FPC from trunk..

fpcupdeluxe-aarch64-android

with kind regards,

Peter

@PTz0uAH
Copy link
Author

PTz0uAH commented Oct 22, 2024

Hoi Devs, it seemed Win11 x86_64 was a literal string so I just had to change it..

Now it looks fine and I guess it's a premiere for running FPCUPDELUXE on ANDROID/AARCH64..

Screenshot_20241022-133648

I managed to build FPC and Lazarus after a lot of manual editing the sources and committing them locally before a succesfull build..

I guess we can close it up.. since it was no bug but a "typo"..

with kind regards,

Peter

@PTz0uAH PTz0uAH closed this as completed Oct 22, 2024
@LongDirtyAnimAlf
Copy link
Owner

This is a very nice result !!
It would be interesting (and perhaps useful) if fpcupdeluxe could cross-compile towards Termux.
For that, I need your help.

Look here.
https://github.com/LongDirtyAnimAlf/fpcupdeluxe/tree/master/fpcuptools/libraryscanner
This is a library scanner and copier. It will try to locate all the necessary libraries for building FPC and Lazarus on your system.
Would you mind trying to compile the command line version on your Termux system, run it, and look into the libs directory to see if it has succeeded ?
And, if success, zip and copy the libs for me to use ?
Thanks !

@PTz0uAH
Copy link
Author

PTz0uAH commented Nov 3, 2024

Thanks @LongDirtyAnimAlf !

As you can see the libraryscanner was useless even after patching..

Screenshot_20241103-112049

All packages/programs available for Termux are adapted for usage on Termux.. non-fsh complient.. so I had to adapt the libraryscanner with altered paths as also the aarch64-linux-android target but that did not work..

Well after copying the "termuxified" FPC and LAZARUS sources from the Android Tablet to the PC with Linux Subsystem for Win installed, after creating FPC and LAZARUS with FPCUPDELUXE I tried to crossbuild with LAZBUILD a simple project1.lpr from WSL2 to Android/Termux and failed with the default gcc toolchains.. I did not try clang on WSL2 for getting that to work was too elaborate for me..

I use Clang19 on Termux which does the job.. it replaces all previous standardised gcc toolchains..

With the current available android toolchains it is not possible to i.e. use GTK2/X11 needed for creating desktop (XFCE4) programs..

Though Termux is on-device developer friendly so most packages (debian alike) also install the dev parts..

Here some manual scans so you can see what the Termux filesystem has onboard..
usr_lib.txt
usr_bin.txt
clanglibs.txt

FYI.. I have the compiled fpcupdeluxe binary for Termux AARCH64 available ("handbuild" with heavily patched fpc and lazbuild).. for testing..

You can find it at https://github.com/PTz0uAH/termuxified/tree/main/projects/fpcupdeluxe

I guess if the host pc can cross compile to aarch64-linux-android with clang 19 then fpcupdeluxe would probably work for crossbuilding to termux too.. just like building native from termux.. but that needs some "diving into it" IYKWIM..

Maybe you can distribute my binary build until things work the way you want.. a lot of termux pascal fans could experiment for themselves.. I "only" needed to create 3.2.2 bootstrap compilers for ARM-ANDROID and AARCH64-ANDROID.. those I built before to get a sane 3.2.2 binary to build FPC from trunk.. that was some journey..

I thought of offering FPCUPDELUXE as binary package to Termux-packages but since it runs from $HOME/fpc4termux/fpcupdeluxe/ installing to $HOME from a package is a no-go.. so I must take into consideration to build FPC and LAZARUS from $PREFIX/lib/fpc4termux/fpcupdeluxe/ to be able to create FPC/LAZARUS Termux complient packages with also a complient FPCUPDELUXE Termux-package to get one started I guess..

@LongDirtyAnimAlf
Copy link
Owner

Good info !
Please send me the libs and the patched scanner, so I can start experimenting and building.
Thanks very much !

@PTz0uAH
Copy link
Author

PTz0uAH commented Nov 4, 2024

@LongDirtyAnimAlf

Ok.. but the quickly patched scanner (wip) was not yet of use to me as it didn't work with android/termux/clang19 (llvm?) backend.. still working on it so..

@LongDirtyAnimAlf
Copy link
Owner

I succeeded myself. Fpcupdeluxe cross-compiled from Windows. Up and running in Termux !!

android

@PTz0uAH
Copy link
Author

PTz0uAH commented Nov 6, 2024

@LongDirtyAnimAlf congrats and welcome to Termux!

I guess this does mean you do not need those results from the libraryscanner..

What toolchain did you use on windows.. clang14+ or plain gcc?

btw.. I 've been testing if using crosscompiling with help of Fpcupdeluxe works.. and yes it also works from termux and managed to build ppcross68k with an amiga-m68k toolchain (alt binutils) to work with the Amiga emulators I am also porting.. preserving those "oldskool" feelings..

crosscompilers that compiled ootb without too much hassle were: jvm-java, wasm-wasi and amiga-m68k..

wanted to create avr-embedded (arc5,arc6) for some arduino but those binutils are not availlable..

todo also get the esp32 toolchain working with FPC and Lazarus on Termux..

@LongDirtyAnimAlf
Copy link
Owner

I have adapted the scanner to work on Termux. And collected all the needed libs.
The toolchain is the latest GNU toolchain provided by the NDK. Its quite old already.
I am very happy with your efforts. The gtk2 toolkit is already enabled by the FPC core devs in FPC main.
I try to get more changes implemented.
And I guess that the devs would be very happy if you share your work on clang for Android !!
Thanks again.

@PTz0uAH
Copy link
Author

PTz0uAH commented Nov 10, 2024

@LongDirtyAnimAlf glad you made some significant progress.. and activated the upstream division of Freepascal.. superb!

Those FPC devs reside on gitlab I assume and a couple of months ago when I started the porting-journey there was a new-membership stop so I only exported locally the source edits on FPC/Lazarus to a couple of "patchfiles" with intention to apply them before every fresh trunk build..

The "ugly" patches need to be applied as there was no termux specific source ootb available.. with OpenGL and X11 and GTK2 etc.. needed to get the Castle Game Engine to work with Lazarus and Lazbuild.. on Termux-app/X11..

I could not get those patches to work automatically with FPCUPDELUXE.. lacking some basic information about howto-use.. so even thought about a custom patcher to build with FPC which I did before with the Amiga platform.. yet if all that can be achieved at the root of the Freepascal/Lazarus source git that would be fantastic and FPC and Lazarus from trunk (or stable) will work ootb soon with FPCUPDELUXE.. for all Termux-fans..

Auto-patching those sources before the first compilation was my first thought but I patched the sources after the first failing build.. do a local git commit and it works.. but very time-consuming.. (never used the patching mechanism in FPC ever for self-produced patches.. so I do not know exactly how that works.. but I managed to export some files via git )

What I could do if needed is make a repo here at github and upload the compete snapshot of the FPC?Lazarus build-sources that worked.. yet I do not know how fast the FPC upstream teams are able to implement the things we need.. another repo has not my preference but if there is no other way I maybe goto gitlab..

The "ugly" patches I posted at FPCUPDELUXE Issues.. at my "termuxified" repo.. where I keep track of all Termux related projects.. so maybe you can take a look.. PTz0uAH/termuxified#2 (comment)

So I really need to go on GitLab to communicate with the Freepascal people.. clone the repo, apply my patches and push or is there already a (Termux) aarch64-linux-android source repo for FPC and Lazarus.. or even representation on Github.. couldn't find a recent github freepascal trunk repo..

Well we'll see how it works out.. and if it leads to the much wanted/anticipated FPC/Lazarus packages for Termux.. but I think from educational perspective learning to build your "own" generates a lot of experience for the pascal devs of "tomorrow"..

@LongDirtyAnimAlf
Copy link
Owner

Thanks for your detailed update !
Upstream changes are limited to the enabling of gtk2 for Android. And only available in FPC trunk/main.
To make more progress and get the FPC devs activated, more is needed:

  • a fork of FPC and Lazarus that is in sync and contains your changes.
  • detailed info about what is needed to get things running on Termux
    (Termux packages needed, Termux changes needed)
  • detailed info on how to build FPC on Termux

Please provide all of the above.
Sidenote. the use of androidXXX will never be accepted. My suggestion: introduce a new define like {$define AndroidTermux} or a simple {$define Termux} and use that in the FPC and Lazarus sources.

I hope we can make progress.

@PTz0uAH
Copy link
Author

PTz0uAH commented Nov 12, 2024

Well that is some thing..

I'll do what I can from the context I am working from..

& I'll create fpc and laz repo of the "proof of concept" and work from that first..

keep you informed..

@PTz0uAH
Copy link
Author

PTz0uAH commented Nov 20, 2024

@LongDirtyAnimAlf some termuxial progress..

I created the experimental FPC/LAZARUS repo to work on..

And also cloned FPCUPDELUXE and made a TMX branch which will contain the (minimal) changes I made in the process to build the first "ported" edition..

All work has been done on-device..

https://github.com/PTz0uAH/fpc4all

Are you willing to test the repo "out-of-the-box" ? That would be nice..

And could you also use your recently cross-build binary of FPCUPDELUXE to see if that works too?

to be continued..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants