OCaml Forge

Detail: [#860] CompiledObject: Both

Feature Requests: Browse | Download .csv | Monitor

[#860] CompiledObject: Both

2011-01-03 17:34
Submitted by:
Török Edwin (edwin)
Assigned to:
Sylvain Le Gall (gildor-admin)
Due in version:
Plugin OCamlbuild
Operating System:
CompiledObject: Both

Detailed description
Sometimes I want to build same target both as bytecode and native.
For example: unit-tests. I want to make sure that my application works both as bytecode and as native executable.
Currently this means I need to create 2 executable targets, with same dependencies and everything listed, except first one is CompiledObject: Byte, and second one is CompiledObject: Native Build$: flag(is_native).

Another example: libraries. If you ship libraries you usually want to ship both bytecode and native ones.

It'd be nice if _oasis supported an CompiledObject: Both, that will build both native and bytecode executables if is_native, and only bytecode if native is not available. The executables will then be called .byte and .native as usual with ocamlbuild.


Date: 2011-01-27 10:48
Sender: Sylvain Le Gall

Yes, "Both" won't fail on non native arch. This is the difference with @2011-01-26 14:21.
Date: 2011-01-27 08:47
Sender: ygrek

Hm, this is the same that was proposed @2011-01-26 14:21? Usecase that I have in mind - test target that builds both byte and native versions of executable and runs them. Currently this can only be achieved with two executable sections. With "CompiledObject: Both" that doesn't fail it becomes possible to run both with simple is_native check in Test section for non-native archs. "CompiledObject: Both" that fails on non-native arch is useless in such setup.
Date: 2011-01-26 21:26
Sender: Sylvain Le Gall

$test = test.native or test.byte
$test_byte = test.byte
$test_native = test.native

Test main
Run: $test

On arch that doesn't have ocamlopt anyway, we won't compile native application anyway and $test = test.byte (and $test_native won't be set)

Is it better ?
Date: 2011-01-26 20:59
Sender: ygrek

> If it is not possible, the build will fail.
Better not.
Then test stage looks like :
Test main
Run: $test_byte
if $is_native
Run: $test_native
Date: 2011-01-26 18:05
Sender: Török Edwin

Works for me.
Date: 2011-01-26 14:21
Sender: Sylvain Le Gall

I feel that I will need to acknowledge the popular pressure!

What about adding Both to "Best, Native, Byte" that will: force to build both native and byte version for applications. If it is not possible, the build will fail. "Both" will not be accepted for libraries.

For an "Executable test" the variable $test will point to the best version (byte or native) and $test_byte and $test_native to byte and native executable.

Is it ok for both of you ?
Date: 2011-01-26 11:04
Sender: ygrek

I second this request - it is useful for tests.
Date: 2011-01-03 23:32
Sender: Sylvain Le Gall


First libraries: using CompiledObject: Best for libraries, generates bytecode
and native versions. So in the case of library, I don't think Both is mandatory.

Concerning executables, I think this feature is maybe a little bit an exceptional
case. I mean that you will deliver only a bytecode or a native targets. I agree
that this can be useful for debugging, but for now I'll need to think about it
-- I am not convince that is such a common case.

Attached Files:


Field Old Value Date By
assigned_tonone2011-01-03 23:32gildor-admin