Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add build scripts for XRT #9290

Merged
merged 28 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e2048b2
Add build scripts for XRT
Mellich Aug 21, 2024
2a15a72
Refactoring and use of atomic_patch
Mellich Aug 23, 2024
a5a8b7d
Adding comments
Mellich Aug 23, 2024
130ad3e
Clean up using line
Mellich Aug 23, 2024
8031dd0
Update patch for the use with atomic_patch
Mellich Aug 23, 2024
9cb47fa
Rearrange linux patch
Mellich Aug 23, 2024
1373671
Add windows patches
Mellich Aug 23, 2024
455ef14
Patch RapidJSON dependency
Mellich Aug 23, 2024
45556cc
Apply patches for mingw support
Mellich Aug 23, 2024
28f668d
Fix cxx flags
Mellich Aug 23, 2024
367d173
Fix include upper case
Mellich Aug 23, 2024
1133539
Use ocl_icd bindings for windows
Mellich Aug 23, 2024
0009c8f
Add compat for libcurl
Mellich Aug 23, 2024
ddb3a06
Apply suggestions from code review
Mellich Aug 23, 2024
62d98d6
Further patching for windows version
Mellich Aug 23, 2024
847ca3e
Use rapidjson package
Mellich Aug 26, 2024
298ee1c
Sort patches by os
Mellich Aug 26, 2024
c11fc89
Patch library configs
Mellich Aug 30, 2024
215d584
Fix xdp link
Mellich Aug 30, 2024
f18354e
Further library import and export fixes for mingw
Mellich Aug 30, 2024
440b159
Add missing library
Mellich Aug 30, 2024
3cf86f4
also patch alveo core
Mellich Aug 30, 2024
f294153
Fix XDP exports and xrt_core dependencies
Mellich Aug 30, 2024
52bc7a3
Remove dependency to libffi
Mellich Aug 30, 2024
c9f7579
Copy over relevant libraries
Mellich Aug 30, 2024
51959f9
Fix symbol for xdp_core library
Mellich Aug 30, 2024
a1d4a84
Fix XRT install path
Mellich Aug 30, 2024
ae67573
Prevent overwrite of install prefix
Mellich Aug 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions X/xrt/build_tarballs.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Note that this script can accept some limited command-line arguments, run
# `julia build_tarballs.jl --help` to see a usage message
using BinaryBuilder

name = "xrt"
version = v"2.17"

# Collection of sources required to complete build
sources = [
GitSource("https://github.com/Xilinx/XRT.git", "a75e9843c875bac0f52d34a1763e39e16fb3c9a7"),
GitSource("https://github.com/Tencent/rapidjson.git", "ab1842a2dae061284c0a62dca1cc6d5e7e37e346"),
Mellich marked this conversation as resolved.
Show resolved Hide resolved
DirectorySource("./bundled")
]

# Bash recipe for building across all platforms
script = raw"""
# Install rapidjson
cd ${WORKSPACE}/srcdir/rapidjson
cmake -S . -B build \
-DCMAKE_INSTALL_PREFIX=${WORKSPACE}/srcdir/rapidjson/install \
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} \
-DCMAKE_BUILD_TYPE=Release \
-DRAPIDJSON_BUILD_DOC=No \
-DRAPIDJSON_BUILD_EXAMPLES=No \
-DRAPIDJSON_BUILD_TESTS=No \
-DRAPIDJSON_BUILD_CXX17=Yes
cmake --build build --parallel ${nproc}
cmake --install build

cd ${WORKSPACE}/srcdir/XRT
install_license LICENSE

# Apply patch with missing define
atomic_patch -p1 ../patches/linux/huge_shift.patch
# Explicitly add RapidJSON include paths
atomic_patch -p1 ../patches/fix_xclbinutil_cmake.patch

# mingw patches
atomic_patch -p1 ../patches/windows/remove_duplicate_type_defs.patch
atomic_patch -p1 ../patches/windows/disable_trace.patch
atomic_patch -p1 ../patches/windows/config_reader.patch
atomic_patch -p1 ../patches/windows/unistd.patch

atomic_patch -p1 ../patches/windows/no_static_boost.patch


if [[ "${target}" == *-w64-* ]]; then
export ADDITIONAL_CMAKE_CXX_FLAGS="-fpermissive -D_WINDOWS"
fi

# Statically link to boost
export XRT_BOOST_INSTALL=${WORKSPACE}/destdir

cd src
cmake -S . -B build \
-DCMAKE_INSTALL_PREFIX=${prefix} \
-DCMAKE_PREFIX_PATH=${WORKSPACE}/srcdir/rapidjson/install \
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} \
-DCMAKE_CXX_FLAGS="${ADDITIONAL_CMAKE_CXX_FLAGS}" \
-DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel ${nproc}
cmake --install build

# Copy folder from xrt to folder to root dest folder
cd ${WORKSPACE}/destdir/
cp -r ./xrt/* ./
rm -rf xrt
"""

