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 all 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
92 changes: 92 additions & 0 deletions X/xrt/build_tarballs.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# 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"),
DirectorySource("./bundled")
]

# Bash recipe for building across all platforms
script = raw"""
cd ${WORKSPACE}/srcdir/XRT
install_license LICENSE

if [[ "${target}" == *-linux-* ]]; then
# Apply patch with missing define
atomic_patch -p1 ../patches/linux/huge_shift.patch
fi

if [[ "${target}" == *-w64-* ]]; then
# mingw patches
atomic_patch -p1 ../patches/windows/fix_xclbinutil_cmake.patch
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/ocl_bindings.patch
atomic_patch -p1 ../patches/windows/aligned_malloc.patch
atomic_patch -p1 ../patches/windows/no_static_boost.patch
atomic_patch -p1 ../patches/windows/config.patch
atomic_patch -p1 ../patches/windows/xbutil.patch
atomic_patch -p1 ../patches/windows/xdp-exports.patch
atomic_patch -p1 ../patches/windows/xrt-core-lib.patch
export ADDITIONAL_CMAKE_CXX_FLAGS="-fpermissive -D_WINDOWS"
fi

atomic_patch -p1 ../patches/fix-install-dir.patch

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

cd src
cmake -S . -B build \
-DCMAKE_INSTALL_PREFIX=${prefix} \
-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
"""

# 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),
LibraryProduct("libxrt_core", :libxrt_core),
LibraryProduct("libxdp_core", :libxdp_core),
LibraryProduct("libxrt++", :libxrtxx),
]

# Dependencies that must be installed before this package can be built
dependencies = [
BuildDependency("boost_jll"),
BuildDependency("ELFIO_jll"),
BuildDependency("OpenCL_Headers_jll"),
Dependency("ocl_icd_jll"),
Dependency("rapidjson_jll"),
Dependency("LibCURL_jll", platforms=filter(Sys.islinux, platforms); compat="7.73, 8"),
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("OpenSSL_jll", platforms=filter(Sys.islinux, platforms); compat="3.0.8"),
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)),
]

# 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")
38 changes: 38 additions & 0 deletions X/xrt/bundled/patches/fix-install-dir.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
--- a/src/CMake/nativeLnx.cmake
+++ b/src/CMake/nativeLnx.cmake
@@ -138,9 +138,9 @@ if (XRT_ENABLE_HIP)
endif()

# --- XRT Variables ---
-set (XRT_INSTALL_DIR "xrt")
+set (XRT_INSTALL_DIR ".")
set (XRT_INSTALL_BIN_DIR "${XRT_INSTALL_DIR}/bin")
-set (XRT_INSTALL_UNWRAPPED_DIR "${XRT_INSTALL_BIN_DIR}/unwrapped")
+set (XRT_INSTALL_UNWRAPPED_DIR "${XRT_INSTALL_BIN_DIR}/bin/unwrapped")
set (XRT_INSTALL_INCLUDE_DIR "${XRT_INSTALL_DIR}/include")
set (XRT_INSTALL_LIB_DIR "${XRT_INSTALL_DIR}/lib${LIB_SUFFIX}")
set (XRT_INSTALL_PYTHON_DIR "${XRT_INSTALL_DIR}/python")
--- a/src/CMake/nativeWin.cmake
+++ b/src/CMake/nativeWin.cmake
@@ -10,7 +10,7 @@
# XRT_VERSION_PATCH

# install under c:/xrt
-set (CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/xilinx")
+#set (CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/xilinx")

# pdb install dir
set (CMAKE_PDB_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/symbols")
@@ -70,9 +70,9 @@ endif()
INCLUDE (FindGTest)

# --- XRT Variables ---
-set (XRT_INSTALL_DIR "xrt")
-set (XRT_INSTALL_BIN_DIR "${XRT_INSTALL_DIR}")
-set (XRT_INSTALL_UNWRAPPED_DIR "${XRT_INSTALL_BIN_DIR}/unwrapped")
+set (XRT_INSTALL_DIR ".")
+set (XRT_INSTALL_BIN_DIR "${XRT_INSTALL_DIR}/bin")
+set (XRT_INSTALL_UNWRAPPED_DIR "${XRT_INSTALL_BIN_DIR}/bin/unwrapped")
set (XRT_INSTALL_INCLUDE_DIR "${XRT_INSTALL_DIR}/include")
set (XRT_INSTALL_LIB_DIR "${XRT_INSTALL_DIR}/lib")
set (XRT_INSTALL_PYTHON_DIR "${XRT_INSTALL_DIR}/python")
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]))

21 changes: 21 additions & 0 deletions X/xrt/bundled/patches/windows/aligned_malloc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--- a/src/runtime_src/core/common/memalign.h
+++ b/src/runtime_src/core/common/memalign.h
@@ -21,6 +21,18 @@
#include <memory>
#include <stdexcept>

