tjunier / newick_utils

shell tools for processing phylogenetic trees
Other
101 stars 31 forks source link

Build fails with LTO #34

Open eli-schwartz opened 5 months ago

eli-schwartz commented 5 months ago

I tried to build with the following *FLAGS to optimize the build: -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing

Note the -Werror=* flags are used to help detect cases where the compiler tries to optimize by assuming UB cannot exist in the source code -- if it does exist, ordinarily the code would be miscompiled, and this says to make the miscompilation a fatal error.

I got this error:

libtool: link: x86_64-pc-linux-gnu-gcc -march=native -fstack-protector-all -O2 -pipe -fdiagnostics-color=always -frecord-gcc-switches -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wformat -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=incompatible-pointer-types -Wl,-O1 -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0 -o .libs/nw_display display.o canvas.o text_graph.o simple_node_pos.o svg_graph.o readline.o node_pos_alloc.o xml_utils.o graph_common.o svg_graph_ortho.o svg_graph_radial.o  -Wl,--as-needed ./.libs/libnw.so -lxml2 -lm
svg_graph_radial.h:43:6: error: type of 'display_svg_tree_radial' does not match original declaration [-Werror=lto-type-mismatch]
   43 | void display_svg_tree_radial(
      |      ^
svg_graph_radial.c:738:5: note: return value type mismatch
  738 | int display_svg_tree_radial(struct rooted_tree *tree,
      |     ^
svg_graph_radial.c:738:5: note: type 'int' should match type 'void'
svg_graph_radial.c:738:5: note: 'display_svg_tree_radial' was previously declared here
svg_graph_radial.c:738:5: note: code may be misoptimized unless '-fno-strict-aliasing' is used
text_graph.h:50:21: error: type of 'display_tree' does not match original declaration [-Werror=lto-type-mismatch]
   50 | enum display_status display_tree(struct rooted_tree *tree,
      |                     ^
text_graph.c:169:21: note: type mismatch in parameter 3
  169 | enum display_status display_tree(
      |                     ^
text_graph.c:169:21: note: type 'int' should match type '_Bool'
text_graph.c:169:21: note: 'display_tree' was previously declared here
text_graph.c:169:21: note: code may be misoptimized unless '-fno-strict-aliasing' is used
lto1: some warnings being treated as errors
lto-wrapper: fatal error: x86_64-pc-linux-gnu-gcc returned 1 exit status
compilation terminated.
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:646: nw_display] Error 1

Reported downstream: https://bugs.gentoo.org/862279 Full build log: build.log