Building from source in OSX

General discussion about anything related to Ultibo.
Poi
Posts: 7
Joined: Mon Jan 07, 2019 11:57 pm

Building from source in OSX

Postby Poi » Tue Jan 08, 2019 12:55 am

Hello, been looking around at how to build from source but haven't found success yet. I was looking at the build steps for Debian https://ultibo.org/wiki/Building_for_Debian, they look similar enough to OSX, so I gave it a go.

This is what I have done so far

1) Installed FPC 3.0.4.
2) Download source of FPC Ultibo edition and Ultibo Core from Github.
3) Setup the folder structure as the instructions say.

4) Here it starts to get dicey

4a) I think that for my system I should be executing these commands

Code: Select all

make distclean
make all OS_TARGET=darwin CPU_TARGET=x86_64
make install OS_TARGET=darwin CPU_TARGET=x86_64 INSTALL_PREFIX=~/ultibo/core/fpc


If I then change to ~/ultibo/core/fpc/bin and do

Code: Select all

fpc -i


It shows me that the version of the Ultibo FPC is 3.1.1 which is correct, but ultibo is not among the available targets, so that is no good.

4b) If I execute these commands instead though...

Code: Select all

make distclean
make all OS_TARGET=darwin CPU_TARGET=i386
make install OS_TARGET=darwin CPU_TARGET=i386 INSTALL_PREFIX=~/ultibo/core/fpc


Then change to ~/ultibo/core/fpc/bin and do

Code: Select all

fpc -i


I shows me that the version of Ultibo FPC is 3.1.1 which is correct, and ultibo is among the available targets, so I continue.

5) Create the default configuration file.
6) Install the arm-none-eabi Toolchain for OSX.

7) Building the FPC ARM Cross compiler, here is where I am stuck.

When I do

Code: Select all

make all OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv6 BINUTILSPREFIX=arm-ultibo- FPCOPT="-dFPC_ARMHF" CROSSOPT="-CpARMV6 -CfVFPV3 -CIARM -CaEABIHF -OoFASTMATH" FPC=$~/ultibo/core/fpc/bin/ppc386


Everything seems to be going alright for a while until it stops with the following error

Code: Select all

syscalls.pas(8961,1) Error: Creation of Dynamic/Shared Libraries not supported
syscalls.pas(8961,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
make[5]: *** [syscalls.ppu] Error 1
make[4]: *** [ultibo_all] Error 2
make[3]: *** [rtl] Error 2
make[2]: *** [cycle] Error 2
make[1]: *** [compiler_cycle] Error 2
make: *** [build-stamp.arm-ultibo] Error 2


I found the error in here https://www.freepascal.org/docs-html/user/userse66.html#x180-187000C.7

Error: Creation of Dynamic/Shared Libraries not supported
Creating dynamically loadable libraries is not supported for this platform, because it was not yet implemented in the compiler.


Not too sure what to do out of that though, has anyone gotten this working in OSX?

Any help is appreciated.
User avatar
Ultibo
Site Admin
Posts: 2092
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Building from source in OSX

Postby Ultibo » Tue Jan 08, 2019 11:34 pm

Poi wrote:Hello, been looking around at how to build from source but haven't found success yet. I was looking at the build steps for Debian https://ultibo.org/wiki/Building_for_Debian, they look similar enough to OSX, so I gave it a go.

Hello Poi, welcome to Ultibo.

We're very keen to see if someone can get this working but we don't have a Mac available to try it, we have even considered renting a Mac in the cloud for a few days to work out the details.

You seem to be close but maybe missing something, there are a couple of points you might try to see it they help.

Poi wrote:4a) I think that for my system I should be executing these commands

Code: Select all

make distclean
make all OS_TARGET=darwin CPU_TARGET=x86_64
make install OS_TARGET=darwin CPU_TARGET=x86_64 INSTALL_PREFIX=~/ultibo/core/fpc


If I then change to ~/ultibo/core/fpc/bin and do

Code: Select all

