public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
* Is compiling glibc with -flto possible?
@ 2020-12-02  8:09 Olivier Langlois
  2020-12-02  9:08 ` Florian Weimer
  0 siblings, 1 reply; 2+ messages in thread
From: Olivier Langlois @ 2020-12-02  8:09 UTC (permalink / raw)
  To: libc-help

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


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

end of thread, other threads:[~2020-12-02  9:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-02  8:09 Is compiling glibc with -flto possible? Olivier Langlois
2020-12-02  9:08 ` Florian Weimer

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).