From 9ac6ecd5ba39ecb055c1496047ed29deeeb32947 Mon Sep 17 00:00:00 2001 From: arezaii Date: Tue, 25 Mar 2025 10:01:58 -0600 Subject: [PATCH] Chapel 2.4 (#49662) * limit some patches by chapel version * fix short output version if building main * update patches, remove unneeded 'self' refs * fix spack style * update patches with changes from PR * change py-protobuf to just protobuf dep * add PR numbers for patches * fix spack style * update 2.4 sha256 --- .../chapel/fix_chpl_shared_lib_path.patch | 119 ++++++++++++------ .../chapel/fix_chpl_shared_lib_path_2.3.patch | 110 +++++++++++----- .../repos/builtin/packages/chapel/package.py | 18 ++- 3 files changed, 165 insertions(+), 82 deletions(-) diff --git a/var/spack/repos/builtin/packages/chapel/fix_chpl_shared_lib_path.patch b/var/spack/repos/builtin/packages/chapel/fix_chpl_shared_lib_path.patch index 047a657d6ef..44b8667e058 100644 --- a/var/spack/repos/builtin/packages/chapel/fix_chpl_shared_lib_path.patch +++ b/var/spack/repos/builtin/packages/chapel/fix_chpl_shared_lib_path.patch @@ -1,46 +1,87 @@ +diff --git a/util/chplenv/chpl_home_utils.py b/util/chplenv/chpl_home_utils.py +index 5d85153835..b08fc2fc93 100644 +--- a/util/chplenv/chpl_home_utils.py ++++ b/util/chplenv/chpl_home_utils.py +@@ -54,6 +54,45 @@ install_path_regex = re.compile( + os.path.sep, + os.path.sep)) + ++@memoize ++def get_chpl_configured_install_lib_prefix(): ++ # gets the path to the lib directory for a prefix install, or None if not ++ # a prefix install ++ chpl_home = str(os.getenv("CHPL_HOME")) ++ if os.path.exists(os.path.join(chpl_home, "configured-prefix")): ++ with open(os.path.join(chpl_home, "CMakeLists.txt"), "r") as f: ++ # read CMakeLists.txt to get the CHPL_MAJOR_VERSION and ++ # CHPL_MINOR_VERSION and then construct the path from that ++ chpl_major_version = None ++ chpl_minor_version = None ++ for line in f: ++ if "set(CHPL_MAJOR_VERSION" in line: ++ chpl_major_version = line.split()[1].strip(")") ++ if "set(CHPL_MINOR_VERSION" in line: ++ chpl_minor_version = line.split()[1].strip(")") ++ if ( ++ chpl_major_version is not None ++ and chpl_minor_version is not None ++ ): ++ break ++ assert chpl_major_version is not None and chpl_minor_version is not None ++ chpl_version_string = "{}.{}".format( ++ chpl_major_version, ++ chpl_minor_version, ++ ) ++ chpl_prefix = None ++ with open(os.path.join(chpl_home, "configured-prefix"), "r") as f: ++ chpl_prefix = f.read().strip() ++ assert chpl_prefix != "" and chpl_prefix is not None ++ return os.path.join( ++ chpl_prefix, ++ "lib", ++ "chapel", ++ chpl_version_string, ++ "compiler", ++ ) ++ return None ++ + @memoize + def get_chpl_version_from_install(): + if get_prefix_install_prefix(): +@@ -189,6 +228,8 @@ def _main(): + ) + parser.add_option('--using-module', action='store_const', + dest='func', const=using_chapel_module) ++ parser.add_option('--configured-install-lib-prefix', action='store_const', ++ dest='func', const=get_chpl_configured_install_lib_prefix) + (options, args) = parser.parse_args() + + if options.func: + diff --git a/tools/chapel-py/setup.py b/tools/chapel-py/setup.py -index bee452790c..58ec46d7e6 100644 +index 0f3dd9fea0..9be2a48cff 100644 --- a/tools/chapel-py/setup.py +++ b/tools/chapel-py/setup.py -@@ -46,7 +46,37 @@ host_cc = str(chpl_variables.get("CHPL_HOST_CC")) - host_cxx = str(chpl_variables.get("CHPL_HOST_CXX")) +@@ -47,6 +47,18 @@ host_cxx = str(chpl_variables.get("CHPL_HOST_CXX")) host_bin_subdir = str(chpl_variables.get("CHPL_HOST_BIN_SUBDIR")) -+ -+# construct the chpl_lib_path from chpl_home, or use the configured-prefix if it exists -+ chpl_lib_path = os.path.join(chpl_home, "lib", "compiler", host_bin_subdir) -+chpl_install_lib_path = None -+if os.path.exists(os.path.join(chpl_home, "configured-prefix")): -+ with open(os.path.join(chpl_home, "CMakeLists.txt"), "r") as f: -+ # read CMakeLists.txt to get the CHPL_MAJOR_VERSION and CHPL_MINOR_VERSION -+ # and then construct the path from that -+ chpl_major_version = None -+ chpl_minor_version = None -+ for line in f: -+ if "set(CHPL_MAJOR_VERSION" in line: -+ chpl_major_version = line.split()[1].strip(')') -+ if "set(CHPL_MINOR_VERSION" in line: -+ chpl_minor_version = line.split()[1].strip(')') -+ if chpl_major_version is not None and chpl_minor_version is not None: -+ break -+ assert(chpl_major_version is not None and chpl_minor_version is not None) -+ chpl_version_string = "{}.{}".format(chpl_major_version, chpl_minor_version) -+ chpl_prefix = None -+ with open(os.path.join(chpl_home, "configured-prefix"), "r") as f: -+ chpl_prefix = f.read().strip() -+ assert(chpl_prefix is not None) -+ chpl_install_lib_path = os.path.join( -+ chpl_prefix, -+ "lib", -+ "chapel", -+ chpl_version_string, -+ "compiler" -+ ) ++# For installations using --prefix, the build and final lib paths are going to ++# differ. figure out the install location now and write it to the rpath ++chpl_home_utils = os.path.join( ++ chpl_home, "util", "chplenv", "chpl_home_utils.py" ++) ++chpl_install_lib_path = ( ++ subprocess.check_output( ++ ["python", chpl_home_utils, "--configured-install-lib-prefix"], ++ ) ++ .decode(sys.stdout.encoding) ++ .strip() ++) CXXFLAGS = [] if have_llvm and have_llvm != "none": -@@ -64,10 +94,14 @@ CXXFLAGS += ["-std=c++17", "-I{}/frontend/include".format(chpl_home)] +@@ -64,11 +76,16 @@ CXXFLAGS += ["-std=c++17", "-I{}/frontend/include".format(chpl_home)] LDFLAGS = [] LDFLAGS += [ "-L{}".format(chpl_lib_path), @@ -49,11 +90,13 @@ index bee452790c..58ec46d7e6 100644 - "-Wl,-rpath", - chpl_lib_path, ] -+if chpl_install_lib_path is not None: + ++if chpl_install_lib_path != "None": + LDFLAGS += [ + "-L{}".format(chpl_install_lib_path), + "-Wl,-rpath,{}".format(chpl_install_lib_path), + ] - - if str(chpl_variables.get("CHPL_SANITIZE")) == "address": - if str(chpl_variables.get("CHPL_HOST_PLATFORM")) == "darwin": ++ + os.environ["CC"] = host_cc + os.environ["CXX"] = host_cxx + setup( diff --git a/var/spack/repos/builtin/packages/chapel/fix_chpl_shared_lib_path_2.3.patch b/var/spack/repos/builtin/packages/chapel/fix_chpl_shared_lib_path_2.3.patch index c566c7329f7..97b1899d2c5 100644 --- a/var/spack/repos/builtin/packages/chapel/fix_chpl_shared_lib_path_2.3.patch +++ b/var/spack/repos/builtin/packages/chapel/fix_chpl_shared_lib_path_2.3.patch @@ -1,49 +1,31 @@ diff --git a/tools/chapel-py/setup.py b/tools/chapel-py/setup.py -index 30c2708724..3921143def 100644 +index 30c2708724..0cf576ab25 100644 --- a/tools/chapel-py/setup.py +++ b/tools/chapel-py/setup.py -@@ -47,6 +47,36 @@ host_cxx = str(chpl_variables.get("CHPL_HOST_CXX")) +@@ -47,6 +47,18 @@ host_cxx = str(chpl_variables.get("CHPL_HOST_CXX")) host_bin_subdir = str(chpl_variables.get("CHPL_HOST_BIN_SUBDIR")) chpl_lib_path = os.path.join(chpl_home, "lib", "compiler", host_bin_subdir) -+# For installations using --prefix, the lib final lib path is going to be different -+# figure it out now and write it to the rpath -+chpl_install_lib_path = None -+if os.path.exists(os.path.join(chpl_home, "configured-prefix")): -+ with open(os.path.join(chpl_home, "CMakeLists.txt"), "r") as f: -+ # read CMakeLists.txt to get the CHPL_MAJOR_VERSION and CHPL_MINOR_VERSION -+ # and then construct the path from that -+ chpl_major_version = None -+ chpl_minor_version = None -+ for line in f: -+ if "set(CHPL_MAJOR_VERSION" in line: -+ chpl_major_version = line.split()[1].strip(')') -+ if "set(CHPL_MINOR_VERSION" in line: -+ chpl_minor_version = line.split()[1].strip(')') -+ if chpl_major_version is not None and chpl_minor_version is not None: -+ break -+ assert(chpl_major_version is not None and chpl_minor_version is not None) -+ chpl_version_string = "{}.{}".format(chpl_major_version, chpl_minor_version) -+ chpl_prefix = None -+ with open(os.path.join(chpl_home, "configured-prefix"), "r") as f: -+ chpl_prefix = f.read().strip() -+ assert(chpl_prefix is not None) -+ chpl_install_lib_path = os.path.join( -+ chpl_prefix, -+ "lib", -+ "chapel", -+ chpl_version_string, -+ "compiler" -+ ) -+ ++# For installations using --prefix, the build and final lib paths are going to ++# differ figure out the install location now and write it to the rpath ++chpl_home_utils = os.path.join( ++ chpl_home, "util", "chplenv", "chpl_home_utils.py" ++) ++chpl_install_lib_path = ( ++ subprocess.check_output( ++ ["python", chpl_home_utils, "--configured-install-lib-prefix"], ++ ) ++ .decode(sys.stdout.encoding) ++ .strip() ++) CXXFLAGS = [] if have_llvm and have_llvm != "none": -@@ -68,6 +98,12 @@ LDFLAGS += [ +@@ -68,6 +80,12 @@ LDFLAGS += [ "-lChplFrontendShared", ] -+if chpl_install_lib_path is not None: ++if chpl_install_lib_path != "None": + LDFLAGS += [ + "-L{}".format(chpl_install_lib_path), + "-Wl,-rpath,{}".format(chpl_install_lib_path), @@ -52,3 +34,63 @@ index 30c2708724..3921143def 100644 if str(chpl_variables.get("CHPL_SANITIZE")) == "address": if str(chpl_variables.get("CHPL_HOST_PLATFORM")) == "darwin": sys.exit( +diff --git a/util/chplenv/chpl_home_utils.py b/util/chplenv/chpl_home_utils.py +index 5f09ffed15..4b93849acd 100644 +--- a/util/chplenv/chpl_home_utils.py ++++ b/util/chplenv/chpl_home_utils.py +@@ -54,6 +54,46 @@ install_path_regex = re.compile( + os.path.sep, + os.path.sep)) + ++@memoize ++def get_chpl_configured_install_lib_prefix(): ++ # gets the path to the lib directory for a prefix install, or None if not ++ # a prefix install ++ chpl_home = str(os.getenv("CHPL_HOME")) ++ if os.path.exists(os.path.join(chpl_home, "configured-prefix")): ++ with open(os.path.join(chpl_home, "CMakeLists.txt"), "r") as f: ++ # read CMakeLists.txt to get the CHPL_MAJOR_VERSION and ++ # CHPL_MINOR_VERSION and then construct the path from that ++ chpl_major_version = None ++ chpl_minor_version = None ++ for line in f: ++ if "set(CHPL_MAJOR_VERSION" in line: ++ chpl_major_version = line.split()[1].strip(")") ++ if "set(CHPL_MINOR_VERSION" in line: ++ chpl_minor_version = line.split()[1].strip(")") ++ if ( ++ chpl_major_version is not None ++ and chpl_minor_version is not None ++ ): ++ break ++ assert chpl_major_version is not None and chpl_minor_version is not None ++ chpl_version_string = "{}.{}".format( ++ chpl_major_version, ++ chpl_minor_version, ++ ) ++ chpl_prefix = None ++ with open(os.path.join(chpl_home, "configured-prefix"), "r") as f: ++ chpl_prefix = f.read().strip() ++ # Problems with the configured-prefix file - maybe empty ++ assert chpl_prefix != "" and chpl_prefix is not None ++ return os.path.join( ++ chpl_prefix, ++ "lib", ++ "chapel", ++ chpl_version_string, ++ "compiler", ++ ) ++ return None ++ + @memoize + def get_chpl_version_from_install(): + if get_prefix_install_prefix(): +@@ -189,6 +229,8 @@ def _main(): + ) + parser.add_option('--using-module', action='store_const', + dest='func', const=using_chapel_module) ++ parser.add_option('--configured-install-lib-prefix', action='store_const', ++ dest='func', const=get_chpl_configured_install_lib_prefix) + (options, args) = parser.parse_args() + + if options.func: diff --git a/var/spack/repos/builtin/packages/chapel/package.py b/var/spack/repos/builtin/packages/chapel/package.py index 08bf0d15c7a..832435fa5f2 100644 --- a/var/spack/repos/builtin/packages/chapel/package.py +++ b/var/spack/repos/builtin/packages/chapel/package.py @@ -58,6 +58,7 @@ class Chapel(AutotoolsPackage, CudaPackage, ROCmPackage): version("main", branch="main") + version("2.4.0", sha256="a51a472488290df12d1657db2e7118ab519743094f33650f910d92b54c56f315") version("2.3.0", sha256="0185970388aef1f1fae2a031edf060d5eac4eb6e6b1089e7e3b15a130edd8a31") version("2.2.0", sha256="bb16952a87127028031fd2b56781bea01ab4de7c3466f7b6a378c4d8895754b6") version("2.1.0", sha256="72593c037505dd76e8b5989358b7580a3fdb213051a406adb26a487d26c68c60") @@ -71,9 +72,9 @@ class Chapel(AutotoolsPackage, CudaPackage, ROCmPackage): depends_on("cxx", type="build") # generated patch("fix_spack_cc_wrapper_in_cray_prgenv.patch", when="@2.0.0:") - patch("fix_chpl_shared_lib_path.patch", when="@2.1:2.2 +python-bindings") - patch("fix_chpl_shared_lib_path_2.3.patch", when="@2.2.1: +python-bindings") - patch("fix_chpl_line_length.patch") + patch("fix_chpl_shared_lib_path.patch", when="@2.1.1:2.2 +python-bindings") # PR 26388 + patch("fix_chpl_shared_lib_path_2.3.patch", when="@2.2.1:2.3 +python-bindings") # PR 26388 + patch("fix_chpl_line_length.patch", when="@:2.3.0") # PRs 26357, 26381, 26491 patch("fix_checkChplInstall.patch", when="@:2.3.0") # PR 26317 patch("fix_llvm_include_path_2.3.patch", when="@=2.3.0 llvm=bundled") # PR 26402 @@ -142,7 +143,7 @@ class Chapel(AutotoolsPackage, CudaPackage, ROCmPackage): "curl": "curl", "hdf5": "hdf5+hl~mpi", "libevent": "libevent", - "protobuf": "py-protobuf", + "protobuf": "protobuf", "ssl": "openssl", "yaml": "libyaml@0.1", "zmq": "libzmq", @@ -608,12 +609,9 @@ def install(self, spec, prefix): # if working from a non-versioned release/branch (such as main) if not self.is_versioned_release(): install("CMakeLists.txt", join_path(prefix.share, "chapel")) + install_tree("doc", join_path(prefix.share, "chapel", self._output_version_short, "doc")) install_tree( - "doc", join_path(self.prefix.share, "chapel", self._output_version_short, "doc") - ) - install_tree( - "examples", - join_path(self.prefix.share, "chapel", self._output_version_short, "examples"), + "examples", join_path(prefix.share, "chapel", self._output_version_short, "examples") ) def setup_chpl_platform(self, env): @@ -839,7 +837,7 @@ def _output_version_long(self) -> str: @llnl.util.lang.memoized def _output_version_short(self) -> str: if not self.is_versioned_release(): - return self.get_chpl_version_from_cmakelists()[-2] + return ".".join(self.get_chpl_version_from_cmakelists().split(".")[:-1]) spec_vers_str = str(self.spec.version.up_to(2)) return spec_vers_str