foss-for-synopsys-dwc-arc-processors / toolchain

Repository containing releases of prebuilt GNU toolchains for DesignWare ARC Processors from Synopsys (available from "releases" link below).
http://www.synopsys.com/IP/ProcessorIP/ARCProcessors/Pages/default.aspx
GNU General Public License v3.0
91 stars 48 forks source link

[GCC] Build fails because of ">=0" of unsigneds #459

Closed shahab-vahedi closed 1 year ago

shahab-vahedi commented 3 years ago

My x86_64 GCC version: gcc (GCC) 10.2.1 20201203 ARC64 GCC commit: 80711e9378 arc64: Add Vectorizer cost hook.


$ cd arc-gnu-toolchain
$ autoconf
$ ./configure --prefix=/path/to/install
$ make -j $(nproc)
...
ctype_members.cc: In member function 'virtual char std::ctype<wchar_t>::do_narrow(wchar_t, char) const':
ctype_members.cc:216:14: error: comparison of unsigned expression in '>= 0' is always true [-Werror=type-limits]
  216 |     if (__wc >= 0 && __wc < 128 && _M_narrow_ok)
      |         ~~~~~^~~~
ctype_members.cc: In member function 'virtual const wchar_t* std::ctype<wchar_t>::do_narrow(const wchar_t*, const wchar_t*, char, char*) const':
ctype_members.cc:230:14: error: comparison of unsigned expression in '>= 0' is always true [-Werror=type-limits]
  230 |    if (*__lo >= 0 && *__lo < 128)
      |        ~~~~~~^~~~
cc1plus: all warnings being treated as errors
make[6]: *** [Makefile:643: ctype_members.lo] Error 1
shahab-vahedi commented 3 years ago
$ ./configure --disable-werror ...

works around this.

abrodkin commented 3 years ago

Label arc64?

shahab-vahedi commented 2 years ago

For ARCv3, this file is copied from src/gcc/libstdc++-v3/config/locale/newlib/ctype_members.cc into the build dir (build-gcc-newlib-stage2/arc64-elf/libstdc++-v3/src/c++11/ctype_members.cc) and then is built. For ARCv2, although this file does exist in the source gcc, it never is copied into the build dir (and compiled?). @claziss a few questions:

1) Do we really need this for arc64? 2) Is the wchar_t type target dependent? If yes, maybe we can fix it from our side. 3) If the answer to (2) is "no", then I will fix this upstream.

claziss commented 2 years ago

For ARCv3, this file is copied from src/gcc/libstdc++-v3/config/locale/newlib/ctype_members.cc into the build dir (build-gcc-newlib-stage2/arc64-elf/libstdc++-v3/src/c++11/ctype_members.cc) and then is built. For ARCv2, although this file does exist in the source gcc, it never is copied into the build dir (and compiled?). @claziss a few questions:

1. Do we really need this for arc64?

2. Is the `wchar_t` type target dependent? If yes, maybe we can fix it from our side.

3. If the answer to (2) is "no", then I will fix this upstream.

AFAIK this file is compiled for ARCv2 too.

shahab-vahedi commented 2 years ago

Then it is not copied to build dir like the arc64 build that I had. Maybe it has something to do with "multilib" building. Nevertheless, you skipped answering the questions.

shahab-vahedi commented 2 years ago

Through personal communication, @claziss 's response:

1. Do we really need this for arc64?
Yes. ctype_members.cc is part of wchar_t (wide chars) support.

2. Is the `wchar_t` type target dependent?
Yes. It is "int" for ARCv2 and "unsigned int" for ARCv3.
claziss commented 2 years ago
  1. ctype_members.cc is part of wchar_t support, so we do need it if we support wide chars.
  2. it is target dependent.
claziss commented 2 years ago

I've changed the ABI to reflect what we were doing in ARCv2. Fix here: https://github.com/foss-for-synopsys-dwc-arc-processors/gcc/commit/9aa6ae66c99ea77a0d3bed00db498e38ddc594f4

abrodkin commented 2 years ago

@claziss do we want it in arc-2021.09 branch as well?