From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 4DB0BBB9C for ; Thu, 17 Nov 2005 17:14:59 +0100 (CET) Received: from [128.93.8.130] (macadam.inria.fr [128.93.8.130]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id jAHGExa7008931 for ; Thu, 17 Nov 2005 17:14:59 +0100 Mime-Version: 1.0 (Apple Message framework v746.2) In-Reply-To: References: Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: Damien Doligez Subject: Re: [Caml-list] bytecode apps without stdlib/pervasives Date: Thu, 17 Nov 2005 17:15:11 +0100 To: caml-list X-Mailer: Apple Mail (2.746.2) X-Miltered: at concorde with ID 437CAC83.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; damien:01 damien:01 caml-list:01 bytecode:01 stdlib:01 pervasives:01 exn:01 compiler:01 ocaml:01 stdlib:01 ocamlc:01 -nostdlib:01 binary:01 flags:01 -nostdlib:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 On Nov 15, 2005, at 23:45, Jonathan Roewen wrote: > Hi, > > I have a simple ML file (test.ml): > > external raise : exn -> 'a = "%raise";; > > raise End_of_file;; > > so I can check how the compiler does things (like if predefined ocaml > symbols are still present without stdlib present), and compile as: > > ocamlc -nostdlib -nopervasives test.ml, which generates a.out. > > when I run it, I get error: "-bash: ./a.out: cannot execute binary > file" (btw, generates expected behabiour without those flags) > > why can't it execute it? can we only use -nostdlib as long as we > provide our own pervasives module? Note that a.out is still a valid bytecode file: ocamlrun ./a.out works. What happens is that ocamlc tries to create an executable bytecode file, by prepending the standard header (#!/usr/local/bin/ocamlrun) to your bytecode file. But it can't find this header because you have specified -nostdlib, thus preventing it from looking in its library directory. It explicitely ignores the "file not found" error, I'm not sure why. What you can do is provide your own header file, named "camlheader", and placed in one of the directories searched by ocamlc. If you don't give any -I option, this has to be the current directory: $ echo '#!/bin/echo foo' >camlheader $ ocamlc -nostdlib -nopervasives test.ml $ ./a.out foo ./a.out -- Damien