Skip to content

Commit b6f66a0

Browse files
authored
Add ARM64 support (#265)
* Initial ARM64 support * Update to .net8 for test app * Update include paths for profiler * Update include paths for profiler * Configurable arch * Configurable arch * Configurable arch * Configurable arch * Configurable arch * Update YAML pipeline to support ARM64 * update template repo name * update template repo name * update template repo name * update template repo name * update template repo name * update template repo name * update template repo name * update container image pre-reqs * update container image pre-reqs * update container image pre-reqs * update container image pre-reqs * update container image pre-reqs * update container image pre-reqs * update container image pre-reqs * update container image pre-reqs * update container image pre-reqs
1 parent 2b9586a commit b6f66a0

15 files changed

Lines changed: 228895 additions & 131475 deletions

File tree

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
#!/bin/bash
2-
echo "APT::Get::Assume-Yes \"true\";" > sudo /etc/apt/apt.conf.d/90assumeyes
3-
DEBIAN_FRONTEND=noninteractive
4-
sudo apt-get update
5-
sudo apt -y install software-properties-common
6-
sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
7-
sudo apt-get update
8-
sudo apt-get install -y --no-install-recommends \
2+
echo "APT::Get::Assume-Yes \"true\";" > /etc/apt/apt.conf.d/90assumeyes
3+
export DEBIAN_FRONTEND=noninteractive
4+
apt-get update
5+
apt -y install software-properties-common
6+
apt-get update
7+
apt upgrade -y \
8+
&& apt-get install -y --no-install-recommends \
99
ca-certificates \
1010
curl \
1111
jq \
1212
git \
1313
iputils-ping \
1414
libcurl4 \
15-
libicu55 \
15+
libicu66 \
1616
libunwind8 \
1717
netcat \
1818
gdb \
@@ -27,32 +27,37 @@ sudo apt-get install -y --no-install-recommends \
2727
pax \
2828
cmake \
2929
libelf-dev \
30+
clang \
3031
clang-12 \
3132
llvm \
3233
build-essential \
3334
libbpf-dev
3435

3536
# Set preference to clang-12
36-
yes '' | sudo update-alternatives --force --all
37-
sudo update-alternatives --remove-all clang
38-
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-12 100
39-
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-12 100
40-
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-12 100
37+
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-12 100
4138

4239
# Build and install bpftool
43-
sudo rm -rf /usr/sbin/bpftool
40+
rm -rf /usr/sbin/bpftool
4441
git clone --recurse-submodules https://github.com/libbpf/bpftool.git
4542
cd bpftool/src
46-
sudo make install
47-
sudo ln -s /usr/local/sbin/bpftool /usr/sbin/bpftool
43+
make install
44+
ln -s /usr/local/sbin/bpftool /usr/sbin/bpftool
4845

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

53-
# install .NET 6 for signing process and integration tests
54-
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
55-
sudo dpkg -i packages-microsoft-prod.deb
56-
rm packages-microsoft-prod.deb
57-
sudo apt -y update && sudo apt-get install -y dotnet-runtime-6.0
58-
sudo apt-get install -y dotnet-sdk-6.0
50+
arch=$(uname -m)
51+
if [[ "$arch" == "aarch64" ]]; then
52+
wget https://dot.net/v1/dotnet-install.sh
53+
chmod +x dotnet-install.sh
54+
./dotnet-install.sh --channel 8.0 --install-dir /usr/share/dotnet
55+
else
56+
# Not ARM64, we can install dotnet the normal way.
57+
# install .NET 6 for signing process and integration tests
58+
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
59+
dpkg -i packages-microsoft-prod.deb
60+
rm packages-microsoft-prod.deb
61+
apt -y update && apt-get install -y dotnet-runtime-8.0
62+
apt-get install -y dotnet-sdk-8.0
63+
fi

CMakeLists.txt

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,6 @@ set(libbpf_SOURCE_DIR ${CMAKE_BINARY_DIR}/libbpf/src/libbpf)
9595
set(procdump_ebpf_SOURCE_DIR ${CMAKE_SOURCE_DIR}/ebpf)
9696
set(sym_SOURCE_DIR ${CMAKE_SOURCE_DIR}/sym)
9797

98-
#
99-
# Configure files
100-
#
101-
configure_file(${procdump_INC}/ProcDumpVersion.h.in ${PROJECT_BINARY_DIR}/ProcDumpVersion.h)
102-
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
103-
configure_file(dist/DEBIAN.in/control.in DEBIANcontrol)
104-
configure_file(dist/SPECS.in/spec.in SPECS.spec)
105-
endif()
106-
10798
#
10899
# Compiler
109100
#
@@ -117,6 +108,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
117108
# Figure out which architecture we are building for
118109
if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64)
119110
set(CLRHOSTDEF -DHOST_AMD64 -DHOST_64BIT)
111+
set(ARCHITECTURE "amd64")
120112
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL x86 OR CMAKE_SYSTEM_PROCESSOR STREQUAL i686)
121113
set(CLRHOSTDEF -DHOST_X86)
122114
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL armv6 OR CMAKE_SYSTEM_PROCESSOR STREQUAL armv6l)
@@ -125,6 +117,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
125117
set(CLRHOSTDEF -DHOST_ARM)
126118
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL arm64)
127119
set(CLRHOSTDEF -DHOST_ARM64 -DHOST_64BIT)
120+
set(ARCHITECTURE "arm64")
128121
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL loongarch64)
129122
set(CLRHOSTDEF -DHOST_LOONGARCH64 -DHOST_64BIT)
130123
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL riscv64)
@@ -156,13 +149,28 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
156149
/usr/include
157150
)
158151

