From: Toon Moene <toon@moene.org>
To: gcc mailing list <gcc@gcc.gnu.org>
Cc: gfortran <fortran@gcc.gnu.org>
Subject: Test with an lto-build of libgfortran.
Date: Wed, 27 Sep 2023 20:21:38 +0200 [thread overview]
Message-ID: <9e347fa4-1940-46c6-a5c9-899cf5a7ae85@moene.org> (raw)
Hi all,
During the GNU Tools Cauldron we discussed (at the BoF: IPA & LTO) the
possibility (and hazards) of building the run time libraries for various
compilers with -flto, enabling an -flto -static linking of programs with
the run time library available during link time optimizations.
Today I tried that on my (AMD Ryzen 7 5800U) laptop with
gcc version 14.0.0 20230926 (experimental) [master
r14-4282-g53daf67fd55] (GCC)
with the following "quick hack":
diff --git a/libgfortran/configure b/libgfortran/configure
index cd176b04a14..69a2b4a8881 100755
--- a/libgfortran/configure
+++ b/libgfortran/configure
@@ -5959,11 +5959,11 @@ fi
# Add -Wall -fno-repack-arrays -fno-underscoring if we are using GCC.
have_real_17=no
if test "x$GCC" = "xyes"; then
- AM_FCFLAGS="-I . -Wall -Werror -fimplicit-none -fno-repack-arrays
-fno-underscoring"
+ AM_FCFLAGS="-I . -Wall -Werror -fimplicit-none -fno-repack-arrays
-fno-underscoring -flto"
## We like to use C11 and C99 routines when available. This makes
## sure that
## __STDC_VERSION__ is set such that libc includes make them available.
- AM_CFLAGS="-std=gnu11 -Wall -Wstrict-prototypes -Wmissing-prototypes
-Wold-style-definition -Wextra -Wwrite-strings
-Werror=implicit-function-declaration -Werror=vla"
+ AM_CFLAGS="-std=gnu11 -Wall -Wstrict-prototypes -Wmissing-prototypes
-Wold-style-definition -Wextra -Wwrite-strings
-Werror=implicit-function-declaration -Werror=vla -flto"
## Compile the following tests with the same system header contents
## that we'll encounter when compiling our own source files.
CFLAGS="-std=gnu11 $CFLAGS"
The build of this compiler (languages=fortran) completed without
problems (no test results - not enough time).
I then proceeded to build LAPACK with the following build options:
CFLAGS = -O3 -flto -flto-partition=none -static
and
FFLAGS = -O3 -flto -flto-partition=none -static
This gave the same test results of the LAPACK test suite as the build
with the same compiler, but without an lto'd libgfortran.
The lto-ing of libgfortran did succeed, because I did get a new warning:
gfortran -O3 -flto -flto-partition=none -static -o xlintstrfz zchkrfp.o
zdrvrfp.o zdrvrf1.o zdrvrf2.o zdrvrf3.o zdrvrf4.o zerrrfp.o zlatb4.o
zlaipd.o zlarhs.o zsbmv.o zget04.o zpot01.o zpot03.o zpot02.o chkxer.o
xerbla.o alaerh.o aladhd.o alahd.o alasvm.o ../../libtmglib.a
../../liblapack.a ../../librefblas.a
In function 'xtoa_big',
inlined from 'write_z' at
/home/toon/compilers/gcc/libgfortran/io/write.c:1296:11,
inlined from 'formatted_transfer_scalar_write' at
/home/toon/compilers/gcc/libgfortran/io/transfer.c:2136:4:
/home/toon/compilers/gcc/libgfortran/io/write.c:1222:6: warning: writing
1 byte into a region of size 0 [-Wstringop-overflow=]
1222 | *q = '\0';
| ^
/home/toon/compilers/gcc/libgfortran/io/write.c: In function
'formatted_transfer_scalar_write':
/home/toon/compilers/gcc/libgfortran/io/write.c:1291:8: note: at offset
[34, 4294967294] into destination object 'itoa_buf' of size 33
1291 | char itoa_buf[GFC_XTOA_BUF_SIZE];
| ^
which was (of course) not given with a non-lto libgfortran.
The full question of "lto-ing" run time libraries is more complicated
than just "whether it works" as those who attended the BoF will recall.
Hope this helps,
--
Toon Moene - e-mail: toon@moene.org - phone: +31 346 214290
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
next reply other threads:[~2023-09-27 18:21 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-27 18:21 Toon Moene [this message]
2023-09-27 21:48 ` Jeff Law
2023-09-28 6:25 ` Richard Biener
2023-09-28 6:29 ` Andrew Pinski
2023-09-28 7:29 ` Tobias Burnus
2023-09-28 9:51 ` Jakub Jelinek
2023-09-28 11:00 ` Tobias Burnus
2023-09-28 11:02 ` Jakub Jelinek
2023-09-28 5:33 ` Thomas Koenig
2023-09-28 19:03 ` Toon Moene
2023-09-28 19:26 ` Jakub Jelinek
2023-09-28 19:59 ` Toon Moene
2023-09-28 20:02 ` David Edelsohn
2023-09-29 10:26 ` Andrew Stubbs
2023-09-29 6:03 ` Thomas Koenig
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=9e347fa4-1940-46c6-a5c9-899cf5a7ae85@moene.org \
--to=toon@moene.org \
--cc=fortran@gcc.gnu.org \
--cc=gcc@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).