How to port fbc to new platform?

General discussion for topics related to the FreeBASIC project or its community.
Cretin Ho
Posts: 182
Joined: Feb 04, 2021 13:01

Re: How to port fbc to new platform?

Post by Cretin Ho »

I saw the Travis CI builds all fail with my changes.

I have do the best I can. Now your turn, the fbc experts.

I have no prior experience with the FreeBASIC language, this is the reason why I said it's risky if me do the porting myself.

As I'm usually on OpenIndiana and I'm interested in your language so I just wanted to be able to have the compiler working and play with it on the OS I use.
Cretin Ho
Posts: 182
Joined: Feb 04, 2021 13:01

Re: How to port fbc to new platform?

Post by Cretin Ho »

Well. Just syntactic errors. Luckily after a bit of trial and error I could make them built fine on my local Linux.

Don't know about the Travis CI builds, though. Let's hope they don't fail.
Cretin Ho
Posts: 182
Joined: Feb 04, 2021 13:01

Re: How to port fbc to new platform?

Post by Cretin Ho »

It's built fine on the native platform. But bootstrapping for Solaris (make bootstrap-dist) fails with this error:

./bin/fbc src/compiler/*.bas -m fbc -i inc -e -r -v -target solaris-x86_64 && mv src/compiler/*.c bootstrap/solaris-x86_64
error 81: Invalid command-line option, "solaris-x86_64"
make: *** [makefile:1138: bootstrap-dist] Error 1

Only fails with Solaris, other targets are fine.

I'm now out of idea. I did the best trial and error could get me.

Now it's depending on you, the fbc developers, if you really want to add these two platforms or not.

Bye.
dkl
Site Admin
Posts: 3235
Joined: Jul 28, 2005 14:45
Location: Germany

Re: How to port fbc to new platform?

Post by dkl »

Thanks for doing the work of adding the changes to fbc, and putting them into Git too. I've merged both branches together and merged them into master. I think that should be fine, since I don't think the changes break anything else. We can improve it further as needed.
Cretin Ho
Posts: 182
Joined: Feb 04, 2021 13:01

Re: How to port fbc to new platform?

Post by Cretin Ho »

dkl wrote:Thanks for doing the work of adding the changes to fbc, and putting them into Git too. I've merged both branches together and merged them into master. I think that should be fine, since I don't think the changes break anything else. We can improve it further as needed.
I think you merged it too soon. It build fine without any problems, but as you see on my post above, make bootstrap-dist failed with the target solaris-x86_64, there must be something silently broken but I can't find a solution for it. Please have a look at the make file. I hope you could fix the error.

p/s: Nevermind. I found the problems. I used the old fbc 1.07.2 to build the bootstrap, it doesn't understand the new targets so it fails. I have to delete the symlink I made (ln -s /usr/local/bin/fbc bin/fbc) to workaround the error bin/fbc not found and make the new compiler first then make bootstrap-dist later. It's all because of lack of knowledge, not something silently broken at all.
Cretin Ho
Posts: 182
Joined: Feb 04, 2021 13:01

Re: How to port fbc to new platform?

Post by Cretin Ho »

New problems arise.

The bootstrap generated on Linux could compile just fine on OpenIndiana.

The only problem when compiling is the libffi headers not found.

I tried:

CFLAGS="-I/usr/lib/amd64/libffi-3.2.1/include" gmake -j4 bootstrap

but it still not able to find the headers.

Finally I used an ugly hack:

sudo ln -s /usr/lib/amd64/libffi-3.2.1/include/ffi.h /usr/include/ffi.h

sudo ln -s /usr/lib/amd64/libffi-3.2.1/include/ffitarget.h /usr/include/ffitarget.h

After that the compilation completed just fine.

But the resulted compiler can't compile any source files. It seemed it fails at the linking stage:

ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.1763 (illumos)
ld: fatal: option -d has illegal argument 'ynamic-linker'
ld: fatal: flags processing errors

This clearly because the Solaris linker is incompatible with the GNU linker.

I will try to find a workaround for this.

BTW, how to correctly tell it to search for the correct location of libffi headers?

CFLAGS is definitely not work.
Cretin Ho
Posts: 182
Joined: Feb 04, 2021 13:01

Re: How to port fbc to new platform?

Post by Cretin Ho »

Please have a look at my latest pull request:

https://github.com/freebasic/fbc/pull/288

This should fix the linker issues on Solaris and correct the path to the libffi headers.
Cretin Ho
Posts: 182
Joined: Feb 04, 2021 13:01

Re: How to port fbc to new platform?

Post by Cretin Ho »

The compiler on Solaris is pretty much just works. I tried to compile the code here:

viewtopic.php?f=7&t=29195

It compiled fine and the program printed the correct result:

Code: Select all

    1.000    6.000   15.000   20.000   15.000    6.000
    1.000    7.000   21.000   35.000   35.000   21.000
    1.000    8.000   28.000   56.000   70.000   56.000
    1.000    9.000   36.000   84.000  126.000  126.000
    1.000   10.000   45.000  120.000  210.000  252.000
    1.000   11.000   55.000  165.000  330.000  462.000
-------------------
   11.000   22.000   33.000   44.000   55.000   99.000  -12.000  -13.000
-------------------
    1.000    2.000    3.000    4.000    5.000    6.000
-------------------
  123.000  234.000  345.000  456.000  567.000  678.000  789.000
However, when I tried to compile the program here:

viewtopic.php?f=7&t=29217

It failed because of linking issue:

ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.1764 (illumos)
Undefined first referenced
symbol in file
__fb_gfx_drivers_list /export/home/fellow/fbc/bin/../lib/freebasic/solaris-x86_64/libfbgfx.a(gfx_screen.o)

BTW, I'm no longer use OpenIndiana as my daily driver anymore but moved back to Linux for work. I think I can't continue to contribute for the Solaris and Dragonfly target anymore. Sorry.

They are kind of work now. But definitely need more love to be production ready. Maybe someone with the knowledge will revisit these targets in the future. Let's hope so.
Cretin Ho
Posts: 182
Joined: Feb 04, 2021 13:01

Re: How to port fbc to new platform?

Post by Cretin Ho »

Cretin Ho wrote:Please have a look at my latest pull request:

https://github.com/freebasic/fbc/pull/288

This should fix the linker issues on Solaris and correct the path to the libffi headers.
Please have a look at this pull request, developers. It's kind of a complete Solaris port now, I fixed the problem with FBGFX applications and I think no new commits is needed.
Cretin Ho
Posts: 182
Joined: Feb 04, 2021 13:01

Re: How to port fbc to new platform?

Post by Cretin Ho »

Caution: this Solaris port is actually about OpenIndiana/Illumos but not Oracle Solaris. Oracle Solaris was never in mind from the beginning even though I want my port to be an umbrella to support the whole Solaris/Illumos family. This port may only works on OpenIndiana but not other Illumos distros. The Illumos distros themselves incompatible. Unlike Linux where there is still some guaranteed compatibility between distros. Just tested on Tribblix and failed to bootstrap.
Cretin Ho
Posts: 182
Joined: Feb 04, 2021 13:01

Re: How to port fbc to new platform?

Post by Cretin Ho »

The VM I shared here have GCC-10 installed:

viewtopic.php?f=17&t=29149#p279839

Prior versions of GCC on OpenIndian will target 32 bit by default. This GCC-10 targets 64 bit by default, so saved us a lot of troubles.

On other Illumos distros that still target 32 bit by default, you could try to bootstrap with:

CC="gcc -m64" gmake bootstrap -j4

But I don't know if it will go well or not. It could be a mess because of linking 32 bit objects with 64 bit objects and failed with an obscure error.

This Illumos platform is a mess!
Cretin Ho
Posts: 182
Joined: Feb 04, 2021 13:01

Re: How to port fbc to new platform?

Post by Cretin Ho »

Now I switch to work on DragonflyBSD port.
Cretin Ho
Posts: 182
Joined: Feb 04, 2021 13:01

Re: How to port fbc to new platform?

Post by Cretin Ho »

No new progress on the DragonflyBSD port. The internal workings of fbc is still somewhat mysterious for me. Even though I have hacked it to add missing bits for the Solaris port. This DragonflyBSD port really needs assisting from fbc developers. I have done my best. Becoming a fbc developer is not easy.

Anyway, you could check out the partial works here:

https://github.com/CretinHo/fbc/tree/dragonfly-fix

I have no idea of how to continue so I will just stop there. Hope someone interested in could resume the work in the future.
Cretin Ho
Posts: 182
Joined: Feb 04, 2021 13:01

Re: How to port fbc to new platform?

Post by Cretin Ho »

Here is my thread on Haiku discuss asked for help to port fbc to Haiku:

https://discuss.haiku-os.org/t/anyone-i ... iler/10489

Seems they are not interested.
Post Reply