diff --git a/D/Dyninst/build_tarballs.jl b/D/Dyninst/build_tarballs.jl new file mode 100644 index 00000000000..af785607a09 --- /dev/null +++ b/D/Dyninst/build_tarballs.jl @@ -0,0 +1,95 @@ +# Note that this script can accept some limited command-line arguments, run +# `julia build_tarballs.jl --help` to see a usage message. +using BinaryBuilder +using Pkg + +name = "Dyninst" +version = v"12.3.0" + +# Collection of sources required to build hwloc +sources = [ + GitSource("https://github.com/dyninst/dyninst", "334b6856e28fd34a698ad74aa277f1399a814183"), + DirectorySource("bundled"), +] + +# Bash recipe for building across all platforms +script = raw""" +cd ${WORKSPACE}/srcdir/dyninst + +rm -f /usr/share/cmake/Modules/Compiler/._*.cmake + +# Find newer versions of TBB which are installed in a different directory structure +atomic_patch -p1 "${WORKSPACE}/srcdir/patches/tbb-version.patch" +# Handle missing enum constants +atomic_patch -p1 "${WORKSPACE}/srcdir/patches/df_1_pie.patch" +atomic_patch -p1 "${WORKSPACE}/srcdir/patches/dt_flags_1.patch" +atomic_patch -p1 "${WORKSPACE}/srcdir/patches/em_amdgpu.patch" +atomic_patch -p1 "${WORKSPACE}/srcdir/patches/r_x86_64_rex_gotpcrelx.patch" + +cmake -B build -S . \ + -DCMAKE_SKIP_BUILD_RPATH=OFF \ + -DCMAKE_BUILD_WITH_INSTALL_RPATH=OFF \ + -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=OFF \ + -DBUILD_SHARED_LIBS=ON \ + -DBUILD_TESTING=OFF \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_FIND_ROOT_PATH=${prefix} \ + -DCMAKE_INSTALL_PREFIX=${prefix} \ + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} \ + -DENABLE_STATIC_LIBS=NO \ + -DSTERILE_BUILD=ON \ + -DUSE_OpenMP=ON +cmake --build build --parallel ${nproc} +cmake --build build --parallel ${nproc} --target install +""" + +# 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) + +# Binutils and Elfutils require Linux +# TODO: We should be able to build on Windows without Binutils and Elfutils +filter!(Sys.islinux, platforms) +# cmake fails with "unknown platform" +filter!(p -> arch(p) ∉ ["armv6l", "armv7l"], platforms) +# linking fails with "undefined reference to `_r_debug'" +# TODO: Would this be fixed by linking against `libdl`? +filter!(p -> libc(p) ≠ "musl", platforms) + +# The products that we will ensure are always built +products = [ + ExecutableProduct("parseThat", :parseThat), + LibraryProduct("libcommon", :libcommon), + LibraryProduct("libdynC_API", :libdynC_API), + LibraryProduct("libdynDwarf", :libdynDwarf), + LibraryProduct("libdynElf", :libdynElf), + LibraryProduct("libdyninstAPI", :libdyninstAPI), + LibraryProduct("libdyninstAPI_RT", :libdyninstAPI_RT), + LibraryProduct("libinstructionAPI", :libinstructionAPI), + LibraryProduct("libparseAPI", :libparseAPI), + LibraryProduct("libpatchAPI", :libpatchAPI), + LibraryProduct("libpcontrol", :libpcontrol), + LibraryProduct("libstackwalk", :libstackwalk), + LibraryProduct("libsymLite", :libsymLite), + LibraryProduct("libsymtabAPI", :libsymtabAPI), +] + +# Dependencies that must be installed before this package can be built +dependencies = [ + # We need at least v2.41 of Binutils_jll to get an `-fPIC` version of `libiberty.a` + BuildDependency(PackageSpec(; name="Binutils_jll", version=v"2.41.0+1")), + BuildDependency("CMake_jll"), + Dependency(PackageSpec(name="CompilerSupportLibraries_jll", uuid="e66e0078-7015-5450-92f7-15fbd957f2ae")), + # We require at least v0.186 of Elfutils + Dependency("Elfutils_jll"; compat="0.189"), + # We require at least v2019.7 of oneTBB + Dependency("oneTBB_jll"; compat="2021.8.0"), + # We require at least v1.70.0 of Boost + Dependency("boost_jll"; compat="=1.79.0"), +] + +# Build the tarballs, and possibly a `build.jl` as well. +# The auditor fails, but the resulting libaries appear usable +build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; + julia_compat="1.6", dont_dlopen=true, preferred_gcc_version=v"7") diff --git a/D/Dyninst/bundled/patches/df_1_pie.patch b/D/Dyninst/bundled/patches/df_1_pie.patch new file mode 100644 index 00000000000..6209e067d07 --- /dev/null +++ b/D/Dyninst/bundled/patches/df_1_pie.patch @@ -0,0 +1,13 @@ +--- a/symtabAPI/src/Object-elf.C ++++ b/symtabAPI/src/Object-elf.C +@@ -328,6 +328,10 @@ + set debugInfoSections = list_of(string(SYMTAB_NAME)) + (string(STRTAB_NAME)); + ++#if !defined(DF_1_PIE) ++#define DF_1_PIE 0x08000000 ++#endif ++ + // loaded_elf(): populate elf section pointers + // for EEL rewritten code, also populate "code_*_" members + bool Object::loaded_elf(Offset &txtaddr, Offset &dataddr, diff --git a/D/Dyninst/bundled/patches/dt_flags_1.patch b/D/Dyninst/bundled/patches/dt_flags_1.patch new file mode 100644 index 00000000000..7b1608ddd78 --- /dev/null +++ b/D/Dyninst/bundled/patches/dt_flags_1.patch @@ -0,0 +1,13 @@ +--- a/symtabAPI/src/Object-elf.C ++++ b/symtabAPI/src/Object-elf.C +@@ -332,6 +332,10 @@ + #define DF_1_PIE 0x08000000 + #endif + ++#if !defined(DT_FLAGS_1) ++#define DT_FLAGS_1 0x6ffffffb ++#endif ++ + // loaded_elf(): populate elf section pointers + // for EEL rewritten code, also populate "code_*_" members + bool Object::loaded_elf(Offset &txtaddr, Offset &dataddr, diff --git a/D/Dyninst/bundled/patches/em_amdgpu.patch b/D/Dyninst/bundled/patches/em_amdgpu.patch new file mode 100644 index 00000000000..182555d71aa --- /dev/null +++ b/D/Dyninst/bundled/patches/em_amdgpu.patch @@ -0,0 +1,24 @@ +--- a/elf/src/Elf_X.C ++++ b/elf/src/Elf_X.C +@@ -1081,6 +1081,9 @@ + #if !defined(EM_AARCH64) + #define EM_AARCH64 183 + #endif ++#if !defined(EM_AMDGPU) ++#define EM_AMDGPU 224 ++#endif + Dyninst::Architecture Elf_X::getArch() const + { + switch(e_machine()) +--- a/dwarf/src/dwarfHandle.C ++++ b/dwarf/src/dwarfHandle.C +@@ -50,6 +50,9 @@ + #if !defined(EM_AARCH64) + #define EM_AARCH64 183 + #endif ++#if !defined(EM_AMDGPU) ++#define EM_AMDGPU 224 ++#endif + + static const Dwfl_Callbacks dwfl_callbacks = + { diff --git a/D/Dyninst/bundled/patches/r_x86_64_rex_gotpcrelx.patch b/D/Dyninst/bundled/patches/r_x86_64_rex_gotpcrelx.patch new file mode 100644 index 00000000000..0ff8d0f2864 --- /dev/null +++ b/D/Dyninst/bundled/patches/r_x86_64_rex_gotpcrelx.patch @@ -0,0 +1,14 @@ +--- a/symtabAPI/src/emitElfStatic-x86.C ++++ b/symtabAPI/src/emitElfStatic-x86.C +@@ -121,7 +121,11 @@ + + return true; + } + ++#if !defined(R_X86_64_REX_GOTPCRELX) ++#define R_X86_64_REX_GOTPCRELX 42 ++#endif ++ + bool emitElfStatic::archSpecificRelocation(Symtab *, Symtab *, char *targetData, relocationEntry &rel, + Offset dest, Offset relOffset, Offset globalOffset, LinkMap &lmap, + string &errMsg) diff --git a/D/Dyninst/bundled/patches/tbb-version.patch b/D/Dyninst/bundled/patches/tbb-version.patch new file mode 100644 index 00000000000..9ad4f2a8d19 --- /dev/null +++ b/D/Dyninst/bundled/patches/tbb-version.patch @@ -0,0 +1,14 @@ +--- a/cmake/Modules/FindTBB.cmake ++++ b/cmake/Modules/FindTBB.cmake +@@ -154,6 +154,10 @@ + if(TBB_INCLUDE_DIRS) + # Starting in 2020.1.1, tbb_stddef.h is replaced by version.h ++ # In the oneAPI releases, the directory structure changes: ++ # "tbb/version.h" still exists but only forwards to the oneapi ++ # version, and we cannot parse this. + set(_version_files "${TBB_INCLUDE_DIRS}/tbb/tbb_stddef.h" +- "${TBB_INCLUDE_DIRS}/tbb/version.h") ++ "${TBB_INCLUDE_DIRS}/tbb/version.h" ++ "${TBB_INCLUDE_DIRS}/oneapi/tbb/version.h") + foreach(f IN ITEMS ${_version_files}) + if(EXISTS ${f}) diff --git a/D/Dyninst/platforms.md b/D/Dyninst/platforms.md new file mode 100644 index 00000000000..22464a9a40e --- /dev/null +++ b/D/Dyninst/platforms.md @@ -0,0 +1,8 @@ +- aarch64-linux-gnu-cxx03 +- aarch64-linux-gnu-cxx11 +- i686-linux-gnu-cxx03 +- i686-linux-gnu-cxx11 +- powerpc64le-linux-gnu-cxx03 +- powerpc64le-linux-gnu-cxx11 +- x86_64-linux-gnu-cxx03 +- x86_64-linux-gnu-cxx11