-
Notifications
You must be signed in to change notification settings - Fork 154
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
Add support for running MIR binaries, useful for binfmt_misc #389
Conversation
In order to be able to execute `.bmir` files directly from the command line, a "soft link interface" was added (similar to busybox), where the links `c2m-ei`, `c2m-eg` and `c2m-el` are created, pointing to `c2m`. These links, to correspond with the binfmt nomenclature, are referred as `interpreters` The c2mir driver source was adapted to check if the argv[0] is any of those links. Invoking `c2m` through those links is similar to invoking using ``` $ c2m /path/to/binary {-ei | -eg | -el} <args>... ``` To use with `binfmt_misc`, the driver expects the `P` flag on the binfmt format, that is, the first argument should be the full path to the executable binary. ``` ./a.bmir <args>... c2m-ei /path/to/a.mir ./a.mir <args...> ``` or if the binary is in PATH ``` a.bmir c2m-ei /usr/local/bin/a.mir a.mir ``` The binfmt line is ``` :mir:M::MIR:/usr/local/bin/c2m-el:P ``` Do adapt the path where the `c2m-*` are and possibly change `-el` to your favorite interface (interpeted, generated or lazy)
This reverts commit db5157a.
As a follow up on `binfmt_misc`, a new `mir-run` tool is created to handle the running of bmir binaries. The MIR execution type is defined by the `MIR_TYPE` environment variable, defaulting to `interp` (other options are `jit` for generation and `lazy` for lazy code generation). This tool also accepts extra libraries to be loaded using the `MIR_LIBS` environment variable and extra library paths to search through environment variables `LD_LIBRARY_PATH` and `MIR_LIB_DIRS` (besides the default ones).
A new "interface" was added, As a follow up on The MIR execution type is defined by the This tool also accepts extra libraries to be loaded using the |
Note: library loading is still a work in progress... |
Initialize temp_string array and use malloc instead of alloca
Just a minor fix needed after all |
Thank you for the pull request implementing an interesting feature. I'll review it on this week. If it is ok for me, I'll merge it. I'll probably do some additional changes in doc (and may be in makefile) after that as this feature is not portable. Still it is pretty interesting. Thank you for the PR again. |
Sorry for the delay. I was and still am very busy. Thank you for the PR. I've merged it. |
Would be nice to also have this available in bbv branch. |
Add support for running MIR binaries, useful for binfmt_misc
(Tries to solve #378 )
In order to be able to execute
.bmir
files directly from the command line, a "soft link interface" was added (similar to busybox), where the linksc2m-ei
,c2m-eg
andc2m-el
are created, pointing toc2m
.These links, to correspond with the binfmt nomenclature, are referred as
interpreters
The c2mir driver source was adapted to check if the argv[0] is any of those links.
Invoking
c2m
through those links is similar to invoking usingTo use with
binfmt_misc
, the driver expects theP
flag on the binfmt format, that is, the first argument should be the full path to the executable binary.or if the binary is in PATH
The binfmt line is (echo it to
/proc/sys/fs/binfmt_misc/register
as root, or add it to /etc/binfmt.d/)Do adapt the path where the
c2m-*
are and possibly change-el
to your favorite interface (interpeted, generated or lazy)