# These are the platforms we will build for by default, unless further
# platforms are passed in on the command line
platforms = supported_platforms()
platforms = expand_cxxstring_abis(platforms)
filter!(p -> arch(p) == "x86_64", platforms)
filter!(p -> Sys.iswindows(p) || (Sys.islinux(p) && libc(p) == "glibc"), platforms)

# The products that we will ensure are always built
products = [
LibraryProduct("libxrt_coreutil", :libxrt_coreutil),
LibraryProduct("libxilinxopencl", :libxilinxopencl),
]

# Dependencies that must be installed before this package can be built
dependencies = [
BuildDependency("boost_jll"),
BuildDependency("ELFIO_jll"),
BuildDependency("OpenCL_Headers_jll"),
Dependency("Libffi_jll"),
Mellich marked this conversation as resolved.
Show resolved Hide resolved
Dependency("LibCURL_jll", platforms=filter(Sys.islinux, platforms)),
Mellich marked this conversation as resolved.
Show resolved Hide resolved
Dependency("libdrm_jll", platforms=filter(Sys.islinux, platforms)),
Dependency("Libuuid_jll", platforms=filter(Sys.islinux, platforms)),
Dependency("LibYAML_jll", platforms=filter(Sys.islinux, platforms)),
Dependency("Ncurses_jll", platforms=filter(Sys.islinux, platforms)),
Dependency("ocl_icd_jll", platforms=filter(Sys.islinux, platforms)),
Dependency("OpenSSL_jll", platforms=filter(Sys.islinux, platforms)),
Mellich marked this conversation as resolved.
Show resolved Hide resolved
Dependency("protobuf_c_jll", platforms=filter(Sys.islinux, platforms)),
Dependency("systemd_jll", platforms=filter(Sys.islinux, platforms)),
Dependency("systemtap_jll", platforms=filter(Sys.islinux, platforms)),
Dependency("OpenCL_jll", platforms=filter(Sys.iswindows, platforms)),
]

# Build the tarballs, and possibly a `build.jl` as well.
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies;
julia_compat="1.6", preferred_gcc_version=v"9")
Mellich marked this conversation as resolved.
Show resolved Hide resolved
19 changes: 19 additions & 0 deletions X/xrt/bundled/patches/fix_xclbinutil_cmake.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
diff --git a/src/runtime_src/tools/xclbinutil/CMakeLists.txt b/src/runtime_src/tools/xclbinutil/CMakeLists.txt
index 4c8a89232..58a211012 100644
--- a/src/runtime_src/tools/xclbinutil/CMakeLists.txt
+++ b/src/runtime_src/tools/xclbinutil/CMakeLists.txt
@@ -79,9 +79,14 @@ set(XCLBINUTIL_SRCS ${XCLBINUTIL_MAIN_FILE} ${XCLBINUTIL_FILES_SRCS})

add_executable(${XCLBINUTIL_NAME} ${XCLBINUTIL_SRCS})

+message(STATUS "RapidJSON include dir:" ${RapidJSON_INCLUDE_DIRS})
+target_include_directories(${XCLBINUTIL_NAME} PRIVATE ${RapidJSON_INCLUDE_DIRS}/..)
+
# Signing xclbin images currently is not support on windows
if(NOT WIN32)
target_link_libraries(${XCLBINUTIL_NAME} PRIVATE crypto)
+else()
+ target_link_libraries(${XCLBINUTIL_NAME} PRIVATE wsock32 ws2_32)
endif()

# Add compile definitions
11 changes: 11 additions & 0 deletions X/xrt/bundled/patches/linux/huge_shift.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/src/runtime_src/core/pcie/linux/shim.cpp
+++ b/src/runtime_src/core/pcie/linux/shim.cpp
@@ -64,6 +64,8 @@
#define SHIM_UNUSED __attribute__((unused))
#endif

+#define MAP_HUGE_SHIFT 26
+
#define GB(x) ((size_t) (x) << 30)
#define ARRAY_SIZE(x) (sizeof (x) / sizeof (x[0]))

