@@ -251,12 +251,8 @@ def concretize_architecture(self, spec):
251251 DAG has an architecture, then use the root otherwise use the defaults
252252 on the platform.
253253 """
254- root_arch = spec .link_root ().architecture
255- if spec .build_dep () and spec .disjoint_build_tree ():
256- sys_arch = spack .spec .ArchSpec (
257- spack .architecture .frontend_sys_type ())
258- else :
259- sys_arch = spack .spec .ArchSpec (spack .architecture .sys_type ())
254+ root_arch = spec .root .architecture
255+ sys_arch = spack .spec .ArchSpec (spack .architecture .sys_type ())
260256 spec_changed = False
261257
262258 if spec .architecture is None :
@@ -327,21 +323,14 @@ def _proper_compiler_style(cspec, aspec):
327323 spec .compiler in all_compilers ):
328324 return False
329325
330- if spec .compiler :
331- other_spec = spec
332- elif spec .build_dep () and spec .disjoint_build_tree ():
333- link_root = spec .link_root ()
334- build_subtree = list (link_root .traverse (direction = 'children' ))
335- candidates = list (x for x in build_subtree if x .compiler )
336- other_spec = candidates [0 ] if candidates else link_root
337- else :
338- # Find another spec that has a compiler, or the root if none do.
339- # Prefer compiler info from other specs which are not build deps.
340- other_spec = (
341- find_spec (spec , lambda x : x .compiler and not x .build_dep ()) or
342- spec .root )
326+ # Find the another spec that has a compiler, or the root if none do
327+ other_spec = spec if spec .compiler else find_spec (
328+ spec , lambda x : x .compiler )
343329
330+ if not other_spec :
331+ other_spec = spec .root
344332 other_compiler = other_spec .compiler
333+ assert (other_spec )
345334
346335 # Check if the compiler is already fully specified
347336 if other_compiler in all_compilers :
@@ -389,20 +378,16 @@ def concretize_compiler_flags(self, spec):
389378 # running.
390379 return True
391380
392- def compiler_match (spec1 , spec2 ):
393- return ((spec1 .compiler , spec1 .architecture ) ==
394- (spec2 .compiler , spec2 .architecture ))
395-
396381 ret = False
397382 for flag in spack .spec .FlagMap .valid_compiler_flags ():
398383 try :
399384 nearest = next (p for p in spec .traverse (direction = 'parents' )
400- if ((p is not spec ) and
401- compiler_match ( p , spec ) and
385+ if ((p . compiler == spec . compiler and
386+ p is not spec ) and
402387 flag in p .compiler_flags ))
403- if ( flag not in spec .compiler_flags or
404- ( set ( nearest .compiler_flags [flag ]) -
405- set ( spec .compiler_flags [flag ]) )):
388+ if flag not in spec .compiler_flags or \
389+ not ( sorted ( spec .compiler_flags [flag ]) >=
390+ sorted ( nearest .compiler_flags [flag ])):
406391 if flag in spec .compiler_flags :
407392 spec .compiler_flags [flag ] = list (
408393 set (spec .compiler_flags [flag ]) |
@@ -413,11 +398,10 @@ def compiler_match(spec1, spec2):
413398 ret = True
414399
415400 except StopIteration :
416- if (compiler_match (spec .root , spec ) and
417- flag in spec .root .compiler_flags and
418- ((flag not in spec .compiler_flags ) or
419- (set (spec .root .compiler_flags [flag ]) -
420- set (spec .compiler_flags [flag ])))):
401+ if (flag in spec .root .compiler_flags and
402+ ((flag not in spec .compiler_flags ) or
403+ sorted (spec .compiler_flags [flag ]) !=
404+ sorted (spec .root .compiler_flags [flag ]))):
421405 if flag in spec .compiler_flags :
422406 spec .compiler_flags [flag ] = list (
423407 set (spec .compiler_flags [flag ]) |
@@ -441,8 +425,10 @@ def compiler_match(spec1, spec2):
441425 if compiler .flags [flag ] != []:
442426 ret = True
443427 else :
444- if (set (compiler .flags [flag ]) -
445- set (spec .compiler_flags [flag ])):
428+ if ((sorted (spec .compiler_flags [flag ]) !=
429+ sorted (compiler .flags [flag ])) and
430+ (not set (spec .compiler_flags [flag ]) >=
431+ set (compiler .flags [flag ]))):
446432 ret = True
447433 spec .compiler_flags [flag ] = list (
448434 set (spec .compiler_flags [flag ]) |
0 commit comments