In file included from /tmp/portage/cross-mips-unknown-linux-gnu/gcc-8.1.0-r1/work/gcc-8.1.0/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc:20: /tmp/portage/cross-mips-unknown-linux-gnu/gcc-8.1.0-r1/work/gcc-8.1.0/libsanitizer/sanitizer_common/sanitizer_internal_defs.h:317:72: error: size of array ‘assertion_failed__71’ is negative typedef char IMPL_PASTE(assertion_failed_##_, line)[2*(int)(pred)-1] ^ /tmp/portage/cross-mips-unknown-linux-gnu/gcc-8.1.0-r1/work/gcc-8.1.0/libsanitizer/sanitizer_common/sanitizer_internal_defs.h:311:30: note: in expansion of macro ‘IMPL_COMPILER_ASSERT’ #define COMPILER_CHECK(pred) IMPL_COMPILER_ASSERT(pred, __LINE__) ^~~~~~~~~~~~~~~~~~~~ /tmp/portage/cross-mips-unknown-linux-gnu/gcc-8.1.0-r1/work/gcc-8.1.0/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc:71:1: note: in expansion of macro ‘COMPILER_CHECK’ COMPILER_CHECK(struct_kernel_stat_sz == sizeof(struct stat)); ^~~~~~~~~~~~~~ I think it is caused by this patch: https://github.com/gcc-mirror/gcc/commit/36093749ff955d9e8cf208b04724c3a1a2ac9b04 libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h #elif defined(__mips__) const unsigned struct_kernel_stat_sz = SANITIZER_ANDROID ? FIRST_32_SECOND_64(104, 128) : - FIRST_32_SECOND_64(144, 216); + FIRST_32_SECOND_64(160, 216);
GCC was configures as: /tmp/portage/cross-mips-unknown-linux-gnu/gcc-8.1.0-r1/work/gcc-8.1.0/configure --host=x86_64-pc-linux-gnu --target=mips-unknown-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/mips-unknown-linux-gnu/gcc-bin/8.1.0 --includedir=/usr/lib/gcc/mips-unknown-linux-gnu/8.1.0/include --datadir=/usr/share/gcc-data/mips-unknown-linux-gnu/8.1.0 --mandir=/usr/share/gcc-data/mips-unknown-linux-gnu/8.1.0/man --infodir=/usr/share/gcc-data/mips-unknown-linux-gnu/8.1.0/info --with-gxx-include-dir=/usr/lib/gcc/mips-unknown-linux-gnu/8.1.0/include/g++-v8 --with-python-dir=/share/gcc-data/mips-unknown-linux-gnu/8.1.0/python --enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion=Gentoo 8.1.0-r1 p1.1 --disable-esp --enable-libstdcxx-time --enable-poison-system-directories --with-sysroot=/usr/mips-unknown-linux-gnu --disable-bootstrap --enable-__cxa_atexit --enable-clocale=gnu --disable-multilib --disable-altivec --disable-fixed-point --with-abi= --disable-libgcj --enable-libgomp --disable-libmudflap --disable-libssp --disable-libmpx --enable-vtable-verify --enable-libvtv --enable-lto --without-isl --enable-libsanitizer --enable-default-pie --enable-default-ssp
> - FIRST_32_SECOND_64(144, 216); > + FIRST_32_SECOND_64(160, 216); I think mips has really 3 stat values: 32 ABI: 144 n32 ABI: 160 64 ABI: 216 $ cat a.c #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> int main() { return sizeof(struct stat); } $ mips-unknown-linux-gnu-gcc -E -dM - </dev/null | fgrep MIPS_SIM #define _MIPS_SIM _ABIO32 $ mips-unknown-linux-gnu-gcc -S -O2 a.c && grep '[^a]li' a.s li $2,144 # 0x90 $ mips64-unknown-linux-gnu-gcc -E -dM - </dev/null | fgrep MIPS_SIM #define _MIPS_SIM _ABIN32 $ mips64-unknown-linux-gnu-gcc -S -O2 a.c && grep '[^a]li' a.s li $2,160 # 0xa0
Created attachment 44077 [details] gcc-8.1.0-mips-o32-asan.patch gcc-8.1.0-mips-o32-asan.patch is enough to get asan cross-compiled on o32 ABI.
GCC 8.2 has been released.
CCing Hans-Peter, who has enabled libsanitizer on mips*. If this needs to be done, it should be ideally pushed upstream first and then cherry-picked.
Hans-Peter, any comments on this?
(In reply to Jakub Jelinek from comment #6) > Hans-Peter, any comments on this? (In reply to Sergei Trofimovich from comment #2) > > - FIRST_32_SECOND_64(144, 216); > > + FIRST_32_SECOND_64(160, 216); > > I think mips has really 3 stat values: > 32 ABI: 144 > n32 ABI: 160 > 64 ABI: 216 > > $ cat a.c > #include <sys/types.h> > #include <sys/stat.h> > #include <unistd.h> > > int main() { > return sizeof(struct stat); > } This is misleading. What needs to be checked is the size of the *kernel* stat. See https://gcc.gnu.org/ml/gcc-patches/2018-03/msg01263.html where I fixed it correctly and explained the issue. I'm guessing a later import unfixed it, but I'll go check. I'm changing the related version (8.0.1 -> 8.1.0), as from the comments it seems obvious that this is 8.1.0 (and later, presumably?), not 8.0.1.
The report is misleading regarding version, thus I'm resetting the versions. For mips, sanitizer support was neither in gcc-8.0.1 nor gcc-8.1.0 nor gcc-8.2.0. I suppose the reporter meant "trunk after gcc-8.0.1", but is confused by the change in versioning scheme. (As was I, trying to correct the information in the report. I'm not sure I have it correct even now...) Reporter, please confirm or correct.
(In reply to Hans-Peter Nilsson from comment #8) > The report is misleading regarding version, thus I'm resetting the versions. > For mips, sanitizer support was neither in gcc-8.0.1 nor gcc-8.1.0 nor > gcc-8.2.0. I suppose the reporter meant "trunk after gcc-8.0.1", but is > confused by the change in versioning scheme. > (As was I, trying to correct the information in the report. I'm not sure I > have it correct even now...) > > Reporter, please confirm or correct. Original bug was reported against gcc-8.1.0. Apologies for the confusion. gcc-8.2.0 has the same problem. With workaround it manages to build and install asan libraries: /usr/lib/gcc/mips-unknown-linux-gnu/8.2.0/include/sanitizer/asan_interface.h /usr/lib/gcc/mips-unknown-linux-gnu/8.2.0/plugin/include/asan.h /usr/lib/gcc/mips-unknown-linux-gnu/8.2.0/libasan.a /usr/lib/gcc/mips-unknown-linux-gnu/8.2.0/libasan.so /usr/lib/gcc/mips-unknown-linux-gnu/8.2.0/libasan.so.5 /usr/lib/gcc/mips-unknown-linux-gnu/8.2.0/libasan.so.5.0.0 /usr/lib/gcc/mips-unknown-linux-gnu/8.2.0/libasan_preinit.o I'm a bit confused by lack of sanitizer support. I guess you mean that libsanitizer/configure.tgt has no mips entry and should fail ./configure or silently skip sanitizer build/install.
That is not really possible, as libsanitizer/configure.tgt in 8.x doesn't support mips at all, only GCC 9 has added: + mips*64*-*-linux*) + # This clause is only here to not match the supported mips*-*-linux*. + UNSUPPORTED=1 + ;; + mips*-*-linux*) + ;; lines to libsanitizer/configure.tgt, before that it would fall through to: *) UNSUPPORTED=1 ;; which then means the toplevel configury doesn't build libsanitizer at all: # Disable libsanitizer on unsupported systems. if test -d ${srcdir}/libsanitizer; then if test x$enable_libsanitizer = x; then AC_MSG_CHECKING([for libsanitizer support]) if (srcdir=${srcdir}/libsanitizer; \ . ${srcdir}/configure.tgt; \ test -n "$UNSUPPORTED") then AC_MSG_RESULT([no]) noconfigdirs="$noconfigdirs target-libsanitizer" else AC_MSG_RESULT([yes]) fi fi fi Of course, unless you are patching this in gcc 8.x somehow, but then you are on your own.
Ah, no, you are forcing it to ignore that through --enable-libsanitizer. Don't do that for unsupported targets.
(In reply to Sergei Trofimovich from comment #9) > (In reply to Hans-Peter Nilsson from comment #8) > > The report is misleading regarding version, thus I'm resetting the versions. > > For mips, sanitizer support was neither in gcc-8.0.1 nor gcc-8.1.0 nor > > gcc-8.2.0. I suppose the reporter meant "trunk after gcc-8.0.1", but is > > confused by the change in versioning scheme. > > (As was I, trying to correct the information in the report. I'm not sure I > > have it correct even now...) > > > > Reporter, please confirm or correct. > > Original bug was reported against gcc-8.1.0. Apologies for the confusion. > > gcc-8.2.0 has the same problem. Oh, I missed the --enable-libsanitizer option. You really have a *huge* list of configure options there. > With workaround it manages to build and > install asan libraries: > > > /usr/lib/gcc/mips-unknown-linux-gnu/8.2.0/include/sanitizer/asan_interface.h > /usr/lib/gcc/mips-unknown-linux-gnu/8.2.0/plugin/include/asan.h > /usr/lib/gcc/mips-unknown-linux-gnu/8.2.0/libasan.a > /usr/lib/gcc/mips-unknown-linux-gnu/8.2.0/libasan.so > /usr/lib/gcc/mips-unknown-linux-gnu/8.2.0/libasan.so.5 > /usr/lib/gcc/mips-unknown-linux-gnu/8.2.0/libasan.so.5.0.0 > /usr/lib/gcc/mips-unknown-linux-gnu/8.2.0/libasan_preinit.o > > I'm a bit confused by lack of sanitizer support. I was too, but that's (supposedly) fixed on trunk, modulo effects from later sanitizer imports. Care to try it out on a 9.0 snapshot? We can keep this PR open if you notice issues, otherwise I think it's time to close it as invalid. > I guess you mean that libsanitizer/configure.tgt has no mips entry and > should fail ./configure or silently skip sanitizer build/install. As Jakub says; by default, yes.
I didn't realize --enable-sanitizer has such an overriding effect. Having looked at top-level configure.ac I now see that similar behaviour is applied to other libraries. We'll change downstream and stop passing explicit --enable-sanitizer flag at least on mips. I'll open a new bug if gcc-9's sanitizer fails on mips. Thanks all!