public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* Test with an lto-build of libgfortran.
@ 2023-09-27 18:21 Toon Moene
  2023-09-27 21:48 ` Jeff Law
  2023-09-28  5:33 ` Thomas Koenig
  0 siblings, 2 replies; 15+ messages in thread
From: Toon Moene @ 2023-09-27 18:21 UTC (permalink / raw)
  To: gcc mailing list; +Cc: gfortran

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

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

end of thread, other threads:[~2023-09-29 10:26 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-27 18:21 Test with an lto-build of libgfortran Toon Moene
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

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