diff options
| author | Sören Tempel <soeren+git@soeren-tempel.net> | 2025-10-06 07:06:13 +0200 |
|---|---|---|
| committer | 宋文武 <iyzsong@member.fsf.org> | 2025-11-24 18:50:37 +0800 |
| commit | e11b1787217aa306d2925d3857efd04a8f68b08d (patch) | |
| tree | eb24f10d39185bc5bb3f7fdc35d85541df26d06b /gnu/packages/debug.scm | |
| parent | c3a3858c93b2af163a7fe860149939fdda189ca9 (diff) | |
gnu: aflplusplus: Enable llvm_mode and afl-clang-lto.
* gnu/packages/debug.scm (aflplusplus)
[inputs]: Replace gcc-11 with gcc; add clang.
[native-inputs]: Replace gcc-11 with gcc.
[arguments]<make-flags>: Set CXX, LLVM_CONFIG, AFL_REAL_LD, CLANG_BIN,
CLANGPP_BIN, LLVM_LTO and AFL_CLANG_FLTO.
<phases>: Add fatal-llvm-failure and patch-clang-path.
Closes: guix/guix#3358
Change-Id: Ia306cc33b07186299c4310619a0b70bc42fea1be
Signed-off-by: 宋文武 <iyzsong@member.fsf.org>
Diffstat (limited to 'gnu/packages/debug.scm')
| -rw-r--r-- | gnu/packages/debug.scm | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/gnu/packages/debug.scm b/gnu/packages/debug.scm index cf00e82cca0..2258e2ff2df 100644 --- a/gnu/packages/debug.scm +++ b/gnu/packages/debug.scm @@ -627,9 +627,47 @@ server and embedded PowerPC, and S390 guests.") (string-append "DOC_PATH=" #$output "/share/doc/" #$(package-name this-package) "-" #$(package-version this-package)) - (string-append "CC=" #$(cc-for-target)))) + (string-append "CC=" #$(cc-for-target)) + (string-append "CXX=" #$(cxx-for-target)) + (string-append "LLVM_CONFIG=" + (search-input-file %build-inputs "/bin/llvm-config")) + ;; Need to use LLD with the llvm_mode, because LTO in + ;; combination with binutils gold is currently broken. + ;; + ;; See: https://codeberg.org/guix/guix/issues/3307 + (string-append "AFL_REAL_LD=" + (search-input-file %build-inputs "/bin/ld.lld")) + (string-append "CLANG_BIN=" + (search-input-file %build-inputs "/bin/clang")) + (string-append "CLANGPP_BIN=" + (search-input-file %build-inputs "/bin/clang++")) + "LLVM_LTO=1" + "AFL_CLANG_FLTO=-flto=full")) ((#:phases phases '%standard-phases) #~(modify-phases #$phases + ;; Ensure that the build fails early if LLVM support fails to + ;; compile, makes the build log much easier to understand. + (add-after 'unpack 'fatal-llvm-failure + (lambda* (#:key inputs #:allow-other-keys) + (substitute* "GNUmakefile" + (("-\\$\\(MAKE\\) ..* -f GNUmakefile.llvm$" all) + (substring all 1))))) ; remove the leading '-' + ;; GNUmakefile.llvm tries to find clang/clang++ relative to the + ;; --bindir reported by llvm-config, but since llvm and clang + ;; have different store paths on Guix, this doesn't work here. + (add-after 'unpack 'patch-clang-path + (lambda* (#:key inputs #:allow-other-keys) + (substitute* "GNUmakefile.llvm" + (("^CC *= .*$") + (string-append + "override CC = " + (search-input-file inputs "/bin/clang") + "\n")) + (("^CXX *= .*$") + (string-append + "override CXX = " + (search-input-file inputs "/bin/clang++") + "\n"))))) ;; For GCC plugins. (add-after 'unpack 'patch-gcc-path (lambda* (#:key inputs #:allow-other-keys) @@ -656,8 +694,8 @@ server and embedded PowerPC, and S390 guests.") `("AFL_PATH" = (,(string-append #$output "/lib/afl")))))))))) ;; According to the Dockerfile, GCC 12 is producing compile errors for some ;; targets, so explicitly use GCC 11 here. - (inputs (list gcc-11 gmp python qemu-for-aflplusplus)) - (native-inputs (list gcc-11)) + (inputs (list llvm-20 clang-20 lld-20 gcc gmp python qemu-for-aflplusplus)) + (native-inputs (list gcc)) (home-page "https://aflplus.plus/") (description "AFLplusplus is a security-oriented fuzzer that employs a novel type of |
