Skip to content

Commit 4ede63e

Browse files
committed
Merge pull request #1 from boegel/optarch_cmdline
fix minor remarks w.r.t. style & code organization
2 parents bc1881c + b4d7a0b commit 4ede63e

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

easybuild/tools/options.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,9 @@ def override_options(self):
170170
'skip-test-cases': ("Skip running test cases", None, 'store_true', False, 't'),
171171
'umask': ("umask to use (e.g. '022'); non-user write permissions on install directories are removed",
172172
None, 'store', None),
173-
'optarch': ("Set architecture optimization, overriding native architecture optimizations", None, 'store', None),
174-
})
173+
'optarch': ("Set architecture optimization, overriding native architecture optimizations",
174+
None, 'store', None),
175+
})
175176

176177
self.log.debug("override_options: descr %s opts %s" % (descr, opts))
177178
self.add_group_parser(opts, descr)

easybuild/tools/toolchain/compiler.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,13 @@ def _get_optimal_architecture(self):
262262
if self.arch is None:
263263
self.arch = systemtools.get_cpu_vendor()
264264

265-
if self.COMPILER_OPTIMAL_ARCHITECTURE_OPTION is not None and self.arch in self.COMPILER_OPTIMAL_ARCHITECTURE_OPTION:
266-
if build_option('optarch') is not None:
267-
optarch = build_option('optarch')
268-
else:
269-
optarch = self.COMPILER_OPTIMAL_ARCHITECTURE_OPTION[self.arch]
265+
optarch = None
266+
if build_option('optarch') is not None:
267+
optarch = build_option('optarch')
268+
elif self.arch in (self.COMPILER_OPTIMAL_ARCHITECTURE_OPTION or []):
269+
optarch = self.COMPILER_OPTIMAL_ARCHITECTURE_OPTION[self.arch]
270+
271+
if optarch is not None:
270272
self.log.info("_get_optimal_architecture: using %s as optarch for %s." % (optarch, self.arch))
271273
self.options.options_map['optarch'] = optarch
272274

test/framework/toolchain.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,17 +295,16 @@ def test_override_optarch(self):
295295
"""Test whether overriding the optarch flag works."""
296296
tc_class, _ = search_toolchain("goalf")
297297
flag_vars = ['CFLAGS', 'CXXFLAGS', 'FFLAGS', 'F90FLAGS']
298-
build_options = { }
299-
for optarch_var in [ 'march=lovelylovelysandybridge', None ]:
300-
build_options.update({'optarch': optarch_var})
298+
for optarch_var in ['march=lovelylovelysandybridge', None]:
299+
build_options = {'optarch': optarch_var}
301300
init_config(build_options=build_options)
302301
for enable in [True, False]:
303302
tc = tc_class(version="1.1.0-no-OFED")
304303
tc.set_options({'optarch': enable})
305304
tc.prepare()
306305
flag = None
307306
if optarch_var is not None:
308-
flag = '-march=lovelylovelysandybridge'
307+
flag = '-%s' % optarch_var
309308
else:
310309
flag = '-march=native'
311310

@@ -314,7 +313,7 @@ def test_override_optarch(self):
314313
if enable:
315314
self.assertTrue(flag in flags, "optarch: True means %s in %s" % (flag, flags))
316315
else:
317-
self.assertTrue(flag not in flags, "optarch: False means no %s in %s" % (flag, flags))
316+
self.assertFalse(flag in flags, "optarch: False means no %s in %s" % (flag, flags))
318317

319318
def test_misc_flags_unique_fortran(self):
320319
"""Test whether unique Fortran compiler flags are set correctly."""

0 commit comments

Comments
 (0)