From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Authentication-Results: plum.tunbury.org; dkim=pass (1024-bit key; unprotected) header.d=inria.fr header.i=@inria.fr header.a=rsa-sha256 header.s=dc header.b=Oo5GwJvk; dkim-atps=neutral Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=192.134.164.83; helo=mail2-relais-roc.national.inria.fr; envelope-from=caml-list-owner@inria.fr; receiver=tunbury.org Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by plum.tunbury.org (Postfix) with ESMTP id 01FE140098 for ; Fri, 5 Jun 2026 12:18:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=message-id:date:mime-version:to:references:from: in-reply-to:content-transfer-encoding:subject:reply-to: sender:list-id:list-help:list-subscribe:list-unsubscribe: list-post:list-owner:list-archive; bh=FBkU9kEzeGqBj5ieyyues3DE7VXfaope9AM7DL8caFc=; b=Oo5GwJvkMaqeR/guAo+w+xyJA9AyHz+7nZ4ZdtKNCWKcpZkMLwGc0AKr I97MuaSbgBKKEwRzz0vNZnlL/dpROuQuUILuOAmzCpNH9BvEetI3wfTHh PyArc6xvZX5kLBs05nGq9gEMfwVYwqlytd8FdFm+uD8DstcCezs1tiwNi E=; X-CSE-ConnectionGUID: d8vhMDexTCKjDXpW1k7N8w== X-CSE-MsgGUID: /seL31QZQaqwub7MnjmbIg== Authentication-Results: mail2-relais-roc.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=caml-list-owner@inria.fr; spf=None smtp.helo=postmaster@prod-sympa-app.inria.fr Received-SPF: SoftFail (mail2-relais-roc.national.inria.fr: domain of caml-list-owner@inria.fr is inclined to not designate 128.93.162.27 as permitted sender) identity=mailfrom; client-ip=128.93.162.27; receiver=mail2-relais-roc.national.inria.fr; envelope-from="caml-list-owner@inria.fr"; x-sender="caml-list-owner@inria.fr"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:128.93.142.0/24 ip4:192.134.164.0/24 ip4:128.93.162.160 ip4:128.93.162.3 ip4:128.93.162.88 ip4:89.107.174.7 mx ~all" Received-SPF: None (mail2-relais-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@prod-sympa-app.inria.fr) identity=helo; client-ip=128.93.162.27; receiver=mail2-relais-roc.national.inria.fr; envelope-from="caml-list-owner@inria.fr"; x-sender="postmaster@prod-sympa-app.inria.fr"; x-conformance=spf_only X-IronPort-AV: E=Sophos;i="6.24,188,1774306800"; d="scan'208";a="280005509" Received: from prod-sympa-app.inria.fr ([128.93.162.27]) by mail2-relais-roc.national.inria.fr with ESMTP; 05 Jun 2026 14:18:49 +0200 Received: by prod-sympa-app.inria.fr (Postfix, from userid 990) id 2C19881BF9; Fri, 5 Jun 2026 14:18:49 +0200 (CEST) Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by prod-sympa-app.inria.fr (Postfix) with ESMTP id 6191781BC2 for ; Fri, 5 Jun 2026 14:18:41 +0200 (CEST) X-CSE-ConnectionGUID: EmOpiGG4TvCb1XqxPZ/9Xw== X-CSE-MsgGUID: RxwD1lGISOuDoq2DF8RAyg== X-IronPort-AV: E=Sophos;i="6.24,188,1774306800"; d="scan'208";a="280005399" Received: from cadillac.paris.inria.fr (HELO [128.93.64.106]) ([128.93.64.106]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2026 14:18:41 +0200 Message-ID: Date: Fri, 5 Jun 2026 14:18:41 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: caml-list@inria.fr References: <20210305050509.GA97697@pllab.is.ocha.ac.jp> <20210305140334.GA6750@pllab.is.ocha.ac.jp> Content-Language: en-US From: Florian Angeletti In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Caml-list] a simple example of compiler-libs.toplevel? Reply-To: Florian Angeletti X-Loop: caml-list@inria.fr X-Sequence: 19525 Errors-To: caml-list-owner@inria.fr Precedence: list Precedence: bulk Sender: caml-list-request@inria.fr X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: Archived-At: To share the answer discussed during the compiler office hours, I have a very minimal example of a shallow wrapper around compiler-libs.toplevel (with at least its own toplevel loop) which replaces the prompt with a "λ" at https://github.com/Octachron/minitop Note also that the toplevel API is quite awkward and it tends to reflect what is used by the vanilla toplevel rather than what would be useful in general for a REPL. There are been remarks on this point from time to time and I rather agree with them, but I have yet to found the time to solve those paper cuts. Le 15/04/2026 à 14:45, Kenichi Asai a écrit : > Five years ago, I asked a question to this mailing list on how to > create a copy of the OCaml toplevel using compiler-libs (so that I can > customize it). I am trying it again. The thread is here: > > https://inbox.vuxu.org/caml-list/CANhEzE5tOqq7JXA47tmkQcnF6Bz70eU8jPBT+=+g2EwQ7cNf6Q@mail.gmail.com/T/ > > What I did is to copy the necessary files from the OCaml source (I am > working on OCaml 4.14.2.): > > topstart.ml, topmain.ml, toploop.ml, topeval.ml, topdirs.ml > topcommon.ml, trace.ml, genprintval.ml > > rename them to my_topstart.ml, my_topmain.ml, etc, rename all the > module references to the new ones (My_toploop instead of Toploop, etc.) > and compiled them with compiler-libs. See the toplevel1 directory of: > > https://github.com/kenichi-asai/toplevel-experiment > > However, when I compile them (by "make"), and execute the binary, I get: > > $ ./toplevel > OCaml version 4.14.2 > Enter #help;; for help. > > # let a = 3;; > Error: Reference to undefined global `Toploop' > # > > Why does this happen? > > When I search for "Toploop" in the OCaml source outside the toplevel > directory, I found lambda/translmod.ml mentions it: > > let toploop_ident = Ident.create_persistent "Toploop" > > Does this mean the toplevel must be given by the Toploop module > instead of My_toploop? > > As a second attempt, I created the toplevel2 directory of the above > repository, where I did not rename files to "my_*" but used the > original names. When I compiled them and execute the binary, I get > segmentation fault (!): > > $ ./toplevel > OCaml version 4.14.2 > Enter #help;; for help. > > # let a = 3;; > Segmentation fault > $ > > What's wrong? How can I create a copy of the OCaml toplevel using > compiler-libs? Any help appreciated. > > Another question. I also want to use dune to compile, instead of > OCamlMakefile. I provided dune and dune_project files in the > repository, but when I execute dune build, I obtain the following. > What am I doing wrong? > > $ dune build > File "dune", line 2, characters 7-18: > 2 | (name my_topstart) > ^^^^^^^^^^^ > Undefined symbols for architecture x86_64: > "_caml_get_current_environment", referenced from: > _camlDune__exe__My_topmain__fun_2483 in dune__exe__My_topmain.o > _camlDune__exe__My_topmain__1 in dune__exe__My_topmain.o > ld: symbol(s) not found for architecture x86_64 > clang: error: linker command failed with exit code 1 (use -v to see invocation) > File "caml_startup", line 1: > Error: Error during linking (exit code 1) > > Thank you in advance! >