Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001956OCamlruntime system and C interfacepublic2003-12-03 15:292017-03-06 17:05
Assigned Todoligez 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0001956: Name clashes
DescriptionHello Lars and caml-bugs,

There is a name clash between the libcrypto and libcamlrun on the symbol
create_string. This prevents from linking statically an OCaml program that
uses the ocurl library (bindings to the libcurl, which uses libcrypto), and
I guess that horrible things may happen at runtime with dynamic linking.

Similar issues have been raised recently on the caml-list (concerning
the libsamba, libperl, and graphviz libraries).

Any plan to address these issues?

OCaml is no more faulty than these libraries, but this is not a reason not
to fix the problem :-)

A natural solution would be to prefix all the common names like
create_string or get_string. To keep the compatibility with existing C
code that uses Caml C headers, there could be two versions of these
headers (the compatibility header would #DEFINE create_string as
ocaml_create_string and so on).


TagsNo tags attached.
Attached Filespatch file icon no-export-marshall-flags.patch [^] (405 bytes) 2013-09-16 20:00 [Show Content]

- Relationships
related to 0001914closed conflits lors d'interfacage avec du code C 
related to 0004230closeddoligez value name conflict 
related to 0004164closeddoligez caml C headers may clash with other C libraries 
related to 0005254resolvedshinwell Compilation of generated .c files with g++ 
related to 0004877closed Definition of uint64 in caml/config.h conflicts. (MacOSX Snow Leopard, X86_64) 
related to 0006126closedgasche Bigarray doc mention deprecated function Data_bigarray_val(v) 

-  Notes
administrator (administrator)
2004-01-07 22:04

see also PR#1914
fixed for byterun and asmrun 2004-01-07 -DD
still needs to be done for otherlibs (?)
doligez (administrator)
2006-01-27 15:34

done for otherlibs/bigarray (branch 3.10) 2006-01-27
stedolan (developer)
2013-07-30 20:20

Here's a list of the current offenders: [^]
lpw25 (developer)
2013-09-16 20:01

I attached a patch from Stephen Dolan that stops marshall_flags from being exported.
doligez (administrator)
2016-03-03 15:13

Patch for marshall_flags applied to 4.03 (commit 5dbea030d1f05606b5bf008c5118c04f72035d28) and trunk (commit 044901bf13bb223684535e375008f7cf105ae843).

The rest will wait till 4.04.
xleroy (administrator)
2016-12-07 18:43

Now that the runtime is clean name-wise, and that several offending "otherlibs" are on their way out (num, str) or are disused (vmthreads), maybe we could declare victory?
stedolan (developer)
2016-12-07 20:21

Re-running the command at the top of [^] indicates that there are now a few more offenders, such as invert_root in compact.c and process_debug_events in byterun/backtrace_prim.c.
shinwell (developer)
2016-12-08 11:52

@stedolan Could you produce a patch for those?
shinwell (developer)
2016-12-08 12:00

Consolidating this with another issue so we have a single place to keep track of namespacing problems: the runtime isn't clean yet because of macros and so forth, I suspect:


All function in caml C headers are prefixed with caml_.
This is not the case for typedef nor macros in mlvalues.h.
See mlvalues.h for example:
typedef intnat value;
typedef uintnat header_t;
typedef uintnat mlsize_t;
typedef unsigned int tag_t; /* Actually, an unsigned char */
typedef uintnat color_t;
typedef uintnat mark_t;
#define Is_long(x) (((x) & 1) != 0)
#define Is_block(x) (((x) & 1) == 0)
#define Val_long(x) (((intnat)(x) << 1) + 1)
#define Long_val(x) ((x) >> 1)
stedolan (developer)
2016-12-14 18:07

Macros, typedefs and static functions are not an issue.

The `caml_` prefix is only necessary for functions and globals which have external linkage. Things like `value` can only conflict with code that explicitly does `#include <mlvalues.h>` and is presumably aware of the OCaml API. Externally-linked symbols like marshall_flags will break other code that defines the same symbol regardless of header files.

I've created a pull request (#GPR973) that removes the current offenders, and adds a tool to detect them.

- Issue History
Date Modified Username Field Change
2005-11-18 10:14 administrator New Issue
2005-12-15 15:45 doligez Status acknowledged => assigned
2005-12-15 15:45 doligez Assigned To => doligez
2006-01-27 15:34 doligez Note Added: 0003525
2006-07-25 11:08 doligez Relationship added related to 0001914
2006-11-17 15:26 doligez Relationship added related to 0004164
2007-04-03 18:02 doligez Relationship added related to 0004230
2007-11-19 19:09 doligez Status assigned => acknowledged
2011-08-02 09:58 xclerc Relationship added related to 0005254
2012-07-11 17:38 doligez Target Version => 4.01.0+dev
2012-07-11 17:38 doligez Description Updated View Revisions
2012-07-31 13:37 doligez Target Version 4.01.0+dev => 4.00.1+dev
2012-09-11 09:19 doligez Target Version 4.00.1+dev => 4.01.0+dev
2012-09-17 17:34 doligez Relationship added related to 0004877
2013-07-18 17:10 doligez Target Version 4.01.0+dev => 4.02.0+dev
2013-07-24 18:38 doligez Target Version 4.02.0+dev => 4.01.1+dev
2013-07-30 20:20 stedolan Note Added: 0010015
2013-08-07 13:53 gasche Relationship added related to 0006126
2013-09-16 20:00 lpw25 File Added: no-export-marshall-flags.patch
2013-09-16 20:01 lpw25 Note Added: 0010361
2014-05-21 17:42 doligez Target Version 4.01.1+dev => 4.03.0+dev / +beta1
2016-03-03 15:13 doligez Note Added: 0015427
2016-03-03 15:13 doligez Target Version 4.03.0+dev / +beta1 => 4.03.1+dev
2016-12-07 18:22 shinwell Category OCaml general => OCaml runtime system
2016-12-07 18:43 xleroy Note Added: 0016795
2016-12-07 18:43 xleroy Target Version 4.03.1+dev => 4.05.0 +dev/beta1/beta2/beta3/rc1
2016-12-07 20:21 stedolan Note Added: 0016807
2016-12-08 11:52 shinwell Note Added: 0016845
2016-12-08 11:59 shinwell Priority normal => high
2016-12-08 12:00 shinwell Note Added: 0016852
2016-12-14 18:07 stedolan Note Added: 0017003
2017-02-23 16:43 doligez Category OCaml runtime system => runtime system
2017-03-03 17:45 doligez Category runtime system => runtime system and C interface
2017-03-06 17:05 doligez Target Version 4.05.0 +dev/beta1/beta2/beta3/rc1 =>

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker