summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
authorHarmen Stoppels <harmenstoppels@gmail.com>2022-05-25 14:42:14 +0200
committerGitHub <noreply@github.com>2022-05-25 14:42:14 +0200
commit0c9370ce722dc3b5f2c349f6d7a9f68466841783 (patch)
treeb06014dfb255707d3a01bccbc0c93062e80f281a /var
parent3620204db6014c079ae7f554e84d4eab75b75e2e (diff)
downloadspack-0c9370ce722dc3b5f2c349f6d7a9f68466841783.tar.gz
spack-0c9370ce722dc3b5f2c349f6d7a9f68466841783.tar.bz2
spack-0c9370ce722dc3b5f2c349f6d7a9f68466841783.tar.xz
spack-0c9370ce722dc3b5f2c349f6d7a9f68466841783.zip
julia: support clang, set llvm NDEBUG correctly (#30800)
Diffstat (limited to 'var')
-rw-r--r--var/spack/repos/builtin/packages/julia/gcc-ifdef.patch25
-rw-r--r--var/spack/repos/builtin/packages/julia/llvm-NDEBUG.patch30
-rw-r--r--var/spack/repos/builtin/packages/julia/package.py9
3 files changed, 64 insertions, 0 deletions
diff --git a/var/spack/repos/builtin/packages/julia/gcc-ifdef.patch b/var/spack/repos/builtin/packages/julia/gcc-ifdef.patch
new file mode 100644
index 0000000000..51ed450b7f
--- /dev/null
+++ b/var/spack/repos/builtin/packages/julia/gcc-ifdef.patch
@@ -0,0 +1,25 @@
+From 3193c8f2596711c1feb8e655ec391050e0e78ed0 Mon Sep 17 00:00:00 2001
+From: Harmen Stoppels <harmenstoppels@gmail.com>
+Date: Mon, 23 May 2022 16:58:23 +0200
+Subject: [PATCH] Guard GCC-specific macros with _COMPILER_GCC_
+
+---
+ src/julia_internal.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/julia_internal.h b/src/julia_internal.h
+index fbded19..32d038b 100644
+--- a/src/julia_internal.h
++++ b/src/julia_internal.h
+@@ -392,7 +392,7 @@ jl_svec_t *jl_perm_symsvec(size_t n, ...);
+
+ // this sizeof(__VA_ARGS__) trick can't be computed until C11, but that only matters to Clang in some situations
+ #if !defined(__clang_analyzer__) && !(defined(JL_ASAN_ENABLED) || defined(JL_TSAN_ENABLED))
+-#ifdef __GNUC__
++#ifdef _COMPILER_GCC_
+ #define jl_perm_symsvec(n, ...) \
+ (jl_perm_symsvec)(__extension__({ \
+ static_assert( \
+--
+2.25.1
+
diff --git a/var/spack/repos/builtin/packages/julia/llvm-NDEBUG.patch b/var/spack/repos/builtin/packages/julia/llvm-NDEBUG.patch
new file mode 100644
index 0000000000..1bdbd728fa
--- /dev/null
+++ b/var/spack/repos/builtin/packages/julia/llvm-NDEBUG.patch
@@ -0,0 +1,30 @@
+From 4ec1970178606127fd8bbffa763f135ca0f12ee3 Mon Sep 17 00:00:00 2001
+From: Harmen Stoppels <harmenstoppels@gmail.com>
+Date: Tue, 24 May 2022 14:03:48 +0200
+Subject: [PATCH] llvm: add NDEBUG when assertion mode is off
+
+`llvm-config --cxxflags` unfortunately does not set `-DNDEBUG`, which
+Julia needs to set correctly when including LLVM header files.
+---
+ src/Makefile | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/src/Makefile b/src/Makefile
+index 1a9af2fa7c..766fd2945f 100644
+--- a/src/Makefile
++++ b/src/Makefile
+@@ -98,6 +98,11 @@ PUBLIC_HEADER_TARGETS := $(addprefix $(build_includedir)/julia/,$(notdir $(PUBLI
+ LLVM_LDFLAGS := $(shell $(LLVM_CONFIG_HOST) --ldflags)
+ LLVM_CXXFLAGS := $(shell $(LLVM_CONFIG_HOST) --cxxflags)
+
++# llvm-config --cxxflags does not return -DNDEBUG
++ifeq ($(shell $(LLVM_CONFIG_HOST) --assertion-mode),OFF)
++LLVM_CXXFLAGS += -DNDEBUG
++endif
++
+ ifeq ($(JULIACODEGEN),LLVM)
+ ifneq ($(USE_SYSTEM_LLVM),0)
+ LLVMLINK += $(LLVM_LDFLAGS) $(shell $(LLVM_CONFIG_HOST) --libs --system-libs)
+--
+2.25.1
+
diff --git a/var/spack/repos/builtin/packages/julia/package.py b/var/spack/repos/builtin/packages/julia/package.py
index d3fbd85c7a..6ef36a421b 100644
--- a/var/spack/repos/builtin/packages/julia/package.py
+++ b/var/spack/repos/builtin/packages/julia/package.py
@@ -130,6 +130,12 @@ class Julia(MakefilePackage):
# only applied to libllvm when it's vendored by julia).
patch('revert-fix-rpath-of-libllvm.patch', when='@1.7.0:1.7')
+ # Allow build with clang.
+ patch('gcc-ifdef.patch', when='@1.7.0:1.7')
+
+ # Make sure Julia sets -DNDEBUG when including LLVM header files.
+ patch('llvm-NDEBUG.patch', when='@1.7.0:1.7')
+
def patch(self):
# The system-libwhich-libblastrampoline.patch causes a rebuild of docs as it
# touches the main Makefile, so we reset the a/m-time to doc/_build's.
@@ -215,6 +221,9 @@ class Julia(MakefilePackage):
'1' if spec.variants['precompile'].value else '0'),
]
+ options.append('USEGCC:={}'.format('1' if '%gcc' in spec else '0'))
+ options.append('USECLANG:={}'.format('1' if '%clang' in spec else '0'))
+
# libm or openlibm?
if spec.variants['openlibm'].value:
options.append('USE_SYSTEM_LIBM=0')