152+
if(NOT APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
153+
target_include_directories(ProcDumpProfiler PUBLIC
154+
/usr/include/aarch64-linux-gnu
155+
)
156+
endif()
157+
159158
add_custom_command(OUTPUT ProcDumpProfiler.o
160159
COMMAND "${LD}" -r -b binary -o "${PROJECT_BINARY_DIR}/ProcDumpProfiler.o" ProcDumpProfiler.so
161160
COMMENT "Packing ProcDumpProfiler.so into ProcDumpProfiler.o"
162161
DEPENDS ProcDumpProfiler
163162
)
164163
endif()
165164

165+
#
166+
# Configure files
167+
#
168+
configure_file(${procdump_INC}/ProcDumpVersion.h.in ${PROJECT_BINARY_DIR}/ProcDumpVersion.h)
169+
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
170+
configure_file(dist/DEBIAN.in/control.in DEBIANcontrol)
171+
configure_file(dist/SPECS.in/spec.in SPECS.spec)
172+
endif()
173+
166174
#
167175
# Make ProcDump
168176
#
@@ -225,6 +233,14 @@ target_include_directories(procdump PUBLIC
225233
${sym_SOURCE_DIR}
226234
${procdump_ebpf_SOURCE_DIR}
227235
)
236+
237+
if(NOT APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
238+
message(STATUS "Adding include path for aarch64: /usr/include/aarch64-linux-gnu")
239+
target_include_directories(procdump PUBLIC
240+
/usr/include/aarch64-linux-gnu
241+
)
242+
endif()
243+
228244
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
229245
add_dependencies(procdump libbpf procdump_ebpf)
230246
target_link_libraries(procdump ${libbpf_SOURCE_DIR}/src/libbpf.a elf z pthread)
@@ -260,8 +276,9 @@ target_link_libraries(ProcDumpTestApplication pthread)
260276
# Make package(s)
261277
#
262278
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
279+
message("Architecture: ${ARCHITECTURE}")
263280
add_custom_target(deb
264-
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"
281+
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}"
265282
DEPENDS "${CMAKE_SOURCE_DIR}/dist" "${PROJECT_BINARY_DIR}/procdump"
266283
)
267284

@@ -306,22 +323,38 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
306323
)
307324
set(CLANG_DEFINES -D __KERNEL__
308325
-D __BPF_TRACING__
309-
-D __TARGET_ARCH_x86
310326
-D __linux__
311327
)
328+
329+
if(NOT APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
330+
list(APPEND CLANG_DEFINES -D __TARGET_ARCH_arm64)
331+
endif()
332+
333+
if(NOT APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
334+
list(APPEND CLANG_DEFINES -D __TARGET_ARCH_x86)
335+
endif()
336+
312337
if (DEBUG_K)
313338
message("Using DEBUG_K Option...")
314339
list(APPEND CLANG_DEFINES -DDEBUG_K)
315340
endif()
316341

317342
set(CLANG_INCLUDES
318343
-I "/usr/include"
319-
-I "/usr/include/x86_64-linux-gnu"
344+
#-I "/usr/include/x86_64-linux-gnu"
320345
-I "${CMAKE_SOURCE_DIR}"
321346
-I "${CMAKE_BINARY_DIR}"
322347
-I "${libbpf_SOURCE_DIR}/src"
323348
)
324349

350+
if(NOT APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
351+
list(APPEND CLANG_INCLUDES -I "/usr/include/aarch64-linux-gnu")
352+
endif()
353+
354+
if(NOT APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
355+
list(APPEND CLANG_INCLUDES -I "/usr/include/x86_64-linux-gnu")
356+
endif()
357+
325358
add_custom_target(procdump_ebpf
326359
DEPENDS procdump_ebpf.o
327360
)

0 commit comments

Comments
 (0)