Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 16 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
./docker
./build
*
!.git
!cmake/
!config/
!include/
!lib/
!test/
!tools/
!unittests/
!utils/*.sh
!utils/*.py

!.gitmodules
!CMakeLists.txt
!Config.cmake.in
!config.h.in
30 changes: 7 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ on:
pull_request:
branches: [ master, development ]

# TODO test in tree build?
# TODO test conan build
jobs:
build:
runs-on: ubuntu-20.04
strategy:
fail-fast: true
matrix:
compiler: [ [clang++-14, clang-14] ]
compiler: [ [clang++-19, clang-19, "clang-19 libclang-rt-19-dev"] ]
build: [ Debug, Release, DebugLibdeps ]
include:
- build: Debug
Expand All @@ -36,24 +38,7 @@ jobs:
- name: Install Phasar Dependencies
shell: bash
run: |
./utils/InstallAptDependencies.sh
sudo apt-get -y install --no-install-recommends libboost-graph-dev

- name: Install Strategy Dependencies
shell: bash
run: |
sudo apt-key adv --fetch-keys https://apt.llvm.org/llvm-snapshot.gpg.key
sudo add-apt-repository -y 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main'
sudo apt-get update
sudo apt-get -y install --no-install-recommends \
${{ matrix.compiler[1] }} \
llvm-14-dev \
libllvm14 \
libclang-common-14-dev \
libclang-14-dev \
libclang-cpp14-dev \
clang-tidy-14 \
libclang-rt-14-dev
./utils/InstallAptDependencies.sh --noninteractive tzdata ${{ matrix.compiler[2] }}

- uses: swift-actions/setup-swift@v2
with:
Expand All @@ -64,15 +49,14 @@ jobs:
CC: ${{ matrix.compiler[1] }}
shell: bash
run: |
mkdir build
cd build
cmake .. \
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
-DBUILD_PHASAR_CLANG=OFF \
-DBUILD_SWIFT_TESTS=ON \
-DPHASAR_USE_Z3=ON \
${{ matrix.flags }} \
-G Ninja
cmake --build .
ninja -C build

- name: Run Unittests
shell: bash
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ on:
jobs:
push_to_registries:
name: Push Docker image to multiple registries
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
permissions:
packages: write
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
# If we want to publish an image of PhASAR to the official docker hub we
# can just use the following code and set the corresponding secrets.
# - name: Log in to Docker Hub
Expand All @@ -27,7 +27,7 @@ jobs:
# password: ${{ secrets.DOCKER_TOKEN }}

- name: Log in to the Container registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand All @@ -41,7 +41,7 @@ jobs:
# here we could add a second image for the official docker registry
# sse/phasar
- name: Build and push Docker images
uses: docker/build-push-action@v3
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
Expand Down
10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.14)
cmake_minimum_required (VERSION 3.16)

# Avoid IPO/LTO Warnings:
cmake_policy(SET CMP0069 NEW)
Expand All @@ -8,9 +8,11 @@ set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
cmake_policy(SET CMP0077 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)

# Allow overwriting cache variables of external projects from this CMakeLists file
cmake_policy(SET CMP0126 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0126 NEW)
if ("${CMAKE_VERSION}" GREATER_EQUAL "3.21")
# Allow overwriting cache variables of external projects from this CMakeLists file
cmake_policy(SET CMP0126 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0126 NEW)
endif()

# Allow portable use of CMAKE_VISIBILITY_INLINES_HIDDEN not only for shared libraries
cmake_policy(SET CMP0063 NEW)
Expand Down
93 changes: 32 additions & 61 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,61 +1,32 @@
FROM ubuntu:22.04
ARG LLVM_INSTALL_DIR="/usr/local/llvm-14"
LABEL Name=phasar Version=2403

RUN apt -y update && apt install bash sudo -y


WORKDIR /usr/src/phasar
RUN mkdir -p /usr/src/phasar/utils

COPY ./utils/InitializeEnvironment.sh /usr/src/phasar/utils/
RUN ./utils/InitializeEnvironment.sh

RUN apt-get -y install --no-install-recommends \
cmake \
ninja-build \
libstdc++6 \
libboost-graph-dev

COPY ./utils/InstallAptDependencies.sh /usr/src/phasar/utils/
RUN ./utils/InstallAptDependencies.sh

RUN apt-get update && \
apt-get install -y software-properties-common

RUN apt-key adv --fetch-keys https://apt.llvm.org/llvm-snapshot.gpg.key && \
add-apt-repository -y 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main' && \
apt-get update && \
apt-get -y install --no-install-recommends \
clang-14 \
llvm-14-dev \
libllvm14 \
libclang-common-14-dev \
libclang-14-dev \
libclang-cpp14-dev \
clang-tidy-14 \
libclang-rt-14-dev

RUN pip3 install Pygments pyyaml



# installing wllvm
RUN pip3 install wllvm

ENV CC=/usr/bin/clang-14
ENV CXX=/usr/bin/clang++-14

COPY . /usr/src/phasar

RUN git submodule init
RUN git submodule update
RUN mkdir -p build && cd build && \
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DPHASAR_TARGET_ARCH="" \
-DCMAKE_CXX_COMPILER=$CXX \
-G Ninja && \
cmake --build .

ENTRYPOINT [ "./build/tools/phasar-cli/phasar-cli" ]
ARG baseimage="ubuntu:24.04"
FROM "$baseimage" as build

RUN --mount=type=bind,source=./utils/InstallAptDependencies.sh,target=/InstallAptDependencies.sh \
set -eux; \
./InstallAptDependencies.sh --noninteractive tzdata clang-19 libclang-rt-19-dev

ENV CC=/usr/bin/clang-19 \
CXX=/usr/bin/clang++-19

FROM build

ARG RUN_TESTS=OFF
RUN --mount=type=bind,source=.,target=/usr/src/phasar,rw \
set -eux; \
cd /usr/src/phasar; \
git submodule update --init; \
cmake -S . -B cmake-build/Release \
-DCMAKE_BUILD_TYPE=Release \
-DPHASAR_TARGET_ARCH="" \
-DPHASAR_ENABLE_SANITIZERS=ON \
-DBUILD_PHASAR_CLANG=ON \
-DPHASAR_USE_Z3=ON \
-DPHASAR_ALLOW_LTO_IN_RELEASE_BUILD=ON \
-DPHASAR_BUILD_UNITTESTS=$RUN_TESTS \
-DPHASAR_BUILD_OPENSSL_TS_UNITTESTS=OFF \
-G Ninja; \
ninja -C cmake-build/Release install; \
[ "${RUN_TESTS}" = "ON" ] && ctest --test-dir cmake-build/Release --output-on-failure || true; \
phasar-cli --version

ENTRYPOINT [ "phasar-cli" ]
6 changes: 5 additions & 1 deletion cmake/phasar_macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ function(generate_ll_file)

if (NOT clang)
# Conan deps are available in in PATH
foreach(hint "${LLVM_TOOLS_BINARY_DIR}" "${Clang_INCLUDE_DIR}/../bin" "${LLVM_INCLUDE_DIR}/../bin" "/usr/local/llvm-${PHASAR_LLVM_VERSION}/bin")
set(default_llvm "${LLVM_TOOLS_BINARY_DIR}" )
set(fallback_llvm "${Clang_INCLUDE_DIR}/../bin" "${LLVM_INCLUDE_DIR}/../bin")
set(user_compiled_llvm "/usr/local/llvm-${PHASAR_LLVM_VERSION}/bin")
set(package_manager_llvm "/usr/lib/llvm-${PHASAR_LLVM_VERSION}/bin/")
foreach(hint ${default_llvm} ${fallback_llvm} ${user_compiled_llvm} ${package_manager_llvm})
if ("${CMAKE_VERSION}" VERSION_GREATER_EQUAL "3.20")
cmake_path(NORMAL_PATH hint OUTPUT_VARIABLE hint)
endif()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ TEST_F(IDEGeneralizedLCATest, StringTestCpp) {
getLastInstructionOf(HA->getProjectIRDB().getFunction("main"));
GroundTruth.push_back({{EdgeValue("Hello, World")},
3,
std::stoi(getMetaDataID(LastMainInstruction))});
static_cast<unsigned int>(
std::stoi(getMetaDataID(LastMainInstruction)))});
compareResults(GroundTruth);
}

Expand Down
7 changes: 0 additions & 7 deletions utils/InitializeEnvironment.sh

This file was deleted.

87 changes: 83 additions & 4 deletions utils/InstallAptDependencies.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,85 @@
#!/bin/bash
set -e
set -euo pipefail

sudo apt-get update
sudo apt-get install git -y
sudo apt-get install zlib1g-dev python3 python3-pip g++ ninja-build cmake -y
if printf "%s\n" "$@" | grep -Eqe '^--noninteractive|-ni$'; then
readonly noninteractive="true"
shift
else
readonly noninteractive="false"
fi
readonly LLVM_IR_VERSION=14
additional_dependencies=("$@")

(
source /etc/os-release
distro="$ID" # ubuntu / debian / alpine / centos / rocky
codename="${VERSION_CODENAME:-}" # focal / stretch / - / - / -
distro_version="$VERSION_ID" # 22.04 / 12 / 3.21.2 / 8 / 9.3
# can be used to adapt to different distros / version

if "$noninteractive"; then
export DEBIAN_FRONTEND=noninteractive
fi

packages=("${additional_dependencies[@]}")
packages+=(
git ca-certificates build-essential cmake ninja-build # build
binutils # LTO
"clang-$LLVM_IR_VERSION" # compiler for IR
"libclang-rt-$LLVM_IR_VERSION-dev" # ASAN
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
)


pkg_mgr=()
privileged=()
if which sudo >/dev/null 2>&1; then
privileged+=("sudo")
fi


if which apt-get >/dev/null 2>&1; then
pkg_mgr+=("${privileged[@]}" "apt-get")
else
echo "Couldn't determine package manager, sry."
exit 1
fi

function check_if_llvm_apt_is_required() {
# probe if llvm apt repositories are required
mapfile -t llvm_deps < <(printf "%s\n" "${packages[@]}" | grep -E 'clang-|llvm-')
mapfile -t llvm_versions < <(printf "%s\n" "${llvm_deps[@]}" | grep -Eo '[0-9]+' | sort | uniq)

required_versions=()
for llvm_version in "${llvm_versions[@]}"; do
mapfile -t current_llvm_deps < <(printf "%s\n" "${llvm_deps[@]}" | grep -E "$llvm_version")
for dep in "${current_llvm_deps[@]}"; do
if ! apt search "^$dep$" 2>&1 | grep -qe "$dep"; then
echo "warning: couldn't find $dep via apt"
required_versions+=("$llvm_version")
break
fi
done
done

if [ "${#required_versions[@]}" -gt 0 ]; then
if ! "$noninteractive"; then
echo "It seems I need additional apt repositories for:"
printf "missing llvm version %s\n" "${required_versions[@]}"
read -p "Should I add them? (y/n)" choice
fi
if "$noninteractive" || echo "$choice" | grep -Eqie '^y|yes$'; then
"${privileged[@]}" apt-get install -y gnupg ca-certificates
"${privileged[@]}" apt-key adv -v --fetch-keys https://apt.llvm.org/llvm-snapshot.gpg.key
for required_version in "${required_versions[@]}"; do
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"
done
"${pkg_mgr[@]}" update
fi
fi
}

"${pkg_mgr[@]}" update
check_if_llvm_apt_is_required
"${pkg_mgr[@]}" install --no-install-recommends -y "${packages[@]}"
)
Loading