+// Add memalgin definitions here since
+// they are not present because of a bug:
+// https://sourceforge.net/p/mingw-w64/bugs/192/
+extern void * _aligned_malloc(
+ size_t size,
+ size_t alignment
+);
+
+extern void _aligned_free (
+ void *memblock
+);
+
namespace xrt_core {

inline int
125 changes: 125 additions & 0 deletions X/xrt/bundled/patches/windows/config.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
--- a/src/runtime_src/core/common/config.h
+++ b/src/runtime_src/core/common/config.h
@@ -21,13 +21,13 @@
//------------------Enable dynamic linking on windows-------------------------//

#ifdef _WIN32
-# ifdef XRT_CORE_COMMON_SOURCE
-# define XRT_CORE_COMMON_EXPORT __declspec(dllexport)
-# else
-# define XRT_CORE_COMMON_EXPORT __declspec(dllimport)
-# endif
+#ifdef XRT_CORE_COMMON_SOURCE
+#define XRT_CORE_COMMON_EXPORT __declspec(dllexport)
+#else
+#define XRT_CORE_COMMON_EXPORT __declspec(dllimport)
+#endif
#endif
-#ifdef __GNUC__
+#ifndef _WIN32
# ifdef XRT_CORE_COMMON_SOURCE
# define XRT_CORE_COMMON_EXPORT __attribute__ ((visibility("default")))
# else
@@ -36,15 +36,15 @@
#endif

#ifndef XRT_CORE_COMMON_EXPORT
-# define XRT_CORE_COMMON_EXPORT
+#define XRT_CORE_COMMON_EXPORT
#endif

-#ifdef __GNUC__
+#ifndef _WIN32
# define XRT_CORE_UNUSED __attribute__((unused))
#endif

#ifdef _WIN32
-# define XRT_CORE_UNUSED
+#define XRT_CORE_UNUSED
#endif

#endif
--- a/src/runtime_src/core/include/xrt/detail/config.h
+++ b/src/runtime_src/core/include/xrt/detail/config.h
@@ -12,7 +12,7 @@
# define XRT_API_EXPORT __declspec(dllimport)
# endif
#endif
-#ifdef __GNUC__
+#ifdef __linux__
# ifdef XRT_API_SOURCE
# define XRT_API_EXPORT __attribute__ ((visibility("default")))
# else
--- a/src/runtime_src/core/pcie/noop/config.h
+++ b/src/runtime_src/core/pcie/noop/config.h
@@ -27,7 +27,7 @@
# define XRT_CORE_PCIE_NOOP_EXPORT __declspec(dllimport)
# endif
#endif
-#ifdef __GNUC__
+#ifdef __linux__
# ifdef XRT_CORE_PCIE_NOOP_SOURCE
# define XRT_CORE_PCIE_NOOP_EXPORT __attribute__ ((visibility("default")))
# else
--- a/src/runtime_src/core/pcie/windows/alveo/config.h
+++ b/src/runtime_src/core/pcie/windows/alveo/config.h
@@ -14,7 +14,7 @@
# define XRT_CORE_PCIE_WINDOWS_EXPORT __declspec(dllimport)
# endif
#endif
-#ifdef __GNUC__
+#ifdef __linux__
# ifdef XRT_CORE_PCIE_WINDOWS_SOURCE
# define XRT_CORE_PCIE_WINDOWS_EXPORT __attribute__ ((visibility("default")))
# else
--- a/src/runtime_src/xdp/config.h
+++ b/src/runtime_src/xdp/config.h
@@ -28,7 +28,7 @@
#define XDP_CORE_EXPORT __declspec(dllimport)
#endif
#endif
-#ifdef __GNUC__
+#ifndef _WIN32
#ifdef XDP_CORE_SOURCE
#define XDP_CORE_EXPORT __attribute__ ((visibility("default")))
#else
@@ -47,7 +47,7 @@
#define XDP_PLUGIN_EXPORT __declspec(dllimport)
#endif
#endif
-#ifdef __GNUC__
+#ifndef _WIN32
#ifdef XDP_PLUGIN_SOURCE
#define XDP_PLUGIN_EXPORT __attribute__ ((visibility("default")))
#else
--- a/src/runtime_src/xocl/config.h
+++ b/src/runtime_src/xocl/config.h
@@ -29,7 +29,7 @@
# endif
#endif

-#ifdef __GNUC__
+#ifndef _WIN32
# ifdef XRT_XOCL_SOURCE
# define XRT_XOCL_EXPORT __attribute__ ((visibility("default")))
# else
--- a/src/runtime_src/xrt/config.h
+++ b/src/runtime_src/xrt/config.h
@@ -26,7 +26,7 @@
# define XRT_EXPORT __declspec(dllimport)
# endif
#endif
-#ifdef __GNUC__
+#ifdef __linux__
# ifdef XRT_SOURCE
# define XRT_EXPORT __attribute__ ((visibility("default")))
# else
@@ -38,7 +38,7 @@
# define XRT_EXPORT
#endif

-#ifdef __GNUC__
+#ifdef __linux__
# define XRT_UNUSED __attribute__((unused))
#endif

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);
Loading