| Anonymous | Login | Signup for a new account | 2013-05-25 10:16 CEST | ![]() |
| Main | My View | View Issues | Change Log | Roadmap |
| View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | |||
| 0000129 | OCaml | OCaml general | public | 2000-05-23 12:42 | 2000-06-05 14:38 | |||
| Reporter | administrator | |||||||
| Assigned To | ||||||||
| Priority | normal | Severity | minor | Reproducibility | always | |||
| Status | closed | Resolution | fixed | |||||
| Platform | OS | OS Version | ||||||
| Product Version | ||||||||
| Target Version | Fixed in Version | |||||||
| Summary | 0000129: Use of external functions alone does not cause module to be linked | |||||||
| Description | Hello, I've run into what seems to be a small bug. I'm using the ocaml-3.00 under Redhat 6.2; I've tried this using both OCaml installed from ocaml-3.00-2.rh61.i386.rpm and from an OCaml I I built from source. It appears that if you use a "external" function from a library, without using any other normal values (like regular functions) from that library, the O'Caml linker does not include that library's auto-link C libraries in the final link, preventing the executable from being built. I don't think this behavior is documented anywhere. There are three simple workarounds: add -cclib -llibrary to the link command, or add -linkall, or use some normal value from that library. I've included some examples below, in the form of a shell script that creates some source files and tries to compile them. The examples are admittedly contrived, but do illustrate the problem. #### Start of shell script with examples set -x ## Example using Str cat >bug.ml <<'EOF' let x = Str.search_forward let _ = print_endline "this program shows the bug!" EOF echo This fails ocamlc -verbose -o bug -custom str.cma bug.ml echo This succeeds, since we add -linkall ocamlc -verbose -linkall -o bug -custom str.cma bug.ml ## Example using Dbm cat >bug2.ml <<'EOF' let d = Dbm.close let _ = print_endline "this program also shows the bug!" EOF echo This fails ocamlc -verbose -o bug2 -custom dbm.cma bug2.ml echo This succeeds, since we add -linkall ocamlc -verbose -linkall -o bug2 -custom dbm.cma bug2.ml ## This example works; Str.regexp is not an "external" function. cat >nobug.ml <<'EOF' let x = Str.regexp let _ = print_endline "this program does *not* show the bug!" EOF echo This succeeds ocamlc -verbose -o nobug -custom str.cma nobug.ml #### End of shell script with examples -- T. Kurt Bond, tkb@tkb.mpl.com | |||||||
| Tags | No tags attached. | |||||||
| Attached Files | ||||||||
Notes |
|
|
(0000402) administrator (administrator) 2000-06-05 09:40 |
Xavier Leroy writes: > > I've run into what seems to be a small bug. > > It appears that if you use a "external" function from a library, > > without using any other normal values (like regular functions) from > > that library, the O'Caml linker does not include that library's > > auto-link C libraries in the final link, preventing the executable > > from being built. > > Right, this is a bug. It is fixed in the working sources. If you > wish to test the fix, a patch is appended below. This worked perfectly for me. > Thanks for the bug report, You are welcome! > - Xavier Leroy Thanks! -- T. Kurt Bond, tkb@tkb.mpl.com |
|
(0000403) administrator (administrator) 2000-06-05 14:28 |
> I've run into what seems to be a small bug. > It appears that if you use a "external" function from a library, > without using any other normal values (like regular functions) from > that library, the O'Caml linker does not include that library's > auto-link C libraries in the final link, preventing the executable > from being built. Right, this is a bug. It is fixed in the working sources. If you wish to test the fix, a patch is appended below. Thanks for the bug report, - Xavier Leroy Index: csl/bytecomp/bytelink.ml diff -u csl/bytecomp/bytelink.ml:1.55 csl/bytecomp/bytelink.ml:1.56 --- csl/bytecomp/bytelink.ml:1.55 Thu Apr 20 16:39:01 2000 +++ csl/bytecomp/bytelink.ml Mon Jun 5 14:19:50 2000 @@ -10,7 +10,7 @@ (* *) (***********************************************************************) -(* $Id: bytelink.ml,v 1.55 2000/04/20 14:39:01 doligez Exp $ *) +(* $Id: bytelink.ml,v 1.56 2000/06/05 12:19:50 xleroy Exp $ *) (* Link a set of .cmo files and produce a bytecode executable. *) @@ -129,6 +129,7 @@ seek_in ic pos_toc; let toc = (input_value ic : library) in close_in ic; + add_ccobjs toc; let required = List.fold_right (fun compunit reqd -> @@ -142,7 +143,6 @@ end else reqd) toc.lib_units [] in - if required <> [] then add_ccobjs toc; Link_archive(file_name, required) :: tolink end else raise(Error(Not_an_object_file file_name)) |
|
(0000404) administrator (administrator) 2000-06-05 14:38 |
Fixed on 2000-06-05 by Xavier |
Issue History |
|||
| Date Modified | Username | Field | Change |
| 2005-11-18 10:13 | administrator | New Issue | |
| Copyright © 2000 - 2011 MantisBT Group |