From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 1B3FE7F917 for ; Fri, 6 Jun 2014 22:24:47 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of info@gerd-stolpmann.de) identity=pra; client-ip=212.227.126.130; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="info@gerd-stolpmann.de"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of info@gerd-stolpmann.de) identity=mailfrom; client-ip=212.227.126.130; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="info@gerd-stolpmann.de"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mout.kundenserver.de) identity=helo; client-ip=212.227.126.130; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="postmaster@mout.kundenserver.de"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AskEAPUiklPU436ClGdsb2JhbABZgyI9xGEBgQcWDwEBAQEHCwsJEiqEBAEFVSQQCw44VwYTCRKIKwmuMyFvDZ4DF4kihSEmB4RBBJAtgTqBO4JxinsFkAxq X-IPAS-Result: AskEAPUiklPU436ClGdsb2JhbABZgyI9xGEBgQcWDwEBAQEHCwsJEiqEBAEFVSQQCw44VwYTCRKIKwmuMyFvDZ4DF4kihSEmB4RBBJAtgTqBO4JxinsFkAxq X-IronPort-AV: E=Sophos;i="4.98,991,1392159600"; d="sh'?scan'208";a="65796681" Received: from mout.kundenserver.de ([212.227.126.130]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 06 Jun 2014 22:24:46 +0200 Received: from office1.lan.sumadev.de (dslb-178-004-064-210.pools.arcor-ip.net [178.4.64.210]) by mrelayeu.kundenserver.de (node=mreue004) with ESMTP (Nemesis) id 0MN912-1Wqptt1sDY-006ieM; Fri, 06 Jun 2014 22:24:45 +0200 Received: from [192.168.0.146] (546BEFE6.cm-12-4d.dynamic.ziggo.nl [84.107.239.230]) by office1.lan.sumadev.de (Postfix) with ESMTPSA id B85A9DC270; Fri, 6 Jun 2014 22:24:44 +0200 (CEST) Message-ID: <1402086284.3141.12.camel@e130> From: Gerd Stolpmann To: Andreea Costea Cc: "caml-list@inria.fr" Date: Fri, 06 Jun 2014 22:24:44 +0200 In-Reply-To: References: Content-Type: multipart/mixed; boundary="=-jxGLJviMkMYsvEzk9dHl" X-Mailer: Evolution 3.10.4-0ubuntu1 Mime-Version: 1.0 X-Provags-ID: V02:K0:XGiCfIXsKCQ1ikhpTUMz+26OHkaPs9wSHvOng1/o3V0 wDIRK8dPUhgwtS7+ZnE5Opue79JA6PvLTaZfVUuxmFyAZiCvfT +uj2OLIESZkv1qHvmlz3Uw4HiACLMCF9ZjyRCfzkRdj6L0h60F kbtIPZxWXBUm+IvBiDxvHn/dQIcK7Kty/ViQsVy3cUBzhN4Wpy r/pkS1LDjJjVO0cBu3HX+HBwelqCnJ9fAxIjG4C0SoWqaW5Wbs DrOeCqm3NePEaZrtvK7jRsA16+4JvxNuYfMfqdMqCulAmsSqk1 xfBxkXvum/UmrL0iFAvkXt6FPPfl1BtbyKEqoRzCsHFvSnlQrz l4IwnJg4ez6eDIeJj07FvxW2gpnQmh0tGReFOhCdA Subject: Re: [Caml-list] static linking --=-jxGLJviMkMYsvEzk9dHl Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: 7bit I'd strongly recommend against linking statically libc and other core system libraries (e.g. libm, libdl, librt, ...). This creates more problems than it solves. Instead, only link those libraries statically that are causing the trouble. Unfortunately, this isn't directly possible by just passing a linker option, but there is a solution by rewriting the linker arguments: See the attached script gcc_wrapper.sh (I'm using this or a derivative, depending on the system). Just tell ocaml to use this script as C compiler: ocamlopt ... -cc ./gcc_wrapper.sh ... Also set the environment variable STATIC_LIBS to the names of the libraries you'd like to link statically (e.g. STATIC_LIBS="pcre z" would select libpcre and libz). The script here is only activated when there is an -o .opt argument. You may want to modify this part. (I'm just taking the version of the script from the plasma project; some more work is required to make it fully generic.) Gerd Am Freitag, den 06.06.2014, 23:43 +0800 schrieb Andreea Costea: > Hi, > > > I'm trying to build a rather big system written in Ocaml, using > ocamlbuild. I managed to set all the needed flags nicely, so that the > resulted binaries can run on any Unix machine, independent on their > Ocaml distribution. However, on certain machines I have problems with > the compatibility between the C libraries. Hence, I tried using > "-ccopt -static" for the -lflags and -cflags, respectively, in order > to produce the desired statically linked binaries while building the > project. Unfortunately, this attempt leads to the following error: > > > "/usr/bin/ld: dynamic STT_GNU_IFUNC symbol `cos' with pointer equality > in > `/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libm.a(s_sin.o)' can not be used when making an executable; recompile with -fPIE and relink with -pie" > > > Does this mean I need to recompile the gcc libraries using -pie? Or > does it mean I am using the wrong method to build the standalone > executable? Any recommendation to modify the building process (i would > prefer to use ocambuild)? > > > Your answer is much appreciated, > Andreea > > > > > > > > > > -- ------------------------------------------------------------ Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de My OCaml site: http://www.camlcity.org Contact details: http://www.camlcity.org/contact.html Company homepage: http://www.gerd-stolpmann.de ------------------------------------------------------------ --=-jxGLJviMkMYsvEzk9dHl Content-Type: application/x-shellscript; name="gcc_wrapper.sh" Content-Disposition: attachment; filename="gcc_wrapper.sh" Content-Transfer-Encoding: 7bit #! /bin/sh # A wrapper script around gcc # Set STATIC_LIBS to the libraries that need to be linked statically. # e.g. STATIC_LIBS="pcre z" # # ALso honours EARLY_ARGS real_gcc=/usr/bin/gcc args="" opt_found=0 for arg in "$@"; do case "$arg" in -l*) trans="$arg" for lib in $STATIC_LIBS; do if [ "X-l$lib" = "X$arg" ]; then trans="-Wl,-Bstatic $arg -Wl,-Bdynamic" break fi done args="$args $trans" ;; *.opt) if [ "X$prev_arg" = "X-o" ]; then opt_found=1 fi args="$args $arg" ;; *) args="$args $arg" ;; esac prev_arg="$arg" done if [ $opt_found -gt 0 ]; then echo "+ $real_gcc $args" exec $real_gcc "-Wl,--start-group" $EARLY_ARGS $args "-Wl,--end-group" else $real_gcc "$@" fi --=-jxGLJviMkMYsvEzk9dHl--