1. Translate once, run anywhere.
- Posted by SDPringle Jun 08, 2022
- 1592 views
It has been a problem that once we have code in C it is fixed to one platform and architecture or another. To me the code produced by the translator should be portable. Testing this is rather adhoc though. Is there anyone around with 32-bit systems or UNIX systems that are not Linux who would like to participate in experiments of getting a translated to C helloworld program to compile so the buildsys can eventually do the right thing and create portable C code?
2. Re: Translate once, run anywhere.
- Posted by ghaberek (admin) Jun 09, 2022
- 1558 views
It has been a problem that once we have code in C it is fixed to one platform and architecture or another. To me the code produced by the translator should be portable. Testing this is rather adhoc though. Is there anyone around with 32-bit systems or UNIX systems that are not Linux who would like to participate in experiments of getting a translated to C helloworld program to compile so the buildsys can eventually do the right thing and create portable C code?
I would love to accomplish this because it's been itching at me for a while. The current Makefile is huge, uses a lot of recursion, and repeats itself often.
I think it would be best to set the current Makefile aside build a new one, while updating the backend code to be as platform-agnostic as possible.
Most of the macros that are set by configure can simply be inferred by the backend automatically and overridden when necessary.
Here is a good resource for predefined macros: https://sourceforge.net/p/predef/wiki/Home/
-Greg
3. Re: Translate once, run anywhere.
- Posted by mitgedanken Jun 10, 2022
- 1538 views
I suggest to use LLVM as backend. It's portable. But it needs time. So, I guess it will be done for 5.0?
4. Re: Translate once, run anywhere.
- Posted by mitgedanken Jun 10, 2022
- 1531 views
Oh, and for Windows we could use FlexDLL. Then it will be easier to write portable DLLs which we could use now.
5. Re: Translate once, run anywhere.
- Posted by ghaberek (admin) Jun 10, 2022
- 1523 views
I suggest to use LLVM as backend. It's portable. But it needs time. So, I guess it will be done for 5.0?
I'm not sure what the cost/benefit trade-off looks like for something like LLVM. I think we'd effectively just be adopting LLVM as a platform with a front-end for ingesting Euphoria code to LLVM IR (intermediate representation).
Euphoria already has its own IR, but we call it IL (intermediate language) and it's very much purpose-built for Euphoria, while LLVM IR is meant as an abstracted layer between any language and any architecture.
Don't get me wrong, LLVM is great and I'd love to see somebody build a Euphoria front-end for LLVM at some point. It'd be a neat project! But I think it would be a new dialect of the language (like Phix) and not "Euphoria" per se.
Other similar projects I've looked at are QBE which is lighter-weight but sadly only supports x64, and TinyCC which supports various platforms and is relatively portable and supports many architectures.
If anything, what I may do in the future is package TinyCC with Euphoria so the translator always has something to use out of the box, and users could still choose GCC if they want. Hypothetically it could also provide JIT-style execution.
Oh, and for Windows we could use FlexDLL. Then it will be easier to write portable DLLs which we could use now.
I'm not sure I understand what problems we have that this project would solve?
I don't think Shawn was proposing we make portable binaries just that the C code coming out of the translator be identical regardless of where it's run from, and then rely on the compiler to make the platform-specific executable or library.
One thing I'd really like to see is being able to "load" a DLL built with the translator as if it were an include file. That would require exporting a symbol and then having a way to import it again later.
-Greg
6. Re: Translate once, run anywhere.
- Posted by achury Jun 12, 2022
- 1500 views
I wonder what about using eu4 transñater with eu3.1 source. Is possible to use it to compile the euphoria-only source to win or linux with 64 bits?
7. Re: Translate once, run anywhere.
- Posted by SDPringle Jun 13, 2022
- 1438 views
The eu3.1 code is written with assumptions about pointer size. Simply translating it to C wouldn't have fixed that. Why would you want to use 3.1?
8. Re: Translate once, run anywhere.
- Posted by SDPringle Jun 13, 2022
- 1437 views
Walk before you run. Ideally, a man would be able to download the translated C source of the Euphoria interpreter which could have been translated on Windows, and then just run 'configure;make' on his NetBSD system. I'm starting with trivial programs.
If anyone would like to volunteer, you don't need to know how to code C. You do need a C compiler; either some GNU variant or Watcom.
https://github.com/OpenEuphoria/translator-generated
The repo is for code the translator generates. check it out. In the hello subdirectory try 'sh configure;make' or 'wmake'.
To get your own portable C, checkout the branch here: https://github.com/OpenEuphoria/euphoria/tree/translator-portable-c
For this part you would need to know how to compile Euphoria binaries. It's pretty much 'configure;make' on Linux.
9. Re: Translate once, run anywhere.
- Posted by gdm85 Sep 27, 2022
- 925 views
Hi there,
I come from this other thread; I would be interested in making sure that all sources to build Euphoria can be generated from scratch; as I understand that requires the pre-translated sources.
Unfortunately I cannot manage to generate them using Ubuntu/Debian.
Would anyone be interested in helping out to achieve this?
10. Re: Translate once, run anywhere.
- Posted by ghaberek (admin) Sep 27, 2022
- 967 views
Hi there,
I come from this other thread; I would be interested in making sure that all sources to build Euphoria can be generated from scratch; as I understand that requires the pre-translated sources.
Unfortunately I cannot manage to generate them using Ubuntu/Debian.
Would anyone be interested in helping out to achieve this?
Let's keep this discussion in that thread and I will try to help you there.
-Greg