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

Add ability to build with clang #499

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b598f0a
Minor changes in build.sh
p-senichenkov Nov 25, 2024
3f00f3d
Add goggletest as SYSTEM subdirectory
p-senichenkov Nov 26, 2024
24780b7
Replace INSTANTIATE_TEST_CASE_P with INSTANTIATE_TEST_SUITE_P
p-senichenkov Nov 25, 2024
096bfb1
Mark unused variables as [[maybe_unused]]
p-senichenkov Nov 27, 2024
cdd1263
Convert values explicitly in tests/test_types.cpp
p-senichenkov Nov 27, 2024
7894ecf
Biuld and test with Clang in CI
p-senichenkov Nov 27, 2024
862481a
Fix UB found by clang UB sanitizer
p-senichenkov Nov 28, 2024
f43886f
Update README
p-senichenkov Dec 1, 2024
fd385d4
Use &Insert instead of this->Insert in KDTree constructor
p-senichenkov Dec 7, 2024
fafff20
Use proxy class when jthread isn't availible
p-senichenkov Nov 30, 2024
8c2d63c
Use custom implementations of some std::bitset functions
p-senichenkov Dec 1, 2024
e33a6d1
Use std::chrono::high_resolution_clock in Fastod's timer
p-senichenkov Dec 1, 2024
34080fd
Fix formatting
p-senichenkov Dec 4, 2024
9f5e277
Make GetByte in bitset_extensions conditionally constexpr
p-senichenkov Dec 4, 2024
35e0df3
Fix formatting
p-senichenkov Dec 4, 2024
fdc6aad
Fix: shift bitset in CreateDynamicBtiset
p-senichenkov Dec 8, 2024
752abba
Use system_clock in fd/sfd/cords
p-senichenkov Dec 2, 2024
9b5a39a
Update README
p-senichenkov Dec 16, 2024
f19759b
Use libc++ and build boost with clang in CI
p-senichenkov Dec 16, 2024
bdb1d4e
Catch exceptions in AutoJoinThread's destructor
p-senichenkov Dec 16, 2024
4c95222
Update googletest version from 1.13.0 to 1.14.0
p-senichenkov Nov 26, 2024
dd75964
Install all LLVM packages in CI
p-senichenkov Dec 16, 2024
c51921b
Use concepts instead of SFINAE in bitset_extensions
p-senichenkov Dec 18, 2024
90efdf0
Use stable_sort in PDFTane::CalculatePFDError
p-senichenkov Dec 9, 2024
7adcb42
Sort pairs by value if frequencies are equal in Cords
p-senichenkov Dec 8, 2024
7940b8a
Use revese iterators in egfd_validation.cpp: ReverseConstruction
p-senichenkov Dec 12, 2024
8d17f04
Add explicit 'install-gcc' flag in download-libraries
p-senichenkov Dec 19, 2024
eb39b0c
Disable false positive ASAN check
p-senichenkov Dec 21, 2024
f8571d4
Fix: don't build boost in wheel.yml
p-senichenkov Dec 21, 2024
53c8e42
Fix: build boost in /usr/local instead of /usr/lib
p-senichenkov Dec 21, 2024
06220e4
Update README
p-senichenkov Dec 21, 2024
a97055e
Fix some uncertainties in README
p-senichenkov Jan 3, 2025
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
47 changes: 42 additions & 5 deletions .github/composite-actions/download-libraries/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,26 @@ inputs:
description: 'Download googletest'
default: true

install-boost:
install-boost-gcc:
type: boolean
description: 'Install boost'
description: 'Install boost built with GCC'
default: true

install-boost-clang:
type: boolean
description: 'Install boost built with clang'
default: false

install-gcc:
type: boolean
description: 'Install GCC toolset (compiler and build tools)'
default: true

install-clang:
type: boolean
description: 'Install clang toolset (compiler and build tools)'
default: false

runs:
using: 'composite'
steps:
Expand All @@ -25,6 +40,19 @@ runs:
sudo apt-get update -y
sudo apt-get install gcc-10 g++-10 cmake build-essential -y
shell: bash
if: inputs.install-gcc != 'false'

- name: Install clang
# llvm.sh installs all needed libraries, no need in build-essential
# "all" option is needed to install libc++ and libc++abi
run: |
sudo apt-get update -y
sudo apt-get install cmake make -y
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 17 all
shell: bash
if: inputs.install-clang != 'false'

- name: Make lib directory
run: |
Expand All @@ -35,7 +63,7 @@ runs:
uses: ./.github/composite-actions/download-library
with:
directory: googletest
download-command: git clone https://github.com/google/googletest/ --branch release-1.12.1 --depth 1
download-command: git clone https://github.com/google/googletest/ --branch release-1.14.0 --depth 1
if: inputs.download-googletest != 'false'

- name: Download easyloggingpp
Expand Down Expand Up @@ -72,13 +100,22 @@ runs:
directory: boost
download-command: wget -O boost_1_81_0.tar.gz https://sourceforge.net/projects/boost/files/boost/1.81.0/boost_1_81_0.tar.gz/download && tar xzvf boost_1_81_0.tar.gz && mv boost_1_81_0 boost

- name: Install Boost
- name: Install Boost built with GCC
run: |
cd lib/boost
./bootstrap.sh --prefix=/usr
sudo ./b2 install --prefix=/usr
shell: bash
if: inputs.install-boost != 'false'
if: inputs.install-boost-gcc != 'false'
- name: Install Boost built with clang
run: |
cd lib/boost
./bootstrap.sh --prefix=/usr --with-toolset=clang
./b2 clean
./b2 toolset=clang cxxflags="-stdlib=libc++" linkflags="-stdlib=libc++"
sudo ./b2 install --prefix=/usr
shell: bash
if: inputs.install-boost-clang != 'false'
- name: Download frozen
uses: ./.github/composite-actions/download-library
with:
Expand Down
39 changes: 38 additions & 1 deletion .github/workflows/core-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ on:
#- examples/**
workflow_dispatch:
jobs:
run_tests:
run_tests_gcc:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -44,6 +44,43 @@ jobs:
uses: ./.github/composite-actions/download-datasets
- name: Build
run: |
export CC=gcc-10
export CXX=g++-10
if [[ "${{matrix.cfg.BUILD_TYPE}}" == "Debug" ]]; then
./build.sh --debug --sanitizer=${{ matrix.cfg.SANITIZER }}
else
./build.sh
fi
- name: Test
working-directory: ${{github.workspace}}/build/target
shell: bash
run: ./Desbordante_test --gtest_filter='*:-*HeavyDatasets*'
run_tests_clang:
runs-on: ubuntu-latest
strategy:
matrix:
cfg:
- { BUILD_TYPE: Release }
- { BUILD_TYPE: Debug }
- { BUILD_TYPE: Debug, SANITIZER : ADDRESS }
- { BUILD_TYPE: Debug, SANITIZER : UB }
steps:
- uses: actions/checkout@v3
- name: Download libraries
uses: ./.github/composite-actions/download-libraries
with:
install-gcc: false
install-clang: true
install-boost-gcc: false
install-boost-clang: true
- name: Download datasets
uses: ./.github/composite-actions/download-datasets
- name: Build
run: |
export CC=clang-17
export CXX=clang++-17
export CXXFLAGS="-stdlib=libc++"
export LDFLAGS="-lc++abi"
if [[ "${{matrix.cfg.BUILD_TYPE}}" == "Debug" ]]; then
./build.sh --debug --sanitizer=${{ matrix.cfg.SANITIZER }}
else
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
with:
download-pybind: true
download-googletest: false
install-boost: false
install-boost-gcc: false

- name: Build wheels
uses: pypa/[email protected]
Expand Down
28 changes: 27 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,22 @@ else()
if (ASAN)
# Set DEBUG build options specific for build with ASAN
set(ASAN_OPTS "-fsanitize=address")

find_program(APT_FOUND apt-get)
if (APT_FOUND AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# alloc-dealloc-mismatch generates false positives on boost exceptions
# This applies only to Ubuntu package:
# https://github.com/llvm/llvm-project/issues/59432?ysclid=m4y0iqca2c577414782
# Disable this check on files listed in address_sanitizer_ignore_list.txt if compiler
# is Clang and apt-get is installed on system:
# FIXME(senichenkov): apt-get is not an ideal check -- maybe it wouldn't be so hard to
# ask apt-get if repository is ubuntu-...?
message("Running on Ubuntu")
message(WARNING "ASAN is broken in Ubuntu package, therefore alloc-dealloc-mismatch")
message(WARNING "check will be supressed. Consider using another distro for full ASAN coverage.")
string(JOIN ";" ASAN_OPTS "-fsanitize-ignorelist=${CMAKE_SOURCE_DIR}/address_sanitizer_ignore_list.txt")
endif()

string(JOIN ";" DEBUG_BUILD_OPTS "${DEBUG_BUILD_OPTS}"
"-O1"
"-Wno-error" # Use of -Werror is discouraged with sanitizers
Expand Down Expand Up @@ -95,6 +111,16 @@ else()
add_compile_options(-ggdb3)
endif()

# Workaround clang-18 bug:
# https://github.com/llvm/llvm-project/issues/76515?ysclid=m406q4it5k674680045
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
string(FIND "${CMAKE_CXX_COMPILER_VERSION}" "18" IDX)
if (IDX EQUAL 0) # clang major version is 18
message(WARNING "C++ compiler is Clang++-18. Supressing deprecated declaration warnings. Consider using another version of Clang")
string(JOIN ";" DEBUG_BUILD_OPTS "${DEBUG_BUILD_OPTS}" "-Wno-deprecated-declarations")
endif()
endif()

add_compile_options("$<$<CONFIG:Debug>:${DEBUG_BUILD_OPTS}>")
add_link_options("$<$<CONFIG:Debug>:${DEBUG_LINK_OPTS}>")

Expand Down Expand Up @@ -122,7 +148,7 @@ include_directories(SYSTEM "lib/easyloggingpp/src" "lib/better-enums/" "lib/emha

# adding submodules
if (COMPILE_TESTS)
add_subdirectory("lib/googletest")
add_subdirectory("lib/googletest" SYSTEM)
endif()

set( CMAKE_BUILD_TYPE_COPY "${CMAKE_BUILD_TYPE}" )
Expand Down
44 changes: 42 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,16 @@ The following instructions were tested on Ubuntu 20.04+ LTS and macOS Sonoma 14.
### Dependencies
Prior to cloning the repository and attempting to build the project, ensure that you have the following software:

- GNU GCC, version 10+
- GNU GCC, version 10+ or Clang, version 16+
- CMake, version 3.13+
- Boost library built with GCC, version 1.81.0+
- Boost library built with compiler you're going to use (GCC or Clang), version 1.81.0+

To use test datasets you will need:
- Git Large File Storage, version 3.0.2+

#### Ubuntu dependencies installation

##### GCC
Run the following commands:
```sh
sudo apt install gcc g++ cmake libboost-all-dev git-lfs
Expand All @@ -263,6 +264,45 @@ export CXX=g++
The last 2 lines set gcc as CMake compiler in your terminal session.
You can also add them to the end of `~/.profile` to set this by default in all sessions.

##### Clang
Firstly, you'll need to build Boost with Clang, as packaged versions, distributed by package managers, are built with GCC and have different ABI.
Instructions below are given for Boost-1.81.0. If you want to use another version, you'll need to change `tar ...` command on step 3.
For further details on Boost installation, please consult [Boost documentation](https://www.boost.org/doc/libs/1_81_0/more/getting_started/unix-variants.html).
1) It's recommended to install Boost into `/usr/local`. You can use any other location, but you'll need to adapt instructions for it.
```sh
cd /usr/local
```
2) Download an official Boost distribuition from [SourceForge](https://sourceforge.net/projects/boost/files/boost/1.81.0/)
3) Unpack downloaded archive:
```sh
tar --bzip2 -xf boost_1_81_0.tar.bz2
```
4) Compile Boost:
```sh
./bootstrap --with-toolset=clang
./b2 clean
./b2 toolset=clang cxxflags="-stdlib=libc++" linkflags="-stdlib=libc++"
```
5) Install Boost:
```sh
sudo ./b2 install
```

Run the following commands:
```sh
sudo apt install cmake git-lfs
bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
export CC=clang
export CXX=clang++
export CXXFLAGS="-stdlib=libc++"
# libc++ is fully compatible with GCC's ABI, so you can omit the next line if you want to use libstdc++ ABI:
export LDFLAGS="-lc++abi"
export BOOST_ROOT="/usr/local/"
```
Second command installs the latest version of LLVM (which includes Clang). For other installation options, see [LLVM packages page](https://apt.llvm.org/).
The last 5 lines set Clang as CMake compiler in your terminal session and set directory where Boost libraries are located.
You can also add them to the end of `~/.profile` to set this by default in all sessions.

#### MacOS dependencies installation

Install Xcode Command Line Tools if you don't have them. Run:
Expand Down
4 changes: 4 additions & 0 deletions address_sanitizer_ignore_list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Disable alloc_dealloc_mismatch ASAN check
[alloc_dealloc_mismatch]
# in file:
src:typed_column_data.h
7 changes: 5 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash

# Stop on error:
set -e

function print_help() {
cat << EOF
Usage: ./build.sh [options]
Expand Down Expand Up @@ -85,7 +88,7 @@ if [[ $NO_TESTS == true ]]; then
PREFIX="$PREFIX -D COMPILE_TESTS=OFF"
else
if [[ ! -d "googletest" ]] ; then
git clone https://github.com/google/googletest/ --branch v1.13.0 --depth 1
git clone https://github.com/google/googletest/ --branch v1.14.0 --depth 1
fi
fi

Expand Down Expand Up @@ -116,5 +119,5 @@ fi
cd ..
mkdir -p build
cd build
rm CMakeCache.txt
rm -f CMakeCache.txt
cmake $PREFIX .. && make $JOBS_OPTION
21 changes: 10 additions & 11 deletions src/core/algorithms/fd/fdep/fd_tree_element.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "fd_tree_element.h"

#include "boost/dynamic_bitset.hpp"
#include "util/bitset_extensions.h"

FDTreeElement::FDTreeElement(size_t max_attribute_number)
: max_attribute_number_(max_attribute_number) {
Expand Down Expand Up @@ -45,7 +46,7 @@ bool FDTreeElement::ContainsGeneralization(std::bitset<kMaxAttrNum> const& lhs,
return true;
}

size_t next_set_attr = lhs._Find_next(current_attr);
size_t next_set_attr = util::FindNext(lhs, current_attr);
if (next_set_attr == kMaxAttrNum) {
return false;
}
Expand All @@ -71,7 +72,7 @@ bool FDTreeElement::GetGeneralizationAndDelete(std::bitset<kMaxAttrNum> const& l
return true;
}

size_t next_set_attr = lhs._Find_next(current_attr);
size_t next_set_attr = util::FindNext(lhs, current_attr);
if (next_set_attr == kMaxAttrNum) {
return false;
}
Expand Down Expand Up @@ -104,7 +105,7 @@ bool FDTreeElement::GetSpecialization(std::bitset<kMaxAttrNum> const& lhs, size_

bool found = false;
size_t attr = (current_attr > 1 ? current_attr : 1);
size_t next_set_attr = lhs._Find_next(current_attr);
size_t next_set_attr = util::FindNext(lhs, current_attr);

if (next_set_attr == kMaxAttrNum) {
while (!found && attr <= this->max_attribute_number_) {
Expand Down Expand Up @@ -153,7 +154,8 @@ void FDTreeElement::AddFunctionalDependency(std::bitset<kMaxAttrNum> const& lhs,
FDTreeElement* current_node = this;
this->AddRhsAttribute(attr_num);

for (size_t i = lhs._Find_first(); i != kMaxAttrNum; i = lhs._Find_next(i)) {
auto iter = util::MakeBitsetIterator(lhs);
for (size_t i = iter->Pos(); i != kMaxAttrNum; iter->Next(), i = iter->Pos()) {
if (current_node->children_[i - 1] == nullptr) {
current_node->children_[i - 1] =
std::make_unique<FDTreeElement>(this->max_attribute_number_);
Expand Down Expand Up @@ -215,8 +217,8 @@ void FDTreeElement::PrintDependencies(std::bitset<kMaxAttrNum>& active_path, std
if (this->is_fd_[attr - 1]) {
out = "{";

for (size_t i = active_path._Find_first(); i != kMaxAttrNum;
i = active_path._Find_next(i)) {
auto iter = util::MakeBitsetIterator(active_path);
for (size_t i = iter->Pos(); i != kMaxAttrNum; iter->Next(), i = iter->Pos()) {
if (!column_id.empty())
out += column_id + std::to_string(std::stoi(column_names[i - 1]) + 1) + ",";
else
Expand Down Expand Up @@ -257,11 +259,8 @@ void FDTreeElement::TransformTreeFdCollection(std::bitset<kMaxAttrNum>& active_p

for (size_t attr = 1; attr <= this->max_attribute_number_; ++attr) {
if (this->is_fd_[attr - 1]) {
boost::dynamic_bitset<> lhs_bitset(this->max_attribute_number_);
for (size_t i = active_path._Find_first(); i != kMaxAttrNum;
i = active_path._Find_next(i)) {
lhs_bitset.set(i - 1);
}
auto lhs_bitset =
util::CreateShiftedDynamicBitset(active_path, this->max_attribute_number_);
Vertical lhs(scheme.get(), lhs_bitset);
Column rhs(scheme.get(), scheme->GetColumn(attr - 1)->GetName(), attr - 1);
fd_collection.emplace_back(FD{lhs, rhs, scheme});
Expand Down
6 changes: 4 additions & 2 deletions src/core/algorithms/fd/fdep/fdep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "config/equal_nulls/option.h"
#include "config/tabular_data/input_table/option.h"
#include "model/table/column_layout_relation_data.h"
#include "util/bitset_extensions.h"

// #ifndef PRINT_FDS
// #define PRINT_FDS
Expand Down Expand Up @@ -96,8 +97,9 @@ void FDep::AddViolatedFDs(std::vector<size_t> const& t1, std::vector<size_t> con
}

equal_attr &= (~diff_attr);
for (size_t attr = diff_attr._Find_first(); attr != FDTreeElement::kMaxAttrNum;
attr = diff_attr._Find_next(attr)) {
auto iter = util::MakeBitsetIterator(diff_attr);
for (size_t attr = iter->Pos(); attr != FDTreeElement::kMaxAttrNum;
iter->Next(), attr = iter->Pos()) {
this->neg_cover_tree_->AddFunctionalDependency(equal_attr, attr);
}
}
Expand Down
Loading
Loading