I’m trying to port a library called Unibilium to OpenWrt as one of the dependencies of Neovim. The source MakeFile calls libtoolfor compiling and linking. Here’s the excerpt:
uniutil.lo: uniutil.c unibilium.h
$(LIBTOOL) --mode=compile --tag=CC $(CC) -I. -DTERMINFO_DIRS='$(TERMINFO_DIRS)' -Wall -std=c99 $(CFLAGS) $(CFLAGS_DEBUG) -o $@ -c $<
$(LIBRARY): $(OBJECTS)
$(LIBTOOL) --mode=link --tag=CC $(CC) $(LDFLAGS) -rpath '$(LIBDIR)' -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) -o $@ $^
I verified that it’s the libtoolfrom staging_dir/host/bin/libtool that’s being called, not the system one, and it works for the compiling part, but not for linking.
libtool --mode=link --tag=CC aarch64-openwrt-linux-musl-gcc -L/home/vkosikhin/git/openwrt/staging_dir/toolchain-aarch64_cortex-a53_gcc-14.3.0_musl/usr/lib -L/home/vkosikhin/git/openwrt/staging_dir/toolchain-aarch64_cortex-a53_gcc-14.3.0_musl/lib -fuse-ld=bfd -znow -zrelro -rpath '/usr/local/lib' -version-info 4:0:0 -o libunibilium.la unibilium.lo uninames.lo uniutil.lo
OpenWrt-libtool: link: /home/vkosikhin/git/openwrt/staging_dir/host/bin/gcc -std=gnu23 -shared -fPIC -DPIC .libs/unibilium.o .libs/uninames.o .libs/uniutil.o -L/home/vkosikhin/git/openwrt/staging_dir/toolchain-aarch64_cortex-a53_gcc-14.3.0_musl/usr/lib -L/home/vkosikhin/git/openwrt/staging_dir/toolchain-aarch64_cortex-a53_gcc-14.3.0_musl/lib -fuse-ld=bfd -Wl,-soname -Wl,libunibilium.so.4 -o .libs/libunibilium.so.4.0.0
/usr/bin/ld.bfd: .libs/unibilium.o: Relocations in generic ELF (EM: 183)
/usr/bin/ld.bfd: .libs/unibilium.o: Relocations in generic ELF (EM: 183)
/usr/bin/ld.bfd: .libs/unibilium.o: error adding symbols: file in wrong format
collect2: error: ld returned 1 exit status
I separated the log lines for clarity. As shown, the CCvariable still expands to aarch64-openwrt-linux-musl-gcc, but OpenWrt-libtoolis completely ignoring it in favor of the system cc. Why does this happen while linking specifically and not while compiling?