summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorAndreas Enge <andreas@enge.fr>2026-02-17 12:35:58 +0100
committerAndreas Enge <andreas@enge.fr>2026-02-17 13:44:24 +0100
commit40fdbd43a120890332e1e93009642eafb55e69dd (patch)
treeec8058866bddaafd64750f3a347390c06448dee8 /gnu
parentd926044cd53ae5a2c6d5e7cb97d99051d4760044 (diff)
gnu: aflplusplus: Drop inheritance from american-fuzzy-lop.
The resulting derivation remains unchanged. * gnu/packages/debug.scm (aflplusplus)[inherit]: Remove field. [build-system, synopsis, license]: Copy-paste fields from american-fuzzy-lop. [arguments]: Use arguments from american-fuzzy-lop and keep the duplicate %modify-phases. Change-Id: I3972e1ab2ace5a84041181a83d728822c7f49c5f
Diffstat (limited to 'gnu')
-rw-r--r--gnu/packages/debug.scm229
1 files changed, 137 insertions, 92 deletions
diff --git a/gnu/packages/debug.scm b/gnu/packages/debug.scm
index 1bc79a49048..0a278a8f5d0 100644
--- a/gnu/packages/debug.scm
+++ b/gnu/packages/debug.scm
@@ -607,97 +607,141 @@ server and embedded PowerPC, and S390 guests.")
607 (synopsis "QEMU for AFL++"))))) 607 (synopsis "QEMU for AFL++")))))
608 608
609(define-public aflplusplus 609(define-public aflplusplus
610 (package 610 ;; TODO: Merge the duplicate application of modify-phases,
611 (inherit american-fuzzy-lop) 611 ;; due to the previous inheritance from american-fuzzy-lop.
612 (name "aflplusplus") 612 (let* ((machine (match (or (%current-target-system)
613 (version "4.35c") 613 (%current-system))
614 (source (origin 614 ("x86_64-linux" "x86_64")
615 (method git-fetch) 615 ("i686-linux" "i386")
616 (uri (git-reference 616 ("aarch64-linux" "aarch64")
617 (url "https://github.com/AFLplusplus/AFLplusplus") 617 ("armhf-linux" "arm")
618 (commit (string-append "v" version)))) 618 ("mips64el-linux" "mips64el")
619 (file-name (git-file-name name version)) 619 ("powerpc-linux" "ppc")
620 (sha256 620 ;; Prevent errors when querying this package on unsupported
621 (base32 621 ;; platforms, e.g. when running "guix package --search="
622 "0mwamvyv2ckfxrrns4cnhx9gf2dn9jjgi9dc1qp3cwjasbghg5lg")))) 622 (_ "UNSUPPORTED")))
623 (arguments 623 (arguments-american-fuzzy-lop
624 (substitute-keyword-arguments (package-arguments american-fuzzy-lop) 624 `(#:make-flags '()
625 ((#:make-flags _ ''()) 625 #:phases (modify-phases %standard-phases
626 #~(list (string-append "PREFIX=" #$output) 626 (add-after 'unpack 'make-git-checkout-writable
627 (string-append "DOC_PATH=" #$output "/share/doc/" 627 (lambda _
628 #$(package-name this-package) "-" 628 (for-each make-file-writable (find-files "."))
629 #$(package-version this-package)) 629 #t))
630 (string-append "CC=" #$(cc-for-target)) 630 (delete 'configure)
631 (string-append "CXX=" #$(cxx-for-target)) 631 ,@(if (string=? (%current-system) (or "x86_64-linux"
632 (string-append "LLVM_CONFIG=" 632 "i686-linux"))
633 (search-input-file %build-inputs "/bin/llvm-config")) 633 '()
634 ;; Need to use LLD with the llvm_mode, because LTO in 634 '((add-before 'build 'set-afl-flag
635 ;; combination with binutils gold is currently broken. 635 (lambda _ (setenv "AFL_NO_X86" "1") #t))
636 ;; 636 (add-after 'install 'remove-x86-programs
637 ;; See: https://codeberg.org/guix/guix/issues/3307 637 (lambda* (#:key outputs #:allow-other-keys)
638 (string-append "AFL_REAL_LD=" 638 (let* ((out (assoc-ref outputs "out"))
639 (search-input-file %build-inputs "/bin/ld.lld")) 639 (bin (string-append out "/bin/")))
640 (string-append "CLANG_BIN=" 640 (delete-file (string-append bin "afl-gcc"))
641 (search-input-file %build-inputs "/bin/clang")) 641 (delete-file (string-append bin "afl-g++"))
642 (string-append "CLANGPP_BIN=" 642 (delete-file (string-append bin "afl-clang"))
643 (search-input-file %build-inputs "/bin/clang++")) 643 (delete-file (string-append bin "afl-clang++")))
644 "LLVM_LTO=1" 644 #t))))
645 "AFL_CLANG_FLTO=-flto=full")) 645 (add-after
646 ((#:phases phases '%standard-phases) 646 ;; TODO: Build and install the afl-llvm tool.
647 #~(modify-phases #$phases 647 'install 'install-qemu
648 ;; Ensure that the build fails early if LLVM support fails to 648 (lambda* (#:key inputs outputs #:allow-other-keys)
649 ;; compile, makes the build log much easier to understand. 649 (let ((qemu (assoc-ref inputs "qemu"))
650 (add-after 'unpack 'fatal-llvm-failure 650 (out (assoc-ref outputs "out")))
651 (lambda* (#:key inputs #:allow-other-keys) 651 (symlink (string-append qemu "/bin/qemu-" ,machine)
652 (substitute* "GNUmakefile" 652 (string-append out "/bin/afl-qemu-trace"))
653 (("-\\$\\(MAKE\\) ..* -f GNUmakefile.llvm$" all) 653 #t)))
654 (substring all 1))))) ; remove the leading '-' 654 (delete 'check))))) ; tests are run during 'install phase
655 ;; GNUmakefile.llvm tries to find clang/clang++ relative to the 655 (package
656 ;; --bindir reported by llvm-config, but since llvm and clang 656 (name "aflplusplus")
657 ;; have different store paths on Guix, this doesn't work here. 657 (version "4.35c")
658 (add-after 'unpack 'patch-clang-path 658 (source (origin
659 (lambda* (#:key inputs #:allow-other-keys) 659 (method git-fetch)
660 (substitute* "GNUmakefile.llvm" 660 (uri (git-reference
661 (("^CC *= .*$") 661 (url "https://github.com/AFLplusplus/AFLplusplus")
662 (string-append 662 (commit (string-append "v" version))))
663 "override CC = " 663 (file-name (git-file-name name version))
664 (search-input-file inputs "/bin/clang") 664 (sha256
665 "\n")) 665 (base32
666 (("^CXX *= .*$") 666 "0mwamvyv2ckfxrrns4cnhx9gf2dn9jjgi9dc1qp3cwjasbghg5lg"))))
667 (string-append 667 (build-system gnu-build-system)
668 "override CXX = " 668 (arguments
669 (search-input-file inputs "/bin/clang++") 669 (substitute-keyword-arguments arguments-american-fuzzy-lop
670 "\n"))))) 670 ((#:make-flags _ ''())
671 ;; For GCC plugins. 671 #~(list (string-append "PREFIX=" #$output)
672 (add-after 'unpack 'patch-gcc-path 672 (string-append "DOC_PATH=" #$output "/share/doc/"
673 (lambda* (#:key inputs #:allow-other-keys) 673 #$(package-name this-package) "-"
674 (substitute* "src/afl-cc.c" 674 #$(package-version this-package))
675 (("alt_cc = \"gcc\";") 675 (string-append "CC=" #$(cc-for-target))
676 (format #f "alt_cc = \"~a\";" 676 (string-append "CXX=" #$(cxx-for-target))
677 (search-input-file inputs "bin/gcc"))) 677 (string-append "LLVM_CONFIG="
678 (("alt_cxx = \"g\\+\\+\";") 678 (search-input-file %build-inputs "/bin/llvm-config"))
679 (format #f "alt_cxx = \"~a\";" 679 ;; Need to use LLD with the llvm_mode, because LTO in
680 (search-input-file inputs "bin/g++")))))) 680 ;; combination with binutils gold is currently broken.
681 (add-after 'build 'build-qasan 681 ;;
682 (lambda* (#:key parallel-build? make-flags #:allow-other-keys) 682 ;; See: https://codeberg.org/guix/guix/issues/3307
683 (apply invoke "make" "-C" "qemu_mode/libqasan" 683 (string-append "AFL_REAL_LD="
684 "-j" (number->string (if parallel-build? 684 (search-input-file %build-inputs "/bin/ld.lld"))
685 (parallel-job-count) 685 (string-append "CLANG_BIN="
686 "1")) 686 (search-input-file %build-inputs "/bin/clang"))
687 make-flags))) 687 (string-append "CLANGPP_BIN="
688 ;; afl-qemu-trace is a symbolic link to QEMU's binary. 688 (search-input-file %build-inputs "/bin/clang++"))
689 ;; Substituting its source code with AFL++'s output path 689 "LLVM_LTO=1"
690 ;; would result in a dependency cycle. 690 "AFL_CLANG_FLTO=-flto=full"))
691 (add-after 'install-qemu 'wrap-qemu 691 ((#:phases phases '%standard-phases)
692 (lambda _ 692 #~(modify-phases #$phases
693 (wrap-program (string-append #$output "/bin/afl-qemu-trace") 693 ;; Ensure that the build fails early if LLVM support fails to
694 `("AFL_PATH" = (,(string-append #$output "/lib/afl")))))))))) 694 ;; compile, makes the build log much easier to understand.
695 ;; According to the Dockerfile, GCC 12 is producing compile errors for some 695 (add-after 'unpack 'fatal-llvm-failure
696 ;; targets, so explicitly use GCC 11 here. 696 (lambda* (#:key inputs #:allow-other-keys)
697 (inputs (list llvm-20 clang-20 lld-20 gcc gmp python qemu-for-aflplusplus)) 697 (substitute* "GNUmakefile"
698 (native-inputs (list gcc)) 698 (("-\\$\\(MAKE\\) ..* -f GNUmakefile.llvm$" all)
699 (home-page "https://aflplus.plus/") 699 (substring all 1))))) ; remove the leading '-'
700 (description 700 ;; GNUmakefile.llvm tries to find clang/clang++ relative to the
701 ;; --bindir reported by llvm-config, but since llvm and clang
702 ;; have different store paths on Guix, this doesn't work here.
703 (add-after 'unpack 'patch-clang-path
704 (lambda* (#:key inputs #:allow-other-keys)
705 (substitute* "GNUmakefile.llvm"
706 (("^CC *= .*$")
707 (string-append
708 "override CC = "
709 (search-input-file inputs "/bin/clang")
710 "\n"))
711 (("^CXX *= .*$")
712 (string-append
713 "override CXX = "
714 (search-input-file inputs "/bin/clang++")
715 "\n")))))
716 ;; For GCC plugins.
717 (add-after 'unpack 'patch-gcc-path
718 (lambda* (#:key inputs #:allow-other-keys)
719 (substitute* "src/afl-cc.c"
720 (("alt_cc = \"gcc\";")
721 (format #f "alt_cc = \"~a\";"
722 (search-input-file inputs "bin/gcc")))
723 (("alt_cxx = \"g\\+\\+\";")
724 (format #f "alt_cxx = \"~a\";"
725 (search-input-file inputs "bin/g++"))))))
726 (add-after 'build 'build-qasan
727 (lambda* (#:key parallel-build? make-flags #:allow-other-keys)
728 (apply invoke "make" "-C" "qemu_mode/libqasan"
729 "-j" (number->string (if parallel-build?
730 (parallel-job-count)
731 "1"))
732 make-flags)))
733 ;; afl-qemu-trace is a symbolic link to QEMU's binary.
734 ;; Substituting its source code with AFL++'s output path
735 ;; would result in a dependency cycle.
736 (add-after 'install-qemu 'wrap-qemu
737 (lambda _
738 (wrap-program (string-append #$output "/bin/afl-qemu-trace")
739 `("AFL_PATH" = (,(string-append #$output "/lib/afl"))))))))))
740 (inputs (list llvm-20 clang-20 lld-20 gcc gmp python qemu-for-aflplusplus))
741 (native-inputs (list gcc))
742 (home-page "https://aflplus.plus/")
743 (synopsis "Security-oriented fuzzer")
744 (description
701 "AFLplusplus is a security-oriented fuzzer that employs a novel type of 745 "AFLplusplus is a security-oriented fuzzer that employs a novel type of
702compile-time instrumentation and genetic algorithms to automatically discover 746compile-time instrumentation and genetic algorithms to automatically discover
703clean, interesting test cases that trigger new internal states in the targeted 747clean, interesting test cases that trigger new internal states in the targeted
@@ -709,7 +753,8 @@ It is a fork of American Fuzzy Lop fuzzer and features:
709@item A more recent qemu version. 753@item A more recent qemu version.
710@item More algorithms like collision-free coverage, enhanced laf-intel & 754@item More algorithms like collision-free coverage, enhanced laf-intel &
711redqueen, AFLfast++ power schedules, MOpt mutators, unicorn_mode, etc. 755redqueen, AFLfast++ power schedules, MOpt mutators, unicorn_mode, etc.
712@end itemize"))) 756@end itemize")
757 (license license:asl2.0))))
713 758
714(define-public backward-cpp 759(define-public backward-cpp
715 (package 760 (package