summaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-extended/newt/files/cross_ar.patch
blob: eb8c4134b2a3e20932a0018c3d9878b2263e6454 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
From 0f33421000006f5991d1cddcb9dbc68b64141e44 Mon Sep 17 00:00:00 2001
From: Jason Wessel <jason.wessel@windriver.com>
Date: Wed, 19 Jun 2024 11:22:48 +0200
Subject: [PATCH] Fix cross link using autoconf detected AR

If building on 32bit host and creating 64bit libraries, the target
package builds should not invoke the 32bit hosts's ar.  Specifically
you will get an error message like:

x86_64-linux-gcc    -m64 --sysroot=/opt/qemux86-64/tmp/sysroots/qemux86-64 -g -o test test.o libnewt.a -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -lslang
libnewt.a: could not read symbols: Archive has no index; run ranlib to add one
collect2: error: ld returned 1 exit status

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>

Upstream-Status: Pending

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 Makefile.in  | 3 ++-
 configure.ac | 4 ++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/Makefile.in b/Makefile.in
index f8fe290..8a44a56 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -7,6 +7,7 @@ CFLAGS = @CFLAGS@
 LDFLAGS = @LDFLAGS@
 CPPFLAGS = -D_GNU_SOURCE @CPPFLAGS@
 GNU_LD = @GNU_LD@
+AR = @AR@
 
 VERSION = @VERSION@
 TAG = r$(subst .,-,$(VERSION))
@@ -109,7 +110,7 @@ whiptcl.$(SOEXT): $(WHIPTCLOBJS) $(LIBNEWTSH)
 	$(CC) -shared $(SHCFLAGS) $(LDFLAGS) -o whiptcl.$(SOEXT) $(WHIPTCLOBJS) -L. -lnewt  $(LIBTCL) -lpopt $(LIBS)
 
 $(LIBNEWT): $(LIBOBJS)
-	ar rv $@ $^
+	$(AR) rv $@ $^
 
 newt.o $(SHAREDDIR)/newt.o: newt.c Makefile
 
diff --git a/configure.ac b/configure.ac
index 434121e..2cfffd6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,6 +15,10 @@ AC_PROG_CC
 AC_PROG_LN_S
 AC_PROG_GREP
 AC_SYS_LARGEFILE
+AN_MAKEVAR([AR], [AC_PROG_AR])
+AN_PROGRAM([ar], [AC_PROG_AR])
+AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL(AR, ar, :)])
+AC_PROG_AR
 
 AC_CHECK_SIZEOF([long])
 AC_CHECK_SIZEOF([long long])