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

Dyninst: New package #7473

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ea3e257
Dyninst: New package
eschnett Oct 3, 2023
c5940e2
Dyninst: Update build script
eschnett Oct 3, 2023
335c4ab
Dyninst: Require newer cmake
eschnett Oct 3, 2023
be2eeed
Dyninst: libparseThat does not exist
eschnett Oct 5, 2023
6e68985
Dyninst: Experiment with rpath settings
eschnett Oct 5, 2023
e1d538e
Dyninst: Avoid unsupported platforms
eschnett Oct 5, 2023
eb9d18a
Dyninst: Add comment
eschnett Oct 6, 2023
2247528
Dyninst: Start debugging
eschnett Oct 10, 2023
e75f23c
Dyninst: Start debugging
eschnett Oct 10, 2023
4a3a4e9
Dyninst: More debugging
eschnett Oct 10, 2023
347ddb8
Dyninst: More debugging
eschnett Oct 10, 2023
ddb823a
Dyninst: More debugging
eschnett Oct 10, 2023
fdc8148
Dyninst: More debugging
eschnett Oct 10, 2023
7f99ccc
Dyninst: More debugging
eschnett Oct 10, 2023
96b82d9
Dyninst: More debugging
eschnett Oct 10, 2023
03e3382
Dyninst: More debugging
eschnett Oct 10, 2023
e700afb
Dyninst: More debugging
eschnett Oct 10, 2023
acb4d50
Dyninst: More debugging
eschnett Oct 10, 2023
e817d46
Dyninst: More debugging
eschnett Oct 10, 2023
9b9723b
Dyninst: More debugging
eschnett Oct 10, 2023
8da836f
Dyninst: More debugging
eschnett Oct 10, 2023
286565c
Dyninst: More debugging
eschnett Oct 10, 2023
5549369
Dyninst: More debugging
eschnett Oct 10, 2023
712d758
Dyninst: More debugging
eschnett Oct 10, 2023
5d6ee51
Dyninst: More debugging
eschnett Oct 10, 2023
63a04eb
Dyninst: More debugging
eschnett Oct 11, 2023
56d54ec
Dyninst: More debugging
eschnett Oct 11, 2023
7de75ea
Dyninst: More debugging
eschnett Oct 11, 2023
e765583
Dyninst: More debugging
eschnett Oct 11, 2023
503e2f7
Dyninst: More debugging
eschnett Oct 11, 2023
530f049
Dyninst: Skip auditor
eschnett Oct 19, 2023
0d4c42c
Dyninst: Remove debugging code
eschnett Oct 19, 2023
68fe4e5
Dyninst: Don't dlopen the generated libraries
eschnett Oct 19, 2023
6894bdb
Dyninst: Remove debugging code
eschnett Oct 19, 2023
7393e35
Dyninst: Do dlopen the generated libraries
eschnett Oct 19, 2023
d67e931
Dyninst: Don't dlopen the generated libraries
eschnett Oct 19, 2023
b09e4bf
Dyninst: Don't skip auditing
eschnett Oct 19, 2023
03ab070
Merge branch 'master' into eschnett/DynInst
eschnett Oct 19, 2023
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
95 changes: 95 additions & 0 deletions D/Dyninst/build_tarballs.jl
Original file line number Diff line number Diff line change
@@ -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")
13 changes: 13 additions & 0 deletions D/Dyninst/bundled/patches/df_1_pie.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- a/symtabAPI/src/Object-elf.C
+++ b/symtabAPI/src/Object-elf.C
@@ -328,6 +328,10 @@
set<string> 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,
13 changes: 13 additions & 0 deletions D/Dyninst/bundled/patches/dt_flags_1.patch
Original file line number Diff line number Diff line change
@@ -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,
24 changes: 24 additions & 0 deletions D/Dyninst/bundled/patches/em_amdgpu.patch
Original file line number Diff line number Diff line change
@@ -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 =
{
14 changes: 14 additions & 0 deletions D/Dyninst/bundled/patches/r_x86_64_rex_gotpcrelx.patch
Original file line number Diff line number Diff line change
@@ -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)
14 changes: 14 additions & 0 deletions D/Dyninst/bundled/patches/tbb-version.patch
Original file line number Diff line number Diff line change
@@ -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})
8 changes: 8 additions & 0 deletions D/Dyninst/platforms.md
Original file line number Diff line number Diff line change
@@ -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