From f5000c087fbc99c2b28580c9d2c83a1981914804 Mon Sep 17 00:00:00 2001 From: Theo Butler Date: Sat, 18 May 2019 10:38:41 +0200 Subject: [PATCH 1/4] merge clang and gcc build into one matrix --- azure-pipelines.yml | 77 +++++++++++++++------------------------------ 1 file changed, 25 insertions(+), 52 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1027cc9..9942ebf 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -21,6 +21,7 @@ phases: 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 @@ -49,57 +50,26 @@ phases: - phase: Linux queue: name: 'Hosted Ubuntu 1604' - parallel: 2 + parallel: 4 matrix: - Debug: + Clang_6 Debug: + CC: clang-6.0 + CXX: clang++-6.0 BuildType: Debug - Release: + + Clang_6 Release: + CC: clang-6.0 + CXX: clang++-6.0 BuildType: Release - 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=$(BuildType) -DCMAKE_CXX_FLAGS="-stdlib=libstdc++ -std=c++17"' - inputs: - cmakeArgs: '.. -GNinja -DCMAKE_BUILD_TYPE=$(BuildType) -DCMAKE_CXX_FLAGS="-stdlib=libstdc++ -std=c++17"' - - - script: | - ninja - - workingDirectory: build - failOnStderr: true - displayName: 'Compile' - - - script: | - ctest -j 4 --output-on-failure -C $(BuildType) - - workingDirectory: build - failOnStderr: true - displayName: 'Test' - -- phase: LinuxGCC - queue: - name: 'Hosted Ubuntu 1604' - parallel: 2 - matrix: - Debug: + GCC_7 Debug: + CC: gcc-7 + CXX: g++-7 BuildType: Debug - Release: + + GCC_7 Release: + CC: gcc-7 + CXX: g++-7 BuildType: Release steps: @@ -109,18 +79,21 @@ phases: sudo apt-get install -y ninja-build libc++-dev libc++abi-dev libc++abi1 libstdc++-7-dev gcc-7 g++-7 # sudo apt-get install clang-6.0 clang++-6.0 - sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-7 100 - sudo update-alternatives --set cc /usr/bin/gcc-7 + sudo update-alternatives --install /usr/bin/cc cc /usr/bin/$(CC) 100 + sudo update-alternatives --set cc /usr/bin/$(CC) - sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-7 100 - sudo update-alternatives --set c++ /usr/bin/g++-7 + sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/$(CXX) 100 + sudo update-alternatives --set c++ /usr/bin/$(CXX) + + CMAKE_CXX_FLAGS="-std=c++17" + if [[ "$CXX" == clang++* ]]; then CMAKE_CXX_FLAGS+=" -stdlib=libstdc++"; fi displayName: 'Install Build Dependencies' - task: CMake@1 - displayName: 'CMake .. -GNinja -DCMAKE_BUILD_TYPE=$(BuildType) -DCMAKE_CXX_FLAGS="-std=c++17"' + displayName: 'CMake .. -GNinja -DCMAKE_BUILD_TYPE=$(BuildType) -DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS"' inputs: - cmakeArgs: '.. -GNinja -DCMAKE_BUILD_TYPE=$(BuildType) -DCMAKE_CXX_FLAGS="-std=c++17"' + cmakeArgs: '.. -GNinja -DCMAKE_BUILD_TYPE=$(BuildType) -DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS"' - script: | ninja From f9b9523d0cfaa00d79e4b2ae9717dfa90bc26e86 Mon Sep 17 00:00:00 2001 From: Theo Butler Date: Sat, 18 May 2019 11:07:50 +0200 Subject: [PATCH 2/4] add ld preload build to linux matrix --- azure-pipelines.yml | 67 ++++++++++++++------------------------------- 1 file changed, 20 insertions(+), 47 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9942ebf..d803ad3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -2,75 +2,40 @@ 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' - parallel: 4 + parallel: 5 matrix: Clang_6 Debug: CC: clang-6.0 CXX: clang++-6.0 BuildType: Debug + SelfHost: false Clang_6 Release: CC: clang-6.0 CXX: clang++-6.0 BuildType: Release + SelfHost: false GCC_7 Debug: CC: gcc-7 CXX: g++-7 BuildType: Debug + SelfHost: false GCC_7 Release: CC: gcc-7 CXX: g++-7 BuildType: Release + SelfHost: false + + Self Host: + CC: clang-6.0 + CXX: clang++-6.0 + BuildType: Debug + SelfHost: true steps: - script: | @@ -103,7 +68,15 @@ phases: displayName: 'Compile' - script: | - ctest -j 4 --output-on-failure -C $(BuildType) + if [ $(SelfHost) = false ]; then + ctest -j 4 --output-on-failure -C $(BuildType) + else + sudo cp libsnmallocshim.so 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 + fi workingDirectory: build failOnStderr: true From 070e0700a802e51495f7c365e3d8e9da5075e137 Mon Sep 17 00:00:00 2001 From: Theo Butler Date: Sat, 18 May 2019 12:54:35 +0200 Subject: [PATCH 3/4] use clangformat cmake target --- CMakeLists.txt | 11 +++--- azure-pipelines.yml | 86 +++++++++++++++------------------------------ check-format.sh | 18 ---------- 3 files changed, 34 insertions(+), 81 deletions(-) delete mode 100644 check-format.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index ecafc9d..3649761 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,10 +170,9 @@ if(NOT DEFINED SNMALLOC_ONLY_HEADER_LIBRARY) message(STATUS "Generating clangformat target using ${CLANG_FORMAT}") file(GLOB_RECURSE ALL_SOURCE_FILES *.cc *.h *.hh) add_custom_target( - clangformat - COMMAND ${CLANG_FORMAT} - -i - ${ALL_SOURCE_FILES} - ) + clangformat + COMMAND ${CLANG_FORMAT} + -i + ${ALL_SOURCE_FILES}) endif() -endif() \ No newline at end of file +endif() diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d803ad3..cd302c8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -7,25 +7,25 @@ phases: name: 'Hosted Ubuntu 1604' parallel: 5 matrix: - Clang_6 Debug: + Clang-6 Debug: CC: clang-6.0 CXX: clang++-6.0 BuildType: Debug SelfHost: false - Clang_6 Release: + Clang-6 Release: CC: clang-6.0 CXX: clang++-6.0 BuildType: Release SelfHost: false - GCC_7 Debug: + GCC-7 Debug: CC: gcc-7 CXX: g++-7 BuildType: Debug SelfHost: false - GCC_7 Release: + GCC-7 Release: CC: gcc-7 CXX: g++-7 BuildType: Release @@ -82,71 +82,36 @@ phases: failOnStderr: true displayName: 'Test' -- phase: Windows64bit +- phase: Windows queue: name: 'Hosted VS2017' - parallel: 2 + parallel: 5 matrix: - Debug: + 64-bit Debug: BuildType: Debug - Release: + CMakeArgs: '-G"Visual Studio 15 2017 Win64"' + + 64-bit Release: BuildType: Release + CMakeArgs: '-G"Visual Studio 15 2017 Win64"' - steps: - - task: CMake@1 - displayName: 'CMake .. -G"Visual Studio 15 2017 Win64"' - inputs: - cmakeArgs: '.. -G"Visual Studio 15 2017 Win64"' - - - task: MSBuild@1 - displayName: 'Build solution build/snmalloc.sln' - inputs: - solution: build/snmalloc.sln - msbuildArguments: '/m /p:Configuration=$(BuildType)' - - - script: 'ctest -j 4 --interactive-debug-mode 0 --output-on-failure -C $(BuildType)' - workingDirectory: build - displayName: 'Run Ctest' - -- phase: Windows8Compat - queue: - name: 'Hosted VS2017' - parallel: 2 - matrix: - Release: + 64-bit Release Windows8Compat: BuildType: Release + CMakeArgs: '-G"Visual Studio 15 2017 Win64" -DWIN8COMPAT=TRUE' - steps: - - task: CMake@1 - displayName: 'CMake .. -G"Visual Studio 15 2017 Win64"' - inputs: - cmakeArgs: '.. -G"Visual Studio 15 2017 Win64" -DWIN8COMPAT=TRUE' - - - task: MSBuild@1 - displayName: 'Build solution build/snmalloc.sln' - inputs: - solution: build/snmalloc.sln - msbuildArguments: '/m /p:Configuration=$(BuildType)' - - - script: 'ctest -j 4 --interactive-debug-mode 0 --output-on-failure -C $(BuildType)' - workingDirectory: build - displayName: 'Run Ctest' - -- phase: Windows32bit - queue: - name: 'Hosted VS2017' - parallel: 2 - matrix: - Debug: + 32-bit Debug: BuildType: Debug - Release: + CMakeArgs: '-G"Visual Studio 15 2017"' + + 32-bit Release: BuildType: Release + CMakeArgs: '-G"Visual Studio 15 2017"' steps: - task: CMake@1 - displayName: 'CMake .. -G"Visual Studio 15 2017"' + displayName: 'CMake .. $(CMakeArgs)' inputs: - cmakeArgs: '.. -G"Visual Studio 15 2017"' + cmakeArgs: '.. $(CMakeArgs)' - task: MSBuild@1 displayName: 'Build solution build/snmalloc.sln' @@ -201,9 +166,16 @@ phases: displayName: 'Install clang' - - script: | - bash check-format.sh + - task: CMake@1 + displayName: 'CMake ..' + inputs: + cmakeArgs: '..' + - script: | + if [ "$(git diff $(Build.SourceVersion))" != "" ]; then exit 1; fi + make clangformat + + workingDirectory: build displayName: 'Clang-Format' - script: | diff --git a/check-format.sh b/check-format.sh deleted file mode 100644 index bcd1deb..0000000 --- a/check-format.sh +++ /dev/null @@ -1,18 +0,0 @@ - -set -u - -unformatted_files="" -for f in `find . -name *.h -o -name *.hh -o -name *.cc`; do - d=`clang-format -style=file $f | diff $f -` - if [ "$d" != "" ]; then - if [ "$unformatted_files" != "" ]; then - unformatted_files+=$'\n' - fi - unformatted_files+="$f" - fi -done - -if [ "$unformatted_files" != "" ]; then - echo "$unformatted_files" - exit 1 -fi From fd4d88ecc1a3887d35e6092f4138509d095811b7 Mon Sep 17 00:00:00 2001 From: Theo Butler Date: Sat, 18 May 2019 13:00:25 +0200 Subject: [PATCH 4/4] fix Windows build type --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index cd302c8..e136fd0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -109,9 +109,9 @@ phases: steps: - task: CMake@1 - displayName: 'CMake .. $(CMakeArgs)' + displayName: 'CMake .. $(CMakeArgs) -DCMAKE_BUILD_TYPE=$(BuildType)' inputs: - cmakeArgs: '.. $(CMakeArgs)' + cmakeArgs: '.. $(CMakeArgs) -DCMAKE_BUILD_TYPE=$(BuildType)' - task: MSBuild@1 displayName: 'Build solution build/snmalloc.sln'