caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Romain Beauxis <toots@rastageeks.org>
To: caml-list@yquem.inria.fr
Subject: Re: Options order for ocamlc/opt/opt.opt
Date: Fri, 23 Nov 2007 17:40:27 +0100	[thread overview]
Message-ID: <200711231740.27208.toots@rastageeks.org> (raw)
In-Reply-To: <200711230243.34108.toots@rastageeks.org>

[-- Attachment #1: Type: text/plain, Size: 1087 bytes --]

Le Friday 23 November 2007 02:43:34, vous avez écrit :
> 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 static
> archives."
(...)
> There's a good documentation where the above statement is taken there:
>   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, 
I ended up with a patch that orders them just perfectly, 
so that the following is passed:

  gcc <other options> <-I options> -Wl,--as-needed <base_file.o> <project_files.o> <static_libraries.a> <dynamic list of -lfoo> -o object

This is exactly what's refered as a good practice in the above link, but still I got my linking wrong...

Ha, and of course this option works on a simple hello_world with the same gcc...


Another nice possibility would be to be able to filter out -l values, since they are automagically 
added, we don't have control over them...


Romain



[-- Attachment #2: link_args_order.patch --]
[-- Type: text/x-diff, Size: 1673 bytes --]

--- 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;


  reply	other threads:[~2007-11-23 16:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-23  1:43 Romain Beauxis
2007-11-23 16:40 ` Romain Beauxis [this message]
2007-11-24  3:10   ` [Caml-list] " Julien Moutinho
2007-11-24  3:15     ` Julien Moutinho
2007-12-02 21:39       ` Romain Beauxis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200711231740.27208.toots@rastageeks.org \
    --to=toots@rastageeks.org \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).