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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 456407F917 for ; Sat, 7 Jun 2014 11:55:51 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of andre.costea@gmail.com) identity=pra; client-ip=209.85.213.171; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="andre.costea@gmail.com"; x-sender="andre.costea@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of andre.costea@gmail.com designates 209.85.213.171 as permitted sender) identity=mailfrom; client-ip=209.85.213.171; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="andre.costea@gmail.com"; x-sender="andre.costea@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-ig0-f171.google.com) identity=helo; client-ip=209.85.213.171; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="andre.costea@gmail.com"; x-sender="postmaster@mail-ig0-f171.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsIDAMrgklPRVdWrlGdsb2JhbABZgkaBGVYDgmyoDQaZEAF7CBYPAQEBAQcLCwkSKoQDAQEBAwESER0BFAcdAQMBCwYDAgsDNAICIgERAQUBHAYTCRIHiAsBAwkIDZFjkBNqiyeBcoMPkzoKGScNZIUkEQEFDIVRiGYmB4J1gUwEii+LZIITgXeRUxgphHkwLw X-IPAS-Result: AsIDAMrgklPRVdWrlGdsb2JhbABZgkaBGVYDgmyoDQaZEAF7CBYPAQEBAQcLCwkSKoQDAQEBAwESER0BFAcdAQMBCwYDAgsDNAICIgERAQUBHAYTCRIHiAsBAwkIDZFjkBNqiyeBcoMPkzoKGScNZIUkEQEFDIVRiGYmB4J1gUwEii+LZIITgXeRUxgphHkwLw X-IronPort-AV: E=Sophos;i="4.98,994,1392159600"; d="scan'208";a="78589774" Received: from mail-ig0-f171.google.com ([209.85.213.171]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 07 Jun 2014 11:55:50 +0200 Received: by mail-ig0-f171.google.com with SMTP id c1so1741701igq.16 for ; Sat, 07 Jun 2014 02:55:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=IOmsh1JChSph26R7xTCKjt63XIBtNKwr3JyBZdmfB4Y=; b=C3tNXrOjy1rq5aTpYFBWAkACFGApgTyM3nxi4orjpZr4AqyFbnw0uy7hz6SxzduJMt t9vqE8vDVia+0rSimCFttqIPL677F/AXtPfc3Q7Gj51V1UuD4Tkpe4tQtrPPMFMZHNpg eMaw7oedesMDEjj2MQqwFmF1FpByc9evKKdQnP8ypr79V4PwnmMIsXjsj3fyZQLzhFkr TKBQZRCv5EVTKnr2QkbN/9Mv+30O+ZCH0dWVbxsMozoDZkGT/4Om5zwGXm+/NDzzsACx Sqoeiab0SWJDdq5Dsl/YrcGLz3KXtKsztMWe/QQwA3QtAV8KC0VWyHCFGTtFi9koJzeB 1UJQ== MIME-Version: 1.0 X-Received: by 10.50.176.167 with SMTP id cj7mr14484232igc.44.1402134948936; Sat, 07 Jun 2014 02:55:48 -0700 (PDT) Received: by 10.50.117.101 with HTTP; Sat, 7 Jun 2014 02:55:48 -0700 (PDT) In-Reply-To: <1402086284.3141.12.camel@e130> References: <1402086284.3141.12.camel@e130> Date: Sat, 7 Jun 2014 17:55:48 +0800 Message-ID: From: Andreea Costea To: Gerd Stolpmann Cc: "caml-list@inria.fr" Content-Type: multipart/alternative; boundary=089e0111be128f075204fb3bfbdd X-Validation-by: andre.costea@gmail.com Subject: Re: [Caml-list] static linking --089e0111be128f075204fb3bfbdd Content-Type: text/plain; charset=UTF-8 Mark and Gerd, thank you both for your replies and suggestions. Indeed glibc (/lib64/libc.so.6) was the one causing troubles. For short time, I shall try the script Gerd provided, and perhaps for long term we should consider building our system without the core libs statically linked. Thanks again, Andreea On Sat, Jun 7, 2014 at 4:24 AM, Gerd Stolpmann wrote: > 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 > ------------------------------------------------------------ > > --089e0111be128f075204fb3bfbdd Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Mark and Gerd, thank you both for your replies and suggest= ions. Indeed glibc (/lib64/libc.so.6) was the one causing troubles.
For short t= ime, I shall try the script Gerd provided, and perhaps for long term we sho= uld consider building our system without the core libs statically linked.

Thanks again,
Andreea



On Sat= , Jun 7, 2014 at 4:24 AM, Gerd Stolpmann <info@gerd-stolpmann.de&= gt; wrote:
I'd strongly recommend against linking s= tatically 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=3D"pcre = z" would
select libpcre and libz).

The script here is only activated when there is an

=C2=A0 -o <name>.opt

argument. You may want to modify this part. (I'm just taking the versio= n
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<= br> > resulted binaries can run on any Unix machine, independent on their
> Ocaml distribution. However, on certain machines I have problems with<= br> > the compatibility between the C libraries. Hence, I tried using
> "-ccopt -static" =C2=A0for the -lflags and -cflags, respecti= vely, 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 =C2=A0 =C2=A0gerd@gerd-stolpmann.de
My OCaml site: =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0http://www.camlcity.org
Contact details: =C2=A0 =C2=A0 =C2=A0 =C2=A0http://www.camlcity.org/contact.html
Company homepage: =C2=A0 =C2=A0 =C2=A0
http://www.gerd-stolpmann.de
------------------------------------------------------------


--089e0111be128f075204fb3bfbdd--