Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

CMake warnings when LTO is enabled as part of building Minetest #54

Closed
Calinou opened this issue Aug 9, 2021 · 2 comments · Fixed by #57
Closed

CMake warnings when LTO is enabled as part of building Minetest #54

Calinou opened this issue Aug 9, 2021 · 2 comments · Fixed by #57

Comments

@Calinou
Copy link
Member

Calinou commented Aug 9, 2021

When building Minetest on Fedora 34 with CMake 3.20 and cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=1, I get the following warnings near the end of the configuration process:

❯ cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=1                                                                                                            
-- *** Will build version 5.5.0-dev ***
-- Using user-provided IrrlichtMt at subdirectory 'lib/irrlichtmt'
-- *** Building IrrlichtMt 1.9.0 ***
-- Found ZLIB: /usr/lib64/libz.so (found version "1.2.11") 
-- Found JPEG: /usr/local/lib64/libjpeg.so (found version "62") 
-- Found PNG: /usr/lib64/libpng.so (found version "1.6.37") 
-- Looking for _IRR_COMPILE_WITH_OGLES1_
-- Looking for _IRR_COMPILE_WITH_OGLES1_ - not found
-- Looking for _IRR_COMPILE_WITH_OGLES2_
-- Looking for _IRR_COMPILE_WITH_OGLES2_ - not found
-- Looking for _IRR_COMPILE_WITH_OPENGL_
-- Looking for _IRR_COMPILE_WITH_OPENGL_ - found
-- Found OpenGL: /usr/lib64/libOpenGL.so   
-- Found X11: /usr/include   
-- Looking for XOpenDisplay in /usr/lib64/libX11.so;/usr/lib64/libXext.so
-- Looking for XOpenDisplay in /usr/lib64/libX11.so;/usr/lib64/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Using GMP provided by system.
-- Found GMP: /usr/lib64/libgmp.so  
-- Using JsonCpp provided by system.
-- Found Json: /usr/lib64/libjsoncpp.so  
-- Found LuaJIT: /usr/lib64/libluajit-5.1.so  
-- Using LuaJIT provided by system.
-- Found CURL: /usr/lib64/libcurl.so  
-- cURL support enabled.
-- Found GettextLib: /usr/include  
-- GetText enabled; locales found: ar;be;bg;ca;cs;da;de;dv;el;eo;es;et;eu;fi;fil;fr;gd;gl;he;hi;hu;id;it;ja;jbo;kk;kn;ko;ky;lt;lv;mr;ms;ms_Arab;nb;nl;nn;pl;pt;pt_BR;ro;ru;sk;sl;sr_Cyrl;sr_Latn;sv;sw;th;tr;tt;uk;vi;zh_CN;zh_TW
-- Found OpenAL: /usr/lib64/libopenal.so  
-- Found Vorbis: /usr/include  
-- Sound enabled.
-- Found Freetype: /usr/lib64/libfreetype.so (found version "2.10.4") 
-- Freetype enabled.
-- Looking for cbreak in /usr/lib64/libncursesw.so
-- Looking for cbreak in /usr/lib64/libncursesw.so - found
-- Found Ncursesw: /usr/lib64/libncursesw.so  
-- ncurses console enabled.
-- Could NOT find PostgreSQL (missing: PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR) 
-- PostgreSQL not found!
-- LevelDB backend enabled.
-- Redis not found!
-- Found SQLite3: /usr/lib64/libsqlite3.so  
-- Prometheus client disabled.
-- SpatialIndex AreaStore backend enabled.
-- Looking for clock_gettime in rt
-- Looking for clock_gettime in rt - found
-- Looking for include file endian.h
-- Looking for include file endian.h - found
-- Locale blacklist applied; Locales used: be;bg;ca;cs;da;de;el;eo;es;et;eu;fi;fil;fr;gd;gl;hu;id;it;ja;jbo;kk;ko;ky;lt;lv;mr;ms;nb;nl;nn;pl;pt;pt_BR;ro;ru;sk;sl;sr_Cyrl;sr_Latn;sv;sw;tr;tt;uk;vi;zh_CN;zh_TW
-- Performing Test IS_AARCH64
-- Performing Test IS_AARCH64 - Failed
-- Found Doxygen: /usr/bin/doxygen (found version "1.9.1") found components: doxygen dot 
-- Configuring done
CMake Warning (dev) at lib/irrlichtmt/source/Irrlicht/CMakeLists.txt:117 (add_library):
  Policy CMP0069 is not set: INTERPROCEDURAL_OPTIMIZATION is enforced when
  enabled.  Run "cmake --help-policy CMP0069" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  INTERPROCEDURAL_OPTIMIZATION property will be ignored for target
  'IRRMESHOBJ'.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at lib/irrlichtmt/source/Irrlicht/CMakeLists.txt:171 (add_library):
  Policy CMP0069 is not set: INTERPROCEDURAL_OPTIMIZATION is enforced when
  enabled.  Run "cmake --help-policy CMP0069" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  INTERPROCEDURAL_OPTIMIZATION property will be ignored for target
  'IRRVIDEOOBJ'.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at lib/irrlichtmt/source/Irrlicht/CMakeLists.txt:178 (add_library):
  Policy CMP0069 is not set: INTERPROCEDURAL_OPTIMIZATION is enforced when
  enabled.  Run "cmake --help-policy CMP0069" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  INTERPROCEDURAL_OPTIMIZATION property will be ignored for target
  'IRRIOOBJ'.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at lib/irrlichtmt/source/Irrlicht/CMakeLists.txt:125 (add_library):
  Policy CMP0069 is not set: INTERPROCEDURAL_OPTIMIZATION is enforced when
  enabled.  Run "cmake --help-policy CMP0069" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  INTERPROCEDURAL_OPTIMIZATION property will be ignored for target 'IRROBJ'.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at lib/irrlichtmt/source/Irrlicht/CMakeLists.txt:222 (add_library):
  Policy CMP0069 is not set: INTERPROCEDURAL_OPTIMIZATION is enforced when
  enabled.  Run "cmake --help-policy CMP0069" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  INTERPROCEDURAL_OPTIMIZATION property will be ignored for target
  'IRRGUIOBJ'.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at lib/irrlichtmt/source/Irrlicht/CMakeLists.txt:190 (add_library):
  Policy CMP0069 is not set: INTERPROCEDURAL_OPTIMIZATION is enforced when
  enabled.  Run "cmake --help-policy CMP0069" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  INTERPROCEDURAL_OPTIMIZATION property will be ignored for target
  'IRROTHEROBJ'.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at lib/irrlichtmt/source/Irrlicht/CMakeLists.txt:256 (add_library):
  Policy CMP0069 is not set: INTERPROCEDURAL_OPTIMIZATION is enforced when
  enabled.  Run "cmake --help-policy CMP0069" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  INTERPROCEDURAL_OPTIMIZATION property will be ignored for target
  'IrrlichtMt'.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at src/CMakeLists.txt:518 (add_executable):
  Policy CMP0069 is not set: INTERPROCEDURAL_OPTIMIZATION is enforced when
  enabled.  Run "cmake --help-policy CMP0069" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  INTERPROCEDURAL_OPTIMIZATION property will be ignored for target
  'minetest'.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: /home/hugo/Documents/Git/minetest/minetest/build

