Skip to content

building .cmxa does not build/link c_names files #131

@lehy-probayes

Description

@lehy-probayes

Consider the following setup:

echo "This C file does not compile" > exists.c
echo "let x = 42" > a.ml
cat << EOF > jbuild
(jbuild_version 1)
(library
 ((name            mylib)
  (modules         (a))
  (c_names         (exists doesnotexist))
))
EOF

Note that one of the C files exists but contains code that does not compile, and the other does not exist.
Then:
jbuilder build mylib.cmxa --verbose
-> builds mylib.cmxa without building exists.c and doesnotexist.c. This links against a libmylib_stubs.a which is not built and does not exist anywhere AFAICS:

Running[2]: (cd _build/default && /home/rlehy/.opam/4.04.0/bin/ocamldep.opt -modules a.ml -impl mylib.ml-gen) > _build/default/mylib.depends.ocamldep-output
Running[3]: (cd _build/default && /home/rlehy/.opam/4.04.0/bin/ocamlc.opt -w -40 -w -49 -g -bin-annot -no-alias-deps -I . -o mylib.cmo -c -impl mylib.ml-gen)
Running[4]: (cd _build/default && /home/rlehy/.opam/4.04.0/bin/ocamlopt.opt -w -40 -w -49 -g -intf-suffix .ml-gen -no-alias-deps -I . -o mylib.cmx -c -impl mylib.ml-gen)
Running[5]: (cd _build/default && /home/rlehy/.opam/4.04.0/bin/ocamlc.opt -w -40 -g -bin-annot -no-alias-deps -I . -open Mylib -o mylib__A.cmo -c -impl a.ml)
Running[6]: (cd _build/default && /home/rlehy/.opam/4.04.0/bin/ocamlopt.opt -w -40 -g -intf-suffix .ml -no-alias-deps -I . -open Mylib -o mylib__A.cmx -c -impl a.ml)
Running[7]: (cd _build/default && /home/rlehy/.opam/4.04.0/bin/ocamlopt.opt -w -40 -g -a -o mylib.cmxa -cclib -lmylib_stubs mylib.cmx mylib__A.cmx)

However, if I ask for the .cmxs, the .cmxa is correctly built with the C files inside (I fixed up exists.c and touched doesnotexist.c):
jbuilder build mylib.cmxs --verbose

Running[2]: (cd _build/default && /home/rlehy/.opam/4.04.0/bin/ocamlc.opt -g -ccopt -g -o doesnotexist.o doesnotexist.c)
Running[3]: (cd _build/default && /home/rlehy/.opam/4.04.0/bin/ocamlc.opt -g -ccopt -g -o exists.o exists.c)
Running[4]: (cd _build/default && /home/rlehy/.opam/4.04.0/bin/ocamldep.opt -modules a.ml -impl mylib.ml-gen) > _build/default/mylib.depends.ocamldep-output
Running[5]: (cd _build/default && /home/rlehy/.opam/4.04.0/bin/ocamlc.opt -w -40 -w -49 -g -bin-annot -no-alias-deps -I . -o mylib.cmo -c -impl mylib.ml-gen)
Running[6]: (cd _build/default && /home/rlehy/.opam/4.04.0/bin/ocamlopt.opt -w -40 -w -49 -g -intf-suffix .ml-gen -no-alias-deps -I . -o mylib.cmx -c -impl mylib.ml-gen)
Running[7]: (cd _build/default && /home/rlehy/.opam/4.04.0/bin/ocamlc.opt -w -40 -g -bin-annot -no-alias-deps -I . -open Mylib -o mylib__A.cmo -c -impl a.ml)
Running[8]: (cd _build/default && /home/rlehy/.opam/4.04.0/bin/ocamlopt.opt -w -40 -g -intf-suffix .ml -no-alias-deps -I . -open Mylib -o mylib__A.cmx -c -impl a.ml)
Running[9]: (cd _build/default && /home/rlehy/.opam/4.04.0/bin/ocamlopt.opt -w -40 -g -a -o mylib.cmxa -cclib -lmylib_stubs mylib.cmx mylib__A.cmx)
Running[10]: (cd _build/default && /home/rlehy/.opam/4.04.0/bin/ocamlmklib.opt -g -o mylib_stubs exists.o doesnotexist.o)
Running[11]: (cd _build/default && /home/rlehy/.opam/4.04.0/bin/ocamlopt.opt -w -40 -g -shared -linkall -I . -o mylib.cmxs mylib.cmxa)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions