[0/2] Replace intl/ with out-of-tree GNU gettext

Message ID 20230925150921.894157-1-arsen@aarsen.me
Headers
Series Replace intl/ with out-of-tree GNU gettext |

Message

Arsen Arsenović Sept. 25, 2023, 3 p.m. UTC
  Afternoon,

This patch series replaces the old (early 2000s era, AFAICT) libintl
implementation in-tree, which relies on C constructs some compilers
(newer clang, hopefully GCC 14) refuse to compile by default with
out-of-tree gettext, in a manner similar to GMP et al, and adds gettext
to download_prerequisites.

Regstrapped on x86_64-pc-linux-gnu --with-included-gettext and all
languages enabled.  Tested for localization on x86_64-pc-linux-gnu,
x86_64-unknown-freebsd13.2, x86_64-darwin21, i686-darwin9 (thanks,
Iain!).

Example from FreeBSD:

  [arsen@fbsd132 ~/gcc-bld/_pfx/bin]$ LANG=sr_RS.UTF-8 ./gcc
  gcc: кобна грешка: нема улазних датотека
  компиловање прекинуто.
  [arsen@fbsd132 ~/gcc-bld/_pfx/bin]$ ldd ./gcc
  ./gcc:
  	libiconv.so.2 => /usr/local/lib/libiconv.so.2 (0x258b24264000)
  	libm.so.5 => /lib/libm.so.5 (0x258b2314b000)
  	libc.so.7 => /lib/libc.so.7 (0x258b25acc000)
  	[vdso] (0x7fffffffe5d0)

OK for trunk (if passing review on the binutils and GDB sides)?

Thanks in advance, have a lovely day.

Arsen Arsenović (2):
  intl: remove, in favor of out-of-tree gettext
  *: add modern gettext

 .gitignore                     |    1 +
 Makefile.def                   |   72 +-
 Makefile.in                    | 1612 +++----
 config/gettext-sister.m4       |   35 +-
 config/gettext.m4              |  357 +-
 config/iconv.m4                |  313 +-
 config/intlmacosx.m4           |   65 +
 configure                      |   44 +-
 configure.ac                   |   44 +-
 contrib/download_prerequisites |    2 +
 contrib/prerequisites.md5      |    1 +
 contrib/prerequisites.sha512   |    1 +
 gcc/Makefile.in                |    8 +-
 gcc/aclocal.m4                 |    4 +
 gcc/configure                  | 2001 +++++++-
 intl/ChangeLog                 |  306 --
 intl/Makefile.in               |  264 -
 intl/README                    |   21 -
 intl/VERSION                   |    1 -
 intl/aclocal.m4                |   33 -
 intl/bindtextdom.c             |  374 --
 intl/config.h.in               |  280 --
 intl/config.intl.in            |   12 -
 intl/configure                 | 8288 --------------------------------
 intl/configure.ac              |  108 -
 intl/dcgettext.c               |   59 -
 intl/dcigettext.c              | 1238 -----
 intl/dcngettext.c              |   60 -
 intl/dgettext.c                |   60 -
 intl/dngettext.c               |   62 -
 intl/eval-plural.h             |  114 -
 intl/explodename.c             |  192 -
 intl/finddomain.c              |  195 -
 intl/gettext.c                 |   64 -
 intl/gettextP.h                |  224 -
 intl/gmo.h                     |  148 -
 intl/hash-string.h             |   59 -
 intl/intl-compat.c             |  151 -
 intl/l10nflist.c               |  453 --
 intl/libgnuintl.h              |  341 --
 intl/loadinfo.h                |  156 -
 intl/loadmsgcat.c              | 1322 -----
 intl/localcharset.c            |  398 --
 intl/localcharset.h            |   42 -
 intl/locale.alias              |   78 -
 intl/localealias.c             |  419 --
 intl/localename.c              |  772 ---
 intl/log.c                     |  104 -
 intl/ngettext.c                |   68 -
 intl/osdep.c                   |   24 -
 intl/plural-config.h           |    1 -
 intl/plural-exp.c              |  156 -
 intl/plural-exp.h              |  132 -
 intl/plural.c                  | 1540 ------
 intl/plural.y                  |  434 --
 intl/relocatable.c             |  439 --
 intl/relocatable.h             |   67 -
 intl/textdomain.c              |  142 -
 libcpp/aclocal.m4              |    5 +
 libcpp/configure               | 2139 ++++++++-
 libstdc++-v3/configure         |  727 +--
 61 files changed, 5398 insertions(+), 21434 deletions(-)
 create mode 100644 config/intlmacosx.m4
 delete mode 100644 intl/ChangeLog
 delete mode 100644 intl/Makefile.in
 delete mode 100644 intl/README
 delete mode 100644 intl/VERSION
 delete mode 100644 intl/aclocal.m4
 delete mode 100644 intl/bindtextdom.c
 delete mode 100644 intl/config.h.in
 delete mode 100644 intl/config.intl.in
 delete mode 100755 intl/configure
 delete mode 100644 intl/configure.ac
 delete mode 100644 intl/dcgettext.c
 delete mode 100644 intl/dcigettext.c
 delete mode 100644 intl/dcngettext.c
 delete mode 100644 intl/dgettext.c
 delete mode 100644 intl/dngettext.c
 delete mode 100644 intl/eval-plural.h
 delete mode 100644 intl/explodename.c
 delete mode 100644 intl/finddomain.c
 delete mode 100644 intl/gettext.c
 delete mode 100644 intl/gettextP.h
 delete mode 100644 intl/gmo.h
 delete mode 100644 intl/hash-string.h
 delete mode 100644 intl/intl-compat.c
 delete mode 100644 intl/l10nflist.c
 delete mode 100644 intl/libgnuintl.h
 delete mode 100644 intl/loadinfo.h
 delete mode 100644 intl/loadmsgcat.c
 delete mode 100644 intl/localcharset.c
 delete mode 100644 intl/localcharset.h
 delete mode 100644 intl/locale.alias
 delete mode 100644 intl/localealias.c
 delete mode 100644 intl/localename.c
 delete mode 100644 intl/log.c
 delete mode 100644 intl/ngettext.c
 delete mode 100644 intl/osdep.c
 delete mode 100644 intl/plural-config.h
 delete mode 100644 intl/plural-exp.c
 delete mode 100644 intl/plural-exp.h
 delete mode 100644 intl/plural.c
 delete mode 100644 intl/plural.y
 delete mode 100644 intl/relocatable.c
 delete mode 100644 intl/relocatable.h
 delete mode 100644 intl/textdomain.c
  

Comments

Xi Ruoyao Sept. 25, 2023, 5:20 p.m. UTC | #1
On Mon, 2023-09-25 at 17:00 +0200, Arsen Arsenović wrote:
> Afternoon,
> 
> This patch series replaces the old (early 2000s era, AFAICT) libintl
> implementation in-tree, which relies on C constructs some compilers
> (newer clang, hopefully GCC 14) refuse to compile by default with
> out-of-tree gettext, in a manner similar to GMP et al, and adds gettext
> to download_prerequisites.

I think we need to update install.texi to mention the new dependency.

And IIUC if --disable-nls is used, we can still build GCC with neither
system gettext nor in-tree gettext.  Or am I wrong?  (I'm asking because
we'll need to adjust Linux From Scratch [1-3] for this change if it's
applied.)

[1]:https://www.linuxfromscratch.org/lfs/view/development/chapter05/gcc-pass1.html
[2]:https://www.linuxfromscratch.org/lfs/view/development/chapter06/gcc-pass2.html
[3]:https://www.linuxfromscratch.org/lfs/view/development/chapter08/gcc.html
  
Arsen Arsenović Sept. 25, 2023, 5:28 p.m. UTC | #2
Xi Ruoyao <xry111@xry111.site> writes:

> On Mon, 2023-09-25 at 17:00 +0200, Arsen Arsenović wrote:
>> Afternoon,
>> 
>> This patch series replaces the old (early 2000s era, AFAICT) libintl
>> implementation in-tree, which relies on C constructs some compilers
>> (newer clang, hopefully GCC 14) refuse to compile by default with
>> out-of-tree gettext, in a manner similar to GMP et al, and adds gettext
>> to download_prerequisites.
>
> I think we need to update install.texi to mention the new dependency.

Ah, thanks.  I had forgotten to update it.  What do you think of the
following prose?

1:  2ac5c8240c0f ! 1:  2cc0029921fb *: add modern gettext
    @@ Commit message
                 * aclocal.m4: Regenerate.
                 * Makefile.in (LIBDEPS): Remove (potential) ./ prefix from
                 LIBINTL_DEP.
    -            * doc/install.texi: Document new (notable) flags added by the optional
    -            gettext tree and by AM_GNU_GETTEXT.
     
         libcpp/ChangeLog:
     
    @@ gcc/configure: $as_echo "$as_me: executing $ac_file commands" >&6;}
          "collect-ld":F) chmod +x collect-ld ;;
          "nm":F) chmod +x nm ;;
     
    - ## gcc/doc/install.texi ##
    -@@ gcc/doc/install.texi: is shown below:
    - @code{sys} and @code{time}.
    - @end table
    - 
    -+@item GNU gettext
    -+
    -+Necessary to build GCC with internationalization support via
    -+@option{--enable-nls}.  It can be downloaded from
    -+@uref{https://gnu.org/s/gettext/}.  If a GNU gettext distribution is
    -+found in a subdirectory of your GCC sources named @file{gettext}, it
    -+will be built together with GCC, unless present in the system (either in
    -+libc or as a stand-alone library).
    -+
    -+The in-tree configuration requires GNU gettext v0.22.
    -+
    - @end table
    - 
    - @heading Tools/packages necessary for modifying GCC
    -@@ gcc/doc/install.texi: components of the binutils you intend to build alongside the compiler
    - (@file{bfd}, @file{binutils}, @file{gas}, @file{gprof}, @file{ld},
    - @file{opcodes}, @dots{}) to the directory containing the GCC sources.
    - 
    --Likewise the GMP, MPFR and MPC libraries can be automatically built
    --together with GCC.  You may simply run the
    -+Likewise the GMP, MPFR, MPC and Gettext libraries can be automatically
    -+built together with GCC.  You may simply run the
    - @command{contrib/download_prerequisites} script in the GCC source directory
    - to set up everything.
    --Otherwise unpack the GMP, MPFR and/or MPC source
    -+Otherwise unpack the GMP, MPFR, MPC and/or Gettext source
    - distributions in the directory containing the GCC sources and rename
    --their directories to @file{gmp}, @file{mpfr} and @file{mpc},
    --respectively (or use symbolic links with the same name).
    -+their directories to @file{gmp}, @file{mpfr}, @file{mpc} and
    -+@file{gettext}, respectively (or use symbolic links with the same name).
    - 
    - @html
    - <hr />
    -@@ gcc/doc/install.texi: which lets GCC output diagnostics in languages other than American
    - English.  Native Language Support is enabled by default if not doing a
    - canadian cross build.  The @option{--disable-nls} option disables NLS@.
    - 
    -+@item --with-libintl-prefix=@var{dir}
    -+@itemx --without-libintl-prefix
    -+Searches for libintl in @file{@var{dir}/include} and
    -+@file{@var{dir}/lib}, or disables manual searching for it, letting the
    -+linker handle it.
    -+
    -+@item --with-libintl-type=@var{type}
    -+Specifies the type of library to search for when looking for libintl.
    -+@var{type} can be one of @code{auto}, @code{static} or @code{shared}.
    -+
    - @item --with-included-gettext
    --If NLS is enabled, the @option{--with-included-gettext} option causes the build
    --procedure to prefer its copy of GNU @command{gettext}.
    -+Only available if @file{gettext} is present in the source tree.
    -+
    -+Forces the gettext tree to be configured to build and use a new static
    -+libintl, overriding the system libintl.
    - 
    - @item --with-catgets
    - If NLS is enabled, and if the host lacks @code{gettext} but has the
    -
      ## libcpp/aclocal.m4 ##
     @@ libcpp/aclocal.m4: m4_include([../config/codeset.m4])
      m4_include([../config/depstand.m4])

Perhaps this is easier to read when not a range-diff..
https://git.sr.ht/~arsen/gcc/commit/2ac5c8240c0f1a670f100c8e38baf40b13cc50b2#gcc/doc/install.texi

> And IIUC if --disable-nls is used, we can still build GCC with neither
> system gettext nor in-tree gettext.  Or am I wrong?  (I'm asking because
> we'll need to adjust Linux From Scratch [1-3] for this change if it's
> applied.)

Yes, this doesn't change how --disable-nls works.

> [1]:https://www.linuxfromscratch.org/lfs/view/development/chapter05/gcc-pass1.html
> [2]:https://www.linuxfromscratch.org/lfs/view/development/chapter06/gcc-pass2.html
> [3]:https://www.linuxfromscratch.org/lfs/view/development/chapter08/gcc.html
  
Bruno Haible Sept. 29, 2023, 11:10 a.m. UTC | #3
Arsen Arsenović wrote:
> -+The in-tree configuration requires GNU gettext v0.22.

Can you change this to "... requires GNU gettext version 0.22 or newer.", please?
I wouldn't like to give the impression that a particular release (0.22) is the
only one that works.
Also, some people may understand 'v' as meaning "version", but some may not.

> +Forces the gettext tree to be configured to build and use a new static
> +libintl, overriding the system libintl.

This sounds like it has no effects on the GCC tree, only on the gettext
tree. Surely that's not the intention?

>    --with-libiconv-prefix[=DIR]  search for libiconv in DIR/include and DIR/lib
>    --without-libiconv-prefix     don't search for libiconv in includedir and libdir
>    --with-libiconv-type=TYPE     type of library to search for (auto/static/shared)
> +  --with-libintl-prefix[=DIR]  search for libintl in DIR/include and DIR/lib
> +  --without-libintl-prefix     don't search for libintl in includedir and libdir
> +  --with-libintl-type=TYPE     type of library to search for (auto/static/shared)

It looks like an additional space in the middle of the last three lines would
provide a better alignment for the 'configure --help' output.

Bruno
  
Arsen Arsenović Sept. 29, 2023, 4:21 p.m. UTC | #4
Bruno Haible <bruno@clisp.org> writes:

> Arsen Arsenović wrote:
>> -+The in-tree configuration requires GNU gettext v0.22.
>
> Can you change this to "... requires GNU gettext version 0.22 or newer.", please?
> I wouldn't like to give the impression that a particular release (0.22) is the
> only one that works.
> Also, some people may understand 'v' as meaning "version", but some may not.

Certainly, good idea.  Thanks for the notes.

>> +Forces the gettext tree to be configured to build and use a new static
>> +libintl, overriding the system libintl.
>
> This sounds like it has no effects on the GCC tree, only on the gettext
> tree. Surely that's not the intention?

Hmm, well, it has no primary effect on the gettext tree, only the
secondary effect of 'if gettext is configured with this flag, then other
parts of the source tree use included over system gettext'.


Do you like the following?

@@ -486,7 +486,7 @@ found in a subdirectory of your GCC sources
 will be built together with GCC, unless present in the system (either in
 libc or as a stand-alone library).
 
-The in-tree configuration requires GNU gettext v0.22.
+The in-tree configuration requires GNU gettext version 0.22 or later.
 
 @end table
 
@@ -2229,7 +2229,8 @@ Specifies the type of library to search
 Only available if @file{gettext} is present in the source tree.
 
 Forces the gettext tree to be configured to build and use a new static
-libintl, overriding the system libintl.
+libintl, overriding the system libintl.  Results in GCC being built
+against the newly built libintl rather than the system libintl.
 
 @item --with-catgets
 If NLS is enabled, and if the host lacks @code{gettext} but has the

I'm open to better wording in the hunk 2 paragraph.

>>    --with-libiconv-prefix[=DIR]  search for libiconv in DIR/include and DIR/lib
>>    --without-libiconv-prefix     don't search for libiconv in includedir and libdir
>>    --with-libiconv-type=TYPE     type of library to search for (auto/static/shared)
>> +  --with-libintl-prefix[=DIR]  search for libintl in DIR/include and DIR/lib
>> +  --without-libintl-prefix     don't search for libintl in includedir and libdir
>> +  --with-libintl-type=TYPE     type of library to search for (auto/static/shared)
>
> It looks like an additional space in the middle of the last three lines would
> provide a better alignment for the 'configure --help' output.

Hmm, I thought that AS_HELP_STRING handles that..  These flags are
(AFAIK) from inside AM_GNU_GETTEXT, so I'm unsure on how to change this
formatting properly.
  
Bruno Haible Sept. 29, 2023, 4:48 p.m. UTC | #5
Arsen Arsenović wrote:
> Do you like the following?
> 
> @@ -486,7 +486,7 @@ found in a subdirectory of your GCC sources
>  will be built together with GCC, unless present in the system (either in
>  libc or as a stand-alone library).
>  
> -The in-tree configuration requires GNU gettext v0.22.
> +The in-tree configuration requires GNU gettext version 0.22 or later.
>  
>  @end table
>  
> @@ -2229,7 +2229,8 @@ Specifies the type of library to search
>  Only available if @file{gettext} is present in the source tree.
>  
>  Forces the gettext tree to be configured to build and use a new static
> -libintl, overriding the system libintl.
> +libintl, overriding the system libintl.  Results in GCC being built
> +against the newly built libintl rather than the system libintl.
>  
>  @item --with-catgets
>  If NLS is enabled, and if the host lacks @code{gettext} but has the

Yes, that's better. Thanks!

> >>    --with-libiconv-prefix[=DIR]  search for libiconv in DIR/include and DIR/lib
> >>    --without-libiconv-prefix     don't search for libiconv in includedir and libdir
> >>    --with-libiconv-type=TYPE     type of library to search for (auto/static/shared)
> >> +  --with-libintl-prefix[=DIR]  search for libintl in DIR/include and DIR/lib
> >> +  --without-libintl-prefix     don't search for libintl in includedir and libdir
> >> +  --with-libintl-type=TYPE     type of library to search for (auto/static/shared)
> >
> > It looks like an additional space in the middle of the last three lines would
> > provide a better alignment for the 'configure --help' output.
> 
> Hmm, I thought that AS_HELP_STRING handles that..  These flags are
> (AFAIK) from inside AM_GNU_GETTEXT, so I'm unsure on how to change this
> formatting properly.

Ah, indeed. Then you cannot change it.

Bruno