Skip to content

call_linker now returns exit_code for better user response on linking_error, fixes #7141#9389

Merged
gasche merged 3 commits intoocaml:trunkfrom
Anukriti12:trunk
Apr 17, 2020
Merged

call_linker now returns exit_code for better user response on linking_error, fixes #7141#9389
gasche merged 3 commits intoocaml:trunkfrom
Anukriti12:trunk

Conversation

@Anukriti12
Copy link
Copy Markdown
Contributor

Created additional error Linking_error_c_compiler fixes #7141

Copy link
Copy Markdown
Member

@gasche gasche left a comment

Choose a reason for hiding this comment

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

I think the approach in this PR is not completely right: it assumes that the exit code is always 127 and the linker called always g++, but this is not always the case. I would propose to:

  • Focus on the exit code only: have a working PR that prints the exit code in the error message, and forget about the linker program name for now; we can always add this in a later PR.

  • Change Ccomp.call_linker to return the exit code of the call, instead of just a boolean (this means that all callers have to be adapted to check = 0 themselves)

  • Add the exit code number as a parameter of the exception: exception Linking_error of int. (Note: instead of defining a new exception, we just extend Linking_error.)

in
if not (Ccomp.call_linker mode output_name files c_lib)
then raise(Error Linking_error)
then raise(Error Linking_error_c_compiler)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The error message says that the exit code is 127 and the caller program is g++, but the way you raise the exception does not ensure this: call_linker may return false even with other exit codes, and we don't know which linker was called.

@Anukriti12 Anukriti12 changed the title Added link time error check, fixes #7141 call_linker now returns exit_code for better user response on linking_error, fixes #7141 Mar 22, 2020
@v-gb
Copy link
Copy Markdown
Contributor

v-gb commented Mar 22, 2020

In principle, #1727 should have fixed the problem. I still see a bad error my machine, but it looks like a glibc bug where system() returns wrong values (the child gets E2BIG in exec, which is errno 7, which gets reinterpreted as status 7, which is signalled by sibgus, which Sys.command returns as 255).

@Anukriti12 Anukriti12 force-pushed the trunk branch 3 times, most recently from 833af0a to a4203e3 Compare March 22, 2020 23:38
@gasche
Copy link
Copy Markdown
Member

gasche commented Mar 23, 2020

@sliquister ah, I had missed this change. (cc @trefis in case). Do you think the change in the present PR, which adds the exit code to the non-127 linking-error case, would possibly be helpful for users?

@v-gb
Copy link
Copy Markdown
Contributor

v-gb commented Mar 23, 2020

The only confusing case I have ever seen is with exit code 127 (because that's what system uses whenever anything goes wrong), because the rest of the time the program should print an error. It might be useful if the linker was killed by a signal, but I haven't tried seeing if any error is printed then.

@Anukriti12
Copy link
Copy Markdown
Contributor Author

@gasche Can you please review once?

Copy link
Copy Markdown
Member

@gasche gasche left a comment

Choose a reason for hiding this comment

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

From my reading of the reports on this error, the exit code is not often necessary but it may still be useful in some cases (including the tool being buggy and returning something else than 127 when it should): it does not hurt and can help. I am in favor in merging if the style-small style-level nitpicks I made are adressed.

@gasche gasche merged commit 9568154 into ocaml:trunk Apr 17, 2020
gasche added a commit to gasche/ocaml that referenced this pull request Aug 11, 2020
gasche added a commit to gasche/ocaml that referenced this pull request Aug 11, 2020
gasche added a commit that referenced this pull request Aug 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants