Hi Nelson -
It looks like you are using 2.1. If it were me, I would test the patch by trying it on a clone of Chapel (because it makes it easier to keep track of whether you have patched the sources / what version you have). If you wait a bit (until my PR is merged, later today), you can make a clone with git clone https://github.com/chapel-lang/chapel
and then you can bring that up to date now or in the future with git pull
.
Patching
If you want to try to patch 2.1, you can try that now. Save the following to a file, say patch.txt
:
diff --git a/util/chplenv/chpl_llvm.py b/util/chplenv/chpl_llvm.py
index c29da81c40..7f898b5adf 100755
--- a/util/chplenv/chpl_llvm.py
+++ b/util/chplenv/chpl_llvm.py
@@ -649,7 +649,7 @@ def llvm_enabled():
return False
@memoize
-def get_gcc_prefix():
+def get_gcc_prefix_dir():
gcc_prefix = overrides.get('CHPL_LLVM_GCC_PREFIX', '')
# allow CHPL_LLVM_GCC_PREFIX=none to disable inferring it
@@ -710,6 +710,12 @@ def get_gcc_prefix():
return gcc_prefix
+@memoize
+def get_gcc_install_dir():
+ gcc_dir = overrides.get('CHPL_LLVM_GCC_INSTALL_DIR', '')
+
+ return gcc_dir
+
# The bundled LLVM does not currently know to look in a particular Mac OS X SDK
# so we provide a -isysroot arg to indicate which is used.
@@ -808,9 +814,13 @@ def get_system_llvm_built_sdkroot():
def get_clang_basic_args():
clang_args = [ ]
- gcc_prefix = get_gcc_prefix()
- if gcc_prefix:
- clang_args.append('--gcc-toolchain=' + gcc_prefix)
+ gcc_install_dir = get_gcc_install_dir();
+ if gcc_install_dir:
+ clang_args.append('--gcc-install-dir=' + gcc_install_dir)
+ else:
+ gcc_prefix = get_gcc_prefix_dir()
+ if gcc_prefix:
+ clang_args.append('--gcc-toolchain=' + gcc_prefix)
sysroot_args = get_sysroot_resource_dir_args()
if sysroot_args:
Then, cd
to your chapel-2.1.0
directory and then run patch -p1 < patch.txt
.
Using the patch
To understand what to set CHPL_LLVM_GCC_INSTALL_DIR
to, try a test compile:
echo 'int main() { return 0; }' > hello.cc
clang++ -v hello.cc
This will print out lines along these lines:
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/12
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/13
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/14
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/14
The paths printed here are suitable for use with CHPL_LLVM_GCC_INSTALL_DIR
. Since you want to use GCC 13 (since it is the system default), you should pick that one.
For me, it amounts to doing
export CHPL_LLVM_GCC_INSTALL_DIR=/usr/bin/../lib/gcc/x86_64-linux-gnu/13
You can check if all of this is working by running printchplenv --all
. You should see CHPL_TARGET_CC
/ CHPL_TARGET_CXX
/ CHPL_TARGET_LD
lines that include --gcc-install-dir
options with the path you have selected.
For me:
./util/printchplenv --all
machine info: Linux iris 6.8.0-44-generic #44-Ubuntu SMP PREEMPT_DYNAMIC Tue Aug 13 13:35:26 UTC 2024 x86_64
CHPL_HOME: /home/mppf/chapel-old-versions/chapel-2.1.0
script location: /home/mppf/chapel-old-versions/chapel-2.1.0/util/chplenv
CHPL_HOST_PLATFORM: linux64
CHPL_HOST_COMPILER: gnu
CHPL_HOST_CC: gcc
CHPL_HOST_CXX: g++
CHPL_HOST_ARCH: x86_64
CHPL_TARGET_PLATFORM: linux64
CHPL_TARGET_COMPILER: llvm
CHPL_TARGET_CC: /usr/lib/llvm-18/bin/clang --gcc-install-dir=/usr/bin/../lib/gcc/x86_64-linux-gnu/13
CHPL_TARGET_CXX: /usr/lib/llvm-18/bin/clang++ --gcc-install-dir=/usr/bin/../lib/gcc/x86_64-linux-gnu/13
CHPL_TARGET_LD: /usr/lib/llvm-18/bin/clang++ --gcc-install-dir=/usr/bin/../lib/gcc/x86_64-linux-gnu/13
...