Build error: optimization flag '-fno-fat-lto-objects' is not supported
TheAlexFuller opened this issue · comments
This is output from cmake --build ./build
in the Docker container (Ubuntu host machine):
[ 0%] Building CXX object _deps/fmt-build/CMakeFiles/fmt.dir/src/format.cc.o
[ 0%] Building CXX object _deps/fmt-build/CMakeFiles/fmt.dir/src/os.cc.o
[ 0%] Linking CXX static library libfmt.a
[ 0%] Built target fmt
[ 0%] Building CXX object _deps/spdlog-build/CMakeFiles/spdlog.dir/src/spdlog.cpp.o
[ 1%] Building CXX object _deps/spdlog-build/CMakeFiles/spdlog.dir/src/stdout_sinks.cpp.o
[ 1%] Building CXX object _deps/spdlog-build/CMakeFiles/spdlog.dir/src/color_sinks.cpp.o
[ 1%] Building CXX object _deps/spdlog-build/CMakeFiles/spdlog.dir/src/file_sinks.cpp.o
[ 1%] Building CXX object _deps/spdlog-build/CMakeFiles/spdlog.dir/src/async.cpp.o
[ 3%] Building CXX object _deps/spdlog-build/CMakeFiles/spdlog.dir/src/cfg.cpp.o
[ 3%] Linking CXX static library libspdlog.a
[ 3%] Built target spdlog
[ 5%] Building CXX object src/sample_library/CMakeFiles/sample_library.dir/sample_library.cpp.o
error: optimization flag '-fno-fat-lto-objects' is not supported [clang-diagnostic-ignored-optimization-argument,-warnings-as-errors]
7 warnings generated.
Suppressed 6 warnings (6 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
1 warning treated as error
make[2]: *** [src/sample_library/CMakeFiles/sample_library.dir/build.make:76: src/sample_library/CMakeFiles/sample_library.dir/sample_library.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:3662: src/sample_library/CMakeFiles/sample_library.dir/all] Error 2
make: *** [Makefile:166: all] Error 2
The error is optimization flag '-fno-fat-lto-objects' is not supported
. From a quick Google search, this post on StackOverflow says that the solution is to include the compiler flag -Wno-ignored-optimization-argument
.
I just followed the instructions for building in the Docker container, so I would expect it to work without modification. Is this project not maintained anymore?
Okay the solution was just to disable IPO/LTO in ProjectOptions.cmake.
48 option(myproject_ENABLE_IPO "Enable IPO/LTO" OFF)