diff --git a/libcxx/utils/ci/buildkite-pipeline.yml b/libcxx/utils/ci/buildkite-pipeline.yml --- a/libcxx/utils/ci/buildkite-pipeline.yml +++ b/libcxx/utils/ci/buildkite-pipeline.yml @@ -460,6 +460,19 @@ limit: 2 timeout_in_minutes: 120 + - label: "New standalone runtimes build" + command: "libcxx/utils/ci/run-buildbot new-standalone" + artifact_paths: + - "**/test-results.xml" + agents: + queue: "libcxx-builders" + os: "linux" + retry: + automatic: + - exit_status: -1 # Agent was lost + limit: 2 + timeout_in_minutes: 120 + - label: "Runtimes build" command: "libcxx/utils/ci/run-buildbot runtimes-build" artifact_paths: diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot --- a/libcxx/utils/ci/run-buildbot +++ b/libcxx/utils/ci/run-buildbot @@ -430,6 +430,23 @@ check-cxx-cxxabi ;; +new-standalone) + + clean + + echo "--- Generating CMake" + ${CMAKE} \ + -S "${MONOREPO_ROOT}/runtimes" \ + -B "${BUILD_DIR}" \ + -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \ + -DLLVM_INCLUDE_TESTS=ON \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \ + -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \ + -DLIBCXX_TEST_CONFIG="${MONOREPO_ROOT}/libcxx/test/configs/libcxx-trunk-shared.cfg.in" + + check-cxx-cxxabi +;; runtimes-build) clean diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt --- a/llvm/runtimes/CMakeLists.txt +++ b/llvm/runtimes/CMakeLists.txt @@ -13,6 +13,13 @@ if(LLVM_ENABLE_RUNTIMES STREQUAL "all" ) set(LLVM_ENABLE_RUNTIMES ${LLVM_ALL_RUNTIMES}) endif() +set(COMMON_CMAKE_ARGS "-DLLVM_RUNTIMES_BUILD=ON") +# Disable use of the installed C++ standard library when building runtimes. If +# MSVC is true, we must be using the clang-cl driver, which doesn't understand +# these flags. +if (NOT MSVC) + set(DEFAULT_COMMON_CMAKE_ARGS "-DCMAKE_REQUIRED_FLAGS=-nostdinc++;-nostdlib++") +endif() foreach(proj ${LLVM_ENABLE_RUNTIMES}) set(proj_dir "${CMAKE_CURRENT_SOURCE_DIR}/../../${proj}") if(IS_DIRECTORY ${proj_dir} AND EXISTS ${proj_dir}/CMakeLists.txt) @@ -87,6 +94,7 @@ -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default} -DCMAKE_C_COMPILER_WORKS=ON -DCMAKE_ASM_COMPILER_WORKS=ON + ${COMMON_CMAKE_ARGS} ${DEFAULT_COMMON_CMAKE_ARGS} ${BUILTINS_CMAKE_ARGS} PASSTHROUGH_PREFIXES COMPILER_RT USE_TOOLCHAIN @@ -109,6 +117,11 @@ endif() endforeach() + is_msvc_triple(is_msvc_target ${target}) + if (NOT is_msvc_target) + list(APPEND ${target}_extra_args "-DCMAKE_REQUIRED_FLAGS=-nostdinc++;-nostdlib++") + endif() + llvm_ExternalProject_Add(builtins-${target} ${compiler_rt_path}/lib/builtins DEPENDS ${ARG_DEPENDS} @@ -119,6 +132,7 @@ -DCMAKE_C_COMPILER_WORKS=ON -DCMAKE_ASM_COMPILER_WORKS=ON -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON + ${COMMON_CMAKE_ARGS} ${${target}_extra_args} USE_TOOLCHAIN TARGET_TRIPLE ${target} @@ -236,6 +250,7 @@ -DCMAKE_C_COMPILER_WORKS=ON -DCMAKE_CXX_COMPILER_WORKS=ON -DCMAKE_ASM_COMPILER_WORKS=ON + ${COMMON_CMAKE_ARGS} ${DEFAULT_COMMON_CMAKE_ARGS} ${RUNTIMES_CMAKE_ARGS} PASSTHROUGH_PREFIXES LLVM_ENABLE_RUNTIMES ${ARG_PREFIXES} @@ -324,6 +339,11 @@ list(APPEND ${name}_extra_args -DLLVM_ENABLE_RUNTIMES=${LLVM_ENABLE_RUNTIMES_PASSTHROUGH}) endif() + is_msvc_triple(is_msvc_target ${target}) + if (NOT is_msvc_target) + list(APPEND ${name}_extra_args "-DCMAKE_REQUIRED_FLAGS=-nostdinc++;-nostdlib++") + endif() + llvm_ExternalProject_Add(runtimes-${name} ${CMAKE_CURRENT_SOURCE_DIR}/../../runtimes DEPENDS ${${name}_deps} @@ -338,6 +358,7 @@ -DCMAKE_ASM_COMPILER_WORKS=ON -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON -DLLVM_RUNTIMES_TARGET=${name} + ${COMMON_CMAKE_ARGS} ${${name}_extra_args} EXTRA_TARGETS ${${name}_extra_targets} ${${name}_test_targets} diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt --- a/runtimes/CMakeLists.txt +++ b/runtimes/CMakeLists.txt @@ -75,11 +75,11 @@ set(LLVM_RUNTIME_OUTPUT_INTDIR ${LLVM_TOOLS_BINARY_DIR}) # This variable makes sure that e.g. llvm-lit is found. -set(LLVM_MAIN_SRC_DIR ${LLVM_BUILD_MAIN_SRC_DIR}) +set(LLVM_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../llvm) set(LLVM_CMAKE_PATH ${LLVM_MAIN_SRC_DIR}/cmake/modules) # This variable is used by individual runtimes to locate LLVM files. -set(LLVM_PATH ${LLVM_BUILD_MAIN_SRC_DIR}) +set(LLVM_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../llvm) if(APPLE) set(LLVM_ENABLE_LIBCXX ON CACHE BOOL "") @@ -88,13 +88,6 @@ include(CheckLibraryExists) include(CheckCCompilerFlag) -# Disable use of the installed C++ standard library when building runtimes. If -# MSVC is true, we must be using the clang-cl driver, which doesn't understand -# these flags. -if (NOT MSVC) - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdinc++ -nostdlib++") -endif() - # Avoid checking whether the compiler is working. set(LLVM_COMPILER_CHECKED ON) @@ -104,14 +97,16 @@ find_package(Python3 REQUIRED COMPONENTS Interpreter) +if (NOT LLVM_DEFAULT_TARGET_TRIPLE) + include(GetHostTriple) + get_host_triple(LLVM_DEFAULT_TARGET_TRIPLE) +endif() + # Use libtool instead of ar if you are both on an Apple host, and targeting Apple. if(CMAKE_HOST_APPLE AND APPLE) include(UseLibtool) endif() -# This can be used to detect whether we're in the runtimes build. -set(LLVM_RUNTIMES_BUILD ON) - foreach(entry ${runtimes}) get_filename_component(projName ${entry} NAME) @@ -172,6 +167,14 @@ ARGS ${RUNTIMES_LIT_EXTRA_ARGS} ) add_custom_target(runtimes-test-depends DEPENDS ${RUNTIMES_LIT_DEPENDS}) + + if (NOT LLVM_RUNTIMES_BUILD) + # If built by manually invoking cmake on this directory, we don't have + # llvm-lit. If invoked via llvm/runtimes, this is already set up at that + # level. + add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/llvm-lit + ${CMAKE_CURRENT_BINARY_DIR}/llvm-lit) + endif() endif() get_property(SUB_COMPONENTS GLOBAL PROPERTY SUB_COMPONENTS)