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
89 changes: 16 additions & 73 deletions .github/workflows/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ pushd "${HOME}/bin"

popd

export DREDD_CLANG_LLVM_DIR=$(pwd)/third_party/clang+llvm

case "$(uname)" in
"Linux")

Expand All @@ -120,17 +122,17 @@ esac

mkdir -p build
pushd build
cmake -G Ninja .. -DCMAKE_BUILD_TYPE="${CONFIG}" "${CMAKE_OPTIONS[@]}"
cmake -G Ninja .. -DCMAKE_BUILD_TYPE="${CONFIG}" -DDREDD_CLANG_LLVM_DIR="${DREDD_CLANG_LLVM_DIR}" "${CMAKE_OPTIONS[@]}"
cmake --build . --config "${CONFIG}"
cmake -DCMAKE_INSTALL_PREFIX=./install -DBUILD_TYPE="${CONFIG}" -P cmake_install.cmake
# Run the unit tests
./src/libdreddtest/libdreddtest
popd

cp build/src/dredd/dredd third_party/clang+llvm/bin/
DREDD_REPO_ROOT=$(pwd)
export DREDD_REPO_ROOT
export DREDD_REPO_ROOT=$(pwd)
export DREDD_EXECUTABLE=${DREDD_REPO_ROOT}/third_party/clang+llvm/bin/dredd
export PATH=${PATH}:${DREDD_REPO_ROOT}/scripts
cp build/src/dredd/dredd ${DREDD_EXECUTABLE}

case "$(uname)" in
"Linux")
Expand All @@ -148,6 +150,10 @@ case "$(uname)" in
# The C++ code generated by Dredd may require C++20.
export DREDD_EXTRA_CXX_ARGS="-std=c++20"
export DREDD_EXTRA_C_ARGS="-std=c17"

./scripts/check_single_file_tests.sh
./scripts/check_execute_tests.sh
./scripts/check_bespoke_tests.sh
;;

"Darwin"*)
Expand Down Expand Up @@ -182,82 +188,19 @@ case "$(uname)" in
# The C++ code generated by Dredd may require recent C/C++ support.
export DREDD_EXTRA_CXX_ARGS="-std=c++20"
export DREDD_EXTRA_C_ARGS="-std=c17"

./scripts/check_single_file_tests.sh
./scripts/check_execute_tests.sh
./scripts/check_bespoke_tests.sh
;;

"MINGW"*|"MSYS_NT"*)
# On Windows, run the single-file tests
export CC=cl.exe
export CXX=cl.exe

# The following single-file tests give different expected results on Windows
# due to differences in how certain builtin types, such as size_t and
# uint64_t, expand. For simplicity, remove them before running single-file
# tests.
rm test/single_file/do_not_mutate_under_alignof.cc
rm test/single_file/do_not_mutate_under_alignof.cc.expected
rm test/single_file/do_not_mutate_under_alignof.cc.noopt.expected
rm test/single_file/do_not_mutate_under_sizeof.c
rm test/single_file/do_not_mutate_under_sizeof.c.expected
rm test/single_file/do_not_mutate_under_sizeof.c.noopt.expected
rm test/single_file/initializer_list.cc
rm test/single_file/initializer_list.cc.expected
rm test/single_file/initializer_list.cc.noopt.expected
rm test/single_file/add_type_aliases.c
rm test/single_file/add_type_aliases.c.expected
rm test/single_file/add_type_aliases.c.noopt.expected
rm test/single_file/add_type_aliases.cc
rm test/single_file/add_type_aliases.cc.expected
rm test/single_file/add_type_aliases.cc.noopt.expected
rm test/single_file/positive_int_as_minus_one.c
rm test/single_file/positive_int_as_minus_one.c.expected
rm test/single_file/positive_int_as_minus_one.c.noopt.expected
rm test/single_file/positive_int_as_minus_one.cc
rm test/single_file/positive_int_as_minus_one.cc.expected
rm test/single_file/positive_int_as_minus_one.cc.noopt.expected
rm test/single_file/vector_returns_temporary.cc
rm test/single_file/vector_returns_temporary.cc.expected
rm test/single_file/vector_returns_temporary.cc.noopt.expected

# These tests rely on non-constant sized arrays, which the Microsoft compiler
# does not support.
rm test/single_file/non_const_sized_array.cc
rm test/single_file/non_const_sized_array.cc.expected
rm test/single_file/non_const_sized_array.cc.noopt.expected
rm test/single_file/non_const_sized_array.c
rm test/single_file/non_const_sized_array.c.expected
rm test/single_file/non_const_sized_array.c.noopt.expected

# These tests expose a difference in how value-dependent types are handled in
# Windows vs. Linux builds of Clang. Not sure what's going on, so removing
# the tests under Windows for simplicity.
rm test/single_file/sizeof_template.cc
rm test/single_file/sizeof_template.cc.expected
rm test/single_file/sizeof_template.cc.noopt.expected
rm test/single_file/sizeof_template2.cc
rm test/single_file/sizeof_template2.cc.expected
rm test/single_file/sizeof_template2.cc.noopt.expected

# These test relies on `__builtin_function()` not avilable on Windows.
rm test/single_file/builtin_frame_address_with_argument_rewrite.cc
rm test/single_file/builtin_frame_address_with_argument_rewrite.cc.expected
rm test/single_file/builtin_frame_address_with_argument_rewrite.cc.noopt.expected
rm test/single_file/builtin_frame_address.cc
rm test/single_file/builtin_frame_address.cc.expected
rm test/single_file/builtin_frame_address.cc.noopt.expected
rm -r test/execute/constant_function_argument

# The C code generated by Dredd may require recent C/C++ support.
# Dredd's prelude includes the experimental `stdatomic.h` header.
export DREDD_EXTRA_C_ARGS="/std:c17 /experimental:c11atomics"
export DREDD_EXTRA_CXX_ARGS="/std:c++20"
# Do not run tests on Windows. Dredd doesn't really work on Windows without a proper tool chain;
# performing builds on Windows merely helps by providing one extra compilation target.
;;

*)
echo "Unknown OS"
exit 1
;;
esac

DREDD_SKIP_COPY_EXECUTABLE=1 ./scripts/check_single_file_tests.sh
DREDD_SKIP_COPY_EXECUTABLE=1 ./scripts/check_execute_tests.sh
DREDD_SKIP_COPY_EXECUTABLE=1 ./scripts/check_bespoke_tests.sh
30 changes: 10 additions & 20 deletions .github/workflows/c_apps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ uname
case "$(uname)" in
"Linux")
NINJA_OS="linux"

sudo apt update
sudo apt install -y llvm-17 clang-17 clang-tidy-17 clang-format-17 libclang-17-dev

# Free up some space
df -h
sudo swapoff -a
sudo rm -f /swapfile
sudo apt clean
# shellcheck disable=SC2046
docker rmi $(docker image ls -aq)
df -h
;;

Expand All @@ -50,35 +53,22 @@ pushd "${HOME}/bin"
ls
popd

# Install clang.
DREDD_LLVM_TAG=$(./scripts/llvm_tag.sh)
pushd ./third_party/clang+llvm
curl -fsSL -o clang+llvm.tar.xz "https://github.com/llvm/llvm-project/releases/download/llvmorg-${DREDD_LLVM_TAG}/clang+llvm-${DREDD_LLVM_TAG}-x86_64-linux-gnu-ubuntu-22.04.tar.xz"
tar xf clang+llvm.tar.xz
mv clang+llvm-${DREDD_LLVM_TAG}-x86_64-linux-gnu-ubuntu-22.04/* .
rm clang+llvm.tar.xz
popd

DREDD_ROOT=$(pwd)

export PATH="${DREDD_ROOT}/third_party/clang+llvm/bin:$PATH"
DREDD_CLANG_LLVM_DIR="/usr/lib/llvm-17"
export PATH="${DREDD_CLANG_LLVM_DIR}/bin:$PATH"

export CC=clang
export CXX=clang++

which ${CC}
which ${CXX}

mkdir -p build
pushd build
cmake -G Ninja .. -DCMAKE_BUILD_TYPE=Debug
cmake --build . --config Debug
cmake -DCMAKE_INSTALL_PREFIX=./install -DBUILD_TYPE=Debug -P cmake_install.cmake
popd
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DDREDD_CLANG_LLVM_DIR="${DREDD_CLANG_LLVM_DIR}"
cmake --build build --config Debug

# Check that dredd works on some projects
DREDD_EXECUTABLE="${DREDD_ROOT}/third_party/clang+llvm/bin/dredd"
cp "${DREDD_ROOT}/build/src/dredd/dredd" "${DREDD_EXECUTABLE}"
DREDD_EXECUTABLE="${DREDD_ROOT}/build/src/dredd/dredd"

echo "Curl"
date
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/c_apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
fail-fast: false
matrix:
os:
- ubuntu-22.04
- ubuntu-24.04
config:
- Release

Expand Down
24 changes: 9 additions & 15 deletions .github/workflows/cxx_apps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ uname
case "$(uname)" in
"Linux")
NINJA_OS="linux"

sudo apt update
sudo apt install -y llvm-17 clang-17 clang-tidy-17 clang-format-17 libclang-17-dev

# Free up some space
df -h
sudo swapoff -a
sudo rm -f /swapfile
sudo apt clean
# shellcheck disable=SC2046
docker rmi $(docker image ls -aq)
df -h
;;

Expand All @@ -50,31 +53,22 @@ pushd "${HOME}/bin"
ls
popd

# Install clang.
DREDD_LLVM_TAG=$(./scripts/llvm_tag.sh)
pushd ./third_party/clang+llvm
curl -fsSL -o clang+llvm.tar.xz "https://github.com/llvm/llvm-project/releases/download/llvmorg-${DREDD_LLVM_TAG}/clang+llvm-${DREDD_LLVM_TAG}-x86_64-linux-gnu-ubuntu-22.04.tar.xz"
tar xf clang+llvm.tar.xz
mv clang+llvm-${DREDD_LLVM_TAG}-x86_64-linux-gnu-ubuntu-22.04/* .
rm clang+llvm.tar.xz
popd

DREDD_ROOT=$(pwd)

export PATH="${DREDD_ROOT}/third_party/clang+llvm/bin:$PATH"
DREDD_CLANG_LLVM_DIR="/usr/lib/llvm-17"
export PATH="${DREDD_CLANG_LLVM_DIR}/bin:$PATH"

export CC=clang
export CXX=clang++

which ${CC}
which ${CXX}

cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DDREDD_CLANG_LLVM_DIR="${DREDD_CLANG_LLVM_DIR}"
cmake --build build --config Debug

# Check that dredd works on some projects
DREDD_EXECUTABLE="${DREDD_ROOT}/third_party/clang+llvm/bin/dredd"
cp "${DREDD_ROOT}/build/src/dredd/dredd" "${DREDD_EXECUTABLE}"
DREDD_EXECUTABLE="${DREDD_ROOT}/build/src/dredd/dredd"

echo "examples/simple/pi.cc: check that we can build the simple example"
date
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cxx_apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
fail-fast: false
matrix:
os:
- ubuntu-22.04
- ubuntu-24.04
config:
- Release

Expand Down
16 changes: 6 additions & 10 deletions .github/workflows/dev_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ uname
case "$(uname)" in
"Linux")
NINJA_OS="linux"

sudo apt update
sudo apt install -y llvm-17 clang-17 clang-tidy-17 clang-format-17 libclang-17-dev

# Free up some space
df -h
sudo swapoff -a
sudo rm -f /swapfile
sudo apt clean
# shellcheck disable=SC2046
docker rmi $(docker image ls -aq)
df -h
;;

Expand All @@ -53,14 +56,7 @@ pushd "${HOME}/bin"
ls
popd

# Install clang.
DREDD_LLVM_TAG=$(./scripts/llvm_tag.sh)
pushd ./third_party/clang+llvm
curl -fsSL -o clang+llvm.tar.xz "https://github.com/llvm/llvm-project/releases/download/llvmorg-${DREDD_LLVM_TAG}/clang+llvm-${DREDD_LLVM_TAG}-x86_64-linux-gnu-ubuntu-22.04.tar.xz"
tar xf clang+llvm.tar.xz
mv clang+llvm-${DREDD_LLVM_TAG}-x86_64-linux-gnu-ubuntu-22.04/* .
rm clang+llvm.tar.xz
popd
export DREDD_CLANG_LLVM_DIR="/usr/lib/llvm-17"

# Source the dev shell to download clang-tidy and other tools.
# Developers should *run* the dev shell, but we want to continue executing this script.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dev_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
fail-fast: false
matrix:
os:
- ubuntu-22.04
- ubuntu-24.04
config:
- Release

Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ endif()

# Third party targets.
if(NOT DEFINED DREDD_CLANG_LLVM_DIR)
set(DREDD_CLANG_LLVM_DIR "${CMAKE_SOURCE_DIR}/third_party/clang+llvm")
message(
FATAL_ERROR "DEFINED DREDD_CLANG_LLVM_DIR must refer to an installation of \
Clang/LLVM.")
endif()

set(LLVM_DIR "${DREDD_CLANG_LLVM_DIR}/lib/cmake/llvm")
Expand Down
Loading