summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorLiliana Marie Prikler <liliana.prikler@gmail.com>2024-06-29 08:53:54 +0200
committerLiliana Marie Prikler <liliana.prikler@gmail.com>2024-07-07 08:04:47 +0200
commit3ed077e92cebe4286eeecf372722690eb5c9a8aa (patch)
treee40b319d6d6c47c0f5e1c1e275e766dcb7bb403c /gnu
parent8546ca946e617c32ef3bb60947e368f7d038090c (diff)
gnu: clasp: Prevent ID clashes in dependent packages.
Clasp uses an interesting CRTP pattern to insert statically (i.e. compile-time) generated numeric IDs into global fields. However, these templates are instantiated once per shared library---thus, whenever a library is linked, new IDs are generated, and the original intent (safely type-casting objects across libraries) is lost. To help the linker out, we make sure that these IDs are only instantiated in clasp and not when building other libraries. * gnu/packages/patches/clasp-hide-event-ids.patch: New file. * gnu/local.mk (dist_patch_DATA): Register it here. * gnu/packages/clasp.scm (source)[patches]: Add it here. (clingo)[#:phases]: Drop ‘skip-failing-tests’. (python-clorm)[#:phases]<fix-breaking-tests>: Adjust accordingly. (python-clintest): Drop arguments.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/local.mk1
-rw-r--r--gnu/packages/patches/clasp-hide-event-ids.patch41
-rw-r--r--gnu/packages/potassco.scm31
3 files changed, 45 insertions, 28 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index 7db556fa560..329eaf9358c 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1064,6 +1064,7 @@ dist_patch_DATA = \
1064 %D%/packages/patches/clang-runtime-3.7-fix-build-with-python3.patch \ 1064 %D%/packages/patches/clang-runtime-3.7-fix-build-with-python3.patch \
1065 %D%/packages/patches/clang-runtime-3.9-libsanitizer-mode-field.patch \ 1065 %D%/packages/patches/clang-runtime-3.9-libsanitizer-mode-field.patch \
1066 %D%/packages/patches/clang-runtime-3.8-libsanitizer-mode-field.patch \ 1066 %D%/packages/patches/clang-runtime-3.8-libsanitizer-mode-field.patch \
1067 %D%/packages/patches/clasp-hide-event-ids.patch \
1067 %D%/packages/patches/classpath-aarch64-support.patch \ 1068 %D%/packages/patches/classpath-aarch64-support.patch \
1068 %D%/packages/patches/classpath-miscompilation.patch \ 1069 %D%/packages/patches/classpath-miscompilation.patch \
1069 %D%/packages/patches/cling-use-shared-library.patch \ 1070 %D%/packages/patches/cling-use-shared-library.patch \
diff --git a/gnu/packages/patches/clasp-hide-event-ids.patch b/gnu/packages/patches/clasp-hide-event-ids.patch
new file mode 100644
index 00000000000..9587f9ff3f4
--- /dev/null
+++ b/gnu/packages/patches/clasp-hide-event-ids.patch
@@ -0,0 +1,41 @@
1From a4c4e4f3c410834c3e56f644841f5bcbb084225c Mon Sep 17 00:00:00 2001
2From: Liliana Marie Prikler <liliana.prikler@ist.tugraz.at>
3Date: Fri, 28 Jun 2024 11:15:16 +0200
4Subject: [PATCH] clasp: Hide Event_t<T>::id_s.
5
6This patch helps build clingo with non-local clasp while keeping the
7event system working as intended.
8---
9 clasp/util/misc_types.h | 2 ++
10 src/CMakeLists.txt | 2 +-
11 2 files changed, 3 insertions(+), 1 deletion(-)
12
13diff --git a/clasp/util/misc_types.h b/clasp/util/misc_types.h
14index 3677873..09c2075 100644
15--- a/clasp/util/misc_types.h
16+++ b/clasp/util/misc_types.h
17@@ -432,7 +432,9 @@ struct Event_t : Event {
18 Event_t(Subsystem sys, Verbosity verb) : Event(sys, id_s, verb) {}
19 static const uint32 id_s;
20 };
21+#if _BUILDING_CLASP_
22 template <class T> const uint32 Event_t<T>::id_s = Event::nextId();
23+#endif
24
25 template <class ToType, class EvType> const ToType* event_cast(const EvType& ev) { return ev.id == ToType::id_s ? static_cast<const ToType*>(&ev) : 0; }
26
27diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
28index 8439d12..4f55990 100644
29--- a/src/CMakeLists.txt
30+++ b/src/CMakeLists.txt
31@@ -123,6 +123,7 @@ source_group("${ide_header}\\mt" FILES ${header_mt})
32 endif()
33
34 add_library(libclasp ${header} ${header_util} ${header_cli} ${header_mt} ${src})
35+target_compile_definitions(libclasp PRIVATE _BUILDING_CLASP_)
36 if (CLASP_BUILD_WITH_THREADS)
37 target_link_libraries(libclasp PUBLIC Threads::Threads)
38 target_compile_options(libclasp PRIVATE
39--
402.45.1
41
diff --git a/gnu/packages/potassco.scm b/gnu/packages/potassco.scm
index b7cfca2eecf..5432fc10c36 100644
--- a/gnu/packages/potassco.scm
+++ b/gnu/packages/potassco.scm
@@ -112,6 +112,7 @@ between aspif and smodels format or to a human-readable text format.")
112 (url "https://github.com/potassco/clasp") 112 (url "https://github.com/potassco/clasp")
113 (commit (string-append "v" version)))) 113 (commit (string-append "v" version))))
114 (file-name (git-file-name name version)) 114 (file-name (git-file-name name version))
115 (patches (search-patches "clasp-hide-event-ids.patch"))
115 (sha256 116 (sha256
116 (base32 117 (base32
117 "0qap7rar8a5mkqz28n2hnvr4cfv5x0rh4zs3wdp919dw4d034chr")))) 118 "0qap7rar8a5mkqz28n2hnvr4cfv5x0rh4zs3wdp919dw4d034chr"))))
@@ -200,22 +201,7 @@ satisfiability checking (SAT).")
200 (substitute* "cmake/ClingoConfig.cmake.in" 201 (substitute* "cmake/ClingoConfig.cmake.in"
201 (("find_package\\(Clasp") "find_package(clasp")) 202 (("find_package\\(Clasp") "find_package(clasp"))
202 (rename-file "cmake/ClingoConfig.cmake.in" 203 (rename-file "cmake/ClingoConfig.cmake.in"
203 "cmake/clingo-config.cmake.in"))) 204 "cmake/clingo-config.cmake.in"))))))
204 (add-after 'unpack 'skip-failing-tests
205 (lambda _
206 (with-directory-excursion "libclingo/tests"
207 (substitute* "CMakeLists.txt"
208 (("COMMAND test_clingo" all)
209 (string-append all
210 " -f "
211 "\"${CMAKE_CURRENT_SOURCE_DIR}/good.txt\"")))
212 (call-with-output-file "good.txt"
213 (lambda (port)
214 (for-each (lambda (test) (format port "~s~%" test))
215 '("parse-ast-v2" "add-ast-v2" "build-ast-v2"
216 "unpool-ast-v2" "parse_term"
217 "propagator" "propgator-sequence-mining"
218 "symbol" "visitor"))))))))))
219 (inputs (list catch2-3 clasp libpotassco)) 205 (inputs (list catch2-3 clasp libpotassco))
220 (native-inputs (list bison re2c 206 (native-inputs (list bison re2c
221 mpark-variant 207 mpark-variant
@@ -465,10 +451,7 @@ directly from the python command line.")))
465 (lambda _ 451 (lambda _
466 ;; noclingo tests rely on this being set 452 ;; noclingo tests rely on this being set
467 (setenv "CLORM_NOCLINGO" "1") 453 (setenv "CLORM_NOCLINGO" "1")
468 (delete-file "tests/test_mypy_query.py") 454 (delete-file "tests/test_mypy_query.py"))))))
469 (substitute* "tests/test_clingo.py"
470 (("self\\.assertTrue\\(os_called\\)" all)
471 (string-append "# " all))))))))
472 (propagated-inputs (list python-clingo)) 455 (propagated-inputs (list python-clingo))
473 (native-inputs (list python-typing-extensions)) 456 (native-inputs (list python-typing-extensions))
474 (home-page "https://potassco.org") 457 (home-page "https://potassco.org")
@@ -627,14 +610,6 @@ which allows user interfaces to be specified entirely as a logic program.")
627 (base32 610 (base32
628 "0xzbby9ram55h87ykm652kgm45b8rlhbjc8gjkz308h1jnjllmmy")))) 611 "0xzbby9ram55h87ykm652kgm45b8rlhbjc8gjkz308h1jnjllmmy"))))
629 (build-system pyproject-build-system) 612 (build-system pyproject-build-system)
630 (arguments
631 (list #:phases
632 #~(modify-phases %standard-phases
633 (add-after 'unpack 'delete-failing-tests
634 (lambda _
635 ;; XXX: Clingo statistics are broken in dependencies already.
636 (for-each delete-file '("tests/test_solver.py"
637 "tests/test_test.py")))))))
638 (inputs (list python-clingo)) 613 (inputs (list python-clingo))
639 (native-inputs (list python-pytest)) 614 (native-inputs (list python-pytest))
640 (home-page "https://potassco.org/clintest/") 615 (home-page "https://potassco.org/clintest/")