Dear GCC developers:If this email address is not correct for questions, please help forward this email. Sincerely sorry that I just find this email on gcc.gnu.org website and hope my question can be answered.
I am currently working on building cpython with gcc. The problem is that after turning on lto option, such as the following
|if [[ ${_OPTIMIZED} == yes ]]; then _extra_opts+=(--enable-optimizations) _extra_opts+=(--with-lto) _MAKE_TARGET=profile-opt # To speed up build times during testing (1): # _PROFILE_TASK="./python -m test.regrtest --pgo test_builtin" if [[ ${CC} =~ .*gcc.* && ! ${c_compiler} =~ .*toolchain.* ]]; then LTO_CFLAGS+=(-fuse-linker-plugin) LTO_CFLAGS+=(-ffat-lto-objects) # -flto must come after -flto-partition due to the replacement code LTO_CFLAGS+=(-flto-partition=none) LTO_CFLAGS+=(-flto) else # TODO :: Check if -flto=thin gives better results. It is about faster # compilation rather than faster execution so probably not: # http://clang.llvm.org/docs/ThinLTO.html # http://blog.llvm.org/2016/06/thinlto-scalable-and-incremental-lto.html LTO_CFLAGS+=(-flto) fi export CFLAGS="${CFLAGS} ${LTO_CFLAGS[@]}" else _MAKE_TARGET= fi |
When I enabled the LTO flags and built cpython with optimization (enable –with-lto, -fuse-linker-plugin, -ffat-lto-objets, -flto-partition=none, -flto), the built python3 will encounter segmentation fault when I trying to run it on another host (not using Docker ,but using some LD_PRELOAD hacks created sandbox, which means host libc will be involved during the initialization), when I use Docker (isolated namespaces) with LTO compiled python3, there is no such segmentation fault issue.
My guess is that LTO has requirements for gcc link/compiler environments?Though I’ve read this url https://gcc.gnu.org/onlinedocs/gccint/LTO-Overview.html <https://gcc.gnu.org/onlinedocs/gccint/LTO-Overview.html>
but still could not understand whether the LTO is link/compiler specific? and how about its portability(compiled in one environment, and can be used in another environment with different link/compiler versions? )
Thanks so much for the help! And looking forward to your responses! Best regards, Jason
Attachment:
OpenPGP_0xDA13D7409C72F5E1.asc
Description: OpenPGP public key
Attachment:
OpenPGP_signature
Description: OpenPGP digital signature