From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,b2796c9ed44bd3f5 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!l34g2000vba.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Static linking Date: Fri, 7 Aug 2009 03:15:38 -0700 (PDT) Organization: http://groups.google.com Message-ID: <3cb4bb38-5be5-46d2-97e9-f7a3a9a59329@l34g2000vba.googlegroups.com> References: NNTP-Posting-Host: 153.98.68.197 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1249640138 27399 127.0.0.1 (7 Aug 2009 10:15:38 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 7 Aug 2009 10:15:38 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: l34g2000vba.googlegroups.com; posting-host=153.98.68.197; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.13) Gecko/2009073022 Firefox/3.0.13,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:7648 Date: 2009-08-07T03:15:38-07:00 List-Id: Markus Schoepflin wrote on comp.lang.ada: > up to now (gcc-4.3.x) we have been happily using 'gnatmake ... -largs > -static' to create statically linked executable. This has stopped working > with 4.4: > > =A0> touch foo.adb && gnatmake foo -largs -static > gcc-4.4 -c foo.adb > gnatbind -x foo.ali > gnatlink foo.ali -static > /usr/bin/ld: cannot find -lgnat-4.4 > collect2: ld returned 1 exit status > gnatlink: error when calling /usr/bin/gcc-4.4 > gnatmake: *** link failed. > > Now I have been told that -static is a binder, not a linker argument, and > indeed this works: > > =A0> touch foo.adb && gnatmake foo -bargs -static > gcc-4.4 -c foo.adb > gnatbind -static -x foo.ali > gnatlink foo.ali > > But this is not a static executable: > > =A0> ldd foo > =A0 =A0 =A0 =A0 linux-gate.so.1 =3D> =A0(0xb7f9e000) > =A0 =A0 =A0 =A0 libc.so.6 =3D> /lib/i686/cmov/libc.so.6 (0xb7e2d000) > =A0 =A0 =A0 =A0 /lib/ld-linux.so.2 (0xb7f9f000) > > Looking at the manual for the binder I'm told: '-static Link against a > static GNAT run time.'. OK, so this works as advertised, no dynamic GNAT > runtime used. > > Now what is the correct way to created a static executable? This seems to > work, but is it correct? libc6 does not exist as a static library anymore; on GNU/Linux there is no way to create a completely static executable; you have to link against (at least) libc.so.6 dynamically. So, the executable you obtain with -bargs -static is as static as you can get :) > =A0> touch foo.adb && gnatmake foo -bargs -static -largs -static > gcc-4.4 -c foo.adb > gnatbind -static -x foo.ali > gnatlink foo.ali -static > =A0> ldd foo > =A0 =A0 =A0 =A0 not a dynamic executable > > And why did only passing '-largs -static' work for gcc-3.3.x? I don't know and it seems strange to me that it worked at all if the binder was not called with -static. Maybe others on comp.lang.ada have more to tell us? -- Ludovic Brenta.