Skip to content

Commit 0d66644

Browse files
GalaxySnailskeeto
authored andcommitted
Fix a Binutils 2.40 regression
In Binutils 2.40, there is a regression that ld fails with MSVC lib files. Add a patch to fix it. Closes #59. [1] msys2/MINGW-packages#15469 [2] https://sourceware.org/bugzilla/show_bug.cgi?id=30079
1 parent 5875e0b commit 0d66644

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ ARG ARCH=x86_64-w64-mingw32
6868
# Build cross-compiler
6969

7070
WORKDIR /binutils-$BINUTILS_VERSION
71-
RUN sed -ri 's/(static bool insert_timestamp = )/\1!/' ld/emultempl/pe*.em
71+
COPY src/binutils-*.patch $PREFIX/src/
72+
RUN sed -ri 's/(static bool insert_timestamp = )/\1!/' ld/emultempl/pe*.em \
73+
&& cat $PREFIX/src/binutils-*.patch | patch -p1
7274
WORKDIR /x-binutils
7375
RUN /binutils-$BINUTILS_VERSION/configure \
7476
--prefix=/bootstrap \
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
From b7eab2a9d4f4e92692daf14b09fc95ca11b72e30 Mon Sep 17 00:00:00 2001
2+
From: Michael Matz <matz@suse.de>
3+
Date: Thu, 9 Feb 2023 15:29:00 +0100
4+
Subject: [PATCH] Fix PR30079: abort on mingw
5+
6+
the early-out in wild_sort is not enough, it might still be
7+
that filenames are equal _and_ the wildcard list doesn't specify
8+
a sort order either. Don't call compare_section then.
9+
10+
Tested on all targets.
11+
---
12+
ld/ldlang.c | 3 ++-
13+
1 file changed, 2 insertions(+), 1 deletion(-)
14+
15+
diff --git a/ld/ldlang.c b/ld/ldlang.c
16+
index 84a2914fc26..b5e0d026ae4 100644
17+
--- a/ld/ldlang.c
18+
+++ b/ld/ldlang.c
19+
@@ -649,7 +649,8 @@ wild_sort (lang_wild_statement_type *wild,
20+
looking at the sections for this file. */
21+
22+
/* Find the correct node to append this section. */
23+
- if (compare_section (sec->spec.sorted, section, (*tree)->section) < 0)
24+
+ if (sec && sec->spec.sorted != none && sec->spec.sorted != by_none
25+
+ && compare_section (sec->spec.sorted, section, (*tree)->section) < 0)
26+
tree = &((*tree)->left);
27+
else
28+
tree = &((*tree)->right);
29+
--
30+
2.31.1
31+

0 commit comments

Comments
 (0)