11 changes: 11 additions & 0 deletions X/xrt/bundled/patches/windows/config_reader.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/src/runtime_src/core/common/config_reader.cpp
+++ b/src/runtime_src/core/common/config_reader.cpp
@@ -85,7 +85,7 @@ is_true(const std::string& str)
static std::string
get_self_path()
{
-#ifdef __GNUC__
+#ifdef __linux__
char buf[PATH_MAX] = {0};
auto len = ::readlink("/proc/self/exe", buf, PATH_MAX);
return std::string(buf, (len>0) ? len : 0);
59 changes: 59 additions & 0 deletions X/xrt/bundled/patches/windows/disable_trace.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
--- a/src/runtime_src/core/common/detail/windows/trace.h
+++ b/src/runtime_src/core/common/detail/windows/trace.h
@@ -23,11 +23,11 @@
#include "core/common/trace.h"
#include <memory>
#include <windows.h>
-#include <TraceLoggingProvider.h>
+// #include <TraceLoggingProvider.h>

// Forward declare the logging provider object. The provider
// is defined in a single compilation unit (core/common/trace.cpp).
-TRACELOGGING_DECLARE_PROVIDER(g_logging_provider);
+// TRACELOGGING_DECLARE_PROVIDER(g_logging_provider);

namespace xrt_core::trace::detail {

@@ -35,30 +35,30 @@ template <typename ProbeType>
inline void
add_event(ProbeType&& p)
{
- TraceLoggingWrite(g_logging_provider,
- "XRTTraceEvent", // must be a string literal
- TraceLoggingValue(std::forward<ProbeType>(p), "Event"));
+ // TraceLoggingWrite(g_logging_provider,
+ // "XRTTraceEvent", // must be a string literal
+ // TraceLoggingValue(std::forward<ProbeType>(p), "Event"));
}

template <typename ProbeType, typename A1>
inline void
add_event(ProbeType&& p, A1&& a1)
{
- TraceLoggingWrite(g_logging_provider,
- "XRTTraceEvent", // must be a string literal
- TraceLoggingValue(std::forward<ProbeType>(p), "Event"),
- TraceLoggingValue(std::forward<A1>(a1), "arg1"));
+ // TraceLoggingWrite(g_logging_provider,
+ // "XRTTraceEvent", // must be a string literal
+ // TraceLoggingValue(std::forward<ProbeType>(p), "Event"),
+ // TraceLoggingValue(std::forward<A1>(a1), "arg1"));
}

template <typename ProbeType, typename A1, typename A2>
inline void
add_event(ProbeType&& p, A1&& a1, A2&& a2)
{
- TraceLoggingWrite(g_logging_provider,
- "XRTTraceEvent", // must be a string literal
- TraceLoggingValue(std::forward<ProbeType>(p), "Event"),
- TraceLoggingValue(std::forward<A1>(a1), "arg1"),
- TraceLoggingValue(std::forward<A2>(a1), "arg2"));
+ // TraceLoggingWrite(g_logging_provider,
+ // "XRTTraceEvent", // must be a string literal
+ // TraceLoggingValue(std::forward<ProbeType>(p), "Event"),
+ // TraceLoggingValue(std::forward<A1>(a1), "arg1"),
+ // TraceLoggingValue(std::forward<A2>(a1), "arg2"));
}

template<typename ...Args>
13 changes: 13 additions & 0 deletions X/xrt/bundled/patches/windows/no_static_boost.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/src/CMake/nativeWin.cmake b/src/CMake/nativeWin.cmake
index 571b1cf66..646dd092b 100644
--- a/src/CMake/nativeWin.cmake
+++ b/src/CMake/nativeWin.cmake
@@ -29,7 +29,7 @@ endif(GIT_FOUND)

INCLUDE (FindBoost)
set(Boost_USE_MULTITHREADED ON)
-set(Boost_USE_STATIC_LIBS ON)
+set(Boost_USE_STATIC_LIBS OFF)
find_package(Boost
REQUIRED COMPONENTS system filesystem program_options)

13 changes: 13 additions & 0 deletions X/xrt/bundled/patches/windows/remove_duplicate_type_defs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- a/src/runtime_src/core/include/windows/types.h
+++ b/src/runtime_src/core/include/windows/types.h
@@ -19,7 +19,7 @@

#include <stdint.h>

-typedef int64_t ssize_t;
-typedef int pid_t;
+// typedef int64_t ssize_t;
+// typedef int pid_t;

#endif

11 changes: 11 additions & 0 deletions X/xrt/bundled/patches/windows/unistd.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/src/runtime_src/core/common/unistd.h
+++ b/src/runtime_src/core/common/unistd.h
@@ -20,7 +20,7 @@
#ifndef _WIN32
#include <unistd.h>
#else
-#include <Shlobj.h>
+#include <shlobj.h>
#endif

namespace xrt_core {