[LLVMdev] compiler-rt CMake build

Alexey Samsonov samsonov at google.com
Fri Feb 21 06:49:23 PST 2014


Hi Brad,

I have a few questions regarding ExternalProject_Add. For me it doesn't
really work as expected.
I add the following code to the tools/clang/runtime/CMakeLists.txt to
configure compiler-rt as external project:

  ExternalProject_Add(compiler-rt

    #DEPENDS clang clang++ llvm-config

    PREFIX ${CMAKE_BINARY_DIR}/projects/compiler-rt
    SOURCE_DIR ${COMPILER_RT_SRC_ROOT}

    CMAKE_ARGS -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang

               -DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++

               -DCMAKE_BUILD_TYPE=Release

               -DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config


 -DCOMPILER_RT_OUTPUT_DIR=${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}


 -DCOMPILER_RT_INSTALL_PATH=lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}

               # -DCOMPILER_RT_INCLUDE_TESTS=ON

    INSTALL_COMMAND ""

    )
  add_dependencies(compiler-rt clang clang++ llvm-config)

1) Looks like "DEPENDS" option is just broken - docs here (
http://www.kitware.com/media/html/BuildingExternalProjectsWithCMake2.8.html)
state that you can pass CMake targets there, but if I uncomment that line,
I get errors like:

CMake Error at /usr/local/share/cmake-2.8/Modules/ExternalProject.cmake:720
(message):
  External project "clang" has no stamp_dir
Call Stack (most recent call first):
  /usr/local/share/cmake-2.8/Modules/ExternalProject.cmake:932
(ExternalProject_Get_Property)
  /usr/local/share/cmake-2.8/Modules/ExternalProject.cmake:1488
(_ep_get_step_stampfile)
  /usr/local/share/cmake-2.8/Modules/ExternalProject.cmake:1702
(_ep_add_configure_command)
  tools/clang/runtime/CMakeLists.txt:18 (ExternalProject_Add)

as if "clang" was supposed to be another external project. FTR, I use cmake
2.8.10.2.

2) The dependencies don't act as expected: if I run "make compiler-rt", it
builds Clang, uses it to configure
compiler-rt and builds compiler-rt. But if I then change the Clang sources,
and re-run "make compiler-rt",
Clang is re-built, but compiler-rt is *not* re-configured or re-built,
while I definitely want this.

3) The same doc (
http://www.kitware.com/media/html/BuildingExternalProjectsWithCMake2.8.html)
states that
"One drawback, however, is ExternalProject’s lack of full dependency
analysis. Changes in header files of an external project may
not cause an incremental rebuild of the affected sources that depend on
those headers."
Looks like even if I modify *sources* under projects/compiler-rt, and
re-run "make compiler-rt" from the build
directory, it doesn't re-build the compiler-rt libraries. This makes
incremental development simply impossible.

What am I doing wrong?

On Fri, Feb 7, 2014 at 1:59 AM, Brad King <brad.king at kitware.com> wrote:

> On 02/06/2014 01:02 PM, Alexey Samsonov wrote:
> > OK, I feel like I need to learn more about ExternalProject_Add magic.
>
> It is the CMake equivalent to a configure+make build target that
> runs configure+make for another project.
>
> > I have a few quick questions for people with knowledge - currently:
> > 1) "compiler-rt"'s CMake needs to know about targets in the Clang build
> tree ("clang") and
> > in LLVM build tree ("FileCheck", llvm-* command-line tools, googletest
> etc.), and uses common
> > macro from LLVM's CMake modules like "configute_lit_site_cfg",
> "parse_arguments".
>
> This will be possible once LLVM and Clang are taught to provide proper
> content in LLVMConfig.cmake and ClangConfig.cmake package configuration
> files.  The patch series I proposed in the thread Greg linked at the
> start of this thread is the first step to do that.
>
> > 2) top-level targets from compiler-rt's CMake files are visible at the
> root of LLVM's build tree,
> > so that I can run "make check-asan" or even "make clang_rt.asan-x86_64"
> from the root of
> > the build tree.
>
> This would not work with ExternalProject_Add because the CMake
> running on LLVM or Clang would not see the targets in compiler-rt
> since the project will not even be processed until build (make) time.
> In return the compiler-rt would be able to build using the just-built
> Clang because it will now be available when CMake runs on compiler-rt.
> (IIUC this is currently the case for configure+make.)  Also compiler-rt
> could now be built outside of a LLVM/Clang that was built unaware of
> compiler-rt.
>
> It is also possible to make project/compiler-rt build optionally
> with add_subdirectory instead of ExternalProject_Add, as it does now,
> with the cost of not using the just-built Clang.
>

-- 
Alexey Samsonov, MSK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140221/e77c08c8/attachment.html>


More information about the llvm-dev mailing list