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

Add dashes directly in compiler optimization flags #4698

Open
wants to merge 23 commits into
base: 5.0.x
Choose a base branch
from

Conversation

Micket
Copy link
Contributor

@Micket Micket commented Nov 7, 2024

Fixes #4269

It was extremely difficult to read this code, partly because a bunch of variables like:

COMPILER_F_UNIQUE_FLAGS = []

were, in fact, not flags, but options. I renamed these variables because it was so misleading. To add to this, we also have two COMPILER_FLAGS used for different things (neither of them are flags)

@Micket Micket added the EasyBuild-5.0 EasyBuild 5.0 label Nov 7, 2024
@Micket Micket added this to the 5.0 milestone Nov 7, 2024
@Micket
Copy link
Contributor Author

Micket commented Nov 12, 2024

I finally found the place that actually adds the extra -

It boils down to using FlagList, and possible CommandFlagList.
Instead, these are not just plain StrList

I need to find a scenario where CommandFlagList was used withmore than a single argument, but it's all so very deeply hidden and obscured it's impossible to tell where the heck these are coming from. Tests indicate it works like

        cmd = CommandFlagList(["gcc", "bar", "baz"])
        self.assertEqual(str(cmd), "gcc -bar -baz")

so i need to find a scenario where this actually used, to ensure i did fix it correctly.

@Micket Micket marked this pull request as ready for review November 12, 2024 13:10
}

COMPILER_CC = 'clang'
COMPILER_CXX = 'clang++'
COMPILER_C_UNIQUE_FLAGS = []
COMPILER_C_UNIQUE_OPTIONS = []
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, do we really need to change this?

We have to take into account that people may have their own/custom implementations of classes that derive from Compiler, they will need to be adjusted accordingly (and we have no easy way to produce a clean error message there, I think)...

@@ -349,6 +349,11 @@ def _set_optimal_architecture(self, default_optarch=None):
optarch = self.COMPILER_OPTIMAL_ARCHITECTURE_OPTION[(self.arch, self.cpu_family)]

if optarch is not None:
if not optarch.startswith('-'):
print_warning(f'Specifying optarch "{optarch}" without initial dash is deprecated in EasyBuild 5.')
Copy link
Member

Choose a reason for hiding this comment

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

use self.log.deprecated here

test/framework/toolchain.py Outdated Show resolved Hide resolved
@@ -3144,21 +3145,6 @@ def test_env_vars_external_module(self):
expected = {}
self.assertEqual(res, expected)

def test_get_flag(self):
Copy link
Member

Choose a reason for hiding this comment

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

Why is this test removed?

COMPILER_PREC_FLAGS = ['strict', 'precise', 'defaultprec', 'loose', 'veryloose'] # precision flags, ordered !
COMPILER_OPTIONS = ['debug', 'ieee', 'openmp', 'pic', 'shared', 'static', 'unroll', 'verbose'] # any compiler
COMPILER_OPT_OPTIONS = ['noopt', 'lowopt', DEFAULT_OPT_LEVEL, 'opt'] # optimisation args, ordered !
COMPILER_PREC_OPTIONS = ['strict', 'precise', 'defaultprec', 'loose', 'veryloose'] # precision flags, ordered !
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need these renames from _FLAGS to _OPTIONS?

I'd say -O3 is a compiler flag as well as an option, there's no crystal clear definition there, so let's not cause any "pain" by renaming this (since it's not really internal)

Copy link
Member

Choose a reason for hiding this comment

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

At the very least there should be a warning if COMPILER_PREC_FLAGS (or any other *_FLAGS being renamed) is still being used...

@Micket Micket marked this pull request as draft November 13, 2024 11:44
@Micket Micket marked this pull request as ready for review November 15, 2024 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Changed default
Development

Successfully merging this pull request may close these issues.

2 participants