fpc -i


It shows me that the version of the Ultibo FPC is 3.1.1 which is correct, but ultibo is not among the available targets, so that is no good.

That might be ok anyway, remember that fpc -i will really just call ppc386 -i or ppcx64 -i in the background.

ppcx64 -i won't list ultibo as a target because you can't compile x86_64 applications for the ultibo target, ppc386 -i lists ultibo because there is (non working) support for compiling ultibo applications for i386 included.

If the build was successful you could try using this version for the cross compiler build to see what happens.

Regardless, the i386 version should also do the job fine anyway because you really just want to create a cross compiler at this point.

Poi wrote:7) Building the FPC ARM Cross compiler, here is where I am stuck.

When I do

Code: Select all

make all OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv6 BINUTILSPREFIX=arm-ultibo- FPCOPT="-dFPC_ARMHF" CROSSOPT="-CpARMV6 -CfVFPV3 -CIARM -CaEABIHF -OoFASTMATH" FPC=$~/ultibo/core/fpc/bin/ppc386


Everything seems to be going alright for a while until it stops with the following error

Code: Select all

syscalls.pas(8961,1) Error: Creation of Dynamic/Shared Libraries not supported
syscalls.pas(8961,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
make[5]: *** [syscalls.ppu] Error 1
make[4]: *** [ultibo_all] Error 2
make[3]: *** [rtl] Error 2
make[2]: *** [cycle] Error 2
make[1]: *** [compiler_cycle] Error 2
make: *** [build-stamp.arm-ultibo] Error 2


I think the FPC=$~/ultibo/core/fpc/bin/ppc386 on the end of the command might be incorrect, it should probably not include the $, like this FPC=~/ultibo/core/fpc/bin/ppc386

Sometimes the last error message shown in the output from building the compiler is not the actual error so maybe Creation of Dynamic/Shared Libraries not supported is not really related. It might be worth looking back at the previous 50 or so lines in the output to see if there is anything else shown.

If there is no other error you could also try adding -Xt to the FPCOPT part of the command line like this:

Code: Select all

make all OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv6 BINUTILSPREFIX=arm-ultibo- FPCOPT="-Xt -dFPC_ARMHF" CROSSOPT="-CpARMV6 -CfVFPV3 -CIARM -CaEABIHF -OoFASTMATH" FPC=~/ultibo/core/fpc/bin/ppc386

which will explicitly tell it to pass -static to the linker.

Let us know how you get on.
Ultibo.org | Make something amazing
https://ultibo.org
Poi
Posts: 7
Joined: Mon Jan 07, 2019 11:57 pm

Re: Building from source in OSX

Postby Poi » Wed Jan 09, 2019 1:31 am

I did a few tweeks and got a bit further, still not quite there.

First, I just used the master branch of both Ultibo/Core and Ultibo/FPC, previously I was using the latest tag for each of the repos.

I also installed version 3.0.2 of the Free Pascal Compiler, because that is what the Makefile in Ultibo/FPC says so. Previously I modified it so it would accept version 3.0.4, not such a great idea.

I also made sure to start over from the beginning if anything didn't go as expected. Using git it is quite easy to get rid of any un-tracked files, so I did that anyway, not sure if it matters.

With that, these two commands worked just fine

Code: Select all

make all OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv6 BINUTILSPREFIX=arm-ultibo- FPCOPT="-dFPC_ARMHF" CROSSOPT="-CpARMV6 -CfVFPV2 -CIARM -CaEABIHF -OoFASTMATH" FPC=$HOME/ultibo/core/fpc/bin/ppc386


Code: Select all

make crossinstall BINUTILSPREFIX=arm-ultibo- FPCOPT="-dFPC_ARMHF" CROSSOPT="-CpARMV6 -CfVFPV2 -CIARM -CaEABIHF -OoFASTMATH" OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv7a FPC=$HOME/ultibo/core/fpc/bin/ppc386 INSTALL_PREFIX=$HOME/ultibo/core/fpc


So now I have my cross compiler :)

