Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007172OCamlconfigure and build/installpublic2016-03-11 12:192017-02-27 16:54
Reporterdbuenzli 
Assigned Todra 
PrioritynormalSeverityfeatureReproducibilityhave not tried
StatusassignedResolutionopen 
PlatformOSOS Version
Product Version4.02.3 
Target Version4.06.0+devFixed in Version 
Summary0007172: More information in ocamlc -config
DescriptionIt would be nice if ocamlc -config could report whether:

1) Native compilation is available
2) Native dynlinking is available.

TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0015461)
shinwell (developer)
2016-03-11 14:35

I think we may need to fix matters for 4.03 such that there is a means of discovering whether Flambda is enabled or not. Perhaps we could just fix these all at once.
(0015462)
dbuenzli (reporter)
2016-03-11 14:49

@shinwell I'd be delighted if this could go into 4.03 and I may be tempted to hide the fact that ocamlc -config already reports if flambda is enabled or not.
(0015463)
shinwell (developer)
2016-03-11 14:54

Oh, so it does. Well it will probably have to wait then :p
(0015465)
dbuenzli (reporter)
2016-03-11 14:58

Grrrrr.
(0015524)
dbuenzli (reporter)
2016-03-17 00:17

Somehow I had hoped that I could fill the missing slots with:

$(ocamlc -where)/Makefile.config

but in fact this file seems to reflect the output of the configure process, not of what is actually installed, e.g. on a bytecode only switch like:

https://github.com/ocaml/opam-repository/blob/master/compilers/4.02.3/4.02.3%2Bbytecode-only/4.02.3%2Bbytecode-only.comp [^]

NATDYNLINK will be true even though there no actual dynlink.cmxa. In fact reading the INSTALL file it seems there's no way to configure ocaml to be bytecode only.

So I guess I'm left with discovery hacks.

I'm thinking about:

* native code compilation is available if $(ocamlc -where)/libasmrun.$(EXT_DLL) exists
(looking up ocamlopt in the path can be a bit unreliable, for example in a bytecode only switch ocamlopt may actually be in the path, but it's the ocamlopt of the system compiler...)

* native dynlinking is available if $(ocamlc -where)/dynlink.cmxa exists

Does it sound reasonable ?
(0015525)
dbuenzli (reporter)
2016-03-17 00:23

That is libasmrun.$(EXT_LIB) rather than $(EXT_DLL).
(0015527)
gasche (developer)
2016-03-17 00:58

I needed a -no-native-compiler configure option to test the bytecode-only build of ocamlbuild, and added it to the script in GPR#387. The relevant variables *should* be set to a meaningful value in this case, and the fact that this is not done for NATDYNLINK comes from an (independent) omission in the relevant logic:

  https://github.com/ocaml/ocaml/blob/d3d30f3/configure#L874-L878 [^]

I need to document the -no-native-compiler switch in the INSTALL file, and I think I will fix the configure script as well.
(0015536)
dbuenzli (reporter)
2016-03-17 21:48

Also it would be nice to give us ext_exe, since the logic is a little bit twisted and requires to consult both ccomp_type and os_type. There is the EXE variable in Makefile.config but I now decided I'd rely only on the output of ocamlc -config.
(0015602)
doligez (administrator)
2016-03-24 17:12

@dbuenzli your "discovery hacks" look quite reasonable to me.

It's not clear to me how `ocamlc -config` could know whether the native compiler was built or anything about the build process. Currently, it relies only on information from `configure`.

I agree with ext_exe.
(0015605)
dbuenzli (reporter)
2016-03-24 17:24

@doligez The solution is to be able to specify whether native compilers should be built in the configure of course.
(0015606)
gasche (developer)
2016-03-24 17:30

I proposed
  https://github.com/ocaml/ocaml/pull/513 [^]
to solve this issue.
(0015671)
gasche (developer)
2016-04-04 14:46

GPR#513 has just been merged in 4.03 and trunk. `./configure -no-native-compiler` now sets NATDYNLINK=false in Makefile.config.
(0016024)
dbuenzli (reporter)
2016-06-30 14:47
edited on: 2016-06-30 14:48

Another bit that is useful for build systems to know an that should be reported by ocamlc -config is the value of `Sys.word_size` on the target platform. This is useful even for OCaml programs as it affects the size of ocaml integers.

Currently workarounds include:

1) Grepping for SIZEOF_PTR in $(ocamlc -where)/caml/config.h
2) Trying to pattern match on the values of architecture: and model: of ocamlc -config and try to infer the size based on the meaning of these keys according to https://github.com/ocaml/ocaml/blob/4ca0ca4690ec2ceaeb6167033d2b3727398d5c14/configure#L810-L862 [^]

(0016992)
dbuenzli (reporter)
2016-12-13 11:38

shinwell asked me to update on the status of this bug. So in 4.04, ocamlc -config still does not report the following useful tidbits:

* ext_exe
* word_size
* natdynlink
* nativecomp
(0016998)
gasche (developer)
2016-12-13 23:23

https://github.com/ocaml/ocaml/pull/970 [^]
(0016999)
dra (developer)
2016-12-14 14:06
edited on: 2016-12-14 14:07

GPR#970 adds ext_exe, word_size and possibly natdynlink.

A suggestion for nativecomp (and really natdynlink) would to be change the logic for make install. At present, if native code has been built then it is installed, but we could instead make it that if native code has been *configured* then make install fails if it has not also been built (same could sensibly be done at the same time for opt.opt).

At present, Windows should be configured so that opt and opt.opt are assumed.

(0017001)
gasche (developer)
2016-12-14 15:50

So after discussion with dra, GPR#970 only includes int_size, word_size and ext_exe. I won't work on natdynlink and nativecomp myself in the 4.05 timeline, so I just un-assigned myself.
(0017002)
dra (developer)
2016-12-14 15:52

So int_size, word_size and ext_exe are merged and will be in 4.05.0

I've assigned the issue and hope to have a GPR for natdynlink and nativecomp ready for the 4.05 freeze.

- Issue History
Date Modified Username Field Change
2016-03-11 12:19 dbuenzli New Issue
2016-03-11 14:35 shinwell Note Added: 0015461
2016-03-11 14:49 dbuenzli Note Added: 0015462
2016-03-11 14:54 shinwell Note Added: 0015463
2016-03-11 14:58 dbuenzli Note Added: 0015465
2016-03-17 00:17 dbuenzli Note Added: 0015524
2016-03-17 00:23 dbuenzli Note Added: 0015525
2016-03-17 00:58 gasche Note Added: 0015527
2016-03-17 21:48 dbuenzli Note Added: 0015536
2016-03-24 17:12 doligez Note Added: 0015602
2016-03-24 17:12 doligez Status new => acknowledged
2016-03-24 17:12 doligez Target Version => 4.03.1+dev
2016-03-24 17:24 dbuenzli Note Added: 0015605
2016-03-24 17:30 gasche Note Added: 0015606
2016-04-04 14:46 gasche Note Added: 0015671
2016-06-30 14:47 dbuenzli Note Added: 0016024
2016-06-30 14:47 dbuenzli Note Edited: 0016024 View Revisions
2016-06-30 14:48 dbuenzli Note Edited: 0016024 View Revisions
2016-12-06 15:44 frisch Severity minor => feature
2016-12-13 11:38 dbuenzli Note Added: 0016992
2016-12-13 23:23 gasche Note Added: 0016998
2016-12-14 12:38 shinwell Assigned To => gasche
2016-12-14 12:38 shinwell Status acknowledged => assigned
2016-12-14 14:06 dra Note Added: 0016999
2016-12-14 14:07 dra Note Edited: 0016999 View Revisions
2016-12-14 15:49 gasche Assigned To gasche =>
2016-12-14 15:49 dra Assigned To => dra
2016-12-14 15:50 gasche Note Added: 0017001
2016-12-14 15:52 dra Note Added: 0017002
2017-02-16 14:01 doligez Target Version 4.03.1+dev => undecided
2017-02-23 16:36 doligez Category OCaml general => -OCaml general
2017-02-27 16:54 doligez Category -OCaml general => configure and build/install
2017-02-27 16:54 doligez Target Version undecided => 4.06.0+dev


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker