From f4c68951804088424793d38e69903e2af9c82614 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Fri, 7 Aug 2020 21:09:39 +0000 Subject: [PATCH] Use llvm-tblgen from build --- recipe/build.sh | 14 +++++--------- recipe/meta.yaml | 3 ++- recipe/patches/cross-compile.diff | 18 ++++++++++++------ 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/recipe/build.sh b/recipe/build.sh index c99fad1b..7c97d46b 100644 --- a/recipe/build.sh +++ b/recipe/build.sh @@ -4,9 +4,6 @@ IFS='.' read -r -a PKG_VER_ARRAY <<< "${PKG_VERSION}" sed -i.bak "s/libLTO.dylib/libLTO.${PKG_VER_ARRAY[0]}.dylib/g" lib/Driver/ToolChains/Darwin.cpp -mkdir build -cd build - if [[ "$variant" == "hcc" ]]; then CMAKE_ARGS="$CMAKE_ARGS -DKALMAR_BACKEND=HCC_BACKEND_AMDGPU -DHCC_VERSION_STRING=2.7-19365-24e69cd8-24e69cd8-24e69cd8" CMAKE_ARGS="$CMAKE_ARGS -DHCC_VERSION_MAJOR=2 -DHCC_VERSION_MINOR=7 -DHCC_VERSION_PATCH=19365" @@ -14,14 +11,13 @@ if [[ "$variant" == "hcc" ]]; then fi if [[ "$CC_FOR_BUILD" != "" && "$CC_FOR_BUILD" != "$CC" ]]; then - # This is a really convoluted way to cross compile. - # We are going to ask clang to build the native tools with host compiler - # and since we have QEMU, it's going to work. - # Correct way would be to build `llvm-tblgen` and `clang-tblgen` for the - # native platform and use them, but who has time? - CMAKE_ARGS="${CMAKE_ARGS} -DLLVM_USE_HOST_TOOLS=ON" + CMAKE_ARGS="${CMAKE_ARGS} -DLLVM_TABLEGEN_EXE=$BUILD_PREFIX/bin/llvm-tblgen -DNATIVE_LLVM_DIR=$BUILD_PREFIX/lib/cmake/llvm" + CMAKE_ARGS="${CMAKE_ARGS} -DCROSS_TOOLCHAIN_FLAGS_NATIVE=-DCMAKE_C_COMPILER=$CC_FOR_BUILD;-DCMAKE_CXX_COMPILER=$CXX_FOR_BUILD;-DCMAKE_C_FLAGS=-O2;-DCMAKE_CXX_FLAGS=-O2;-DCMAKE_EXE_LINKER_FLAGS=;-DCMAKE_MODULE_LINKER_FLAGS=;-DCMAKE_SHARED_LINKER_FLAGS=;-DCMAKE_STATIC_LINKER_FLAGS=;" fi +mkdir build +cd build + cmake \ -DCMAKE_INSTALL_PREFIX=$PREFIX \ -DCMAKE_PREFIX_PATH=$PREFIX \ diff --git a/recipe/meta.yaml b/recipe/meta.yaml index a56b3d2d..acb9e583 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -15,7 +15,7 @@ source: - patches/0002-clang-add-conda-specific-env-var-CONDA_BUILD_SYSROOT.patch - patches/0003-clang-Fix-normalizeProgramName-s-handling-of-dots-ou.patch - patches/0001-Set-VERSION-in-osx-as-well.patch - - patches/cross-compile.patch + - patches/cross-compile.diff #- patches/amd-roc-2.7.0.diff # [variant != "hcc"] #- patches/amd-roc-hcc-2.7.0.diff # [variant == "hcc"] folder: . @@ -38,6 +38,7 @@ requirements: # Building with ninja on windows for parallel builds - ninja # [win] - make # [unix] + - llvmdev =={{ version }} # [build_platform != target_platform] host: - libcxx {{ cxx_compiler_version }} # [osx] - llvmdev =={{ version }} diff --git a/recipe/patches/cross-compile.diff b/recipe/patches/cross-compile.diff index 37cb5e81..b7963cc8 100644 --- a/recipe/patches/cross-compile.diff +++ b/recipe/patches/cross-compile.diff @@ -1,13 +1,19 @@ ---- CMakeLists.txt 2020-08-07 20:15:39.605174899 +0000 -+++ CMakeLists.txt 2020-08-07 20:15:14.288910164 +0000 -@@ -111,6 +111,10 @@ +--- CMakeLists.txt.old 2020-08-07 20:15:39.605174899 +0000 ++++ CMakeLists.txt 2020-08-07 20:20:01.383910098 +0000 +@@ -111,6 +111,16 @@ option(LLVM_ENABLE_LIBXML2 "Use libxml2 if available." ON) include(AddLLVM) -+ if(LLVM_USE_HOST_TOOLS) ++ if(CMAKE_CROSSCOMPILING) ++ set(LLVM_USE_HOST_TOOLS ON) + include(CrossCompile) -+ llvm_create_cross_target(Clang NATIVE "" Release) -+ endif(LLVM_USE_HOST_TOOLS) ++ if (NOT NATIVE_LLVM_DIR) ++ message(FATAL_ERROR ++ "Crosscompiling standalone requires the variable NATIVE_LLVM_DIR ++ for building the native lldb-tblgen used during the build process.") ++ endif() ++ llvm_create_cross_target(Clang NATIVE "" Release -DLLVM_DIR=${NATIVE_LLVM_DIR}) ++ endif() include(TableGen) include(HandleLLVMOptions) include(VersionFromVCS)