@@ -486,36 +486,51 @@ class Chapel(AutotoolsPackage, CudaPackage, ROCmPackage):
486486
487487 conflicts ("+rocm" , when = "+cuda" , msg = "Chapel must be built with either CUDA or ROCm, not both" )
488488
489+ # GPU requirements should encode the requirements documented at:
490+ # https://chapel-lang.org/docs/technotes/gpu.html#requirements
491+
489492 # CUDA conflicts and dependencies
490- conflicts (
491- "^llvm@20" ,
492- when = "@:2.5 +cuda" ,
493- msg = "Chapel through 2.5 does not support Nvidia GPUs with LLVM 20, see "
494- "https://github.com/chapel-lang/chapel/issues/27273" ,
495- )
493+ with when ("+cuda" ):
494+ conflicts ("llvm=none" , msg = "Cuda support requires building with LLVM" )
495+
496+ depends_on ("llvm@16:" , when = "llvm=spack ^cuda@12:" )
497+ requires (
498+ "^llvm targets=all" ,
499+ msg = "llvm=spack +cuda requires LLVM support the nvptx target" ,
500+ when = "llvm=spack" ,
501+ )
502+ conflicts (
503+ "^llvm@20" ,
504+ when = "@:2.5" ,
505+ msg = "Chapel through 2.5 does not support Nvidia GPUs with LLVM 20, see "
506+ "https://github.com/chapel-lang/chapel/issues/27273" ,
507+ )
496508
497- conflicts ("cuda@12.9:" , when = "+cuda " ) # deprecation warnings otherwise
509+ conflicts ("cuda@12.9:" ) # deprecation warnings otherwise
498510
499511 # ROCm conflicts and dependencies
500- conflicts ("+rocm" , when = "@:2.1" , msg = "ROCm support in spack requires Chapel 2.2.0 or later" )
501- # Chapel restricts the allowable ROCm versions
502- with when ("@2.2: +rocm" ):
512+ with when ("+rocm" ):
513+ conflicts ("llvm=none" , msg = "ROCm support requires building with LLVM" )
514+
515+ # Chapel restricts the allowable ROCm versions
503516 depends_on ("hsa-rocr-dev@6.0:6.2" )
504517 depends_on ("hip@6.0:6.2" )
505- # This is the case because the package only supports ROCm 6, and Chapel
506- # requires bundled LLVM for that version.
507- # TODO: Modify this constrant and message if/when Chapel supports an
508- # additional ROCm version without that requirement.
509- requires ("llvm=bundled" , when = "+rocm" , msg = "Chapel ROCm support requires llvm=bundled" )
510-
511- # Workaround for ROCmPackage forcing a dependency on llvm-amdgpu, which
512- # provides %rocmcc, which we don't want to use.
513- requires (
514- * ("%" + comp for comp in compiler_map .keys () if comp != "rocmcc" and comp != "unset" ),
515- policy = "any_of" , # any to ensure %clang works
516- when = "+rocm" ,
517- msg = "Chapel ROCm support requires a supported host compiler other than rocmcc" ,
518- )
518+
519+ conflicts ("@:2.1" , msg = "ROCm support in spack requires Chapel 2.2.0 or later" )
520+
521+ # This is the case because the package only supports ROCm 6, and Chapel
522+ # requires bundled LLVM for that version.
523+ # TODO: Modify this constrant and message if/when Chapel supports an
524+ # additional ROCm version without tht requirement.
525+ requires ("llvm=bundled" , msg = "Chapel ROCm support requires llvm=bundled" )
526+
527+ # Workaround for ROCmPackage forcing a dependency on llvm-amdgpu, which
528+ # provides %rocmcc, which we don't want to use.
529+ requires (
530+ * ("%" + comp for comp in compiler_map .keys () if comp != "rocmcc" and comp != "unset" ),
531+ policy = "any_of" , # any to ensure %clang works
532+ msg = "Chapel ROCm support requires a supported host compiler other than rocmcc" ,
533+ )
519534
520535 conflicts (
521536 "comm_substrate=unset" ,
@@ -553,14 +568,12 @@ class Chapel(AutotoolsPackage, CudaPackage, ROCmPackage):
553568 "https://chapel-lang.org/docs/usingchapel/chplenv.html#chpl-host-jemalloc" ,
554569 )
555570
556- with when ("llvm=none" ):
557- conflicts ("+cuda" , msg = "Cuda support requires building with LLVM" )
558- conflicts ("+rocm" , msg = "ROCm support requires building with LLVM" )
559- conflicts (
560- "+python-bindings" ,
561- msg = "Python bindings require building with LLVM, see "
562- "https://chapel-lang.org/docs/tools/chapel-py/chapel-py.html#installation" ,
563- )
571+ conflicts (
572+ "+python-bindings" ,
573+ when = "llvm=none" ,
574+ msg = "Python bindings require building with LLVM, see "
575+ "https://chapel-lang.org/docs/tools/chapel-py/chapel-py.html#installation" ,
576+ )
564577
565578 # Add dependencies
566579 depends_on ("c" , type = "build" ) # generated
@@ -584,14 +597,6 @@ class Chapel(AutotoolsPackage, CudaPackage, ROCmPackage):
584597 depends_on ("llvm@14:20" , when = "@2.6:2.7" )
585598 depends_on ("llvm@14:21" , when = "@2.8:" )
586599
587- # Based on docs https://chapel-lang.org/docs/technotes/gpu.html#requirements
588- depends_on ("llvm@16:" , when = "llvm=spack +cuda ^cuda@12:" )
589- requires (
590- "^llvm targets=all" ,
591- msg = "llvm=spack +cuda requires LLVM support the nvptx target" ,
592- when = "llvm=spack +cuda" ,
593- )
594-
595600 # This is because certain systems have binutils installed as a system package
596601 # but do not include the headers. Spack incorrectly supplies those external
597602 # packages as proper dependencies for LLVM, but then LLVM will fail to build
0 commit comments