Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OCamlc] fixes output-complete-object #1332

Merged
merged 7 commits into from
Sep 16, 2017
Merged

Conversation

bobot
Copy link
Contributor

@bobot bobot commented Sep 13, 2017

When trying to add support for --output-complete-obj for jbuilder [ocaml/dune#23], I was not able to make --output-complete-obj work in bytecode mode. ocamlc complains that the temporary files it just created exist. This PR fixes this option and add tests for it.

The support for --output-complete-obj has been added in ed60dec and 19d3bcc

   ocamlc complained that the temporary files it just created existed.
   since ed60dec and
   19d3bcc
@bobot bobot changed the title [OCamlc] fixes output_complete_object [OCamlc] fixes output-complete-object Sep 13, 2017
try
link_bytecode_as_c ppf tolink c_file;
if not (Filename.check_suffix output_name ".c") then begin
temps := c_file :: !temps;
if Ccomp.compile_file c_file <> 0 then
(* -DCAML_INTERNALS because the .c use startup.h *)
if Ccomp.compile_file ~output:obj_file ~opt:"-DCAML_INTERNALS" c_file <> 0 then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't obviously see an equivalent use of -DCAML_INTERNALS in asmlink.ml, is that expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since asmlink goes directly to assembly I think so. But indeed CAML_INTERNALS is not defined in this way: all the other C files that use startup.h just define CAML_INTERNALS directly in the file. It is now fixed.

utils/ccomp.ml Outdated
@@ -87,6 +87,8 @@ let compile_file name =
then (Config.ocamlopt_cflags, Config.ocamlopt_cppflags)
else (Config.ocamlc_cflags, Config.ocamlc_cppflags) in
(String.concat " " [Config.c_compiler; cflags; cppflags]))
(match output with | None -> "" | Some o -> "-o " ^ o)
opt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you checked that all the C compilers support the -o option? (Sun compiler, Intel compiler, MSVC, gcc, clang, pcc)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't, and it is not the case. It is fixed by adding OUTPUTOBJ to config.ml and using it.

@lpw25 lpw25 merged commit e1fd8d5 into ocaml:trunk Sep 16, 2017
@damiendoligez
Copy link
Member

Note: needs more work (fails on most architectures, including linux/amd64). I've disabled the test for the moment (commit 47a6e48).

@bobot
Copy link
Contributor Author

bobot commented Sep 18, 2017

@damiendoligez thank you for the news. Do you still have any log of the failures?

@damiendoligez
Copy link
Member

@bobot I'll get back to you in a few days.

Oh, and it needs documentation too. I can't find any trace of it in the manual or even in the man pages.

@bobot
Copy link
Contributor Author

bobot commented Sep 18, 2017

Started #1351 for the doc and more importantly the possible deprecation of output-obj.

@@ -180,6 +180,8 @@ Working version

### Compiler user-interface and warnings:

- GPR##1332: fix ocamlc handling of "-output-complete-obj"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worst Changes entry ever! :-)

@dbuenzli
Copy link
Contributor

dbuenzli commented Nov 3, 2017

Started #1351 for the doc and more importantly the possible deprecation of output-obj.

Since I see this. As I hope #1351 made clear, output-obj should not be deprecated.

@damiendoligez
Copy link
Member

@bobot "a few" days have passed... When I enable the test I get this:

4.06/testsuite $ make one DIR=tests/output_obj
Running tests from 'tests/output_obj' ...
 ... testing 'test.ml' with native => failed
+ /Users/doligez/o/4.06/testsuite/../byterun/ocamlrun /Users/doligez/o/4.06/testsuite/../ocamlopt -nostdlib -I /Users/doligez/o/4.06/testsuite/../stdlib -w a -output-complete-obj -o test.ml.exe.o test.ml
+ gcc -O2 -fno-strict-aliasing -fwrapv -Wall -Werror -D_FILE_OFFSET_BITS=64 -D_REENTRANT -DCAML_NAME_SPACE -Wl,-no_compact_unwind -I/Users/doligez/o/4.06/testsuite/../byterun -o test.ml_stub test.ml.exe.o test.ml_stub.c
Undefined symbols for architecture x86_64:
  "_caml_code_area_end", referenced from:
      _segv_handler in test.ml.exe.o
  "_caml_code_area_start", referenced from:
      _segv_handler in test.ml.exe.o
  "_caml_startup", referenced from:
      _main in test-af8fba.o
     (maybe you meant: _caml_startup__frametable, _caml_startup__data_begin , _caml_startup_aux , _caml_startup__code_end , _caml_startup__code_begin , _caml_startup__data_end )
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
 ... testing 'test.ml' with byte => passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants