This is an archive of the discontinued LLVM Phabricator instance.

[runtime][CMake] use static_library try compile
AbandonedPublic

Authored by jsji on Mar 18 2021, 1:39 PM.

Details

Summary

We were using static library trycompile in compiler-rt, eg:

compiler-rt/lib/builtins/CMakeLists.txt:
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
compiler-rt/cmake/Modules/AddCompilerRT.cmake:
-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY

We should also use it in runtime build.
Or else CMake may not be able to detect ABI and others correctly when
configuring compiler-rt.

eg: On AIX, we can't build compiler-rt without this fix in runtime build,
linking CMakeCCompilerABI.c will fail hence failing to detect ABI.

Diff Detail

Event Timeline

jsji created this revision.Mar 18 2021, 1:39 PM
jsji requested review of this revision.Mar 18 2021, 1:39 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 18 2021, 1:39 PM

See this thread https://groups.google.com/g/llvm-dev/c/KWy1-Dw_9Rk, as I mentioned there I don't think we can set CMAKE_TRY_COMPILE_TARGET_TYPE unconditionally to STATIC_LIBRARY because doing so is going to disable some checks which may cause issues for some targets.

You should be able to bypass the failing ABI detection by setting CMAKE_{C,CXX,ASM}_COMPILER_WORKS to ON.

jsji added a comment.Mar 19 2021, 7:12 AM

See this thread https://groups.google.com/g/llvm-dev/c/KWy1-Dw_9Rk, as I mentioned there I don't think we can set CMAKE_TRY_COMPILE_TARGET_TYPE unconditionally to STATIC_LIBRARY because doing so is going to disable some checks which may cause issues for some targets.

You should be able to bypass the failing ABI detection by setting CMAKE_{C,CXX,ASM}_COMPILER_WORKS to ON.

Thanks for the info. I will do some more experiments then.

jsji abandoned this revision.Mar 22 2021, 12:02 PM

This only *workaround* the failure in AIX runtime build, which we should fix in AIX runtime, so this is not required. Thanks Petr.