Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
74 changes: 72 additions & 2 deletions .github/workflows/github-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on: [push, pull_request]
env:
SVF_CTIR: 1
SVF_Z3: 1
SVF_DIR: $GITHUB_WORKSPACE
SVF_DIR: ${{ github.workspace }}

jobs:
build:
Expand Down Expand Up @@ -40,7 +40,10 @@ jobs:
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install cmake gcc g++ nodejs doxygen graphviz lcov libncurses5-dev libtinfo6 libzstd-dev astyle
sudo apt-get install -y cmake gcc g++ nodejs doxygen graphviz lcov libncurses5-dev libtinfo6 libzstd-dev astyle wget
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 22

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good not to specify a particular version here. Using a macro would be better, as SVF will keep evolving and specifying the version would make maintenance more difficult.

I would also suggest moving the Windows build to a separate GitHub Action.


# build-svf
- name: build-svf
Expand All @@ -49,6 +52,7 @@ jobs:
echo $(pwd)
if [ "${{matrix.sanitizer}}" != "" ]; then export SVF_SANITIZER="${{matrix.sanitizer}}"; fi
if [ "$RUNNER_OS" == "Linux" ] && [ "${{matrix.sanitizer}}" == "" ]; then export SVF_COVERAGE=1; fi
export LLVM_DIR=/usr/lib/llvm-22
git clone "https://github.com/SVF-tools/Test-Suite.git";
source ${{github.workspace}}/build.sh

Expand Down Expand Up @@ -173,3 +177,69 @@ jobs:
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

windows-build:
name: windows-build (${{ matrix.compiler }})
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
compiler: [mingw, msvc]
steps:
- uses: actions/checkout@v4

- name: Install dependencies (MSVC only)
if: matrix.compiler == 'msvc'
shell: powershell
run: |
# 1. Install LLVM toolchain via Chocolatey (provides clang.exe)
choco install llvm -y

# 2. Download and extract LLVM SDK from c3lang/llvm-for-c3 (provides LLVMConfig.cmake and static libraries) using curl.exe
curl.exe -L "https://github.com/c3lang/llvm-for-c3/releases/download/llvm_22.1.4/llvm-windows-amd64.tar.gz" -o llvm-sdk.tar.gz
New-Item -ItemType Directory -Force -Path C:\llvm-sdk | Out-Null
tar -xf llvm-sdk.tar.gz -C C:\llvm-sdk

# 3. Copy Clang compiler binaries from Chocolatey LLVM to the SDK bin folder
Copy-Item -Path "C:\Program Files\LLVM\bin\clang.exe" -Destination "C:\llvm-sdk\bin\" -Force
Copy-Item -Path "C:\Program Files\LLVM\bin\clang++.exe" -Destination "C:\llvm-sdk\bin\" -Force
Copy-Item -Path "C:\Program Files\LLVM\bin\clang-cl.exe" -Destination "C:\llvm-sdk\bin\" -Force

# 3.5. Strip the hardcoded MSVC diaguids.lib dependency from LLVMExports.cmake
$exportsFile = "C:\llvm-sdk\lib\cmake\llvm\LLVMExports.cmake"
if (Test-Path $exportsFile) {
$content = Get-Content $exportsFile -Raw
# Remove any absolute path ending in /DIA SDK/lib/amd64/diaguids.lib;
$newContent = $content -replace '[a-zA-Z]:/[^";]+?/DIA SDK/lib/amd64/diaguids\.lib;', ""
Set-Content $exportsFile $newContent -NoNewline
}

# 4. Export environment variables using UTF-8 encoding
Add-Content -Path $env:GITHUB_PATH -Value "C:\llvm-sdk\bin" -Encoding UTF8
Add-Content -Path $env:GITHUB_ENV -Value "LLVM_DIR=C:\llvm-sdk" -Encoding UTF8

- name: Add MSVC to PATH
if: matrix.compiler == 'msvc'
uses: ilammy/msvc-dev-cmd@v1

- name: Clone Test-Suite
shell: powershell
run: |
git clone "https://github.com/SVF-tools/Test-Suite.git" Test-Suite


- name: Build SVF
shell: powershell
run: |
if ("${{ matrix.compiler }}" -eq "msvc") {
powershell -ExecutionPolicy Bypass -File build.ps1 -BuildType Release -Compiler msvc -LLVMDir "$env:LLVM_DIR"
} else {
powershell -ExecutionPolicy Bypass -File build.ps1 -BuildType Release -Compiler mingw
}

- name: Run CTests
shell: powershell
working-directory: ${{ github.workspace }}/Release-build
run: |
. ..\setup.ps1 Release
ctest --output-on-failure
2 changes: 1 addition & 1 deletion .github/workflows/svf-lib_binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
if [ "$(uname -m)" == "x86_64" ]; then
ctest -R diff-perf-cruxbc -VV
git pull
cp -r ${{github.workspace}}/Release-build/Testing/Temporary/LastTest.log $GITHUB_WORKSPACE/Test-Suite/diff_tests/perf_history/perf-$(date +'%Y-%m-%dT%H:%M:%S').txt
cp -r ${{github.workspace}}/Release-build/Testing/Temporary/LastTest.log $GITHUB_WORKSPACE/Test-Suite/diff_tests/perf_history/perf-$(date +'%Y-%m-%dT%H-%M-%S').txt
cp -r ${{github.workspace}}/Release-build/Testing/Temporary/LastTest.log $GITHUB_WORKSPACE/Test-Suite/diff_tests/perf-latest.txt
cd $GITHUB_WORKSPACE/Test-Suite/diff_tests
git add .
Expand Down
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,12 @@ doxygen/
*.svf
cmake-build-debug/
compile_commands.json

# Local agent files and logs
AGENTS.md
err.txt
wiki/
docs/extending-handoffs/
docs/images/
svf-llvm/tools/GraphDB/
docs/windows-port/IMPLEMENTATION-LOG.md
60 changes: 43 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
cmake_minimum_required(VERSION 3.23)

# Reset invalid cached compiler paths so project() can probe available compilers.
if(DEFINED CMAKE_C_COMPILER)
if(IS_ABSOLUTE "${CMAKE_C_COMPILER}" AND NOT EXISTS "${CMAKE_C_COMPILER}")
unset(CMAKE_C_COMPILER CACHE)
endif()
endif()
if(DEFINED CMAKE_CXX_COMPILER)
if(IS_ABSOLUTE "${CMAKE_CXX_COMPILER}" AND NOT EXISTS "${CMAKE_CXX_COMPILER}")
unset(CMAKE_CXX_COMPILER CACHE)
endif()
endif()

# =================================================================================
# SVF project definition
# =================================================================================
Expand All @@ -14,6 +26,14 @@ project(

# Export compile commands for clangd & IDE support
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

# Configure MSVC runtime library (default to static to match LLVM SDK, but allow override)
if(MSVC OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
if(NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
endif()

# Set SVF's default C/C++ standards (C11/C++17)
set(CMAKE_C_STANDARD 11)
Expand Down Expand Up @@ -51,11 +71,12 @@ if(WIN32
OR MSYS
OR CYGWIN
)
file(
COPY ${SVF_BINARY_DIR}/compile_commands.json
DESTINATION ${CMAKE_CURRENT_LIST_DIR}
RENAME compile_commands.json
)
if(EXISTS ${SVF_BINARY_DIR}/compile_commands.json)
file(
COPY ${SVF_BINARY_DIR}/compile_commands.json
DESTINATION ${CMAKE_CURRENT_LIST_DIR}
)
endif()
else()
file(CREATE_LINK ${SVF_BINARY_DIR}/compile_commands.json compile_commands.json COPY_ON_ERROR SYMBOLIC)
endif()
Expand Down Expand Up @@ -267,6 +288,13 @@ target_link_libraries(SvfFlags INTERFACE ${Z3_LIBRARIES})
# Ensure the interface library is exposed during installation
install(TARGETS SvfFlags EXPORT SVFTargets)

# =================================================================================
# SVF core definitions
# =================================================================================

add_subdirectory(svf)
add_subdirectory(svf-llvm)

# =================================================================================
# SVF test suite
# =================================================================================
Expand All @@ -278,20 +306,17 @@ if(EXISTS "${SVF_SOURCE_DIR}/Test-Suite")
add_subdirectory(Test-Suite)
endif()

# =================================================================================
# SVF core definitions
# =================================================================================

add_subdirectory(svf)
add_subdirectory(svf-llvm)

# =================================================================================
# SVF build configuration handling (post linking LLVM)
# =================================================================================

# Expose the required ABI flags (e.g., whether RTTI was disabled) in the build & install trees
target_compile_options(SvfFlags INTERFACE $<$<NOT:$<BOOL:${SVF_ENABLE_RTTI}>>:-fno-rtti>)
target_link_options(SvfFlags INTERFACE $<$<NOT:$<BOOL:${SVF_ENABLE_RTTI}>>:-fno-rtti>)
if(MSVC)
target_compile_options(SvfFlags INTERFACE $<$<NOT:$<BOOL:${SVF_ENABLE_RTTI}>>:/GR->)
else()
target_compile_options(SvfFlags INTERFACE $<$<NOT:$<BOOL:${SVF_ENABLE_RTTI}>>:-fno-rtti>)
target_link_options(SvfFlags INTERFACE $<$<NOT:$<BOOL:${SVF_ENABLE_RTTI}>>:-fno-rtti>)
endif()

# Expose build/link flags not required for users of SVF only in the build tree
target_compile_options(
Expand All @@ -314,9 +339,9 @@ target_link_options(
INTERFACE $<BUILD_INTERFACE:$<$<BOOL:${SVF_WARN_AS_ERROR}>:-Wall>>
INTERFACE $<BUILD_INTERFACE:$<$<BOOL:${SVF_WARN_AS_ERROR}>:-Werror>>
INTERFACE $<BUILD_INTERFACE:$<$<BOOL:${SVF_WARN_AS_ERROR}>:-Wno-deprecated-declarations>>
INTERFACE $<BUILD_INTERFACE:$<$<BOOL:${SVF_USE_LLD}>:-fuse-ld=lld>>
INTERFACE $<BUILD_INTERFACE:$<$<BOOL:${SVF_EXPORT_DYNAMIC}>:-rdynamic>>
INTERFACE $<BUILD_INTERFACE:$<$<BOOL:${SVF_EXPORT_DYNAMIC}>:-Wl,--export-dynamic>>
INTERFACE $<BUILD_INTERFACE:$<$<AND:$<BOOL:${SVF_USE_LLD}>,$<NOT:$<PLATFORM_ID:Windows>>>:-fuse-ld=lld>>
INTERFACE $<BUILD_INTERFACE:$<$<AND:$<BOOL:${SVF_EXPORT_DYNAMIC}>,$<NOT:$<PLATFORM_ID:Windows>>>:-rdynamic>>
INTERFACE $<BUILD_INTERFACE:$<$<AND:$<BOOL:${SVF_EXPORT_DYNAMIC}>,$<NOT:$<PLATFORM_ID:Windows>>>:-Wl,--export-dynamic>>
INTERFACE $<BUILD_INTERFACE:$<$<BOOL:${SVF_ENABLE_ASSERTIONS}>:-UNDEBUG>>
INTERFACE $<BUILD_INTERFACE:$<$<NOT:$<BOOL:${SVF_ENABLE_EXCEPTIONS}>>:-fno-exceptions>>
INTERFACE $<BUILD_INTERFACE:$<$<OR:$<BOOL:${SVF_COVERAGE}>,$<BOOL:$ENV{SVF_COVERAGE}>>:-fprofile-arcs>>
Expand All @@ -330,6 +355,7 @@ target_link_options(
# =================================================================================

# (1) Generate config.h into <build_tree>/include/SVF/Util; (2) Install it under <install_prefix>/include/SVF/Util
set(SVF_BUILD_DIR "${SVF_BINARY_DIR}")
configure_file(${SVF_SOURCE_DIR}/cmake/SVFConfigHdr.cmake.in ${SVF_BINARY_DIR}/include/Util/config.h @ONLY)
install(FILES ${SVF_BINARY_DIR}/include/Util/config.h DESTINATION ${SVF_INSTALL_INCLUDEDIR}/Util)

Expand Down
Loading
Loading