Respect riscv targets in platform macros#2386
Open
carlosqwqqwq wants to merge 1 commit into
Open
Conversation
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
RapidJSON is header-only, but some platform macros and test/performance entry points still infer target capabilities from host compiler predefined macros. In a simulated or cross-target
riscv64configuration built from anx86_64host compiler, that can incorrectly preserve x86-only assumptions such as the 48-bit pointer optimization or host SIMD auto-detection. This patch makes the generic RISC-V path explicit and keeps simulated validation builds from inheriting host-specific SIMD behavior.What changed
RAPIDJSON_RISCVplatform macro inrapidjson.h.__riscv_xlen == 64as a 64-bit target inrapidjson.h.RAPIDJSON_48BITPOINTER_OPTIMIZATIONon RISC-V so RISC-V builds do not inherit the x86-64-specific pointer compression assumption.test/perftest/perftest.handtest/unittest/simdtest.cppso simulated or cross-target RISC-V validation does not auto-enable hostSSE2/SSE4.2/NEONpaths.std::string, avoiding an x86-specific short-string layout assumption during non-x86 validation builds.Verification
RAPIDJSON_BUILD_DOC=OFFandRAPIDJSON_BUILD_TESTS=OFF.cmake --build build-codex-native-058 --parallel 4.riscv64CMake configuration withCMAKE_SYSTEM_NAME=Linux,CMAKE_SYSTEM_PROCESSOR=riscv64,CMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY, and forced__riscv=1/__riscv_xlen=64because no real RISC-V toolchain is available on the host.rapidjson.hunder forced__riscv=1/__riscv_xlen=64and confirmedRAPIDJSON_RISCV=1,RAPIDJSON_64BIT=1, andRAPIDJSON_48BITPOINTER_OPTIMIZATION=0.example/tutorial/tutorial.cpp.o, and confirmedbuild.ninjacontains no-msse*,-mavx*, orNEONflags.Notes
This is a conservative portability patch. It does not add a RISC-V SIMD backend. Because the host environment uses a Windows-native compiler while simulating a Linux
riscv64target, the final executable link step still inherits a host/toolchain mismatch around-rdynamic. Verification therefore focuses on native example build stability, simulated RISC-V configuration, object compilation, macro checks, and x86/ARM SIMD flag exclusion rather than a full realriscv64link.