I'm also inclined to think that LTO isn't functional on Minetest, given what I have below:

Binary size comparison

LTO enabled

❯ ll -B bin/minetest     
Permissions      Size User Date Modified Name
.rwxr-xr-x  9,522,936 hugo  9 Aug 15:30  bin/minetest

LTO disabled

After building with LTO enabled, I ran git clean -dfx and built everything with LTO disabled, but binary size didn't increase. This means LTO is likely not working either.

❯ ll -B bin/minetest 
Permissions      Size User Date Modified Name
.rwxr-xr-x  9,522,936 hugo  9 Aug 15:34  minetest

In comparison, the -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=1 switch has a small but noticeable effect on binary size on Odamex (another software built using CMake). It also increases linking time a lot, so you know that LTO is working 🙂

@sfan5
Copy link
Member

sfan5 commented Aug 9, 2021

As far as I can tell this is not our bug. Reading CMP0069 everything is written as if the project wants to enable LTO. But we don't want to do that, we don't use this feature nor any other features from CMake 3.9. We shouldn't have to care about anything relating to CMake 3.9.
This doesn't sound well thought out by them.
But we probably have to set cmake_policy(SET CMP0069 NEW) to make -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=1 work in both IrrlichtMt and Minetest itself despite this.

@JosiahWI
Copy link
Contributor

We could also consider setting a version range, which would set all policies based on the CMake version in use.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants