Skip to content

Commit

Permalink
Use llvm-tblgen from build
Browse files Browse the repository at this point in the history
  • Loading branch information
isuruf committed Aug 7, 2020
1 parent acd1b73 commit f4c6895
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
14 changes: 5 additions & 9 deletions recipe/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,20 @@ 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"
CMAKE_ARGS="$CMAKE_ARGS -DKALMAR_SDK_COMMIT=24e69cd8 -DKALMAR_FRONTEND_COMMIT=24e69cd8 -DKALMAR_BACKEND_COMMIT=24e69cd8"
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 \
Expand Down
3 changes: 2 additions & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: .
Expand All @@ -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 }}
Expand Down
18 changes: 12 additions & 6 deletions recipe/patches/cross-compile.diff
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit f4c6895

Please sign in to comment.