[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#1014114: installation of crypt.h in the multiarch location breaks the GCC and LLVM multilib builds



Control: clone -1 -2
Control: retitle -2 bootstrap dependency cycle between gcc and libxcrypt: libsanitizer requires struct crypt_data from crypt.h
Control: tags -2 =
Control: severity -2 important
Control: reassign -2 src:libxcrypt,src:gcc-12
Control: user helmutg@debian.org
Control: usertags -2 + rebootstrap

Hi,

On Mon, Jul 04, 2022 at 08:51:05PM +0200, Helmut Grohne wrote:
> A gcc build (cross compiler stage3 or native) requires a target
> architecture crypt.h. Trying to do without breaks libsanitizer (no
> multilib involved). Example from
> https://jenkins.debian.net/job/rebootstrap_ppc64_gcc12_nobiarch/5/consoleText
> 
> | /bin/bash ../libtool  --tag=CXX   --mode=compile /tmp/buildd/gcc3/gcc-12-12.1.0/build/./gcc/xgcc -shared-libgcc -B/tmp/buildd/gcc3/gcc-12-12.1.0/build/./gcc -nostdinc++ -L/tmp/buildd/gcc3/gcc-12-12.1.0/build/powerpc64-linux-gnu/libstdc++-v3/src -L/tmp/buildd/gcc3/gcc-12-12.1.0/build/powerpc64-linux-gnu/libstdc++-v3/src/.libs -L/tmp/buildd/gcc3/gcc-12-12.1.0/build/powerpc64-linux-gnu/libstdc++-v3/libsupc++/.libs -B/usr/powerpc64-linux-gnu/bin/ -B/usr/powerpc64-linux-gnu/lib/ -isystem /usr/powerpc64-linux-gnu/include -isystem /usr/powerpc64-linux-gnu/sys-include -isystem /tmp/buildd/gcc3/gcc-12-12.1.0/build/sys-include    -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS  -DHAVE_RPC_XDR_H=0 -DHAVE_TIRPC_RPC_XDR_H=0 -I. -I../../../../src/libsanitizer/sanitizer_common -I..  -I ../../../../src/libsanitizer/include -I ../../../../src/libsanitizer -isystem ../../../../src/libsanitizer/include/system  -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic -Wno-long-long -fPIC -fno-builtin -fno-exceptions -fno-rtti -fomit-frame-pointer -funwind-tables -fvisibility=hidden -Wno-variadic-macros -I../../libstdc++-v3/include     -I../../libstdc++-v3/include/powerpc64-linux-gnu     -I../../../../src/libsanitizer/../libstdc++-v3/libsupc++ -std=gnu++14  -DSANITIZER_LIBBACKTRACE -DSANITIZER_CP_DEMANGLE -I ../../../../src/libsanitizer/../libbacktrace -I ../libbacktrace -I ../../../../src/libsanitizer/../include -include ../../../../src/libsanitizer/libbacktrace/backtrace-rename.h -g -O2 -D_GNU_SOURCE -MT sanitizer_platform_limits_posix.lo -MD -MP -MF .deps/sanitizer_platform_limits_posix.Tpo -c -o sanitizer_platform_limits_posix.lo ../../../../src/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
> | libtool: compile:  /tmp/buildd/gcc3/gcc-12-12.1.0/build/./gcc/xgcc -shared-libgcc -B/tmp/buildd/gcc3/gcc-12-12.1.0/build/./gcc -nostdinc++ -L/tmp/buildd/gcc3/gcc-12-12.1.0/build/powerpc64-linux-gnu/libstdc++-v3/src -L/tmp/buildd/gcc3/gcc-12-12.1.0/build/powerpc64-linux-gnu/libstdc++-v3/src/.libs -L/tmp/buildd/gcc3/gcc-12-12.1.0/build/powerpc64-linux-gnu/libstdc++-v3/libsupc++/.libs -B/usr/powerpc64-linux-gnu/bin/ -B/usr/powerpc64-linux-gnu/lib/ -isystem /usr/powerpc64-linux-gnu/include -isystem /usr/powerpc64-linux-gnu/sys-include -isystem /tmp/buildd/gcc3/gcc-12-12.1.0/build/sys-include -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DHAVE_RPC_XDR_H=0 -DHAVE_TIRPC_RPC_XDR_H=0 -I. -I../../../../src/libsanitizer/sanitizer_common -I.. -I ../../../../src/libsanitizer/include -I ../../../../src/libsanitizer -isystem ../../../../src/libsanitizer/include/system -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic -Wno-long-long -fPIC -fno-builtin -fno-exceptions -fno-rtti -fomit-frame-pointer -funwind-tables -fvisibility=hidden -Wno-variadic-macros -I../../libstdc++-v3/include -I../../libstdc++-v3/include/powerpc64-linux-gnu -I../../../../src/libsanitizer/../libstdc++-v3/libsupc++ -std=gnu++14 -DSANITIZER_LIBBACKTRACE -DSANITIZER_CP_DEMANGLE -I ../../../../src/libsanitizer/../libbacktrace -I ../libbacktrace -I ../../../../src/libsanitizer/../include -include ../../../../src/libsanitizer/libbacktrace/backtrace-rename.h -g -O2 -D_GNU_SOURCE -MT sanitizer_platform_limits_posix.lo -MD -MP -MF .deps/sanitizer_platform_limits_posix.Tpo -c ../../../../src/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp  -fPIC -DPIC -o .libs/sanitizer_platform_limits_posix.o
> | ../../../../src/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:155:10: fatal error: crypt.h: No such file or directory
> |   155 | #include <crypt.h>
> |       |          ^~~~~~~~~
> | compilation terminated.
> | make[6]: *** [Makefile:616: sanitizer_platform_limits_posix.lo] Error 1
> | make[6]: Leaving directory '/tmp/buildd/gcc3/gcc-12-12.1.0/build/powerpc64-linux-gnu/libsanitizer/sanitizer_common'
> | make[5]: *** [Makefile:533: all-recursive] Error 1
> | make[5]: Leaving directory '/tmp/buildd/gcc3/gcc-12-12.1.0/build/powerpc64-linux-gnu/libsanitizer'
> | make[4]: *** [Makefile:420: all] Error 2
> | make[4]: Leaving directory '/tmp/buildd/gcc3/gcc-12-12.1.0/build/powerpc64-linux-gnu/libsanitizer'
> | make[3]: *** [Makefile:12936: all-target-libsanitizer] Error 2
> | make[3]: Leaving directory '/tmp/buildd/gcc3/gcc-12-12.1.0/build'
> | make[2]: *** [Makefile:1049: all] Error 2
> | make[2]: Leaving directory '/tmp/buildd/gcc3/gcc-12-12.1.0/build'
> | === TIME stamps/05-build-stamp ===

Regardless of how we fix libxcrypt (moving crypt.h back for some
architectures or adding multilib pacages), the libsanitizer issue will
persist. The only option on the libxcrypt side here is adding the
proposed stage1 build profile (but I really don't like that route).

> I've checked that this is the only place in gcc-12 that uses crypt.h and
> that the only thing it uses is sizeof(struct crypt_data), which
> theoretically is architecture-dependent, but practically is not. This is
> why it has worked in the past. Note that this assumption was broken when
> we used musl's crypt.h instead of libxcrypt's.

A possible route here is encoding this assumption into gcc. I'm
attaching patch that does so. I'm not convinced that this is the right
way forward, but it practically fixes the cross toolchain bootstrap.

So does anyone see any better options?

Helmut
--- a/debian/rules2
+++ b/debian/rules2
@@ -1251,6 +1251,13 @@
 	  mkdir -p $(builddir)/sys-include; \
 	  ln -sf /usr/include/$(DEB_TARGET_MULTIARCH)/asm $(builddir)/sys-include/asm; \
 	fi
+	: # Fall back to the host crypt.h when target is unavailable as the sizeof(struct crypt_data) is unlikely to change, needed by libsanitizer.
+	if [ ! -f /usr/include/crypt.h ] && \
+		[ ! -f /usr/include/$(DEB_TARGET_MULTIARCH)/crypt.h ] && \
+		[ -f /usr/include/$(DEB_HOST_MULTIARCH)/crypt.h ]; then \
+	  mkdir -p $(builddir)/sys-include; \
+	  ln -sf /usr/include/$(DEB_HOST_MULTIARCH)/crypt.h $(builddir)/sys-include/crypt.h; \
+	fi

 	touch $(configure_stamp)


Reply to: