https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83492

            Bug ID: 83492
           Summary: [7 Regression] Optimized search_line_fast breaks
                    preprocessor on aarch64_be
           Product: gcc
           Version: 7.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: preprocessor
          Assignee: unassigned at gcc dot gnu.org
          Reporter: michael at weiser dot dinsnail.net
  Target Milestone: ---

Created attachment 42920
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42920&action=edit
patch to fix search_line_fast for aarch64_be

Running the preprocessor on any source gives various errors on aarch64_be.
These suggest that the proprocessor misidentifies token boundaries:

$ echo "#define FOO 1" > t.h
$ gcc -nostdinc -E t.h
# 1 "t.h"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "t.h"
t.h:1:2: error: invalid preprocessing directive #defi
 #define FOO 1
  ^~~~


 FOO 1
$ echo -e "\n#include <somefile>" > t.h
$ gcc -nostdinc -E t.h
# 1 "t.h"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "t.h"

 <s

efile>

This can be traced to an optimized search_line_fast for aarch64 in libcpp/lex.c
which has a special provision for aarch64_be based on the __AARCH64EB. This
check can never succeed since the correct name of the macro is __AARCH64EB__.
Consequently the code for big-endian aarch64 is never activated:

#ifdef __AARCH64EB
  const int16x8_t shift = {8, 8, 8, 8, 0, 0, 0, 0};
#else
  const int16x8_t shift = {0, 0, 0, 0, 8, 8, 8, 8};
#endif

As expected, changing __AARCH64EB to __AARCH64EB__ or disabling the accelerated
routine by substituting search_line_acc_char() fixes the problem.

The offending code is present in current trunk as well:
https://gcc.gnu.org/viewcvs/gcc/trunk/libcpp/lex.c?revision=254707&view=markup#l775.

# gcc -v
Using built-in specs.
COLLECT_GCC=/usr/aarch64_be-unknown-linux-gnu/gcc-bin/7.2.0/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/aarch64_be-unknown-linux-gnu/7.2.0/lto-wrapper
Target: aarch64_be-unknown-linux-gnu
Configured with:
/usr/aarch64_be-unknown-linux-gnu/tmp/portage/sys-devel/gcc-7.2.0/work/gcc-7.2.0/configure
--host=aarch64_be-unknown-linux-gnu --target=aarch64_be-unknown-linux-gnu
--build=x86_64-pc-linux-gnu --prefix=/usr
--bindir=/usr/aarch64_be-unknown-linux-gnu/gcc-bin/7.2.0
--includedir=/usr/lib/gcc/aarch64_be-unknown-linux-gnu/7.2.0/include
--datadir=/usr/share/gcc-data/aarch64_be-unknown-linux-gnu/7.2.0
--mandir=/usr/share/gcc-data/aarch64_be-unknown-linux-gnu/7.2.0/man
--infodir=/usr/share/gcc-data/aarch64_be-unknown-linux-gnu/7.2.0/info
--with-gxx-include-dir=/usr/lib/gcc/aarch64_be-unknown-linux-gnu/7.2.0/include/g++-v7
--with-python-dir=/share/gcc-data/aarch64_be-unknown-linux-gnu/7.2.0/python
--enable-languages=c,c++ --enable-obsolete --enable-secureplt --disable-werror
--with-system-zlib --disable-nls --enable-checking=release
--with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 7.2.0 p1.1'
--disable-esp --enable-libstdcxx-time --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu --enable-multilib --disable-altivec
--disable-fixed-point --disable-libgcj --disable-libgomp --disable-libmudflap
--disable-libssp --disable-libcilkrts --disable-libmpx --enable-vtable-verify
--enable-libvtv --disable-libquadmath --enable-lto --without-isl
--enable-libsanitizer --enable-default-pie --enable-default-ssp
--with-native-system-header-dir=/usr/aarch64_be-unknown-linux-gnu/usr/include
Thread model: posix
gcc version 7.2.0 (Gentoo 7.2.0 p1.1)

Reply via email to