Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The CMake build script breaks check_ipo_supported #4059

Open
andyroiiid opened this issue Jun 2, 2024 · 0 comments
Open

The CMake build script breaks check_ipo_supported #4059

andyroiiid opened this issue Jun 2, 2024 · 0 comments
Labels

Comments

@andyroiiid
Copy link

Describe the bug
check_ipo_supported fails after adding zstd as a subdirectory.

To Reproduce
Steps to reproduce the behavior:

  1. Here's a repro for the bug: https://github.com/andyroiiid/zstd-cmake-lto-bug.git
  2. Clone the repo and run CMake
  3. The configuring process will fail:
"C:\Users\username\AppData\Local\Programs\CLion 2\bin\cmake\win\x64\bin\cmake.exe" -DCMAKE_BUILD_TYPE=RelWithDebInfo "-DCMAKE_MAKE_PROGRAM=C:/Users/username/AppData/Local/Programs/CLion 2/bin/ninja/win/x64/ninja.exe" -G Ninja -S E:\Projects\zstd-cmake-lto-bug -B E:\Projects\zstd-cmake-lto-bug\cmake-build-relwithdebinfo
-- CMAKE_VERSION = 3.28.1
-- LANGUAGES = CXX;RC
-- ZSTD VERSION: 1.5.6
-- CMAKE_INSTALL_PREFIX: C:/Program Files (x86)/zstd_cmake_lto_bug
-- CMAKE_INSTALL_LIBDIR: lib
-- ZSTD_LEGACY_SUPPORT not defined!
-- ZSTD_MULTITHREAD_SUPPORT is enabled
-- LANGUAGES = ASM;C;CXX;RC
CMake Error at C:/Users/username/AppData/Local/Programs/CLion 2/bin/cmake/win/x64/share/cmake-3.28/Modules/CheckIPOSupported.cmake:68 (message):
  IPO is not supported (CMake doesn't support IPO for current C compiler).
Call Stack (most recent call first):
  C:/Users/username/AppData/Local/Programs/CLion 2/bin/cmake/win/x64/share/cmake-3.28/Modules/CheckIPOSupported.cmake:250 (_ipo_not_supported)
  CMakeLists.txt:20 (check_ipo_supported)


-- Configuring incomplete, errors occurred!

[Finished]

Here's a copy of the CMakeLists.txt:

cmake_minimum_required(VERSION 3.9)
project(zstd_cmake_lto_bug CXX)

set(CMAKE_CXX_STANDARD 20)

message(STATUS "CMAKE_VERSION = ${CMAKE_VERSION}")

include(CheckIPOSupported)

get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
message(STATUS "LANGUAGES = ${LANGUAGES}")

check_ipo_supported() # <----------------- This succeeds

add_subdirectory(zstd/build/cmake EXCLUDE_FROM_ALL)

get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
message(STATUS "LANGUAGES = ${LANGUAGES}")

check_ipo_supported() # <----------------- This fails

Expected behavior
check_ipo_supported should not fail after zstd is included.

Screenshots and charts
N/A

Desktop:
Repro environment 1:

  • OS: Microsoft Windows 11 Home
  • Version: 10.0.22631 Build 22631
  • Compiler: Microsoft (R) C/C++ Optimizing Compiler Version 19.40.33811 for x64
  • Flags: N/A - The bug happens before compilation.
  • Other relevant hardware specs: i9-13950HX (Not exactly sure what to put here.)
  • Build system: CMake

Repro environment 2:

  • OS: Ubuntu 22.04 jammy
  • Version: x86_64 Linux 5.15.0-107-generic
  • Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
  • Flags: N/A - The bug happens before compilation.
  • Other relevant hardware specs: AMD Ryzen 5 PRO 2500U (Not exactly sure what to put here.)
  • Build system: CMake

Additional context
I noticed that zstd adds ASM and C to the project language list. CMake will configure successfully if I change the project declaration from project(zstd_cmake_lto_bug CXX) to project(zstd_cmake_lto_bug C CXX).

@Cyan4973 Cyan4973 added the build label Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants