Skip to content

Commit

Permalink
[ci] Add a debug build of Clang (vgvassilev#662)
Browse files Browse the repository at this point in the history
This patch builds clang and llvm from source in debug mode and run clad. We have several test failures which are marked with XFAIL now.
  • Loading branch information
alexander-penev authored Nov 30, 2023
1 parent be3dba1 commit 8647f13
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 7 deletions.
80 changes: 74 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ jobs:
os: ubuntu-20.04
compiler: gcc-9
clang-runtime: '12'

- name: ubu20-clang8-runtime12
os: ubuntu-20.04
compiler: clang-8
Expand Down Expand Up @@ -381,6 +382,12 @@ jobs:
compiler: clang-15
clang-runtime: '16'

- name: ubu22-clang15-runtime16-debug
os: ubuntu-22.04
compiler: clang-15
clang-runtime: '16'
debug_build: true

steps:
- uses: actions/checkout@v3
with:
Expand All @@ -401,11 +408,15 @@ jobs:
name: pr
path: pr/
- uses: nelonoel/[email protected]
- name: Setup default Build Type on *nux
if: runner.os != 'windows'
- name: Setup default Build Type on *nux (coverity)
if: ${{ (matrix.debug_build != true) && (runner.os != 'windows') }}
run: |
echo "BUILD_TYPE=Release" >> $GITHUB_ENV
echo "CODE_COVERAGE=0" >> $GITHUB_ENV
- name: Setup default Build Type on *nux (build_debug & asserts)
if: ${{ (matrix.debug_build == true) && (runner.os != 'windows') }}
run: |
echo "BUILD_TYPE=Debug" >> $GITHUB_ENV
- name: Setup default Build Type on Windows
if: runner.os == 'windows'
run: |
Expand Down Expand Up @@ -546,8 +557,65 @@ jobs:
done
# We need PATH_TO_LLVM_BUILD later
echo "PATH_TO_LLVM_BUILD=$PATH_TO_LLVM_BUILD" >> $GITHUB_ENV
- name: Restore Cache LLVM/Clang runtime build directory (debug_build==true)
if: ${{ (matrix.debug_build == true) && (runner.os != 'windows') }}
uses: actions/cache/restore@v3
id: cache
with:
path: |
llvm-project
key: ${{ matrix.os }}-clang-${{ matrix.clang-runtime }}.x-${{ env.BUILD_TYPE }}
- name: Build LLVM/Cling on Unix if the cache is invalid (debug_build==true)
if: ${{ (matrix.debug_build == true) && (runner.os != 'windows') && (steps.cache.outputs.cache-hit != 'true') }}
run: |
os="${{ matrix.os }}"
git clone --depth=1 -b release/${{ matrix.clang-runtime }}.x https://github.com/llvm/llvm-project.git
cd llvm-project
# Build
mkdir build
cd build
export CPU_COUNT="$(nproc --all)"
cmake \
-DLLVM_ENABLE_PROJECTS="clang" \
-DLLVM_TARGETS_TO_BUILD="host;NVPTX" \
-DCMAKE_BUILD_TYPE=`[[ -z "$BUILD_TYPE" ]] && echo RelWithDebInfo || echo $BUILD_TYPE` \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCLANG_ENABLE_STATIC_ANALYZER=OFF \
-DCLANG_ENABLE_ARCMT=OFF \
-DCLANG_ENABLE_FORMAT=OFF \
-DCLANG_ENABLE_BOOTSTRAP=OFF \
-DLLVM_ENABLE_TERMINFO=OFF \
-DCLANG_INCLUDE_TESTS=OFF \
-DCLANG_INCLUDE_DOCS=OFF \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_INCLUDE_DOCS=OFF \
../llvm
cmake --build . --target clang FileCheck llvm-config --parallel ${CPU_COUNT}
cd ../../
- name: Save Cache LLVM/Clang runtime build directory (debug_build==true)
uses: actions/cache/save@v3
if: ${{ (matrix.debug_build == true) && (runner.os != 'windows') && (steps.cache.outputs.cache-hit != 'true') }}
with:
path: |
llvm-project
key: ${{ steps.cache.outputs.cache-primary-key }}
- name: Set LLVM/Cling build path on Unix (debug_build==true)
if: ${{ (matrix.debug_build == true) && (runner.os != 'windows') }}
run: |
export PATH_TO_LLVM_BUILD="$PWD/llvm-project/build"
echo "PATH_TO_LLVM_BUILD=$PATH_TO_LLVM_BUILD"
echo "PATH_TO_LLVM_BUILD=$PATH_TO_LLVM_BUILD" >> $GITHUB_ENV
pip3 install lit # LLVM lit is not part of the llvm releases...
vers="${compiler#*-}"
if [[ ! -f "$PATH_TO_LLVM_BUILD/bin/FileCheck" ]]; then
ln -s /usr/bin/FileCheck-$vers $PATH_TO_LLVM_BUILD/bin/FileCheck
fi
env:
compiler: ${{ matrix.compiler }}

- name: Setup LLVM/Clang on Linux
if: runner.os == 'Linux'
if: ${{ (runner.os == 'Linux') && (matrix.debug_build != true) }}
run: |
UNIX_DISTRO=$(lsb_release -rs)
PATH_TO_LLVM_BUILD=/usr/lib/llvm-${{ matrix.clang-runtime }}/
Expand All @@ -564,7 +632,7 @@ jobs:
# We need PATH_TO_LLVM_BUILD later
echo "PATH_TO_LLVM_BUILD=$PATH_TO_LLVM_BUILD" >> $GITHUB_ENV
- name: Setup LLVM/Clang on Windows
if: runner.os == 'windows'
if: ${{ runner.os == 'windows' }}
run: |
C:\Miniconda\condabin\conda.bat install -y -c conda-forge "clangdev=${{ matrix.clang-runtime }}"
$env:PATH_TO_LLVM_BUILD="$env:CONDA\Library"
Expand Down Expand Up @@ -593,7 +661,7 @@ jobs:
echo "CODE_COVERAGE=1" >> $GITHUB_ENV
echo "BUILD_TYPE=Debug" >> $GITHUB_ENV
- name: Display config *nix
if: runner.os != 'windows'
if: ${{ runner.os != 'windows' }}
run: |
cmake --version
$CC --version
Expand All @@ -604,7 +672,7 @@ jobs:
echo "Building clad in `[[ -z "$BUILD_TYPE" ]] && echo RelWithDebInfo || echo $BUILD_TYPE`"
python3 --version
- name: Display config Windows
if: runner.os == 'windows'
if: ${{ runner.os == 'windows' }}
run: |
cmake --version
echo "CC=$env:CC"
Expand Down
2 changes: 2 additions & 0 deletions test/Arrays/ArrayInputsReverseMode.C
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// RUN: %cladclang %s -I%S/../../include -Wno-unused-value -oArrayInputsReverseMode.out 2>&1 | FileCheck %s
// RUN: ./ArrayInputsReverseMode.out | FileCheck -check-prefix=CHECK-EXEC %s

// XFAIL: asserts

//CHECK-NOT: {{.*error|warning|note:.*}}

#include "clad/Differentiator/Differentiator.h"
Expand Down
2 changes: 2 additions & 0 deletions test/Arrays/ArrayInputsVectorForwardMode.C
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// RUN: %cladclang %s -I%S/../../include -oArrayInputsVectorForwardMode.out 2>&1 | FileCheck %s
// RUN: ./ArrayInputsVectorForwardMode.out | FileCheck -check-prefix=CHECK-EXEC %s

// XFAIL: asserts

// CHECK-NOT: {{.*error|warning|note:.*}}

#include "clad/Differentiator/Differentiator.h"
Expand Down
1 change: 1 addition & 0 deletions test/FirstDerivative/Overloads.C
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// RUN: %cladclang %s -I%S/../../include -oOverloads.out 2>&1 | FileCheck %s
// RUN: ./Overloads.out | FileCheck -check-prefix=CHECK-EXEC %s
// XFAIL: asserts
//CHECK-NOT: {{.*error|warning|note:.*}}

#include "clad/Differentiator/Differentiator.h"
Expand Down
1 change: 1 addition & 0 deletions test/FirstDerivative/VirtualMethodsCall.C
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// RUN: %cladclang %s -I%S/../../include -oVirtualMethodsCall.out 2>&1 | FileCheck %s
// RUN: ./VirtualMethodsCall.out | FileCheck -check-prefix=CHECK-EXEC %s
// XFAIL: asserts
//CHECK-NOT: {{.*error|warning|note:.*}}

#include "clad/Differentiator/Differentiator.h"
Expand Down
2 changes: 2 additions & 0 deletions test/ForwardMode/UserDefinedTypes.C
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// RUN: %cladclang %s -I%S/../../include -oUserDefinedTypes.out | FileCheck %s
// RUN: ./UserDefinedTypes.out | FileCheck -check-prefix=CHECK-EXEC %s

// XFAIL: asserts

// CHECK-NOT: {{.*error|warning|note:.*}}

#include "clad/Differentiator/Differentiator.h"
Expand Down
2 changes: 2 additions & 0 deletions test/ForwardMode/VectorMode.C
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// RUN: %cladclang %s -I%S/../../include -oVectorMode.out 2>&1 | FileCheck %s
// RUN: ./VectorMode.out | FileCheck -check-prefix=CHECK-EXEC %s

// XFAIL: asserts

//CHECK-NOT: {{.*error|warning|note:.*}}

#include "clad/Differentiator/Differentiator.h"
Expand Down
2 changes: 2 additions & 0 deletions test/ForwardMode/VectorModeInterface.C
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// RUN: %cladclang %s -I%S/../../include -fsyntax-only -Xclang -verify 2>&1 | FileCheck %s

// XFAIL: asserts

//CHECK-NOT: {{.*error|warning|note:.*}}

#include "clad/Differentiator/Differentiator.h"
Expand Down
2 changes: 2 additions & 0 deletions test/Gradient/MemberFunctions.C
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// RUN: %cladclang -std=c++17 %s -fno-exceptions -I%S/../../include -oMemberFunctions-cpp17.out 2>&1 | FileCheck %s
// RUN: ./MemberFunctions-cpp17.out | FileCheck -check-prefix=CHECK-EXEC %s

// XFAIL: asserts

//CHECK-NOT: {{.*error|warning|note:.*}}
#include "clad/Differentiator/Differentiator.h"

Expand Down
1 change: 1 addition & 0 deletions test/Gradient/UserDefinedTypes.C
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// RUN: %cladclang %s -I%S/../../include -oUserDefinedTypes.out 2>&1 | FileCheck %s
// RUN: ./UserDefinedTypes.out | FileCheck -check-prefix=CHECK-EXEC %s
// XFAIL: asserts
// CHECK-NOT: {{.*error|warning|note:.*}}

#include "clad/Differentiator/Differentiator.h"
Expand Down
1 change: 1 addition & 0 deletions test/Misc/RunDemos.C
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// RUN: %cladclang %S/../../demos/RosenbrockFunction.cpp -I%S/../../include 2>&1
// RUN: %cladclang %S/../../demos/ComputerGraphics/smallpt/SmallPT.cpp -I%S/../../include 2>&1

// XFAIL: asserts

//-----------------------------------------------------------------------------/
// Demo: Gradient.cpp
Expand Down
12 changes: 11 additions & 1 deletion test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import os
import platform
import re

import lit.util
import lit.formats
import lit.util

from lit.llvm import llvm_config

# name: The name of this test suite.
config.name = 'clad'
Expand Down Expand Up @@ -322,3 +324,11 @@ if libcudart_path is not None:

if(config.have_enzyme):
config.available_features.add('Enzyme')

# Ask llvm-config about asserts and build mode
llvm_config.feature_config(
[
("--assertion-mode", {"ON": "asserts"}),
("--build-mode", {"[Dd][Ee][Bb][Uu][Gg]": "debug"}),
]
)
3 changes: 3 additions & 0 deletions test/lit.site.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ except KeyError:
key, = e.args
lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))

import lit.llvm
lit.llvm.initialize(lit_config, config)

# Let the main config do the real work.
lit_config.load_config(config, "@CLAD_SOURCE_DIR@/test/lit.cfg")

0 comments on commit 8647f13

Please sign in to comment.