[m-users.] Compiler build failure with --enable-lto (was: Link-time optimization)

Massimo Dentico m.dentico at virgilio.it
Mon Jun 15 08:13:50 AEST 2020


On 13/06/2020 04:09, M McDonough wrote:
> It's not just enough to put the LTO flags in the CFLAGS, since the
> standard library (which accounts for much of the executable size in my
> experience).
> 
> There is an LTO option during configuration, although I only seriously
> tested it for MSVC since that's my main target on Windows and shared
> libraries aren't possible with Mercury in that configuration. That
> will reduce the resulting exe file by quite a lot.
> 
> The LTO flags are implemented for gcc and clang as well as MSVC, but I
> am unsure if it's done in an optimal way (a large part of why it's
> marked as experimental I believe).
> 
> Using LTO will also cause the linking steps to be quite long, since
> it's basically compiling the entire Mercury runtime and standard
> library at that point. But the file size is quite a bit smaller. The
> actual performance change is pretty minor from my experience over just
> intermodule optimization, since intermodule-optimization tends to be
> very effective before the actual grade's compiler even gets the code.

Unfortunately the Mercury compiler build with "--enable-lto" failed in
my configuration. It seems is failing right while linking.

This is the error message and a few lines before the build failure 
(shortened, where there is [...] there was a wall full of .o files):

--------------------------------------------------------------------------
../scripts/mgnuc --grade asm_fast.gc       --      -c 
mercury_compile_init.c -o mercury_compile_init.o
../scripts/ml --grade asm_fast.gc    --no-mercury-stdlib-dir --shared 
--trace-init-file ../browser/mer_browser.init --ssdb-init-file 
../ssdb/mer_ssdb.init        -- -Wl,--stack=8388608   -o 
mercury_compile.exe mercury_compile_init.o \
         analysis.o analysis.file.o backend_libs.o 
backend_libs.base_typeclass_info.o
[...] \
         ../trace/libmer_eventspec.a ../trace/libmer_trace.a 
../trace/libmer_eventspec.a ../ssdb/libmer_ssdb.a 
../browser/libmer_browser.a ../mdbcomp/libmer_mdbcomp.a 
../library/libmer_std.a ../runtime/libmer_rt.a ../boehm_gc/libgc.a 
-lpthread
lto1.exe: error: two or more sections for 
.gnu.lto_mercury_data_term__ti_var_1parse_tree__prog_data__type_ctor_info_prog_var_type_0.lto_priv.26.444332.afc92650
(null):0: confused by earlier errors, bailing out
lto-wrapper.exe: fatal error: C:\msys64\mingw64\bin\gcc.exe returned 1 
exit status
compilation terminated.
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: 
error: lto-wrapper failed
collect2.exe: error: ld returned 1 exit status
make[2]: *** [/tmp/mmake.cB1SBk:1287378: mercury_compile.exe] Error 1
make[2]: Leaving directory '/c/mercury-srcdist-20.01.2/compiler'
make[1]: *** [/tmp/mmake.e0opid:1043: compiler] Error 2
make[1]: Leaving directory '/c/mercury-srcdist-20.01.2'
make: *** [Makefile:30: all] Error 2
--------------------------------------------------------------------------


--
Massimo A. Dentico



More information about the users mailing list