Tests on MinGW: undef ref pthread_mutex_lock/unlock
Hi, Running gnulib tests on MinGW (current Debian unstable) fail: /usr/bin/x86_64-w64-mingw32-ld: libtests.a(localename.o):localename.c:(.text+0x10): undefined reference to `pthread_mutex_lock' /usr/bin/x86_64-w64-mingw32-ld: libtests.a(localename.o):localename.c:(.text+0x83): undefined reference to `pthread_mutex_unlock' /usr/bin/x86_64-w64-mingw32-ld: libtests.a(localename.o):localename.c:(.text+0xa8): undefined reference to `pthread_mutex_unlock' collect2: error: ld returned 1 exit status This is with latest master (eb8278fefa0bbf2a53b706bffb2c99ccfe5d7bd4). From gl/Makefile.am: # Generated by gnulib-tool. # Reproduce by: # gnulib-tool --import --local-dir=gl/override \ # --lib=libgnu \ # --source-base=gl \ # --m4-base=m4 \ # --doc-base=doc \ # --tests-base=gl/tests \ # --aux-dir=build-aux \ # --with-tests \ # --no-conditional-dependencies \ # --libtool \ # --macro-prefix=gl \ # --avoid=alignof-tests \ # --avoid=lock-tests \ # --avoid=lseek-tests \ # alloca \ # arpa_inet \ # byteswap \ # c-ctype \ # c-strcase \ # extensions \ # func \ # gendocs \ # getline \ # gettext-h \ # gettimeofday \ # hash-pjw-bare \ # havelib \ # inet_ntop \ # inet_pton \ # intprops \ # lib-msvc-compat \ # lib-symbol-versions \ # maintainer-makefile \ # manywarnings \ # memmem-simple \ # minmax \ # netdb \ # netinet_in \ # pmccabe2html \ # read-file \ # secure_getenv \ # setsockopt \ # snprintf \ # stdint \ # strcase \ # strdup-posix \ # strndup \ # strtok_r \ # strverscmp \ # sys_socket \ # sys_stat \ # sys_types \ # time_r \ # unistd \ # valgrind-tests \ # vasprintf \ # vsnprintf \ # warnings My environment, if of any interest: PREFIX=x86_64-w64-mingw32 export PATH="/usr/$PREFIX/bin:$PATH" export INSTALLDIR="$PWD/$PREFIX" export PKG_CONFIG_PATH=$INSTALLDIR/lib/pkgconfig:/usr/$PREFIX/lib/pkgconfig export PKG_CONFIG_LIBDIR="$INSTALLDIR/lib/pkgconfig" export PKG_CONFIG="/usr/bin/${PREFIX}-pkg-config" export CPPFLAGS="-I$INSTALLDIR/include" export LDFLAGS="-L$INSTALLDIR/lib" export CFLAGS="-O2 -Wall -Wno-format" Any help is thankfully appreciated, Tim signature.asc Description: OpenPGP digital signature
Re: Tests on MinGW: undef ref pthread_mutex_lock/unlock
Hi Tim, > Running gnulib tests on MinGW (current Debian unstable) fail: > > /usr/bin/x86_64-w64-mingw32-ld: > libtests.a(localename.o):localename.c:(.text+0x10): undefined reference > to `pthread_mutex_lock' > /usr/bin/x86_64-w64-mingw32-ld: > libtests.a(localename.o):localename.c:(.text+0x83): undefined reference > to `pthread_mutex_unlock' > /usr/bin/x86_64-w64-mingw32-ld: > libtests.a(localename.o):localename.c:(.text+0xa8): undefined reference > to `pthread_mutex_unlock' > collect2: error: ld returned 1 exit status For analyzing this, we would need the generated - config.log, - config.status, - config.h. Bruno
Re: Tests on MinGW: undef ref pthread_mutex_lock/unlock
Hi Tim, > > For analyzing this, we would need the generated > > - config.log, > > - config.status, > > - config.h. > > Thanks, attached. You should also say which package you are building, and with which configure options you configured it. It looks like - you are building gnutls-3.6.7, not just a gnulib testdir, - you gave the configure option --disable-threads, - but at the same time the C macro USE_POSIX_THREADS is defined. How come? Bruno
Re: Tests on MinGW: undef ref pthread_mutex_lock/unlock
On 11.04.19 20:56, Bruno Haible wrote: > Hi Tim, > >>> For analyzing this, we would need the generated >>> - config.log, >>> - config.status, >>> - config.h. >> >> Thanks, attached. > > You should also say which package you are building, and with which > configure options you configured it. > > It looks like > - you are building gnutls-3.6.7, not just a gnulib testdir, > - you gave the configure option --disable-threads, > - but at the same time the C macro USE_POSIX_THREADS is defined. > How come? Yes, it's gnutls from master. I don't use --disable-threads nor do I set USE_POSIX_THREADS manually. Basically (after building the dependencies): ### unset CC unset CXX #PREFIX=i686-w64-mingw32 PREFIX=x86_64-w64-mingw32 export PATH="/usr/$PREFIX/bin:$PATH" export INSTALLDIR="$PWD/$PREFIX" export PKG_CONFIG_PATH=$INSTALLDIR/lib/pkgconfig:/usr/$PREFIX/lib/pkgconfig export PKG_CONFIG_LIBDIR="$INSTALLDIR/lib/pkgconfig" export PKG_CONFIG="/usr/bin/${PREFIX}-pkg-config" export CPPFLAGS="-I$INSTALLDIR/include" export LDFLAGS="-L$INSTALLDIR/lib" # stuff for running tests export GCCLIB=$(dirname $(find /usr/lib/gcc/$PREFIX -name libgcc_s_seh-1.dll|grep posix)) export WINEPATH="$WINEPATH;/usr/$PREFIX/bin;/usr/$PREFIX/lib;$PWD/libwget/.libs;$GCCLIB" # let mingw compiler be less verbose export CFLAGS="-O2 -Wall -Wno-format" git clone https://gitlab.com/gnutls/gnutls.git ./configure --build=x86_64-pc-linux-gnu --host=$PREFIX \ --with-nettle-mini --enable-shared --with-included-libtasn1 \ --without-p11-kit --disable-doc --disable-tests --disable-tools --disable-cxx \ --disable-maintainer-mode --disable-libdane --disable-hardware-acceleration --disable-guile --prefix=$INSTALLDIR make -j$(nproc) make check -j$(nproc) ### I could give the the complete script, which worked since years (apart from temporary dependency/build issues). I use it every few weeks, whenever there are MinGW issue with any of the projects I work on. But it has some build overhead, creating from scratch libunistring, libidn2, nettle, gnutls. Let me know if it is of any help for you (I have to brush up a bit before sending). Regards, Tim signature.asc Description: OpenPGP digital signature
Re: Tests on MinGW: undef ref pthread_mutex_lock/unlock
On 11.04.19 20:56, Bruno Haible wrote: > Hi Tim, > >>> For analyzing this, we would need the generated >>> - config.log, >>> - config.status, >>> - config.h. >> >> Thanks, attached. > > You should also say which package you are building, and with which > configure options you configured it. > > It looks like > - you are building gnutls-3.6.7, not just a gnulib testdir, > - you gave the configure option --disable-threads, > - but at the same time the C macro USE_POSIX_THREADS is defined. > How come? Maybe Debian is currently broken regarding MinGW ? I never had issues building libunistring with MinGW, but now compilation stops with In file included from /usr/share/mingw-w64/include/signal.h:10, from ./signal.h:52, from pthread_sigmask.c:20: pthread_sigmask.c:34:1: error: expected identifier or ‘(’ before numeric constant pthread_sigmask (int how, const sigset_t *new_mask, sigset_t *old_mask) ^~~ make[4]: *** [Makefile:10495: pthread_sigmask.o] Fehler 1 Maybe this is related, all about pthreads. Regards, Tim signature.asc Description: OpenPGP digital signature
Re: Tests on MinGW: undef ref pthread_mutex_lock/unlock
Hi Tim, The points to look at are: - How does the configure script behave while running the expanded code that comes from threadlib.m4? Try "sh -x ./configure ..." for this exercise. - Why does gl_lock_unlock expand to a call to pthread_mutex_unlock? Only if USE_POSIX_THREADS is defined. And where does USE_POSIX_THREADS come from on your system? > In file included from /usr/share/mingw-w64/include/signal.h:10, > from ./signal.h:52, > from pthread_sigmask.c:20: > pthread_sigmask.c:34:1: error: expected identifier or ‘(’ before numeric > constant > pthread_sigmask (int how, const sigset_t *new_mask, sigset_t *old_mask) > ^~~ > make[4]: *** [Makefile:10495: pthread_sigmask.o] Fehler 1 This one, you can start with a "gcc -E" command, to see where a macro expansion of pthread_sigmask come from. Btw, I never build with mingw-pthreads installed. But even with mingw-pthreads installed, gnulib modules ought to not use it; they ought to use the Windows API instead. Bruno
Re: Tests on MinGW: undef ref pthread_mutex_lock/unlock
On 4/11/19 7:26 PM, Bruno Haible wrote: > Btw, I never build with mingw-pthreads installed. But even with mingw-pthreads > installed, gnulib modules ought to not use it; they ought to use the Windows > API instead. Jumping in late, but this reminded me of a patch I wrote years ago: https://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=c91d13bd > On my Fedora 20 box with mingw cross-compiler, the build failed with: > > ../../src/rpc/virnetclient.c: In function 'virNetClientSetTLSSession': > ../../src/rpc/virnetclient.c:745:14: error: unused variable 'oldmask' > [-Werror=unused-variable] > sigset_t oldmask, blockedsigs; > ^ > > I traced it to the fact that mingw64-winpthreads installs a header > that does #define pthread_sigmask(...) 0, which means any argument > only ever passed to pthread_sigmask is reported as unused. This > patch works around the compilation failure, with behavior no worse > than what mingw already gives us regarding the function being a > no-op. > > * configure.ac (pthread_sigmask): Probe for broken mingw macro. > * src/util/virutil.h (pthread_sigmask): Rewrite to something that > avoids unused variables. Here we are 5 years later, and mingw32-winpthreads-5.0.4-2.fd29 still has a broken: /usr/i686-w64-mingw32/sys-root/mingw/include/pthread_signal.h: #define pthread_sigmask(H, S1, S2) 0 So indeed, gnulib could do a better job at avoiding that library as more pain than it is worth. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org signature.asc Description: OpenPGP digital signature