Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005260OCaml~DO NOT USE (was: OCaml general)public2011-05-01 22:402013-08-31 12:43
Assigned To 
StatusclosedResolutionno change required 
PlatformOSOS Version
Product Version3.12.0 
Target VersionFixed in Version 
Summary0005260: ocaml compiler presents static link libraries to GCC backwards
DescriptionYeah, the title says it all.

OS: Linux/openSUSE 11.4
Kernel Version:
Arch: x86_64

The openSUSE build service compiles static libraries with the --as-needed linker flag, which causes the statically linking against the pcre library fail with GCC linker errors. This likely extends to other libraries as well.

This can be set to ocamlc or ocamlopt by adding '-ccopt -Wl,--as-needed'

For example, compiling the attached file with

ocamlc.opt -verbose -g -o test.byt -thread -I /usr/lib64/ocaml/pcre/ /usr/lib64/ocaml/pcre/pcre.cma

Works fine. The relevant linker arguments are '-lpcre' and '-lpcre_stubs', in that order However, when called as:

ocamlc.opt -ccopt -Wl,--as-needed -verbose -g -o test.byt -thread -I /usr/lib64/ocaml/pcre/ /usr/lib64/ocaml/pcre/pcre.cma

It fails. However, It works when I explicitly add a 'cclib -lpcre' to the mix, like so:

ocamlc.opt -ccopt -Wl,--as-needed -cclib -lpcre -verbose -g -o test.byt -thread -I /usr/lib64/ocaml/pcre/ /usr/lib64/ocaml/pcre/pcre.cma

It works perfectly fine, dumping the pcre linker flags as -lpcre -lpcre_stubs -lpcre, with the last '-lpcre' appearing to be appended as a result of the '-cclib -lpcre' argument.

The linker args at the bottom of the pcre.cma file appear to be specified in the correct order of '-lpcre_stubs -lpcre' as was seen by opening it in a text editor. Attempting to reverse the order of the flags in the file resulted in the compiler segfaulting.

It was suggested that the problem is somehow related to a list reversal, but I do not know for sure.
Additional InformationThis problem was first noted in this thread: //"> [//" target="_blank">^]

It was unclear whether this was a problem with pcre or ocaml itself, but Gerd seems to suggest that it was related to ocaml itself.

This bug is likely the same as described in [^]
TagsNo tags attached.
Attached Files? file icon [^] (99 bytes) 2011-05-01 22:40 [Show Content]

- Relationships
related to 0005234closed ocamlopt -shared does not preserve order of -cclib options 

-  Notes
doligez (administrator)
2011-05-17 16:08

When I compile pcre 6.2.2, the command line that compiles pcre.cmxa is the following:

  ocamlopt -a -cclib "-L/opt/local/lib -lpcre" -cclib -lpcre_stubs -o pcre.cmxa pcre.cmx

Note that "-lpcre" and "-lpcre_stubs" appear in this order (which is the wrong order, given the strange semantics of the Unix linker). OCaml preserves this order, as it should.

I strongly claim that the problem is in pcre itself: it should list -lpcre_stubs before -lpcre.

- Issue History
Date Modified Username Field Change
2011-05-01 22:40 nacl New Issue
2011-05-01 22:40 nacl File Added:
2011-05-02 12:47 doligez Relationship added related to 0005234
2011-05-16 16:36 doligez Status new => acknowledged
2011-05-17 16:08 doligez Note Added: 0005900
2011-05-17 16:08 doligez Status acknowledged => resolved
2011-05-17 16:08 doligez Resolution open => no change required
2013-08-31 12:43 xleroy Status resolved => closed
2017-02-23 16:36 doligez Category OCaml general => -OCaml general
2017-03-03 17:55 doligez Category -OCaml general => -(deprecated) general
2017-03-03 18:01 doligez Category -(deprecated) general => ~deprecated (was: OCaml general)
2017-03-06 17:04 doligez Category ~deprecated (was: OCaml general) => ~DO NOT USE (was: OCaml general)

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker