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

Wrong openmp flag when using clang compiler #30

Closed
andrsd opened this issue Jan 14, 2013 · 8 comments
Closed

Wrong openmp flag when using clang compiler #30

andrsd opened this issue Jan 14, 2013 · 8 comments
Labels

Comments

@andrsd
Copy link
Member

andrsd commented Jan 14, 2013

Using a clang compiler (3.1), ./configure script adds -fopenmp info CXXFLAGS and CFLAGS. It should be -openmp.

@roystgnr
Copy link
Member

On Mon, 14 Jan 2013, David Andrs wrote:

Using a clang compiler (3.1), ./configure script adds -fopenmp info CXXFLAGS and CFLAGS. It
should be -openmp.

We're using ax_openmp.m4 from the autoconf archive, which does try
-fopenmp before trying -openmp. My clang++ 3.0 seems to be happy with
either (at least it doesn't emit "argument unused during compilation"
warnings like it does with -thiswontwork)... if clang 3.1 is getting
more picky about its options, I'm not sure how to easily modify that
m4 file, which seems to assume that compilers will return errors upon
seeing unknown options, not just warnings.

@jwpeterson
Copy link
Member

On Mon, Jan 14, 2013 at 3:22 PM, David Andrs notifications@github.comwrote:

Using a clang compiler (3.1), ./configure script adds -fopenmp info
CXXFLAGS and CFLAGS. It should be -openmp.

I can take a look at this... it appears that because the AX_OPENMP script
tries the options in the following order:

ax_openmp_flags="-fopenmp -openmp -mp -xopenmp -omp -qsmp=omp none"

And clang doesn't return 1 (it only warns) if it sees -fopenmp, that
configure thinks it succeeds.

Easy fix: we could change the order in which the flags are tested, of
course this might break another compiler in the same manner.

More complicated: we could re-order the options based on knowing what the
compiler is. Seems to be a way of doing this through the
$OPENMP_[]_AC_LANG_PREFIX[]FLAGS variable (though I don't understand this
syntax).

Even more complicated: we could actually try to parse more detailed output
from the compiler (and look for warnings) but I don't know how to do that
in autoconf...

John

@andrsd
Copy link
Member Author

andrsd commented Jan 15, 2013

Hmm. Tried it again today and I think I was wrong with the -openmp flag. If I use this switch, I do not get any error. However clang will interpret this switch as "-o penmp" and produces a file called penmp - which I did not notice before. Compiling from a command line with -fopenmp does not throw any warnings on my simple test C and C++ files. Thus, I am not quite sure why the libmesh build produces that " clang++: warning: argument unused during compilation: '-fopenmp' "... Feel free to mark this issue as wontfix or invalid unless you guys want to look at source of that unused flag warning...

@benkirk
Copy link
Member

benkirk commented Jan 15, 2013

On Jan 15, 2013, at 9:42 AM, David Andrs notifications@github.com wrote:

" clang++: warning: argument unused during compilation: '-fopenmp'

The way I interpret that is that the argument was truly unused - e.g. the underlying file that was compiled had no OpenMP pragmas?

What happens if you try

./configure libmesh_CXXFLAGS="-Qunused-arguments" libmesh_CFLAGS="-Qunused-arguments"

?

-Ben

@jwpeterson
Copy link
Member

On Tue, Jan 15, 2013 at 8:42 AM, David Andrs notifications@github.comwrote:

Hmm. Tried it again today and I think I was wrong with the -openmp flag.
If I use this switch, I do not get any error. However clang will interpret
this switch as "-o penmp" and produces a file called penmp - which I did
not notice before. Compiling from a command line with -fopenmp does not
throw any warnings on my simple test C and C++ files. Thus, I am not quite
sure why the libmesh build produces that " clang++: warning: argument
unused during compilation: '-fopenmp' "... Feel free to mark this issue as
wontfix or invalid unless you guys want to look at source of that unused
flag warning...

Looks like this may have been a compiler bug. Here it was discussed in
October 2012:

http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-October/054459.html

Do you like the idea of adding -Qunused-arguments in compiler.m4 for all
clang builds?

John

@jwpeterson
Copy link
Member

On Tue, Jan 15, 2013 at 8:54 AM, John Peterson jwpeterson@gmail.com wrote:

On Tue, Jan 15, 2013 at 8:42 AM, David Andrs notifications@github.com
wrote:

Hmm. Tried it again today and I think I was wrong with the -openmp flag.
If I use this switch, I do not get any error. However clang will interpret
this switch as "-o penmp" and produces a file called penmp - which I did not
notice before. Compiling from a command line with -fopenmp does not throw
any warnings on my simple test C and C++ files. Thus, I am not quite sure
why the libmesh build produces that " clang++: warning: argument unused
during compilation: '-fopenmp' "... Feel free to mark this issue as wontfix
or invalid unless you guys want to look at source of that unused flag
warning...

Looks like this may have been a compiler bug. Here it was discussed in
October 2012:

http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-October/054459.html

Where by "bug" I mean "unsupported feature". I think David's clang
(3.1) was released 22 May 2012

http://llvm.org/releases/

i.e. prior to the discussion cited above.

Do you like the idea of adding -Qunused-arguments in compiler.m4 for all
clang builds?

If there's any desire for this, I will take a crack at adding it.

John

@andrsd
Copy link
Member Author

andrsd commented Jan 15, 2013

On Tue, Jan 15, 2013 at 8:46 AM, Benjamin S. Kirk
notifications@github.comwrote:

On Jan 15, 2013, at 9:42 AM, David Andrs notifications@github.com
wrote:

" clang++: warning: argument unused during compilation: '-fopenmp'

The way I interpret that is that the argument was truly unused - e.g. the
underlying file that was compiled had no OpenMP pragmas?

What happens if you try

./configure libmesh_CXXFLAGS="-Qunused-arguments"
libmesh_CFLAGS="-Qunused-arguments"

This works, i.e. no warnings generated during the build.

?

-Ben


Reply to this email directly or view it on GitHubhttps://github.com//issues/30#issuecomment-12273218.

David

@benkirk
Copy link
Member

benkirk commented Jan 22, 2013

Resurrecting... John, I have no problem adding -Qunused-arguments

Looks like it is understood at least as far back as 2.8.

jwpeterson pushed a commit that referenced this issue Jan 24, 2013
Can someone who uses clang double-check that this works?

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

No branches or pull requests

4 participants