TrampolineRTOS / trampoline

Trampoline is a static RTOS for small embedded systems. Its API is aligned with OSEK/VDX OS and AUTOSAR OS 4.2 standards.
GNU General Public License v2.0
620 stars 269 forks source link

Multiple POSIX targets #141

Closed jlbirccyn closed 1 year ago

jlbirccyn commented 1 year ago

From the very beginning, the POSIX port has been slightly different between Mac OS X and Linux when building an application. Indeed, on Linux, certain functions linked to the management of semaphores used for synchronization between Trampoline and Viper are in the librt for historical reasons, whereas on Mac OS X they are in the libsystem.

In addition, on Apple Silicon Macs (arm64), for some reason I can't explain, building a Trampoline application produces x86_64 code which is then run in emulation with Rosetta. This poses a problem for testing, as the libEmbunit is compiled in arm64 and linking between it and Trampoline is impossible. You need to add the -arch arm64 option to force native code generation.

What I propose is to add subarchitectures to posix: linux, darwin and darwin/arm64 so as to put in config.oil of linux LDFLAGS = "-rt"; and in the config.oil of darwin/arm64 CFLAGS = "-arch arm64" and LDFLAGS = "-arch arm64";.

RICCIARDI-Adrien commented 1 year ago

Seems fine to me. If I have understood correctly, you would add the goil/templates/config/posix/darwin/arm64 and put the relevant CFLAGS and LDFLAGS in each goil/templates/config/posix subarchitecture.

jlbirccyn commented 1 year ago

Yes, and goil/templates/config/posix/linux too

sefau commented 1 year ago

Seems OK for me too. Given that there are still some X86-64 darwin machines around, should we also have a corresponding target? In the same vein, should we have subdirectories in linux?

RICCIARDI-Adrien commented 1 year ago

It seems to me that goil/templates/config/posix/linux is already existing. It works fine on Debian and Ubuntu, which are the most used development systems nowadays. I think that the Linux part can stay as it is to ease maintenance.

jlbirccyn commented 1 year ago

Given that there are still some X86-64 darwin machines around, should we also have a corresponding target? In the same vein, should we have subdirectories in linux?

Since X86-64 Darwin is the lowest common denominator (needs only the -lpthread option), it compiles with --target=posix/darwin only.

As Adrien said linux is already there. So we would have in the end:

--target=posix/linux
--target=posix/darwin
--target=posix/darwin/arm64
jlbirccyn commented 1 year ago

Done with 1aa8c1a9f6743bc8b9ee270a5db7fdc14d402a2d