Since setting COMPILER_RT_USE_BUILTINS_LIBRARY would remove -z,defs flag, missing builtins library would continue to build unnoticed. Explicitly emit an error in such case.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
compiler-rt/cmake/Modules/AddCompilerRT.cmake | ||
---|---|---|
240 | Should be "NOTFOUND"? |
This broke bootstrapping compiler-rt builtins for me.
When bootstrapping a new toolchain from scratch, we don't have any compiler-rt builtins, so this test will necessarily fail - until the builtins have been compiled and installed.
I can work around it temporarily by not setting COMPILER_RT_USE_BUILTINS_LIBRARY while building the builtins, but if that flag isnt' set, it literally means "we should use libgcc instead of compiler-rt builtins".
I think this kind of fix would make sense:
diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake b/compiler-rt/cmake/Modules/AddCompilerRT.cmake index 1dde396b1f6..55fd125bac2 100644 --- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake +++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake @@ -231,13 +231,14 @@ function(add_compiler_rt_runtime name type) if(WIN32) set_output_name(output_name_${libname} ${name}_dynamic ${arch}) else() set_output_name(output_name_${libname} ${name} ${arch}) endif() endif() - if(COMPILER_RT_USE_BUILTINS_LIBRARY AND NOT type STREQUAL "OBJECT") + if(COMPILER_RT_USE_BUILTINS_LIBRARY AND NOT type STREQUAL "OBJECT" AND + NOT name STREQUAL "clang_rt.builtins") get_compiler_rt_target(${arch} target) find_compiler_rt_library(builtins ${target} builtins_${libname}) if(builtins_${libname} STREQUAL "NOTFOUND") message(FATAL_ERROR "Cannot find builtins library for the target architecture") endif() endif()
Because when building the builtins themselves, we can't expect to find builtins, right? (Alternatively the check against clang_rt.builtins could be moved down to the NOTFOUND case.)
You're right, we shouldn't fail the build for standalone clang_rt.builtins target. Please submit your change.
Should be "NOTFOUND"?