Skip to content

Commit

Permalink
Merge bitcoin#29846: guix: replace GCC unaligned VMOV patch with binu…
Browse files Browse the repository at this point in the history
…tils patch

a0dc2eb guix: replace GCC unaligned VMOV patch with binutils patch (fanquake)

Pull request description:

  Rather than invasively patching GCC, given we have binutils 2.38 available, we can patch it to flip the default for
  `-muse-unaligned-vector-move`.

  A 1 line binutils patch, is much more maintainable than the ~300 line patch into GCC. It's also a slight inprovement in regards to patching out ualigned instructions in the release binaries. For comparison:
  Master:
  ```bash
  objdump -D bin/*.exe | rg "vmova|vmovdqa|vmovaps|vmovapd|vmovdqa64|vmovdqa32"
  141b8be20: c5 f8 28 1a                 vmovaps(%rdx), %xmm3
  1420564b3: c5 79 29 36                 vmovapd%xmm14, (%rsi)
  1403060f3: c5 79 29 36                 vmovapd%xmm14, (%rsi)
  140792b13: c5 79 29 36                 vmovapd%xmm14, (%rsi)
  140cb0693: c5 79 29 36                 vmovapd%xmm14, (%rsi)
  1415ea0f3: c5 79 29 36                 vmovapd%xmm14, (%rsi)
  ```

  This PR:
  ```bash
  objdump -D bin/*.exe | rg "vmova|vmovdqa|vmovaps|vmovapd|vmovdqa64|vmovdqa32"
  141b8be20: c5 f8 28 1a                 vmovaps(%rdx), %xmm3
  1420564b3: c5 79 29 36                 vmovapd%xmm14, (%rsi)
  1403060f3: c5 79 29 36                 vmovapd%xmm14, (%rsi)
  140792b13: c5 79 29 36                 vmovapd%xmm14, (%rsi)
  140cb0693: c5 79 29 36                 vmovapd%xmm14, (%rsi)
  ```

ACKs for top commit:
  laanwj:
    Code review ACK a0dc2eb

Tree-SHA512: b3b6dcd2efaaa825d32c768302651d26a120a3e47b93fafb862a1884ff68fd96edb42ea9bc9974c005c8f5a1d15c217deec0ed462cc4a3365cab1bad5a0b5fef
  • Loading branch information
fanquake committed Apr 17, 2024
2 parents 8cd9475 + a0dc2eb commit 3b70ce2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 291 deletions.
9 changes: 6 additions & 3 deletions contrib/guix/manifest.scm
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,15 @@ desirable for building Bitcoin Core release binaries."

(define (gcc-mingw-patches gcc)
(package-with-extra-patches gcc
(search-our-patches "gcc-remap-guix-store.patch"
"vmov-alignment.patch")))
(search-our-patches "gcc-remap-guix-store.patch")))

(define (binutils-mingw-patches binutils)
(package-with-extra-patches binutils
(search-our-patches "binutils-unaligned-default.patch")))

(define (make-mingw-pthreads-cross-toolchain target)
"Create a cross-compilation toolchain package for TARGET"
(let* ((xbinutils (cross-binutils target))
(let* ((xbinutils (binutils-mingw-patches (cross-binutils target)))
(pthreads-xlibc mingw-w64-x86_64-winpthreads)
(pthreads-xgcc (cross-gcc target
#:xgcc (gcc-mingw-patches mingw-w64-base-gcc)
Expand Down
22 changes: 22 additions & 0 deletions contrib/guix/patches/binutils-unaligned-default.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
commit 6537181f59ed186a341db621812a6bc35e22eaf6
Author: fanquake <[email protected]>
Date: Wed Apr 10 12:15:52 2024 +0200

build: turn on -muse-unaligned-vector-move by default

This allows us to avoid (more invasively) patching GCC, to avoid
unaligned instruction use.

diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index e0632681477..14a9653abdf 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -801,7 +801,7 @@ static unsigned int no_cond_jump_promotion = 0;
static unsigned int sse2avx;

/* Encode aligned vector move as unaligned vector move. */
-static unsigned int use_unaligned_vector_move;
+static unsigned int use_unaligned_vector_move = 1;

/* Encode scalar AVX instructions with specific vector length. */
static enum
288 changes: 0 additions & 288 deletions contrib/guix/patches/vmov-alignment.patch

This file was deleted.

0 comments on commit 3b70ce2

Please sign in to comment.