public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Olivier Langlois <olivier@trillion01.com>
To: libc-help@sourceware.org
Subject: Is compiling glibc with -flto possible?
Date: Wed, 02 Dec 2020 03:09:03 -0500	[thread overview]
Message-ID: <e1dfb4d7aa121cd98033dae20bfcf377c237ca24.camel@trillion01.com> (raw)

I am trying to build the release/2.32/master branch with gcc 10.2.0 on
a CentOS 7 machine (Kernel 3.10.0)

This is definitely uncharted territory as I have stumbled into a minor
issue that I have been able to work around.

1. script/gen-as-const.py generates empty output when -flto flag is
present.

Workaround:

diff --git a/scripts/glibcextract.py b/scripts/glibcextract.py
index b7b0f38c7a..741be71128 100644
--- a/scripts/glibcextract.py
+++ b/scripts/glibcextract.py
@@ -58,7 +58,7 @@ def compute_c_consts(sym_data, cc):
             c_file.write(out_text)
         # Compilation has to be from stdin to avoid the temporary file
         # name being written into the generated dependencies.
-        cmd = ('%s -S -o %s -x c - < %s' % (cc, s_file_name,
c_file_name))
+        cmd = ('%s -S -o %s -x c - < %s' % (cc.replace('-flto', ''),
s_file_name, c_file_name))
         subprocess.check_call(cmd, shell=True)
         consts = {}
         with open(s_file_name, 'r') as s_file:

2. Next, a little bit further in the compilation process, I get the
following error:

gcc pthread_getattr_np.c -c -std=gnu11 -fgnu89-inline  -O3 -flto -Wall
-Wwrite-strings -Wundef -fmerge-all-constants -frounding-math -fstack-
protector-strong -Wstrict-prototypes -Wold-style-definition -fmath-
errno   -fPIC -fcf-protection   -ftls-model=initial-exec    -
I/home/juicingf/include  -I../include -I/home/juicingf/dev/glibc-
build/nptl  -I/home/juicingf/dev/glibc-build  -
I../sysdeps/unix/sysv/linux/x86_64/64  -
I../sysdeps/unix/sysv/linux/x86_64  -
I../sysdeps/unix/sysv/linux/x86/include -
I../sysdeps/unix/sysv/linux/x86  -I../sysdeps/x86/nptl  -
I../sysdeps/unix/sysv/linux/wordsize-64  -I../sysdeps/x86_64/nptl  -
I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux  -
I../sysdeps/nptl  -I../sysdeps/pthread  -I../sysdeps/gnu  -
I../sysdeps/unix/inet  -I../sysdeps/unix/sysv  -I../sysdeps/unix/x86_64
-I../sysdeps/unix  -I../sysdeps/posix  -I../sysdeps/x86_64/64  -
I../sysdeps/x86_64/fpu/multiarch  -I../sysdeps/x86_64/fpu  -
I../sysdeps/x86/fpu  -I../sysdeps/x86_64/multiarch  -I../sysdeps/x86_64
-I../sysdeps/x86  -I../sysdeps/ieee754/float128  -
I../sysdeps/ieee754/ldbl-96/include -I../sysdeps/ieee754/ldbl-96  -
I../sysdeps/ieee754/dbl-64/wordsize-64  -I../sysdeps/ieee754/dbl-64  -
I../sysdeps/ieee754/flt-32  -I../sysdeps/wordsize-64  -
I../sysdeps/ieee754  -I../sysdeps/generic  -I.. -I../libio -I. -
nostdinc -isystem /home/juicingf/lib/gcc/x86_64-pc-linux-
gnu/10.2.0/include -isystem /home/juicingf/lib/gcc/x86_64-pc-linux-
gnu/10.2.0/include-fixed -isystem /home/juicingf/include -
D_LIBC_REENTRANT -include /home/juicingf/dev/glibc-build/libc-modules.h
-DMODULE_NAME=libc -include ../include/libc-symbols.h  -DPIC -DSHARED 
-DTOP_NAMESPACE=glibc -o /home/juicingf/dev/glibc-
build/nptl/pthread_getattr_np.os -MD -MP -MF /home/juicingf/dev/glibc-
build/nptl/pthread_getattr_np.os.dt -MT /home/juicingf/dev/glibc-
build/nptl/pthread_getattr_np.os
In file included from ../sysdeps/x86/ldsodefs.h:65,
                 from ../sysdeps/gnu/ldsodefs.h:46,
                 from ../sysdeps/unix/sysv/linux/ldsodefs.h:25,
                 from pthread_getattr_np.c:29:
../sysdeps/generic/ldsodefs.h:693:14: error: '__libc_stack_end' causes
a section type conflict with '_rtld_global_ro'
  693 | extern void *__libc_stack_end
      |              ^~~~~~~~~~~~~~~~
../sysdeps/generic/ldsodefs.h:670:36: note: '_rtld_global_ro' was
declared here
  670 | extern const struct rtld_global_ro _rtld_global_ro
      |                                    ^~~~~~~~~~~~~~~

this type of low-level error is unfortunately outside my system
programming understanding reach.

I'll fumble around with my compiler switch values as it is currently my
prime suspect.

Please chime in if you have an idea of what my problem is.

Thank you,
Olivier


             reply	other threads:[~2020-12-02  8:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-02  8:09 Olivier Langlois [this message]
2020-12-02  9:08 ` Florian Weimer

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=e1dfb4d7aa121cd98033dae20bfcf377c237ca24.camel@trillion01.com \
    --to=olivier@trillion01.com \
    --cc=libc-help@sourceware.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).