I'm trying to use LTO in clang (with cmake): flag -emit-llvm
set in compile time, output generated with -c
flag, so LLVM bitcode is the result. The problem is, cmake give me result with ".o" suffix, but i need ".bc". I found other codes that used this: set(CMAKE_C_OUTPUT_EXTENSION .bc)
, but it didn't work.
cmake_minimum_required(VERSION 3.3)
project(cc C)
set(CMAKE_BUILD_TYPE Release)
enable_language(C)
file(GLOB_RECURSE SOURCES "src/*.c")
add_executable(cc ${SOURCES})
if (UNIX)
target_compile_options(cc PRIVATE "-Weverything")
target_compile_options(cc PRIVATE "-std=c11")
target_compile_options(cc PRIVATE "-emit-llvm")
set(CMAKE_C_FLAGS_RELEASE "-Ofast -DNDEBUG")
set(CMAKE_C_OUTPUT_EXTENSION ".bc")
endif()