From 2e7a289c35091d4fa22bd3b4a85322077a53d2bc Mon Sep 17 00:00:00 2001 From: David Date: Thu, 26 Jun 2025 16:44:03 +0300 Subject: [PATCH 1/3] Support compilation of headers with x86 binaries --- include/flatbuffers/flatbuffer_builder.h | 6 +++--- include/flatbuffers/vector_downward.h | 4 ++-- include/flatbuffers/verifier.h | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/flatbuffers/flatbuffer_builder.h b/include/flatbuffers/flatbuffer_builder.h index 9ceca8207b6..9d77f58ee3c 100644 --- a/include/flatbuffers/flatbuffer_builder.h +++ b/include/flatbuffers/flatbuffer_builder.h @@ -288,7 +288,7 @@ template class FlatBufferBuilderImpl { void Align(size_t elem_size) { TrackMinAlign(elem_size); - buf_.fill(PaddingBytes(buf_.size(), elem_size)); + buf_.fill(PaddingBytes(static_cast(buf_.size()), elem_size)); } void PushFlatBuffer(const uint8_t *bytes, size_t size) { @@ -516,7 +516,7 @@ template class FlatBufferBuilderImpl { void PreAlign(size_t len, size_t alignment) { if (len == 0) return; TrackMinAlign(alignment); - buf_.fill(PaddingBytes(GetSize() + len, alignment)); + buf_.fill(PaddingBytes(static_cast(GetSize()) + len, alignment)); } // Aligns such than when "len" bytes are written, an object of type `AlignT` @@ -712,7 +712,7 @@ template class FlatBufferBuilderImpl { ForceVectorAlignment(len, elemsize, alignment); // Update the 64 bit region. - length_of_64_bit_region_ = GetSize(); + length_of_64_bit_region_ = static_cast(GetSize()); } // Similar to ForceVectorAlignment but for String fields. diff --git a/include/flatbuffers/vector_downward.h b/include/flatbuffers/vector_downward.h index 2b5a92cf171..bff94f39dfb 100644 --- a/include/flatbuffers/vector_downward.h +++ b/include/flatbuffers/vector_downward.h @@ -268,8 +268,8 @@ template class vector_downward { void reallocate(size_t len) { auto old_reserved = reserved_; - auto old_size = size(); - auto old_scratch_size = scratch_size(); + auto old_size = static_cast(size()); + auto old_scratch_size = static_cast(scratch_size()); reserved_ += (std::max)(len, old_reserved ? old_reserved / 2 : initial_size_); reserved_ = (reserved_ + buffer_minalign_ - 1) & ~(buffer_minalign_ - 1); diff --git a/include/flatbuffers/verifier.h b/include/flatbuffers/verifier.h index 6df923be45c..9a2e356b9f1 100644 --- a/include/flatbuffers/verifier.h +++ b/include/flatbuffers/verifier.h @@ -258,15 +258,15 @@ class VerifierTemplate FLATBUFFERS_FINAL_CLASS { template size_t VerifyOffset(const size_t start) const { if (!Verify(start)) return 0; - const auto o = ReadScalar(buf_ + start); + const auto o = static_cast(ReadScalar(buf_ + start)); // May not point to itself. if (!Check(o != 0)) return 0; // Can't wrap around larger than the max size. if (!Check(static_cast(o) >= 0)) return 0; // Must be inside the buffer to create a pointer from it (pointer outside // buffer is UB). - if (!Verify(start + o, 1)) return 0; - return o; + if (!static_cast(Verify(start + o, 1))) return 0; + return static_cast(o); } template From 62e56ee1c04f25a1c2f7180ab8b313294b986a95 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 26 Jun 2025 16:51:34 +0300 Subject: [PATCH 2/3] build for x86 --- .github/workflows/build.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a3f68059591..fae49caed35 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -127,6 +127,27 @@ jobs: if: matrix.std >= 17 run: ./flattests_cpp17 + build-linux-x86: + name: Build Linux (x86) + runs-on: ubuntu-24.04 + container: + image: i386/debian:bullseye + steps: + - name: Install dependencies + run: | + apt-get update + apt-get install -y build-essential cmake git clang g++ curl unzip + - name: Checkout repo + uses: actions/checkout@v3 + - name: cmake + run: CXX=g++ cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON . + - name: build + run: make -j$(nproc) + - name: test + run: ./flattests + - name: Check architecture + run: file flattests | grep "ELF 32-bit" + build-cpp-std: name: Build Windows C++ runs-on: windows-2019 From fb6ba4947415aee6c9e574037832ac9a1040e496 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 26 Jun 2025 16:52:40 +0300 Subject: [PATCH 3/3] Revert job --- .github/workflows/build.yml | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fae49caed35..a3f68059591 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -127,27 +127,6 @@ jobs: if: matrix.std >= 17 run: ./flattests_cpp17 - build-linux-x86: - name: Build Linux (x86) - runs-on: ubuntu-24.04 - container: - image: i386/debian:bullseye - steps: - - name: Install dependencies - run: | - apt-get update - apt-get install -y build-essential cmake git clang g++ curl unzip - - name: Checkout repo - uses: actions/checkout@v3 - - name: cmake - run: CXX=g++ cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_STRICT_MODE=ON . - - name: build - run: make -j$(nproc) - - name: test - run: ./flattests - - name: Check architecture - run: file flattests | grep "ELF 32-bit" - build-cpp-std: name: Build Windows C++ runs-on: windows-2019