diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 9cbc8a79cd..062863fda4 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -12,9 +12,11 @@ jobs: container: image: fedora:40 steps: - - uses: actions/checkout@v4 - name: Install dependencies - run: dnf install -y ninja-build cmake gtest-devel re2c clang util-linux + run: dnf install -y ninja-build cmake gtest-devel re2c clang util-linux git + - uses: actions/checkout@v4 + with: + submodules: recursive - name: Linting run: misc/ci.py - name: Configure with CMake @@ -41,16 +43,18 @@ jobs: container: image: rockylinux:8 steps: - - uses: actions/checkout@v4 - - uses: codespell-project/actions-codespell@master - with: - ignore_words_list: fo,wee,addin,notin - name: Install dependencies run: | dnf install -y make gcc-c++ libasan clang-analyzer cmake dnf-plugins-core epel-release dnf config-manager --set-enabled powertools - dnf install -y gtest-devel p7zip p7zip-plugins - + dnf install -y gtest-devel p7zip p7zip-plugins git + - uses: actions/checkout@v4 + with: + submodules: recursive + - uses: codespell-project/actions-codespell@master + with: + ignore_words_list: fo,wee,addin,notin + skip: ./parallel-hashmap - name: Build debug ninja shell: bash env: @@ -103,12 +107,14 @@ jobs: container: image: ubuntu:20.04 steps: - - uses: actions/checkout@v4 - name: Install dependencies run: | apt update - apt install -y python3-pytest ninja-build clang-tidy python3-pip clang libgtest-dev + apt install -y python3-pytest ninja-build clang-tidy python3-pip clang libgtest-dev git pip3 install cmake==3.17.* + - uses: actions/checkout@v4 + with: + submodules: recursive - name: Configure (GCC) run: cmake -Bbuild-gcc -DCMAKE_BUILD_TYPE=Debug -G'Ninja Multi-Config' @@ -159,11 +165,13 @@ jobs: matrix: image: ['ubuntu:20.04', 'ubuntu:22.04', 'ubuntu:24.04'] steps: - - uses: actions/checkout@v4 - name: Install dependencies run: | apt update - apt install -y g++ python3 + apt install -y g++ python3 git + - uses: actions/checkout@v4 + with: + submodules: recursive - name: ${{ matrix.image }} run: | python3 configure.py --bootstrap @@ -176,6 +184,8 @@ jobs: runs-on: [ubuntu-latest] steps: - uses: actions/checkout@v4 + with: + submodules: recursive - name: Build uses: uraimo/run-on-arch-action@v2 diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index f4f26abf69..910ebad5a4 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -12,6 +12,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + submodules: recursive - name: Install dependencies run: brew install re2c p7zip cmake diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index c20889d40d..9e6c68ef4c 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -21,6 +21,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + submodules: recursive - name: Install dependencies run: choco install re2c diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..5659dfa757 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "parallel-hashmap"] + path = parallel-hashmap + url = https://github.com/greg7mdp/parallel-hashmap.git diff --git a/CMakeLists.txt b/CMakeLists.txt index b8fdee7d3a..1e446508e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,6 +61,8 @@ else() endif() endif() +include_directories(parallel-hashmap) + # --- optional re2c set(RE2C_MAJOR_VERSION 0) find_program(RE2C re2c) diff --git a/appveyor.yml b/appveyor.yml index 505e1423af..a6bd39c21f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,6 +10,9 @@ environment: - MSYSTEM: MINGW64 - MSYSTEM: LINUX +install: + - git submodule update --init --recursive + matrix: exclude: - image: Visual Studio 2017 diff --git a/configure.py b/configure.py index c88daad508..b2abdfd50a 100755 --- a/configure.py +++ b/configure.py @@ -345,6 +345,7 @@ def search_system_path(file_name: str) -> Optional[str]: # type: ignore # Missi # Disable size_t -> int truncation warning. # We never have strings or arrays larger than 2**31. '/wd4267', + '/Iparallel-hashmap', '/DNOMINMAX', '/D_CRT_SECURE_NO_WARNINGS', '/D_HAS_EXCEPTIONS=0', '/DNINJA_PYTHON="%s"' % options.with_python] @@ -363,6 +364,7 @@ def search_system_path(file_name: str) -> Optional[str]: # type: ignore # Missi '-fno-exceptions', '-std=c++11', '-fvisibility=hidden', '-pipe', + '-Iparallel-hashmap', '-DNINJA_PYTHON="%s"' % options.with_python] if options.debug: cflags += ['-D_GLIBCXX_DEBUG', '-D_GLIBCXX_DEBUG_PEDANTIC'] diff --git a/misc/ci.py b/misc/ci.py index 20a4415f8a..d2220f2bb5 100755 --- a/misc/ci.py +++ b/misc/ci.py @@ -7,6 +7,7 @@ 'misc/afl-fuzz-tokens/', 'src/depfile_parser.cc', 'src/lexer.cc', + 'parallel-hashmap/', ] error_count = 0 diff --git a/parallel-hashmap b/parallel-hashmap new file mode 160000 index 0000000000..d88c5e1507 --- /dev/null +++ b/parallel-hashmap @@ -0,0 +1 @@ +Subproject commit d88c5e15079047777b418132ece5879e7c9aaa2b diff --git a/src/hash_map.h b/src/hash_map.h index 3f465338ac..5448a3fcef 100644 --- a/src/hash_map.h +++ b/src/hash_map.h @@ -17,6 +17,8 @@ #include #include +#include "parallel_hashmap/phmap.h" +#include "parallel_hashmap/phmap_utils.h" #include "string_piece.h" #include "util.h" @@ -53,8 +55,6 @@ unsigned int MurmurHash2(const void* key, size_t len) { return h; } -#include - namespace std { template<> struct hash { @@ -73,7 +73,7 @@ struct hash { /// mapping StringPiece => Foo*. template struct ExternalStringHashMap { - typedef std::unordered_map Type; + typedef phmap::flat_hash_map Type; }; #endif // NINJA_MAP_H_