Package: libtool
Version: 2.5.4-9
Severity: normal
X-Debbugs-Cc: [email protected]

Dear Maintainer,

I recently discovered llvm-mingw project that builds llvm that targets
windows systems with libc++ and ucrt. Among other things it has
"proper" windows TLS support. I then attempted to cross-compile my
project (gperftools) with it and I saw linker failures. llvm-mingw
mentions those libtool errors in their README
(https://github.com/mstorsjo/llvm-mingw/), but in fact upstream
libtool has been fixed already. I have verified by building libtool
from their git. So it looks like debian libtool "simply" needs to
fetch those fixes.

The linking errors look like this:

libtool: link: x86_64-w64-mingw32-clang++ -std=gnu++17 -shared -nostdlib 
/opt/llvm-mingw-21-1-8/x86_64-w64-mingw32/lib/dllcrt2.o 
/opt/llvm-mingw-21-1-8/x86_64-w64-mingw32/lib/crtbegin.o  
src/windows/.libs/libtcmalloc_minimal_la-patch_functions.o 
src/.libs/libtcmalloc_minimal_la-common.o 
src/.libs/libtcmalloc_minimal_la-internal_logging.o 
src/windows/.libs/libtcmalloc_minimal_la-system-alloc.o 
src/.libs/libtcmalloc_minimal_la-memfs_malloc.o 
src/.libs/libtcmalloc_minimal_la-safe_strerror.o 
src/.libs/libtcmalloc_minimal_la-central_freelist.o 
src/.libs/libtcmalloc_minimal_la-page_heap.o 
src/.libs/libtcmalloc_minimal_la-sampler.o 
src/.libs/libtcmalloc_minimal_la-span.o 
src/.libs/libtcmalloc_minimal_la-stack_trace_table.o 
src/.libs/libtcmalloc_minimal_la-static_vars.o 
src/.libs/libtcmalloc_minimal_la-thread_cache.o 
src/.libs/libtcmalloc_minimal_la-thread_cache_ptr.o 
src/.libs/libtcmalloc_minimal_la-malloc_hook.o 
src/.libs/libtcmalloc_minimal_la-malloc_extension.o  -Wl,--whole-archive 
./.libs/libcommon.a -Wl,--no-whole-archive  -lpthread -lpsapi -lsynchronization 
-lshlwapi -L/opt/llvm-mingw-21-1-8/x86_64-w64-mingw32/lib 
-L/opt/llvm-mingw-21-1-8/x86_64-w64-mingw32/mingw/lib 
-L/opt/llvm-mingw-21-1-8/lib/clang/21/lib/windows -lc++ -lmingw32 -lunwind 
-lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 
-lmingw32 -lunwind -lmoldname -lmingwex -lmsvcrt -lkernel32 
/opt/llvm-mingw-21-1-8/x86_64-w64-mingw32/lib/crtend.o  
-momit-leaf-frame-pointer -g -O2   -pthread -o .libs/libtcmalloc_minimal-4.dll 
-Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker 
.libs/libtcmalloc_minimal.dll.a
clang: warning: argument unused during compilation: '-pthread' 
[-Wunused-command-line-argument]
ld.lld: error: undefined symbol: ___chkstk_ms
>>> referenced by src/windows/patch_functions.cc:685
>>>               
>>> src/windows/.libs/libtcmalloc_minimal_la-patch_functions.o:((anonymous 
>>> namespace)::PatchAllModules())
>>> referenced by src/base/proc_maps_iterator.cc:612
>>>               
>>> libcommon.a(proc_maps_iterator.o):(tcmalloc::SaveProcSelfMapsToRawFD(void*))
>>> referenced by ../crt/pseudo-reloc.c:493
>>>               
>>> libmingw32.a(lib64_libmingw32_a-pseudo-reloc.o):(_pei386_runtime_relocator)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Makefile:3153: libtcmalloc_minimal.la] Error 1

I don't quite understand what happens there but here is quote from
that llvm-mingw README I mentioned above:

Libtool based projects fail to link with llvm-mingw if the project
contains C++. (This often manifests with undefined symbols like
___chkstk_ms, __alloca or ___divdi3.) For such targets, libtool tries
to detect which libraries to link by invoking the compiler with $CC -v
and picking up the libraries that are linked by default, and then
invoking the linker driver with -nostdlib and specifying the default
libraries manually. In doing so, libtool fails to detect when clang is
using compiler_rt instead of libgcc, because clang refers to it as an
absolute path to a static library, instead of specifying a library
path with -L and linking the library with -l. Clang is reluctant to
changing this behaviour. A bug has been filed with libtool, but no fix
has been committed, and as libtool files are shipped with the projects
that use them (bundled within the configure script), one has to update
the configure script in each project to avoid the issue. This can
either be done by installing libtool, patching it and running
autoreconf -fi in the project, or by manually applying the fix on the
shipped configure script. A patched version of libtool is shipped in
MSYS2 at least.

** end of quote **

As noted above, I have verified that the upstream git master of
libtool works.


-- System Information:
Debian Release: forky/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.18.5-alk (SMP w/32 CPU threads)
Kernel taint flags: TAINT_USER
Locale: LANG=be_BY.UTF-8, LC_CTYPE=be_BY.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages libtool depends on:
ii  automake               1:1.18.1-3
ii  autotools-dev          20240727.1
ii  clang-14 [c-compiler]  1:14.0.6-20
ii  clang-15 [c-compiler]  1:15.0.7-15+b1
ii  clang-16 [c-compiler]  1:16.0.6-27+b1
ii  clang-17 [c-compiler]  1:17.0.6-23+b2
ii  clang-18 [c-compiler]  1:18.1.8-20+b2
ii  clang-19 [c-compiler]  1:19.1.7-20+b1
ii  clang-20 [c-compiler]  1:20.1.8-1~exp1
ii  clang-21 [c-compiler]  1:21.1.8-2
ii  cpp                    4:15.2.0-4
ii  file                   1:5.46-5+b1
ii  gcc [c-compiler]       4:15.2.0-4
ii  gcc-10 [c-compiler]    10.5.0-4
ii  gcc-11 [c-compiler]    11.5.0-7
ii  gcc-12 [c-compiler]    12.5.0-6
ii  gcc-13 [c-compiler]    13.4.0-5
ii  gcc-14 [c-compiler]    14.3.0-11
ii  gcc-15 [c-compiler]    15.2.0-12
ii  gcc-4.4 [c-compiler]   4.4.7-8
ii  gcc-4.6 [c-compiler]   4.6.4-7
ii  gcc-4.7 [c-compiler]   4.7.4-3
ii  gcc-4.8 [c-compiler]   4.8.5-4
ii  gcc-4.9 [c-compiler]   4.9.4-2
ii  gcc-5 [c-compiler]     5.5.0-12
ii  gcc-6 [c-compiler]     6.5.0-2
ii  gcc-8 [c-compiler]     8.4.0-7
ii  gcc-9 [c-compiler]     9.5.0-6+b2
ii  libc6-dev [libc-dev]   2.42-9
ii  tcc [c-compiler]       0.9.27+git20200814.62c30a4a-2

Versions of packages libtool recommends:
ii  libltdl-dev  2.5.4-9

Versions of packages libtool suggests:
ii  autoconf                          2.72-3.1
ii  automake [automaken]              1:1.18.1-3
ii  automake1.11 [automaken]          1:1.11.6-6
ii  automake1.9 [automaken]           1.9.6+nogfdl-4
ii  gfortran-15 [fortran95-compiler]  15.2.0-12
ii  gfortran-5 [fortran95-compiler]   5.5.0-12
ii  libtool-doc                       2.5.4-9

-- no debconf information

Reply via email to