You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently we depend on either gcc and the standard libc, or with the --ld-musl flag on ld and musl. It would be nice to be able to compile executables without depending on any external package.
To do so, we have to link the .o files ourselves (see also numba/llvmlite#311). One can use link_in() in llvmlite to link the LLVM modules together, then we have just one .o file. Then we need to convert it into an executable.
The second step is to figure out how to link in other libraries (such as libc and others).
The compiler will have several options:
a) use gcc to link (already implemented as default)
b) use ld to link (already implemented as --ld-musl)
c) or our own linking (to be implemented, see above)
The advantage of a) is that it works on all platforms easily, but one depends on gcc. The advantage of b) is that it doesn't require gcc, but it is more platform dependent. The advantage of c) is that it doesn't depend on any external package, and so the compiler is completely self-contained/self-sufficient to produce executables, but we have to implement the functionality of a linker, which is specific to each platform.
I think a good plan for c) is to start with a simple proof of concept that works, and then keep improving it. It doesn't have to be feature complete right away, as one can use a) or b) for that.
The text was updated successfully, but these errors were encountered:
Original issue: https://gitlab.com/lfortran/lfortran/-/issues/45
Currently we depend on either
gcc
and the standardlibc
, or with the--ld-musl
flag onld
andmusl
. It would be nice to be able to compile executables without depending on any external package.To do so, we have to link the
.o
files ourselves (see also numba/llvmlite#311). One can uselink_in()
inllvmlite
to link the LLVM modules together, then we have just one.o
file. Then we need to convert it into an executable.The first step is to do it without linking against any other library (such as
libc
). Here are some initial pointers how to do get started on that:https://blogs.oracle.com/linux/hello-from-a-libc-free-world-part-1-v2
https://blogs.oracle.com/linux/hello-from-a-libc-free-world-part-2-v2
http://www.muppetlabs.com/~breadbox/software/tiny/teensy.html
https://stackoverflow.com/a/2548601/479532
The second step is to figure out how to link in other libraries (such as
libc
and others).The compiler will have several options:
a) use
gcc
to link (already implemented as default)b) use
ld
to link (already implemented as--ld-musl
)c) or our own linking (to be implemented, see above)
The advantage of a) is that it works on all platforms easily, but one depends on
gcc
. The advantage of b) is that it doesn't requiregcc
, but it is more platform dependent. The advantage of c) is that it doesn't depend on any external package, and so the compiler is completely self-contained/self-sufficient to produce executables, but we have to implement the functionality of a linker, which is specific to each platform.I think a good plan for c) is to start with a simple proof of concept that works, and then keep improving it. It doesn't have to be feature complete right away, as one can use a) or b) for that.
The text was updated successfully, but these errors were encountered: