Commit Graph

1426 Commits

Author SHA1 Message Date
GCC Administrator 7f57e04ce4 Daily bump. 2025-10-05 16:50:51 +00:00
H.J. Lu 6051a849aa Sync toplevel files from binutils-gdb
commit aef88b83384976e96a8fb287a001588a2277ecd5
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Oct 2 08:53:45 2025 +0800

    binutils/GCC: Quote ${COMPILER_FOR_TARGET}

    Replace

    if test x${COMPILER_FOR_TARGET} = x"\$(CC)"; then

    with

    if test x"${COMPILER_FOR_TARGET}" = x"\$(CC)"; then

    since COMPILER_FOR_TARGET may contain spaces when configuring GCC.

commit 76a693c087c30e8108852928c717399011c6166d
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Sep 30 11:23:58 2025 +0800

    binutils: Use AC_TRY_COMPILE to check target clang/gcc

    Use AC_TRY_COMPILE to check for the working target clang and gcc when
    configuring for cross tools.

commit 77c74294bfc5005204a2de3cc64bbdb2f877be29
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Sep 26 08:03:01 2025 +0800

    binutils: Pass target plugin file to target ar/nm/ranlib

    There are 2 kinds of binutils tests:

    1. Tests of binutils object files and libraries using the build tools,
    like CC, AR, NM and RANLIB.
    2. Tests of binutils programs as the target tools, like CC_FOR_TARGET,
    AR_FOR_TARGET, NM_FOR_TARGET and RANLIB_FOR_TARGET.

    Set AR_PLUGIN_OPTION_FOR_TARGET, NM_PLUGIN_OPTION_FOR_TARGET and
    RANLIB_PLUGIN_OPTION_FOR_TARGET to the target compiler plugin file for
    target ar/nm/ranlib.

commit 10deea6e2fc1b9ec5818b5fa1bc510c63ff5b2e2
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Sep 23 04:24:00 2025 +0800

    Binutils/GCC: Add clang LTO support to AR, NM and RANLIB

    Add CLANG_PLUGIN_FILE to find the clang plugin file and pass it to
    --plugin for ar, nm and ranlib so that binutils can be built with
    clang LTO.  Run CLANG_PLUGIN_FILE before GCC_PLUGIN_OPTION since
    GCC_PLUGIN_OPTION may return the wrong PLUGIN_OPTION with clang.

commit 1fcb94ed750db2ac30d0f0ecc04fa0c7833dd10f
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Thu Sep 18 16:17:14 2025 +0200

    Remove remnants of Solaris/PowerPC support

    When removing Solaris/PowerPC support, I missed a couple of references.
    This patch removes them.

    Tested with crosses to ppc-unknown-linux-gnu and powerpc-ibm-aix7.

ChangeLog:

	* Makefile.in: Regenerated.
	* configure: Likewise.
	* Makefile.tpl: Synced from binutils-gdb.
	* configure.ac: Likewise.
	* libtool.m4: Likewise.

config/ChangeLog:

	* clang-plugin.m4: Synced from binutils-gdb.
	* gcc-plugin.m4: Likewise.

libbacktrace/ChangeLog:

	* Makefile.in: Regenerated.
	* aclocal.m4: Likewise.
	* configure: Likewise.

libiberty/ChangeLog:

	* aclocal.m4: Regenerated.
	* configure: Likewise.
	* configure.ac: Synced from binutils-gdb.

zlib/ChangeLog:

	* Makefile.in: Regenerated.
	* aclocal.m4: Likewise.
	* configure: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-10-02 15:00:06 +08:00
GCC Administrator b42c5ee445 Daily bump. 2025-08-17 00:19:17 +00:00
Nathaniel Shead 7921bb4afc c++: Implement P2115R0 linkage changes for unnamed unscoped enums [PR120503]
We currently list P2115R0 as implemented, but only the modules changes
had been done.  This patch implements the linkage changes so that
unnamed unscoped enums will use the name of the first enumerator for
linkage purposes.

This is (strictly speaking) a breaking change, as code that previously
relied on unnamed enumerations being internal linkage may have overloads
using those types become exposed and clash with other functions in a
different TU that have been similarly exposed.  As such this feature is
only implemented for C++20.

No ABI flag warning is provided, partly because C++20 is still an
experimental standard, but also because any affected functions could not
have been part of an ABI until this change anyway.

A number of testcases that are testing for behaviour of no-linkage types
are adjusted to use an enumeration with no values, so that the pre-C++20
and post-C++20 behaviour is equivalently tested.

In terms of implementation, I had originally considered adjusting the
DECL_NAME of the enum, as with 'name_unnamed_type', but this ended up
being more complicated as it had unwanted interactions with the existing
modules streaming and with name lookup and diagnostic messages.  This
patch instead uses a new function to derive this case.

The standard says that ([dcl.enum] p11) such an enum "...is denoted, for
linkage purposes, by its underlying type and its first enumerator", so
we need to add a new mangling production as well to handle this.

	PR c++/120503
	PR c++/120824

gcc/cp/ChangeLog:

	* cp-tree.h (TYPE_UNNAMED_P): Adjust for enums with enumerators
	for linkage purposes.
	(enum_with_enumerator_for_linkage_p): Declare.
	* decl.cc (name_unnamed_type): Adjust assertions to handle enums
	with enumerators for linkage purposes.
	(grokdeclarator): Use a typedef name for enums with enumerators
	for linkage purposes.
	(enum_with_enumerator_for_linkage_p): New function.
	(finish_enum_value_list): Reset type linkage for enums with
	enumerators for linkage purposes.
	* mangle.cc (write_unnamed_enum_name): New function.
	(write_unqualified_name): Handle enums with enumerators for
	linkage purposes.
	* tree.cc (decl_linkage): Fixup unnamed enums.

gcc/testsuite/ChangeLog:

	* g++.dg/abi/mangle32.C: Remove enumerator list.
	* g++.dg/cpp0x/linkage2.C: Likewise.
	* g++.dg/ext/vector26.C: Likewise.
	* g++.dg/other/anon3.C: Likewise.
	* g++.dg/abi/mangle83.C: New test.
	* g++.dg/modules/enum-15_a.C: New test.
	* g++.dg/modules/enum-15_b.C: New test.

include/ChangeLog:

	* demangle.h (enum demangle_component_type): Add enumeration
	DEMANGLE_COMPONENT_UNNAMED_ENUM.

libiberty/ChangeLog:

	* cp-demangle.c (d_unnamed_enum): New function.
	(d_unqualified_name): Call it.
	(cplus_demangle_type): Handle unscoped unnamed types
	(Ue, Ul, etc.)
	(d_count_templates_scopes): Handle unnamed enums.
	(d_find_pack): Likewise.
	(d_print_comp_inner): Print unnamed enums.
	* testsuite/demangle-expected: Add tests.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
2025-08-17 10:14:14 +10:00
GCC Administrator 6520bb9efb Daily bump. 2025-08-14 00:20:55 +00:00
Jakub Jelinek 0f665822a0 libiberty: Fix comment typo
This patch fixes a comment typo, whaever -> whatever, prompted by the
recent hae -> has typo fix.

2025-08-13  Jakub Jelinek  <jakub@redhat.com>

	* cp-demangle.c (d_encoding): Fix a comment typo, whaever -> whatever.
2025-08-13 22:26:54 +02:00
GCC Administrator ca2169c65b Daily bump. 2025-08-07 00:20:46 +00:00
Matthieu Longo 0d0837df69 libiberty: disable logging of list content for doubly-linked list tests
When the doubly-linked list tests were introduced, the tests were
printing the content of the list forward and backward. However, this
printing is not needed outside of debugging, and confuses people because
the output is not only composed of PASS: lines.

This patch disables the printing of the list content by default. If
one wants to re-enable it for debugging, he can set the macro DUMP_LIST
to 1.

libiberty/ChangeLog:

	* testsuite/test-doubly-linked-list.c: disable debug logging on
	stdout.
2025-08-06 15:25:22 +01:00
GCC Administrator 285422c70e Daily bump. 2025-07-10 00:20:18 +00:00
Matthieu Longo 0fd98b6f9f libiberty: add routines to handle type-sensitive doubly linked lists
Those methods's implementation is relying on duck-typing at compile
time.
The structure corresponding to the node of a doubly linked list needs
to define attributes 'prev' and 'next' which are pointers on the type
of a node.
The structure wrapping the nodes and others metadata (first, last, size)
needs to define pointers 'first', and 'last' of the node's type, and
an integer type for 'size'.

Mutative methods can be bundled together and be declarable once via a
same macro, or can be declared separately. The merge sort is bundled
separately.
There are 3 types of macros:
1. for the declaration of prototypes: to use in a header file for a
   public declaration, or as a forward declaration in the source file
   for private declaration.
2. for the declaration of the implementation: to use always in a
   source file.
3. for the invocation of the functions.

The methods can be declared either public or private via the second
argument of the declaration macros.

List of currently implemented methods:
- LINKED_LIST_*:
    - APPEND: insert a node at the end of the list.
    - PREPEND: insert a node at the beginning of the list.
    - INSERT_BEFORE: insert a node before the given node.
    - POP_FRONT: remove the first node of the list.
    - POP_BACK: remove the last node of the list.
    - REMOVE: remove the given node from the list.
    - SWAP: swap the two given nodes in the list.
- LINKED_LIST_MERGE_SORT: a merge sort implementation.

include/ChangeLog:

	* doubly-linked-list.h: New file.

libiberty/ChangeLog:

	* Makefile.in: Add new header.
	* testsuite/Makefile.in: Add new test.
	* testsuite/test-doubly-linked-list.c: New test.
2025-07-09 16:15:55 +01:00
GCC Administrator 92430eec52 Daily bump. 2025-05-14 00:18:21 +00:00
Andreas Schwab 43717ee906 libiberty: Fix off-by-one when collecting range expression
Fixes this error during build of fixincludes:

In function ‘byte_regex_compile’,
    inlined from ‘xregcomp’ at ../libiberty/../../libiberty/regex.c:7973:11:
../libiberty/../../libiberty/regex.c:3477:29: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
 3477 |                     str[c1] = '\0';
      |                             ^
../libiberty/../../libiberty/regex.c: In function ‘xregcomp’:
../libiberty/../../libiberty/regex.c:3454:35: note: at offset 128 into destination object ‘str’ of size 128
 3454 |                     unsigned char str[128];     /* Should be large enough.  */
      |                                   ^

	* regex.c (regex_compile): Don't write beyond array bounds when
	collecting range expression.
2025-05-13 09:51:49 +02:00
GCC Administrator cc63163f0a Daily bump. 2025-03-30 00:16:46 +00:00
Iain Sandoe 9018336252 libiberty, gcc: Add memrchr to libiberty and use it [PR119283].
This adds an implementation of memrchr to libiberty and arranges
to configure gcc to use it, if the host does not have it.

	PR cobol/119283

gcc/ChangeLog:

	* config.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Check for host memrchr.

include/ChangeLog:

	* libiberty.h (memrchr): New.

libiberty/ChangeLog:

	* Makefile.in: Add memrchr build rules.
	* config.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Check for memrchr.
	* functions.texi: Document memrchr.
	* memrchr.c: New file.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2025-03-29 13:53:22 +00:00
GCC Administrator 7d414e11ac Daily bump. 2025-03-26 00:17:07 +00:00
Iain Sandoe f3d07779fd libiberty: Append <libgen.h> to AC_CHECK_DECLS [PR119218].
Darwin and Solaris, at least, provide basename() in libc, but only
declare it in <libgen.h>.  That library is not one of the set in
AC_INCLUDES_DEFAULT and so we fail the config test and fall back
to the libiberty-provided version.  In itself, this is not an
issue; however, if we include <libgen.h> and libiberty.h in the same
TU we do then get a decl conflict.

	PR other/119218

libiberty/ChangeLog:

	* config.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Append <libgen.h> to AC_INCLUDES_DEFAULT
	when checking for the 'basename' decl.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2025-03-25 19:29:12 +00:00
GCC Administrator a03e863975 Daily bump. 2025-03-19 00:17:56 +00:00
Jose E. Marchesi 31dd621796 libiberty: add ldirname function
This patch adds a function ldirname to libiberty.  It is implemented
in terms of lbasename.  Basically, given a given pathname, the dirname
part is what is not the basename minus the last directory separator
separating the dirname with the basename.

include/ChangeLog

	* libiberty.h (ldirname): New function declaration.
	(dos_ldirname): Likewise.
	(unix_ldirname): Likewise.

libiberty/ChangeLog

	* ldirname.c: New file.
	* Makefile.in (CFILES): Add ldirname.c.
	(REQUIRED_OFILES): Add ldirname.$(objext).
	(./ldirname.$(objext)): New rule.
	* makefile.vms (OBJS): Add ldirname.obj.
	* configure.com (FILES): Add ldirname.
2025-03-18 11:19:48 +01:00
Jakub Jelinek 6441eb6dc0 Update copyright years. 2025-01-02 11:59:57 +01:00
GCC Administrator 24822c0942 Daily bump. 2024-12-12 00:19:00 +00:00
Matthieu Longo f78b4da602 autoupdate: replace obsolete macros in libiberty
Autoreconf-2.72 warns about obsolete macros. This patch aims at removing
the noise from a future upgrade to autoreconf-2.72 or later. This is in
no a way a complete patch allowing the upgrade to autoreconf-2.72.

- AC_GNU_SOURCE by AC_USE_SYSTEM_EXTENSIONS
  https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.72/
  autoconf.html#index-AC_005fGNU_005fSOURCE-1
- AC_CONFIG_HEADER by AC_CONFIG_HEADERS
  https://www.gnu.org/software/automake/manual/1.12.2/html_node/Obsolete-
  Macros.html#index-AM_005fCONFIG_005fHEADER

Those fixes were originally submitted in a patch series in binutils.
https://inbox.sourceware.org/binutils/878qthm6a0.fsf@gentoo.org/

libiberty/ChangeLog:

	* configure: Regenerate.
	* configure.ac: Fix autoupdate warnings.
2024-12-11 11:17:01 +00:00
Sangamesh Mallayya e76df35864 aix: Resolve build failure with default C23
libiberty/getopt.c file is defining _NO_PROTO, which causes
conflicting declarations for the functions in AIX header files
like stdio.h & stdlib.h.
Looks like _NO_PROTO define were added long back and conflicting
declarations were always present until C23 standard uncovered it.

Remove the block defining _NO_PROTO as both Tru64 UNIX (ex-OSF/1)
and AIX 3.2 is no more supported.

libiberty/ChangeLog:

	* getopt.c: Remove _NO_PROTO block
2024-12-11 03:54:50 -06:00
GCC Administrator b597edbdfb Daily bump. 2024-11-20 00:19:59 +00:00
Evgeny Karpov 961c504109 Add LTO support
The patch reuses the configuration for LTO from ix86 and adds the
aarch64 architecture to the list of supported COFF headers.

gcc/ChangeLog:

	* config/aarch64/cygming.h (TARGET_ASM_LTO_START): New.
	(TARGET_ASM_LTO_END): Likewise.
	* config/i386/cygming.h (TARGET_ASM_LTO_START): Update.
	(TARGET_ASM_LTO_END): Likewise.
	* config/i386/i386-protos.h (i386_pe_asm_lto_start): Delete.
	(i386_pe_asm_lto_end): Likewise.
	* config/mingw/winnt.cc (i386_pe_asm_lto_start): Rename
	into ...
	(mingw_pe_asm_lto_start): ... this.
	(i386_pe_asm_lto_end): Rename into ...
	(mingw_pe_asm_lto_end): ... this.
	* config/mingw/winnt.h (mingw_pe_asm_lto_start): New.
	(mingw_pe_asm_lto_end): Likewise.

libiberty/ChangeLog:

	* simple-object-coff.c: Add aarch64.
2024-11-19 14:27:33 +01:00
GCC Administrator a649efea00 Daily bump. 2024-11-17 00:21:19 +00:00
Andrew Pinski 94bea5dd6c libiberity: ANSIfy test-demangle.c
Some of the function definitions used K&R style definitions (but not all).
This just moves them all to be ANSI C

Bootstrapped and tested on x86_64-linux-gnu.

libiberty/ChangeLog:

	* testsuite/test-demangle.c (get_line): Change K&R style
	definition into ANSI C90 definitions.
	(fail): Likewise.
	(main): Likewise.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2024-11-16 11:10:48 -08:00
GCC Administrator 441676b588 Daily bump. 2024-11-02 00:19:21 +00:00
Mark Wielaard aa84020b2e libiberty: Fix comment typos
These comment typos were found in the valgrind fork of libiberty
demangle code.

libiberty/ChangeLog:

	* cplus-dem.c: Change preceeded to preceded.

include/ChangeLog:

	* safe-ctype.h: Change accidently to accidentally.
2024-10-31 22:07:18 +01:00
GCC Administrator ccd7ede939 Daily bump. 2024-10-11 00:17:48 +00:00
Simon Martin c1b2100e73 libiberty: Restore build with CP_DEMANGLE_DEBUG defined
cp-demangle.c does not build when CP_DEMANGLE_DEBUG is defined since
r13-2887-gb04208895fed34. This trivial patch fixes the issue.

libiberty/ChangeLog:

	* cp-demangle.c (d_dump): Fix compilation when CP_DEMANGLE_DEBUG
	is defined.
2024-10-10 15:59:38 +02:00
GCC Administrator bfb9105ffb Daily bump. 2024-09-08 00:17:46 +00:00
Jakub Jelinek bb8dd0980b libiberty: Fix up > 64K section handling in simple_object_elf_copy_lto_debug_section [PR116614]
cat abc.C
  #define A(n) struct T##n {} t##n;
  #define B(n) A(n##0) A(n##1) A(n##2) A(n##3) A(n##4) A(n##5) A(n##6) A(n##7) A(n##8) A(n##9)
  #define C(n) B(n##0) B(n##1) B(n##2) B(n##3) B(n##4) B(n##5) B(n##6) B(n##7) B(n##8) B(n##9)
  #define D(n) C(n##0) C(n##1) C(n##2) C(n##3) C(n##4) C(n##5) C(n##6) C(n##7) C(n##8) C(n##9)
  #define E(n) D(n##0) D(n##1) D(n##2) D(n##3) D(n##4) D(n##5) D(n##6) D(n##7) D(n##8) D(n##9)
  E(1) E(2) E(3)
  int main () { return 0; }
./xg++ -B ./ -o abc{.o,.C} -flto -flto-partition=1to1 -O2 -g -fdebug-types-section -c
./xgcc -B ./ -o abc{,.o} -flto -flto-partition=1to1 -O2
(not included in testsuite as it takes a while to compile) FAILs with
lto-wrapper: fatal error: Too many copied sections: Operation not supported
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status

The following patch fixes that.  Most of the 64K+ section support for
reading and writing was already there years ago (and especially reading used
quite often already) and a further bug fixed in it in the PR104617 fix.

Yet, the fix isn't solely about removing the
  if (new_i - 1 >= SHN_LORESERVE)
    {
      *err = ENOTSUP;
      return "Too many copied sections";
    }
5 lines, the missing part was that the function only handled reading of
the .symtab_shndx section but not copying/updating of it.
If the result has less than 64K-epsilon sections, that actually wasn't
needed, but e.g. with -fdebug-types-section one can exceed that pretty
easily (reported to us on WebKitGtk build on ppc64le).
Updating the section is slightly more complicated, because it basically
needs to be done in lock step with updating the .symtab section, if one
doesn't need to use SHN_XINDEX in there, the section should (or should be
updated to) contain SHN_UNDEF entry, otherwise needs to have whatever would
be overwise stored but couldn't fit.  But repeating due to that all the
symtab decisions what to discard and how to rewrite it would be ugly.

So, the patch instead emits the .symtab_shndx section (or sections) last
and prepares the content during the .symtab processing and in a second
pass when going just through .symtab_shndx sections just uses the saved
content.

2024-09-07  Jakub Jelinek  <jakub@redhat.com>

	PR lto/116614
	* simple-object-elf.c (SHN_COMMON): Align comment with neighbouring
	comments.
	(SHN_HIRESERVE): Use uppercase hex digits instead of lowercase for
	consistency.
	(simple_object_elf_find_sections): Formatting fixes.
	(simple_object_elf_fetch_attributes): Likewise.
	(simple_object_elf_attributes_merge): Likewise.
	(simple_object_elf_start_write): Likewise.
	(simple_object_elf_write_ehdr): Likewise.
	(simple_object_elf_write_shdr): Likewise.
	(simple_object_elf_write_to_file): Likewise.
	(simple_object_elf_copy_lto_debug_section): Likewise.  Don't fail for
	new_i - 1 >= SHN_LORESERVE, instead arrange in that case to copy
	over .symtab_shndx sections, though emit those last and compute their
	section content when processing associated .symtab sections.  Handle
	simple_object_internal_read failure even in the .symtab_shndx reading
	case.
2024-09-07 09:39:06 +02:00
GCC Administrator 8ac4db24e4 Daily bump. 2024-08-06 00:17:19 +00:00
Andrew Burgess ea23809688 libiberty/argv.c: remove only_whitespace
After the commit:

  commit 5e1d530da8 (gcc-buildargv)
  Date:   Sat Feb 10 11:22:13 2024 +0000

      libiberty/buildargv: handle input consisting of only white space

The function only_whitespace (in argv.c) was no longer being called.
Lets delete it.

There should be no user visible changes after this commit.

2024-07-29  Andrew Burgess  <aburgess@redhat.com>

libiberty/

	* argv.c (only_whitespace): Delete.
2024-08-05 12:35:38 +01:00
GCC Administrator 72bce1fbef Daily bump. 2024-07-17 00:18:32 +00:00
Andrew Burgess 5e1d530da8 libiberty/buildargv: handle input consisting of only white space
GDB makes use of the libiberty function buildargv for splitting the
inferior (program being debugged) argument string in the case where
the inferior is not being started under a shell.

I have recently been working to improve this area of GDB, and noticed
some unexpected behaviour to the libiberty function buildargv, when
the input is a string consisting only of white space.

What I observe is that if the input to buildargv is a string
containing only white space, then buildargv will return an argv list
containing a single empty argument, e.g.:

  char **argv = buildargv (" ");
  assert (*argv[0] == '\0');
  assert (argv[1] == NULL);

We get the same output from buildargv if the input is a single space,
or multiple spaces.  Other white space characters give the same
results.

This doesn't seem right to me, and in fact, there appears to be a work
around for this issue in expandargv where we have this code:

  /* If the file is empty or contains only whitespace, buildargv would
     return a single empty argument.  In this context we want no arguments,
     instead.  */
  if (only_whitespace (buffer))
    {
      file_argv = (char **) xmalloc (sizeof (char *));
      file_argv[0] = NULL;
    }
  else
    /* Parse the string.  */
    file_argv = buildargv (buffer);

I think that the correct behaviour in this situation is to return an
empty argv array, e.g.:

  char **argv = buildargv (" ");
  assert (argv[0] == NULL);

And it turns out that this is a trivial change to buildargv.  The diff
does look big, but this is because I've re-indented a block.  Check
with 'git diff -b' to see the minimal changes.  I've also removed the
work around from expandargv.

When testing this sort of thing I normally write the tests first, and
then fix the code.  In this case test-expandargv.c has sort-of been
used as a mechanism for testing the buildargv function (expandargv
does call buildargv most of the time), however, for this particular
issue the work around in expandargv (mentioned above) masked the
buildargv bug.

I did consider adding a new test-buildargv.c file, however, this would
have basically been a copy & paste of test-expandargv.c (with some
minor changes to call buildargv).  This would be fine now, but feels
like we would eventually end up with one file not being updated as
much as the other, and so test coverage would suffer.

Instead, I have added some explicit buildargv testing to the
test-expandargv.c file, this reuses the test input that is already
defined for expandargv.

Of course, once I removed the work around from expandargv then we now
do always call buildargv from expandargv, and so the bug I'm fixing
would impact both expandargv and buildargv, so maybe the new testing
is redundant?  I tend to think more testing is always better, so I've
left it in for now.

2024-07-16  Andrew Burgess  <aburgess@redhat.com>

libiberty/

	* argv.c (buildargv): Treat input of only whitespace as an empty
	argument list.
	(expandargv): Remove work around for intput that is only
	whitespace.
	* testsuite/test-expandargv.c: Add new tests 10, 11, and 12.
	Extend testing to call buildargv in more cases.
2024-07-16 13:52:03 +01:00
Andrew Burgess a87954610f libiberty/buildargv: POSIX behaviour for backslash handling
GDB makes use of the libiberty function buildargv for splitting the
inferior (program being debugged) argument string in the case where
the inferior is not being started under a shell.

I have recently been working to improve this area of GDB, and have
tracked done some of the unexpected behaviour to the libiberty
function buildargv, and how it handles backslash escapes.

For reference, I've been mostly reading:

  https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html

The issues that I would like to fix are:

  1. Backslashes within single quotes should not be treated as an
  escape, thus: '\a' should split to \a, retaining the backslash.

  2. Backslashes within double quotes should only act as an escape if
  they are immediately before one of the characters $ (dollar),
  ` (backtick), " (double quote), ` (backslash), or \n (newline).  In
  all other cases a backslash should not be treated as an escape
  character.  Thus: "\a" should split to \a, but "\$" should split to
  $.

  3. A backslash-newline sequence should be treated as a line
  continuation, both the backslash and the newline should be removed.

I've updated libiberty and also added some tests.  All the existing
libiberty tests continue to pass, but I'm not sure if there is more
testing that should be done, buildargv is used within lto-wraper.cc,
so maybe there's some testing folk can suggest that I run?

2024-07-16  Andrew Burgess  <aburgess@redhat.com>

libiberty/

	* argv.c (buildargv): Backslashes within single quotes are
	literal, backslashes only escape POSIX defined special characters
	within double quotes, and backslashed newlines should act as line
	continuations.
	* testsuite/test-expandargv.c: Add new tests 7, 8, and 9.
2024-07-16 13:51:15 +01:00
GCC Administrator a1e6798acf Daily bump. 2024-04-03 00:17:29 +00:00
Tom Tromey ca2f7c8492 libiberty: Invoke D demangler when --format=auto
Investigating GDB PR d/31580 showed that the libiberty demangler
doesn't automatically demangle D mangled names.  However, I think it
should -- like C++ and Rust (new-style), D mangled names are readily
distinguished by the leading "_D", and so the likelihood of confusion
is low.  The other non-"auto" cases in this code are Ada (where the
encoded form could more easily be confused by ordinary programs) and
Java (which is long gone, but which also shared the C++ mangling and
thus was just an output style preference).

This patch also fixed another GDB bug, though of course that part
won't apply to the GCC repository.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31580
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30276

libiberty
	* cplus-dem.c (cplus_demangle): Try the D demangler with
	"auto" format.
	* testsuite/d-demangle-expected: Add --format=auto test.
2024-04-02 13:30:19 -06:00
Jakub Jelinek 94792057ad Fix up duplicated words mostly in comments, part 1
Like in r12-7519-g027e30414492d50feb2854aff38227b14300dc4b, I've done
git grep -v 'long long\|optab optab\|template template\|double double' | grep ' \([a-zA-Z]\+\) \1 '

This is just part of the changes, mostly for non-gcc directories.
I'll try to get to the rest soon.  Obviously, the above command also
finds cases which are correct as is and shouldn't be changed, so one
needs to manually inspect everything.

I'd hope most of it is pretty obvious, but the config/ and libstdc++-v3/
hunks include a tweak in a license wording, though other copies of the
similar license have the wording right.

2024-04-02  Jakub Jelinek  <jakub@redhat.com>

	* Makefile.tpl: Fix duplicated words; returns returns ->
	returns.
config/
	* lcmessage.m4: Fix duplicated words; can can -> can,
	package package -> package.
libdecnumber/
	* decCommon.c (decFinalize): Fix duplicated words in
	comment; the the -> the.
libgcc/
	* unwind-dw2-fde.c (struct fde_accumulator): Fix duplicated
	words in comment; is is -> is.
libgfortran/
	* configure.host: Fix duplicated words; the the -> the.
libgm2/
	* configure.host: Fix duplicated words; the the -> the.
libgomp/
	* libgomp.texi (OpenMP 5.2): Fix duplicated words; with with ->
	with.
	(omp_target_associate_ptr): Fix duplicated words; either either ->
	either.
	(omp_init_allocator): Fix duplicated words; be be -> be.
	(omp_realloc): Fix duplicated words; is is -> is.
	(OMP_ALLOCATOR): Fix duplicated words; other other -> other.
	* priority_queue.h (priority_queue_multi_p): Fix duplicated words;
	to to -> to.
libiberty/
	* regex.c (byte_re_match_2_internal): Fix duplicated words in comment;
	next next -> next.
	* dyn-string.c (dyn_string_init): Fix duplicated words in comment;
	of of -> of.
libitm/
	* beginend.cc (GTM::gtm_thread::begin_transaction): Fix duplicated
	words in comment; not not -> not to.
libobjc/
	* init.c (duplicate_classes): Fix duplicated words in comment; in in
	-> in.
	* sendmsg.c (__objc_prepare_dtable_for_class): Fix duplicated words
	in comment; the the -> the.
	* encoding.c (objc_layout_structure): Likewise.
libstdc++-v3/
	* acinclude.m4: Fix duplicated words; file file -> file can.
	* configure.host: Fix duplicated words; the the -> the.
libvtv/
	* vtv_rts.cc (vtv_fail): Fix duplicated words; to to -> to.
	* vtv_fail.cc (vtv_fail): Likewise.
2024-04-02 13:39:11 +02:00
GCC Administrator 5249027846 Daily bump. 2024-02-20 00:17:58 +00:00
Iain Sandoe 20e57660e6 libiberty: Fix error return value in pex_unix_exec_child [PR113957].
r14-5310-g879cf9ff45d940 introduced some new handling for spawning sub
processes.  The return value from the generic exec_child is examined
and needs to be < 0 to signal an error. However, the unix flavour of
this routine is returning the PID value set from the posix_spawn{p}.

This latter value is undefined per the manual pages for both Darwin
and Linux, and it seems Darwin, at least, sets the value to some
usually positive number (presumably the PID that would have been used
if the fork had succeeded).

The fix proposed here is to set the pid = -1 in the relevant error
paths.

	PR other/113957

libiberty/ChangeLog:

	* pex-unix.c (pex_unix_exec_child): Set pid = -1 in the error
	paths, since that is used to signal an erroneous outcome for
	the routine.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2024-02-19 20:13:30 +00:00
GCC Administrator 5c30ecfa81 Daily bump. 2024-02-16 00:17:22 +00:00
Richard Biener 52ac4c6be8 [libiberty] remove TBAA violation in iterative_hash, improve code-gen
The following removes the TBAA violation present in iterative_hash.
As we eventually LTO that it's important to fix.  This also improves
code generation for the >= 12 bytes loop by using | to compose the
4 byte words as at least GCC 7 and up can recognize that pattern
and perform a 4 byte load while the variant with a + is not
recognized (not on trunk either), I think we have an enhancement bug
for this somewhere.

Given we reliably merge and the bogus "optimized" path might be
only relevant for archs that cannot do misaligned loads efficiently
I've chosen to keep a specialization for aligned accesses.

libiberty/
	* hashtab.c (iterative_hash): Remove TBAA violating handling
	of aligned little-endian case in favor of just keeping the
	aligned case special-cased.  Use | for composing a larger word.
2024-02-15 09:14:22 +01:00
GCC Administrator bf074ee40a Daily bump. 2024-02-13 00:17:51 +00:00
Jakub Jelinek 53bb714513 libiberty: Fix up libiberty_vprintf_buffer_size
When writing the HOST_SIZE_T_PRINT_UNSIGNED incremental patch,
my first bootstrap failed on i686-linux.  That is because I've also had
@@ -1344,8 +1344,10 @@ adjust_field_rtx_def (type_p t, options_
            }

          subfields = create_field (subfields, t,
-                                   xasprintf (".fld[%lu].%s",
-                                              (unsigned long) aindex,
+                                   xasprintf (".fld["
+                                              HOST_SIZE_T_PRINT_UNSIGNED
+                                              "].%s",
+                                              (fmt_size_t) aindex,
                                               subname));
          subfields->opt = nodot;
          if (t == note_union_tp)
hunk in gengtype.cc.  While sprintf obviously can print in this case %llu
with fmt_size_t being unsigned long long (that is another bug I'll fix
incrementally), seems libiberty_vprintf_buffer_size
can't deal with that, it ignores h, hh, l, ll and L modifiers and
unconditionally, estimates 30 chars as upper bounds for integers (that is
fine) and then uses (void) va_arg (ap, int); to skip over the argument
regardless if it was %d, %ld, %lld, %hd, %hhd etc.
Now, on x86_64 that happens to work fine probably for all of those,
on ia32 for everything but %lld, because it then skips just one half
of the long long argument; now as there is %s after it, it will try to
compute strlen not from the pointer argument corresponding to %s, but
from the most significant half of the previous long long argument.

So, the following patch attempts not to completely ignore the modifiers,
but figure out from them whether to va_arg an int (used for h and hh as
well), or long, or long long, or size_t, or ptrdiff_t - added support for
z and t there, plus for Windows I64.  And also %Lf etc. for long double.

2024-02-12  Jakub Jelinek  <jakub@redhat.com>

	* vprintf-support.c (libiberty_vprintf_buffer_size): Handle
	properly l, ll, z, t or on _WIN32 I64 modifiers for diouxX
	and L modifier for fFgGeE.
2024-02-12 18:50:16 +01:00
GCC Administrator ed5bf2080c Daily bump. 2024-01-14 00:17:47 +00:00
Jakub Jelinek 65388b2865 c++, demangle: Implement https://github.com/itanium-cxx-abi/cxx-abi/issues/148 non-proposal
The following patch attempts to implement what apparently clang++
implemented for explicit object member function mangling, but nobody
actually proposed in patch form in
https://github.com/itanium-cxx-abi/cxx-abi/issues/148

2024-01-13  Jakub Jelinek  <jakub@redhat.com>

gcc/cp/
	* mangle.cc (write_nested_name): Mangle explicit object
	member functions with H as per
	https://github.com/itanium-cxx-abi/cxx-abi/issues/148 non-proposal.
gcc/testsuite/
	* g++.dg/abi/mangle79.C: New test.
include/
	* demangle.h (enum demangle_component_type): Add
	DEMANGLE_COMPONENT_XOBJ_MEMBER_FUNCTION.
libiberty/
	* cp-demangle.c (FNQUAL_COMPONENT_CASE): Add case for
	DEMANGLE_COMPONENT_XOBJ_MEMBER_FUNCTION.
	(d_dump): Handle DEMANGLE_COMPONENT_XOBJ_MEMBER_FUNCTION.
	(d_nested_name): Parse H after N in nested name.
	(d_count_templates_scopes): Handle
	DEMANGLE_COMPONENT_XOBJ_MEMBER_FUNCTION.
	(d_print_mod): Likewise.
	(d_print_function_type): Likewise.
	* testsuite/demangle-expected: Add tests for explicit object
	member functions.
2024-01-13 10:23:53 +01:00
Jakub Jelinek a945c346f5 Update copyright years. 2024-01-03 12:19:35 +01:00
GCC Administrator 3dd09cd9e1 Daily bump. 2023-12-06 00:17:50 +00:00