Skip to content

Commit

Permalink
determine rpath for chapel-py shared lib when using --prefix
Browse files Browse the repository at this point in the history
Signed-off-by: Ahmad Rezaii <[email protected]>
  • Loading branch information
arezaii committed Dec 10, 2024
1 parent c534099 commit bcedc08
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tools/chapel-py/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,36 @@

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"
)


CXXFLAGS = []
if have_llvm and have_llvm != "none":
Expand All @@ -68,6 +98,12 @@
"-lChplFrontendShared",
]

if chpl_install_lib_path is not 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":
sys.exit(
Expand Down

0 comments on commit bcedc08

Please sign in to comment.