aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (test-debug-link)
  #:use-module (guix elf)
  #:use-module (guix build utils)
  #:use-module (guix build debug-link)
  #:use-module (guix gexp)
  #:use-module (guix store)
  #:use-module (guix tests)
  #:use-module (guix monads)
  #:use-module (guix derivations)
  #:use-module (gnu packages bootstrap)
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-26)
  #:use-module (srfi srfi-64)
  #:use-module (rnrs io ports)
  #:use-module (ice-9 match))

(define %guile-executable
  (match (false-if-exception (readlink "/proc/self/exe"))
    ((? string? program)
     (and (file-exists? program) (elf-file? program)
          program))
    (_
     #f)))

(define read-elf
  (compose parse-elf get-bytevector-all))


(test-begin "debug-link")

(unless %guile-executable (test-skip 1))
(test-assert "elf-debuglink"
  (let ((elf (call-with-input-file %guile-executable read-elf)))
    (match (call-with-values (lambda () (elf-debuglink elf)) list)
      ((#f #f)                                    ;no '.gnu_debuglink' section
       (pk 'no-debuglink #t))
      (((? string? file) (? integer? crc))
       (string-suffix? ".debug" file)))))

;; Since we need %BOOTSTRAP-GCC and co., we have to skip the following tests
;; when networking is unreachable because we'd fail to download it.
(unless (network-reachable?) (test-skip 1))
(test-assertm "elf-debuglink"
  ;; Check whether we can compute the CRC just like objcopy, and whether we
  ;; can retrieve it.
  (let* ((code (plain-file "test.c" "int main () { return 42; }"))
         (exp  (with-imported-modules '((guix build utils)
                                        (guix build debug-link)
                                        (guix elf))
                 #~(begin
                     (use-modules (guix build utils)
                                  (guix build debug-link)
                                  (guix elf)
                                  (rnrs io ports))

                     (define read-elf
                       (compose parse-elf get-bytevector-all))

                     (setenv "PATH" (string-join '(#$%bootstrap-gcc
                                                   #$%bootstrap-binutils)
                                                 "/bin:" 'suffix))
                     (invoke "gcc" "-O0" "-g" #$code "-o" "exe")
                     (copy-file "exe" "exe.debug")
                     (invoke "strip" "--only-keep-debug" "exe.debug")
                     (invoke "strip" "--strip-debug" "exe")
                     (invoke "objcopy" "--add-gnu-debuglink=exe.debug"
                             "exe")
                     (call-with-values (lambda ()
                                         (elf-debuglink
                                          (call-with-input-file "exe"
                                            read-elf)))
                       (lambda (file crc)
                         (call-with-output-file #$output
                           (lambda (port)
                             (let ((expected (call-with-input-file "exe.debug"
                                               debuglink-crc32)))
                               (write (list file (= crc expected))
                                      port))))))))))
    (mlet* %store-monad ((drv (gexp->derivation "debuglink" exp))
                         (x   (built-derivations (list drv))))
      (call-with-input-file (derivation->output-path drv)
        (lambda (port)
          (return (match (read port)
                    (("exe.debug" #t) #t)
                    (x                (pk 'fail x #f)))))))))

(unless (network-reachable?) (test-skip 1))
(test-assertm "set-debuglink-crc"
  ;; Check whether 'set-debuglink-crc' successfully updates the CRC.
  (let* ((code  (plain-file "test.c" "int main () { return 42; }"))
         (debug (plain-file "exe.debug" "a"))
         (exp   (with-imported-modules '((guix build utils)
                                         (guix build debug-link)
                                         (guix elf))
                  #~(begin
                      (use-modules (guix build utils)
                                   (guix build debug-link)
                                   (guix elf)
                                   (rnrs io ports))

                      (define read-elf
                        (compose parse-elf get-bytevector-all))

                      (setenv "PATH" (string-join '(#$%bootstrap-gcc
                                                    #$%bootstrap-binutils)
                                                  "/bin:" 'suffix))
                      (invoke "gcc" "-O0" "-g" #$code "-o" "exe")
                      (copy-file "exe" "exe.debug")
                      (invoke "strip" "--only-keep-debug" "exe.debug")
                      (invoke "strip" "--strip-debug" "exe")
                      (invoke "objcopy" "--add-gnu-debuglink=exe.debug"
                              "exe")
                      (set-debuglink-crc "exe" #$debug)
                      (call-with-values (lambda ()
                                          (elf-debuglink
                                           (call-with-input-file "exe"
                                             read-elf)))
                        (lambda (file crc)
                          (call-with-output-file #$output
                            (lambda (port)
                              (write (list file crc) port)))))))))
    (mlet* %store-monad ((drv (gexp->derivation "debuglink" exp))
                         (x   (built-derivations (list drv))))
      (call-with-input-file (derivation->output-path drv)
        (lambda (port)
          (return (match (read port)
                    (("exe.debug" crc)
                     (= crc (debuglink-crc32 (open-input-string "a"))))
                    (x
                     (pk 'fail x #f)))))))))

(test-end "debug-link")
ename Item>
- inline py::object GET_ITEM_BORROW(const py::handle& container, const Item& item) {
-@@ -171,11 +175,13 @@ inline py::object GET_ITEM_BORROW<py::tuple>(const py::handle& container, const
- return py::reinterpret_borrow<py::object>(
- PyTuple_GET_ITEM(container.ptr(), py::ssize_t_cast(item)));
- }
-+#if __WORDSIZE != 32
- template <>
- inline py::object GET_ITEM_BORROW<py::tuple>(const py::handle& container, const int& item) {
- return py::reinterpret_borrow<py::object>(
- PyTuple_GET_ITEM(container.ptr(), py::ssize_t_cast(item)));
- }
-+#endif
- template <>
- inline py::object GET_ITEM_BORROW<py::list>(const py::handle& container, const ssize_t& item) {
- return py::reinterpret_borrow<py::object>(PyList_GET_ITEM(container.ptr(), item));
-@@ -185,11 +191,13 @@ inline py::object GET_ITEM_BORROW<py::list>(const py::handle& container, const s
- return py::reinterpret_borrow<py::object>(
- PyList_GET_ITEM(container.ptr(), py::ssize_t_cast(item)));
- }
-+#if __WORDSIZE != 32
- template <>
- inline py::object GET_ITEM_BORROW<py::list>(const py::handle& container, const int& item) {
- return py::reinterpret_borrow<py::object>(
- PyList_GET_ITEM(container.ptr(), py::ssize_t_cast(item)));
- }
-+#endif
-
- template <typename Container, typename Item>
- inline py::object GET_ITEM_STEAL(const py::handle& container, const Item& item) {
-@@ -204,11 +212,13 @@ inline py::object GET_ITEM_STEAL<py::tuple>(const py::handle& container, const s
- return py::reinterpret_steal<py::object>(
- PyTuple_GET_ITEM(container.ptr(), py::ssize_t_cast(item)));
- }
-+#if __WORDSIZE != 32
- template <>
- inline py::object GET_ITEM_STEAL<py::tuple>(const py::handle& container, const int& item) {
- return py::reinterpret_steal<py::object>(
- PyTuple_GET_ITEM(container.ptr(), py::ssize_t_cast(item)));
- }
-+#endif
- template <>
- inline py::object GET_ITEM_STEAL<py::list>(const py::handle& container, const ssize_t& item) {
- return py::reinterpret_steal<py::object>(PyList_GET_ITEM(container.ptr(), item));
-@@ -218,11 +228,13 @@ inline py::object GET_ITEM_STEAL<py::list>(const py::handle& container, const si
- return py::reinterpret_steal<py::object>(
- PyList_GET_ITEM(container.ptr(), py::ssize_t_cast(item)));
- }
-+#if __WORDSIZE != 32
- template <>
- inline py::object GET_ITEM_STEAL<py::list>(const py::handle& container, const int& item) {
- return py::reinterpret_steal<py::object>(
- PyList_GET_ITEM(container.ptr(), py::ssize_t_cast(item)));
- }
-+#endif
-
- template <typename Container, typename Item>
- inline void SET_ITEM(const py::handle& container, const Item& item, const py::handle& value) {
-@@ -240,12 +252,14 @@ inline void SET_ITEM<py::tuple>(const py::handle& container,
- const py::handle& value) {
- PyTuple_SET_ITEM(container.ptr(), py::ssize_t_cast(item), value.inc_ref().ptr());
- }
-+#if __WORDSIZE != 32
- template <>
- inline void SET_ITEM<py::tuple>(const py::handle& container,
- const int& item,
- const py::handle& value) {
- PyTuple_SET_ITEM(container.ptr(), py::ssize_t_cast(item), value.inc_ref().ptr());
- }
-+#endif
- template <>
- inline void SET_ITEM<py::list>(const py::handle& container,
- const ssize_t& item,
-@@ -258,12 +272,14 @@ inline void SET_ITEM<py::list>(const py::handle& container,
- const py::handle& value) {
- PyList_SET_ITEM(container.ptr(), py::ssize_t_cast(item), value.inc_ref().ptr());
- }
-+#if __WORDSIZE != 32
- template <>
- inline void SET_ITEM<py::list>(const py::handle& container,
- const int& item,
- const py::handle& value) {
- PyList_SET_ITEM(container.ptr(), py::ssize_t_cast(item), value.inc_ref().ptr());
- }
-+#endif
-
- template <typename PyType>
- inline void AssertExact(const py::handle& object) {
diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index 11113ea00d..29ebcec153 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -13248,7 +13248,7 @@ without using the configuration machinery.")
(define-public python-optree
(package
(name "python-optree")
- (version "0.11.0")
+ (version "0.14.0")
(source
(origin
(method git-fetch)
@@ -13258,21 +13258,21 @@ without using the configuration machinery.")
(file-name (git-file-name name version))
(sha256
(base32
- "0sk5lm1xyxi7z0yjckip77qvbidyb7i1znmn9fz96q74hl9ffyan"))
- (patches (search-patches "python-optree-fix-32-bit.patch"))))
+ "17zph1jgzk0zaanj7057qj8x5cml8j66ip0xmlbwmq4396hmdlbs"))))
(build-system pyproject-build-system)
(arguments
(list
#:test-flags
- ;; This test fails due to a circular import
- ''("-k" "not test_treespec_pickle_missing_registration")))
+ ;; These tests fails due to a circular import
+ '`("-k" ,(string-append "not test_treespec_pickle_missing_registration"
+ " and not test_import_no_warnings"))))
(propagated-inputs (list python-typing-extensions))
(native-inputs
(list python-pytest
python-setuptools
python-wheel
- cmake
- pybind11))
+ cmake-minimal
+ pybind11-2.13))
(home-page "https://github.com/metaopt/optree")
(synopsis "Optimized PyTree Utilities")
(description "This package contains operations on PyTrees (a tree made of