New Issue: [Bug]: 'make install' installs a 'mason' with incorrect paths

25356, "jabraham17", "[Bug]: 'make install' installs a 'mason' with incorrect paths", "2024-06-24T23:31:08Z"

When a chapel program is compiled certain paths are embedded into the resulting binary. Some of these are done by the Chapel compiler (e.g., ChplConfig.CHPL_HOME) and some are done by the system linker (e.g., the path to the runtime library is linked into the executable with -Wl,-rpath). However, this causes issues if the chapel program is moved (like when using make install).

In particular, mason hits this issue with make install. The following series of events cause a problem

git clone chapel
cd chapel
./configure --prefix=/usr
make all # build chapel compiler
make mason # build mason, this uses the local chapel
make install # install chpl and mason to /usr
cd ..
# I built Chapel and installed it, I can delete the source tree
rm -rf chapel

/usr/bin/mason # error, can't find library

This is caused by the fact that mason is built using the chpl compiler in CHPL_SOURCE/bin/CHPL_BIN_SUBDIR, not /usr/bin/chpl.

This is currently worked around when build chapel packages by using util/packaging/common/fixpaths.py to rewrite the RUNPATH/RPATH in the mason binary after installing it. However, it does not fix the usage of ChplConfig.CHPL_HOME in mason, which means that mason test will not work in an installed mason. And this is currently broken in the Linux OS packages.

I think one way to fix this is to have the following workflow

./configure --prefix=/usr
make all
make install
CHPL_USE_CHPL=/usr/bin/chpl make mason
make install

This is not the most user-friendly fix and is error prone (users still can create a broken mason by doing make all mason && make install).