From 3ed077e92cebe4286eeecf372722690eb5c9a8aa Mon Sep 17 00:00:00 2001 From: Liliana Marie Prikler Date: Sat, 29 Jun 2024 08:53:54 +0200 Subject: gnu: clasp: Prevent ID clashes in dependent packages. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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]: Adjust accordingly. (python-clintest): Drop arguments. --- gnu/local.mk | 1 + gnu/packages/patches/clasp-hide-event-ids.patch | 41 +++++++++++++++++++++++++ gnu/packages/potassco.scm | 31 ++----------------- 3 files changed, 45 insertions(+), 28 deletions(-) create mode 100644 gnu/packages/patches/clasp-hide-event-ids.patch diff --git a/gnu/local.mk b/gnu/local.mk index 7db556fa56..329eaf9358 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1064,6 +1064,7 @@ dist_patch_DATA = \ %D%/packages/patches/clang-runtime-3.7-fix-build-with-python3.patch \ %D%/packages/patches/clang-runtime-3.9-libsanitizer-mode-field.patch \ %D%/packages/patches/clang-runtime-3.8-libsanitizer-mode-field.patch \ + %D%/packages/patches/clasp-hide-event-ids.patch \ %D%/packages/patches/classpath-aarch64-support.patch \ %D%/packages/patches/classpath-miscompilation.patch \ %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 0000000000..9587f9ff3f --- /dev/null +++ b/gnu/packages/patches/clasp-hide-event-ids.patch @@ -0,0 +1,41 @@ +From a4c4e4f3c410834c3e56f644841f5bcbb084225c Mon Sep 17 00:00:00 2001 +From: Liliana Marie Prikler +Date: Fri, 28 Jun 2024 11:15:16 +0200 +Subject: [PATCH] clasp: Hide Event_t::id_s. + +This patch helps build clingo with non-local clasp while keeping the +event system working as intended. +--- + clasp/util/misc_types.h | 2 ++ + src/CMakeLists.txt | 2 +- + 2 files changed, 3 insertions(+), 1 deletion(-) + +diff --git a/clasp/util/misc_types.h b/clasp/util/misc_types.h +index 3677873..09c2075 100644 +--- a/clasp/util/misc_types.h ++++ b/clasp/util/misc_types.h +@@ -432,7 +432,9 @@ struct Event_t : Event { + Event_t(Subsystem sys, Verbosity verb) : Event(sys, id_s, verb) {} + static const uint32 id_s; + }; ++#if _BUILDING_CLASP_ + template const uint32 Event_t::id_s = Event::nextId(); ++#endif + + template const ToType* event_cast(const EvType& ev) { return ev.id == ToType::id_s ? static_cast(&ev) : 0; } + +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 8439d12..4f55990 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -123,6 +123,7 @@ source_group("${ide_header}\\mt" FILES ${header_mt}) + endif() + + add_library(libclasp ${header} ${header_util} ${header_cli} ${header_mt} ${src}) ++target_compile_definitions(libclasp PRIVATE _BUILDING_CLASP_) + if (CLASP_BUILD_WITH_THREADS) + target_link_libraries(libclasp PUBLIC Threads::Threads) + target_compile_options(libclasp PRIVATE +-- +2.45.1 + diff --git a/gnu/packages/potassco.scm b/gnu/packages/potassco.scm index b7cfca2eec..5432fc10c3 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.") (url "https://github.com/potassco/clasp") (commit (string-append "v" version)))) (file-name (git-file-name name version)) + (patches (search-patches "clasp-hide-event-ids.patch")) (sha256 (base32 "0qap7rar8a5mkqz28n2hnvr4cfv5x0rh4zs3wdp919dw4d034chr")))) @@ -200,22 +201,7 @@ satisfiability checking (SAT).") (substitute* "cmake/ClingoConfig.cmake.in" (("find_package\\(Clasp") "find_package(clasp")) (rename-file "cmake/ClingoConfig.cmake.in" - "cmake/clingo-config.cmake.in"))) - (add-after 'unpack 'skip-failing-tests - (lambda _ - (with-directory-excursion "libclingo/tests" - (substitute* "CMakeLists.txt" - (("COMMAND test_clingo" all) - (string-append all - " -f " - "\"${CMAKE_CURRENT_SOURCE_DIR}/good.txt\""))) - (call-with-output-file "good.txt" - (lambda (port) - (for-each (lambda (test) (format port "~s~%" test)) - '("parse-ast-v2" "add-ast-v2" "build-ast-v2" - "unpool-ast-v2" "parse_term" - "propagator" "propgator-sequence-mining" - "symbol" "visitor")))))))))) + "cmake/clingo-config.cmake.in")))))) (inputs (list catch2-3 clasp libpotassco)) (native-inputs (list bison re2c mpark-variant @@ -465,10 +451,7 @@ directly from the python command line."))) (lambda _ ;; noclingo tests rely on this being set (setenv "CLORM_NOCLINGO" "1") - (delete-file "tests/test_mypy_query.py") - (substitute* "tests/test_clingo.py" - (("self\\.assertTrue\\(os_called\\)" all) - (string-append "# " all)))))))) + (delete-file "tests/test_mypy_query.py")))))) (propagated-inputs (list python-clingo)) (native-inputs (list python-typing-extensions)) (home-page "https://potassco.org") @@ -627,14 +610,6 @@ which allows user interfaces to be specified entirely as a logic program.") (base32 "0xzbby9ram55h87ykm652kgm45b8rlhbjc8gjkz308h1jnjllmmy")))) (build-system pyproject-build-system) - (arguments - (list #:phases - #~(modify-phases %standard-phases - (add-after 'unpack 'delete-failing-tests - (lambda _ - ;; XXX: Clingo statistics are broken in dependencies already. - (for-each delete-file '("tests/test_solver.py" - "tests/test_test.py"))))))) (inputs (list python-clingo)) (native-inputs (list python-pytest)) (home-page "https://potassco.org/clintest/") -- cgit v1.2.3