Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add ARM64 support #265

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

Merged
merged 27 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
947a791
Initial ARM64 support
MarioHewardt Dec 13, 2024
f53e9ee
Update to .net8 for test app
MarioHewardt Dec 13, 2024
1178f9c
Update include paths for profiler
MarioHewardt Dec 17, 2024
1fa71e6
Update include paths for profiler
MarioHewardt Dec 17, 2024
2962003
Configurable arch
MarioHewardt Dec 17, 2024
0799d72
Configurable arch
MarioHewardt Dec 17, 2024
2bda4cf
Configurable arch
MarioHewardt Dec 17, 2024
b5e7b61
Configurable arch
MarioHewardt Dec 17, 2024
6cc8ca3
Configurable arch
MarioHewardt Dec 17, 2024
2db5ed5
Merge remote-tracking branch 'upstream/master'
MarioHewardt Jan 21, 2025
cf38d23
Update YAML pipeline to support ARM64
MarioHewardt Jan 21, 2025
4f1371f
update template repo name
MarioHewardt Jan 23, 2025
83a476b
update template repo name
MarioHewardt Jan 23, 2025
dbe440c
update template repo name
MarioHewardt Jan 23, 2025
b7537ef
update template repo name
MarioHewardt Jan 23, 2025
4cc2a56
update template repo name
MarioHewardt Jan 23, 2025
9f24483
update template repo name
MarioHewardt Jan 23, 2025
273c844
update template repo name
MarioHewardt Jan 23, 2025
8e11c2a
update container image pre-reqs
MarioHewardt Jan 23, 2025
3af9b29
update container image pre-reqs
MarioHewardt Jan 23, 2025
194b93a
update container image pre-reqs
MarioHewardt Jan 23, 2025
483556a
update container image pre-reqs
MarioHewardt Jan 23, 2025
15b0866
update container image pre-reqs
MarioHewardt Jan 23, 2025
d9cf549
update container image pre-reqs
MarioHewardt Jan 23, 2025
bfa2b55
update container image pre-reqs
MarioHewardt Jan 23, 2025
1483a3c
update container image pre-reqs
MarioHewardt Jan 23, 2025
ee8211b
update container image pre-reqs
MarioHewardt Jan 23, 2025
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
51 changes: 28 additions & 23 deletions .devcontainer/install-ubuntu-dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#!/bin/bash
echo "APT::Get::Assume-Yes \"true\";" > sudo /etc/apt/apt.conf.d/90assumeyes
DEBIAN_FRONTEND=noninteractive
sudo apt-get update
sudo apt -y install software-properties-common
sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
echo "APT::Get::Assume-Yes \"true\";" > /etc/apt/apt.conf.d/90assumeyes
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt -y install software-properties-common
apt-get update
apt upgrade -y \
&& apt-get install -y --no-install-recommends \
ca-certificates \
curl \
jq \
git \
iputils-ping \
libcurl4 \
libicu55 \
libicu66 \
libunwind8 \
netcat \
gdb \
Expand All @@ -27,32 +27,37 @@ sudo apt-get install -y --no-install-recommends \
pax \
cmake \
libelf-dev \
clang \
clang-12 \
llvm \
build-essential \
libbpf-dev

# Set preference to clang-12
yes '' | sudo update-alternatives --force --all
sudo update-alternatives --remove-all clang
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-12 100
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-12 100
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-12 100
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-12 100

# Build and install bpftool
sudo rm -rf /usr/sbin/bpftool
rm -rf /usr/sbin/bpftool
git clone --recurse-submodules https://github.com/libbpf/bpftool.git
cd bpftool/src
sudo make install
sudo ln -s /usr/local/sbin/bpftool /usr/sbin/bpftool
make install
ln -s /usr/local/sbin/bpftool /usr/sbin/bpftool

# install debbuild
wget https://github.com/debbuild/debbuild/releases/download/22.02.1/debbuild_22.02.1-0ubuntu20.04_all.deb \
&& sudo dpkg -i debbuild_22.02.1-0ubuntu20.04_all.deb
&& dpkg -i debbuild_22.02.1-0ubuntu20.04_all.deb

# install .NET 6 for signing process and integration tests
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt -y update && sudo apt-get install -y dotnet-runtime-6.0
sudo apt-get install -y dotnet-sdk-6.0
arch=$(uname -m)
if [[ "$arch" == "aarch64" ]]; then
wget https://dot.net/v1/dotnet-install.sh
chmod +x dotnet-install.sh
./dotnet-install.sh --channel 8.0 --install-dir /usr/share/dotnet
else
# Not ARM64, we can install dotnet the normal way.
# install .NET 6 for signing process and integration tests
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
apt -y update && apt-get install -y dotnet-runtime-8.0
apt-get install -y dotnet-sdk-8.0
fi
57 changes: 45 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,6 @@ set(libbpf_SOURCE_DIR ${CMAKE_BINARY_DIR}/libbpf/src/libbpf)
set(procdump_ebpf_SOURCE_DIR ${CMAKE_SOURCE_DIR}/ebpf)
set(sym_SOURCE_DIR ${CMAKE_SOURCE_DIR}/sym)

