public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "i at maskray dot me" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/100896] --enable-initfini-array should be enabled for cross compiler to Linux
Date: Fri, 05 Nov 2021 18:57:51 +0000	[thread overview]
Message-ID: <bug-100896-4-p3n3oZuG98@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-100896-4@http.gcc.gnu.org/bugzilla/>

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

  parent reply	other threads:[~2021-11-05 18:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-03 19:39 [Bug target/100896] New: " 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 [this message]
2021-11-05 19:00 ` i at maskray dot me

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-100896-4-p3n3oZuG98@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).