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 34EC0BB9A for ; Wed, 9 Nov 2005 12:14:51 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id jA9BEoIg022262 for ; Wed, 9 Nov 2005 12:14:50 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id MAA08096 for ; Wed, 9 Nov 2005 12:14:50 +0100 (MET) Received: from mx2.mail.ru (mx2.mail.ru [194.67.23.122]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jA9BEnYj003917 for ; Wed, 9 Nov 2005 12:14:50 +0100 Received: from [164.8.213.91] (port=40357 helo=bely) by mx2.mail.ru with asmtp id 1EZnuh-000ImN-00 for caml-list@inria.fr; Wed, 09 Nov 2005 14:14:48 +0300 To: caml-list@inria.fr Subject: No unused code linking? From: Dmitry Bely Date: Wed, 09 Nov 2005 14:11:47 +0300 Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.5 (chayote, windows-nt) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Miltered: at concorde with ID 4371DA2A.003 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 4371DA29.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; stdlib:01 otherlibs:01 gcc's:01 ocamlopt:01 compiler:01 ocaml:01 -gy:98 functions:01 functions:01 dmitry:01 dmitry:01 executables:01 bely:02 bely:02 dbely:02 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 I am thinking of reducing the size of ocamlopt-generated executables that easily grows to 1Mb and above. The problem as I see it is that any module is linked as a single whole (as all its functions are placed into the single object file), no matter what is actually used. So almost all stdlib/otherlibs become quickly linked into even not very complex project. In C world there is a solution that lets the linker to do its job smartly for monolitic object files: place each function into the separate section (gcc's "-ffunction-sections" or msvc's "-Gy" options) and then ask linker to eliminate unused sections during the link stage. Can anything similar be done with Ocamlopt compiler? Of course, placing each function into the separate section is not a problem - modifications of the code generator would be minimal. The real problem are the frame tables - the single table references all functions in the module. Maybe they can be split and linked separately? What Ocaml developers think of that? - Dmitry Bely