ngagesdk / ngage-toolchain

A modern CMake toolchain for Symbian S60v1 devices such as the Nokia N-Gage.
MIT License
89 stars 2 forks source link

Update GCC to version 4.6.4, add Linux support #9

Open mupfdev opened 2 years ago

mupfdev commented 2 years ago

In the long run, it would make sense for the compiler to be replaced by one that is somewhat more up-to-date. This would also be interesting for development on *nix-based operating systems.

The latest possible version would be 4.6.4, as support for ARM PE executables was removed in later versions.

Unfortunately, I have not been successful in my previous attempts and could use some help in this regard.

FtZPetruska commented 1 year ago

Okay, over the past few days I've taken a crack at it so here's a breakdown of my approaches and findings.


Approach 1 - Reverting the arm-epoc-pe removal

For this approach, I took all the commits in GCC and binutils that aimed to remove the arm-epoc-pe backend, and tried to revert them on the latest release.

While this appeared to work initially, many issues arose when building libgcc. Most notably, the assembler would SEGFAULT when assembling lib1funcs. I suspect the removal of all *-*-pe targets has taken away some glue common to all these backends.

Other limitations/issues I have noticed are:

NB: Reusing libgcc from the existing SDK does not work either.

Approach 2 - Building a newer GCC version before arm-epoc-pe removal

This approach is simple:

The last version supporting arm-epoc-pe are:

Binutils compiled with no issue and seemed to work.

GCC on the other hand did not work at all:

Most specifically, cc1 hits a SEGFAULT regardless of the mode used:

I looked around bug trackers and couldn't find anyone discussing similar issues.

I saw a stackoverflow post (that I can't find anymore) suggesting that mpfr (a GCC dependency) was maybe "too new". So I attempted to downgrade it to the recommended 2.4.2 (along the necessary downgrades of gmp and mpc), but it did not solve the issue.


So unfortunately, after working on them for a few days, I wasn't able to make either approach work, and I won't have time to keep working on this.

One last note is the following project: https://www.inf.u-szeged.hu/projectdirs/symbian-gcc/index.php

I wasn't able to build it from source on any machine because GCC's config.gcc does not know about x86_64, and makes the assumption that darwin only runs on PowerPC. So while an i386 build should be possible in theory on Windows:

mupfdev commented 10 months ago

@FtZPetruska Look here, is this helpful in any way?

https://github.com/fedor4ever/GCC4Symbian

FtZPetruska commented 10 months ago

I'm not sure it would. The SDK for the ngage specifically ships with an arm-epoc-pe toolchain, on the other hand, this toolchain targets arm-none-symbianelf (actually, this is still a valid target in GCC and binutils).

This seems to be targeted to more recent Nokia devices running at least armv5 CPUs (ngage runs armv4 afaik).

mupfdev commented 9 months ago

@FtZPetruska managed to compile a toolchain based on GCC 4.6.4, however, it does not work with the SDK yet due to relocation errors when linking. Needs further investigation.