blob: 447640cef63a5acb3adb87b7b4c5e7669ed9e34d [file] [log] [blame]
Andrew Geissler595f6302022-01-24 19:11:47 +00001From 418129bc63afc312701e84cb8afa5ca413df1ab5 Mon Sep 17 00:00:00 2001
2From: Pavel Raiskup <praiskup@redhat.com>
3Date: Fri, 17 Apr 2015 16:54:58 +0200
4Subject: ARFLAGS: use 'cr' instead of 'cru' by default
5
6In some GNU/Linux distributions people started to compile 'ar'
7binary with --enable-deterministic-archives (binutils project).
8That, however, in combination with our previous long time working
9default AR_FLAGS=cru causes warnings on such installations:
10ar: `u' modifier ignored since `D' is the default (see `U')
11
12The 'u' option (at least with GNU binutils) did small optimization
13during repeated builds because it instructed 'ar' to not
14open/close unchanged *.o files and to rather read their contents
15from old archive file. However, its removal should not cause a
16big performance hit for usual workflows.
17
18Distributions started using --enable-deterministic-archives
19knowing that it would disable the 'u', just to rather have a bit
20more deterministic builds.
21
22Also, to justify this change a bit more, keeping 'u' in ARFLAGS
23could only result in many per-project changes to override
24Libtool's ARFLAGS default, just to silent such warnings.
25
26Fixes bug#19967. Reported by Eric Blake.
27
28* m4/libtool.m4 (_LT_PROG_AR): Default AR_FLAGS to 'cr'.
29(_LT_REQUIRED_DARWIN_CHECKS): Use $AR_FLAGS instead 'cru' string.
30* doc/libtool.texi: Do 's/ar cru/ar cr/' in whole documentation.
31* NEWS: Document.
32
33Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/libtool.git/commit/?id=418129bc63afc312701e84cb8afa5ca413df1ab5]
34
35Signed-off-by: Li Wang <li.wang@windriver.com>
36Signed-off-by: Changqing Li <changqing.li@windriver.com>
37---
38 NEWS | 4 ++++
39 doc/libtool.texi | 10 +++++-----
40 m4/libtool.m4 | 6 +++---
41 3 files changed, 12 insertions(+), 8 deletions(-)
42
43diff --git a/NEWS b/NEWS
44index 71a932d..1518f09 100644
45--- a/NEWS
46+++ b/NEWS
47@@ -13,6 +13,10 @@ NEWS - list of user-visible changes between releases of GNU Libtool
48 variable, which obsoletes AR_FLAGS. This is due to naming conventions
49 among other *FLAGS and to be consistent with Automake's ARFLAGS.
50
51+** Important incompatible changes:
52+
53+ - Libtool changed ARFLAGS/AR_FLAGS default from 'cru' to 'cr'.
54+
55 ** Bug fixes:
56
57 - Fix a race condition in ltdl dryrun test that would cause spurious
58diff --git a/doc/libtool.texi b/doc/libtool.texi
59index 0298627..4c664bb 100644
60--- a/doc/libtool.texi
61+++ b/doc/libtool.texi
62@@ -602,7 +602,7 @@ Without libtool, the programmer would invoke the @command{ar} command to
63 create a static library:
64
65 @example
66-burger$ @kbd{ar cru libhello.a hello.o foo.o}
67+burger$ @kbd{ar cr libhello.a hello.o foo.o}
68 burger$
69 @end example
70
71@@ -632,7 +632,7 @@ libtool are the same ones you would use to produce an executable named
72 a23$ @kbd{libtool --mode=link gcc -g -O -o libhello.la foo.o hello.o}
73 *** Warning: Linking the shared library libhello.la against the
74 *** non-libtool objects foo.o hello.o is not portable!
75-ar cru .libs/libhello.a
76+ar cr .libs/libhello.a
77 ranlib .libs/libhello.a
78 creating libhello.la
79 (cd .libs && rm -f libhello.la && ln -s ../libhello.la libhello.la)
80@@ -662,7 +662,7 @@ archive, not a shared library (@pxref{Static libraries}).}:
81 @example
82 a23$ @kbd{libtool --mode=link gcc -g -O -o libhello.la foo.lo hello.lo \
83 -rpath /usr/local/lib -lm}
84-ar cru @value{objdir}/libhello.a foo.o hello.o
85+ar cr @value{objdir}/libhello.a foo.o hello.o
86 ranlib @value{objdir}/libhello.a
87 creating libhello.la
88 (cd @value{objdir} && rm -f libhello.la && ln -s ../libhello.la libhello.la)
89@@ -676,7 +676,7 @@ burger$ @kbd{libtool --mode=link gcc -g -O -o libhello.la foo.lo hello.lo \
90 -rpath /usr/local/lib -lm}
91 rm -fr @value{objdir}/libhello.a @value{objdir}/libhello.la
92 ld -Bshareable -o @value{objdir}/libhello.so.0.0 @value{objdir}/foo.o @value{objdir}/hello.o -lm
93-ar cru @value{objdir}/libhello.a foo.o hello.o
94+ar cr @value{objdir}/libhello.a foo.o hello.o
95 ranlib @value{objdir}/libhello.a
96 creating libhello.la
97 (cd @value{objdir} && rm -f libhello.la && ln -s ../libhello.la libhello.la)
98@@ -6001,7 +6001,7 @@ in cases where it is necessary.
99 @subsection Archivers
100
101 On all known systems, building a static library can be accomplished by
102-running @kbd{ar cru lib@var{name}.a @var{obj1}.o @var{obj2}.o @dots{}},
103+running @kbd{ar cr lib@var{name}.a @var{obj1}.o @var{obj2}.o @dots{}},
104 where the @file{.a} file is the output library, and each @file{.o} file is an
105 object file.
106
107diff --git a/m4/libtool.m4 b/m4/libtool.m4
108index 6514196..add06ee 100644
109--- a/m4/libtool.m4
110+++ b/m4/libtool.m4
111@@ -1041,8 +1041,8 @@ int forced_loaded() { return 2;}
112 _LT_EOF
113 echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD
114 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD
115- echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD
116- $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD
117+ echo "$AR $AR_FLAGS libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD
118+ $AR $AR_FLAGS libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD
119 echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD
120 $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD
121 cat > conftest.c << _LT_EOF
122@@ -1505,7 +1505,7 @@ _LT_DECL([], [AR], [1], [The archiver])
123 # ARFLAGS for automake and AR_FLAGS for libtool). FIXME: Make the AR_FLAGS
124 # variable obsoleted/removed.
125
126-test ${AR_FLAGS+y} || AR_FLAGS=${ARFLAGS-cru}
127+test ${AR_FLAGS+y} || AR_FLAGS=${ARFLAGS-cr}
128 lt_ar_flags=$AR_FLAGS
129 _LT_DECL([], [lt_ar_flags], [0], [Flags to create an archive (by configure)])
130
131--
1322.23.0
133