#
# Configure files
#
configure_file(${procdump_INC}/ProcDumpVersion.h.in ${PROJECT_BINARY_DIR}/ProcDumpVersion.h)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
configure_file(dist/DEBIAN.in/control.in DEBIANcontrol)
configure_file(dist/SPECS.in/spec.in SPECS.spec)
endif()

#
# Compiler
#
Expand All @@ -117,6 +108,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
# Figure out which architecture we are building for
if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64)
set(CLRHOSTDEF -DHOST_AMD64 -DHOST_64BIT)
set(ARCHITECTURE "amd64")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL x86 OR CMAKE_SYSTEM_PROCESSOR STREQUAL i686)
set(CLRHOSTDEF -DHOST_X86)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL armv6 OR CMAKE_SYSTEM_PROCESSOR STREQUAL armv6l)
Expand All @@ -125,6 +117,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(CLRHOSTDEF -DHOST_ARM)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL arm64)
set(CLRHOSTDEF -DHOST_ARM64 -DHOST_64BIT)
set(ARCHITECTURE "arm64")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL loongarch64)
set(CLRHOSTDEF -DHOST_LOONGARCH64 -DHOST_64BIT)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL riscv64)
Expand Down Expand Up @@ -156,13 +149,28 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
/usr/include
)

if(NOT APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
target_include_directories(ProcDumpProfiler PUBLIC
/usr/include/aarch64-linux-gnu
)
endif()

add_custom_command(OUTPUT ProcDumpProfiler.o
COMMAND "${LD}" -r -b binary -o "${PROJECT_BINARY_DIR}/ProcDumpProfiler.o" ProcDumpProfiler.so
COMMENT "Packing ProcDumpProfiler.so into ProcDumpProfiler.o"
DEPENDS ProcDumpProfiler
)
endif()

#
# Configure files
#
configure_file(${procdump_INC}/ProcDumpVersion.h.in ${PROJECT_BINARY_DIR}/ProcDumpVersion.h)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
configure_file(dist/DEBIAN.in/control.in DEBIANcontrol)
configure_file(dist/SPECS.in/spec.in SPECS.spec)
endif()

#
# Make ProcDump
#
Expand Down Expand Up @@ -225,6 +233,14 @@ target_include_directories(procdump PUBLIC
${sym_SOURCE_DIR}
${procdump_ebpf_SOURCE_DIR}
)

if(NOT APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
message(STATUS "Adding include path for aarch64: /usr/include/aarch64-linux-gnu")
target_include_directories(procdump PUBLIC
/usr/include/aarch64-linux-gnu
)
endif()

if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
add_dependencies(procdump libbpf procdump_ebpf)
target_link_libraries(procdump ${libbpf_SOURCE_DIR}/src/libbpf.a elf z pthread)
Expand Down Expand Up @@ -260,8 +276,9 @@ target_link_libraries(ProcDumpTestApplication pthread)
# Make package(s)
#
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
message("Architecture: ${ARCHITECTURE}")
add_custom_target(deb
COMMAND "${CMAKE_SOURCE_DIR}/makePackages.sh" "${CMAKE_SOURCE_DIR}" "${PROJECT_BINARY_DIR}" "${PACKAGE_NAME}" "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}" "0" "deb"
COMMAND "${CMAKE_SOURCE_DIR}/makePackages.sh" "${CMAKE_SOURCE_DIR}" "${PROJECT_BINARY_DIR}" "${PACKAGE_NAME}" "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}" "0" "deb" "${ARCHITECTURE}"
DEPENDS "${CMAKE_SOURCE_DIR}/dist" "${PROJECT_BINARY_DIR}/procdump"
)

Expand Down Expand Up @@ -306,22 +323,38 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
)
set(CLANG_DEFINES -D __KERNEL__
-D __BPF_TRACING__
-D __TARGET_ARCH_x86
-D __linux__
)

if(NOT APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
list(APPEND CLANG_DEFINES -D __TARGET_ARCH_arm64)
endif()

if(NOT APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
list(APPEND CLANG_DEFINES -D __TARGET_ARCH_x86)
endif()

if (DEBUG_K)
message("Using DEBUG_K Option...")
list(APPEND CLANG_DEFINES -DDEBUG_K)
endif()

set(CLANG_INCLUDES
-I "/usr/include"
-I "/usr/include/x86_64-linux-gnu"
#-I "/usr/include/x86_64-linux-gnu"
-I "${CMAKE_SOURCE_DIR}"
-I "${CMAKE_BINARY_DIR}"
-I "${libbpf_SOURCE_DIR}/src"
)

if(NOT APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
list(APPEND CLANG_INCLUDES -I "/usr/include/aarch64-linux-gnu")
endif()

if(NOT APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
list(APPEND CLANG_INCLUDES -I "/usr/include/x86_64-linux-gnu")
endif()

add_custom_target(procdump_ebpf
DEPENDS procdump_ebpf.o
)
Expand Down
Loading
Loading