Now I am stuck again, this time building Ultibo RTL :(

This works

Code: Select all

make rtl_clean CROSSINSTALL=1 OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv6 FPCFPMAKE=$HOME/ultibo/core/fpc/bin/fpc CROSSOPT="-CpARMV6 -CfVFPV2 -CIARM -CaEABIHF -OoFASTMATH" FPC=$HOME/ultibo/core/fpc/bin/fpc


The following step doesn't though...

Code: Select all

make rtl OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv6 FPCFPMAKE=$HOME/ultibo/core/fpc/bin/fpc CROSSOPT="-CpARMV6 -CfVFPV2 -CIARM -CaEABIHF -OoFASTMATH" FPC=$HOME/ultibo/core/fpc/bin/fpc


It blows up very quickly with this output

Code: Select all

/Applications/Xcode.app/Contents/Developer/usr/bin/make -C rtl all
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C ultibo all
/Users/johndoe/ultibo/core/fpc/bin/fpc -Cparmv6 @rtl.cfg -Ur -Tultibo -Parm -XParm-ultibo- -Xr -Ur -Xs -O2 -n -Fi../inc -Fi../arm -FE. -FU/Users/johndoe/ultibo/core/fpc/source/rtl/units/arm-ultibo -darm -dRELEASE -CpARMV6 -CfVFPV2 -CIARM -CaEABIHF -OoFASTMATH -Us -Sg system.pp
Error: ppcarm can't be executed, error message: Failed to execute "ppcarm", error code: 127
make[2]: *** [system.ppu] Error 1
make[1]: *** [ultibo_all] Error 2
make: *** [rtl] Error 2


I'll have to continue going at it.

On a side note, getting everything to work on Windows was a breeze. Was done in about 15 minutes.
Last edited by Poi on Wed Jan 09, 2019 9:43 am, edited 1 time in total.
pik33
Posts: 817
Joined: Fri Sep 30, 2016 6:30 pm
Location: Poland
Contact:

Re: Building from source in OSX

Postby pik33 » Wed Jan 09, 2019 5:44 am

Try to install "normal" lazarus first and then compile Ultibo with its fpc.
User avatar
Ultibo
Site Admin
Posts: 2092
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Building from source in OSX

Postby Ultibo » Wed Jan 09, 2019 10:06 am

Poi wrote:First, I just used the master branch of both Ultibo/Core and Ultibo/FPC, previously I was using the latest tag for each of the repos.

There was a fix for building the compiler under Linux since that tag so that might explain some of the errors.

Poi wrote:I also installed version 3.0.2 of the Free Pascal Compiler, because that is what the Makefile in Ultibo/FPC says so. Previously I modified it so it would accept version 3.0.4, not such a great idea.

Good idea, we haven't fully tested building with 3.0.4 yet.

Poi wrote:I also made sure to start over from the beginning if anything didn't go as expected. Using git it is quite easy to get rid of any un-tracked files, so I did that anyway, not sure if it matters.

The clean and distclean operations should take care of removing anything that might mess up future builds.

Poi wrote:The following step doesn't though...

Code: Select all

make rtl OS_TARGET=ultibo CPU_TARGET=arm SUBARCH=armv6 FPCFPMAKE=$HOME/ultibo/core/fpc/bin/fpc CROSSOPT="-CpARMV6 -CfVFPV2 -CIARM -CaEABIHF -OoFASTMATH" FPC=$HOME/ultibo/core/fpc/bin/fpc


It blows up very quickly with this output

Code: Select all

/Applications/Xcode.app/Contents/Developer/usr/bin/make -C rtl all
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C ultibo all
/Users/johndoe/ultibo/core/fpc/bin/fpc -Cparmv6 @rtl.cfg -Ur -Tultibo -Parm -XParm-ultibo- -Xr -Ur -Xs -O2 -n -Fi../inc -Fi../arm -FE. -FU/Users/johndoe/ultibo/core/fpc/source/rtl/units/arm-ultibo -darm -dRELEASE -CpARMV6 -CfVFPV2 -CIARM -CaEABIHF -OoFASTMATH -Us -Sg system.pp
Error: ppcarm can't be executed, error message: Failed to execute "ppcarm", error code: 127
make[2]: *** [system.ppu] Error 1
make[1]: *** [ultibo_all] Error 2
make: *** [rtl] Error 2


The thing that stands out is that it is looking for ppcarm but the cross compiler should normally be called ppcrossarm instead.

Do you have ppcrossarm in /Users/johndoe/ultibo/core/fpc/bin?
Do you have ppcarm anywhere at all?
If you copy ppcrossarm to ppcarm does it help?

Must be getting close, just a couple of steps to go and it should work!
Ultibo.org | Make something amazing
https://ultibo.org
Gavinmc42
Posts: 1436
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: Building from source in OSX

Postby Gavinmc42 » Wed Jan 09, 2019 10:43 am

The thing that stands out is that it is looking for ppcarm but the cross compiler should normally be called ppcrossarm instead.


My Gentoo64 3.2.0-Beta fpc is called ppca64, that will only compile for Aarch64.
So for Ultibo I will need a ppcarm version that runs on Aarch64?
Would that be called cross compiling too?
Gavinmc42
Posts: 1436
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: Building from source in OSX

Postby Gavinmc42 » Wed Jan 09, 2019 10:49 am

Hard to keep up fpc, 3.3.1-r20 is also working in Aarch64.
Not sure if 3.2/3.3 will break Ultibo anyway, so no hurry, still trying to get Laz 2.0? going.
Poi
Posts: 7
Joined: Mon Jan 07, 2019 11:57 pm

Re: Building from source in OSX

Postby Poi » Wed Jan 09, 2019 11:53 am

Ultibo wrote:The thing that stands out is that it is looking for ppcarm but the cross compiler should normally be called ppcrossarm instead.

Do you have ppcrossarm in /Users/johndoe/ultibo/core/fpc/bin?
Do you have ppcarm anywhere at all?
If you copy ppcrossarm to ppcarm does it help?


I have ppcrossarm, copied it from /Users/johndoe/ultibo/core/fpc/source/compiler to /Users/johndoe/ultibo/core/fpc/bin after I was done with the Building the FPC ARM Cross Compiler step of the instructions.

I did look for ppcarm, but couldn't find it anywhere

I was thinking of renaming my ppcrossarm to ppcarm, hoping that will do the trick.

I was also thinking of checking out the rtl task in the main Makefile, just to see what it is trying to do.
Poi
Posts: 7
Joined: Mon Jan 07, 2019 11:57 pm

Re: Building from source in OSX

Postby Poi » Wed Jan 09, 2019 9:55 pm

Managed to get all the way to the end!

Renaming ppcrossarm to ppcarm did the trick. After that, it was all smooth sailing.

Although it seems like it is a bug. I was looking at the source code and right in the part where it decides which executable to use, there is a special case for darwin. This is what I am talking about https://github.com/ultibohub/FPC/blob/master/source/compiler/utils/fpc.pp. Ofcourse, I have no clue what is
actually going on in there, so don't take me too seriously.

I still need to make a sample application to verify all of this is working, and since the only display I have for my raspberry pi zero is a PITFT 3.5", I might take a bit longer than I would like to get a "Hello World" up and running, specially because this is the first time I get my hands on a raspberry pi, and I think I already bludgeon the thing while trying to put the GPIO pins.

I'll post back.
Gavinmc42
Posts: 1436
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: Building from source in OSX

Postby Gavinmc42 » Thu Jan 10, 2019 1:47 am

I normally use USB boot mode on Zero's.
Saves SD card wear and is a bit quicker.

Not sure if the Zero identifies as a 500ma USB device?
It would need to if a LCD with backlight is also running from the USB port.
Now you got me interested I will have to try this ;)

Return to “Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests