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

ocaml won't compile correctly with icc 9.0 (many standard library calls with end up ending up in Invalid_argument) #3917

Closed
vicuna opened this issue Dec 12, 2005 · 4 comments

Comments

@vicuna
Copy link

vicuna commented Dec 12, 2005

Original bug ID: 3917
Reporter: monniaux
Status: acknowledged (set by @damiendoligez on 2005-12-15T12:23:39Z)
Resolution: open
Priority: normal
Severity: feature
Version: 3.09.0
Category: configure and build/install
Tags: patch
Related to: #7000
Monitored by: @jmeber

Bug description

If cc is icc (Intel's compiler) version 9, config/auto-aux/hasgot will fail to detect most library functions.

The reason is that hasgot tests whether library function f exists by compiling and linking the following template file:

main() {
f();
}

icc refuses to compile such a file if f is a C standard library function and the number of arguments of f does not correspond to that in the C standard.

The result is that, for instance, HAS_GETTIMEOFDAY will be undefined and the corresponding OCaml function will always raise Invalid_argument.

Additional information

Such behaviour is apparently correct with respect to the C99 standard, section 7.1.4, as recalled in appendix J.2 (i.e. calls to library functions with incorrect number of arguments have undefined behaviour).

I do not know whether it is possible to stop icc from doing so, I do not see any applicable option (safe perhaps for telling it not to use stdlib).

My personal fix is to test for the library functions using gcc, but it is obviously broken in general.

I suggest the hasgot script should be replaced by a script testing for the functions using appropriate arguments.

File attachments

@vicuna
Copy link
Author

vicuna commented Dec 15, 2005

Comment author: @damiendoligez

This is going to take a lot of work to fix properly.

@vicuna
Copy link
Author

vicuna commented Nov 24, 2006

Comment author: monniaux

One dirty practical hack is to configure under gcc, save s.h, configure with icc, and put back the saved s.h.

@vicuna
Copy link
Author

vicuna commented Feb 5, 2007

Comment author: @oandrieu

I disagree with david's analysis :) I believe the UB in section 7.1.4 is about incorrect number of arguments in calls to library functions with variable number of parameters. Here the problem is simply that there is no declarator at all for the called function.

Adding a (bogus) declarator one is enough to turn the compiler error into a warning.

@xavierleroy
Copy link
Contributor

Configuration has been entirely rewritten using GNU autoconf, which has different, more clever ways to test availability of library functions. Optimistically, I think the present issue goes away, and so I'm closing it. There might remain other issues with ICC, though.

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

No branches or pull requests

2 participants