MichalStrehovsky / zerosharp

Demo of the potential of C# for systems programming with the .NET native ahead-of-time compilation technology.
2.02k stars 105 forks source link

Single elf binary output. #20

Closed martasp closed 3 years ago

martasp commented 3 years ago

Is it possible to compile it down to a single ELF binary file?.

MichalStrehovsky commented 3 years ago

Yes, the samples could be adapted to that. The build scripts need to be modified to either pass --targetos linux to ilc.exe or just invoke ilc on Linux from the Linux nuget package (the default target os is always the one the compiler is running on but it can crosscompile). Once you do that, you'll get an ELF object file.

That object file can be passed to ld.

Of course the samples here call Windows apis so you need to change them to e.g. call into libc.

MichalStrehovsky commented 3 years ago

I've updated the samples in https://github.com/MichalStrehovsky/zerosharp/commit/26b8800c63f2ddbbfc1927861299008a59f916d9. It's possible to build the no-runtime sample for Linux now.