Branch: refs/heads/main
Revision: 4112d47eae48cbb9b8dbdcf934f4e7f5822f3835
Author: mppf
Link: Fix problem running 'make' with CC and CXX set by mppf · Pull Request #21985 · chapel-lang/chapel · GitHub
Log Message:
Fix problem running 'make' with CC and CXX set (#21985)
This PR is intended to resolve the build issue discussed in
When building Chapel with something like CC=clang CXX=clang++ make,
several things were going wrong:
- There was an error from printchplenv
- That error did not stop the build & later there were linker errors
Why was there an error at all? it was this sequence of events:
- the Makefile invoking cmake set
CMAKE_C_COMPILERand
CMAKE_CXX_COMPILERbased on CHPL_MAKE_HOST_CC etc to communicate this
setting to cmake (so cmake does not infer it based upon CC or use its
favorite compiler) - the cmake script invoked printchplenv while setting
CHPL_HOST_CCand
CHPL_HOST_CXXin the environment (so that printchplenv will be
considering the same configuration that cmake is using) - printchplenv supports inferring
CHPL_HOST_COMPILERfromCCand
CXXbut not fromCHPL_HOST_CCandCHPL_HOST_CXX. So, it failed,
because the default valueCHPL_HOST_COMPILER=gnuwas inconsistent with
CHPL_HOST_CC=clang/CHPL_HOST_CXX=clang++.
This PR:
- It adjusts the cmake script to check for the return code from
printchplenv and fail with an error if it is nonzero. - Enables inferring
CHPL_HOST_COMPILERfromCHPL_HOST_CC/
CHPL_HOST_CXX - Enables inferring
CHPL_TARGET_COMPILERfromCHPL_TARGET_CC/
CHPL_TARGET_CXX(but this does not happen when LLVM would be the
default or when using a PrgEnv).
An alternative solution to the issue of inferring CHPL_HOST_COMPILER
would be to pass it as an environment variable from make to cmake
and from cmake to printchplenv.
Reviewed by @arezaii - thanks!
- verified that
CC=clang-14 CXX=clang++-14 makeworks on an Ubuntu
22.10 system where it did not work before - full local testing
Diff:
M CMakeLists.txt
M util/chplenv/chpl_compiler.py
https://github.com/chapel-lang/chapel/pull/21985.diff