Can C/C++ software be compiled into bytecode for later execution? (Architecture independent unix software.)

前端 未结 6 925
失恋的感觉
失恋的感觉 2021-02-04 17:34

I would want to compile existing software into presentation that can later be run on different architectures (and OS).

For that I need a (byte)code that can be easily ru

6条回答
  •  庸人自扰
    2021-02-04 18:08

    LLVM is not a good solution for this problem. As beautiful as LLVM IR is, it is by no means machine independent, nor was it intended to be. It is very easy, and indeed necessary in some languages, to generate target dependent LLVM IR: sizeof(void*), for example, will be 4 or 8 or whatever when compiled into IR.

    LLVM also does nothing to provide OS independence.

    One interesting possibility might be QEMU. You could compile a program for a particular architecture and then use QEMU user space emulation to run it on different architectures. Unfortunately, this might solve the target machine problem, but doesn't solve the OS problem: QEMU Linux user mode emulation only works on Linux systems.

    JVM is probably your best bet for both target and OS independence if you want to distribute binaries.

提交回复
热议问题