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
43 changes: 21 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,29 +90,28 @@ enable_testing()

set(TESTDIR ${CMAKE_CURRENT_SOURCE_DIR}/src/test)
subdirlist(TEST_CATEGORIES ${TESTDIR})
foreach(TEST_CACHE_FRIENDLY_OFFSET OFF;ON)
foreach(SUPER_SLAB_SIZE 1;16)
foreach(TEST_CATEGORY ${TEST_CATEGORIES})
subdirlist(TESTS ${TESTDIR}/${TEST_CATEGORY})
foreach(TEST ${TESTS})
unset(SRC)
aux_source_directory(${TESTDIR}/${TEST_CATEGORY}/${TEST} SRC)
set(TESTNAME "${TEST_CATEGORY}-${TEST}-${SUPER_SLAB_SIZE}")
if (TEST_CACHE_FRIENDLY_OFFSET)
set(TESTNAME "${TESTNAME}-cache-friendly")
endif()

add_executable(${TESTNAME} ${SRC} src/override/new.cc)
if (${SUPER_SLAB_SIZE} EQUAL 1)
target_compile_definitions(${TESTNAME} PRIVATE IS_ADDRESS_SPACE_CONSTRAINED)
endif()
if(TEST_CACHE_FRIENDLY_OFFSET)
target_compile_definitions(${TESTNAME} PRIVATE CACHE_FRIENDLY_OFFSET=64)
endif()
target_include_directories(${TESTNAME} PRIVATE src)
linklibs(${TESTNAME})
list(REVERSE TEST_CATEGORIES)
foreach(TEST_CATEGORY ${TEST_CATEGORIES})
subdirlist(TESTS ${TESTDIR}/${TEST_CATEGORY})
foreach(TEST ${TESTS})
foreach(SUPER_SLAB_SIZE 1;16)
unset(SRC)
aux_source_directory(${TESTDIR}/${TEST_CATEGORY}/${TEST} SRC)
set(TESTNAME "${TEST_CATEGORY}-${TEST}-${SUPER_SLAB_SIZE}")

add_executable(${TESTNAME} ${SRC} src/override/new.cc)
if (${SUPER_SLAB_SIZE} EQUAL 1)
target_compile_definitions(${TESTNAME} PRIVATE IS_ADDRESS_SPACE_CONSTRAINED)
endif()
target_include_directories(${TESTNAME} PRIVATE src)
linklibs(${TESTNAME})
if (${TEST} MATCHES "release-.*")
message(STATUS "Adding test: ${TESTNAME} only for release configs")
add_test(NAME ${TESTNAME} COMMAND ${TESTNAME} CONFIGURATIONS "Release")
else()
message(STATUS "Adding test: ${TESTNAME}")
add_test(${TESTNAME} ${TESTNAME})
endforeach()
endif()
endforeach()
endforeach()
endforeach()
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ build configuration.
Alternatively, you can follow the steps in the next section to build with Ninja
using the Visual Studio compiler.

# Building on Linux or FreeBSD
# Building on macOS, Linux or FreeBSD
Snmalloc has very few dependencies, CMake, Ninja, Clang 6.0 or later and a C++17
standard library.
Building with GCC is currently not supported because GCC lacks support for the
Expand Down Expand Up @@ -61,7 +61,8 @@ cmake -G Ninja .. -DCMAKE_BUILD_TYPE=RelWithDebInfo
ninja
```

The build produces a binary `libsnmallocshim.so`. This file can be
On ELF platforms, The build produces a binary `libsnmallocshim.so`.
This file can be
`LD_PRELOAD`ed to use the allocator in place of the system allocator, for
Copy link
Member

Choose a reason for hiding this comment

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

Is this true on Mac OS X

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, on macOS it produces libsnmallocshim.dyld, which might be useable with DYLD_INSERT_LIBRARIES, but might not, depending on the binary. That seemed too difficult to usefully explain in a README, so I decided not to.

example, you can run the build script using the snmalloc as the allocator for
your toolchain:
Expand Down
73 changes: 59 additions & 14 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,50 @@ resources:
- repo: self

phases:
- phase: LinuxSelfHost
queue:
name: 'Hosted Ubuntu 1604'

steps:
- script: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install -y ninja-build libc++-dev libc++abi-dev libc++abi1 libstdc++-7-dev
# sudo apt-get install clang-6.0 clang++-6.0

sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-6.0 100
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100
sudo update-alternatives --set cc /usr/bin/clang

sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-6.0 100
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100
sudo update-alternatives --set c++ /usr/bin/clang++

displayName: 'Install Build Dependencies'

- task: CMake@1
displayName: 'CMake .. -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-stdlib=libstdc++ -std=c++17"'
inputs:
cmakeArgs: '.. -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-stdlib=libstdc++ -std=c++17"'

- script: |
ninja

workingDirectory: build
failOnStderr: true
displayName: 'Compile'

- script: |
sudo cp libsnmallocshim.so /usr/local/lib/
sudo cp libsnmallocshim-1mib.so /usr/local/lib/
ninja clean
LD_PRELOAD=/usr/local/lib/libsnmallocshim.so ninja
ninja clean
LD_PRELOAD=/usr/local/lib/libsnmallocshim-1mib.so ninja
workingDirectory: build
failOnStderr: true
displayName: 'LD_PRELOAD Compile'

- phase: Linux
queue:
name: 'Hosted Ubuntu 1604'
Expand Down Expand Up @@ -36,22 +80,17 @@ phases:

- script: |
ninja
ctest -j 4 --output-on-failure

workingDirectory: build
failOnStderr: true
displayName: 'Compile & Test'
displayName: 'Compile'

- script: |
sudo cp libsnmallocshim.so /usr/local/lib/
sudo cp libsnmallocshim-1mib.so /usr/local/lib/
ninja clean
LD_PRELOAD=/usr/local/lib/libsnmallocshim.so ninja
ninja clean
LD_PRELOAD=/usr/local/lib/libsnmallocshim-1mib.so ninja
ctest -j 4 --output-on-failure -C $(BuildType)

workingDirectory: build
failOnStderr: true
displayName: 'LD_PRELOAD Compile'
displayName: 'Test'

- phase: Windows64bit
queue:
Expand All @@ -75,7 +114,7 @@ phases:
solution: build/snmalloc.sln
msbuildArguments: '/m /p:Configuration=$(BuildType)'

- script: 'ctest -j 4 --interactive-debug-mode 0 --output-on-failure'
- script: 'ctest -j 4 --interactive-debug-mode 0 --output-on-failure -C $(BuildType)'
workingDirectory: build
displayName: 'Run Ctest'

Expand All @@ -99,7 +138,7 @@ phases:
solution: build/snmalloc.sln
msbuildArguments: '/m /p:Configuration=$(BuildType)'

- script: 'ctest -j 4 --interactive-debug-mode 0 --output-on-failure'
- script: 'ctest -j 4 --interactive-debug-mode 0 --output-on-failure -C $(BuildType)'
workingDirectory: build
displayName: 'Run Ctest'

Expand All @@ -125,7 +164,7 @@ phases:
solution: build/snmalloc.sln
msbuildArguments: '/m /p:Configuration=$(BuildType)'

- script: 'ctest -j 4 --interactive-debug-mode 0 --output-on-failure'
- script: 'ctest -j 4 --interactive-debug-mode 0 --output-on-failure -C $(BuildType)'
workingDirectory: build
displayName: 'Run Ctest'

Expand All @@ -147,11 +186,17 @@ phases:

- script: |
make -j 4
ctest -j 4 --output-on-failure

workingDirectory: build
failOnStderr: true
displayName: 'Compile & Test'
displayName: 'Compile'

- script: |
ctest -j 4 --output-on-failure -C $(BuildType)

workingDirectory: build
failOnStderr: true
displayName: 'Test'

- phase: Format
queue:
Expand Down