From f30f4a860627be26d860803c576a76e39ce44633 Mon Sep 17 00:00:00 2001 From: "Evgeny @ SimpleX Chat" <259188159+evgeny-simplex@users.noreply.github.com> Date: Tue, 9 Jun 2026 17:58:57 +0000 Subject: [PATCH] use constraint to include simplexmq --- .github/workflows/build.yml | 8 ++++---- Dockerfile | 2 +- cabal.project | 2 +- flake.nix | 3 ++- scripts/desktop/build-lib-linux.sh | 4 ++-- scripts/desktop/build-lib-mac.sh | 4 ++-- scripts/desktop/build-lib-windows.sh | 2 +- scripts/nix/sha256map.nix | 3 ++- scripts/simplex-chat-reproduce-builds.sh | 2 +- 9 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 550b76786f..e2ee966b9d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -233,7 +233,7 @@ jobs: run: | cabal clean cabal update - cabal build -j --enable-tests ${{ github.event_name != 'pull_request' && '-foptimize' || '' }} + cabal build -j --enable-tests ${{ github.event_name != 'pull_request' && '--constraint "simplex-chat +optimize" --constraint "simplexmq +optimize"' || '' }} mkdir -p /out for i in simplex-chat simplex-chat-test; do bin=$(find /project/dist-newstyle -name "$i" -type f -executable) @@ -527,7 +527,7 @@ jobs: id: mac_cli_build shell: bash run: | - cabal build -j --enable-tests ${{ github.event_name != 'pull_request' && '-foptimize' || '' }} + cabal build -j --enable-tests ${{ github.event_name != 'pull_request' && '--constraint "simplex-chat +optimize" --constraint "simplexmq +optimize"' || '' }} path=$(cabal list-bin simplex-chat) echo "bin_path=$path" >> $GITHUB_OUTPUT echo "bin_hash=$(echo SHA2-256\(${{ matrix.cli_asset_name }}\)= $(openssl sha256 $path | cut -d' ' -f 2))" >> $GITHUB_OUTPUT @@ -575,7 +575,7 @@ jobs: attempts=1 ${{ (github.ref == 'refs/heads/stable' || startsWith(github.ref, 'refs/tags/v')) }} && attempts=3 while [ "$i" -le "$attempts" ]; do - if cabal test --test-show-details=direct ${{ github.event_name != 'pull_request' && '-foptimize' || '' }}; then + if cabal test --test-show-details=direct ${{ github.event_name != 'pull_request' && '--constraint "simplex-chat +optimize" --constraint "simplexmq +optimize"' || '' }}; then break else echo "Attempt $i failed, retrying..." @@ -654,7 +654,7 @@ jobs: rm -rf dist-newstyle/src/direct-sq* sed -i "s/, unix /--, unix /" simplex-chat.cabal - cabal build -j --enable-tests ${{ github.event_name != 'pull_request' && '-foptimize' || '' }} + cabal build -j --enable-tests ${{ github.event_name != 'pull_request' && '--constraint "simplex-chat +optimize" --constraint "simplexmq +optimize"' || '' }} rm -rf dist-newstyle/src/direct-sq* path=$(cabal list-bin simplex-chat | tail -n 1) echo "bin_path=$path" >> $GITHUB_OUTPUT diff --git a/Dockerfile b/Dockerfile index 9830d18b9f..ba79955c8a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,7 @@ RUN cp ./scripts/cabal.project.local.linux ./cabal.project.local # Compile simplex-chat RUN cabal update -RUN cabal build exe:simplex-chat --constraint 'simplexmq +client_library' --constraint 'simplex-chat +client_library +optimize' +RUN cabal build exe:simplex-chat --constraint 'simplexmq +client_library +optimize' --constraint 'simplex-chat +client_library +optimize' # Strip the binary from debug symbols to reduce size RUN bin=$(find /project/dist-newstyle -name "simplex-chat" -type f -executable) && \ diff --git a/cabal.project b/cabal.project index 3e32dfcd5e..802c198116 100644 --- a/cabal.project +++ b/cabal.project @@ -21,7 +21,7 @@ constraints: zip +disable-bzip2 +disable-zstd source-repository-package type: git location: https://github.com/simplex-chat/simplexmq.git - tag: b981dcb70b8c99dc3733a99b6c1dc0d0ef83a3f7 + tag: 3dd2f746f5d6e8d9f55db2128745797364175fc6 source-repository-package type: git diff --git a/flake.nix b/flake.nix index ca51bb0881..41480ed14d 100644 --- a/flake.nix +++ b/flake.nix @@ -52,9 +52,10 @@ ({ ... }: { - # Build simplex-chat with -O2 in all nix outputs (desktop, mobile, libs). + # Build with -O2 in all nix outputs (desktop, mobile, libs). # The optimize flag defaults off (fast local/PR builds); nix always enables it. packages.simplex-chat.flags.optimize = true; + packages.simplexmq.flags.optimize = true; } ) diff --git a/scripts/desktop/build-lib-linux.sh b/scripts/desktop/build-lib-linux.sh index 22cfe942e8..68b21c15e5 100755 --- a/scripts/desktop/build-lib-linux.sh +++ b/scripts/desktop/build-lib-linux.sh @@ -28,10 +28,10 @@ for elem in "${exports[@]}"; do count=$(grep -R "\"$elem\"" flake.nix | wc -l); #rm -rf $BUILD_DIR if [[ "$DATABASE_BACKEND" == "postgres" ]]; then echo "Building with postgres backend..." - cabal build lib:simplex-chat --ghc-options='-optl-Wl,-rpath,$ORIGIN -optl-Wl,-soname,libsimplex.so -flink-rts -threaded' --constraint 'simplexmq +client_library +client_postgres' --constraint 'simplex-chat +client_library +client_postgres +optimize' + cabal build lib:simplex-chat --ghc-options='-optl-Wl,-rpath,$ORIGIN -optl-Wl,-soname,libsimplex.so -flink-rts -threaded' --constraint 'simplexmq +client_library +client_postgres +optimize' --constraint 'simplex-chat +client_library +client_postgres +optimize' else echo "Building with sqlite backend..." - cabal build lib:simplex-chat --ghc-options='-optl-Wl,-rpath,$ORIGIN -optl-Wl,-soname,libsimplex.so -flink-rts -threaded' --constraint 'simplexmq +client_library' --constraint 'simplex-chat +client_library +optimize' + cabal build lib:simplex-chat --ghc-options='-optl-Wl,-rpath,$ORIGIN -optl-Wl,-soname,libsimplex.so -flink-rts -threaded' --constraint 'simplexmq +client_library +optimize' --constraint 'simplex-chat +client_library +optimize' fi cd $BUILD_DIR/build mv libHSsimplex-chat-*-inplace-ghc${GHC_VERSION}.so libsimplex.so 2> /dev/null || true diff --git a/scripts/desktop/build-lib-mac.sh b/scripts/desktop/build-lib-mac.sh index 5716483c49..1aa42cff3b 100755 --- a/scripts/desktop/build-lib-mac.sh +++ b/scripts/desktop/build-lib-mac.sh @@ -28,10 +28,10 @@ rm -rf $BUILD_DIR if [[ "$DATABASE_BACKEND" == "postgres" ]]; then echo "Building with postgres backend..." - cabal build lib:simplex-chat lib:simplex-chat --ghc-options="-optl-Wl,-rpath,@loader_path -optl-Wl,-install_name,@rpath/$LIB -optl-Wl,-L$GHC_LIBS_DIR/$ARCH-osx-ghc-$GHC_VERSION -optl-lHSrts_thr-ghc$GHC_VERSION -optl-lffi" --constraint 'simplexmq +client_library +client_postgres' --constraint 'simplex-chat +client_library +client_postgres +optimize' + cabal build lib:simplex-chat lib:simplex-chat --ghc-options="-optl-Wl,-rpath,@loader_path -optl-Wl,-install_name,@rpath/$LIB -optl-Wl,-L$GHC_LIBS_DIR/$ARCH-osx-ghc-$GHC_VERSION -optl-lHSrts_thr-ghc$GHC_VERSION -optl-lffi" --constraint 'simplexmq +client_library +client_postgres +optimize' --constraint 'simplex-chat +client_library +client_postgres +optimize' else echo "Building with sqlite backend..." - cabal build lib:simplex-chat lib:simplex-chat --ghc-options="-optl-Wl,-rpath,@loader_path -optl-Wl,-install_name,@rpath/$LIB -optl-Wl,-L$GHC_LIBS_DIR/$ARCH-osx-ghc-$GHC_VERSION -optl-lHSrts_thr-ghc$GHC_VERSION -optl-lffi" --constraint 'simplexmq +client_library' --constraint 'simplex-chat +client_library +optimize' + cabal build lib:simplex-chat lib:simplex-chat --ghc-options="-optl-Wl,-rpath,@loader_path -optl-Wl,-install_name,@rpath/$LIB -optl-Wl,-L$GHC_LIBS_DIR/$ARCH-osx-ghc-$GHC_VERSION -optl-lHSrts_thr-ghc$GHC_VERSION -optl-lffi" --constraint 'simplexmq +client_library +optimize' --constraint 'simplex-chat +client_library +optimize' fi cd $BUILD_DIR/build diff --git a/scripts/desktop/build-lib-windows.sh b/scripts/desktop/build-lib-windows.sh index 80b373e9a2..752ae11fa2 100755 --- a/scripts/desktop/build-lib-windows.sh +++ b/scripts/desktop/build-lib-windows.sh @@ -51,7 +51,7 @@ echo " ghc-options: -shared -threaded -optl-L$openssl_windows_style_path -opt # Very important! Without it the build fails on linking step since the linker can't find exported symbols. # It looks like GHC bug because with such random path the build ends successfully sed -i "s/ld.lld.exe/abracadabra.exe/" `ghc --print-libdir`/settings -cabal build lib:simplex-chat --constraint 'simplexmq +client_library' --constraint 'simplex-chat +client_library +optimize' +cabal build lib:simplex-chat --constraint 'simplexmq +client_library +optimize' --constraint 'simplex-chat +client_library +optimize' rm -rf apps/multiplatform/common/src/commonMain/cpp/desktop/libs/$OS-$ARCH/ rm -rf apps/multiplatform/desktop/build/cmake diff --git a/scripts/nix/sha256map.nix b/scripts/nix/sha256map.nix index 3610906390..5a3b026bb7 100644 --- a/scripts/nix/sha256map.nix +++ b/scripts/nix/sha256map.nix @@ -1,5 +1,6 @@ { - "https://github.com/simplex-chat/simplexmq.git"."b981dcb70b8c99dc3733a99b6c1dc0d0ef83a3f7" = "0wpri01w30rd3wwzw630yngnj9fmyb7rschl3ic1cjd926vpg9b7"; + # NOTE: hash below is a PLACEHOLDER for the new simplexmq commit - run `update-sha256map` (in `nix develop`) to regenerate from cabal.project, or let `nix build` report the correct hash and paste it here. + "https://github.com/simplex-chat/simplexmq.git"."3dd2f746f5d6e8d9f55db2128745797364175fc6" = "0000000000000000000000000000000000000000000000000000"; "https://github.com/simplex-chat/hs-socks.git"."a30cc7a79a08d8108316094f8f2f82a0c5e1ac51" = "0yasvnr7g91k76mjkamvzab2kvlb1g5pspjyjn2fr6v83swjhj38"; "https://github.com/simplex-chat/direct-sqlcipher.git"."f814ee68b16a9447fbb467ccc8f29bdd3546bfd9" = "1ql13f4kfwkbaq7nygkxgw84213i0zm7c1a8hwvramayxl38dq5d"; "https://github.com/simplex-chat/sqlcipher-simple.git"."a46bd361a19376c5211f1058908fc0ae6bf42446" = "1z0r78d8f0812kxbgsm735qf6xx8lvaz27k1a0b4a2m0sshpd5gl"; diff --git a/scripts/simplex-chat-reproduce-builds.sh b/scripts/simplex-chat-reproduce-builds.sh index c2eb6b60df..6c29d6026e 100755 --- a/scripts/simplex-chat-reproduce-builds.sh +++ b/scripts/simplex-chat-reproduce-builds.sh @@ -80,7 +80,7 @@ for os_pair in ${oses}; do # CLI docker exec \ -t "${container_name}" \ - sh -c 'cabal clean && cabal update && cabal build -j -foptimize && mkdir -p /out && for i in simplex-chat; do bin=$(find /project/dist-newstyle -name "$i" -type f -executable) && chmod +x "$bin" && mv "$bin" /out/; done && strip /out/simplex-chat' + sh -c 'cabal clean && cabal update && cabal build -j --constraint "simplex-chat +optimize" --constraint "simplexmq +optimize" && mkdir -p /out && for i in simplex-chat; do bin=$(find /project/dist-newstyle -name "$i" -type f -executable) && chmod +x "$bin" && mv "$bin" /out/; done && strip /out/simplex-chat' # Copy CLI docker cp \