Skip to content

non informative link time error when the c compiler couldn't run #7141

@vicuna

Description

@vicuna

Original bug ID: 7141
Reporter: @sliquister
Status: acknowledged (set by @damiendoligez on 2016-02-25T13:24:13Z)
Resolution: open
Priority: normal
Severity: minor
Version: 4.02.3
Category: compiler driver
Tags: junior_job
Monitored by: @diml @hcarty

Bug description

When failing to run the c compiler at link time (in my case because
the command line is too big), ocamlopt just fails with this error:

$ /tmp/script.sh
File "caml_startup", line 1:
Error: Error during linking

which is not super helpful. Even after adding -verbose, we still
didn't know what was failing and strac'ing was necessary.

This is because ocamlopt runs [Sys.command .. = 0], presumably relying
on the command to report an error. I think it would be preferable if
the Linking_error exception thrown in the false case could contain the
exit code, and perhaps the program name, so the error could look like:

$ /tmp/script.sh
File "caml_startup", line 1:
Error: Error during linking (exit code 127 from running g++)

Steps to reproduce

cd /tmp
rm -f a.cmx* b.cmx*
touch a.ml b.ml
ocamlopt -c a.ml
ocamlopt -ccopt "$(printf "%70000s")" -a a.cmx -o a.cmxa
ocamlopt -c b.ml
ocamlopt -ccopt "$(printf "%70000s")" -a b.cmx -o b.cmxa
ocamlopt a.cmxa b.cmxa -o out

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions