Merge branch 'master' into jkeiser/wconversion

This commit is contained in:
Daniel Lemire 2020-04-22 22:03:34 -04:00
commit e030f02776
11 changed files with 119 additions and 33 deletions

View File

@ -34,7 +34,7 @@ test_script:
matrix:
fast_finish: true
exclude:
# Don't build all variants on 2019, just running it to make sure readme_tests succeed
- image: Visual Studio 2019
# Don't build all variants on 2017, just running it to make sure readme_tests succeed
- image: Visual Studio 2017
SIMDJSON_BUILD_STATIC: ON
SIMDJSON_ENABLE_THREADS: OFF

View File

@ -25,6 +25,13 @@ executors:
CXX: g++
BUILD_FLAGS: -j
CTEST_FLAGS: -j4 --output-on-failure
clang9:
docker:
- image: conanio/clang9
environment:
CXX: clang++-9
BUILD_FLAGS: -j
CTEST_FLAGS: -j4 --output-on-failure
clang6:
docker:
@ -50,10 +57,13 @@ commands:
- run: make test
- run: make checkperf
cmake_prep:
install_cmake:
steps:
- run: apt-get update -qq
- run: apt-get install -y cmake
cmake_prep:
steps:
- checkout
cmake_build:
@ -78,6 +88,7 @@ commands:
- run: SIMDJSON_FORCE_IMPLEMENTATION=fallback ctest $CTEST_FLAGS -L per_implementation
- run: ctest $CTEST_FLAGS -LE "acceptance|per_implementation" # Everything we haven't run yet, run now.
# we not only want cmake to build and run tests, but we want also a successful installation from which we can build, link and run programs
cmake_install_test: # this version builds, install, test and then verify from the installation
steps:
@ -91,60 +102,65 @@ jobs:
description: Build and run tests on GCC 7 and AVX 2 with a cmake static build
executor: gcc7
environment: { CMAKE_FLAGS: -DSIMDJSON_GOOGLE_BENCHMARKS=ON }
steps: [ cmake_test_all, cmake_install_test ]
steps: [ install_cmake, cmake_test_all, cmake_install_test ]
clang6:
description: Build and run tests on clang 6 and AVX 2 with a cmake static build
executor: clang6
environment: { CMAKE_FLAGS: -DSIMDJSON_GOOGLE_BENCHMARKS=ON }
steps: [ init_clang6, cmake_test_all, cmake_install_test ]
steps: [ init_clang6, install_cmake, cmake_test_all, cmake_install_test ]
# libcpp
libcpp-clang9:
description: Build and run tests on clang 6 and AVX 2 with a cmake static build and libc++
executor: clang9
environment: { CMAKE_FLAGS: -DSIMDJSON_USE_LIBCPP=ON }
steps: [ cmake_test_all, cmake_install_test ]
# sanitize
sanitize-gcc9:
description: Build and run tests on GCC 9 and AVX 2 with a cmake sanitize build
executor: gcc9
environment: { CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF -DSIMDJSON_SANITIZE=ON, CTEST_FLAGS: -j4 --output-on-failure -E checkperf }
steps: [ cmake_test_all ]
steps: [ install_cmake, cmake_test_all ]
sanitize-clang6:
description: Build and run tests on clang 6 and AVX 2 with a cmake sanitize build
executor: clang6
environment: { CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF -DSIMDJSON_SANITIZE=ON, CTEST_FLAGS: -j4 --output-on-failure -E checkperf }
steps: [ init_clang6, cmake_test_all ]
steps: [ init_clang6, install_cmake, cmake_test_all ]
# dynamic
dynamic-gcc7:
description: Build and run tests on GCC 7 and AVX 2 with a cmake dynamic build
executor: gcc7
environment: { CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF }
steps: [ cmake_test, cmake_install_test ]
steps: [ install_cmake, cmake_test, cmake_install_test ]
dynamic-clang6:
description: Build and run tests on clang 6 and AVX 2 with a cmake dynamic build
executor: clang6
environment: { CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF }
steps: [ init_clang6, cmake_test, cmake_install_test ]
steps: [ init_clang6, install_cmake, cmake_test, cmake_install_test ]
# unthreaded
unthreaded-gcc7:
description: Build and run tests on GCC 7 and AVX 2 *without* threads
executor: gcc7
environment: { CMAKE_FLAGS: -DSIMDJSON_ENABLE_THREADS=OFF }
steps: [ cmake_test, cmake_install_test ]
steps: [ install_cmake, cmake_test, cmake_install_test ]
unthreaded-clang6:
description: Build and run tests on Clang 6 and AVX 2 *without* threads
executor: clang6
environment: { CMAKE_FLAGS: -DSIMDJSON_ENABLE_THREADS=OFF }
steps: [ init_clang6, cmake_test, cmake_install_test ]
steps: [ init_clang6, install_cmake, cmake_test, cmake_install_test ]
# noexcept
noexcept-gcc7:
description: Build and run tests on GCC 7 and AVX 2 with exceptions off
executor: gcc7
environment: { CMAKE_FLAGS: -DSIMDJSON_EXCEPTIONS=OFF }
steps: [ cmake_test, cmake_install_test ]
steps: [ install_cmake, cmake_test, cmake_install_test ]
noexcept-clang6:
description: Build and run tests on GCC 7 and AVX 2 with exceptions off
executor: clang6
environment: { CMAKE_FLAGS: -DSIMDJSON_EXCEPTIONS=OFF }
steps: [ init_clang6, cmake_test, cmake_install_test ]
steps: [ init_clang6, install_cmake, cmake_test, cmake_install_test ]
#
# Misc.
@ -174,7 +190,10 @@ workflows:
# full multi-implementation tests
- gcc7
- clang6
# libc++
- libcpp-clang9
# full single-implementation tests
- sanitize-gcc9
- sanitize-clang6

View File

@ -3,18 +3,19 @@ task:
freebsd_instance:
matrix:
- image_family: freebsd-13-0-snap
- image_family: freebsd-12-1
- image_family: freebsd-11-3-snap
env:
ASSUME_ALWAYS_YES: YES
setup_script:
- pkg update -f
- pkg install bash
- pkg install cmake
- pkg install git
build_script:
- mkdir build
- cd build
- cmake ..
- make
- make -j2
test_script:
- ctest
- cd build
- ctest -j2 --output-on-failure -E checkperf

View File

@ -25,11 +25,13 @@ if(MSVC)
else()
option(SIMDJSON_BUILD_STATIC "Build a static library" OFF) # turning it on disables the production of a dynamic library
option(SIMDJSON_COMPETITION "Compile competitive benchmarks" ON)
option(SIMDJSON_USE_LIBCPP "Use the libc++ library" OFF)
endif()
option(SIMDJSON_GOOGLE_BENCHMARKS "compile the Google Benchmark benchmarks" OFF)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake")
# We compile tools, tests, etc. with C++ 17. Override yourself if you need on a target.
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@ -38,6 +40,7 @@ set(CMAKE_MACOSX_RPATH OFF)
set(CMAKE_THREAD_PREFER_PTHREAD ON)
set(THREADS_PREFER_PTHREAD_FLAG ON)
# LTO seems to create all sorts of fun problems. Let us
# disable temporarily.
#include(CheckIPOSupported)
@ -58,6 +61,17 @@ else()
target_compile_options(simdjson-flags INTERFACE -Werror -Wall -Wextra -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self -Wconversion -Wno-sign-conversion)
endif()
if(SIMDJSON_USE_LIBCPP)
target_link_libraries(simdjson-flags INTERFACE -stdlib=libc++ -lc++abi)
# instead of the above line, we could have used
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi")
# The next line is needed empirically.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
# we update CMAKE_SHARED_LINKER_FLAGS, this gets updated later as well
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lc++abi")
endif(SIMDJSON_USE_LIBCPP)
# Optional flags
option(SIMDJSON_IMPLEMENTATION_HASWELL "Include the haswell implementation" ON)
if(NOT SIMDJSON_IMPLEMENTATION_HASWELL)

View File

@ -2,6 +2,7 @@
[![CircleCI](https://circleci.com/gh/simdjson/simdjson.svg?style=svg)](https://circleci.com/gh/simdjson/simdjson)
[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/simdjson.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&q=proj%3Asimdjson&can=2)
[![Build status](https://ci.appveyor.com/api/projects/status/ae77wp5v3lebmu6n/branch/master?svg=true)](https://ci.appveyor.com/project/lemire/simdjson-jmmti/branch/master)
[![CirrusCI](https://api.cirrus-ci.com/github/simdjson/simdjson.svg)](https://cirrus-ci.com/github/simdjson/simdjson)
[![][license img]][license]
simdjson : Parsing gigabytes of JSON per second

View File

@ -35,7 +35,7 @@ if (SIMDJSON_COMPETITION)
target_compile_definitions(allparsingcompetition PRIVATE ALLPARSER)
endif()
if (NOT MSVC)
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
add_test(NAME checkperf
COMMAND ${CMAKE_COMMAND} -E env
CHECKPERF_REPOSITORY=https://github.com/simdjson/simdjson
@ -46,4 +46,4 @@ if (NOT MSVC)
set_property(TEST checkperf APPEND PROPERTY LABELS per_implementation)
set_property(TEST checkperf APPEND PROPERTY DEPENDS parse perfdiff ${SIMDJSON_USER_CMAKECACHE})
set_property(TEST checkperf PROPERTY RUN_SERIAL TRUE)
endif()
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")

View File

@ -20,7 +20,7 @@ Requirements
------------------
- A recent compiler (LLVM clang6 or better, GNU GCC 7 or better, Visual Studio 2017 or better). We require C++11 support as a minimum.
- A 64-bit system (ARM or x64 Intel/AMD). Under Visual Studio, you must compile for 64-bit (e.g., x64) targets.
- A 64-bit system (ARM or x64 Intel/AMD). We run tests on macOS, freeBSD, Linux and Windows. We recommend that Visual Studio users target a 64-bit build (x64).
Including simdjson
------------------

View File

@ -3,7 +3,13 @@
#
# TODO haven't quite decided the right way to run quickstart on Windows. Needs README update.
if (NOT MSVC)
#
# Note: on macOS and other platforms, the 'command' described below may not work even if the cmake builds.
# For example, it may be necessary to specify the sysroot, which CMake does, but the 'command' does not
# handle such niceties. On a case-by-case basis it is fixable but it requires work that CMake knows how
# to do but that is not trivial.
#
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
# TODO run amalgamate first!
function(add_quickstart_test TEST_NAME SOURCE_FILE)
# Second argument is C++ standard name

View File

@ -122,11 +122,49 @@ constexpr size_t DEFAULT_MAX_DEPTH = 1024;
#endif // MSC_VER
//
// Backfill std::string_view using nonstd::string_view on C++11
//
#if (!SIMDJSON_CPLUSPLUS17)
// C++17 requires string_view.
#if SIMDJSON_CPLUSPLUS17
#define SIMDJSON_HAS_STRING_VIEW
#endif
// This macro (__cpp_lib_string_view) has to be defined
// for C++17 and better, but if it is otherwise defined,
// we are going to assume that string_view is available
// even if we do not have C++17 support.
#ifdef __cpp_lib_string_view
#define SIMDJSON_HAS_STRING_VIEW
#endif
// Some systems have string_view even if we do not have C++17 support,
// and even if __cpp_lib_string_view is undefined, it is the case
// with Apple clang version 11.
// We must handle it. *This is important.*
#ifndef SIMDJSON_HAS_STRING_VIEW
#if defined __has_include
// do not combine the next #if with the previous one (unsafe)
#if __has_include (<string_view>)
// now it is safe to trigger the include
#include <string_view> // though the file is there, it does not follow that we got the implementation
#if defined(_LIBCPP_STRING_VIEW)
// Ah! So we under libc++ which under its Library Fundamentals Technical Specification, which preceeded C++17,
// included string_view.
// This means that we have string_view *even though* we may not have C++17.
#define SIMDJSON_HAS_STRING_VIEW
#endif // _LIBCPP_STRING_VIEW
#endif // __has_include (<string_view>)
#endif // defined __has_include
#endif // def SIMDJSON_HAS_STRING_VIEW
// end of complicated but important routine to try to detect string_view.
//
// Backfill std::string_view using nonstd::string_view on systems where
// we expect that string_view is missing. Important: if we get this wrong,
// we will end up with two string_view definitions and potential trouble.
// That is why we work so hard above to avoid it.
//
#ifndef SIMDJSON_HAS_STRING_VIEW
SIMDJSON_PUSH_DISABLE_ALL_WARNINGS
#include "simdjson/nonstd/string_view.hpp"
SIMDJSON_POP_DISABLE_WARNINGS
@ -134,6 +172,7 @@ SIMDJSON_POP_DISABLE_WARNINGS
namespace std {
using string_view = nonstd::string_view;
}
#endif // if (SIMDJSON_CPLUSPLUS < 201703L)
#endif // SIMDJSON_HAS_STRING_VIEW
#undef SIMDJSON_HAS_STRING_VIEW // We are not going to need this macro anymore.
#endif // SIMDJSON_COMMON_DEFS_H

View File

@ -1,7 +1,13 @@
#
# Amalgamation
#
# We should check whether bash is available here and avoid failures on systems where
# bash is unavailable.
if (NOT MSVC)
##
# Important! The script amalgamate.sh is not generally executable. It
# assumes that bash is at /bin/bash which may not be true.
###
set(SINGLEHEADER_FILES simdjson.h simdjson.cpp amalgamate_demo.cpp README.md)
add_custom_command(
OUTPUT ${SINGLEHEADER_FILES}
@ -9,12 +15,11 @@ if (NOT MSVC)
AMALGAMATE_SOURCE_PATH=${PROJECT_SOURCE_DIR}/src
AMALGAMATE_INPUT_PATH=${PROJECT_SOURCE_DIR}/include
AMALGAMATE_OUTPUT_PATH=${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/amalgamate.sh
DEPENDS simdjson-source amalgamate.sh
bash ${CMAKE_CURRENT_SOURCE_DIR}/amalgamate.sh
DEPENDS amalgamate.sh simdjson-source
)
add_custom_target(amalgamate DEPENDS ${SINGLEHEADER_FILES})
add_executable(amalgamate_demo amalgamate_demo.cpp)
target_link_libraries(amalgamate_demo simdjson-include-source)
add_test(amalgamate_demo amalgamate_demo ${EXAMPLE_JSON} ${EXAMPLE_NDJSON})

View File

@ -66,7 +66,7 @@ if (NOT MSVC) # Can't run .sh on windows
#
add_test(
NAME testjson2json
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/testjson2json.sh
COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/testjson2json.sh
WORKING_DIRECTORY $<TARGET_FILE_DIR:minify>
)
set_property(TEST testjson2json APPEND PROPERTY DEPENDS minify json2json)
@ -79,12 +79,13 @@ if (NOT MSVC) # Can't run .sh on windows
add_executable(allparserscheckfile allparserscheckfile.cpp)
target_link_libraries(allparserscheckfile competition-all)
add_test(issue150 ${CMAKE_CURRENT_SOURCE_DIR}/issue150.sh)
add_test(issue150 bash ${CMAKE_CURRENT_SOURCE_DIR}/issue150.sh)
set_property(TEST issue150 APPEND PROPERTY DEPENDS allparserscheckfile)
set_property(TEST issue150 APPEND PROPERTY LABELS per_implementation)
endif()
endif()
# This should really test whether bash is available.
if (NOT MSVC)
#
# json2json tool test: check that json2json can parse twitter.json