G. Branden Robinson wrote:
> > I'll report on samples of the build failures in separate
> > message, this one for Apple macOS 15.4 (Sequoia):
> >
> > CXXLD grodvi
> > ld: archive member 'libgnu.a' not a mach-o file in 'libgroff.a'
> > clang++: error: linker command failed with exit code 1 (use -v to see
> > invocation)
> >
> > % file ./lib/libgnu.a
> > ./lib/libgnu.a: current ar archive random library
> >
> > % nm ./lib/libgnu.a |grep -c ' T '
> > 83
> >
> > Evidently, ld on macOS does not like to find a .a file inside
> > another .a file.
>
> I don't have any idea what to do about this. This part of a groff build
> is thoroughly dedicated to gnulib.
>
> gnulib mavens, can you help? groff is largely a C++ project.
This has nothing to do with C++.
Simply, a .a file that is passed to the linker is supposed to hold .o files
only. On FreeBSD 15, I see a warning:
CXXLD grodvi
ld: warning: libgroff.a: archive member 'libgnu.a' is neither ET_REL nor LLVM
bitcode
With the GNU linker, the member libgnu.a of libgroff.a is simply ignored.
And on macOS, as reported by Nelson, the linker produces an error.
The problem is this line in src/libs/libgroff/libgroff.am:
libgroff_a_LIBADD = lib/libgnu.a
The Automake documentation
---------------------------------------------------------------------------
‘maude_LIBADD’
Extra objects can be added to a _library_ using the ‘_LIBADD’
variable. For instance, this should be used for objects determined
by ‘configure’ (*note A Library::).
In the case of Libtool libraries, ‘maude_LIBADD’ can also refer to
other Libtool libraries.
---------------------------------------------------------------------------
makes it clear that *_LIBADD should contain object files, or *.la files in
case of libtool libraries.
Therefore you have three options:
(a) Remove said line, and use lib/libgnu.a everywhere where linking with
libgroff.a occurs. groff's *.am files already do this. So, only the patch
below needs to be applied.
(b) Unpack the contents of libgnu.a when creating libgroff.a. A Makefile rule
for combining two archives roughly goes like this:
objects=`$(AR) t lib1.a`" "`$(AR) t lib2.a` && \
$(AR) x lib1.a && $(AR) x lib2.a && \
$(AR) q libboth.a $$objects && \
rm -f $$objects
(c) Start to use libtool. Use libgroff.la instead of libgroff.a. Use
lib/libgnu.la instead of lib/libgnu.a. Then you can have
libgroff_la_LIBADD = lib/libgnu.la
And configure libtool to create static libraries only.
The simplest solution is (a), which is what I would recommend.
Bruno
diff --git a/src/libs/libgroff/libgroff.am b/src/libs/libgroff/libgroff.am
index af675374d..2a8e22972 100644
--- a/src/libs/libgroff/libgroff.am
+++ b/src/libs/libgroff/libgroff.am
@@ -76,8 +76,6 @@ libgroff_a_SOURCES += \
endif
nodist_libgroff_a_SOURCES = src/libs/libgroff/version.cpp
-libgroff_a_LIBADD = lib/libgnu.a
-
# TODO: these .c files could be removed (use gnulib instead).
EXTRA_DIST += \
src/libs/libgroff/mkstemp.cpp \