Skip to content

Commit 74baa2a

Browse files
authored
ci: arm segfault (#749)
* package(docker): update to clang-19 * ci: update github actions * ci: update build to clang-19 * ci: disable clang to stop double linking?
1 parent 6d3f495 commit 74baa2a

9 files changed

Lines changed: 157 additions & 109 deletions

File tree

.dockerignore

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
1-
./docker
2-
./build
1+
*
2+
!.git
3+
!cmake/
4+
!config/
5+
!include/
6+
!lib/
7+
!test/
8+
!tools/
9+
!unittests/
10+
!utils/*.sh
11+
!utils/*.py
12+
13+
!.gitmodules
14+
!CMakeLists.txt
15+
!Config.cmake.in
16+
!config.h.in

.github/workflows/ci.yml

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ on:
66
pull_request:
77
branches: [ master, development ]
88

9+
# TODO test in tree build?
10+
# TODO test conan build
911
jobs:
1012
build:
1113
runs-on: ubuntu-20.04
1214
strategy:
1315
fail-fast: true
1416
matrix:
15-
compiler: [ [clang++-14, clang-14] ]
17+
compiler: [ [clang++-19, clang-19, "clang-19 libclang-rt-19-dev"] ]
1618
build: [ Debug, Release, DebugLibdeps ]
1719
include:
1820
- build: Debug
@@ -36,24 +38,7 @@ jobs:
3638
- name: Install Phasar Dependencies
3739
shell: bash
3840
run: |
39-
./utils/InstallAptDependencies.sh
40-
sudo apt-get -y install --no-install-recommends libboost-graph-dev
41-
42-
- name: Install Strategy Dependencies
43-
shell: bash
44-
run: |
45-
sudo apt-key adv --fetch-keys https://apt.llvm.org/llvm-snapshot.gpg.key
46-
sudo add-apt-repository -y 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main'
47-
sudo apt-get update
48-
sudo apt-get -y install --no-install-recommends \
49-
${{ matrix.compiler[1] }} \
50-
llvm-14-dev \
51-
libllvm14 \
52-
libclang-common-14-dev \
53-
libclang-14-dev \
54-
libclang-cpp14-dev \
55-
clang-tidy-14 \
56-
libclang-rt-14-dev
41+
./utils/InstallAptDependencies.sh --noninteractive tzdata ${{ matrix.compiler[2] }}
5742
5843
- uses: swift-actions/setup-swift@v2
5944
with:
@@ -64,15 +49,14 @@ jobs:
6449
CC: ${{ matrix.compiler[1] }}
6550
shell: bash
6651
run: |
67-
mkdir build
68-
cd build
69-
cmake .. \
52+
cmake -S . -B build \
7053
-DCMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
54+
-DBUILD_PHASAR_CLANG=OFF \
7155
-DBUILD_SWIFT_TESTS=ON \
7256
-DPHASAR_USE_Z3=ON \
7357
${{ matrix.flags }} \
7458
-G Ninja
75-
cmake --build .
59+
ninja -C build
7660
7761
- name: Run Unittests
7862
shell: bash

.github/workflows/docker.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ on:
77
jobs:
88
push_to_registries:
99
name: Push Docker image to multiple registries
10-
runs-on: ubuntu-20.04
10+
runs-on: ubuntu-24.04
1111
permissions:
1212
packages: write
1313
contents: read
1414
steps:
1515
- name: Check out the repo
16-
uses: actions/checkout@v3
16+
uses: actions/checkout@v4
1717
- name: Set up QEMU
18-
uses: docker/setup-qemu-action@v2
18+
uses: docker/setup-qemu-action@v3
1919
- name: Set up Docker Buildx
20-
uses: docker/setup-buildx-action@v2
20+
uses: docker/setup-buildx-action@v3
2121
# If we want to publish an image of PhASAR to the official docker hub we
2222
# can just use the following code and set the corresponding secrets.
2323
# - name: Log in to Docker Hub
@@ -27,7 +27,7 @@ jobs:
2727
# password: ${{ secrets.DOCKER_TOKEN }}
2828

2929
- name: Log in to the Container registry
30-
uses: docker/login-action@v2
30+
uses: docker/login-action@v3
3131
with:
3232
registry: ghcr.io
3333
username: ${{ github.actor }}
@@ -41,7 +41,7 @@ jobs:
4141
# here we could add a second image for the official docker registry
4242
# sse/phasar
4343
- name: Build and push Docker images
44-
uses: docker/build-push-action@v3
44+
uses: docker/build-push-action@v6
4545
with:
4646
context: .
4747
platforms: linux/amd64,linux/arm64

CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required (VERSION 3.14)
1+
cmake_minimum_required (VERSION 3.16)
22

33
# Avoid IPO/LTO Warnings:
44
cmake_policy(SET CMP0069 NEW)
@@ -8,9 +8,11 @@ set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
88
cmake_policy(SET CMP0077 NEW)
99
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
1010

11-
# Allow overwriting cache variables of external projects from this CMakeLists file
12-
cmake_policy(SET CMP0126 NEW)
13-
set(CMAKE_POLICY_DEFAULT_CMP0126 NEW)
11+
if ("${CMAKE_VERSION}" GREATER_EQUAL "3.21")
12+
# Allow overwriting cache variables of external projects from this CMakeLists file
13+
cmake_policy(SET CMP0126 NEW)
14+
set(CMAKE_POLICY_DEFAULT_CMP0126 NEW)
15+
endif()
1416

1517
# Allow portable use of CMAKE_VISIBILITY_INLINES_HIDDEN not only for shared libraries
1618
cmake_policy(SET CMP0063 NEW)

Dockerfile

Lines changed: 32 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,32 @@
1-
FROM ubuntu:22.04
2-
ARG LLVM_INSTALL_DIR="/usr/local/llvm-14"
3-
LABEL Name=phasar Version=2403
4-
5-
RUN apt -y update && apt install bash sudo -y
6-
7-
8-
WORKDIR /usr/src/phasar
9-
RUN mkdir -p /usr/src/phasar/utils
10-
11-
COPY ./utils/InitializeEnvironment.sh /usr/src/phasar/utils/
12-
RUN ./utils/InitializeEnvironment.sh
13-
14-
RUN apt-get -y install --no-install-recommends \
15-
cmake \
16-
ninja-build \
17-
libstdc++6 \
18-
libboost-graph-dev
19-
20-
COPY ./utils/InstallAptDependencies.sh /usr/src/phasar/utils/
21-
RUN ./utils/InstallAptDependencies.sh
22-
23-
RUN apt-get update && \
24-
apt-get install -y software-properties-common
25-
26-
RUN apt-key adv --fetch-keys https://apt.llvm.org/llvm-snapshot.gpg.key && \
27-
add-apt-repository -y 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main' && \
28-
apt-get update && \
29-
apt-get -y install --no-install-recommends \
30-
clang-14 \
31-
llvm-14-dev \
32-
libllvm14 \
33-
libclang-common-14-dev \
34-
libclang-14-dev \
35-
libclang-cpp14-dev \
36-
clang-tidy-14 \
37-
libclang-rt-14-dev
38-
39-
RUN pip3 install Pygments pyyaml
40-
41-
42-
43-
# installing wllvm
44-
RUN pip3 install wllvm
45-
46-
ENV CC=/usr/bin/clang-14
47-
ENV CXX=/usr/bin/clang++-14
48-
49-
COPY . /usr/src/phasar
50-
51-
RUN git submodule init
52-
RUN git submodule update
53-
RUN mkdir -p build && cd build && \
54-
cmake .. \
55-
-DCMAKE_BUILD_TYPE=Release \
56-
-DPHASAR_TARGET_ARCH="" \
57-
-DCMAKE_CXX_COMPILER=$CXX \
58-
-G Ninja && \
59-
cmake --build .
60-
61-
ENTRYPOINT [ "./build/tools/phasar-cli/phasar-cli" ]
1+
ARG baseimage="ubuntu:24.04"
2+
FROM "$baseimage" as build
3+
4+
RUN --mount=type=bind,source=./utils/InstallAptDependencies.sh,target=/InstallAptDependencies.sh \
5+
set -eux; \
6+
./InstallAptDependencies.sh --noninteractive tzdata clang-19 libclang-rt-19-dev
7+
8+
ENV CC=/usr/bin/clang-19 \
9+
CXX=/usr/bin/clang++-19
10+
11+
FROM build
12+
13+
ARG RUN_TESTS=OFF
14+
RUN --mount=type=bind,source=.,target=/usr/src/phasar,rw \
15+
set -eux; \
16+
cd /usr/src/phasar; \
17+
git submodule update --init; \
18+
cmake -S . -B cmake-build/Release \
19+
-DCMAKE_BUILD_TYPE=Release \
20+
-DPHASAR_TARGET_ARCH="" \
21+
-DPHASAR_ENABLE_SANITIZERS=ON \
22+
-DBUILD_PHASAR_CLANG=ON \
23+
-DPHASAR_USE_Z3=ON \
24+
-DPHASAR_ALLOW_LTO_IN_RELEASE_BUILD=ON \
25+
-DPHASAR_BUILD_UNITTESTS=$RUN_TESTS \
26+
-DPHASAR_BUILD_OPENSSL_TS_UNITTESTS=OFF \
27+
-G Ninja; \
28+
ninja -C cmake-build/Release install; \
29+
[ "${RUN_TESTS}" = "ON" ] && ctest --test-dir cmake-build/Release --output-on-failure || true; \
30+
phasar-cli --version
31+
32+
ENTRYPOINT [ "phasar-cli" ]

cmake/phasar_macros.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ function(generate_ll_file)
6161

6262
if (NOT clang)
6363
# Conan deps are available in in PATH
64-
foreach(hint "${LLVM_TOOLS_BINARY_DIR}" "${Clang_INCLUDE_DIR}/../bin" "${LLVM_INCLUDE_DIR}/../bin" "/usr/local/llvm-${PHASAR_LLVM_VERSION}/bin")
64+
set(default_llvm "${LLVM_TOOLS_BINARY_DIR}" )
65+
set(fallback_llvm "${Clang_INCLUDE_DIR}/../bin" "${LLVM_INCLUDE_DIR}/../bin")
66+
set(user_compiled_llvm "/usr/local/llvm-${PHASAR_LLVM_VERSION}/bin")
67+
set(package_manager_llvm "/usr/lib/llvm-${PHASAR_LLVM_VERSION}/bin/")
68+
foreach(hint ${default_llvm} ${fallback_llvm} ${user_compiled_llvm} ${package_manager_llvm})
6569
if ("${CMAKE_VERSION}" VERSION_GREATER_EQUAL "3.20")
6670
cmake_path(NORMAL_PATH hint OUTPUT_VARIABLE hint)
6771
endif()

unittests/PhasarLLVM/DataFlow/IfdsIde/Problems/IDEGeneralizedLCATest.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ TEST_F(IDEGeneralizedLCATest, StringTestCpp) {
131131
getLastInstructionOf(HA->getProjectIRDB().getFunction("main"));
132132
GroundTruth.push_back({{EdgeValue("Hello, World")},
133133
3,
134-
std::stoi(getMetaDataID(LastMainInstruction))});
134+
static_cast<unsigned int>(
135+
std::stoi(getMetaDataID(LastMainInstruction)))});
135136
compareResults(GroundTruth);
136137
}
137138

utils/InitializeEnvironment.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

utils/InstallAptDependencies.sh

Lines changed: 83 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,85 @@
11
#!/bin/bash
2-
set -e
2+
set -euo pipefail
33

4-
sudo apt-get update
5-
sudo apt-get install git -y
6-
sudo apt-get install zlib1g-dev python3 python3-pip g++ ninja-build cmake -y
4+
if printf "%s\n" "$@" | grep -Eqe '^--noninteractive|-ni$'; then
5+
readonly noninteractive="true"
6+
shift
7+
else
8+
readonly noninteractive="false"
9+
fi
10+
readonly LLVM_IR_VERSION=14
11+
additional_dependencies=("$@")
12+
13+
(
14+
source /etc/os-release
15+
distro="$ID" # ubuntu / debian / alpine / centos / rocky
16+
codename="${VERSION_CODENAME:-}" # focal / stretch / - / - / -
17+
distro_version="$VERSION_ID" # 22.04 / 12 / 3.21.2 / 8 / 9.3
18+
# can be used to adapt to different distros / version
19+
20+
if "$noninteractive"; then
21+
export DEBIAN_FRONTEND=noninteractive
22+
fi
23+
24+
packages=("${additional_dependencies[@]}")
25+
packages+=(
26+
git ca-certificates build-essential cmake ninja-build # build
27+
binutils # LTO
28+
"clang-$LLVM_IR_VERSION" # compiler for IR
29+
"libclang-rt-$LLVM_IR_VERSION-dev" # ASAN
30+
libboost-graph-dev libsqlite3-dev libssl-dev zlib1g-dev "libclang-$LLVM_IR_VERSION-dev" "llvm-$LLVM_IR_VERSION-dev" "libclang-common-$LLVM_IR_VERSION-dev" # build deps
31+
)
32+
33+
34+
pkg_mgr=()
35+
privileged=()
36+
if which sudo >/dev/null 2>&1; then
37+
privileged+=("sudo")
38+
fi
39+
40+
41+
if which apt-get >/dev/null 2>&1; then
42+
pkg_mgr+=("${privileged[@]}" "apt-get")
43+
else
44+
echo "Couldn't determine package manager, sry."
45+
exit 1
46+
fi
47+
48+
function check_if_llvm_apt_is_required() {
49+
# probe if llvm apt repositories are required
50+
mapfile -t llvm_deps < <(printf "%s\n" "${packages[@]}" | grep -E 'clang-|llvm-')
51+
mapfile -t llvm_versions < <(printf "%s\n" "${llvm_deps[@]}" | grep -Eo '[0-9]+' | sort | uniq)
52+
53+
required_versions=()
54+
for llvm_version in "${llvm_versions[@]}"; do
55+
mapfile -t current_llvm_deps < <(printf "%s\n" "${llvm_deps[@]}" | grep -E "$llvm_version")
56+
for dep in "${current_llvm_deps[@]}"; do
57+
if ! apt search "^$dep$" 2>&1 | grep -qe "$dep"; then
58+
echo "warning: couldn't find $dep via apt"
59+
required_versions+=("$llvm_version")
60+
break
61+
fi
62+
done
63+
done
64+
65+
if [ "${#required_versions[@]}" -gt 0 ]; then
66+
if ! "$noninteractive"; then
67+
echo "It seems I need additional apt repositories for:"
68+
printf "missing llvm version %s\n" "${required_versions[@]}"
69+
read -p "Should I add them? (y/n)" choice
70+
fi
71+
if "$noninteractive" || echo "$choice" | grep -Eqie '^y|yes$'; then
72+
"${privileged[@]}" apt-get install -y gnupg ca-certificates
73+
"${privileged[@]}" apt-key adv -v --fetch-keys https://apt.llvm.org/llvm-snapshot.gpg.key
74+
for required_version in "${required_versions[@]}"; do
75+
echo "deb http://apt.llvm.org/${codename}/ llvm-toolchain-${codename}-$required_version main" | "${privileged[@]}" tee "/etc/apt/sources.list.d/llvm-$required_version-$codename.list"
76+
done
77+
"${pkg_mgr[@]}" update
78+
fi
79+
fi
80+
}
81+
82+
"${pkg_mgr[@]}" update
83+
check_if_llvm_apt_is_required
84+
"${pkg_mgr[@]}" install --no-install-recommends -y "${packages[@]}"
85+
)

0 commit comments

Comments
 (0)