From 3c2d15abc22a053449f57bdb4b42add6da52168a Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Fri, 23 May 2025 12:46:03 +0800 Subject: [PATCH] add musl math library --- .github/workflows/main.yml | 14 +++++++------- .gitmodules | 3 +++ 3rd/dmath/dmath | 1 + CMakeLists.txt | 9 ++++++++- CMakeOptions.txt | 2 +- cmake_build.py | 2 +- 6 files changed, 21 insertions(+), 10 deletions(-) create mode 160000 3rd/dmath/dmath diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0c5ba1b1..ba9c4e42 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,7 +17,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: true + submodules: recursive - uses: ilammy/msvc-dev-cmd@v1 - name: Compile shell: powershell @@ -30,7 +30,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: true + submodules: recursive - uses: ilammy/msvc-dev-cmd@v1 - name: Compile shell: bash @@ -52,7 +52,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: true + submodules: recursive - name: Setup Clang uses: egor-tensin/setup-clang@v1 with: @@ -87,7 +87,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: true + submodules: recursive - name: Compile and Test run: | python cmake_build.py Release -DPK_BUILD_MODULE_LZ4=ON @@ -101,7 +101,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: true + submodules: recursive - uses: nttld/setup-ndk@v1 id: setup-ndk with: @@ -132,7 +132,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: true + submodules: recursive - name: Compile Frameworks run: | git clone https://github.com/leetal/ios-cmake --depth 1 ~/ios-cmake @@ -151,7 +151,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: true + submodules: recursive - name: Setup Alpine Linux for ${{ matrix.arch }} uses: jirutka/setup-alpine@v1 with: diff --git a/.gitmodules b/.gitmodules index f2aa6039..563e5145 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "3rd/lz4/lz4"] path = 3rd/lz4/lz4 url = https://github.com/lz4/lz4 +[submodule "3rd/dmath/dmath"] + path = 3rd/dmath/dmath + url = https://github.com/pocketpy/dmath diff --git a/3rd/dmath/dmath b/3rd/dmath/dmath new file mode 160000 index 00000000..bc5ece5f --- /dev/null +++ b/3rd/dmath/dmath @@ -0,0 +1 @@ +Subproject commit bc5ece5f534d0d6bac8b0d88e121055fc8dfba6d diff --git a/CMakeLists.txt b/CMakeLists.txt index 68afcf7f..52535788 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,7 @@ else() endif() if(PK_ENABLE_DETERMINISM) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexcess-precision=standard -ffp-contract=off") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffp-contract=off") endif() endif() @@ -82,6 +82,13 @@ else() target_link_libraries(main ${PROJECT_NAME}) endif() + +if(PK_ENABLE_DETERMINISM) + add_subdirectory(3rd/dmath/dmath) + target_link_libraries(${PROJECT_NAME} dmath) + add_definitions(-DPK_ENABLE_DETERMINISM=1) +endif() + if(UNIX AND NOT APPLE) if(NOT PK_ENABLE_DETERMINISM) # use platform libm diff --git a/CMakeOptions.txt b/CMakeOptions.txt index 4e21ab44..1a22197b 100644 --- a/CMakeOptions.txt +++ b/CMakeOptions.txt @@ -7,7 +7,7 @@ endif() # system features option(PK_ENABLE_OS "" OFF) -option(PK_ENABLE_DETERMINISM "" FALSE) +option(PK_ENABLE_DETERMINISM "" OFF) option(PK_ENABLE_WATCHDOG "" OFF) # modules diff --git a/cmake_build.py b/cmake_build.py index 24437fb6..0e47e990 100644 --- a/cmake_build.py +++ b/cmake_build.py @@ -20,7 +20,7 @@ assert config in ['Debug', 'Release', 'RelWithDebInfo'] os.chdir("build") -code = os.system(f"cmake .. -DPK_ENABLE_OS=ON -DCMAKE_BUILD_TYPE={config} {extra_flags}") +code = os.system(f"cmake .. -DPK_ENABLE_OS=ON -DPK_ENABLE_DETERMINISM=ON -DCMAKE_BUILD_TYPE={config} {extra_flags}") assert code == 0 code = os.system(f"cmake --build . --config {config} -j 4") assert code == 0