kekcleader / FreeOberon

Cross-platform IDE for development in Oberon programming language made in the classical FreePascal-like pseudo-graphic style.
GNU General Public License v3.0
135 stars 14 forks source link

How to build on macOS ? #10

Open ijean opened 10 months ago

ijean commented 10 months ago

Hi, I learned about FreeOberon from a HN post. I was able to to build and run the code in a x86_64 VM, but my main computing device is an arm64 MacBook from 2021 and I was wondering if it will be possible to build and use FreeOberon on macOS. I installed liballegro 5 using Homebrew on my Mac, but the docs of FreeOberon seem to target mostly x86_64 Linux. It would be great if you could write a short intro of how to build it on macOS. Regards, Jean

ijean commented 10 months ago

In case you do not have access to macOS, instructions for building for a Debian system for arm64 (aarch64) would be great also. It is much easier for me to run arm64 Linux virtualized on macOS than to run x86_64. Regards, Jean

kekcleader commented 10 months ago

Hi @ijean Yes, I don't have access to MacOS, but I know Ofront+ (this repo's submodule) can be compiled for MacOS. Free Oberon is also cross-platform, so should compile well.

Neither I have access to arm64 computer. Can I virtualize it on an ordinary x86_64 Linux or Windows?

ijean commented 10 months ago

Hello, I tried to build Ofront+ on macOS, but it crashed at some point due to missing some SDL dependencies (I did not had time dig too much into what caused the crash). I think you can virtualize an arm64 if you use QEMU on a powerful x86_64 machine. Alternatively, if you have a Raspberry Pi around (3B or 4B) you can use it if you install the 64 bits version of Raspberry OS. Regards, Jean

kekcleader commented 10 months ago

An old version of Free Oberon had SDL as a dependency, but now it is based on Allegro 5. SDL is not a dependency any more. I think I'll try QEMU

ijean commented 10 months ago

I tried building on a Debian arm64 machine and failed. Than I tried to build just Ofront+, failed again. I opened a new issue on Ofront+ if you want to have a look https://github.com/Oleg-N-Cher/OfrontPlus/issues/122

Thanks, Jean

Oleg-N-Cher commented 9 months ago

Hello, I tried to build Ofront+ on macOS, but it crashed at some point due to missing some SDL dependencies

SDL support is only needed to build examples (Target/macOS/Examples) that work with the graphics window. The Ofront+ itself does not need SDL and does not require it.

ijean commented 9 months ago

@Oleg-N-Cher Yes, I realized that later, SDL is not needed to build the translator.

Biggest problem on macOS is that your provided ofront+ executable can't be run no matter what I tried (chmod +x and so on ...).

I assume there is no way to build without having this ofront+ binary ?

Oleg-N-Cher commented 9 months ago

Biggest problem on macOS is that your provided ofront+ executable can't be run no matter what I tried (chmod +x and so on ...).

As you know, there is Intel-macOS and there is Motorola-macOS platforms. I offer a built binary for Motorola-Mac only.

I assume there is no way to build without having this ofront+ binary ?

No, you can still build your own binary for the platform you need using a host Linux system or Wine.

After that you will get the executables ofront+ and all utilities and you can rebuild ofront directly on your mac.

The Wine method is a little simpler. If you have Wine installed on your mac, run Target/macOS/Lib/Bin/o2c.bat and Target/macOS/Bin/o2c.bat, after this, run Target/macOS/Lib/Bin/cc and Target/macOS/Bin/cc

ijean commented 9 months ago

Hi, I did as you suggested, I run o2c on Debian arm64 in Target/macOS/Lib/Bin/o2c and Target/macOS/Bin/o2c. Moved the repo to my Mac and tried to run cc. Like before it failed while trying to link the SDL2, I wonder if your cc script tries to build the Examples.

Screenshot 2023-11-20 at 10 31 35 AM
ijean commented 9 months ago

Yep, check the cc script from Target/macOS/Lib/Bin, your script tries to build and link with SDL2.

## Free Oberon

$CC SDL2.c SDL2mixer.c In.c Out.c Graph.c Sound.c Turtle.c -w
if [ $? != 0 ]; then exit 1; fi
$AR SDL2.o SDL2mixer.o In.o Out.o Graph.o Sound.o Turtle.o
Oleg-N-Cher commented 9 months ago

Well, you saw for yourself that your Linux on aarch64 compiled that.

What a C compiler (version) did you use on your mac?

ijean commented 9 months ago

On macOS Ventura (aarch64/arm64) I used the default C compiler - Clang:

~ % clang --version
Apple clang version 15.0.0 (clang-1500.0.40.1)
Target: arm64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Oleg-N-Cher commented 9 months ago

Hmmm... I didn't know there was a macOS on the arm architecture.

I don't see a quick way to help you, as although I have made Clang support for Ofront+, its various versions (especially newer ones) can have unexpected behavior.

The module "Sound" that is causing the problems is not critical for Ofront+ builds. Try to remove it from Target/Lib/Bin/cc

Ignore the warnings for now. Send me the full log with warnings as a text file. But I don't know where I can run exactly your version of Clang. What are your comments on this problem?

ijean commented 9 months ago

After I removed Sound.c and Sound.o from the cc script I was able to build the library and executable !

(As a side note Apple moved all their laptops and desktops to the arm architecture since 2020.)

I don't think Clang is the problem, C code is C code and it should be the same on both GCC and Clang. What is interesting is that same code behaves a bit different on Linux and macOS (both in principle POSIX systems).

If you don't have access to a Mac produced after 2020, I think best approximation would be FreeBSD aarch64. FreeBSD also uses Clang as the default system compiler.

An alternative is to use GitHub Actions which let you build software for various architectures. Apparently it is free for open source projects, but I never used it so I don't know exactly how it works:

https://github.com/features/actions

I've attached a file with the warnings I get when I run "cc" in Lib/Bin. warns.txt

Oleg-N-Cher commented 9 months ago

I think I fixed the bugs. If you still have them, that would be weird. But I didn't do anything about the warrnings.

Plz, re-download the repository. See if these warnings happen again?

ijean commented 9 months ago

Thanks, I was able to build it, still got the warnings but I built the ofront+ executable.

Oleg-N-Cher commented 9 months ago

I'll figure out what to do about the warnings when I can reproduce it at my place.

If you manage to build examples (macOS/Examples), let me know. I haven't been able to do something with SDL.