Skip to content

Handle multi-flag compiler options on all types of options.#1966

Merged
boegel merged 7 commits intoeasybuilders:developfrom
akesandgren:fix-multi-flag-compiler-options
Nov 4, 2016
Merged

Handle multi-flag compiler options on all types of options.#1966
boegel merged 7 commits intoeasybuilders:developfrom
akesandgren:fix-multi-flag-compiler-options

Conversation

@akesandgren
Copy link
Copy Markdown
Contributor

@akesandgren akesandgren commented Oct 23, 2016

tools/toolchain/compiler.py _set_compiler_flags should use nextend
instead of nappend when setting the actual C/F FLAGS

If there is a option that isn't a simple flag but multiple flags the use of
self.variables.nappend(var, flags) results in things like
-fPIC -['someflag', 'flag2']

Using
self.variables.nextend(var, flags)
instead gives the expected result of
-fPIC -someflag -flag2

tools/toolchain/compiler.py _set_compiler_flags should use nextend
instead of nappend when setting the actual C/F FLAGS

If there is a option that isn't a simple flag but multiple flags the use of
self.variables.nappend(var, flags) results in things like
-fPIC -['someflag', 'flag2']

Using
self.variables.nextend(var, flags)
instead gives the expected result of
-fPIC -someflag -flag2
@akesandgren
Copy link
Copy Markdown
Contributor Author

I'm looking into the failed tests to see if i can figure out a better solution

@akesandgren akesandgren force-pushed the fix-multi-flag-compiler-options branch from 9e1e115 to 7689007 Compare October 23, 2016 09:04
compiler/cuda.py also needs to use nextend when setting it's CUDA_FLAGS.
@akesandgren akesandgren force-pushed the fix-multi-flag-compiler-options branch from 7689007 to 0fa4c25 Compare October 23, 2016 09:06
This is caused by the
"Handle multi-flag compiler options on all types of options"
commits.

Have no idea why but it is coming from the _set_compiler_flags in
toolchains/compiler/cuda.py
@akesandgren
Copy link
Copy Markdown
Contributor Author

akesandgren commented Oct 23, 2016

Please rewiew, and especially the "Handle weird bool" commit, and if someone can figure out why it happens in the first place (coming from the cuda.py nextend calls somehow) i'd be interested.

I just can't figure out that part....

@boegel boegel added this to the v3.0 milestone Nov 3, 2016
@boegel
Copy link
Copy Markdown
Member

boegel commented Nov 3, 2016

@akesandgren Can you clarify the context in which you were hitting this?

I think there should be no need for this, since -fPIC -['someflag', 'flag2'] should get flattened to -fPIC -someflag -flag2 in time before it's actually used to define $CFLAGS.

The bool change you had to include seems be required for handling openmp being defined, it may be a sign of a different problem (that does not occur when sticking to nappend).

It's clear that the way in which the toolchain supports deals with variables is quite complex, it should probably be thoroughly revised/simplified at some point...

@akesandgren
Copy link
Copy Markdown
Contributor Author

I was hitting it when trying to add a 'ieee' toolchain option (PR 1975), where the gcc definition is:
'ieee': ['mieee-fp', 'fno-trapping-math'],

So if you take PR 1975 by itself you will see a bunch of errors that this PR deals with.

@boegel
Copy link
Copy Markdown
Member

boegel commented Nov 3, 2016

@akesandgren we already have various other options that relate to a list of flags rather than a single flag, and that's working fine?

I don't see what's different about ieee in that respect?

Where are you seeing errors pop up without this change?

@boegel
Copy link
Copy Markdown
Member

boegel commented Nov 3, 2016

Hmm, wait, the precision options relate to lists of flags, but those are already handled via nextend.

I'm adding a test for ieee in #1975, and I'm now indeed seeing something like:

======================================================================
FAIL: test_precision_flags (__main__.ToolchainTest)
Test whether precision flags are being set correctly.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/kehoste/work/easybuild-framework/test/framework/toolchain.py", line 389, in test_precision_flags
    self.assertEqual(os.getenv(var), "-O2 -march=native %s" % prec_flags[prec])
  File "/Users/kehoste/work/vsc-install/lib/vsc/install/testing.py", line 79, in assertEqual
    raise AssertionError("%s:\nDIFF%s:\n%s" % (msg, limit, ''.join(diff[:self.ASSERT_MAX_DIFF])))
AssertionError: "-['mieee-fp', 'fno-trapping-math'] -O2 -march=native" != '-O2 -march=native -mieee-fp -fno-trapping-math':
DIFF:
- -['mieee-fp', 'fno-trapping-math'] -O2 -march=native

So, this change indeed makes sense. That leaves the bool weirdness that we need to figure out...

@boegel
Copy link
Copy Markdown
Member

boegel commented Nov 3, 2016

@akesandgren OK, I think the problem is that using defining the openmp toolchain option as True is not being handled well in case there's no mapping for openmp, like is the case in cuda.py.
The openmp flag should probably be skipped all together in cuda.py...

I'll see if I can come up with a better fix, your change in easybuild/tools/variables.py is basically sweeping something under the rug, rather than an actual fix...

@akesandgren
Copy link
Copy Markdown
Contributor Author

Yeah, i thought it was suspicious.

@boegel
Copy link
Copy Markdown
Member

boegel commented Nov 3, 2016

@akesandgren I fixed the problem differently by making sure there's always a compiler flag defined for openmp, see akesandgren#2

It's not airtight either, but at least I'm dealing with the root of the problem you ran into, I feel it's better than the change you made to nextend...

boegel and others added 2 commits November 4, 2016 00:24
specify -fopenmp as general compiler flag for enabling OpenMP mode, enhance tests to check it's handled correctly
@boegel
Copy link
Copy Markdown
Member

boegel commented Nov 4, 2016

lgtm, thanks @akesandgren!

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.

2 participants