Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005084OCamlOCamlbuild (the tool)public2010-06-22 18:542012-05-07 15:12
Reportermww 
Assigned Toprotz 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version3.12.0+beta1 or 3.12.0+rc1 
Target VersionFixed in Version4.00.0+dev 
Summary0005084: sub-sub-module building fails for native code compilation
Descriptionwhen building a sub-sub-module with the for-pack option, compilation fails ("was not compiled with the for-pack subXX option)

This works on 3.11.2 -- for 3.12.0+beta1 only when building bytecode..
Additional Informationthis is Mac OS X 10.6.4/amd64;

the attached tarball has a sub-sub module and demonstrates the error:

ocamlbuild main.native

compiles and works with 3.11.2 but fails on 3.12.0+beta with:


File "sub1.cmx", line 1, characters 0-1:
Error: File sub1/sub2.cmx
was not compiled with the `-for-pack Sub1' option
Command exited with code 1.
Compilation unsuccessful after building 9 targets (0 cached) in 00:00:00.
TagsNo tags attached.
Attached Filesgz file icon example.tar.gz [^] (482 bytes) 2010-06-22 18:54

- Relationships

-  Notes
(0005620)
mww (reporter)
2010-07-24 01:28

This is still the case with 3.12.0+rc1
(0005637)
mww (reporter)
2010-08-13 08:59

This is still the case with 3.12.0 (release)
(0005748)
xclerc (developer)
2010-12-21 13:28

My understanding of this report is that it is not an ocamlbuild-specific problem.
Indeed, contrary to the bytecode compiler, the native compiler does not allow
one to "compose" pack operations. Moreover, the native compiler requires (where
the bytecode one only accepts) the '-for-pack' option to specify the final module
into which the compiled unit will be packed.
(0005758)
mww (reporter)
2011-01-04 22:41

It didn't occur to me that this could be the native compilers fault -- why would this feature get removed in 3.12.0?
(0006089)
abdallah (reporter)
2011-08-13 01:57

This is still the case with 3.12.1 (release)
(0006126)
protz (manager)
2011-09-16 15:46
edited on: 2011-09-16 15:47

GOOD:

commit 71ba631c28d7398cb78a5fcfcb1c1b00b8472722
Author: frisch <frisch@f963ae5c-01c2-4b8c-9fe0-0dff7051ff02>
Date: Wed Jan 20 12:48:34 2010 +0000

    Fix ocamldep for 1st class modules.
    
    git-svn-id: file:///net/yquem/devel/caml/svn/ocaml/trunk@9538 [^] f963ae5c-01c2-4b8c-9fe0-0dff7051ff02

BAD:

commit ee5f671c834da0eee1b28412313628556f9ddc10
Author: xclerc <xclerc@f963ae5c-01c2-4b8c-9fe0-0dff7051ff02>
Date: Mon Jan 25 13:47:28 2010 +0000

    Infrastructure for test suite.
    
    
    git-svn-id: file:///net/yquem/devel/caml/svn/ocaml/trunk@9562 [^] f963ae5c-01c2-4b8c-9fe0-0dff7051ff02


These two revisions are approximately 7 commits apart. It's hard to bisect in that range because someone (I'm looking at you xclerc ;-)) forgot to add files for ocamlbuild parameterized tags, so I basically can't compile in that range.

I'm going to try right before and right after the parameterized tags stuff, just to confirm.

(0006127)
protz (manager)
2011-09-16 15:58

GOOD:

commit d71b23f614d913a84ab75f6d83feb499a787b4d9
Author: doligez <doligez@f963ae5c-01c2-4b8c-9fe0-0dff7051ff02>
Date: Fri Jan 22 12:48:24 2010 +0000

    clean up spaces and tabs
    
    git-svn-id: file:///net/yquem/devel/caml/svn/ocaml/trunk@9547 [^] f963ae5c-01c2-4b8c-9fe0-0dff7051ff02

BAD:
commit 15ff52580e4b985103fe4fa9731c6123c2796f0b
Author: xclerc <xclerc@f963ae5c-01c2-4b8c-9fe0-0dff7051ff02>
Date: Fri Jan 22 14:36:57 2010 +0000

    Support for parametrized tags (N. Pouillard et al.)
    
    
    git-svn-id: file:///net/yquem/devel/caml/svn/ocaml/trunk@9548 [^] f963ae5c-01c2-4b8c-9fe0-0dff7051ff02

with the files from

commit 87cd319c69653b747ea3ae40c527c145049517d0
Author: xclerc <xclerc@f963ae5c-01c2-4b8c-9fe0-0dff7051ff02>
Date: Mon Jan 25 08:16:23 2010 +0000

    Added some missing files for parameterized tags.
    
    
    git-svn-id: file:///net/yquem/devel/caml/svn/ocaml/trunk@9558 [^] f963ae5c-01c2-4b8c-9fe0-0dff7051ff02

So the problem is in one of the two commits above.
(0007421)
protz (manager)
2012-05-07 13:57

Mantis erased my comment by accident. How I hate you Mantis!

This is definitely a bug in OCamlbuild that was introduced when we committed parameterized flags. Here's the output of ocamlbuild on 3.11

/usr/local/bin/ocamldep.opt -modules main.ml > main.ml.depends
/usr/local/bin/ocamldep.opt -modules sub1/sub2/sub3.ml > sub1/sub2/sub3.ml.depends
/usr/local/bin/ocamlc.opt -c -I sub1/sub2 -o sub1/sub2/sub3.cmo sub1/sub2/sub3.ml
/usr/local/bin/ocamlc.opt -pack sub1/sub2/sub3.cmo -o sub1/sub2.cmo
/usr/local/bin/ocamlc.opt -pack sub1/sub2.cmo -o sub1.cmo
/usr/local/bin/ocamlc.opt -c -o main.cmo main.ml
/usr/local/bin/ocamlopt.opt -c -for-pack Sub1.Sub2 -I sub1/sub2 -o sub1/sub2/sub3.cmx sub1/sub2/sub3.ml
touch sub1/sub2.mli ; if /usr/local/bin/ocamlopt.opt -pack -I sub1/sub2 sub1/sub2/sub3.cmx -for-pack Sub1 -o sub1/sub2.cmx ; then rm -f sub1/sub2.mli ; else rm -f sub1/sub2.mli ; exit 1; fi
touch sub1.mli ; if /usr/local/bin/ocamlopt.opt -pack -I sub1 sub1/sub2.cmx -o sub1.cmx ; then rm -f sub1.mli ; else rm -f sub1.mli ; exit 1; fi
/usr/local/bin/ocamlopt.opt -c -o main.cmx main.ml
/usr/local/bin/ocamlopt.opt sub1.cmx main.cmx -o main.native

Here is the output on trunk:

usr/local/bin/ocamldep.opt -modules main.ml > main.ml.depends
/usr/local/bin/ocamldep.opt -modules sub1/sub2/sub3.ml > sub1/sub2/sub3.ml.depends
/usr/local/bin/ocamlc.opt -c -I sub1/sub2 -o sub1/sub2/sub3.cmo sub1/sub2/sub3.ml
/usr/local/bin/ocamlc.opt -pack sub1/sub2/sub3.cmo -o sub1/sub2.cmo
/usr/local/bin/ocamlc.opt -pack sub1/sub2.cmo -o sub1.cmo
/usr/local/bin/ocamlc.opt -c -o main.cmo main.ml
/usr/local/bin/ocamlopt.opt -c -for-pack Sub1.Sub2 -I sub1/sub2 -o sub1/sub2/sub3.cmx sub1/sub2/sub3.ml
touch sub1/sub2.mli ; if /usr/local/bin/ocamlopt.opt -pack -I sub1/sub2 sub1/sub2/sub3.cmx -o sub1/sub2.cmx ; then rm -f sub1/sub2.mli ; else rm -f sub1/sub2.mli ; exit 1; fi
+ touch sub1/sub2.mli ; if /usr/local/bin/ocamlopt.opt -pack -I sub1/sub2 sub1/sub2/sub3.cmx -o sub1/sub2.cmx ; then rm -f sub1/sub2.mli ; else rm -f sub1/sub2.mli ; exit 1; fi
File "sub1/sub2.cmx", line 1:
Error: File sub1/sub2/sub3.cmx
was not compiled with the `-for-pack Sub2' option
Command exited with code 1.

Please note that in the latter case, the -for-pack argument is missing, on the line that starts with "touch".

Here's what happens (beware, this is just a theory).

The code that is responsible for adding the -for-pack flag to the command line is in ocaml_specific.ml:454

let () =
  pflag ["ocaml"; "native"; "compile"] "for-pack"
    (fun param -> S [A "-for-pack"; A param]);

However,

protzenk@sauternes:/tmp/exemple $ ocamlbuild -show-tags sub1/sub2.cmx
Tags for "sub1/sub2.cmx":
  {. extension:cmx, file:sub1/sub2.cmx, for-pack(Sub1), native, ocaml,
     pkg_unix, quiet, traverse .}

That is to say, when ocamlbuild builds the sub2.cmx file, there *should* be a -for-pack flag, but since sub2.cmx does not have a "compile" tag, the -for-pack flag is not added. Xclerc, do you have any idea how we could add an extra line in ocaml_specific.ml that triggers the -for-pack flag when building a .cmx? Adding another rule that matches on "extension:cmx" instead of "compile" doesn't work (the -for-pack flag gets passed as an argument to -pp when building ocamlbuild itself...).

In this case, the -for-pack *tag* is present, so I think the least we could do is honor the user's instructions and actually pass the -for-pack *flag* to the compiler. How do we write this in ocamlbuild?

Thanks,

jonathan
(0007422)
protz (manager)
2012-05-07 15:12

r12437 and r12438, on 4.00 and trunk respectively.

- Issue History
Date Modified Username Field Change
2010-06-22 18:54 mww New Issue
2010-06-22 18:54 mww File Added: example.tar.gz
2010-07-22 11:39 ertai Status new => assigned
2010-07-22 11:39 ertai Assigned To => xclerc
2010-07-24 01:28 mww Note Added: 0005620
2010-08-13 08:59 mww Note Added: 0005637
2010-12-21 13:28 xclerc Note Added: 0005748
2010-12-21 13:28 xclerc Status assigned => feedback
2011-01-04 22:41 mww Note Added: 0005758
2011-08-13 01:57 abdallah Note Added: 0006089
2011-09-16 15:46 protz Note Added: 0006126
2011-09-16 15:47 protz Note Edited: 0006126
2011-09-16 15:58 protz Note Added: 0006127
2011-09-28 09:56 xclerc Note View State: 6089: private
2011-09-28 09:57 xclerc Note View State: 6089: public
2012-02-02 15:17 protz Category OCamlbuild => OCamlbuild (the tool)
2012-05-07 13:57 protz Note Added: 0007421
2012-05-07 15:12 protz Note Added: 0007422
2012-05-07 15:12 protz Status feedback => resolved
2012-05-07 15:12 protz Fixed in Version => 4.00.0+dev
2012-05-07 15:12 protz Resolution open => fixed
2012-05-07 15:12 protz Assigned To xclerc => protz


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker