public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/100896] New: --enable-initfini-array should be enabled for cross compiler to Linux
@ 2021-06-03 19:39 hjl.tools at gmail dot com
  2021-06-09 12:15 ` [Bug target/100896] " cvs-commit at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: hjl.tools at gmail dot com @ 2021-06-03 19:39 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100896
           Summary: --enable-initfini-array should be enabled for cross
                    compiler to Linux
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hjl.tools at gmail dot com
  Target Milestone: ---

--enable-initfini-array should be enabled for cross compiler to
all *-*-linux* and *-*-gnu* targets.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/100896] --enable-initfini-array should be enabled for cross compiler to Linux
  2021-06-03 19:39 [Bug target/100896] New: --enable-initfini-array should be enabled for cross compiler to Linux hjl.tools at gmail dot com
@ 2021-06-09 12:15 ` cvs-commit at gcc dot gnu.org
  2021-06-09 12:16 ` hjl.tools at gmail dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-06-09 12:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by H.J. Lu <hjl@gcc.gnu.org>:

https://gcc.gnu.org/g:13a39886940331149173b25d6ebde0850668d8b9

commit r12-1328-g13a39886940331149173b25d6ebde0850668d8b9
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Jun 8 16:09:24 2021 -0700

    Always enable DT_INIT_ARRAY/DT_FINI_ARRAY on Linux

    DT_INIT_ARRAY/DT_FINI_ARRAY support was added to glibc 2.1 by

    commit fcf70d4114db9ff7923f5dfeb3fea6e2d623e5c2
    Author: Ulrich Drepper <drepper@redhat.com>
    Date:   Sat Jul 24 19:45:13 1999 +0000

        Update.

        1999-07-24  Ulrich Drepper  <drepper@cygnus.com>

                * elf/dl-fini.c: Handle DT_FINI_ARRAY.
                * elf/link.h (struct link_map): Remove l_init_running.  Add
l_runcount
                and l_initcount.
                * elf/dl-init.c: Handle DT_INIT_ARRAY.
    ...

    and added to binutils 2.12 by

    commit e9682144c14fc809af72bd6c0b8c69731d38679c
    Author: H.J. Lu <hjl.tools@gmail.com>
    Date:   Mon Mar 4 20:40:48 2002 +0000

        2002-03-04  H.J. Lu <hjl@gnu.org>

                * config/obj-elf.c (special_section): Add .init_array,
                .fini_array and .preinit_array.

                * config/tc-ia64.h (ELF_TC_SPECIAL_SECTIONS): Remove
                .init_array and .fini_array.

    gcc/

            PR target/100896
            * config.gcc (gcc_cv_initfini_array): Set to yes for Linux and
            GNU targets.
            * doc/install.texi: Require glibc 2.1 and binutils 2.12 for
            Linux and GNU targets.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/100896] --enable-initfini-array should be enabled for cross compiler to Linux
  2021-06-03 19:39 [Bug target/100896] New: --enable-initfini-array should be enabled for cross compiler to Linux hjl.tools at gmail dot com
  2021-06-09 12:15 ` [Bug target/100896] " cvs-commit at gcc dot gnu.org
@ 2021-06-09 12:16 ` hjl.tools at gmail dot com
  2021-08-17 13:00 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: hjl.tools at gmail dot com @ 2021-06-09 12:16 UTC (permalink / raw)
  To: gcc-bugs

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.0
         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> ---
Fixed for GCC 12.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/100896] --enable-initfini-array should be enabled for cross compiler to Linux
  2021-06-03 19:39 [Bug target/100896] New: --enable-initfini-array should be enabled for cross compiler to Linux hjl.tools at gmail dot com
  2021-06-09 12:15 ` [Bug target/100896] " cvs-commit at gcc dot gnu.org
  2021-06-09 12:16 ` hjl.tools at gmail dot com
@ 2021-08-17 13:00 ` cvs-commit at gcc dot gnu.org
  2021-11-05 18:57 ` i at maskray dot me
  2021-11-05 19:00 ` i at maskray dot me
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-17 13:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Christophe Lyon <clyon@gcc.gnu.org>:

https://gcc.gnu.org/g:9c560cf23996271ee26dfc4a1d8484b85173cd12

commit r12-2954-g9c560cf23996271ee26dfc4a1d8484b85173cd12
Author: Christophe Lyon <christophe.lyon@foss.st.com>
Date:   Tue Aug 17 12:59:26 2021 +0000

    Do not enable DT_INIT_ARRAY/DT_FINI_ARRAY on uclinuxfdpiceabi

    Commit r12-1328 enabled DT_INIT_ARRAY/DT_FINI_ARRAY for all Linux
    targets, but this does not work for arm-none-uclinuxfdpiceabi: it
    makes all the execution tests fail.

    This patch restores the original behavior for uclinuxfdpiceabi.

    2021-08-12  Christophe Lyon  <christophe.lyon@foss.st.com>

            gcc/
            PR target/100896
            * config.gcc (gcc_cv_initfini_array): Leave undefined for
            uclinuxfdpiceabi targets.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/100896] --enable-initfini-array should be enabled for cross compiler to Linux
  2021-06-03 19:39 [Bug target/100896] New: --enable-initfini-array should be enabled for cross compiler to Linux hjl.tools at gmail dot com
                   ` (2 preceding siblings ...)
  2021-08-17 13:00 ` cvs-commit at gcc dot gnu.org
@ 2021-11-05 18:57 ` i at maskray dot me
  2021-11-05 19:00 ` i at maskray dot me
  4 siblings, 0 replies; 6+ messages in thread
From: i at maskray dot me @ 2021-11-05 18:57 UTC (permalink / raw)
  To: gcc-bugs

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

Fangrui Song <i at maskray dot me> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |i at maskray dot me

--- Comment #4 from Fangrui Song <i at maskray dot me> ---
In gcc/acinclude.m4:285, if cross-compiling, (`if test "x${build}" =
"x${target}" && test "x${build}" = "x${host}"; then `) will not be taken.

  else
    case "${target}" in
      aarch64*-linux-gnu*)
        # AArch64 postdates glibc support for .init_array/.fini_array,
        # so we don't need the preprocessor test above.
        gcc_cv_initfini_array=yes
        ;;

      *)
        AC_MSG_CHECKING(cross compile... guessing)
        gcc_cv_initfini_array=no
        ;;
    esac
  fi])

On non-aarch64, `gcc_cv_initfini_array=no` will run,
`HAVE_INITFINI_ARRAY_SUPPORT` will therefore be 0.

  compilers/powerpc64le-linux-gnu/gcc/gcc/auto-host.h
  1578:#define HAVE_INITFINI_ARRAY_SUPPORT 0

  compilers/powerpc64le-linux-gnu/gcc/gcc/config.status
  1257:D["HAVE_INITFINI_ARRAY_SUPPORT"]=" 0"

  compilers/powerpc64le-linux-gnu/gcc/gcc/config.log
  6900:| #define HAVE_INITFINI_ARRAY_SUPPORT 0
  7169:| #define HAVE_INITFINI_ARRAY_SUPPORT 0
  7484:| #define HAVE_INITFINI_ARRAY_SUPPORT 0
  8557:#define HAVE_INITFINI_ARRAY_SUPPORT 0

The built GCC will use the legacy .ctors

% many=/tmp/glibc-many
% cat a.c
__attribute__ ((constructor)) static int foo (void) { return 42; }
%
/tmp/glibc-many/install/compilers/powerpc64le-linux-gnu/bin/powerpc64le-glibc-linux-gnu-gcc
-c a.c && readelf -WS a.o | egrep 'ctors|init_array'
  [ 4] .ctors            PROGBITS        0000000000000000 000070 000008 00  WA 
0   0  8
  [ 5] .rela.ctors       RELA            0000000000000000 000218 000018 18   I
10   4  8


---

Noticed the problem when using scripts/build-many-glibcs.py built GCC

(cd ~/Dev/glibc)
scripts/build-many-glibcs.py /tmp/glibc-many checkout --shallow
scripts/build-many-glibcs.py /tmp/glibc-many host-libraries
scripts/build-many-glibcs.py /tmp/glibc-many compilers powerpc64le-linux-gnu
--keep all

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/100896] --enable-initfini-array should be enabled for cross compiler to Linux
  2021-06-03 19:39 [Bug target/100896] New: --enable-initfini-array should be enabled for cross compiler to Linux hjl.tools at gmail dot com
                   ` (3 preceding siblings ...)
  2021-11-05 18:57 ` i at maskray dot me
@ 2021-11-05 19:00 ` i at maskray dot me
  4 siblings, 0 replies; 6+ messages in thread
From: i at maskray dot me @ 2021-11-05 19:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Fangrui Song <i at maskray dot me> ---
Ah, ok, my /tmp/glibc-many/src/gcc is at releases/gcc-11 while the fix is for
12.0?

Anyway, you may want to clean up  gcc/acinclude.m4

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-11-05 19:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-03 19:39 [Bug target/100896] New: --enable-initfini-array should be enabled for cross compiler to Linux hjl.tools at gmail dot com
2021-06-09 12:15 ` [Bug target/100896] " cvs-commit at gcc dot gnu.org
2021-06-09 12:16 ` hjl.tools at gmail dot com
2021-08-17 13:00 ` cvs-commit at gcc dot gnu.org
2021-11-05 18:57 ` i at maskray dot me
2021-11-05 19:00 ` i at maskray dot me

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).