-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cross compilation? #12
Comments
The Seed7 compiler uses a C compiler as back-end. Seed7 can cross compile if there are multiple C compilers (for different targets) or a C compiler that can cross-compile. Currently cross compilation is supported for compilation to JavaScript/web-assembly (with Emscripten). When Seed7 is compiled with Emscripten (makefile mk_emccl.mak for Linux and mk_emccw.mak for Windows) preparations for cross compilation are done:
If Seed7 has been compiled for the local machine and for JavaScript/web-assembly the Seed7 compiler can be used in two ways:
Basically this concept can be extended to other cross compilation situations. |
Could you let the C compiler be configurable (along with compiler flags), so Zig could be used and consequently you would get cross-compilation to any target for free? |
I assume you are referring to the Seed7 compiler that generates C. The Seed7 compiler is configurable but it always generates C (tailored for a specific C compiler and operating system). Changing the Seed7 compiler to emit another language would be a significant effort. Probably a complete rewrite would be necessary. If I would do that I would aim for a much more common platform such as JAVA or the JVM. Supporting the JVM as platform would also be possible by using a C compiler that targets the JVM. Unfortunately such C compilers are highly experimental and not well maintained. |
I should've been more clear. The Zig compiler can (cross-)compile C code. https://andrewkelley.me/post/zig-cc-powerful-drop-in-replacement-gcc-clang.html Uber is using Zig to cross compiler their C code and they probably don't use Zig as a language (yet). To configure Seed7 to use zig, you basically need to replace |
In the linked blog post, Andrew Kelly, author of Zig, shows how to cross compile a C project, LuaJIT:
It works so easily in this case because the LuaJIT makefile allowed for "plugging in" another C compiler (using What I am suggesting is that you make compilation in Seed7 work similarly. |
The cross compiler can even emit WASM, besides a large number of OS/architectures. |
I see what you mean:
would compile to a Windows executable and
would compile to a Linux executable for the MIPS processor with the MUSL run-time library.
The makefiles of Seed7 use also CC. Additionally they contain also C compiler specific options. So changing CC might not be enough. But if Seed7 does not just use C but also the C run-time library and many operating system specific functions.
WASM is already supported by Seed7. Take a look at mk_emccl.mak and mk_emccw.mak. They use the Emscripten C compiler. As mentioned further above this is supported with the cross-compilation option The Seed7 compiler is prepared to switch between different C compilers (and their run-time libraries) with the option |
I dont see any option for compile to another target in the s7c options. Is it planned/possible?
Cross compilation feels like something primordial to a modern compiled language to me, specially when you enforces that the code is portable across multiple targets... we should be able to compile to them from the same environment.
Just asking, amazing project, found yesterday and I am following the manual.
The text was updated successfully, but these errors were encountered: