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 on macOS #500

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 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
3d3fae4
Add macOS build and tests to CI
p-senichenkov Dec 2, 2024
1f41a2b
Add missing "Download datasets" action in run_tests_macos_clang
p-senichenkov Dec 4, 2024
e670f44
Use GCC implementation of bitset (UNFINISHED)
p-senichenkov Dec 7, 2024
b2908e2
Disable some UB sanitizer checks on some system files
p-senichenkov Dec 7, 2024
3d3a284
Fix: shift bitset in CreateDynamicBtiset
p-senichenkov Dec 8, 2024
ccf9ab8
Revert "Use GCC implementation of bitset (UNFINISHED)"
p-senichenkov Dec 9, 2024
a54bb1b
Fix: use right condition to disable test that produces UB
p-senichenkov Dec 11, 2024
0be78a5
Rename sanitizer_ignore_list to ub_sanitizer_ignore_lsit for clarity
p-senichenkov Dec 21, 2024
2e6a281
Build boost with homebrew clang in CI
p-senichenkov Dec 21, 2024
5feb0d0
Clone googletest "v1.14.0" instead of "release-1.14.0" in CI
p-senichenkov Dec 21, 2024
b4d8aaa
Install boost into /usr/local in CI
p-senichenkov Dec 21, 2024
7d4f6af
Add support for brew clang 16
p-senichenkov Dec 22, 2024
ef2285e
Fix typo in fallback comparison in hymd/utility/md_less
p-senichenkov Dec 22, 2024
63fe715
Update README
p-senichenkov Dec 22, 2024
40bf046
Fix some uncertainties in macOS section of 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
64 changes: 59 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,31 @@ 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-boost-brew-clang:
type: boolean
description: 'Install boost built with Homebrew 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 +45,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 +68,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 v1.14.0 --depth 1
if: inputs.download-googletest != 'false'

- name: Download easyloggingpp
Expand Down Expand Up @@ -72,13 +105,34 @@ 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: Install Boost built with Homebrew Clang
# b2 doesn't recognize custom compilers, so some trick is needed:
# Also, /usr is read-only, so install into /usr/local
run: |
cd lib/boost
export PATH=$(brew --prefix llvm@17)/bin:$PATH
./bootstrap.sh --prefix=/usr/local --with-toolset=clang
./b2 clean
./b2 toolset=clang cxxflags="-std=c++11 -stdlib=libc++" linkflags="-stdlib=libc++"
sudo ./b2 install --prefix=/usr/local
shell: bash
if: inputs.install-boost-brew-clang != 'false'
- name: Download frozen
uses: ./.github/composite-actions/download-library
with:
Expand Down
77 changes: 76 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,81 @@ 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
./build.sh
fi
- name: Test
working-directory: ${{github.workspace}}/build/target
shell: bash
run: ./Desbordante_test --gtest_filter='*:-*HeavyDatasets*'
run_tests_macos_clang:
runs-on: macos-14
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 build system
run: brew install llvm@17 make
shell: bash
- name: Download libraries
uses: ./.github/composite-actions/download-libraries
with:
install-gcc: false
install-clang: false
install-boost-gcc: false
install-boost-clang: false
install-boost-brew-clang: true
- name: Download datasets
uses: ./.github/composite-actions/download-datasets
- name: Build
run: |
export CC=$(brew --prefix llvm@17)/bin/clang
export CXX=$(brew --prefix llvm@17)/bin/clang++
export BOOST_ROOT=/usr/local
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
34 changes: 33 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 All @@ -81,6 +97,12 @@ else()
"-fno-sanitize=signed-integer-overflow" # Remove this when CustomRandom gets fixed
"-fno-sanitize=shift" # Remove this when CustomRandom gets fixed
"-fno-sanitize-recover=all") # For tests to fail if UBSan finds an error
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_HOST_APPLE)
# Limit some UB sanitizer checks to "src" directory on macOS when building with Clang,
# because libraries (STL, googletest, boost, etc.) are somehow broken
string(JOIN ";" UBSAN_OPTS
"-fsanitize-ignorelist=${CMAKE_SOURCE_DIR}/ub_sanitizer_ignore_list.txt")
endif()
string(JOIN ";" DEBUG_BUILD_OPTS "${DEBUG_BUILD_OPTS}"
"-O1"
"${UBSAN_OPTS}")
Expand All @@ -95,6 +117,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 +154,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
Loading
Loading