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

Export of runtime in a separate repository #162

Merged
merged 13 commits into from
Apr 22, 2024
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
6 changes: 5 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ TAGS
compile_commands.json

# The Dockerfile itself doesn't need to be copied
Dockerfile
Dockerfile

# Do not include build directories
build/
cmake-*
13 changes: 9 additions & 4 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,18 @@ jobs:
sudo apt-get update
sudo apt-get install -y \
llvm-${{ matrix.llvm_version }}-dev \
libz3-dev
libz3-dev \
git

- name: Build SymCC with the QSYM backend
run: |
git submodule update --init --recursive runtime
mkdir build
cd build
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DZ3_TRUST_SYSTEM_VERSION=ON \
-DQSYM_BACKEND=ON \
-DSYMCC_RT_BACKEND=qsym \
-DLLVM_DIR=/usr/lib/llvm-${{ matrix.llvm_version }}/cmake \
..
make
Expand All @@ -67,15 +70,17 @@ jobs:
sudo apt-get update
sudo apt-get install -y \
llvm-${{ matrix.llvm_version }}-dev \
libz3-dev
libz3-dev \
git
- name: Build SymCC with the QSYM backend
run: |
git submodule update --init --recursive runtime
mkdir build
cd build
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DZ3_TRUST_SYSTEM_VERSION=ON \
-DQSYM_BACKEND=ON \
-DSYMCC_RT_BACKEND=qsym \
-DLLVM_DIR=/usr/lib/llvm-${{ matrix.llvm_version }}/cmake \
..
make
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ compile_commands.json
.cache

# Build directories
build*
*build*
8 changes: 4 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "qsym_backend/qsym"]
path = runtime/qsym_backend/qsym
url = https://github.com/eurecom-s3/qsym.git
branch = symcc
[submodule "runtime"]
path = runtime
url = https://github.com/eurecom-s3/symcc-rt.git
branch = main
44 changes: 29 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,29 @@
# You should have received a copy of the GNU General Public License along with
# SymCC. If not, see <https://www.gnu.org/licenses/>.

cmake_minimum_required(VERSION 3.5)
project(SymbolicCompiler)
cmake_minimum_required(VERSION 3.16)
project(SymCC)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

option(QSYM_BACKEND "Use the Qsym backend instead of our own" OFF)
set(LLVM_VERSION "" CACHE STRING "LLVM version to use. The corresponding LLVM dev package must be installed.")
set(SYMCC_RT_BACKEND "qsym" CACHE STRING "The symbolic backend to use. Please check symcc-rt to get a list of the available backends.")
option(TARGET_32BIT "Make the compiler work correctly with -m32" OFF)

# We need to build the runtime as an external project because CMake otherwise
# doesn't allow us to build it twice with different options (one 32-bit version
# and one 64-bit variant).
include(ExternalProject)

# Find LLVM
find_package(LLVM ${LLVM_VERSION} REQUIRED CONFIG)

message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake from ${LLVM_DIR}")

if (${LLVM_VERSION_MAJOR} LESS 8 OR ${LLVM_VERSION_MAJOR} GREATER 17)
message(WARNING "The software has been developed for LLVM 8 through 17; \
it is unlikely to work with other versions!")
endif()

set(SYM_RUNTIME_BUILD_ARGS
-DCMAKE_AR=${CMAKE_AR}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
Expand All @@ -42,11 +52,12 @@ set(SYM_RUNTIME_BUILD_ARGS
-DCMAKE_SHARED_LINKER_FLAGS_INIT=${CMAKE_SHARED_LINKER_FLAGS_INIT}
-DCMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}
-DCMAKE_SYSROOT=${CMAKE_SYSROOT}
-DQSYM_BACKEND=${QSYM_BACKEND}
-DSYMCC_RT_BACKEND=${SYMCC_RT_BACKEND}
-DLLVM_VERSION=${LLVM_PACKAGE_VERSION}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DZ3_TRUST_SYSTEM_VERSION=${Z3_TRUST_SYSTEM_VERSION})

ExternalProject_Add(SymRuntime
ExternalProject_Add(SymCCRuntime
SOURCE_DIR ${CMAKE_SOURCE_DIR}/runtime
CMAKE_ARGS
${SYM_RUNTIME_BUILD_ARGS}
Expand All @@ -56,11 +67,11 @@ ExternalProject_Add(SymRuntime
INSTALL_COMMAND ""
BUILD_ALWAYS TRUE)

ExternalProject_Get_Property(SymRuntime BINARY_DIR)
set(SYM_RUNTIME_DIR ${BINARY_DIR})
ExternalProject_Get_Property(SymCCRuntime BINARY_DIR)
set(SYMCC_RUNTIME_DIR ${BINARY_DIR})

if (${TARGET_32BIT})
ExternalProject_Add(SymRuntime32
ExternalProject_Add(SymCCRuntime32
SOURCE_DIR ${CMAKE_SOURCE_DIR}/runtime
CMAKE_ARGS
${SYM_RUNTIME_BUILD_ARGS}
Expand All @@ -71,8 +82,8 @@ if (${TARGET_32BIT})
INSTALL_COMMAND ""
BUILD_ALWAYS TRUE)

ExternalProject_Get_Property(SymRuntime32 BINARY_DIR)
set(SYM_RUNTIME_32BIT_DIR ${BINARY_DIR})
ExternalProject_Get_Property(SymCCRuntime32 BINARY_DIR)
set(SYMCC_RUNTIME_32BIT_DIR ${BINARY_DIR})
endif()

find_package(LLVM REQUIRED CONFIG)
Expand All @@ -88,7 +99,8 @@ endif()
add_definitions(${LLVM_DEFINITIONS})
include_directories(SYSTEM ${LLVM_INCLUDE_DIRS})

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 \
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-Wredundant-decls -Wcast-align -Wmissing-include-dirs -Wswitch-default \
-Wextra -Wall -Winvalid-pch -Wredundant-decls -Wformat=2 \
-Wmissing-format-attribute -Wformat-nonliteral -Werror -Wno-error=deprecated-declarations")
Expand All @@ -99,13 +111,15 @@ set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-z,nodelete")
# This is the compiler pass that we later load into clang or opt. If LLVM is
# built without RTTI we have to disable it for our library too, otherwise we'll
# get linker errors.
add_library(Symbolize MODULE
add_library(SymCC MODULE
compiler/Symbolizer.cpp
compiler/Pass.cpp
compiler/Runtime.cpp
compiler/Main.cpp)

set_target_properties(SymCC PROPERTIES OUTPUT_NAME "symcc")
if (NOT LLVM_ENABLE_RTTI)
set_target_properties(Symbolize PROPERTIES COMPILE_FLAGS "-fno-rtti")
set_target_properties(SymCC PROPERTIES COMPILE_FLAGS "-fno-rtti")
endif()

find_program(CLANG_BINARY "clang"
Expand Down
19 changes: 7 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,20 @@ FROM ubuntu:22.04 AS builder
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
cargo \
clang-15 \
cmake \
g++ \
git \
libz3-dev \
llvm-15-dev \
llvm-15-tools \
ninja-build \
python3-pip \
zlib1g-dev \
llvm-15 \
clang-15 \
&& rm -rf /var/lib/apt/lists/*
RUN pip3 install lit

WORKDIR /

# Build AFL.
RUN git clone -b v2.56b https://github.com/google/AFL.git afl \
&& cd afl \
Expand All @@ -48,11 +49,7 @@ COPY . /symcc_source

# Init submodules if they are not initialiazed yet
WORKDIR /symcc_source
RUN if git submodule status | grep "^-">/dev/null ; then \
echo "Initializing submodules"; \
git submodule init; \
git submodule update; \
fi
RUN git submodule update --init --recursive


#
Expand All @@ -61,7 +58,7 @@ RUN if git submodule status | grep "^-">/dev/null ; then \
FROM builder AS builder_simple
WORKDIR /symcc_build_simple
RUN cmake -G Ninja \
-DQSYM_BACKEND=OFF \
-DSYMCC_RT_BACKEND=simple \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DZ3_TRUST_SYSTEM_VERSION=on \
/symcc_source \
Expand Down Expand Up @@ -93,7 +90,7 @@ RUN export SYMCC_REGULAR_LIBCXX=yes SYMCC_NO_SYMBOLIC_INPUT=yes \
FROM builder_libcxx AS builder_qsym
WORKDIR /symcc_build
RUN cmake -G Ninja \
-DQSYM_BACKEND=ON \
-DSYMCC_RT_BACKEND=qsym \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DZ3_TRUST_SYSTEM_VERSION=on \
/symcc_source \
Expand All @@ -109,9 +106,7 @@ FROM ubuntu:22.04
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
build-essential \
clang-15 \
g++ \
libllvm15 \
zlib1g \
sudo \
&& rm -rf /var/lib/apt/lists/* \
Expand Down
Loading
Loading