From ffdc02c61c1edeefb5ec0a2d8ec6af61f877d858 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Mon, 2 Mar 2026 19:12:49 +0800 Subject: [PATCH 01/17] test i386 --- .github/copilot-instructions.md | 22 +++ .github/workflows/bisects.yml | 68 +++++----- .github/workflows/ci_docs.yml | 202 ++++++++++++++-------------- .github/workflows/ci_i386_linux.yml | 99 ++++++++++++++ .github/workflows/ci_packages.yml | 144 ++++++++++---------- .github/workflows/ci_publish.yml | 130 +++++++++--------- .github/workflows/stale.yml | 46 +++---- lib/system/bitmasks.nim | 3 + lib/system/gc.nim | 4 +- 9 files changed, 421 insertions(+), 297 deletions(-) create mode 100644 .github/copilot-instructions.md create mode 100644 .github/workflows/ci_i386_linux.yml diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 0000000000000..fb48b4af62abb --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,22 @@ +## Code Standards + +### General Guidelines + +Don't modify testing files, instead, you should fix the compiler or library code that is causing the test to fail. + + + + +### Testing a single case + +You can run a single test case by using the command `./koch temp c -r testname`, where `testname` is the name of the test case you want to run. Don't use testament. + + +### Repository Structure + +- `compiler`: Contains the Nim compiler source code. +- `lib`: Contains standard libraries and modules. +- `tests`: Contains test cases for the compiler and standard libraries. +- `doc`: Contains documentation related to the Nim programming language. \ No newline at end of file diff --git a/.github/workflows/bisects.yml b/.github/workflows/bisects.yml index ef6e160a06f2a..271fd9eb6f6d1 100644 --- a/.github/workflows/bisects.yml +++ b/.github/workflows/bisects.yml @@ -1,38 +1,38 @@ -# See https://github.com/juancarlospaco/nimrun-action/issues/3#issuecomment-1607344901 -name: issue comments bisects -on: - issue_comment: - types: created +# # See https://github.com/juancarlospaco/nimrun-action/issues/3#issuecomment-1607344901 +# name: issue comments bisects +# on: +# issue_comment: +# types: created -jobs: - bisects: - if: | - github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '!nim ') && github.event.issue.pull_request == null && github.event.comment.author_association != 'NONE' - strategy: - fail-fast: false - matrix: - platform: [ubuntu-latest, windows-latest, macos-latest] - name: ${{ matrix.platform }}-bisects - runs-on: ${{ matrix.platform }} - steps: - - uses: actions/checkout@v6 +# jobs: +# bisects: +# if: | +# github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '!nim ') && github.event.issue.pull_request == null && github.event.comment.author_association != 'NONE' +# strategy: +# fail-fast: false +# matrix: +# platform: [ubuntu-latest, windows-latest, macos-latest] +# name: ${{ matrix.platform }}-bisects +# runs-on: ${{ matrix.platform }} +# steps: +# - uses: actions/checkout@v6 - - name: Install OpenSSL (Windows) - if: | - runner.os == 'Windows' - run: choco install openssl.light --version=1.1.1.0 # OpenSSL 3.x removed SSL_library_init - shell: 'powershell' +# - name: Install OpenSSL (Windows) +# if: | +# runner.os == 'Windows' +# run: choco install openssl.light --version=1.1.1.0 # OpenSSL 3.x removed SSL_library_init +# shell: 'powershell' - # v2 wont work here, because uses "hardcoded" nim versions, action "dynamically" finds version with bug. - - uses: jiro4989/setup-nim-action@v1 - with: - nim-version: 'devel' +# # v2 wont work here, because uses "hardcoded" nim versions, action "dynamically" finds version with bug. +# - uses: jiro4989/setup-nim-action@v1 +# with: +# nim-version: 'devel' - - uses: juancarlospaco/nimrun-action@nim - if: | - runner.os == 'Linux' && contains(github.event.comment.body, '-d:linux' ) || - runner.os == 'Windows' && contains(github.event.comment.body, '-d:windows') || - runner.os == 'macOS' && contains(github.event.comment.body, '-d:osx' ) || - runner.os == 'Linux' && !contains(github.event.comment.body, '-d:linux') && !contains(github.event.comment.body, '-d:windows') && !contains(github.event.comment.body, '-d:osx') - with: - github-token: ${{ secrets.GITHUB_TOKEN }} +# - uses: juancarlospaco/nimrun-action@nim +# if: | +# runner.os == 'Linux' && contains(github.event.comment.body, '-d:linux' ) || +# runner.os == 'Windows' && contains(github.event.comment.body, '-d:windows') || +# runner.os == 'macOS' && contains(github.event.comment.body, '-d:osx' ) || +# runner.os == 'Linux' && !contains(github.event.comment.body, '-d:linux') && !contains(github.event.comment.body, '-d:windows') && !contains(github.event.comment.body, '-d:osx') +# with: +# github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/ci_docs.yml b/.github/workflows/ci_docs.yml index 74dd234a289b0..c259d1ba5d45d 100644 --- a/.github/workflows/ci_docs.yml +++ b/.github/workflows/ci_docs.yml @@ -1,116 +1,116 @@ -name: Nim Docs CI -on: - push: - paths: - - 'compiler/**.nim' - - 'config/nimdoc.cfg' - - 'doc/**.rst' - - 'doc/**.md' - - 'doc/nimdoc.css' - - 'lib/**.nim' - - 'nimdoc/testproject/expected/testproject.html' - - 'tools/dochack/dochack.nim' - - 'tools/kochdocs.nim' - - '.github/workflows/ci_docs.yml' - - 'koch.nim' +# name: Nim Docs CI +# on: +# push: +# paths: +# - 'compiler/**.nim' +# - 'config/nimdoc.cfg' +# - 'doc/**.rst' +# - 'doc/**.md' +# - 'doc/nimdoc.css' +# - 'lib/**.nim' +# - 'nimdoc/testproject/expected/testproject.html' +# - 'tools/dochack/dochack.nim' +# - 'tools/kochdocs.nim' +# - '.github/workflows/ci_docs.yml' +# - 'koch.nim' - pull_request: - # Run only on changes on these files. - paths: - - 'compiler/**.nim' - - 'config/nimdoc.cfg' - - 'doc/**.rst' - - 'doc/**.md' - - 'doc/nimdoc.css' - - 'lib/**.nim' - - 'nimdoc/testproject/expected/testproject.html' - - 'tools/dochack/dochack.nim' - - 'tools/kochdocs.nim' - - '.github/workflows/ci_docs.yml' - - 'koch.nim' +# pull_request: +# # Run only on changes on these files. +# paths: +# - 'compiler/**.nim' +# - 'config/nimdoc.cfg' +# - 'doc/**.rst' +# - 'doc/**.md' +# - 'doc/nimdoc.css' +# - 'lib/**.nim' +# - 'nimdoc/testproject/expected/testproject.html' +# - 'tools/dochack/dochack.nim' +# - 'tools/kochdocs.nim' +# - '.github/workflows/ci_docs.yml' +# - 'koch.nim' -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true +# concurrency: +# group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} +# cancel-in-progress: true -jobs: - build: - strategy: - fail-fast: false - matrix: - target: [linux, windows, osx] - include: - - target: linux - os: ubuntu-22.04 - - target: windows - os: windows-latest - - target: osx - os: macos-15 +# jobs: +# build: +# strategy: +# fail-fast: false +# matrix: +# target: [linux, windows, osx] +# include: +# - target: linux +# os: ubuntu-22.04 +# - target: windows +# os: windows-latest +# - target: osx +# os: macos-15 - name: ${{ matrix.target }} - runs-on: ${{ matrix.os }} - timeout-minutes: 60 # refs bug #18178 +# name: ${{ matrix.target }} +# runs-on: ${{ matrix.os }} +# timeout-minutes: 60 # refs bug #18178 - steps: - - name: 'Checkout' - uses: actions/checkout@v6 - with: - fetch-depth: 2 +# steps: +# - name: 'Checkout' +# uses: actions/checkout@v6 +# with: +# fetch-depth: 2 - - name: 'Install build dependencies (macOS)' - if: runner.os == 'macOS' - run: brew install make +# - name: 'Install build dependencies (macOS)' +# if: runner.os == 'macOS' +# run: brew install make - - name: 'Install build dependencies (Windows)' - if: runner.os == 'Windows' - shell: bash - run: | - set -e - . ci/funs.sh - nimInternalInstallDepsWindows - echo "${{ github.workspace }}/dist/mingw64/bin" >> "${GITHUB_PATH}" +# - name: 'Install build dependencies (Windows)' +# if: runner.os == 'Windows' +# shell: bash +# run: | +# set -e +# . ci/funs.sh +# nimInternalInstallDepsWindows +# echo "${{ github.workspace }}/dist/mingw64/bin" >> "${GITHUB_PATH}" - - name: 'Add build binaries to PATH' - shell: bash - run: echo "${{ github.workspace }}/bin" >> "${GITHUB_PATH}" +# - name: 'Add build binaries to PATH' +# shell: bash +# run: echo "${{ github.workspace }}/bin" >> "${GITHUB_PATH}" - - name: 'System information' - shell: bash - run: . ci/funs.sh && nimCiSystemInfo +# - name: 'System information' +# shell: bash +# run: . ci/funs.sh && nimCiSystemInfo - - name: 'Build csourcesAny (posix)' - # this would work on windows and other CI use this on windows, - # but we ensure here that `ci/build_autogen.bat` keeps working on windows. - if: runner.os != 'Windows' - shell: bash - run: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc - # was previously using caching via `actions/cache@v1` but this wasn't - # used in other CI pipelines and it's unclear the added complexity - # was worth the saving; can be revisited if needed. +# - name: 'Build csourcesAny (posix)' +# # this would work on windows and other CI use this on windows, +# # but we ensure here that `ci/build_autogen.bat` keeps working on windows. +# if: runner.os != 'Windows' +# shell: bash +# run: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc +# # was previously using caching via `actions/cache@v1` but this wasn't +# # used in other CI pipelines and it's unclear the added complexity +# # was worth the saving; can be revisited if needed. - - name: 'Build csourcesAny (windows)' - if: runner.os == 'Windows' - shell: cmd - run: ci/build_autogen.bat +# - name: 'Build csourcesAny (windows)' +# if: runner.os == 'Windows' +# shell: cmd +# run: ci/build_autogen.bat - - name: 'Build koch' - shell: bash - run: nim c koch +# - name: 'Build koch' +# shell: bash +# run: nim c koch - - name: 'Build the real compiler' - shell: bash - run: ./koch boot -d:release +# - name: 'Build the real compiler' +# shell: bash +# run: ./koch boot -d:release - - name: 'Build documentation' - shell: bash - run: ./koch doc --git.commit:devel +# - name: 'Build documentation' +# shell: bash +# run: ./koch doc --git.commit:devel - - name: 'Publish documentation to Github Pages' - if: | - github.event_name == 'push' && github.ref == 'refs/heads/devel' && - matrix.target == 'linux' - uses: crazy-max/ghaction-github-pages@v4 - with: - build_dir: doc/html - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# - name: 'Publish documentation to Github Pages' +# if: | +# github.event_name == 'push' && github.ref == 'refs/heads/devel' && +# matrix.target == 'linux' +# uses: crazy-max/ghaction-github-pages@v4 +# with: +# build_dir: doc/html +# env: +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/ci_i386_linux.yml b/.github/workflows/ci_i386_linux.yml new file mode 100644 index 0000000000000..572cf7ab7ce23 --- /dev/null +++ b/.github/workflows/ci_i386_linux.yml @@ -0,0 +1,99 @@ +name: i386 Linux CI + +on: + pull_request: + branches: + - '*' + workflow_dispatch: + + +jobs: + build: + strategy: + fail-fast: false + max-parallel: 20 + matrix: + branch: [devel] + target: + - os: linux + cpu: i386 + nim_branch: devel + include: + - target: + os: linux + builder: ubuntu-24.04 + + name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}-nim-${{ matrix.target.nim_branch }} (${{ matrix.branch }})' + runs-on: ${{ matrix.builder }} + env: + NIM_DIR: nim-${{ matrix.target.nim_branch }}-${{ matrix.target.cpu }} + NIM_BRANCH: ${{ matrix.target.nim_branch }} + NIM_ARCH: ${{ matrix.target.cpu }} + steps: + - name: set `core.autocrlf` to false + run: | + git config --global core.autocrlf false + git config --global init.defaultBranch master + + - name: Checkout + uses: actions/checkout@v6 + with: + submodules: false + + - name: Install dependencies (Linux i386) + if: runner.os == 'Linux' && matrix.target.cpu == 'i386' + working-directory: ${{ github.workspace }} + run: | + sudo dpkg --add-architecture i386 + sudo apt-get update -qq + sudo DEBIAN_FRONTEND='noninteractive' apt-get install \ + --no-install-recommends -yq gcc-multilib g++-multilib \ + libssl-dev:i386 + + mkdir -p external/bin + cat << EOF > external/bin/gcc + #!/bin/bash + + exec $(which gcc) -m32 "\$@" + EOF + + cat << EOF > external/bin/g++ + #!/bin/bash + + exec $(which g++) -m32 "\$@" + EOF + + chmod 755 external/bin/gcc external/bin/g++ + + echo "$PWD/external/bin" >> "${GITHUB_PATH}" + + - name: Add repo bin to PATH + run: echo "${GITHUB_WORKSPACE}/bin" >> ${GITHUB_PATH} + + - name: Setup Nim + uses: alaviss/setup-nim@0.1.1 + with: + path: 'nim' + version: ${{ matrix.target.nim_branch }} + architecture: ${{ matrix.target.cpu }} + + # - name: Build koch using existing nim + # run: | + # nim c koch.nim + + # - name: Boot the compiler from the checked-out commit + # shell: bash + # run: | + # ./koch boot -d:release + + # - name: Show nim version and system info + # run: | + # bin/nim -v || true + # uname -a || true + + - name: Run talign test (i386) + shell: bash + run: | + set -euo pipefail + export PATH="${GITHUB_WORKSPACE}/bin:$PATH" + nim c -r --lib:lib --mm:refc -d:useGcAssert -d:useSysAssert tests/align/talign.nim \ No newline at end of file diff --git a/.github/workflows/ci_packages.yml b/.github/workflows/ci_packages.yml index 6cef86c28a3f9..2fbd9ddaeb0fb 100644 --- a/.github/workflows/ci_packages.yml +++ b/.github/workflows/ci_packages.yml @@ -1,80 +1,80 @@ -name: Packages CI -on: - pull_request: - push: - branches: - - 'devel' - - 'version-2-2' - - 'version-2-0' - - 'version-1-6' - - 'version-1-2' +# name: Packages CI +# on: +# pull_request: +# push: +# branches: +# - 'devel' +# - 'version-2-2' +# - 'version-2-0' +# - 'version-1-6' +# - 'version-1-2' -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true +# concurrency: +# group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} +# cancel-in-progress: true -jobs: - build: - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, macos-14] - batch: ["allowed_failures", "0_3", "1_3", "2_3"] # list of `index_num` - include: - - os: ubuntu-latest - cpu: amd64 - - os: macos-14 - cpu: arm64 - name: '${{ matrix.os }} (batch: ${{ matrix.batch }})' - runs-on: ${{ matrix.os }} - timeout-minutes: 60 # refs bug #18178 - env: - NIM_TEST_PACKAGES: "1" - NIM_TESTAMENT_BATCH: ${{ matrix.batch }} - steps: - - name: 'Checkout' - uses: actions/checkout@v6 - with: - fetch-depth: 2 +# jobs: +# build: +# strategy: +# fail-fast: false +# matrix: +# os: [ubuntu-latest, macos-14] +# batch: ["allowed_failures", "0_3", "1_3", "2_3"] # list of `index_num` +# include: +# - os: ubuntu-latest +# cpu: amd64 +# - os: macos-14 +# cpu: arm64 +# name: '${{ matrix.os }} (batch: ${{ matrix.batch }})' +# runs-on: ${{ matrix.os }} +# timeout-minutes: 60 # refs bug #18178 +# env: +# NIM_TEST_PACKAGES: "1" +# NIM_TESTAMENT_BATCH: ${{ matrix.batch }} +# steps: +# - name: 'Checkout' +# uses: actions/checkout@v6 +# with: +# fetch-depth: 2 - - name: 'Install node.js' - uses: actions/setup-node@v6 - with: - node-version: 24 +# - name: 'Install node.js' +# uses: actions/setup-node@v6 +# with: +# node-version: 24 - - name: 'Install dependencies (Linux amd64)' - if: runner.os == 'Linux' && matrix.cpu == 'amd64' - run: | - sudo apt-get update -qq - DEBIAN_FRONTEND='noninteractive' \ - sudo apt-get install --no-install-recommends -yq \ - libcurl4-openssl-dev libgc-dev libsdl1.2-dev libsfml-dev \ - valgrind libc6-dbg libblas-dev liblapack-dev libpcre3 xorg-dev - - name: 'Install dependencies (macOS)' - if: runner.os == 'macOS' - run: brew install boehmgc make sfml gtk+3 - # XXX can't find boehm and gtk on macos 13 - - name: 'Install dependencies (Windows)' - if: runner.os == 'Windows' - shell: bash - run: | - set -e - . ci/funs.sh - nimInternalInstallDepsWindows - echo_run echo "${{ github.workspace }}/dist/mingw64/bin" >> "${GITHUB_PATH}" +# - name: 'Install dependencies (Linux amd64)' +# if: runner.os == 'Linux' && matrix.cpu == 'amd64' +# run: | +# sudo apt-get update -qq +# DEBIAN_FRONTEND='noninteractive' \ +# sudo apt-get install --no-install-recommends -yq \ +# libcurl4-openssl-dev libgc-dev libsdl1.2-dev libsfml-dev \ +# valgrind libc6-dbg libblas-dev liblapack-dev libpcre3 xorg-dev +# - name: 'Install dependencies (macOS)' +# if: runner.os == 'macOS' +# run: brew install boehmgc make sfml gtk+3 +# # XXX can't find boehm and gtk on macos 13 +# - name: 'Install dependencies (Windows)' +# if: runner.os == 'Windows' +# shell: bash +# run: | +# set -e +# . ci/funs.sh +# nimInternalInstallDepsWindows +# echo_run echo "${{ github.workspace }}/dist/mingw64/bin" >> "${GITHUB_PATH}" - - name: 'Add build binaries to PATH' - shell: bash - run: echo "${{ github.workspace }}/bin" >> "${GITHUB_PATH}" +# - name: 'Add build binaries to PATH' +# shell: bash +# run: echo "${{ github.workspace }}/bin" >> "${GITHUB_PATH}" - - name: 'System information' - shell: bash - run: . ci/funs.sh && nimCiSystemInfo +# - name: 'System information' +# shell: bash +# run: . ci/funs.sh && nimCiSystemInfo - - name: 'Build csourcesAny' - shell: bash - run: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc ucpu='${{ matrix.cpu }}' +# - name: 'Build csourcesAny' +# shell: bash +# run: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc ucpu='${{ matrix.cpu }}' - - name: 'koch, Run CI' - shell: bash - run: . ci/funs.sh && nimInternalBuildKochAndRunCI +# - name: 'koch, Run CI' +# shell: bash +# run: . ci/funs.sh && nimInternalBuildKochAndRunCI diff --git a/.github/workflows/ci_publish.yml b/.github/workflows/ci_publish.yml index 44cfaf8213150..67b2eea99f195 100644 --- a/.github/workflows/ci_publish.yml +++ b/.github/workflows/ci_publish.yml @@ -1,79 +1,79 @@ -name: Tracking orc-booting compiler memory usage +# name: Tracking orc-booting compiler memory usage -on: - pull_request_target: - types: [closed] +# on: +# pull_request_target: +# types: [closed] -jobs: - build: - if: github.event.pull_request.merged == true - strategy: - fail-fast: false - matrix: - os: [ubuntu-22.04] - cpu: [amd64] - name: '${{ matrix.os }}' - runs-on: ${{ matrix.os }} - steps: - - name: 'Checkout' - uses: actions/checkout@v6 - with: - fetch-depth: 2 +# jobs: +# build: +# if: github.event.pull_request.merged == true +# strategy: +# fail-fast: false +# matrix: +# os: [ubuntu-22.04] +# cpu: [amd64] +# name: '${{ matrix.os }}' +# runs-on: ${{ matrix.os }} +# steps: +# - name: 'Checkout' +# uses: actions/checkout@v6 +# with: +# fetch-depth: 2 - - name: 'Install node.js' - uses: actions/setup-node@v6 - with: - node-version: 24 +# - name: 'Install node.js' +# uses: actions/setup-node@v6 +# with: +# node-version: 24 - - name: 'Install dependencies (Linux amd64)' - if: runner.os == 'Linux' && matrix.cpu == 'amd64' - run: | - sudo apt-fast update -qq - DEBIAN_FRONTEND='noninteractive' \ - sudo apt-fast install --no-install-recommends -yq \ - libcurl4-openssl-dev libgc-dev libsdl1.2-dev libsfml-dev \ - valgrind libc6-dbg libblas-dev xorg-dev +# - name: 'Install dependencies (Linux amd64)' +# if: runner.os == 'Linux' && matrix.cpu == 'amd64' +# run: | +# sudo apt-fast update -qq +# DEBIAN_FRONTEND='noninteractive' \ +# sudo apt-fast install --no-install-recommends -yq \ +# libcurl4-openssl-dev libgc-dev libsdl1.2-dev libsfml-dev \ +# valgrind libc6-dbg libblas-dev xorg-dev - - name: 'Add build binaries to PATH' - shell: bash - run: echo "${{ github.workspace }}/bin" >> "${GITHUB_PATH}" +# - name: 'Add build binaries to PATH' +# shell: bash +# run: echo "${{ github.workspace }}/bin" >> "${GITHUB_PATH}" - - name: 'System information' - shell: bash - run: . ci/funs.sh && nimCiSystemInfo +# - name: 'System information' +# shell: bash +# run: . ci/funs.sh && nimCiSystemInfo - - name: 'Build csourcesAny' - shell: bash - run: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc ucpu='${{ matrix.cpu }}' +# - name: 'Build csourcesAny' +# shell: bash +# run: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc ucpu='${{ matrix.cpu }}' - - name: 'Build koch' - shell: bash - run: nim c koch +# - name: 'Build koch' +# shell: bash +# run: nim c koch - - name: 'Build Nim' - shell: bash - run: ./koch boot -d:release -d:nimStrictMode --lib:lib +# - name: 'Build Nim' +# shell: bash +# run: ./koch boot -d:release -d:nimStrictMode --lib:lib - - name: 'Action' - shell: bash - run: nim c -r -d:release ci/action.nim +# - name: 'Action' +# shell: bash +# run: nim c -r -d:release ci/action.nim - - name: 'Comment' - uses: actions/github-script@v8 - with: - script: | - const fs = require('fs'); +# - name: 'Comment' +# uses: actions/github-script@v8 +# with: +# script: | +# const fs = require('fs'); - try { - const data = fs.readFileSync('ci/nimcache/results.txt', 'utf8'); - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: data - }) - } catch (err) { - console.error(err); - } +# try { +# const data = fs.readFileSync('ci/nimcache/results.txt', 'utf8'); +# github.rest.issues.createComment({ +# issue_number: context.issue.number, +# owner: context.repo.owner, +# repo: context.repo.repo, +# body: data +# }) +# } catch (err) { +# console.error(err); +# } diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index b918b21050a7a..586f2acfde656 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -1,25 +1,25 @@ -# https://github.com/actions/stale#usage -name: Stale pull requests +# # https://github.com/actions/stale#usage +# name: Stale pull requests -on: - schedule: - - cron: '0 0 * * *' # Midnight. +# on: +# schedule: +# - cron: '0 0 * * *' # Midnight. -jobs: - stale: - runs-on: ubuntu-latest - steps: - - uses: actions/stale@v10 - with: - days-before-pr-stale: 365 - days-before-pr-close: 30 - days-before-issue-stale: -1 - days-before-issue-close: -1 - exempt-pr-labels: "ARC,bounty,Codegen,Crash,Generics,High Priority,Macros,Next release,Showstopper,Static[T]" - exempt-issue-labels: "Showstopper,Severe,bounty,Compiler Crash,Medium Priority" - stale-pr-message: > - This pull request is stale because it has been open for 1 year with no activity. - Contribute more commits on the pull request and rebase it on the latest devel, - or it will be closed in 30 days. Thank you for your contributions. - close-pr-message: > - This pull request has been marked as stale and closed due to inactivity after 395 days. +# jobs: +# stale: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/stale@v10 +# with: +# days-before-pr-stale: 365 +# days-before-pr-close: 30 +# days-before-issue-stale: -1 +# days-before-issue-close: -1 +# exempt-pr-labels: "ARC,bounty,Codegen,Crash,Generics,High Priority,Macros,Next release,Showstopper,Static[T]" +# exempt-issue-labels: "Showstopper,Severe,bounty,Compiler Crash,Medium Priority" +# stale-pr-message: > +# This pull request is stale because it has been open for 1 year with no activity. +# Contribute more commits on the pull request and rebase it on the latest devel, +# or it will be closed in 30 days. Thank you for your contributions. +# close-pr-message: > +# This pull request has been marked as stale and closed due to inactivity after 395 days. diff --git a/lib/system/bitmasks.nim b/lib/system/bitmasks.nim index 0663247c28588..76be575a63d9d 100644 --- a/lib/system/bitmasks.nim +++ b/lib/system/bitmasks.nim @@ -24,6 +24,9 @@ const elif defined(useMalloc): when defined(amd64): 16 else: 8 + elif defined(gcRefc): + when defined(i386): 8 + else: 16 else: 16 BitsPerPage = PageSize div MemAlign diff --git a/lib/system/gc.nim b/lib/system/gc.nim index 861e0704f535c..8cc9c63878bd4 100644 --- a/lib/system/gc.nim +++ b/lib/system/gc.nim @@ -460,7 +460,7 @@ proc rawNewObj(typ: PNimType, size: int, gch: var GcHeap): pointer = collectCT(gch) # Use alignment from typ.base if available, otherwise use MemAlign let alignment = if typ.kind == tyRef and typ.base != nil and - typ.base.align >= MemAlign: typ.base.align else: 0 + typ.base.align > 16: typ.base.align else: 0 var res = cast[PCell](rawAlloc(gch.region, size + sizeof(Cell), alignment)) #gcAssert typ.kind in {tyString, tySequence} or size >= typ.base.size, "size too small" # Check that the user data (after the Cell header) is properly aligned @@ -517,7 +517,7 @@ proc newObjRC1(typ: PNimType, size: int): pointer {.compilerRtl, noinline, raise # Use alignment from typ.base if available, otherwise use MemAlign let alignment = if typ.kind == tyRef and typ.base != nil and - typ.base.align >= MemAlign: typ.base.align else: 0 + typ.base.align > 16: typ.base.align else: 0 var res = cast[PCell](rawAlloc(gch.region, size + sizeof(Cell), alignment)) sysAssert(allocInv(gch.region), "newObjRC1 after rawAlloc") # Check that the user data (after the Cell header) is properly aligned From 9a3c243515ca17c97102919b90e1010522cbe7e9 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Mon, 2 Mar 2026 19:13:10 +0800 Subject: [PATCH 02/17] fixes --- azure-pipelines.yml | 344 ++++++++++++++++++++++---------------------- 1 file changed, 172 insertions(+), 172 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 96e747a730fc0..3b5f1c9540f10 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,172 +1,172 @@ -trigger: - branches: - include: - - 'devel' - - 'version-*' -pr: - branches: - include: - - '*' - -variables: -- name: skipci - value: false - -jobs: -- job: packages - - timeoutInMinutes: 90 # default `60` led to lots of cancelled jobs; use 0 for unlimited (may be undesirable) - - strategy: - matrix: - Linux_amd64: - vmImage: 'ubuntu-24.04' - CPU: amd64 - # regularly breaks, refs bug #17325 -# Linux_i386: -# # on 'ubuntu-16.04' (not supported anymore anyways) it errored with: -# # g++-multilib : Depends: gcc-multilib (>= 4:5.3.1-1ubuntu1) but it is not going to be installed -# vmImage: 'ubuntu-18.04' -# CPU: i386 - OSX_arm64: - vmImage: 'macos-15' - CPU: arm64 - OSX_arm64_cpp: - vmImage: 'macos-15' - CPU: arm64 - NIM_COMPILE_TO_CPP: true - Windows_amd64_batch0_3: - vmImage: 'windows-2025' - CPU: amd64 - # see also: `NIM_TEST_PACKAGES` - NIM_TESTAMENT_BATCH: "0_3" - Windows_amd64_batch1_3: - vmImage: 'windows-2025' - CPU: amd64 - NIM_TESTAMENT_BATCH: "1_3" - Windows_amd64_batch2_3: - vmImage: 'windows-2025' - CPU: amd64 - NIM_TESTAMENT_BATCH: "2_3" - - pool: - vmImage: $(vmImage) - - workspace: - clean: all - - steps: - - bash: git config --global core.autocrlf false - displayName: 'Disable auto conversion to CRLF by git (Windows-only)' - condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT')) - - - checkout: self - fetchDepth: 2 # see D20210329T004830 - - - bash: | - set -e - . ci/funs.sh - if nimIsCiSkip; then - echo '##vso[task.setvariable variable=skipci]true' - fi - displayName: 'Check whether to skip CI' - - - task: NodeTool@0 - inputs: - versionSpec: '20.x' - displayName: 'Install node.js 20.x' - condition: and(succeeded(), eq(variables['skipci'], 'false')) - - - bash: | - set -e - . ci/funs.sh - echo_run sudo add-apt-repository universe - echo_run sudo apt-get update -qq - DEBIAN_FRONTEND='noninteractive' \ - echo_run sudo apt-get install --no-install-recommends -yq \ - gcc-14 g++-14 libpcre3 liblapack-dev libpcre3 liblapack-dev libcurl4-openssl-dev libgc-dev libsdl1.2-dev libsfml-dev valgrind libc6-dbg - echo_run sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 60 --slave /usr/bin/g++ g++ /usr/bin/g++-14 - displayName: 'Install dependencies (amd64 Linux)' - condition: and(succeeded(), eq(variables['skipci'], 'false'), eq(variables['Agent.OS'], 'Linux'), eq(variables['CPU'], 'amd64')) - - - bash: | - set -e - . ci/funs.sh - echo_run sudo dpkg --add-architecture i386 - # Downgrade llvm: - # - llvm has to be downgraded to have 32bit version installed for sfml. - - cat << EOF | sudo tee /etc/apt/preferences.d/pin-to-rel - Package: libllvm6.0 - Pin: origin "azure.archive.ubuntu.com" - Pin-Priority: 1001 - EOF - - # echo_run sudo apt-get update -qq - echo_run sudo apt-get update -qq || echo "failed, see bug #17343" - # `:i386` (e.g. in `libffi-dev:i386`) is needed otherwise you may get: - # `could not load: libffi.so` during dynamic loading. - DEBIAN_FRONTEND='noninteractive' \ - echo_run sudo apt-get install --no-install-recommends --allow-downgrades -yq \ - g++-multilib gcc-multilib libcurl4-openssl-dev:i386 libgc-dev:i386 \ - libsdl1.2-dev:i386 libsfml-dev:i386 libglib2.0-dev:i386 libffi-dev:i386 - - - cat << EOF > bin/gcc - #!/bin/bash - - exec $(which gcc) -m32 "\$@" - EOF - - cat << EOF > bin/g++ - #!/bin/bash - - exec $(which g++) -m32 "\$@" - EOF - - echo_run chmod 755 bin/gcc - echo_run chmod 755 bin/g++ - - displayName: 'Install dependencies (i386 Linux)' - condition: and(succeeded(), eq(variables['skipci'], 'false'), eq(variables['Agent.OS'], 'Linux'), eq(variables['CPU'], 'i386')) - - - bash: brew install boehmgc make sfml - displayName: 'Install dependencies (OSX)' - condition: and(succeeded(), eq(variables['skipci'], 'false'), eq(variables['Agent.OS'], 'Darwin')) - # XXX can't find boehm on macos 13 - - - bash: | - set -e - . ci/funs.sh - nimInternalInstallDepsWindows - echo_run echo '##vso[task.prependpath]$(System.DefaultWorkingDirectory)/dist/mingw64/bin' - - displayName: 'Install dependencies (Windows)' - condition: and(succeeded(), eq(variables['skipci'], 'false'), eq(variables['Agent.OS'], 'Windows_NT')) - - - bash: echo '##vso[task.prependpath]$(System.DefaultWorkingDirectory)/bin' - condition: and(succeeded(), eq(variables['skipci'], 'false')) - displayName: 'Add build binaries to PATH' - - - bash: . ci/funs.sh && nimCiSystemInfo - condition: and(succeeded(), eq(variables['skipci'], 'false')) - displayName: 'System information' - - - bash: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc ucpu=$(CPU) - condition: and(succeeded(), eq(variables['skipci'], 'false')) - displayName: 'Build csourcesAny' - - # this could be revived if performance justifies it (needs a few updates) - # - task: Cache@2 - # inputs: - # key: 'csourcesAny | "$(Agent.OS)" | $(CPU) | $(csources_version)' - # path: $(nim_csources) - # condition: and(succeeded(), eq(variables['skipci'], 'false')) - # displayName: 'Restore built csourcesAny' - - - bash: . ci/funs.sh && nimInternalBuildKochAndRunCI - # would could also show on failure: echo '##vso[task.complete result=Failed]' - condition: and(succeeded(), eq(variables['skipci'], 'false')) - displayName: 'koch, Run CI' - env: - SYSTEM_ACCESSTOKEN: $(System.AccessToken) +# trigger: +# branches: +# include: +# - 'devel' +# - 'version-*' +# pr: +# branches: +# include: +# - '*' + +# variables: +# - name: skipci +# value: false + +# jobs: +# - job: packages + +# timeoutInMinutes: 90 # default `60` led to lots of cancelled jobs; use 0 for unlimited (may be undesirable) + +# strategy: +# matrix: +# Linux_amd64: +# vmImage: 'ubuntu-24.04' +# CPU: amd64 +# # regularly breaks, refs bug #17325 +# # Linux_i386: +# # # on 'ubuntu-16.04' (not supported anymore anyways) it errored with: +# # # g++-multilib : Depends: gcc-multilib (>= 4:5.3.1-1ubuntu1) but it is not going to be installed +# # vmImage: 'ubuntu-18.04' +# # CPU: i386 +# OSX_arm64: +# vmImage: 'macos-15' +# CPU: arm64 +# OSX_arm64_cpp: +# vmImage: 'macos-15' +# CPU: arm64 +# NIM_COMPILE_TO_CPP: true +# Windows_amd64_batch0_3: +# vmImage: 'windows-2025' +# CPU: amd64 +# # see also: `NIM_TEST_PACKAGES` +# NIM_TESTAMENT_BATCH: "0_3" +# Windows_amd64_batch1_3: +# vmImage: 'windows-2025' +# CPU: amd64 +# NIM_TESTAMENT_BATCH: "1_3" +# Windows_amd64_batch2_3: +# vmImage: 'windows-2025' +# CPU: amd64 +# NIM_TESTAMENT_BATCH: "2_3" + +# pool: +# vmImage: $(vmImage) + +# workspace: +# clean: all + +# steps: +# - bash: git config --global core.autocrlf false +# displayName: 'Disable auto conversion to CRLF by git (Windows-only)' +# condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT')) + +# - checkout: self +# fetchDepth: 2 # see D20210329T004830 + +# - bash: | +# set -e +# . ci/funs.sh +# if nimIsCiSkip; then +# echo '##vso[task.setvariable variable=skipci]true' +# fi +# displayName: 'Check whether to skip CI' + +# - task: NodeTool@0 +# inputs: +# versionSpec: '20.x' +# displayName: 'Install node.js 20.x' +# condition: and(succeeded(), eq(variables['skipci'], 'false')) + +# - bash: | +# set -e +# . ci/funs.sh +# echo_run sudo add-apt-repository universe +# echo_run sudo apt-get update -qq +# DEBIAN_FRONTEND='noninteractive' \ +# echo_run sudo apt-get install --no-install-recommends -yq \ +# gcc-14 g++-14 libpcre3 liblapack-dev libpcre3 liblapack-dev libcurl4-openssl-dev libgc-dev libsdl1.2-dev libsfml-dev valgrind libc6-dbg +# echo_run sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 60 --slave /usr/bin/g++ g++ /usr/bin/g++-14 +# displayName: 'Install dependencies (amd64 Linux)' +# condition: and(succeeded(), eq(variables['skipci'], 'false'), eq(variables['Agent.OS'], 'Linux'), eq(variables['CPU'], 'amd64')) + +# - bash: | +# set -e +# . ci/funs.sh +# echo_run sudo dpkg --add-architecture i386 +# # Downgrade llvm: +# # - llvm has to be downgraded to have 32bit version installed for sfml. + +# cat << EOF | sudo tee /etc/apt/preferences.d/pin-to-rel +# Package: libllvm6.0 +# Pin: origin "azure.archive.ubuntu.com" +# Pin-Priority: 1001 +# EOF + +# # echo_run sudo apt-get update -qq +# echo_run sudo apt-get update -qq || echo "failed, see bug #17343" +# # `:i386` (e.g. in `libffi-dev:i386`) is needed otherwise you may get: +# # `could not load: libffi.so` during dynamic loading. +# DEBIAN_FRONTEND='noninteractive' \ +# echo_run sudo apt-get install --no-install-recommends --allow-downgrades -yq \ +# g++-multilib gcc-multilib libcurl4-openssl-dev:i386 libgc-dev:i386 \ +# libsdl1.2-dev:i386 libsfml-dev:i386 libglib2.0-dev:i386 libffi-dev:i386 + + +# cat << EOF > bin/gcc +# #!/bin/bash + +# exec $(which gcc) -m32 "\$@" +# EOF + +# cat << EOF > bin/g++ +# #!/bin/bash + +# exec $(which g++) -m32 "\$@" +# EOF + +# echo_run chmod 755 bin/gcc +# echo_run chmod 755 bin/g++ + +# displayName: 'Install dependencies (i386 Linux)' +# condition: and(succeeded(), eq(variables['skipci'], 'false'), eq(variables['Agent.OS'], 'Linux'), eq(variables['CPU'], 'i386')) + +# - bash: brew install boehmgc make sfml +# displayName: 'Install dependencies (OSX)' +# condition: and(succeeded(), eq(variables['skipci'], 'false'), eq(variables['Agent.OS'], 'Darwin')) +# # XXX can't find boehm on macos 13 + +# - bash: | +# set -e +# . ci/funs.sh +# nimInternalInstallDepsWindows +# echo_run echo '##vso[task.prependpath]$(System.DefaultWorkingDirectory)/dist/mingw64/bin' + +# displayName: 'Install dependencies (Windows)' +# condition: and(succeeded(), eq(variables['skipci'], 'false'), eq(variables['Agent.OS'], 'Windows_NT')) + +# - bash: echo '##vso[task.prependpath]$(System.DefaultWorkingDirectory)/bin' +# condition: and(succeeded(), eq(variables['skipci'], 'false')) +# displayName: 'Add build binaries to PATH' + +# - bash: . ci/funs.sh && nimCiSystemInfo +# condition: and(succeeded(), eq(variables['skipci'], 'false')) +# displayName: 'System information' + +# - bash: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc ucpu=$(CPU) +# condition: and(succeeded(), eq(variables['skipci'], 'false')) +# displayName: 'Build csourcesAny' + +# # this could be revived if performance justifies it (needs a few updates) +# # - task: Cache@2 +# # inputs: +# # key: 'csourcesAny | "$(Agent.OS)" | $(CPU) | $(csources_version)' +# # path: $(nim_csources) +# # condition: and(succeeded(), eq(variables['skipci'], 'false')) +# # displayName: 'Restore built csourcesAny' + +# - bash: . ci/funs.sh && nimInternalBuildKochAndRunCI +# # would could also show on failure: echo '##vso[task.complete result=Failed]' +# condition: and(succeeded(), eq(variables['skipci'], 'false')) +# displayName: 'koch, Run CI' +# env: +# SYSTEM_ACCESSTOKEN: $(System.AccessToken) From 24da3f76887775eab35b514c0666bf4bca5326bf Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Mon, 2 Mar 2026 19:30:13 +0800 Subject: [PATCH 03/17] oops --- lib/system/gc.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/system/gc.nim b/lib/system/gc.nim index 8cc9c63878bd4..9039de7d6be64 100644 --- a/lib/system/gc.nim +++ b/lib/system/gc.nim @@ -460,7 +460,7 @@ proc rawNewObj(typ: PNimType, size: int, gch: var GcHeap): pointer = collectCT(gch) # Use alignment from typ.base if available, otherwise use MemAlign let alignment = if typ.kind == tyRef and typ.base != nil and - typ.base.align > 16: typ.base.align else: 0 + typ.base.align > MemAlign: typ.base.align else: 0 var res = cast[PCell](rawAlloc(gch.region, size + sizeof(Cell), alignment)) #gcAssert typ.kind in {tyString, tySequence} or size >= typ.base.size, "size too small" # Check that the user data (after the Cell header) is properly aligned @@ -517,7 +517,7 @@ proc newObjRC1(typ: PNimType, size: int): pointer {.compilerRtl, noinline, raise # Use alignment from typ.base if available, otherwise use MemAlign let alignment = if typ.kind == tyRef and typ.base != nil and - typ.base.align > 16: typ.base.align else: 0 + typ.base.align > MemAlign: typ.base.align else: 0 var res = cast[PCell](rawAlloc(gch.region, size + sizeof(Cell), alignment)) sysAssert(allocInv(gch.region), "newObjRC1 after rawAlloc") # Check that the user data (after the Cell header) is properly aligned From e5d06caa875b5ea89d4de2adee0815d477fba198 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Mon, 2 Mar 2026 19:39:02 +0800 Subject: [PATCH 04/17] check --- lib/system/gc.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/system/gc.nim b/lib/system/gc.nim index 9039de7d6be64..8cc9c63878bd4 100644 --- a/lib/system/gc.nim +++ b/lib/system/gc.nim @@ -460,7 +460,7 @@ proc rawNewObj(typ: PNimType, size: int, gch: var GcHeap): pointer = collectCT(gch) # Use alignment from typ.base if available, otherwise use MemAlign let alignment = if typ.kind == tyRef and typ.base != nil and - typ.base.align > MemAlign: typ.base.align else: 0 + typ.base.align > 16: typ.base.align else: 0 var res = cast[PCell](rawAlloc(gch.region, size + sizeof(Cell), alignment)) #gcAssert typ.kind in {tyString, tySequence} or size >= typ.base.size, "size too small" # Check that the user data (after the Cell header) is properly aligned @@ -517,7 +517,7 @@ proc newObjRC1(typ: PNimType, size: int): pointer {.compilerRtl, noinline, raise # Use alignment from typ.base if available, otherwise use MemAlign let alignment = if typ.kind == tyRef and typ.base != nil and - typ.base.align > MemAlign: typ.base.align else: 0 + typ.base.align > 16: typ.base.align else: 0 var res = cast[PCell](rawAlloc(gch.region, size + sizeof(Cell), alignment)) sysAssert(allocInv(gch.region), "newObjRC1 after rawAlloc") # Check that the user data (after the Cell header) is properly aligned From dc8b4130553be06174bd6dba4b3a252d955ba781 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Mon, 2 Mar 2026 21:36:57 +0800 Subject: [PATCH 05/17] padding `Cell` --- lib/system/bitmasks.nim | 3 --- lib/system/mmdisp.nim | 5 ++++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/system/bitmasks.nim b/lib/system/bitmasks.nim index 76be575a63d9d..0663247c28588 100644 --- a/lib/system/bitmasks.nim +++ b/lib/system/bitmasks.nim @@ -24,9 +24,6 @@ const elif defined(useMalloc): when defined(amd64): 16 else: 8 - elif defined(gcRefc): - when defined(i386): 8 - else: 16 else: 16 BitsPerPage = PageSize div MemAlign diff --git a/lib/system/mmdisp.nim b/lib/system/mmdisp.nim index ce935ff8afd4e..0f3a154b8e8c7 100644 --- a/lib/system/mmdisp.nim +++ b/lib/system/mmdisp.nim @@ -45,6 +45,9 @@ when not defined(nimV2): Cell {.pure.} = object refcount: RefCount # the refcount and some flags typ: PNimType + when sizeof(int) == 4: # 32-bit only + headerAlignPad: array[8, byte] # so addr(data) ≡ 8 (mod 16) + when trackAllocationSource: filename: cstring line: int @@ -93,7 +96,7 @@ else: when not usesDestructors: include "system/cellsets" when not leakDetector and not useCellIds and not defined(nimV2): - sysAssert(sizeof(Cell) == sizeof(FreeCell), "sizeof FreeCell") + sysAssert(sizeof(FreeCell) <= sizeof(Cell), "sizeof FreeCell") when defined(gcRegions): # XXX due to bootstrapping reasons, we cannot use compileOption("gc", "stack") here include "system/gc_regions" From 56fce26f61d1db48c0dc9497dd78ea2b8966916f Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Tue, 3 Mar 2026 16:26:18 +0800 Subject: [PATCH 06/17] refactor memory management structures for consistency across modules --- lib/system/alloc.nim | 2 ++ lib/system/cellsets.nim | 16 ++++++++++++++++ lib/system/mmdisp.nim | 20 +------------------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/system/alloc.nim b/lib/system/alloc.nim index 1c2706120e460..77025265f15a4 100644 --- a/lib/system/alloc.nim +++ b/lib/system/alloc.nim @@ -104,6 +104,8 @@ type zeroField: int # 0 means cell is not used (overlaid with typ field) # 1 means cell is manually managed pointer # otherwise a PNimType is stored in there + when sizeof(int) == 4: # 32-bit only + headerAlignPad: array[8, byte] # so addr(data) ≡ 8 (mod 16) else: alignment: int diff --git a/lib/system/cellsets.nim b/lib/system/cellsets.nim index 80f03670196d4..07bf440753c04 100644 --- a/lib/system/cellsets.nim +++ b/lib/system/cellsets.nim @@ -48,7 +48,23 @@ when defined(gcOrc) or defined(gcArc) or defined(gcAtomicArc) or defined(gcYrc): when not declaredInScope(PageShift): include bitmasks +else: + type + RefCount = int + + Cell {.pure.} = object + refcount: RefCount # the refcount and some flags + typ: PNimType + + when trackAllocationSource: + filename: cstring + line: int + elif useCellIds: + id: int + elif defined(cpu32): + headerAlignPad: array[8, byte] # so addr(data) ≡ 8 (mod 16) + PCell = ptr Cell type PPageDesc = ptr PageDesc diff --git a/lib/system/mmdisp.nim b/lib/system/mmdisp.nim index 0f3a154b8e8c7..3caa41d03cabb 100644 --- a/lib/system/mmdisp.nim +++ b/lib/system/mmdisp.nim @@ -38,24 +38,6 @@ type PByte = ptr ByteArray PString = ptr string -when not defined(nimV2): - type - RefCount = int - - Cell {.pure.} = object - refcount: RefCount # the refcount and some flags - typ: PNimType - when sizeof(int) == 4: # 32-bit only - headerAlignPad: array[8, byte] # so addr(data) ≡ 8 (mod 16) - - when trackAllocationSource: - filename: cstring - line: int - when useCellIds: - id: int - - PCell = ptr Cell - when declared(IntsPerTrunk): discard else: @@ -96,7 +78,7 @@ else: when not usesDestructors: include "system/cellsets" when not leakDetector and not useCellIds and not defined(nimV2): - sysAssert(sizeof(FreeCell) <= sizeof(Cell), "sizeof FreeCell") + sysAssert(sizeof(FreeCell) == sizeof(Cell), "sizeof FreeCell") when defined(gcRegions): # XXX due to bootstrapping reasons, we cannot use compileOption("gc", "stack") here include "system/gc_regions" From d2b7b249eb5766bd54fefb5a13cc752c0f529b17 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Tue, 3 Mar 2026 16:31:36 +0800 Subject: [PATCH 07/17] oops --- lib/system/alloc.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/system/alloc.nim b/lib/system/alloc.nim index 77025265f15a4..c40f808b88ee4 100644 --- a/lib/system/alloc.nim +++ b/lib/system/alloc.nim @@ -856,7 +856,7 @@ proc bigChunkAlignOffset(alignment: int): int {.inline.} = if alignment == 0: result = 0 else: - result = align(sizeof(BigChunk) + sizeof(Cell), alignment) - sizeof(BigChunk) - sizeof(Cell) + result = align(sizeof(BigChunk) + sizeof(FreeCell), alignment) - sizeof(BigChunk) - sizeof(FreeCell) proc rawAlloc(a: var MemRegion, requestedSize: int, alignment: int = 0): pointer = when defined(nimTypeNames): From d965b96e15ce9ab1551d08d39ff3a81199f40b5c Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Tue, 3 Mar 2026 16:40:49 +0800 Subject: [PATCH 08/17] fixes --- lib/system/mmdisp.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/system/mmdisp.nim b/lib/system/mmdisp.nim index 3caa41d03cabb..7fd61e0dc3b43 100644 --- a/lib/system/mmdisp.nim +++ b/lib/system/mmdisp.nim @@ -78,7 +78,7 @@ else: when not usesDestructors: include "system/cellsets" when not leakDetector and not useCellIds and not defined(nimV2): - sysAssert(sizeof(FreeCell) == sizeof(Cell), "sizeof FreeCell") + sysAssert(sizeof(Cell) == sizeof(FreeCell), "sizeof FreeCell") when defined(gcRegions): # XXX due to bootstrapping reasons, we cannot use compileOption("gc", "stack") here include "system/gc_regions" From 3e77cedb3b633db051f9bc2aa5021d7f8d09f67f Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Tue, 3 Mar 2026 16:57:56 +0800 Subject: [PATCH 09/17] progress --- tests/align/talign.nim | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/align/talign.nim b/tests/align/talign.nim index 6397e312142d3..9e68c2766f1dd 100644 --- a/tests/align/talign.nim +++ b/tests/align/talign.nim @@ -169,3 +169,10 @@ for q in 0..100: topArr[i].m.di.b = q doAssert(cast[uint](addr topArr[i].m.di) mod uint(alignof(DeepInner)) == 0) + +block: + type U = object + d {.align: 16.}: int8 + var e: seq[ref U] + for i in 0 ..< 10000: e.add(new U) + doAssert getTotalMem() <= 1052672 * 2 From 0aa5a1d9b02266cc9d62ea6dc4c8979d0697f1dd Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Tue, 3 Mar 2026 17:01:19 +0800 Subject: [PATCH 10/17] GC_fullCollect --- tests/align/talign.nim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/align/talign.nim b/tests/align/talign.nim index 9e68c2766f1dd..3e62fcad74f6a 100644 --- a/tests/align/talign.nim +++ b/tests/align/talign.nim @@ -170,6 +170,8 @@ for q in 0..100: doAssert(cast[uint](addr topArr[i].m.di) mod uint(alignof(DeepInner)) == 0) +GC_fullCollect() + block: type U = object d {.align: 16.}: int8 From 12b1b45710ef5533c40a487d1c048d68a0c24c90 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Tue, 3 Mar 2026 17:02:46 +0800 Subject: [PATCH 11/17] tests --- .github/workflows/ci_i386_linux.yml | 3 ++- tests/align/talign.nim | 10 ---------- tests/align/talign2.nim | 6 ++++++ 3 files changed, 8 insertions(+), 11 deletions(-) create mode 100644 tests/align/talign2.nim diff --git a/.github/workflows/ci_i386_linux.yml b/.github/workflows/ci_i386_linux.yml index 572cf7ab7ce23..5caf1d8d4f0f1 100644 --- a/.github/workflows/ci_i386_linux.yml +++ b/.github/workflows/ci_i386_linux.yml @@ -96,4 +96,5 @@ jobs: run: | set -euo pipefail export PATH="${GITHUB_WORKSPACE}/bin:$PATH" - nim c -r --lib:lib --mm:refc -d:useGcAssert -d:useSysAssert tests/align/talign.nim \ No newline at end of file + nim c -r --lib:lib --mm:refc -d:useGcAssert -d:useSysAssert tests/align/talign.nim + nim c -r --lib:lib --mm:refc -d:useGcAssert -d:useSysAssert tests/align/talign2.nim \ No newline at end of file diff --git a/tests/align/talign.nim b/tests/align/talign.nim index 3e62fcad74f6a..e1cb1539b21c6 100644 --- a/tests/align/talign.nim +++ b/tests/align/talign.nim @@ -168,13 +168,3 @@ for q in 0..100: new topArr[i] topArr[i].m.di.b = q doAssert(cast[uint](addr topArr[i].m.di) mod uint(alignof(DeepInner)) == 0) - - -GC_fullCollect() - -block: - type U = object - d {.align: 16.}: int8 - var e: seq[ref U] - for i in 0 ..< 10000: e.add(new U) - doAssert getTotalMem() <= 1052672 * 2 diff --git a/tests/align/talign2.nim b/tests/align/talign2.nim new file mode 100644 index 0000000000000..2b581afc95665 --- /dev/null +++ b/tests/align/talign2.nim @@ -0,0 +1,6 @@ +block: + type U = object + d {.align: 16.}: int8 + var e: seq[ref U] + for i in 0 ..< 10000: e.add(new U) + doAssert getTotalMem() <= 1052672 * 2 From f43b923406c6dd96b05b55375ff20e6436e9db94 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Tue, 3 Mar 2026 17:11:01 +0800 Subject: [PATCH 12/17] progress --- .github/copilot-instructions.md | 22 -- .github/workflows/bisects.yml | 68 +++--- .github/workflows/ci_docs.yml | 202 ++++++++-------- .github/workflows/ci_i386_linux.yml | 100 -------- .github/workflows/ci_packages.yml | 144 ++++++------ .github/workflows/ci_publish.yml | 130 +++++------ .github/workflows/stale.yml | 46 ++-- azure-pipelines.yml | 344 ++++++++++++++-------------- 8 files changed, 467 insertions(+), 589 deletions(-) delete mode 100644 .github/copilot-instructions.md delete mode 100644 .github/workflows/ci_i386_linux.yml diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md deleted file mode 100644 index fb48b4af62abb..0000000000000 --- a/.github/copilot-instructions.md +++ /dev/null @@ -1,22 +0,0 @@ -## Code Standards - -### General Guidelines - -Don't modify testing files, instead, you should fix the compiler or library code that is causing the test to fail. - - - - -### Testing a single case - -You can run a single test case by using the command `./koch temp c -r testname`, where `testname` is the name of the test case you want to run. Don't use testament. - - -### Repository Structure - -- `compiler`: Contains the Nim compiler source code. -- `lib`: Contains standard libraries and modules. -- `tests`: Contains test cases for the compiler and standard libraries. -- `doc`: Contains documentation related to the Nim programming language. \ No newline at end of file diff --git a/.github/workflows/bisects.yml b/.github/workflows/bisects.yml index 271fd9eb6f6d1..ef6e160a06f2a 100644 --- a/.github/workflows/bisects.yml +++ b/.github/workflows/bisects.yml @@ -1,38 +1,38 @@ -# # See https://github.com/juancarlospaco/nimrun-action/issues/3#issuecomment-1607344901 -# name: issue comments bisects -# on: -# issue_comment: -# types: created +# See https://github.com/juancarlospaco/nimrun-action/issues/3#issuecomment-1607344901 +name: issue comments bisects +on: + issue_comment: + types: created -# jobs: -# bisects: -# if: | -# github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '!nim ') && github.event.issue.pull_request == null && github.event.comment.author_association != 'NONE' -# strategy: -# fail-fast: false -# matrix: -# platform: [ubuntu-latest, windows-latest, macos-latest] -# name: ${{ matrix.platform }}-bisects -# runs-on: ${{ matrix.platform }} -# steps: -# - uses: actions/checkout@v6 +jobs: + bisects: + if: | + github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '!nim ') && github.event.issue.pull_request == null && github.event.comment.author_association != 'NONE' + strategy: + fail-fast: false + matrix: + platform: [ubuntu-latest, windows-latest, macos-latest] + name: ${{ matrix.platform }}-bisects + runs-on: ${{ matrix.platform }} + steps: + - uses: actions/checkout@v6 -# - name: Install OpenSSL (Windows) -# if: | -# runner.os == 'Windows' -# run: choco install openssl.light --version=1.1.1.0 # OpenSSL 3.x removed SSL_library_init -# shell: 'powershell' + - name: Install OpenSSL (Windows) + if: | + runner.os == 'Windows' + run: choco install openssl.light --version=1.1.1.0 # OpenSSL 3.x removed SSL_library_init + shell: 'powershell' -# # v2 wont work here, because uses "hardcoded" nim versions, action "dynamically" finds version with bug. -# - uses: jiro4989/setup-nim-action@v1 -# with: -# nim-version: 'devel' + # v2 wont work here, because uses "hardcoded" nim versions, action "dynamically" finds version with bug. + - uses: jiro4989/setup-nim-action@v1 + with: + nim-version: 'devel' -# - uses: juancarlospaco/nimrun-action@nim -# if: | -# runner.os == 'Linux' && contains(github.event.comment.body, '-d:linux' ) || -# runner.os == 'Windows' && contains(github.event.comment.body, '-d:windows') || -# runner.os == 'macOS' && contains(github.event.comment.body, '-d:osx' ) || -# runner.os == 'Linux' && !contains(github.event.comment.body, '-d:linux') && !contains(github.event.comment.body, '-d:windows') && !contains(github.event.comment.body, '-d:osx') -# with: -# github-token: ${{ secrets.GITHUB_TOKEN }} + - uses: juancarlospaco/nimrun-action@nim + if: | + runner.os == 'Linux' && contains(github.event.comment.body, '-d:linux' ) || + runner.os == 'Windows' && contains(github.event.comment.body, '-d:windows') || + runner.os == 'macOS' && contains(github.event.comment.body, '-d:osx' ) || + runner.os == 'Linux' && !contains(github.event.comment.body, '-d:linux') && !contains(github.event.comment.body, '-d:windows') && !contains(github.event.comment.body, '-d:osx') + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/ci_docs.yml b/.github/workflows/ci_docs.yml index c259d1ba5d45d..74dd234a289b0 100644 --- a/.github/workflows/ci_docs.yml +++ b/.github/workflows/ci_docs.yml @@ -1,116 +1,116 @@ -# name: Nim Docs CI -# on: -# push: -# paths: -# - 'compiler/**.nim' -# - 'config/nimdoc.cfg' -# - 'doc/**.rst' -# - 'doc/**.md' -# - 'doc/nimdoc.css' -# - 'lib/**.nim' -# - 'nimdoc/testproject/expected/testproject.html' -# - 'tools/dochack/dochack.nim' -# - 'tools/kochdocs.nim' -# - '.github/workflows/ci_docs.yml' -# - 'koch.nim' +name: Nim Docs CI +on: + push: + paths: + - 'compiler/**.nim' + - 'config/nimdoc.cfg' + - 'doc/**.rst' + - 'doc/**.md' + - 'doc/nimdoc.css' + - 'lib/**.nim' + - 'nimdoc/testproject/expected/testproject.html' + - 'tools/dochack/dochack.nim' + - 'tools/kochdocs.nim' + - '.github/workflows/ci_docs.yml' + - 'koch.nim' -# pull_request: -# # Run only on changes on these files. -# paths: -# - 'compiler/**.nim' -# - 'config/nimdoc.cfg' -# - 'doc/**.rst' -# - 'doc/**.md' -# - 'doc/nimdoc.css' -# - 'lib/**.nim' -# - 'nimdoc/testproject/expected/testproject.html' -# - 'tools/dochack/dochack.nim' -# - 'tools/kochdocs.nim' -# - '.github/workflows/ci_docs.yml' -# - 'koch.nim' + pull_request: + # Run only on changes on these files. + paths: + - 'compiler/**.nim' + - 'config/nimdoc.cfg' + - 'doc/**.rst' + - 'doc/**.md' + - 'doc/nimdoc.css' + - 'lib/**.nim' + - 'nimdoc/testproject/expected/testproject.html' + - 'tools/dochack/dochack.nim' + - 'tools/kochdocs.nim' + - '.github/workflows/ci_docs.yml' + - 'koch.nim' -# concurrency: -# group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} -# cancel-in-progress: true +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true -# jobs: -# build: -# strategy: -# fail-fast: false -# matrix: -# target: [linux, windows, osx] -# include: -# - target: linux -# os: ubuntu-22.04 -# - target: windows -# os: windows-latest -# - target: osx -# os: macos-15 +jobs: + build: + strategy: + fail-fast: false + matrix: + target: [linux, windows, osx] + include: + - target: linux + os: ubuntu-22.04 + - target: windows + os: windows-latest + - target: osx + os: macos-15 -# name: ${{ matrix.target }} -# runs-on: ${{ matrix.os }} -# timeout-minutes: 60 # refs bug #18178 + name: ${{ matrix.target }} + runs-on: ${{ matrix.os }} + timeout-minutes: 60 # refs bug #18178 -# steps: -# - name: 'Checkout' -# uses: actions/checkout@v6 -# with: -# fetch-depth: 2 + steps: + - name: 'Checkout' + uses: actions/checkout@v6 + with: + fetch-depth: 2 -# - name: 'Install build dependencies (macOS)' -# if: runner.os == 'macOS' -# run: brew install make + - name: 'Install build dependencies (macOS)' + if: runner.os == 'macOS' + run: brew install make -# - name: 'Install build dependencies (Windows)' -# if: runner.os == 'Windows' -# shell: bash -# run: | -# set -e -# . ci/funs.sh -# nimInternalInstallDepsWindows -# echo "${{ github.workspace }}/dist/mingw64/bin" >> "${GITHUB_PATH}" + - name: 'Install build dependencies (Windows)' + if: runner.os == 'Windows' + shell: bash + run: | + set -e + . ci/funs.sh + nimInternalInstallDepsWindows + echo "${{ github.workspace }}/dist/mingw64/bin" >> "${GITHUB_PATH}" -# - name: 'Add build binaries to PATH' -# shell: bash -# run: echo "${{ github.workspace }}/bin" >> "${GITHUB_PATH}" + - name: 'Add build binaries to PATH' + shell: bash + run: echo "${{ github.workspace }}/bin" >> "${GITHUB_PATH}" -# - name: 'System information' -# shell: bash -# run: . ci/funs.sh && nimCiSystemInfo + - name: 'System information' + shell: bash + run: . ci/funs.sh && nimCiSystemInfo -# - name: 'Build csourcesAny (posix)' -# # this would work on windows and other CI use this on windows, -# # but we ensure here that `ci/build_autogen.bat` keeps working on windows. -# if: runner.os != 'Windows' -# shell: bash -# run: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc -# # was previously using caching via `actions/cache@v1` but this wasn't -# # used in other CI pipelines and it's unclear the added complexity -# # was worth the saving; can be revisited if needed. + - name: 'Build csourcesAny (posix)' + # this would work on windows and other CI use this on windows, + # but we ensure here that `ci/build_autogen.bat` keeps working on windows. + if: runner.os != 'Windows' + shell: bash + run: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc + # was previously using caching via `actions/cache@v1` but this wasn't + # used in other CI pipelines and it's unclear the added complexity + # was worth the saving; can be revisited if needed. -# - name: 'Build csourcesAny (windows)' -# if: runner.os == 'Windows' -# shell: cmd -# run: ci/build_autogen.bat + - name: 'Build csourcesAny (windows)' + if: runner.os == 'Windows' + shell: cmd + run: ci/build_autogen.bat -# - name: 'Build koch' -# shell: bash -# run: nim c koch + - name: 'Build koch' + shell: bash + run: nim c koch -# - name: 'Build the real compiler' -# shell: bash -# run: ./koch boot -d:release + - name: 'Build the real compiler' + shell: bash + run: ./koch boot -d:release -# - name: 'Build documentation' -# shell: bash -# run: ./koch doc --git.commit:devel + - name: 'Build documentation' + shell: bash + run: ./koch doc --git.commit:devel -# - name: 'Publish documentation to Github Pages' -# if: | -# github.event_name == 'push' && github.ref == 'refs/heads/devel' && -# matrix.target == 'linux' -# uses: crazy-max/ghaction-github-pages@v4 -# with: -# build_dir: doc/html -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: 'Publish documentation to Github Pages' + if: | + github.event_name == 'push' && github.ref == 'refs/heads/devel' && + matrix.target == 'linux' + uses: crazy-max/ghaction-github-pages@v4 + with: + build_dir: doc/html + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/ci_i386_linux.yml b/.github/workflows/ci_i386_linux.yml deleted file mode 100644 index 5caf1d8d4f0f1..0000000000000 --- a/.github/workflows/ci_i386_linux.yml +++ /dev/null @@ -1,100 +0,0 @@ -name: i386 Linux CI - -on: - pull_request: - branches: - - '*' - workflow_dispatch: - - -jobs: - build: - strategy: - fail-fast: false - max-parallel: 20 - matrix: - branch: [devel] - target: - - os: linux - cpu: i386 - nim_branch: devel - include: - - target: - os: linux - builder: ubuntu-24.04 - - name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}-nim-${{ matrix.target.nim_branch }} (${{ matrix.branch }})' - runs-on: ${{ matrix.builder }} - env: - NIM_DIR: nim-${{ matrix.target.nim_branch }}-${{ matrix.target.cpu }} - NIM_BRANCH: ${{ matrix.target.nim_branch }} - NIM_ARCH: ${{ matrix.target.cpu }} - steps: - - name: set `core.autocrlf` to false - run: | - git config --global core.autocrlf false - git config --global init.defaultBranch master - - - name: Checkout - uses: actions/checkout@v6 - with: - submodules: false - - - name: Install dependencies (Linux i386) - if: runner.os == 'Linux' && matrix.target.cpu == 'i386' - working-directory: ${{ github.workspace }} - run: | - sudo dpkg --add-architecture i386 - sudo apt-get update -qq - sudo DEBIAN_FRONTEND='noninteractive' apt-get install \ - --no-install-recommends -yq gcc-multilib g++-multilib \ - libssl-dev:i386 - - mkdir -p external/bin - cat << EOF > external/bin/gcc - #!/bin/bash - - exec $(which gcc) -m32 "\$@" - EOF - - cat << EOF > external/bin/g++ - #!/bin/bash - - exec $(which g++) -m32 "\$@" - EOF - - chmod 755 external/bin/gcc external/bin/g++ - - echo "$PWD/external/bin" >> "${GITHUB_PATH}" - - - name: Add repo bin to PATH - run: echo "${GITHUB_WORKSPACE}/bin" >> ${GITHUB_PATH} - - - name: Setup Nim - uses: alaviss/setup-nim@0.1.1 - with: - path: 'nim' - version: ${{ matrix.target.nim_branch }} - architecture: ${{ matrix.target.cpu }} - - # - name: Build koch using existing nim - # run: | - # nim c koch.nim - - # - name: Boot the compiler from the checked-out commit - # shell: bash - # run: | - # ./koch boot -d:release - - # - name: Show nim version and system info - # run: | - # bin/nim -v || true - # uname -a || true - - - name: Run talign test (i386) - shell: bash - run: | - set -euo pipefail - export PATH="${GITHUB_WORKSPACE}/bin:$PATH" - nim c -r --lib:lib --mm:refc -d:useGcAssert -d:useSysAssert tests/align/talign.nim - nim c -r --lib:lib --mm:refc -d:useGcAssert -d:useSysAssert tests/align/talign2.nim \ No newline at end of file diff --git a/.github/workflows/ci_packages.yml b/.github/workflows/ci_packages.yml index 2fbd9ddaeb0fb..6cef86c28a3f9 100644 --- a/.github/workflows/ci_packages.yml +++ b/.github/workflows/ci_packages.yml @@ -1,80 +1,80 @@ -# name: Packages CI -# on: -# pull_request: -# push: -# branches: -# - 'devel' -# - 'version-2-2' -# - 'version-2-0' -# - 'version-1-6' -# - 'version-1-2' +name: Packages CI +on: + pull_request: + push: + branches: + - 'devel' + - 'version-2-2' + - 'version-2-0' + - 'version-1-6' + - 'version-1-2' -# concurrency: -# group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} -# cancel-in-progress: true +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true -# jobs: -# build: -# strategy: -# fail-fast: false -# matrix: -# os: [ubuntu-latest, macos-14] -# batch: ["allowed_failures", "0_3", "1_3", "2_3"] # list of `index_num` -# include: -# - os: ubuntu-latest -# cpu: amd64 -# - os: macos-14 -# cpu: arm64 -# name: '${{ matrix.os }} (batch: ${{ matrix.batch }})' -# runs-on: ${{ matrix.os }} -# timeout-minutes: 60 # refs bug #18178 -# env: -# NIM_TEST_PACKAGES: "1" -# NIM_TESTAMENT_BATCH: ${{ matrix.batch }} -# steps: -# - name: 'Checkout' -# uses: actions/checkout@v6 -# with: -# fetch-depth: 2 +jobs: + build: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-14] + batch: ["allowed_failures", "0_3", "1_3", "2_3"] # list of `index_num` + include: + - os: ubuntu-latest + cpu: amd64 + - os: macos-14 + cpu: arm64 + name: '${{ matrix.os }} (batch: ${{ matrix.batch }})' + runs-on: ${{ matrix.os }} + timeout-minutes: 60 # refs bug #18178 + env: + NIM_TEST_PACKAGES: "1" + NIM_TESTAMENT_BATCH: ${{ matrix.batch }} + steps: + - name: 'Checkout' + uses: actions/checkout@v6 + with: + fetch-depth: 2 -# - name: 'Install node.js' -# uses: actions/setup-node@v6 -# with: -# node-version: 24 + - name: 'Install node.js' + uses: actions/setup-node@v6 + with: + node-version: 24 -# - name: 'Install dependencies (Linux amd64)' -# if: runner.os == 'Linux' && matrix.cpu == 'amd64' -# run: | -# sudo apt-get update -qq -# DEBIAN_FRONTEND='noninteractive' \ -# sudo apt-get install --no-install-recommends -yq \ -# libcurl4-openssl-dev libgc-dev libsdl1.2-dev libsfml-dev \ -# valgrind libc6-dbg libblas-dev liblapack-dev libpcre3 xorg-dev -# - name: 'Install dependencies (macOS)' -# if: runner.os == 'macOS' -# run: brew install boehmgc make sfml gtk+3 -# # XXX can't find boehm and gtk on macos 13 -# - name: 'Install dependencies (Windows)' -# if: runner.os == 'Windows' -# shell: bash -# run: | -# set -e -# . ci/funs.sh -# nimInternalInstallDepsWindows -# echo_run echo "${{ github.workspace }}/dist/mingw64/bin" >> "${GITHUB_PATH}" + - name: 'Install dependencies (Linux amd64)' + if: runner.os == 'Linux' && matrix.cpu == 'amd64' + run: | + sudo apt-get update -qq + DEBIAN_FRONTEND='noninteractive' \ + sudo apt-get install --no-install-recommends -yq \ + libcurl4-openssl-dev libgc-dev libsdl1.2-dev libsfml-dev \ + valgrind libc6-dbg libblas-dev liblapack-dev libpcre3 xorg-dev + - name: 'Install dependencies (macOS)' + if: runner.os == 'macOS' + run: brew install boehmgc make sfml gtk+3 + # XXX can't find boehm and gtk on macos 13 + - name: 'Install dependencies (Windows)' + if: runner.os == 'Windows' + shell: bash + run: | + set -e + . ci/funs.sh + nimInternalInstallDepsWindows + echo_run echo "${{ github.workspace }}/dist/mingw64/bin" >> "${GITHUB_PATH}" -# - name: 'Add build binaries to PATH' -# shell: bash -# run: echo "${{ github.workspace }}/bin" >> "${GITHUB_PATH}" + - name: 'Add build binaries to PATH' + shell: bash + run: echo "${{ github.workspace }}/bin" >> "${GITHUB_PATH}" -# - name: 'System information' -# shell: bash -# run: . ci/funs.sh && nimCiSystemInfo + - name: 'System information' + shell: bash + run: . ci/funs.sh && nimCiSystemInfo -# - name: 'Build csourcesAny' -# shell: bash -# run: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc ucpu='${{ matrix.cpu }}' + - name: 'Build csourcesAny' + shell: bash + run: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc ucpu='${{ matrix.cpu }}' -# - name: 'koch, Run CI' -# shell: bash -# run: . ci/funs.sh && nimInternalBuildKochAndRunCI + - name: 'koch, Run CI' + shell: bash + run: . ci/funs.sh && nimInternalBuildKochAndRunCI diff --git a/.github/workflows/ci_publish.yml b/.github/workflows/ci_publish.yml index 67b2eea99f195..44cfaf8213150 100644 --- a/.github/workflows/ci_publish.yml +++ b/.github/workflows/ci_publish.yml @@ -1,79 +1,79 @@ -# name: Tracking orc-booting compiler memory usage +name: Tracking orc-booting compiler memory usage -# on: -# pull_request_target: -# types: [closed] +on: + pull_request_target: + types: [closed] -# jobs: -# build: -# if: github.event.pull_request.merged == true -# strategy: -# fail-fast: false -# matrix: -# os: [ubuntu-22.04] -# cpu: [amd64] -# name: '${{ matrix.os }}' -# runs-on: ${{ matrix.os }} -# steps: -# - name: 'Checkout' -# uses: actions/checkout@v6 -# with: -# fetch-depth: 2 +jobs: + build: + if: github.event.pull_request.merged == true + strategy: + fail-fast: false + matrix: + os: [ubuntu-22.04] + cpu: [amd64] + name: '${{ matrix.os }}' + runs-on: ${{ matrix.os }} + steps: + - name: 'Checkout' + uses: actions/checkout@v6 + with: + fetch-depth: 2 -# - name: 'Install node.js' -# uses: actions/setup-node@v6 -# with: -# node-version: 24 + - name: 'Install node.js' + uses: actions/setup-node@v6 + with: + node-version: 24 -# - name: 'Install dependencies (Linux amd64)' -# if: runner.os == 'Linux' && matrix.cpu == 'amd64' -# run: | -# sudo apt-fast update -qq -# DEBIAN_FRONTEND='noninteractive' \ -# sudo apt-fast install --no-install-recommends -yq \ -# libcurl4-openssl-dev libgc-dev libsdl1.2-dev libsfml-dev \ -# valgrind libc6-dbg libblas-dev xorg-dev + - name: 'Install dependencies (Linux amd64)' + if: runner.os == 'Linux' && matrix.cpu == 'amd64' + run: | + sudo apt-fast update -qq + DEBIAN_FRONTEND='noninteractive' \ + sudo apt-fast install --no-install-recommends -yq \ + libcurl4-openssl-dev libgc-dev libsdl1.2-dev libsfml-dev \ + valgrind libc6-dbg libblas-dev xorg-dev -# - name: 'Add build binaries to PATH' -# shell: bash -# run: echo "${{ github.workspace }}/bin" >> "${GITHUB_PATH}" + - name: 'Add build binaries to PATH' + shell: bash + run: echo "${{ github.workspace }}/bin" >> "${GITHUB_PATH}" -# - name: 'System information' -# shell: bash -# run: . ci/funs.sh && nimCiSystemInfo + - name: 'System information' + shell: bash + run: . ci/funs.sh && nimCiSystemInfo -# - name: 'Build csourcesAny' -# shell: bash -# run: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc ucpu='${{ matrix.cpu }}' + - name: 'Build csourcesAny' + shell: bash + run: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc ucpu='${{ matrix.cpu }}' -# - name: 'Build koch' -# shell: bash -# run: nim c koch + - name: 'Build koch' + shell: bash + run: nim c koch -# - name: 'Build Nim' -# shell: bash -# run: ./koch boot -d:release -d:nimStrictMode --lib:lib + - name: 'Build Nim' + shell: bash + run: ./koch boot -d:release -d:nimStrictMode --lib:lib -# - name: 'Action' -# shell: bash -# run: nim c -r -d:release ci/action.nim + - name: 'Action' + shell: bash + run: nim c -r -d:release ci/action.nim -# - name: 'Comment' -# uses: actions/github-script@v8 -# with: -# script: | -# const fs = require('fs'); + - name: 'Comment' + uses: actions/github-script@v8 + with: + script: | + const fs = require('fs'); -# try { -# const data = fs.readFileSync('ci/nimcache/results.txt', 'utf8'); -# github.rest.issues.createComment({ -# issue_number: context.issue.number, -# owner: context.repo.owner, -# repo: context.repo.repo, -# body: data -# }) -# } catch (err) { -# console.error(err); -# } + try { + const data = fs.readFileSync('ci/nimcache/results.txt', 'utf8'); + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: data + }) + } catch (err) { + console.error(err); + } diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 586f2acfde656..b918b21050a7a 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -1,25 +1,25 @@ -# # https://github.com/actions/stale#usage -# name: Stale pull requests +# https://github.com/actions/stale#usage +name: Stale pull requests -# on: -# schedule: -# - cron: '0 0 * * *' # Midnight. +on: + schedule: + - cron: '0 0 * * *' # Midnight. -# jobs: -# stale: -# runs-on: ubuntu-latest -# steps: -# - uses: actions/stale@v10 -# with: -# days-before-pr-stale: 365 -# days-before-pr-close: 30 -# days-before-issue-stale: -1 -# days-before-issue-close: -1 -# exempt-pr-labels: "ARC,bounty,Codegen,Crash,Generics,High Priority,Macros,Next release,Showstopper,Static[T]" -# exempt-issue-labels: "Showstopper,Severe,bounty,Compiler Crash,Medium Priority" -# stale-pr-message: > -# This pull request is stale because it has been open for 1 year with no activity. -# Contribute more commits on the pull request and rebase it on the latest devel, -# or it will be closed in 30 days. Thank you for your contributions. -# close-pr-message: > -# This pull request has been marked as stale and closed due to inactivity after 395 days. +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v10 + with: + days-before-pr-stale: 365 + days-before-pr-close: 30 + days-before-issue-stale: -1 + days-before-issue-close: -1 + exempt-pr-labels: "ARC,bounty,Codegen,Crash,Generics,High Priority,Macros,Next release,Showstopper,Static[T]" + exempt-issue-labels: "Showstopper,Severe,bounty,Compiler Crash,Medium Priority" + stale-pr-message: > + This pull request is stale because it has been open for 1 year with no activity. + Contribute more commits on the pull request and rebase it on the latest devel, + or it will be closed in 30 days. Thank you for your contributions. + close-pr-message: > + This pull request has been marked as stale and closed due to inactivity after 395 days. diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 3b5f1c9540f10..96e747a730fc0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,172 +1,172 @@ -# trigger: -# branches: -# include: -# - 'devel' -# - 'version-*' -# pr: -# branches: -# include: -# - '*' - -# variables: -# - name: skipci -# value: false - -# jobs: -# - job: packages - -# timeoutInMinutes: 90 # default `60` led to lots of cancelled jobs; use 0 for unlimited (may be undesirable) - -# strategy: -# matrix: -# Linux_amd64: -# vmImage: 'ubuntu-24.04' -# CPU: amd64 -# # regularly breaks, refs bug #17325 -# # Linux_i386: -# # # on 'ubuntu-16.04' (not supported anymore anyways) it errored with: -# # # g++-multilib : Depends: gcc-multilib (>= 4:5.3.1-1ubuntu1) but it is not going to be installed -# # vmImage: 'ubuntu-18.04' -# # CPU: i386 -# OSX_arm64: -# vmImage: 'macos-15' -# CPU: arm64 -# OSX_arm64_cpp: -# vmImage: 'macos-15' -# CPU: arm64 -# NIM_COMPILE_TO_CPP: true -# Windows_amd64_batch0_3: -# vmImage: 'windows-2025' -# CPU: amd64 -# # see also: `NIM_TEST_PACKAGES` -# NIM_TESTAMENT_BATCH: "0_3" -# Windows_amd64_batch1_3: -# vmImage: 'windows-2025' -# CPU: amd64 -# NIM_TESTAMENT_BATCH: "1_3" -# Windows_amd64_batch2_3: -# vmImage: 'windows-2025' -# CPU: amd64 -# NIM_TESTAMENT_BATCH: "2_3" - -# pool: -# vmImage: $(vmImage) - -# workspace: -# clean: all - -# steps: -# - bash: git config --global core.autocrlf false -# displayName: 'Disable auto conversion to CRLF by git (Windows-only)' -# condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT')) - -# - checkout: self -# fetchDepth: 2 # see D20210329T004830 - -# - bash: | -# set -e -# . ci/funs.sh -# if nimIsCiSkip; then -# echo '##vso[task.setvariable variable=skipci]true' -# fi -# displayName: 'Check whether to skip CI' - -# - task: NodeTool@0 -# inputs: -# versionSpec: '20.x' -# displayName: 'Install node.js 20.x' -# condition: and(succeeded(), eq(variables['skipci'], 'false')) - -# - bash: | -# set -e -# . ci/funs.sh -# echo_run sudo add-apt-repository universe -# echo_run sudo apt-get update -qq -# DEBIAN_FRONTEND='noninteractive' \ -# echo_run sudo apt-get install --no-install-recommends -yq \ -# gcc-14 g++-14 libpcre3 liblapack-dev libpcre3 liblapack-dev libcurl4-openssl-dev libgc-dev libsdl1.2-dev libsfml-dev valgrind libc6-dbg -# echo_run sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 60 --slave /usr/bin/g++ g++ /usr/bin/g++-14 -# displayName: 'Install dependencies (amd64 Linux)' -# condition: and(succeeded(), eq(variables['skipci'], 'false'), eq(variables['Agent.OS'], 'Linux'), eq(variables['CPU'], 'amd64')) - -# - bash: | -# set -e -# . ci/funs.sh -# echo_run sudo dpkg --add-architecture i386 -# # Downgrade llvm: -# # - llvm has to be downgraded to have 32bit version installed for sfml. - -# cat << EOF | sudo tee /etc/apt/preferences.d/pin-to-rel -# Package: libllvm6.0 -# Pin: origin "azure.archive.ubuntu.com" -# Pin-Priority: 1001 -# EOF - -# # echo_run sudo apt-get update -qq -# echo_run sudo apt-get update -qq || echo "failed, see bug #17343" -# # `:i386` (e.g. in `libffi-dev:i386`) is needed otherwise you may get: -# # `could not load: libffi.so` during dynamic loading. -# DEBIAN_FRONTEND='noninteractive' \ -# echo_run sudo apt-get install --no-install-recommends --allow-downgrades -yq \ -# g++-multilib gcc-multilib libcurl4-openssl-dev:i386 libgc-dev:i386 \ -# libsdl1.2-dev:i386 libsfml-dev:i386 libglib2.0-dev:i386 libffi-dev:i386 - - -# cat << EOF > bin/gcc -# #!/bin/bash - -# exec $(which gcc) -m32 "\$@" -# EOF - -# cat << EOF > bin/g++ -# #!/bin/bash - -# exec $(which g++) -m32 "\$@" -# EOF - -# echo_run chmod 755 bin/gcc -# echo_run chmod 755 bin/g++ - -# displayName: 'Install dependencies (i386 Linux)' -# condition: and(succeeded(), eq(variables['skipci'], 'false'), eq(variables['Agent.OS'], 'Linux'), eq(variables['CPU'], 'i386')) - -# - bash: brew install boehmgc make sfml -# displayName: 'Install dependencies (OSX)' -# condition: and(succeeded(), eq(variables['skipci'], 'false'), eq(variables['Agent.OS'], 'Darwin')) -# # XXX can't find boehm on macos 13 - -# - bash: | -# set -e -# . ci/funs.sh -# nimInternalInstallDepsWindows -# echo_run echo '##vso[task.prependpath]$(System.DefaultWorkingDirectory)/dist/mingw64/bin' - -# displayName: 'Install dependencies (Windows)' -# condition: and(succeeded(), eq(variables['skipci'], 'false'), eq(variables['Agent.OS'], 'Windows_NT')) - -# - bash: echo '##vso[task.prependpath]$(System.DefaultWorkingDirectory)/bin' -# condition: and(succeeded(), eq(variables['skipci'], 'false')) -# displayName: 'Add build binaries to PATH' - -# - bash: . ci/funs.sh && nimCiSystemInfo -# condition: and(succeeded(), eq(variables['skipci'], 'false')) -# displayName: 'System information' - -# - bash: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc ucpu=$(CPU) -# condition: and(succeeded(), eq(variables['skipci'], 'false')) -# displayName: 'Build csourcesAny' - -# # this could be revived if performance justifies it (needs a few updates) -# # - task: Cache@2 -# # inputs: -# # key: 'csourcesAny | "$(Agent.OS)" | $(CPU) | $(csources_version)' -# # path: $(nim_csources) -# # condition: and(succeeded(), eq(variables['skipci'], 'false')) -# # displayName: 'Restore built csourcesAny' - -# - bash: . ci/funs.sh && nimInternalBuildKochAndRunCI -# # would could also show on failure: echo '##vso[task.complete result=Failed]' -# condition: and(succeeded(), eq(variables['skipci'], 'false')) -# displayName: 'koch, Run CI' -# env: -# SYSTEM_ACCESSTOKEN: $(System.AccessToken) +trigger: + branches: + include: + - 'devel' + - 'version-*' +pr: + branches: + include: + - '*' + +variables: +- name: skipci + value: false + +jobs: +- job: packages + + timeoutInMinutes: 90 # default `60` led to lots of cancelled jobs; use 0 for unlimited (may be undesirable) + + strategy: + matrix: + Linux_amd64: + vmImage: 'ubuntu-24.04' + CPU: amd64 + # regularly breaks, refs bug #17325 +# Linux_i386: +# # on 'ubuntu-16.04' (not supported anymore anyways) it errored with: +# # g++-multilib : Depends: gcc-multilib (>= 4:5.3.1-1ubuntu1) but it is not going to be installed +# vmImage: 'ubuntu-18.04' +# CPU: i386 + OSX_arm64: + vmImage: 'macos-15' + CPU: arm64 + OSX_arm64_cpp: + vmImage: 'macos-15' + CPU: arm64 + NIM_COMPILE_TO_CPP: true + Windows_amd64_batch0_3: + vmImage: 'windows-2025' + CPU: amd64 + # see also: `NIM_TEST_PACKAGES` + NIM_TESTAMENT_BATCH: "0_3" + Windows_amd64_batch1_3: + vmImage: 'windows-2025' + CPU: amd64 + NIM_TESTAMENT_BATCH: "1_3" + Windows_amd64_batch2_3: + vmImage: 'windows-2025' + CPU: amd64 + NIM_TESTAMENT_BATCH: "2_3" + + pool: + vmImage: $(vmImage) + + workspace: + clean: all + + steps: + - bash: git config --global core.autocrlf false + displayName: 'Disable auto conversion to CRLF by git (Windows-only)' + condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT')) + + - checkout: self + fetchDepth: 2 # see D20210329T004830 + + - bash: | + set -e + . ci/funs.sh + if nimIsCiSkip; then + echo '##vso[task.setvariable variable=skipci]true' + fi + displayName: 'Check whether to skip CI' + + - task: NodeTool@0 + inputs: + versionSpec: '20.x' + displayName: 'Install node.js 20.x' + condition: and(succeeded(), eq(variables['skipci'], 'false')) + + - bash: | + set -e + . ci/funs.sh + echo_run sudo add-apt-repository universe + echo_run sudo apt-get update -qq + DEBIAN_FRONTEND='noninteractive' \ + echo_run sudo apt-get install --no-install-recommends -yq \ + gcc-14 g++-14 libpcre3 liblapack-dev libpcre3 liblapack-dev libcurl4-openssl-dev libgc-dev libsdl1.2-dev libsfml-dev valgrind libc6-dbg + echo_run sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 60 --slave /usr/bin/g++ g++ /usr/bin/g++-14 + displayName: 'Install dependencies (amd64 Linux)' + condition: and(succeeded(), eq(variables['skipci'], 'false'), eq(variables['Agent.OS'], 'Linux'), eq(variables['CPU'], 'amd64')) + + - bash: | + set -e + . ci/funs.sh + echo_run sudo dpkg --add-architecture i386 + # Downgrade llvm: + # - llvm has to be downgraded to have 32bit version installed for sfml. + + cat << EOF | sudo tee /etc/apt/preferences.d/pin-to-rel + Package: libllvm6.0 + Pin: origin "azure.archive.ubuntu.com" + Pin-Priority: 1001 + EOF + + # echo_run sudo apt-get update -qq + echo_run sudo apt-get update -qq || echo "failed, see bug #17343" + # `:i386` (e.g. in `libffi-dev:i386`) is needed otherwise you may get: + # `could not load: libffi.so` during dynamic loading. + DEBIAN_FRONTEND='noninteractive' \ + echo_run sudo apt-get install --no-install-recommends --allow-downgrades -yq \ + g++-multilib gcc-multilib libcurl4-openssl-dev:i386 libgc-dev:i386 \ + libsdl1.2-dev:i386 libsfml-dev:i386 libglib2.0-dev:i386 libffi-dev:i386 + + + cat << EOF > bin/gcc + #!/bin/bash + + exec $(which gcc) -m32 "\$@" + EOF + + cat << EOF > bin/g++ + #!/bin/bash + + exec $(which g++) -m32 "\$@" + EOF + + echo_run chmod 755 bin/gcc + echo_run chmod 755 bin/g++ + + displayName: 'Install dependencies (i386 Linux)' + condition: and(succeeded(), eq(variables['skipci'], 'false'), eq(variables['Agent.OS'], 'Linux'), eq(variables['CPU'], 'i386')) + + - bash: brew install boehmgc make sfml + displayName: 'Install dependencies (OSX)' + condition: and(succeeded(), eq(variables['skipci'], 'false'), eq(variables['Agent.OS'], 'Darwin')) + # XXX can't find boehm on macos 13 + + - bash: | + set -e + . ci/funs.sh + nimInternalInstallDepsWindows + echo_run echo '##vso[task.prependpath]$(System.DefaultWorkingDirectory)/dist/mingw64/bin' + + displayName: 'Install dependencies (Windows)' + condition: and(succeeded(), eq(variables['skipci'], 'false'), eq(variables['Agent.OS'], 'Windows_NT')) + + - bash: echo '##vso[task.prependpath]$(System.DefaultWorkingDirectory)/bin' + condition: and(succeeded(), eq(variables['skipci'], 'false')) + displayName: 'Add build binaries to PATH' + + - bash: . ci/funs.sh && nimCiSystemInfo + condition: and(succeeded(), eq(variables['skipci'], 'false')) + displayName: 'System information' + + - bash: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc ucpu=$(CPU) + condition: and(succeeded(), eq(variables['skipci'], 'false')) + displayName: 'Build csourcesAny' + + # this could be revived if performance justifies it (needs a few updates) + # - task: Cache@2 + # inputs: + # key: 'csourcesAny | "$(Agent.OS)" | $(CPU) | $(csources_version)' + # path: $(nim_csources) + # condition: and(succeeded(), eq(variables['skipci'], 'false')) + # displayName: 'Restore built csourcesAny' + + - bash: . ci/funs.sh && nimInternalBuildKochAndRunCI + # would could also show on failure: echo '##vso[task.complete result=Failed]' + condition: and(succeeded(), eq(variables['skipci'], 'false')) + displayName: 'koch, Run CI' + env: + SYSTEM_ACCESSTOKEN: $(System.AccessToken) From 4b1fca79e3b59ed46449780b0fcb4205bdbd1ab5 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Tue, 3 Mar 2026 17:15:05 +0800 Subject: [PATCH 13/17] document --- doc/manual.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual.md b/doc/manual.md index b0de4f58bb5ef..d1db9088efae6 100644 --- a/doc/manual.md +++ b/doc/manual.md @@ -7906,7 +7906,7 @@ alignment requirement of the type are ignored. main() ``` -This pragma has no effect on the JS backend. +This pragma has no effect on the JavaScript backend and may significantly increase memory usage with the `--mm:refc` option. Noalias pragma From 0bba7d1e60067fc31ed0e060cb2e72214e1d4ab5 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Tue, 3 Mar 2026 17:16:37 +0800 Subject: [PATCH 14/17] progress --- lib/system/cellsets.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/system/cellsets.nim b/lib/system/cellsets.nim index 07bf440753c04..249dd522cfcbd 100644 --- a/lib/system/cellsets.nim +++ b/lib/system/cellsets.nim @@ -61,7 +61,7 @@ else: line: int elif useCellIds: id: int - elif defined(cpu32): + elif sizeof(int) == 4: # 32-bit only headerAlignPad: array[8, byte] # so addr(data) ≡ 8 (mod 16) PCell = ptr Cell From 8a5c8522cbefd5e76c02e813404f423e834d066f Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Tue, 3 Mar 2026 17:23:36 +0800 Subject: [PATCH 15/17] oops --- lib/system/cellsets.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/system/cellsets.nim b/lib/system/cellsets.nim index 249dd522cfcbd..641a80b3efe6d 100644 --- a/lib/system/cellsets.nim +++ b/lib/system/cellsets.nim @@ -59,9 +59,9 @@ else: when trackAllocationSource: filename: cstring line: int - elif useCellIds: + when useCellIds: id: int - elif sizeof(int) == 4: # 32-bit only + when (not trackAllocationSource) and (not useCellIds) and sizeof(int) == 4: # 32-bit only headerAlignPad: array[8, byte] # so addr(data) ≡ 8 (mod 16) PCell = ptr Cell From a534927559d062c8b1282d1ff9eaae1db4864196 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Tue, 3 Mar 2026 18:46:19 +0800 Subject: [PATCH 16/17] improves tests --- tests/align/talign2.nim | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/align/talign2.nim b/tests/align/talign2.nim index 2b581afc95665..6d85f392064f9 100644 --- a/tests/align/talign2.nim +++ b/tests/align/talign2.nim @@ -1,6 +1,11 @@ +discard """ + matrix: "--mm:refc -d:useGcAssert -d:useSysAssert; --mm:orc" + targets: "c cpp" +""" + block: type U = object d {.align: 16.}: int8 var e: seq[ref U] for i in 0 ..< 10000: e.add(new U) - doAssert getTotalMem() <= 1052672 * 2 + doAssert getTotalMem() <= 1052672 * 2 \ No newline at end of file From fa7ede64c394de6f51268f21c3980f2efb0bef68 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Tue, 3 Mar 2026 18:47:31 +0800 Subject: [PATCH 17/17] Apply suggestion from @ringabout --- tests/align/talign2.nim | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/align/talign2.nim b/tests/align/talign2.nim index 6d85f392064f9..528ae4d134915 100644 --- a/tests/align/talign2.nim +++ b/tests/align/talign2.nim @@ -1,6 +1,5 @@ discard """ matrix: "--mm:refc -d:useGcAssert -d:useSysAssert; --mm:orc" - targets: "c cpp" """ block: