summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
authorTom Scogland <scogland1@llnl.gov>2024-11-18 17:39:16 -0500
committerGitHub <noreply@github.com>2024-11-18 14:39:16 -0800
commit44225caadeac9f4c9dc03236a1f50650cf5c5ea3 (patch)
tree6450e048ee96274b58b12ba76bad8da2f2b74f5e /var
parent8d325d3e3071319a3bbf89bfee08e07b67bb447c (diff)
downloadspack-44225caadeac9f4c9dc03236a1f50650cf5c5ea3.tar.gz
spack-44225caadeac9f4c9dc03236a1f50650cf5c5ea3.tar.bz2
spack-44225caadeac9f4c9dc03236a1f50650cf5c5ea3.tar.xz
spack-44225caadeac9f4c9dc03236a1f50650cf5c5ea3.zip
llvm: fix sysroot and build on darwin (#47336)
The default build of clang on darwin couldn't actually build anything because of a lack of a sysroot built in. Also several compilation errors finding the system libc++ cropped up, much like those in GCC, and have been fixed.
Diffstat (limited to 'var')
-rw-r--r--var/spack/repos/builtin/packages/llvm/package.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/var/spack/repos/builtin/packages/llvm/package.py b/var/spack/repos/builtin/packages/llvm/package.py
index 81ee8b52c0..ae0db24190 100644
--- a/var/spack/repos/builtin/packages/llvm/package.py
+++ b/var/spack/repos/builtin/packages/llvm/package.py
@@ -12,6 +12,7 @@ from llnl.util.lang import classproperty
import spack.compilers
from spack.build_systems.cmake import get_cmake_prefix_path
+from spack.operating_systems.mac_os import macos_sdk_path
from spack.package import *
from spack.package_base import PackageBase
@@ -821,6 +822,10 @@ class Llvm(CMakePackage, CudaPackage, LlvmDetection, CompilerPackage):
os.symlink(bin, sym)
env.prepend_path("PATH", self.stage.path)
+ if self.spec.satisfies("platform=darwin"):
+ # set the SDKROOT so the bootstrap compiler finds its C++ headers
+ env.set("SDKROOT", macos_sdk_path())
+
def setup_run_environment(self, env):
if self.spec.satisfies("+clang"):
env.set("CC", join_path(self.spec.prefix.bin, "clang"))
@@ -1017,7 +1022,20 @@ class Llvm(CMakePackage, CudaPackage, LlvmDetection, CompilerPackage):
# Enable building with CLT [and not require full Xcode]
# https://github.com/llvm/llvm-project/issues/57037
if self.spec.satisfies("@15.0.0: platform=darwin"):
- cmake_args.append(define("BUILTINS_CMAKE_ARGS", "-DCOMPILER_RT_ENABLE_IOS=OFF"))
+ cmake_args.append(
+ define(
+ "BUILTINS_CMAKE_ARGS",
+ ";".join(
+ [f"-DCOMPILER_RT_ENABLE_{os}=OFF" for os in ("IOS", "WATCHOS", "TVOS")]
+ ),
+ )
+ )
+
+ if self.spec.satisfies("platform=darwin"):
+ cmake_args.append(define("LLVM_ENABLE_LIBCXX", True))
+ cmake_args.append(define("DEFAULT_SYSROOT", macos_sdk_path()))
+ # without this libc++ headers are not fond during compiler-rt build
+ cmake_args.append(define("LLVM_BUILD_EXTERNAL_COMPILER_RT", True))
# Semicolon seperated list of projects to enable
cmake_args.append(define("LLVM_ENABLE_PROJECTS", projects))