From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=AWL,SPF_SOFTFAIL autolearn=disabled version=3.1.3 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 0CE58BC69 for ; Fri, 23 Nov 2007 17:40:32 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao8CAKaRRkdYvxGE/2dsb2JhbAA X-IronPort-AV: E=Sophos;i="4.21,458,1188770400"; d="scan'208";a="4836910" Received: from www.rastageeks.org (HELO mail.rastageeks.org) ([88.191.17.132]) by mail1-smtp-roc.national.inria.fr with ESMTP; 23 Nov 2007 17:40:31 +0100 Received: from [192.168.112.144] (sphinx.lix.polytechnique.fr [129.104.11.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.rastageeks.org (Postfix) with ESMTP id 647C39B810 for ; Fri, 23 Nov 2007 17:40:31 +0100 (CET) From: Romain Beauxis To: caml-list@yquem.inria.fr Subject: Re: Options order for ocamlc/opt/opt.opt Date: Fri, 23 Nov 2007 17:40:27 +0100 User-Agent: KMail/1.9.7 References: <200711230243.34108.toots@rastageeks.org> In-Reply-To: <200711230243.34108.toots@rastageeks.org> MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_7JwRH5Z8UaEEnV4" Message-Id: <200711231740.27208.toots@rastageeks.org> X-Spam: no; 0.00; ocamlc:01 gentoo:01 gcc:01 -wl:01 gcc:01 archives:02 linking:02 linking:02 static:03 static:03 dynamic:03 confused:04 opt:04 opt:04 fix:05 X-Attachments: type="text/x-diff" name="link_args_order.patch" name="link_args_order.patch" --Boundary-00=_7JwRH5Z8UaEEnV4 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Le Friday 23 November 2007 02:43:34, vous avez =E9crit=A0: > The fix in this case is to simply fix the linking order so that the > libraries given to the linker are all after the object files and the stat= ic > archives." (...) > There's a good documentation where the above statement is taken there: > =A0 http://www.gentoo.org/proj/en/qa/asneeded.xml > > What do you think ? Well, I'm quite confused with this... After spending some time finding out how to change those arguments order,=20 I ended up with a patch that orders them just perfectly,=20 so that the following is passed: gcc <-I options> -Wl,--as-needed -o object This is exactly what's refered as a good practice in the above link, but st= ill I got my linking wrong... Ha, and of course this option works on a simple hello_world with the same g= cc... Another nice possibility would be to be able to filter out -l values, since= they are automagically=20 added, we don't have control over them... Romain --Boundary-00=_7JwRH5Z8UaEEnV4 Content-Type: text/x-diff; charset="iso-8859-1"; name="link_args_order.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="link_args_order.patch" --- ocaml-3.10.0.orig/asmcomp/asmlink.ml +++ ocaml-3.10.0/asmcomp/asmlink.ml @@ -239,20 +239,20 @@ | "cc" -> let cmd = if not !Clflags.output_c_object then - Printf.sprintf "%s %s -o %s %s %s %s %s %s %s %s %s" + Printf.sprintf "%s %s %s %s %s %s %s %s %s %s -o %s" !Clflags.c_linker (if !Clflags.gprofile then Config.cc_profile else "") - (Filename.quote output_name) (Clflags.std_include_flag "-I") - (String.concat " " (List.rev !Clflags.ccopts)) - (Filename.quote startup_file) - (Ccomp.quote_files (List.rev file_list)) (Ccomp.quote_files (List.map (fun dir -> if dir = "" then "" else "-L" ^ dir) !load_path)) - (Ccomp.quote_files (List.rev !Clflags.ccobjs)) + (String.concat " " !Clflags.ccopts) + (Filename.quote startup_file) + (Ccomp.quote_files (List.rev file_list)) (Filename.quote runtime_lib) + (Ccomp.quote_files (List.rev !Clflags.ccobjs)) c_lib + (Filename.quote output_name) else Printf.sprintf "%s -o %s %s %s" Config.native_partial_linker @@ -320,7 +320,7 @@ List.iter (fun (info, file_name, crc) -> check_consistency file_name info crc) units_tolink; - Clflags.ccobjs := !Clflags.ccobjs @ !lib_ccobjs; + Clflags.ccobjs := !lib_ccobjs @ !Clflags.ccobjs; Clflags.ccopts := !lib_ccopts @ !Clflags.ccopts; (* put user's opts first *) let startup = Filename.temp_file "camlstartup" ext_asm in make_startup_file ppf startup units_tolink; --Boundary-00=_7JwRH5Z8UaEEnV4--