From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id GKxTEPxL3V7DWwAA0tVLHw (envelope-from ) for ; Sun, 07 Jun 2020 20:20:12 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id INIfDPxL3V62LwAAbx9fmQ (envelope-from ) for ; Sun, 07 Jun 2020 20:20:12 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9DC889407C7 for ; Sun, 7 Jun 2020 20:20:11 +0000 (UTC) Received: from localhost ([::1]:34828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ji1m4-0006PE-Jz for larch@yhetil.org; Sun, 07 Jun 2020 16:20:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ji1ly-0006Oz-Bh for guix-patches@gnu.org; Sun, 07 Jun 2020 16:20:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:43481) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ji1ly-0002Zw-2U for guix-patches@gnu.org; Sun, 07 Jun 2020 16:20:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ji1lx-00044v-Ux for guix-patches@gnu.org; Sun, 07 Jun 2020 16:20:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#40267] [PATCH v2 1/2] gnu: Add unicorn. References: <20200328005052.22846-1-kuba@kadziolka.net> In-Reply-To: <20200328005052.22846-1-kuba@kadziolka.net> Resent-From: Jakub =?UTF-8?Q?K=C4=85dzio=C5=82ka?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 07 Jun 2020 20:20:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40267 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 40267@debbugs.gnu.org Cc: leo@famulari.name Received: via spool by 40267-submit@debbugs.gnu.org id=B40267.159156119015641 (code B ref 40267); Sun, 07 Jun 2020 20:20:01 +0000 Received: (at 40267) by debbugs.gnu.org; 7 Jun 2020 20:19:50 +0000 Received: from localhost ([127.0.0.1]:55025 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ji1ll-00044D-OC for submit@debbugs.gnu.org; Sun, 07 Jun 2020 16:19:50 -0400 Received: from pat.zlotemysli.pl ([37.59.186.212]:55150) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ji1lk-000443-7e for 40267@debbugs.gnu.org; Sun, 07 Jun 2020 16:19:48 -0400 Received: (qmail 15304 invoked by uid 1009); 7 Jun 2020 22:19:46 +0200 Received: from 188.123.215.55 (kuba@kadziolka.net@188.123.215.55) by pat.zlotemysli.pl (envelope-from , uid 1002) with qmail-scanner-2.08st (clamdscan: 0.98.6/25835. spamassassin: 3.4.0. perlscan: 2.08st. Clear:RC:1(188.123.215.55):. Processed in 0.071735 secs); 07 Jun 2020 20:19:46 -0000 Received: from unknown (HELO localhost.localdomain) (kuba@kadziolka.net@188.123.215.55) by pat.zlotemysli.pl with AES256-SHA encrypted SMTP; 7 Jun 2020 22:19:46 +0200 From: Jakub =?UTF-8?Q?K=C4=85dzio=C5=82ka?= Date: Sun, 7 Jun 2020 22:19:40 +0200 Message-Id: <20200607201941.5044-1-kuba@kadziolka.net> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Qmailux-2.08st: added fake Content-Type header Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.0 (-) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: 2.49 X-TUID: ZfMg4gOOBvQc * gnu/packages/emulators.scm (unicorn): New variable. --- Changes from v1: packaged a new -rc, which makes tests pass on ARM. Add an input for cross-binutils, and use it while running tests. Also, the new -rc doesn't need Python for build orchestration, so the python-2 input got dropped. The python-build-system phases hack got prefixed with a comment referencing the core-updates patch. gnu/packages/emulators.scm | 117 ++++++++++++++++++++++++++++++++++++- 1 file changed, 116 insertions(+), 1 deletion(-) diff --git a/gnu/packages/emulators.scm b/gnu/packages/emulators.scm index 9798ac370e..a82df6e9b6 100644 --- a/gnu/packages/emulators.scm +++ b/gnu/packages/emulators.scm @@ -44,7 +44,9 @@ #:use-module (gnu packages boost) #:use-module (gnu packages backup) #:use-module (gnu packages cdrom) + #:use-module (gnu packages check) #:use-module (gnu packages compression) + #:use-module (gnu packages cross-base) #:use-module (gnu packages curl) #:use-module (gnu packages elf) #:use-module (gnu packages fonts) @@ -88,7 +90,8 @@ #:use-module (gnu packages web) #:use-module (guix build-system cmake) #:use-module (guix build-system glib-or-gtk) - #:use-module (guix build-system gnu)) + #:use-module (guix build-system gnu) + #:use-module (guix build-system python)) (define-public desmume (package @@ -1622,3 +1625,115 @@ derived from Gens. Project goals include clean source code, combined features from various forks of Gens, and improved platform portability.") (supported-systems '("i686-linux" "x86_64-linux")) (license license:gpl2+))) + +;; python-pwntools requires a -rc release of unicorn +(define-public unicorn + (let ((unless-x86 + (lambda (code) + (if (member (%current-system) '("x86_64-linux" "i686-linux")) + '() + code)))) + (package + (name "unicorn") + (version "1.0.2-rc4") + ;; NOTE: unicorn ships a bundled QEMU, but with a lot of custom modifications. + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/unicorn-engine/unicorn") + (commit version))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "17nyccgk7hpc4hab24yn57f1xnmr7kq4px98zbp2bkwcrxny8gwy")))) + (outputs '("out" "python")) + ;; The main library is not written in Python, but the build process has + ;; little in common with any defined build system, so we might as well + ;; build on top of python-build-system and make use of all + ;; the Python-specific phases that can be reused. + (build-system python-build-system) + (arguments + `(#:modules ((srfi srfi-26) + (guix build python-build-system) + (guix build utils)) + #:phases + (modify-phases %standard-phases + (add-after 'unpack 'install-bindings-to-python-output + (lambda* (#:key outputs #:allow-other-keys) + ;; python-build-system will build the bindings and install them to + ;; the "out" output, so change the build-internal names of the + ;; outputs. + ;; + ;; TODO: remove this once #40469 lands, through the core-updates + ;; holding zone, on master. + (set-car! (assoc "out" outputs) "lib") + (set-car! (assoc "python" outputs) "out") + #t)) + (add-before 'build 'build-library + (lambda* (#:key inputs #:allow-other-keys) + (invoke "make" + "-j" (number->string (parallel-job-count)) + "UNICORN_STATIC=no" + "CC=gcc"))) + (add-after 'build-library 'install-library + (lambda* (#:key outputs #:allow-other-keys) + (invoke "make" "install" + "UNICORN_STATIC=no" + (string-append + "PREFIX=" + (assoc-ref outputs "lib"))))) + (add-before 'build 'prepare-bindings + (lambda* (#:key outputs #:allow-other-keys) + (chdir "bindings/python") + ;; Set this environment variable so that the Python bindings + ;; don't build their own copy of the shared object, but use + ;; a dummy value such that the bindings test suite uses the + ;; same mechanism for loading the library as any other user. + (setenv "LIBUNICORN_PATH" "1") + (substitute* "unicorn/unicorn.py" + (("_path_list = \\[.*") + (string-append + "_path_list = [\"" + (assoc-ref outputs "lib") + ;; eat the rest of the list + "/lib\"] + 0*["))) + #t)) + (add-before 'check 'check-library + (lambda* (#:key outputs #:allow-other-keys) + (for-each + (lambda (suite) + (with-directory-excursion + (string-append "../../tests/" suite) + (invoke "make" "test" "CC=gcc" + ,@(unless-x86 + '("AS=i686-unknown-linux-gnu-as" + "OBJCOPY=i686-unknown-linux-gnu-objcopy"))))) + '("unit" "regress")) + #t)) + (add-after 'install 'install-samples + (lambda* (#:key outputs #:allow-other-keys) + (let* ((python-samples (find-files "." "sample_.*")) + (c-samples (find-files "../../samples" ".*\\.c")) + (python-docdir + (string-append (assoc-ref outputs "out") + "/share/doc/unicorn/samples")) + (c-docdir + (string-append (assoc-ref outputs "lib") + "/share/doc/unicorn/samples"))) + (for-each (cut install-file <> c-docdir) c-samples) + (for-each (cut install-file <> python-docdir) python-samples) + #t)))))) + (native-inputs + ;; NOTE: cross-binutils needs to be wrapped with unless-x86, as otherwise + ;; the linker provided by the package will be used, circumventing the ld-wrapper. + `(,@(unless-x86 + `(("assembler-for-tests" ,(cross-binutils "i686-unknown-linux-gnu")))) + ("cmocka" ,cmocka) + ("hexdump-for-tests" ,util-linux))) + (home-page "http://www.unicorn-engine.org") + (synopsis "Unicorn CPU emulator framework") + (description + "Unicorn is a lightweight, multi-platform, multi-architecture CPU emulator +framework based on QEMU.") + (license license:gpl2+)))) -- 2.26.2