This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] [cmake] Support generic installation
Needs ReviewPublic

Authored by clm on May 3 2017, 4:18 PM.

Details

Reviewers
beanz
Summary

By default, compiler-rt its libraries in subdirectories such as lib/linux of the specified CMAKE_INSTALL_PREFIX, with names such as libclang_rt.builtins-x86_64.a.

This patch creates a new CMake boolean named COMPILER_RT_GENERIC_BUILD that would cause the builtin library to be installed in lib/libclang_rt.builtins.a. This is intended to be used when compiler-rt is being built standalone.

To provide context, we are working on an embedded toolchain using llvm and would like to build and install separate copies of each multilib.

Diff Detail

Event Timeline

clm created this revision.May 3 2017, 4:18 PM

As an observer: I'm not quite convinced that "generic" is the term that describes what this is intending to do. I don't have better suggestions though. :/

Also, if you want it to only apply when you're using it for a standalone build, don't you want to be conditional on COMPILER_RT_STANDALONE_BUILD as well?

clm added a comment.May 12 2017, 6:27 AM

Thanks for the comments.

I am open to suggestions for a name different than "COMPILER_RT_GENERIC_BUILD", but I'm at a loss for an improvement.
The patch could be made dependent on COMPILER_RT_STANDALONE_BUILD and I'll post a new diff once I hear that the general idea of the patch is acceptable.

Thanks,
Catherine

One way to solve the naming issue is to side-step it, and instead add cmake a option to set COMPILER_RT_LIBRARY_INSTALL_DIR directly.

Something like:

set(COMPILER_RT_LIBRARY_INSTALL_DIR "" CACHE PATH "compiler-rt library install path")
if (NOT COMPILER_RT_LIBRARY_INSTALL_DIR)
  set(COMPILER_RT_LIBRARY_INSTALL_DIR
    ${COMPILER_RT_INSTALL_PATH}/lib/${COMPILER_RT_OS_DIR})
endif()
clm updated this revision to Diff 100326.May 25 2017, 4:17 PM

This version of the patch removes COMPILER_RT_GENERIC_BUILD and instead keys off of COMPILER_RT_LIBNAME (new) and COMPILER_RT_INSTALL_DIR. Does this look okay to install now?

Jon, thanks for the suggestion.

Catherine

beanz added inline comments.May 31 2017, 11:31 AM
CMakeLists.txt
41

What is the intention for this variable? Other than checking if it is set this doesn't seem to be used at all.

cmake/Modules/AddCompilerRT.cmake
141

These look like debugging messages that should be removed.

clm added inline comments.Jun 1 2017, 7:39 AM
CMakeLists.txt
41

The intention is to allow for a custom library name to be defined when cmake is invoked either by -C <cache_file> or -D options.

By using a combination of COMPILER_RT_LIBRARY_INSTALL_DIR and COMPILER_RT_LIBNAME, different multilib combinations from the same architecture can be built and differentiated by directory name.

For example:

install/lib/clang-runtimes/arm-none-eabi/v7/libclang_rt.builtins.a
install/lib/clang-runtimes/arm-none-eabi/v8/libclang_rt.builtins.a

etc.

clm updated this revision to Diff 101025.Jun 1 2017, 7:40 AM

The patch has now been updated to remove the debugging messages.

jroelofs added inline comments.Jun 5 2017, 10:17 AM
CMakeLists.txt
37

ditto for COMPILER_RT_LIBRARY_OUTPUT_DIR

cmake/Modules/AddCompilerRT.cmake
138

this should be:

set(libname ${COMPILER_RT_LIBNAME})
142

we need a call to format_object_libs here, I think.

cmake/base-config-ix.cmake
70

we need the same for COMPILER_RT_LIBRARY_OUTPUT_DIR too

beanz added inline comments.Jun 19 2017, 9:14 AM
CMakeLists.txt
41

It doesn't do that. In fact, the variable is unused.

Also since this really only pertains to the builtins library, I'd rather it not be titled so generically. Maybe COMPILER_RT_BUILTIN_LIBNAME instead?

cmake/Modules/AddCompilerRT.cmake
138

Given that this variable should only ever apply to the builtins library I think the override for the library name should be done elsewhere. Doing it in AddCompilerRT could have strange side-effects if the user configured more than just the builtins.

I would suggest adding a named parameter LIBNAME to add_compiler_rt_runtime that can be optionally set in lib/builtins/CMakeLists.txt if the user-exposed variable is set.