Skip to content

Commit

Permalink
add boost fetch-content
Browse files Browse the repository at this point in the history
  • Loading branch information
makslevental committed Aug 18, 2024
1 parent 9d8c3b7 commit 4e8892b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 56 deletions.
11 changes: 0 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,6 @@ jobs:
ninja: true
ccache: true

- name: Install boost
if: ${{ matrix.os == 'windows' }}
uses: MarkusJx/[email protected]
id: install-boost
with:
boost_install_dir: ${{ github.workspace }}
boost_version: 1.78.0
platform_version: 2019
toolset: msvc
link: shared

- uses: actions/setup-python@v4
if: ${{ matrix.os == 'windows' }}
with:
Expand Down
66 changes: 30 additions & 36 deletions cmake/iree_aie_xrt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,45 @@
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

include(${CMAKE_CURRENT_LIST_DIR}/iree_aie_utils.cmake)

if(TARGET iree-aie-xclbinutil)
return()
endif()

if(WIN32)
set(STATIC_OR_SHARED ON)
else()
# R_X86_64_PC32 relocation at offset 0x684 against symbol
#`boost::system::detail::cat_holder<void>::system_category_instance' can not be used; recompile with -fPIC
set(STATIC_OR_SHARED OFF)
endif()
set(Boost_USE_STATIC_LIBS ${SHARED_OR_STATIC} CACHE BOOL "" FORCE)
include(${CMAKE_CURRENT_LIST_DIR}/iree_aie_utils.cmake)

include(FetchContent)
find_package(Threads REQUIRED)
find_package(Boost REQUIRED COMPONENTS filesystem program_options system)
message(STATUS "Boost include directories:" ${Boost_INCLUDE_DIRS})
set(Boost_USE_STATIC_LIBS ON)
set(BOOST_ENABLE_CMAKE ON)
set(FETCHCONTENT_QUIET FALSE) # Needed to print downloading progress
FetchContent_Declare(
Boost
URL https://github.com/boostorg/boost/releases/download/boost-1.81.0/boost-1.81.0.7z
USES_TERMINAL_DOWNLOAD TRUE
GIT_PROGRESS TRUE
DOWNLOAD_NO_EXTRACT FALSE)
FetchContent_MakeAvailable(Boost)
set(_boost_libs
any
algorithm
asio
format
functional
lexical_cast
process
program_options
property_tree
tokenizer
tuple
uuid)
list(TRANSFORM _boost_libs PREPEND Boost::)

set(IREE_XRT_SOURCE_DIR "${IREE_AMD_AIE_SOURCE_DIR}/third_party/XRT/src")

if(NOT WIN32)
find_package(RapidJSON REQUIRED)
endif()

# Note: we do not simply add the subdirectory and use the imported target because
# XRT will build in its entirety when we do `ninja install` for IREE.

# obv we have python but XRT uses this var to look for an ancient version of pybind (and fail)
replace_string_in_file(${IREE_XRT_SOURCE_DIR}/python/pybind11/CMakeLists.txt
"if (HAS_PYTHON)" "if (FALSE)")
Expand Down Expand Up @@ -123,32 +135,18 @@ file(
"${_xclbinutil_source_dir}/XclBinUtilMain.cxx"
)

if(WIN32)
set(STATIC_OR_SHARED STATIC)
else()
# R_X86_64_PC32 relocation at offset 0x684 against symbol
#`boost::system::detail::cat_holder<void>::system_category_instance' can not be used; recompile with -fPIC
set(STATIC_OR_SHARED SHARED)
endif()
add_library(iree-aie-xclbinutil ${STATIC_OR_SHARED} ${_xclbinutil_srcs})
add_library(iree-aie-xclbinutil STATIC ${_xclbinutil_srcs})
target_compile_options(iree-aie-xclbinutil PRIVATE -fexceptions -frtti)

set(THREADS_PREFER_PTHREAD_FLAG ON)
set(_xclbin_libs
Boost::filesystem
Boost::program_options
Boost::system
Threads::Threads)
set(_xclbin_libs $<BUILD_LOCAL_INTERFACE:${_boost_libs}> Threads::Threads)
set(_xclbinutil_compile_definitions
-DBOOST_BIND_GLOBAL_PLACEHOLDERS
# prevents collision with bootgen's Section class
-DSection=XCLBinUtilSection)

if(WIN32)
list(APPEND _xclbinutil_compile_definitions -D"/EHsc")
# Uncomment if you get LINK : fatal error LNK1104: cannot open file
# 'libboost_filesystem-vc142-mt-gd-x64-1_74.lib'
# target_compile_definitions(iree-aie-xclbinutil PUBLIC BOOST_ALL_DYN_LINK)
else()
list(APPEND _xclbinutil_compile_definitions -DENABLE_JSON_SCHEMA_VALIDATION)
list(APPEND _xclbin_libs $<BUILD_LOCAL_INTERFACE:transformcdo>)
Expand All @@ -160,7 +158,6 @@ target_link_libraries(iree-aie-xclbinutil
PRIVATE ${_xclbin_libs})
target_include_directories(iree-aie-xclbinutil
PRIVATE ${XRT_BINARY_DIR}/gen
${Boost_INCLUDE_DIRS}
${IREE_XRT_SOURCE_DIR}/runtime_src/core/include
${_xclbinutil_source_dir})
# for some reason windows doesn't respect the standard output path without this
Expand Down Expand Up @@ -203,8 +200,5 @@ foreach(_core_lib IN LISTS _core_libs)
target_include_directories(${_core_lib} SYSTEM PUBLIC
${IREE_XRT_SOURCE_DIR}/runtime_src/core/common/elf)
target_compile_definitions(${_core_lib} PRIVATE -DBOOST_BIND_GLOBAL_PLACEHOLDERS)
target_link_libraries(${_core_lib} PRIVATE
Boost::filesystem
Boost::program_options
Boost::system)
target_link_libraries(${_core_lib} PRIVATE $<BUILD_LOCAL_INTERFACE:${_boost_libs}>)
endforeach()
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,9 @@ iree_cc_library(
iree-amd-aie::aie_runtime::iree_aie_runtime_static
iree::target::amd-aie::Transforms
iree-aie-bootgen
iree-aie-xclbinutil
)

if(IREE_AMD_AIE_ENABLE_XRT_DRIVER)
# on windows for some reason `DEPS` above doesn't trigger a build
# and also doesn't point to the .dll (points to .lib instead)
target_link_libraries(iree_target_amd-aie_Target_AIETargets PRIVATE iree-aie-xclbinutil)
# add_dependencies(iree_target_amd-aie_Target_AIETargets iree-aie-xclbinutil)
endif()

iree_cc_library(
NAME
Target
Expand Down
2 changes: 0 additions & 2 deletions iree_compiler_plugin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
find_package(Boost REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})

set(IREE_AMD_AIE_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}")
set(IREE_AMD_AIE_RUNTIME_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/runtime/src)
Expand Down

0 comments on commit 4e8892b

Please sign in to comment.