cmake build integration

Is anyone working on modifications to the projects/CMakeLists.txt in llvm and the missing top-level CMakeLists.txt file for openmp? The openmp merge seems to be making rapid progress towards passing the OpenMP3.1_Validation test suite with the recent and proposed commits so it might be about time to start implementing the missing support for building openmp within the llvm cmake build infrastructure.

Yes, I currently have a preliminary version for this functionality. It includes:

  1. very basic top level CMakeLists.txt file which only calls add_subdirectory(runtime)

  2. correct install target, which will install in $DESTDIR/$CMAKE_INSTALL_PREFIX/lib{LLVM_LIBDIR_SUFFIX} for the libray, $DESTDIR/$CMAKE_INSTALL_PREFIX/lib{LLVM_LIBDIR_SUFFIX}/clang/{CLANG_VERSION}/include for omp.h and iomp.h

  3. I also have it recognize when it is a standalone build, so it knows when to ignore LLVM_ based variables, etc.

I have attached the whole thing as one patch here if you want to try it out or take a look at it.

Keep in mind that a lot of the changes are to the cmake/MicroTests.cmake file which is a refactoring job but not critical for

LLVM integration.

To try this out:

  1. checkout LLVM

  2. checkout clang into llvm/tools

  3. checkout compiler-rt into llvm/projects

  4. checkout openmp into llvm/projects

  5. apply the patch to the llvm/projects/openmp

  6. cd llvm/

  7. mkdir build && cd build

  8. cmake -DCMAKE_INSTALL_PREFIX=install –DCMAKE_C_COMPILER=…

  9. make

  10. make install

The final libiomp5.so should be in CMAKE_INSTALL_PREFIX/lib

And omp.h and iomp.h should be in CMAKE_INSTALL_PREFIX/lib/clang/3.x.x/include

I haven’t bothered putting the Fortran headers and modules in any install target yet but that can be done if necessary.

– Johnny

cmake_integration_v1.patch (42.4 KB)

I forgot to address modifications to projects/CMakeLists.txt. When it comes time, this is a one line change to this file that isn’t necessary for testing this patch because the projects/CMakeLists.txt file scans for any directory with a CMakeLists.txt in it and tries to build it. It would look something like this:

— a/projects/CMakeLists.txt

+++ b/projects/CMakeLists.txt

@@ -6,6 +6,7 @@ foreach(entry ${entries})

if(IS_DIRECTORY ${entry} AND EXISTS ${entry}/CMakeLists.txt)

if((NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/compiler-rt) AND

(NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/dragonegg) AND

  • (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/openmp) AND

(NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/libcxx))

add_subdirectory(${entry})

endif()

@@ -20,6 +21,9 @@ if(${LLVM_BUILD_RUNTIME})

if(NOT MSVC)

add_llvm_external_project(libcxx)

endif()

  • if(NOT MSVC)

  • add_llvm_external_project(openmp)

  • endif()

if(NOT LLVM_BUILD_EXTERNAL_COMPILER_RT)

add_llvm_external_project(compiler-rt)

endif()

– Johnny

Jonathan,
The preliminary version of the cmake support worked perfectly here on darwin with one caveat. The libiomp5.dylib built was only x86_64 and not a fat binary with both x86_64 and i386 code. Could you add a -DCMAKE_LIBIOMP5_FAT option or something similar to allow the build to be toggled to produce a fat binary for libiomp5.dylib on darwin? Thanks in advance.
Jack

Yes, I think I can get that to work.

– Johnny

Jonathan,
Thanks in advance. FYI, the context of the patch was disturbed by OMPT commits. The attached version adjusts your previous patch for those changes.
Jack

cmake_integration_v1_adjusted.patch (49 KB)

Hi,

Sorry for the trouble.

ompt.h should only be generated when it is enabled. The attached (incremental) patch fixes this and applies the changed style for OMPT output as well.

Regards,

Jonas

cmake_integration_ompt.patch (2.1 KB)