├── .gitattributes ├── .github ├── scripts │ ├── install-libs.cmd │ └── install-libs.sh └── workflows │ └── build.yml ├── .gitignore ├── LICENSE ├── README.md ├── certs └── emacs-cert.pfx ├── emacs-build-unix.sh ├── emacs-build.cmd ├── emacs-build.sh ├── patches ├── emacs │ ├── .deprecated │ │ ├── 0001-MPS-Make-one_w32_display_info-an-ambiguous-root.patch │ │ ├── 0001-print_object-call-with-correct-parameters-for-native.patch │ │ ├── 0006-Windows-unaligned-jmpbuf-support.patch │ │ ├── 0009-New-sys-select-for-win.patch │ │ └── 0010-dump_map_file_w32-fix-bad-merge-endif.patch │ ├── 0001-.el.elc-ignore-byte-compile-errors.patch │ ├── 0002-ci-auto-sync.patch │ ├── 0003-makefile-dont-build-leim.patch │ ├── 0004-w32-win-dont-load-dnd-menu-bar-scroll-bar-unneccesar.patch │ ├── 0005-mps_gen_param_s-increase-to-256MB-for-gc.patch │ ├── 0006-package-quickstart-refresh-dont-require-info-delay-l.patch │ ├── 0007-Stop-using-legacy-ffat-lto-objects-option-in-LTO-bui.patch │ ├── 0008-Fix-empty-minor-mode-doc-string-causes-error.patch │ ├── 0009-setup_w32_kbhook-ignore-it.patch │ ├── 0010-clang-fixes.patch │ ├── 0011-aarch64-fixes.patch │ └── 0012-Ensure-sys_jmp_buf-structures-are-marked-during-GC.patch ├── how-to-apply.md └── mps │ ├── 0001-ming-support.patch │ ├── 0003-adding-quick-build-option.patch │ ├── 0004-Fix-register-scanning-on-FreeBSD-and-Linux.patch │ ├── 0005-Fix-some-race-conditions-in-xca6ll-hot-amcssth.patch │ ├── 0006-fix-MSP_PROT_INNER-TO-sync-with-RootModePROTECTABLE_.patch │ └── 0007-build-make-warnings-error-only-in-debug-build.patch ├── scripts ├── aspell.sh ├── create_msix.ps1 ├── gnutls.sh ├── gzip.sh ├── help.txt ├── hunspell.sh ├── msys2.cmd ├── msys2_extra.sh ├── pdf-tools.sh ├── setup-msys2.ps1 ├── site-start.el ├── tools.sh └── trackdlls.sh └── template └── appxmanifest.t.xml /.gitattributes: -------------------------------------------------------------------------------- 1 | *.sh text eol=lf 2 | *.md text eol=lf 3 | -------------------------------------------------------------------------------- /.github/scripts/install-libs.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | cd %~dp0 4 | powershell -noprofile -c ..\..\scripts\setup-msys2.ps1 5 | ..\..\scripts\msys2.cmd -c "./install-libs.sh %*" 6 | -------------------------------------------------------------------------------- /.github/scripts/install-libs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd "$(dirname "$0")/../.." 3 | 4 | mkdir -p ./git/mps 5 | cd ./git/mps 6 | git clone https://github.com/Ravenbrook/mps --branch release-1.118.0 --depth=1 . 7 | git apply --ignore-space-change --ignore-whitespace ../../patches/mps/*.patch || true 8 | PREFIX=${MSYSTEM-usr} 9 | ./configure --prefix=/$PREFIX 10 | make quick VARIETY=hot && make install VARIETY=hot 11 | 12 | ls -la /$PREFIX/include/mps*.h 13 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: build 4 | 5 | # Controls when the action will run. 6 | on: 7 | schedule: 8 | - cron: "0 0 1 * *" # monthly 9 | # Allows you to run this workflow manually from the Actions tab 10 | workflow_dispatch: 11 | 12 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 13 | jobs: 14 | prepare_env: 15 | name: Prepare build version 16 | runs-on: ubuntu-latest 17 | env: 18 | EMACS_REPO: https://github.com/kiennq/emacs.git 19 | GH_TOKEN: ${{ github.token }} 20 | steps: 21 | - uses: actions/checkout@v4 22 | - name: Get build version 23 | id: vars 24 | run: | 25 | mkdir -p ./git/emacs 26 | cd ./git/emacs/ 27 | git clone --depth 1 $EMACS_REPO . 28 | ts=`date +'%Y%m%d'` 29 | commit=`git rev-parse --short=7 HEAD` 30 | major_ver=`cat configure.ac | grep -Po 'AC_INIT\(.*\[\K\d+'` 31 | version=`echo ${major_ver}.${{ github.run_number }}.${ts}.${commit}` 32 | 33 | echo "commit=${commit}" >> $GITHUB_ENV 34 | echo "version=${version}" >> $GITHUB_ENV 35 | echo "pkg_version=${major_ver}.${{ github.run_number }}.0.0" >> $GITHUB_ENV 36 | outputs: 37 | repo: ${{ env.EMACS_REPO }} 38 | version: ${{ env.version }} 39 | pkg_version: ${{ env.pkg_version }} 40 | commit: ${{ env.commit }} 41 | 42 | build: 43 | needs: prepare_env 44 | name: Build Emacs 45 | # Matrix strategy from 46 | # https://github.com/msys2/MINGW-packages/blob/master/.github/workflows/main.yml 47 | strategy: 48 | fail-fast: false 49 | matrix: 50 | include: 51 | - os: windows-latest 52 | shell: powershell 53 | msystem: MINGW64 54 | build_options: --with-rsvg --without-mps 55 | - os: windows-latest 56 | shell: powershell 57 | msystem: UCRT64 58 | build_options: --variant mps --with-rsvg --with-mps --no-strip --enable-build-details 59 | - os: ubuntu-latest 60 | shell: bash 61 | build_options: --with-rsvg --with-mps --without-xwidgets 62 | 63 | # The type of runner that the job will run on 64 | runs-on: ${{ matrix.os }} 65 | env: 66 | MSYS2_DIR: C:\msys64 67 | EMACS_REPO: ${{ needs.prepare_env.outputs.repo }} 68 | EMACS_PKG_VERSION: ${{ needs.prepare_env.outputs.pkg_version }} 69 | EMACS_CERT_SECRET: ${{ secrets.EMACS_CERT_SECRET }} 70 | 71 | defaults: 72 | run: 73 | shell: ${{ matrix.shell }} 74 | 75 | # Steps represent a sequence of tasks that will be executed as part of the job 76 | steps: 77 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 78 | - uses: actions/checkout@v4 79 | 80 | - name: Setup Msys2 81 | uses: msys2/setup-msys2@v2 82 | if: runner.os == 'Windows' 83 | with: 84 | msystem: ${{ matrix.msystem }} 85 | release: false 86 | 87 | # This is the shortest job, but in this case it pulls all MSYS/MINGW64 88 | - name: Clone Emacs 89 | if: runner.os == 'Windows' 90 | run: .\emacs-build.cmd --clone --repo https://github.com/kiennq/emacs.git --branch ${{ needs.prepare_env.outputs.commit }} 91 | 92 | - name: Clone Emacs 93 | if: runner.os != 'Windows' 94 | run: | 95 | mkdir -p ./git/emacs 96 | cd ./git/emacs/ 97 | git clone --filter=tree:0 --no-checkout $EMACS_REPO . 98 | git checkout ${{ needs.prepare_env.outputs.commit }} 99 | 100 | - name: Install deps 101 | if: runner.os == 'Windows' 102 | run: | 103 | .\emacs-build.cmd --slim --ensure ${{ matrix.build_options }} 104 | if ("${{ matrix.build_options }}" -notmatch "--without-mps") { .github/scripts/install-libs.cmd } 105 | 106 | - name: Install deps 107 | if: runner.os != 'Windows' 108 | run: sudo .github/scripts/install-libs.sh 109 | 110 | - name: Build Emacs 111 | if: runner.os == 'Windows' 112 | # Require --with-* flags, else the deps will not be included properly 113 | run: | 114 | .\emacs-build.cmd --slim --branch ${{ needs.prepare_env.outputs.commit }} --configure --build-dev ${{ matrix.build_options }} 115 | 116 | - name: Install winget 117 | if: runner.os == 'Windows' 118 | uses: Cyberboss/install-winget@v1 119 | with: 120 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 121 | 122 | - name: Install MSIXHeroCLI 123 | if: runner.os == 'Windows' 124 | run: winget install msixhero --disable-interactivity --accept-source-agreements 125 | 126 | - name: Package Emacs 127 | if: runner.os == 'Windows' 128 | run: | 129 | $env:MSIXHeroCLI = &where.exe MSIXHeroCLI 130 | .\emacs-build.cmd --slim --branch ${{ needs.prepare_env.outputs.commit }} --msix --pack-all ${{ matrix.build_options }} 131 | 132 | - name: Build and pack Emacs 133 | if: runner.os != 'Windows' 134 | run: | 135 | chmod 755 ./emacs-build-unix.sh 136 | mkdir -p ./zips 137 | ./emacs-build-unix.sh -s ./git/emacs/ -v ${{ needs.prepare_env.outputs.version }} -d ./zips ${{ matrix.build_options }} 138 | 139 | # Upload release for each build 140 | - name: Upload binaries to release 141 | id: upload_release 142 | uses: svenstaro/upload-release-action@v2 143 | with: 144 | repo_token: ${{ github.token }} 145 | file: ./zips/*{-full.zip,.deb,.msix} 146 | file_glob: true 147 | tag: v${{ needs.prepare_env.outputs.version }} 148 | release_name: emacs_${{ needs.prepare_env.outputs.version }} 149 | draft: false 150 | prerelease: false 151 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | git 3 | pkg 4 | zips 5 | *~ 6 | #* 7 | msys64 8 | *.log 9 | .applied -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Juan José García Ripoll 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # emacs-build v0.4 2 | 3 | Scripts to build a distribution of Emacs from sources, using MSYS2 and Mingw64(32) 4 | 5 | ## Rationale 6 | 7 | I wanted a script to build Emacs from sources, package it and install it on 8 | different computers, with the following conditions 9 | 10 | - I should be able to build any branch or release from Emacs. This includes the last release branch (right now emacs-27), as well as the master branch for development. Always using pristine sources from Savannah. 11 | - I want to build emacs with different options from the default, which is to use all features available. For instance, I do not care for SVG support. 12 | - The script needs to track all packages that are required by the Emacs build even if I change the build options. 13 | - The installation should take as little space as possible, removing useless directories or files that come from the dependencies. For instance, headers from libraries used by emacs, spurious documentation files, etc. 14 | - The script should be able to build other components I regularly use, such as mu, mu4e or pdf-tools, in a way that is not affected by updates to the mingw or msys environments. 15 | 16 | ## Usage 17 | 18 | The script supports two way of being invoked: 19 | 20 | - The `emacs-build.cmd` assumes nothing about your system, except for an existing installation of PowerShell. It will download and install a minimal MSYS/MINGW64 environment and build Emacs and all other requested components. This allows for a more deterministic build, without perturbing your computer. 21 | - The `emacs-build.sh` is meant to be ran from an existing MSYS/MINGW64 environment, which will be modified to allow building Emacs and all tools. Use this version at your own risk. 22 | 23 | ### Steps 24 | 25 | 1. Download or clone the script from GitHub 26 | 2. Open a Windows terminal and move to the folder for this script 27 | 3. Issue whatever commands you need, such as `.\emacs-build.cmd --clone --deps --build --pack-emacs` 28 | 4. Inspect the `zips` folder for the products of the script 29 | 30 | ### General options 31 | 32 | ```` 33 | Usage: 34 | emacs-build [--version] [--help] [--features] 35 | [--branch b] [--clone] [--build] [--deps] 36 | [--slim] [--[no-]compress] [--[no-]strip] 37 | [--with-all] [--without-X] [--with-X] 38 | [--pdf-tools] [--aspell] [--hunspell] [--mu] [--isync] 39 | [--pack-emacs] [--pack-all] 40 | Actions: 41 | --build Configure and build Emacs from sources. 42 | --clean Remove all directories except sources and zip files. 43 | --clone Download Savannah's git repository for Emacs. 44 | --deps Create a ZIP file with all the Mingw64/32 dependencies. 45 | --help Output this help message, --features and exit. 46 | --pack-emacs Package an Emacs previously built with the --build option. 47 | --pack-all Package an Emacs previously built, with all the Mingw64/32 48 | dependencies, as well as all extensions (see Extensions below). 49 | --features Shows all active and inactive features for the selected options. 50 | --version Output emacs-build version number and exit. 51 | 52 | Multiple actions can be selected. The default is to run them all in a logical 53 | order: clone, build, deps and pack-all. 54 | 55 | Build options: 56 | --branch b Select Emacs branch (or tag) 'b' for the remaining operations. 57 | --compress Ship Emacs with gunzip and compress documentation and Emacs 58 | script files. 59 | --debug Output all statements run by the script. 60 | --debug-dependencies 61 | Describe which MSYS/MINGW packages depend on which, and 62 | which files are discarded from the ZIP files. 63 | --no-strip Disable the --strip option. 64 | --no-compress Disable the --compress option. 65 | --slim Remove Cairo, SVG and TIFF support for a slimmer build. 66 | Remove also documentation files and other support files 67 | from the dependencies file. Activate --compress and 68 | --strip. (Default configuration) 69 | --strip Strip executables and DLL's from debug information. 70 | --with-all Add all Emacs features. 71 | --with-* Add requested feature in the dependencies and build 72 | * is any of the known features for emacs in Windows/Mingw 73 | (see --features). 74 | --without-* Remove requested feature in the dependencies and build. 75 | 76 | Options are processed in order. Thus --slim followed by --with-cairo 77 | would enable Cairo, even though --slim removes it. 78 | 79 | Extensions: 80 | --pdf-tools Build and package PDF-TOOLS. 81 | --hunspell Install Hunspell spell checker. 82 | --aspell Install Aspell spell checker. 83 | --mu Mail search system and supporting Emacs mu4e libraries. 84 | --isync Synchronize email from IMAP/POP to Maildir format (mbsync). 85 | ```` 86 | 87 | ### An example 88 | 89 | Assume you invoke this script as follows 90 | ```` 91 | .\emacs-build.cmd --slim --clone --deps --build --pdf-tools --hunspell --mu --isync --pack-all 92 | ```` 93 | 94 | It will take care of the following tasks 95 | 96 | 1. Download the latest release of MSYS 97 | 2. Download a minimal set of MSYS and MINGW programs needed to build Emacs and the extensions 98 | 3. Clone the latest emacs repository on the branch emacs-27 99 | 4. Ensure that all required packages Mingw64 are installed, or install them. 100 | 5. Configure and build Emacs using those packages 101 | 6. Pack all the dependencies into a ZIP file. 102 | 7. Download and build pdf-tools, hunspell, mu and isync (plus xapian and gmime3). In the process, ensure that the required packages are also installed. 103 | 8. Create a ZIP file with Emacs, all the dependencies and all the extensions. 104 | 105 | The script, just like its creator, is a bit opinionated. The default build (without arguments), assumes --slim and performs takes some extra steps to reduce the size of the distribution 106 | 107 | - It eliminates the manual pages and large documentation files for the libraries that are used by Emacs. 108 | - It eliminates the library files (*.a). 109 | - It strips the executable files and DLL's from debugging information. 110 | 111 | 112 | ### Considerations 113 | 114 | There are implicit dependencies in the various actions: 115 | 116 | - `--clone` is required to get the sources 117 | - `--build` is assumed to be run before `--pack-all` or `--pack-emacs`, and also before the extensions. 118 | 119 | Note that `--clean` or `--clean-all` do not remove the `msys64` directory, because it is very time consuming to create and update it. 120 | 121 | The tool produces zip files that are stored in `./zips` and can be uncompressed wherever you want: 122 | 123 | - `emacs-xx-xxxx-deps.zips` is the file with optional libraries (png, jpeg, etc) used by Emacs. 124 | - `emacs-xx-xxxx-nodeps.zip` is a bare Emacs installation. It runs even if the 'deps' file is not used 125 | - `emacs-xx-xxxx-full.zip` is a complete Emacs installation, with the optional libraries and all extensions (pdf-tools, mu, etc) you mentioned in the command line. 126 | - `pdf-tools-xxxx.zip` and others are the Zip files for the extensions. They can be unpacked inside an Emacs installation, but may assume that 'deps' have also been unpacked. 127 | 128 | Regarding the extensions to Emacs and third-party utilities: 129 | 130 | - They can be built separately from Emacs. 131 | - If `c:\emacs` is where you unpacked the full installation, some extensions will reside in `c:\emacs\bin` (e.g. pdftools) and some others in `c:\emacs\usr\bin` (e.g. mu and mbsync). 132 | - Even though elisp files are provided, it is highly recommended that you install pdf-tools and mu4e from Melpa or other repositories, to properly take care of dependencies from other elisp libraries. 133 | 134 | 135 | ## TO-DO 136 | 137 | - Consider GitHub actions for automated continuous integration and release 138 | system. References: 139 | - Setting up an MSYS/MINGW system https://github.com/marketplace/actions/setup-msys2 140 | - MINGW packages recipes https://github.com/msys2/MINGW-packages/blob/master/.github/workflows/main.yml 141 | - Uploading artifacts https://github.com/actions/upload-artifact 142 | - https://github.com/actions/create-release 143 | 144 | # Changelog 145 | 146 | ## v0.1 147 | 148 | - First version of the script, to be run from a preexisting MSYS2/MINGW environment. 149 | 150 | ## v0.2 151 | 152 | - New version of the script using also Windows shell and powershell scripts. 153 | - The script downloads and creates a fresh new MSYS2/MINGW environment to build Emacs. 154 | - Fixed some dependency issues, whereby MINGW packages depended on MSYS2 /usr directories. 155 | 156 | ## v0.3 157 | 158 | - Improved help text. 159 | - New option --compress, which ships gzip with Emacs and compresses non-essential files. 160 | - Option --slim is now default. 161 | - Emacs ships with a `site-start.el` that activates the directories for MSYS2 extensions. 162 | - Only one branch of Emacs can be built. 163 | - emacs-build no longer uses log files. 164 | 165 | ## v0.3.1 166 | 167 | - Emacs-build upgrades GNU TLS version to at least 3.7.0, to allow safe https to MELPA. 168 | 169 | ## v0.3.2 170 | 171 | - Undo the fix to GNU TLS, because this library is no longer available for download. 172 | - Simplify and correct the process to detect dependencies between packages. 173 | - Only remove non-essential data from executables (fix how we call 'strip'). 174 | - Enforce Emacs' latest stable release as default. 175 | - Add hunspell and aspell from MINGW, replacing the one downloaded from Sourceforge. 176 | - Cleanup of the build rules. 177 | - Add tests for the extensions. 178 | - Fix the behavior of --slim and --not-slim with respect to features. 179 | 180 | ## v0.4 181 | 182 | - Clarify the order of execution of command line options. 183 | - Remove --not-slim. 184 | - Add --strip, and --with-all. 185 | - Construct --slim out of --with-all, --without-*, --compress and --strip, so that users can counteract their behavior. 186 | -------------------------------------------------------------------------------- /certs/emacs-cert.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kiennq/emacs-build/9e517fae8fba1f50cc5657422105a094760eb02b/certs/emacs-cert.pfx -------------------------------------------------------------------------------- /emacs-build-unix.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function write_help () { 4 | printf "Usage: ./emacs-build-linux.sh [--version|-v ] 5 | [--src|-s ] 6 | [--dest|-d ] 7 | [-?|-h|--help] 8 | []\n" 9 | } 10 | 11 | emacs_pkg_version="0.0.0.0" 12 | emacs_build_flags="" 13 | emacs_dest_dir="$(pwd)" 14 | emacs_src_dir="$(pwd)" 15 | 16 | while test -n "$*"; do 17 | case $1 in 18 | --version|-v) shift; emacs_pkg_version="$1";; 19 | --dest|-d) shift; emacs_dest_dir="$(readlink -f $1)";; 20 | --src|-s) shift; emacs_src_dir="$(readlink -f $1)";; 21 | -?|-h|--help) write_help; exit 0;; 22 | *) emacs_build_flags="$emacs_build_flags $1";; 23 | esac 24 | shift 25 | done 26 | 27 | echo emacs_src_dir=$emacs_src_dir 28 | echo emacs_dest_dir=$emacs_dest_dir 29 | echo emacs_pkg_version=$emacs_pkg_version 30 | echo emacs_build_flags=$emacs_build_flags 31 | 32 | cd $emacs_src_dir 33 | 34 | render_libs="libtiff-dev librsvg2-dev libxpm-dev libjpeg-dev libpng-dev libgif-dev libgtk-3-dev libharfbuzz-dev" 35 | render_deps="libtiff5,librsvg2-2,libxpm4,libjpeg9,libgif7,libpng16-16,libgtk-3-0,libharfbuzz0b" 36 | 37 | sudo add-apt-repository -y ppa:ubuntu-toolchain-r/ppa 38 | sudo apt update 39 | # libtree-sitter-dev is only supported from Jammy (22.04) 40 | sudo apt install -y dpkg-dev autoconf make texinfo $render_libs libgnutls28-dev \ 41 | libncurses-dev libsystemd-dev libgccjit-11-dev gcc-11 libxt-dev \ 42 | libtree-sitter-dev curl 43 | export CC=/usr/bin/gcc-11 CXX=/usr/bin/gcc-11 44 | 45 | ./autogen.sh 46 | 47 | arch=$(dpkg-architecture -q DEB_BUILD_ARCH) 48 | # pkg_name=emacs-dev_${emacs_pkg_version}_$arch 49 | deb_dir=$(pwd)/deb_pkg 50 | mkdir -p $deb_dir/usr/local/ 51 | 52 | echo arch=$arch 53 | echo deb_dir=$deb_dir 54 | # echo pkg_name=$pkg_name 55 | 56 | ./configure CFLAGS="-Ofast -fno-finite-math-only -fomit-frame-pointer" \ 57 | --prefix=/usr/local/ \ 58 | --with-included-regex --with-native-compilation \ 59 | --with-small-ja-dic --with-x-toolkit=lucid --with-xwidgets $emacs_build_flags \ 60 | --with-sound=no --without-gpm --without-dbus \ 61 | --without-pop --without-mailutils --without-gsettings \ 62 | --with-all 63 | 64 | echo "Initial make" 65 | make -j$((`nproc` * 2)) 66 | if [ $? -ne 0 ]; then 67 | exit -1 68 | fi 69 | 70 | echo "Make install" 71 | make install-strip DESTDIR=$deb_dir 72 | 73 | # create control file 74 | echo "Create deb package" 75 | mkdir -p $deb_dir/DEBIAN 76 | 77 | cat > $deb_dir/DEBIAN/control << EOF 78 | Package: emacs-dev 79 | Version: $emacs_pkg_version 80 | Architecture: $arch 81 | Maintainer: www.gnu.org/software/emacs/ 82 | Description: GNU Emacs 83 | Depends: libgccjit0,libtree-sitter0,${render_deps} 84 | EOF 85 | 86 | dpkg-deb --build -z9 --root-owner-group $deb_dir $emacs_dest_dir 87 | -------------------------------------------------------------------------------- /emacs-build.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | if x%1 == x goto default 3 | if %1 == --default-nativecomp goto nativecomp 4 | if %1 == --clean goto clean 5 | if %1 == --clean-all goto cleanall 6 | if %1==--help goto help 7 | if %1==-h goto help 8 | if %1==-? goto help 9 | goto run 10 | 11 | :cleanall 12 | cd %~dp0 && for %%i in (git build zips pkg) do if exist %%i rmdir /S /Q %%i 13 | goto:eof 14 | 15 | :clean 16 | cd %~dp0 && for %%i in (build pkg) do if exist %%i rmdir /S /Q %%i 17 | goto:eof 18 | 19 | :default 20 | emacs-build.cmd --clone --deps --build --pack-emacs --pdf-tools --mu --isync --aspell --pack-all 21 | goto:eof 22 | 23 | :nativecomp 24 | emacs-build.cmd --nativecomp --clone --deps --build --pack-emacs --pdf-tools --mu --isync --aspell --pack-all 25 | goto:eof 26 | 27 | :help 28 | cd %~dp0 29 | powershell -noprofile -c scripts\setup-msys2.ps1 30 | .\scripts\msys2.cmd -c "./emacs-build.sh --help" 31 | goto:eof 32 | 33 | :run 34 | cd %~dp0 35 | powershell -noprofile -c scripts\setup-msys2.ps1 36 | .\scripts\msys2.cmd -c "./emacs-build.sh %*" 37 | -------------------------------------------------------------------------------- /emacs-build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2020 Juan Jose Garcia-Ripoll 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a copy 5 | # of this software and associated documentation files (the "Software"), to deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # copies of the Software, and to permit persons to whom the Software is 9 | # furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included in all 12 | # copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | # 22 | ######################################## 23 | # 24 | # EMACS-BUILD 25 | # 26 | # Standalone script to build Emacs from a running copy of Mingw64. It immitates 27 | # the steps that Emacs developers can take to build the standard distributions. 28 | # See write_help below for all options. 29 | # 30 | 31 | . scripts/tools.sh 32 | . scripts/pdf-tools.sh 33 | . scripts/aspell.sh 34 | . scripts/hunspell.sh 35 | . scripts/msys2_extra.sh 36 | . scripts/gnutls.sh 37 | 38 | function write_help () { 39 | echo "Emacs-build tool version $emacs_build_version, (c) 2020 Juan Jose Garcia-Ripoll" 40 | cat "$emacs_build_root/scripts/help.txt" 41 | echo 42 | write_features 43 | } 44 | 45 | function write_features () { 46 | # local inactive="" 47 | # for f in $all_features; do 48 | # if [[ ! " $features " =~ .*$f ]]; then 49 | # inactive="$f $inactive" 50 | # fi 51 | # done 52 | 53 | echo "Compressed installation: $emacs_compress_files" 54 | echo "Strip executables: $emacs_strip_executables" 55 | echo "Emacs features:" 56 | for f in $features; do echo " --with-$f"; done 57 | for f in $inactive_features; do echo " --without-$f"; done 58 | } 59 | 60 | function write_version_number () 61 | { 62 | echo $emacs_build_version 63 | exit 0 64 | } 65 | 66 | function check_mingw_architecture () 67 | { 68 | mingw_dir="/${MSYSTEM,,}/" 69 | case "$MSYSTEM" in 70 | MINGW32) architecture=i686 71 | mingw_prefix="mingw-w64-$architecture" 72 | build_type="i686-w64-mingw32" 73 | ;; 74 | MINGW64) architecture=x86_64 75 | mingw_prefix="mingw-w64-$architecture" 76 | build_type="x86_64-w64-mingw32" 77 | ;; 78 | UCRT64) architecture=ucrt-x86_64 79 | mingw_prefix="mingw-w64-$architecture" 80 | build_type="x86_64-w64-mingw32" 81 | ;; 82 | CLANGARM64) architecture=clang-aarch64 83 | mingw_prefix="mingw-w64-$architecture" 84 | build_type="x86_64-w64-mingw32" 85 | ;; 86 | MSYS) echo This tool cannot be ran from an MSYS shell. 87 | echo Please open a Ucrt64/Mingw64/Mingw32 terminal. 88 | echo 89 | exit -1 90 | ;; 91 | *) echo This tool must be run from a Ucrt64/Mingw64/Mingw32 terminal. 92 | echo 93 | exit -1 94 | esac 95 | } 96 | 97 | function ensure_mingw_build_software () 98 | { 99 | echo Install essential packages 100 | local build_packages="git zip unzip base-devel ${mingw_prefix}-toolchain autoconf automake" 101 | pacman --noprogressbar --noconfirm --needed -S $build_packages >/dev/null 2>&1 102 | if test "$?" != 0; then 103 | echo Unable to install $build_packages 104 | echo Giving up 105 | exit -1 106 | fi 107 | if [ -z "`which git 2>&1`" ]; then 108 | echo Installing Git for MSYS2 109 | pacman -S --noconfirm --needed git 110 | if test "$?" != 0; then 111 | echo Unable to install Git 112 | echo Giving up 113 | exit -1 114 | fi 115 | fi 116 | } 117 | 118 | 119 | function emacs_root_packages () 120 | { 121 | local feature_selector=`echo $features | sed -e 's, ,|,g'` 122 | feature_list | grep -E "$feature_selector" | cut -d ' ' -f 2- | sed -e "s,mingw-,${mingw_prefix}-,g" 123 | } 124 | 125 | function emacs_dependencies () 126 | { 127 | # Print the list of all mingw/msys packages required for running emacs with 128 | # the selected features. Cache the result value. 129 | # 130 | if test -z "$emacs_dependencies"; then 131 | errcho Inspecting required packages for build features 132 | errcho $features 133 | local packages=`emacs_root_packages` 134 | # emacs_dependencies=`full_dependency_list "$packages" "${mingw_prefix}-glib2" "Emacs"` 135 | emacs_dependencies=`full_dependency_list "$packages" "" "Emacs"` 136 | errcho Total packages required: 137 | for p in $emacs_dependencies; do 138 | errcho " $p" 139 | done 140 | fi 141 | echo $emacs_dependencies 142 | } 143 | 144 | function emacs_configure_build_dir () 145 | { 146 | cd "$emacs_build_dir" 147 | options="$emacs_build_options" 148 | if test "$emacs_compress_files" = "no"; then 149 | options="$options --without-compress-install" 150 | else 151 | options="$options --with-compress-install" 152 | fi 153 | 154 | # if test "$emacs_slim_build" = "yes"; then 155 | # options="$options --with-small-ja-dic" 156 | # fi 157 | 158 | # for f in $all_features; do 159 | # if echo $features | grep $f > /dev/null; then 160 | # options="--with-$f $options" 161 | # else 162 | # options="--without-$f $options" 163 | # fi 164 | # done 165 | for f in $features; do 166 | options="$options --with-$f" 167 | done 168 | 169 | for f in $inactive_features; do 170 | options="$options --without-$f" 171 | done 172 | 173 | echo Configuring Emacs with options 174 | echo "$emacs_source_dir/configure" "--prefix=$emacs_install_dir" CFLAGS="$CFLAGS" $options 175 | if "$emacs_source_dir/configure" "--prefix=$emacs_install_dir" CFLAGS="$CFLAGS" $options; then 176 | echo Emacs configured 177 | else 178 | echo Configuration failed 179 | return -1 180 | fi 181 | } 182 | 183 | function action0_clean () 184 | { 185 | rm -rf "$emacs_build_build_dir" "$emacs_build_install_dir" 186 | } 187 | 188 | function action0_clean_rest () 189 | { 190 | rm -rf "$emacs_build_git_dir" "$emacs_build_zip_dir" msys2-upgraded.log 191 | exit 0 192 | } 193 | 194 | function action0_clone () 195 | { 196 | clone_repo "$emacs_branch" "$emacs_repo" "$emacs_source_dir" 197 | if test "$emacs_apply_patches" = "yes"; then 198 | apply_patches "$emacs_source_dir" || true 199 | fi 200 | } 201 | 202 | function action1_ensure_packages () 203 | { 204 | # Collect the list of packages required for running Emacs, and ensure they 205 | # have been installed. 206 | # 207 | ensure_packages `emacs_root_packages` 208 | } 209 | 210 | function action2.0_prep_build () 211 | { 212 | echo Preparing build directory 213 | prepare_source_dir $emacs_source_dir \ 214 | && prepare_build_dir $emacs_build_dir \ 215 | && emacs_configure_build_dir && return 0 216 | 217 | echo Configuration failed 218 | return -1 219 | } 220 | 221 | function action2.1_build () 222 | { 223 | echo Start building 224 | rm -f "$emacs_install_dir/bin/emacs.exe" 225 | 226 | echo Building Emacs in directory $emacs_build_dir 227 | 228 | make -j $emacs_build_threads -C $emacs_build_dir && return 0 229 | 230 | echo Build process failed 231 | return 1 232 | } 233 | 234 | function action2.2_install () 235 | { 236 | if test -f "$emacs_install_dir/bin/emacs.exe"; then 237 | echo $emacs_install_dir/bin/emacs.exe exists 238 | echo Refusing to reinstall 239 | else 240 | rm -rf "$emacs_install_dir" 241 | mkdir -p "$emacs_install_dir/bin" 242 | if test "$emacs_compress_files" = "yes"; then 243 | # If we compress files we need to install gzip no matter what 244 | # (even in pack-emacs) 245 | (ensure_packages gzip \ 246 | && cp_bindeps_to "$emacs_install_dir/bin" gzip.exe) \ 247 | || return -1 248 | fi 249 | echo Installing Emacs into directory $emacs_install_dir 250 | # HACK!!! Somehow libgmp is not installed as part of the 251 | # standalone Emacs build process. This is weird, but means 252 | # we have to copy it by hand. 253 | 254 | make -j $emacs_build_threads -C $emacs_build_dir install \ 255 | && cp "${mingw_dir}bin/libgmp"*.dll "$emacs_install_dir/bin/" \ 256 | && rm -f "$emacs_install_dir/bin/emacs-"*.exe \ 257 | && emacs_build_strip_exes "$emacs_install_dir" \ 258 | && cp "$emacs_build_root/scripts/site-start.el" "$emacs_install_dir/share/emacs/site-lisp" \ 259 | && mkdir -p "$emacs_install_dir/usr/share/emacs/site-lisp/" \ 260 | && cp "$emacs_install_dir/share/emacs/site-lisp/subdirs.el" \ 261 | "$emacs_install_dir/usr/share/emacs/site-lisp/subdirs.el" 262 | fi 263 | } 264 | 265 | function emacs_build_strip_exes () 266 | { 267 | local dir="$1" 268 | if [ "$emacs_strip_executables" = "yes" ]; then 269 | find "$dir" -name '*.exe' -exec strip -g --strip-unneeded '{}' '+' 270 | fi 271 | } 272 | 273 | function action3_package_deps () 274 | { 275 | # Collect the list of packages required for running Emacs, gather the files 276 | # from those packages and compress them into $emacs_depsfile 277 | # 278 | package_dependencies "$emacs_depsfile" "`emacs_dependencies`" 279 | } 280 | 281 | function write_source_info () 282 | { 283 | cd "$emacs_full_install_dir" 284 | cat < source_info.txt 285 | repo: $emacs_repo 286 | branch/commit: $emacs_branch 287 | EOF 288 | } 289 | 290 | function action4_package_emacs () 291 | { 292 | # Package a prebuilt emacs with and without the required dependencies, ready 293 | # for distribution. 294 | # 295 | if test ! -f $emacs_depsfile; then 296 | echo Missing dependency file $emacs_depsfile. Run with --deps first. 297 | return -1 298 | fi 299 | rm -f "$emacs_nodepsfile" "$emacs_srcfile" 300 | mkdir -p `dirname "$emacs_nodepsfile"` 301 | cd "$emacs_install_dir" 302 | if zip -9r "$emacs_nodepsfile" *; then 303 | echo Built $emacs_nodepsfile; echo 304 | else 305 | echo Failed to compress distribution file $emacs_nodepsfile; echo 306 | return -1 307 | fi 308 | write_source_info 309 | cd "$emacs_source_dir" 310 | if zip -x '.git/*' -9r "$emacs_srcfile" *; then 311 | echo Built source package $emacs_srcfile 312 | else 313 | echo Failed to compress sources $emacs_srcfile; echo 314 | return -1 315 | fi 316 | } 317 | 318 | function action5_package_all () 319 | { 320 | for zipfile in "$emacs_depsfile" $emacs_extensions; do 321 | if test ! -f "$zipfile"; then 322 | echo Missing zip file `basename $zipfile.` Cannot build full distribution. 323 | echo Please use --deps, --build and all extension options before --pack-all. 324 | echo 325 | return -1 326 | fi 327 | done 328 | rm -rf "$emacs_full_install_dir" 329 | if cp -rfp "$emacs_install_dir" "$emacs_full_install_dir"; then 330 | rm -f "${emacs_distfile}" 331 | cd "$emacs_full_install_dir" 332 | for zipfile in "$emacs_depsfile" $emacs_extensions; do 333 | echo Unzipping $zipfile 334 | if unzip -ox $zipfile; then 335 | echo Done!; 336 | else 337 | echo Failed to unzip $zipfile 338 | return -1 339 | fi 340 | done 341 | 342 | emacs_build_strip_exes "$emacs_full_install_dir" 343 | find . -type f | sort | list_filter -i "$packing_slim_exclusion" | xargs rm -f 344 | write_source_info 345 | 346 | if test "$emacs_pkg_msix" = "yes"; then 347 | man_file=`cygpath -w "$emacs_build_root/template/appxmanifest.t.xml"` 348 | pkg_version="${EMACS_PKG_VERSION:-0.0.0.0}" 349 | dist_file=`cygpath -w "$emacs_build_root/zips/${emacs_pkg_prefix}.msix"` 350 | script_file=`cygpath -w "$emacs_build_root/scripts/create_msix.ps1"` 351 | cert_file=`cygpath -w "$emacs_build_root/certs/emacs-cert.pfx"` 352 | secret="${EMACS_CERT_SECRET:-cert!emacs}" 353 | 354 | echo Creating $dist_file package with version $pkg_version 355 | powershell.exe -nop -ex bypass -c "& {$script_file -m $man_file -v $pkg_version -d . -p $dist_file -c $cert_file -s $secret}" 356 | else 357 | echo Creating zip package 358 | zip -9 -r "${emacs_distfile}" * 359 | fi 360 | fi 361 | } 362 | 363 | function feature_list () { 364 | cat <&1 ; then 585 | echo Action $action succeeded. 586 | else 587 | echo Action $action failed. 588 | echo Aborting builds for branch $emacs_branch and architecture $architecture 589 | exit -1 590 | fi 591 | done 592 | -------------------------------------------------------------------------------- /patches/emacs/.deprecated/0001-MPS-Make-one_w32_display_info-an-ambiguous-root.patch: -------------------------------------------------------------------------------- 1 | From ff52ce521ef9b5b295d1387543efba9a07d10852 Mon Sep 17 00:00:00 2001 2 | From: Pip Cet 3 | Subject: [PATCH] [MPS] Make one_w32_display_info an ambiguous root 4 | 5 | * src/w32term.c (w32_initialize_display_info): Create root 6 | 7 | --- 8 | src/w32term.c | 6 ++++++ 9 | 1 file changed, 6 insertions(+) 10 | 11 | diff --git a/src/w32term.c b/src/w32term.c 12 | index ba745c0835..d248fe6b3a 100644 13 | --- a/src/w32term.c 14 | +++ b/src/w32term.c 15 | @@ -47,6 +47,7 @@ Copyright (C) 1989, 1993-2025 Free Software Foundation, Inc. 16 | #include "window.h" 17 | #include "keyboard.h" 18 | #include "menu.h" /* for w32_menu_show */ 19 | +#include "igc.h" 20 | 21 | #ifdef WINDOWSNT 22 | #include "w32.h" /* for filename_from_utf16, filename_from_ansi */ 23 | @@ -7725,6 +7726,11 @@ w32_initialize_display_info (Lisp_Object display_name) 24 | { 25 | struct w32_display_info *dpyinfo = &one_w32_display_info; 26 | 27 | +#ifdef HAVE_MPS 28 | + igc_root_create_ambig (&one_w32_display_info, &one_w32_display_info + 1, 29 | + "w32-display-info"); 30 | +#endif 31 | + 32 | memset (dpyinfo, 0, sizeof (*dpyinfo)); 33 | 34 | dpyinfo->name_list_element = Fcons (display_name, Qnil); 35 | -- 36 | 2.48.1 37 | 38 | -------------------------------------------------------------------------------- /patches/emacs/.deprecated/0001-print_object-call-with-correct-parameters-for-native.patch: -------------------------------------------------------------------------------- 1 | From 484f55a5cea5ba8b72cf6cfe464a057f87687858 Mon Sep 17 00:00:00 2001 2 | From: Kien Nguyen 3 | Date: Thu, 22 May 2025 16:01:51 -0700 4 | Subject: [PATCH] print_object: call with correct parameters for native-comp 5 | 6 | --- 7 | src/print.c | 4 ++-- 8 | 1 file changed, 2 insertions(+), 2 deletions(-) 9 | 10 | diff --git a/src/print.c b/src/print.c 11 | index 9121db429..25061fa4d 100644 12 | --- a/src/print.c 13 | +++ b/src/print.c 14 | @@ -2098,9 +2098,9 @@ print_vectorlike_unreadable (Lisp_Object obj, bool escapeflag, char *buf, 15 | { 16 | struct Lisp_Native_Comp_Unit *cu = XNATIVE_COMP_UNIT (obj); 17 | print_c_string ("#file, printcharfun, escapeflag); 19 | + print_object (cu->file, escapeflag, pc); 20 | printchar (' ', printcharfun); 21 | - print_object (cu->optimize_qualities, printcharfun, escapeflag); 22 | + print_object (cu->optimize_qualities, escapeflag, pc); 23 | printchar ('>', printcharfun); 24 | return; 25 | } 26 | -- 27 | 2.49.0.windows.1 28 | 29 | -------------------------------------------------------------------------------- /patches/emacs/.deprecated/0006-Windows-unaligned-jmpbuf-support.patch: -------------------------------------------------------------------------------- 1 | From 4e329a7bdd31a56025a1ad3cda2c9ff251fc2586 Mon Sep 17 00:00:00 2001 2 | From: Pip Cet 3 | Date: Sun, 27 Oct 2024 18:27:46 -0700 4 | Subject: [PATCH 06/10] Windows: unaligned jmpbuf support 5 | 6 | --- 7 | src/alloc.c | 2 +- 8 | src/comp.c | 165 +++++++++++++++++++++++++++++++++++++++++----------- 9 | src/lisp.h | 29 +++++++++ 10 | 3 files changed, 160 insertions(+), 36 deletions(-) 11 | 12 | diff --git a/src/alloc.c b/src/alloc.c 13 | index d7f0369975..645c10f074 100644 14 | --- a/src/alloc.c 15 | +++ b/src/alloc.c 16 | @@ -2971,7 +2971,7 @@ DEFUN ("make-list", Fmake_list, Smake_list, 2, 2, 0, 17 | Vector Allocation 18 | ***********************************************************************/ 19 | /* Vector size requests are a multiple of this. */ 20 | -enum { roundup_size = COMMON_MULTIPLE (LISP_ALIGNMENT, word_size) }; 21 | +enum { roundup_size = COMMON_MULTIPLE (word_size, word_size) }; 22 | 23 | /* Round up X to nearest mult-of-ROUNDUP_SIZE --- use at compile time. */ 24 | #define vroundup_ct(x) ROUNDUP (x, roundup_size) 25 | diff --git a/src/comp.c b/src/comp.c 26 | index 0a4d4c255c..6d9699afc3 100644 27 | --- a/src/comp.c 28 | +++ b/src/comp.c 29 | @@ -521,6 +521,25 @@ #define DECL_BLOCK(name, func) \ 30 | #endif 31 | #define SETJMP_NAME SETJMP 32 | 33 | +#if defined(WINDOWSNT) 34 | +void *setjmp_real_buffer (sys_jmp_buf j) 35 | +{ 36 | + char *target = (char *)j->raw; 37 | + bool bad = (unsigned long long)target & 8; 38 | + if (bad) { 39 | + target += 8; 40 | + } 41 | + return target; 42 | +} 43 | + 44 | +int setjmp_fixup (sys_jmp_buf j, int ret) 45 | +{ 46 | + memmove (j->raw, setjmp_real_buffer (j), sizeof (j->raw)); 47 | + 48 | + return ret; 49 | +} 50 | +#endif 51 | + 52 | /* Max number function importable by native-compiled code. */ 53 | #define F_RELOC_MAX_SIZE 1600 54 | 55 | @@ -699,7 +718,12 @@ helper_sanitizer_assert (Lisp_Object, Lisp_Object); 56 | /* Note: helper_link_table must match the list created by 57 | `declare_runtime_imported_funcs'. */ 58 | static void *helper_link_table[] = 59 | - { wrong_type_argument, 60 | + { 61 | +#ifdef WINDOWSNT 62 | + setjmp_fixup, 63 | + setjmp_real_buffer, 64 | +#endif 65 | + wrong_type_argument, 66 | helper_PSEUDOVECTOR_TYPEP_XUNTAG, 67 | push_handler, 68 | record_unwind_protect_excursion, 69 | @@ -2177,33 +2201,88 @@ emit_setjmp (gcc_jit_rvalue *buf) 70 | 71 | return gcc_jit_context_new_call (comp.ctxt, NULL, f, 1, args); 72 | #else 73 | - /* _setjmp (buf, __builtin_frame_address (0)) */ 74 | - gcc_jit_param *params[] = 75 | + /* setjmp_fixup (buf, _setjmp (setjmp_real_buffer (buf), 76 | + __builtin_frame_address (0))) */ 77 | + gcc_jit_rvalue *frame_address; 78 | + gcc_jit_rvalue *real_buffer; 79 | + gcc_jit_rvalue *setjmp_result; 80 | + 81 | { 82 | - gcc_jit_context_new_param (comp.ctxt, NULL, comp.void_ptr_type, "buf"), 83 | - gcc_jit_context_new_param (comp.ctxt, NULL, comp.void_ptr_type, "frame"), 84 | - }; 85 | - gcc_jit_rvalue *args[2]; 86 | + gcc_jit_rvalue *args[] = 87 | + { 88 | + gcc_jit_context_new_rvalue_from_int (comp.ctxt, comp.unsigned_type, 0), 89 | + }; 90 | + frame_address = 91 | + gcc_jit_context_new_call (comp.ctxt, 92 | + NULL, 93 | + gcc_jit_context_get_builtin_function (comp.ctxt, 94 | + "__builtin_frame_address"), 95 | + ARRAYELTS (args), args); 96 | + } 97 | 98 | - args[0] = 99 | - gcc_jit_context_new_rvalue_from_int (comp.ctxt, comp.unsigned_type, 0); 100 | + { 101 | + gcc_jit_rvalue *args[] = 102 | + { 103 | + buf, 104 | + }; 105 | + gcc_jit_param *params[] = 106 | + { 107 | + gcc_jit_context_new_param (comp.ctxt, NULL, comp.void_ptr_type, "buf"), 108 | + }; 109 | + gcc_jit_function *f = 110 | + gcc_jit_context_new_function (comp.ctxt, NULL, 111 | + GCC_JIT_FUNCTION_IMPORTED, 112 | + comp.void_ptr_type, "setjmp_real_buffer", 113 | + ARRAYELTS (params), params, 114 | + false); 115 | + real_buffer = 116 | + emit_call (intern_c_string ("setjmp_real_buffer"), comp.void_ptr_type, 117 | + ARRAYELTS (args), args, false); 118 | + } 119 | 120 | - args[1] = 121 | - gcc_jit_context_new_call ( 122 | - comp.ctxt, 123 | - NULL, 124 | - gcc_jit_context_get_builtin_function (comp.ctxt, 125 | - "__builtin_frame_address"), 126 | - 1, args); 127 | - args[0] = buf; 128 | - gcc_jit_function *f = 129 | - gcc_jit_context_new_function (comp.ctxt, NULL, 130 | - GCC_JIT_FUNCTION_IMPORTED, 131 | - comp.int_type, STR (SETJMP_NAME), 132 | - ARRAYELTS (params), params, 133 | - false); 134 | + { 135 | + gcc_jit_param *params[] = 136 | + { 137 | + gcc_jit_context_new_param (comp.ctxt, NULL, comp.void_ptr_type, "buf"), 138 | + gcc_jit_context_new_param (comp.ctxt, NULL, comp.void_ptr_type, "frame"), 139 | + }; 140 | + gcc_jit_rvalue *args[] = 141 | + { 142 | + real_buffer, 143 | + frame_address, 144 | + }; 145 | + gcc_jit_function *f = 146 | + gcc_jit_context_new_function (comp.ctxt, NULL, 147 | + GCC_JIT_FUNCTION_IMPORTED, 148 | + comp.int_type, STR (SETJMP_NAME), 149 | + ARRAYELTS (params), params, 150 | + false); 151 | + setjmp_result = 152 | + gcc_jit_context_new_call (comp.ctxt, 153 | + NULL, 154 | + f, 155 | + ARRAYELTS (args), args); 156 | + } 157 | 158 | - return gcc_jit_context_new_call (comp.ctxt, NULL, f, 2, args); 159 | + { 160 | + gcc_jit_param *params[] = 161 | + { 162 | + gcc_jit_context_new_param (comp.ctxt, NULL, comp.void_ptr_type, "buf"), 163 | + gcc_jit_context_new_param (comp.ctxt, NULL, comp.int_type, "ret"), 164 | + }; 165 | + gcc_jit_rvalue *args[] = 166 | + { 167 | + buf, 168 | + setjmp_result, 169 | + }; 170 | + gcc_jit_function *f = 171 | + gcc_jit_context_new_function (comp.ctxt ,NULL, 172 | + GCC_JIT_FUNCTION_IMPORTED, 173 | + comp.int_type, "setjmp_fixup", 174 | + ARRAYELTS (params), params, false); 175 | + return emit_call (intern_c_string ("setjmp_fixup"), comp.int_type, 176 | + ARRAYELTS (args), args, false); 177 | + } 178 | #endif 179 | } 180 | 181 | @@ -2917,6 +2996,15 @@ #define ADD_IMPORTED(f_name, ret_type, nargs, args) \ 182 | 183 | gcc_jit_type *args[4]; 184 | 185 | +#ifdef WINDOWSNT 186 | + args[0] = comp.void_ptr_type; 187 | + args[1] = comp.int_type; 188 | + ADD_IMPORTED (setjmp_fixup, comp.int_type, 2, args); 189 | + 190 | + args[0] = comp.void_ptr_type; 191 | + ADD_IMPORTED (setjmp_real_buffer, comp.void_ptr_type, 1, args); 192 | +#endif 193 | + 194 | ADD_IMPORTED (wrong_type_argument, comp.void_type, 2, NULL); 195 | 196 | args[0] = comp.lisp_obj_type; 197 | @@ -5135,21 +5223,28 @@ maybe_defer_native_compilation (Lisp_Object function_name, 198 | || !NILP (Fgethash (Vload_true_file_name, V_comp_no_native_file_h, Qnil))) 199 | return; 200 | 201 | - Lisp_Object src = 202 | - concat2 (CALLNI (file-name-sans-extension, Vload_true_file_name), 203 | - build_string (".el")); 204 | - if (NILP (Ffile_exists_p (src))) 205 | + if (Ffboundp (intern_c_string ("file-name-sans-extension"))) 206 | { 207 | - src = concat2 (src, build_string (".gz")); 208 | + Lisp_Object src = 209 | + concat2 (CALLNI (file-name-sans-extension, Vload_true_file_name), 210 | + build_string (".el")); 211 | if (NILP (Ffile_exists_p (src))) 212 | - return; 213 | - } 214 | + { 215 | + src = concat2 (src, build_string (".gz")); 216 | + if (NILP (Ffile_exists_p (src))) 217 | + return; 218 | + } 219 | 220 | - Fputhash (function_name, definition, Vcomp_deferred_pending_h); 221 | + Fputhash (function_name, definition, Vcomp_deferred_pending_h); 222 | 223 | - pending_funcalls 224 | - = Fcons (list (Qnative__compile_async, src, Qnil, Qlate), 225 | - pending_funcalls); 226 | + pending_funcalls 227 | + = Fcons (list (Qnative__compile_async, src, Qnil, Qlate), 228 | + pending_funcalls); 229 | + } 230 | + else 231 | + { 232 | + return; 233 | + } 234 | } 235 | 236 | 237 | diff --git a/src/lisp.h b/src/lisp.h 238 | index 4eec4cbcfd..828312a68e 100644 239 | --- a/src/lisp.h 240 | +++ b/src/lisp.h 241 | @@ -2362,9 +2362,38 @@ CHAR_TABLE_EXTRA_SLOTS (struct Lisp_Char_Table *ct) 242 | #else 243 | /* A platform that uses neither _longjmp nor siglongjmp; assume 244 | longjmp does not affect the sigmask. */ 245 | +#ifndef __WIN64 246 | typedef jmp_buf sys_jmp_buf; 247 | # define sys_setjmp(j) setjmp (j) 248 | # define sys_longjmp(j, v) longjmp (j, v) 249 | +#else 250 | +typedef struct 251 | +{ 252 | + jmp_buf raw; 253 | + uint64_t padding; 254 | +} sys_jmp_buf[1]; 255 | + 256 | +# define sys_setjmp(j) ({ \ 257 | + char *target = (char *)j->raw; \ 258 | + bool bad = (unsigned long long)target & 8; \ 259 | + if (bad) { \ 260 | + target += 8; \ 261 | + } \ 262 | + int ret = setjmp ((void *)target); \ 263 | + memmove (j->raw, target, sizeof (j->raw)); \ 264 | + ret; \ 265 | + }) 266 | + 267 | +# define sys_longjmp(j, v) ({ \ 268 | + char *target = (char *)j->raw; \ 269 | + bool bad = (unsigned long long)target & 8; \ 270 | + if (bad) { \ 271 | + target += 8; \ 272 | + } \ 273 | + memmove (target, j->raw, sizeof (j->raw)); \ 274 | + longjmp ((void *)target, v); \ 275 | + }) 276 | +#endif 277 | #endif 278 | 279 | #include "thread.h" 280 | -- 281 | 2.46.0.windows.1 282 | 283 | -------------------------------------------------------------------------------- /patches/emacs/.deprecated/0009-New-sys-select-for-win.patch: -------------------------------------------------------------------------------- 1 | From 467e87069161a5e2740849acac624644d7bd03cd Mon Sep 17 00:00:00 2001 2 | From: Kien Nguyen 3 | Date: Thu, 4 Jul 2024 23:47:11 -0700 4 | Subject: [PATCH 09/11] New sys select for win 5 | 6 | * add emulation MsgWaitForMultipleObjects and WaitForMultipleObjects 7 | * remove useless code 8 | * optimize MsgWaitForMultipleObjectsCustom 9 | * fix max fd 10 | * improve the format 11 | 12 | Co-authored-by: cat 13 | --- 14 | src/w32.h | 5 +- 15 | src/w32proc.c | 260 ++++++++++++++++++++++++++++++++++++++++++++++---- 16 | 2 files changed, 247 insertions(+), 18 deletions(-) 17 | 18 | diff --git a/src/w32.h b/src/w32.h 19 | index 84059278a2..bca8d3defb 100644 20 | --- a/src/w32.h 21 | +++ b/src/w32.h 22 | @@ -29,7 +29,10 @@ #define EMACS_W32_H 23 | /* File descriptor set emulation. */ 24 | 25 | /* MSVC runtime library has limit of 64 descriptors by default */ 26 | -#define FD_SETSIZE 64 27 | +#undef FD_SETSIZE 28 | +/* for WaitForMultipleObjects/MsgWaitForMultipleObjects, every 29 | + * thread need one exitEvent. 64*64-64 */ 30 | +#define FD_SETSIZE 4032 31 | typedef struct { 32 | unsigned int bits[FD_SETSIZE / 32]; 33 | } fd_set; 34 | diff --git a/src/w32proc.c b/src/w32proc.c 35 | index 000eb9bee3..e3eb899d06 100644 36 | --- a/src/w32proc.c 37 | +++ b/src/w32proc.c 38 | @@ -63,6 +63,231 @@ #define DEFER_MS_W32_H 39 | #include "w32term.h" 40 | #include "coding.h" 41 | 42 | +/* The following is a multi-threaded simulation of 43 | + WaitForMultipleObjects and MsgWaitForMultipleObjects to break 44 | + through the limitation that these two functions can only monitor 64 45 | + handles at most. 46 | + It should be noted that the return values ​​of these two 47 | + functions are different from the original function. This is because 48 | + the number represented by the macro returned by the original 49 | + function is too small. 50 | + */ 51 | +#define MY_MAXIMUM_WAIT_OBJECTS FD_SETSIZE 52 | +/* 1 object for notify thread exit */ 53 | +#define MY_MAX_WAIT_OBJECTS 63 54 | +/* the error number should large enough to ommit the wait object index number */ 55 | +#define MY_WAIT_TIMEOUT 0x9999 56 | +#define MY_WAIT_FAILED 0x9998 57 | +#define MY_WAIT_ABANDONED_0 0x5000 58 | + 59 | +typedef struct 60 | +{ 61 | + HANDLE *handles; 62 | + int count; 63 | + BOOL bWaitAll; 64 | + DWORD dwMilliseconds; 65 | + HANDLE completionEvent; /* to notify main thread that this group has completed */ 66 | + DWORD *threadResult; /* get the result of this group */ 67 | + HANDLE exitEvent; /* to control thread exit */ 68 | +} WaitForThreadData; 69 | + 70 | + 71 | +DWORD WINAPI WaitForThreadProc(LPVOID lpParam) 72 | +{ 73 | + WaitForThreadData *params = (WaitForThreadData *)lpParam; 74 | + HANDLE *allHandles = (HANDLE *)malloc((params->count + 1) * sizeof(HANDLE)); 75 | + memcpy(allHandles, params->handles, params->count * sizeof(HANDLE)); 76 | + allHandles[params->count] = params->exitEvent; 77 | + 78 | + DWORD result = WaitForMultipleObjects(params->count + 1, allHandles, params->bWaitAll, params->dwMilliseconds); 79 | + if (result == WAIT_OBJECT_0 + params->count) /* exitEvent is triggered, thread exit */ 80 | + result = WAIT_TIMEOUT; 81 | + else 82 | + *params->threadResult = result; 83 | + 84 | + SetEvent(params->completionEvent); 85 | + free(allHandles); 86 | + return result; 87 | +} 88 | + 89 | +DWORD WaitForMultipleObjectsCustom(DWORD nCount, CONST HANDLE *lpHandles, BOOL bWaitAll, DWORD dwMilliseconds) 90 | +{ 91 | + /* emacs sys_select always set bWaitAll to FALSE */ 92 | + bWaitAll = FALSE; 93 | + if (nCount <= 64) 94 | + { 95 | + DWORD result = WaitForMultipleObjects (nCount, lpHandles, bWaitAll, dwMilliseconds); 96 | + if (result >= WAIT_OBJECT_0 && result < WAIT_OBJECT_0 + nCount) 97 | + return result - WAIT_OBJECT_0; 98 | + else if (WAIT_TIMEOUT == result) 99 | + return MY_WAIT_TIMEOUT; 100 | + else if (result >= WAIT_ABANDONED_0 && result < WAIT_ABANDONED_0 + nCount) 101 | + return result - WAIT_ABANDONED_0 + MY_WAIT_ABANDONED_0; 102 | + else 103 | + return MY_WAIT_FAILED; 104 | + } 105 | + 106 | + int numGroups = (nCount + MY_MAX_WAIT_OBJECTS - 1) / MY_MAX_WAIT_OBJECTS; 107 | + HANDLE *groupCompletionEvents = (HANDLE *)malloc(numGroups * sizeof(HANDLE)); 108 | + WaitForThreadData *threadParams = (WaitForThreadData *)malloc(numGroups * sizeof(WaitForThreadData)); 109 | + HANDLE *threads = (HANDLE *)malloc(numGroups * sizeof(HANDLE)); 110 | + DWORD *threadResults = (DWORD *)malloc(numGroups * sizeof(DWORD)); 111 | + HANDLE *exitEvents = (HANDLE *)malloc(numGroups * sizeof(HANDLE)); 112 | + DWORD startTime = GetTickCount(); 113 | + DWORD elapsedTime = 0; 114 | + 115 | + for (int i = 0; i < numGroups; ++i) 116 | + { 117 | + int groupCount = (i == numGroups - 1) ? (nCount - i * MY_MAX_WAIT_OBJECTS) : MY_MAX_WAIT_OBJECTS; 118 | + threadParams[i].handles = (HANDLE *)(lpHandles + i * MY_MAX_WAIT_OBJECTS); 119 | + threadParams[i].count = groupCount; 120 | + threadParams[i].bWaitAll = bWaitAll; 121 | + threadParams[i].dwMilliseconds = dwMilliseconds; 122 | + threadParams[i].completionEvent = CreateEvent(NULL, FALSE, FALSE, NULL); 123 | + threadParams[i].threadResult = &threadResults[i]; 124 | + threadParams[i].exitEvent = CreateEvent(NULL, TRUE, FALSE, NULL); 125 | + groupCompletionEvents[i] = threadParams[i].completionEvent; 126 | + exitEvents[i] = threadParams[i].exitEvent; 127 | + 128 | + threads[i] = CreateThread(NULL, 0, WaitForThreadProc, &threadParams[i], 0, NULL); 129 | + } 130 | + 131 | + /* wait for any group to complete */ 132 | + DWORD result; 133 | + if (dwMilliseconds != INFINITE) 134 | + { 135 | + DWORD remainingTime = dwMilliseconds - elapsedTime; 136 | + result = WaitForMultipleObjects(numGroups, groupCompletionEvents, bWaitAll, remainingTime); 137 | + } 138 | + else 139 | + result = WaitForMultipleObjects(numGroups, groupCompletionEvents, bWaitAll, dwMilliseconds); 140 | + 141 | + /* notify all threads to exit */ 142 | + for (int i = 0; i < numGroups; ++i) 143 | + SetEvent(exitEvents[i]); 144 | + 145 | + 146 | + /* get the final result */ 147 | + if (result >= WAIT_OBJECT_0 && result < WAIT_OBJECT_0 + numGroups) 148 | + { 149 | + DWORD inner_result = threadResults[result - WAIT_OBJECT_0]; 150 | + if (inner_result >= WAIT_OBJECT_0 && inner_result < WAIT_OBJECT_0 + threadParams[result - WAIT_OBJECT_0].count) 151 | + result = inner_result + (result - WAIT_OBJECT_0) * MY_MAX_WAIT_OBJECTS; 152 | + else if (inner_result >= WAIT_ABANDONED_0 && inner_result < WAIT_ABANDONED_0 + MY_MAX_WAIT_OBJECTS) 153 | + result = inner_result - WAIT_ABANDONED_0 + MY_WAIT_ABANDONED_0; 154 | + else if (WAIT_TIMEOUT == inner_result) 155 | + result = MY_WAIT_TIMEOUT; 156 | + else 157 | + result = MY_WAIT_FAILED; 158 | + } 159 | + else if (WAIT_TIMEOUT == result) 160 | + result = MY_WAIT_TIMEOUT; 161 | + else if (result >= WAIT_ABANDONED_0 && result < WAIT_ABANDONED_0 + numGroups) 162 | + result = result - WAIT_ABANDONED_0 + MY_WAIT_ABANDONED_0; 163 | + else 164 | + result = MY_WAIT_FAILED; 165 | + 166 | + /* wait for all threads to exit */ 167 | + WaitForMultipleObjects(numGroups, threads, TRUE, INFINITE); 168 | + 169 | + for (int i = 0; i < numGroups; ++i) 170 | + { 171 | + CloseHandle(threads[i]); 172 | + CloseHandle(groupCompletionEvents[i]); 173 | + CloseHandle(exitEvents[i]); 174 | + } 175 | + 176 | + free(groupCompletionEvents); 177 | + free(threadParams); 178 | + free(threads); 179 | + free(threadResults); 180 | + free(exitEvents); 181 | + 182 | + return result; 183 | +} 184 | + 185 | +typedef struct 186 | +{ 187 | + DWORD nCount; 188 | + HANDLE* lpHandles; 189 | + BOOL bWaitAll; 190 | + DWORD dwMilliseconds; 191 | + HANDLE completionEvent; 192 | + HANDLE exitEvent; 193 | + DWORD threadResult; 194 | +} MsgWaitThreadData; 195 | + 196 | +DWORD WINAPI MsgWaitThreadFunction(LPVOID param) 197 | +{ 198 | + MsgWaitThreadData* data = (MsgWaitThreadData*)param; 199 | + HANDLE *allHandles = (HANDLE *)malloc((data->nCount + 1) * sizeof(HANDLE)); 200 | + memcpy(allHandles, data->lpHandles, data->nCount * sizeof(HANDLE)); 201 | + allHandles[data->nCount] = data->exitEvent; 202 | + DWORD result = WaitForMultipleObjectsCustom(data->nCount+1, allHandles, data->bWaitAll, data->dwMilliseconds); 203 | + if (result == WAIT_OBJECT_0 + data->nCount) /* exitEvent is triggered, thread exit */ 204 | + data->threadResult = MY_WAIT_FAILED; 205 | + else 206 | + data->threadResult = result; 207 | + 208 | + SetEvent (data->completionEvent); 209 | + free(allHandles); 210 | + 211 | + return 0; 212 | +} 213 | + 214 | +DWORD MsgWaitForMultipleObjectsCustom(DWORD nCount, HANDLE* lpHandles, BOOL bWaitAll, DWORD dwMilliseconds, DWORD dwWakeMask) 215 | +{ 216 | + /* emacs sys_select always set bWaitAll to FALSE */ 217 | + bWaitAll = FALSE; 218 | + if (nCount <= 63) 219 | + { 220 | + DWORD result = MsgWaitForMultipleObjects (nCount, lpHandles, bWaitAll, dwMilliseconds, dwWakeMask); 221 | + if (result >= WAIT_OBJECT_0 && result <= WAIT_OBJECT_0 + nCount) 222 | + return result - WAIT_OBJECT_0; 223 | + else if (WAIT_TIMEOUT == result) 224 | + return MY_WAIT_TIMEOUT; 225 | + else if (result >= WAIT_ABANDONED_0 && result < WAIT_ABANDONED_0 + nCount) 226 | + return result - WAIT_ABANDONED_0 + MY_WAIT_ABANDONED_0; 227 | + else 228 | + return MY_WAIT_FAILED; 229 | + } 230 | + HANDLE completionEvent = CreateEvent (NULL, FALSE, FALSE, NULL); 231 | + if (completionEvent == NULL) 232 | + return MY_WAIT_FAILED; 233 | + HANDLE exitEvent = CreateEvent(NULL, FALSE, FALSE, NULL); 234 | + if (exitEvent == NULL) 235 | + return MY_WAIT_FAILED; 236 | + 237 | + MsgWaitThreadData data = { nCount, lpHandles, bWaitAll, dwMilliseconds, completionEvent, exitEvent, MY_WAIT_FAILED }; 238 | + HANDLE thread = CreateThread(NULL, 0, MsgWaitThreadFunction, &data, 0, NULL); 239 | + if (thread == NULL) 240 | + { 241 | + CloseHandle (completionEvent); 242 | + CloseHandle (exitEvent); 243 | + return MY_WAIT_FAILED; 244 | + } 245 | + 246 | + DWORD result = MsgWaitForMultipleObjects (1, &completionEvent, FALSE, dwMilliseconds, dwWakeMask); 247 | + /* notify thread to exit */ 248 | + SetEvent(exitEvent); 249 | + if (result == WAIT_OBJECT_0) 250 | + result = data.threadResult; 251 | + else if (result == WAIT_OBJECT_0 + 1) /* means there is message in the message queue */ 252 | + result = WAIT_OBJECT_0 + nCount; 253 | + else if (result == WAIT_TIMEOUT) 254 | + result = MY_WAIT_TIMEOUT; 255 | + else 256 | + result = MY_WAIT_FAILED; 257 | + 258 | + WaitForSingleObject(thread, INFINITE); 259 | + 260 | + CloseHandle(exitEvent); 261 | + CloseHandle (completionEvent); 262 | + CloseHandle(thread); 263 | + return result; 264 | +} 265 | + 266 | + 267 | void w32_raise (int); 268 | 269 | #define RVA_TO_PTR(var,section,filedata) \ 270 | @@ -1566,15 +1791,15 @@ waitpid (pid_t pid, int *status, int options) 271 | quitting in that case. */ 272 | if (!dont_wait) 273 | maybe_quit (); 274 | - active = WaitForMultipleObjects (nh, wait_hnd, FALSE, timeout_ms); 275 | - } while (active == WAIT_TIMEOUT && !dont_wait); 276 | + active = WaitForMultipleObjectsCustom (nh, wait_hnd, FALSE, timeout_ms); 277 | + } while (active == MY_WAIT_TIMEOUT && !dont_wait); 278 | 279 | - if (active == WAIT_FAILED) 280 | + if (active == MY_WAIT_FAILED) 281 | { 282 | errno = EBADF; 283 | return -1; 284 | } 285 | - else if (active == WAIT_TIMEOUT && dont_wait) 286 | + else if (active == MY_WAIT_TIMEOUT && dont_wait) 287 | { 288 | /* PID specifies our subprocess, but it didn't exit yet, so its 289 | status is not yet available. */ 290 | @@ -1584,14 +1809,14 @@ waitpid (pid_t pid, int *status, int options) 291 | return 0; 292 | } 293 | else if (active >= WAIT_OBJECT_0 294 | - && active < WAIT_OBJECT_0+MAXIMUM_WAIT_OBJECTS) 295 | + && active < WAIT_OBJECT_0+MY_MAXIMUM_WAIT_OBJECTS) 296 | { 297 | active -= WAIT_OBJECT_0; 298 | } 299 | - else if (active >= WAIT_ABANDONED_0 300 | - && active < WAIT_ABANDONED_0+MAXIMUM_WAIT_OBJECTS) 301 | + else if (active >= MY_WAIT_ABANDONED_0 302 | + && active < MY_WAIT_ABANDONED_0+MY_MAXIMUM_WAIT_OBJECTS) 303 | { 304 | - active -= WAIT_ABANDONED_0; 305 | + active -= MY_WAIT_ABANDONED_0; 306 | } 307 | else 308 | emacs_abort (); 309 | @@ -2501,12 +2726,13 @@ sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, 310 | /* Wait for input or child death to be signaled. If user input is 311 | allowed, then also accept window messages. */ 312 | if (FD_ISSET (0, &orfds)) 313 | - active = MsgWaitForMultipleObjects (nh + nc, wait_hnd, FALSE, timeout_ms, 314 | - QS_ALLINPUT); 315 | + active = MsgWaitForMultipleObjectsCustom (nh + nc, wait_hnd, FALSE, timeout_ms, 316 | + QS_ALLINPUT); 317 | + 318 | else 319 | - active = WaitForMultipleObjects (nh + nc, wait_hnd, FALSE, timeout_ms); 320 | + active = WaitForMultipleObjectsCustom (nh + nc, wait_hnd, FALSE, timeout_ms); 321 | 322 | - if (active == WAIT_FAILED) 323 | + if (active == MY_WAIT_FAILED) 324 | { 325 | DebPrint (("select.WaitForMultipleObjects (%d, %lu) failed with %lu\n", 326 | nh + nc, timeout_ms, GetLastError ())); 327 | @@ -2517,7 +2743,7 @@ sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, 328 | errno = EINTR; 329 | return -1; 330 | } 331 | - else if (active == WAIT_TIMEOUT) 332 | + else if (active == MY_WAIT_TIMEOUT) 333 | { 334 | if (noninteractive) 335 | { 336 | @@ -2527,14 +2753,14 @@ sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, 337 | return 0; 338 | } 339 | else if (active >= WAIT_OBJECT_0 340 | - && active < WAIT_OBJECT_0+MAXIMUM_WAIT_OBJECTS) 341 | + && active < WAIT_OBJECT_0+MY_MAXIMUM_WAIT_OBJECTS) 342 | { 343 | active -= WAIT_OBJECT_0; 344 | } 345 | - else if (active >= WAIT_ABANDONED_0 346 | - && active < WAIT_ABANDONED_0+MAXIMUM_WAIT_OBJECTS) 347 | + else if (active >= MY_WAIT_ABANDONED_0 348 | + && active < MY_WAIT_ABANDONED_0+MY_MAXIMUM_WAIT_OBJECTS) 349 | { 350 | - active -= WAIT_ABANDONED_0; 351 | + active -= MY_WAIT_ABANDONED_0; 352 | } 353 | else 354 | emacs_abort (); 355 | -- 356 | 2.46.0.windows.1 357 | 358 | -------------------------------------------------------------------------------- /patches/emacs/.deprecated/0010-dump_map_file_w32-fix-bad-merge-endif.patch: -------------------------------------------------------------------------------- 1 | From 128afb9b6cd6fa2dfd59949eeaead1eb23a6cef0 Mon Sep 17 00:00:00 2001 2 | From: Kien Nguyen 3 | Date: Tue, 1 Apr 2025 10:41:46 -0700 4 | Subject: [PATCH 10/11] dump_map_file_w32: fix bad merge endif 5 | 6 | --- 7 | src/pdumper.c | 3 ++- 8 | 1 file changed, 2 insertions(+), 1 deletion(-) 9 | 10 | diff --git a/src/pdumper.c b/src/pdumper.c 11 | index 9e46f32bb..0c0b308c0 100644 12 | --- a/src/pdumper.c 13 | +++ b/src/pdumper.c 14 | @@ -4885,8 +4885,9 @@ dump_anonymous_release (void *addr, size_t size) 15 | emacs_abort (); 16 | #endif 17 | } 18 | +#endif /* not HAVE_MPS */ 19 | 20 | -#elif VM_SUPPORTED == VM_MS_WINDOWS && !defined HAVE_MPS 21 | +#if VM_SUPPORTED == VM_MS_WINDOWS && !defined HAVE_MPS 22 | static void * 23 | dump_map_file_w32 (void *base, int fd, off_t offset, size_t size, 24 | enum dump_memory_protection protection) 25 | -- 26 | 2.46.0.windows.1 27 | 28 | -------------------------------------------------------------------------------- /patches/emacs/0001-.el.elc-ignore-byte-compile-errors.patch: -------------------------------------------------------------------------------- 1 | From 583f437e3136e01c818c6f5b518b93ef621f5ae4 Mon Sep 17 00:00:00 2001 2 | From: Kien Nguyen 3 | Date: Thu, 14 Sep 2023 23:19:25 +0900 4 | Subject: [PATCH 01/12] .el.elc: ignore byte compile errors 5 | 6 | --- 7 | Makefile.in | 2 +- 8 | lisp/Makefile.in | 6 +++--- 9 | 2 files changed, 4 insertions(+), 4 deletions(-) 10 | 11 | diff --git a/Makefile.in b/Makefile.in 12 | index ea05fe6ac..86311b151 100644 13 | --- a/Makefile.in 14 | +++ b/Makefile.in 15 | @@ -754,7 +754,7 @@ install-arch-indep: 16 | [ -z "${GZIP_PROG}" ] || { \ 17 | echo "Compressing *.el etc. ..." && \ 18 | cd "$(DESTDIR)${lispdir}" && \ 19 | - for f in `find . -name "*.elc" -print | sed 's/.elc$$/.el/'`; do \ 20 | + for f in `find . -name "*.elc" ! -name "*loaddefs.elc" -print | sed 's/.elc$$/.el/'`; do \ 21 | ${GZIP_PROG} -9n "$$f"; \ 22 | done; \ 23 | ${GZIP_PROG} -9n "../etc/publicsuffix.txt"; \ 24 | diff --git a/lisp/Makefile.in b/lisp/Makefile.in 25 | index 171823577..999ae7402 100644 26 | --- a/lisp/Makefile.in 27 | +++ b/lisp/Makefile.in 28 | @@ -322,17 +322,17 @@ .SUFFIXES: 29 | # which uses it to avoid displaying certain messages which might be 30 | # irritating/misleading during a bootstrap. 31 | .el.elc: 32 | - $(AM_V_ELC)$(emacs) $(BYTE_COMPILE_FLAGS) \ 33 | + -$(AM_V_ELC)$(emacs) $(BYTE_COMPILE_FLAGS) \ 34 | -l comp -f batch-byte-compile $< 35 | TZ=UTC0 touch -t 197001010000 $@ 36 | else 37 | .el.elc: 38 | - $(AM_V_ELC)$(emacs) $(BYTE_COMPILE_FLAGS) \ 39 | + -$(AM_V_ELC)$(emacs) $(BYTE_COMPILE_FLAGS) \ 40 | -l comp -f batch-byte+native-compile $< 41 | endif 42 | else 43 | .el.elc: 44 | - $(AM_V_ELC)$(emacs) $(BYTE_COMPILE_FLAGS) -f batch-byte-compile $< 45 | + -$(AM_V_ELC)$(emacs) $(BYTE_COMPILE_FLAGS) -f batch-byte-compile $< 46 | endif 47 | 48 | .PHONY: compile-first compile-main compile compile-always 49 | -- 50 | 2.46.0.windows.1 51 | 52 | -------------------------------------------------------------------------------- /patches/emacs/0002-ci-auto-sync.patch: -------------------------------------------------------------------------------- 1 | From e6e5bd18b0166f8b491c6e4588740967fbf1e741 Mon Sep 17 00:00:00 2001 2 | From: Kien Nguyen 3 | Date: Tue, 6 Aug 2024 12:38:45 -0700 4 | Subject: [PATCH 02/12] ci: auto-sync 5 | 6 | --- 7 | .github/workflows/sync.yml | 32 ++++++++++++++++++++++++++++++++ 8 | .gitignore | 1 + 9 | 2 files changed, 33 insertions(+) 10 | create mode 100644 .github/workflows/sync.yml 11 | 12 | diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml 13 | new file mode 100644 14 | index 000000000..e8e074474 15 | --- /dev/null 16 | +++ b/.github/workflows/sync.yml 17 | @@ -0,0 +1,32 @@ 18 | +name: Sync with upstream 19 | + 20 | +on: 21 | + schedule: 22 | + - cron: "0 */2 * * *" 23 | + workflow_dispatch: 24 | + # push: 25 | + # branches: 26 | + # - feature/native-comp 27 | + 28 | +jobs: 29 | + sync: 30 | + name: Sync with upstream 31 | + runs-on: ubuntu-latest 32 | + env: 33 | + upstream_repo: emacs-mirror/emacs 34 | + upstream_branch: master feature/igc 35 | + steps: 36 | + - name: Clone 37 | + run: | 38 | + REPO="https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" 39 | + git clone --filter=tree:0 $REPO . 40 | + - name: Setup upstream 41 | + run: | 42 | + git remote add upstream https://github.com/$upstream_repo.git 43 | + echo $upstream_branch | xargs -n1 | xargs -I{} git fetch upstream {} --filter=tree:0 44 | + - name: Sync 45 | + run: | 46 | + git config --global user.email "github-actions[bot]" 47 | + git config --global user.name "github-actions[bot]@users.noreply.github.com" 48 | + echo $upstream_branch | xargs -n1 | xargs -I{} git merge --no-edit upstream/{} 49 | + git push origin -f 50 | diff --git a/.gitignore b/.gitignore 51 | index 5655ee992..fb1ceaaca 100644 52 | --- a/.gitignore 53 | +++ b/.gitignore 54 | @@ -27,6 +27,7 @@ 55 | !.gitignore 56 | !.gitlab-ci.yml 57 | !.mailmap 58 | +!.github/ 59 | 60 | # Built by 'autogen.sh'. 61 | /aclocal.m4 62 | -- 63 | 2.46.0.windows.1 64 | 65 | -------------------------------------------------------------------------------- /patches/emacs/0003-makefile-dont-build-leim.patch: -------------------------------------------------------------------------------- 1 | From 14833058edf6be0ec75f31ee99a56519d0e179d4 Mon Sep 17 00:00:00 2001 2 | From: Kien Nguyen 3 | Date: Wed, 30 Apr 2025 22:27:07 -0700 4 | Subject: [PATCH 03/12] makefile: dont build leim 5 | 6 | --- 7 | lisp/Makefile.in | 6 +++--- 8 | 1 file changed, 3 insertions(+), 3 deletions(-) 9 | 10 | diff --git a/lisp/Makefile.in b/lisp/Makefile.in 11 | index 999ae7402..d2402ba08 100644 12 | --- a/lisp/Makefile.in 13 | +++ b/lisp/Makefile.in 14 | @@ -132,12 +132,12 @@ SUBDIRS_SUBDIRS = 15 | 16 | # cus-load, finder-inf and autoloads are not explicitly requested by 17 | # anything, so we add them here to make sure they get built. 18 | -all: compile-main $(lisp)/cus-load.el $(lisp)/finder-inf.el generate-ja-dic \ 19 | +all: compile-main $(lisp)/cus-load.el $(lisp)/finder-inf.el \ 20 | org-manuals autoloads 21 | 22 | PHONY_EXTRAS = 23 | .PHONY: all custom-deps finder-data autoloads update-subdirs $(PHONY_EXTRAS) \ 24 | - generate-ja-dic org-manuals 25 | + org-manuals 26 | 27 | # custom-deps and finder-data both used to scan _all_ the *.el files. 28 | # This could lead to problems in parallel builds if automatically 29 | @@ -405,7 +405,7 @@ .PHONY: 30 | 31 | ## make -C ../admin/unidata all should be here, but that would race 32 | ## with ../src. See comments above for loaddefs. 33 | -gen-lisp: leim semantic 34 | +gen-lisp: semantic 35 | 36 | # (re)compile titdic-cnv before recursing into `leim` since its used to 37 | # generate some of the Quail source files from tables. 38 | -- 39 | 2.46.0.windows.1 40 | 41 | -------------------------------------------------------------------------------- /patches/emacs/0004-w32-win-dont-load-dnd-menu-bar-scroll-bar-unneccesar.patch: -------------------------------------------------------------------------------- 1 | From 84ca2a8c2908cbf4b51bfd34aaba72d3b3c0195f Mon Sep 17 00:00:00 2001 2 | From: Kien Nguyen 3 | Date: Wed, 21 May 2025 22:15:05 -0700 4 | Subject: [PATCH 04/12] w32-win: dont load dnd menu-bar scroll-bar 5 | unneccesarily 6 | 7 | --- 8 | lisp/term/w32-win.el | 12 +++++++----- 9 | 1 file changed, 7 insertions(+), 5 deletions(-) 10 | 11 | diff --git a/lisp/term/w32-win.el b/lisp/term/w32-win.el 12 | index a1959cd11..37f1332e4 100644 13 | --- a/lisp/term/w32-win.el 14 | +++ b/lisp/term/w32-win.el 15 | @@ -71,10 +71,7 @@ 16 | (eval-when-compile (require 'cl-lib)) 17 | (require 'frame) 18 | (require 'mouse) 19 | -(require 'scroll-bar) 20 | (require 'select) 21 | -(require 'menu-bar) 22 | -(require 'dnd) 23 | (require 'w32-vars) 24 | 25 | (declare-function x-select-font "w32font.c" 26 | @@ -101,6 +98,7 @@ w32-color-map 27 | ;; (princ event)) 28 | 29 | (defun w32-handle-dropped-file (window file-name) 30 | + (require 'dnd) 31 | (dnd-handle-multiple-urls 32 | window 33 | (list 34 | @@ -142,6 +140,7 @@ w32-drag-n-drop 35 | drag-n-drop action in a newly-created frame using its selected-window 36 | and that window's buffer." 37 | (interactive "e") 38 | + (require 'dnd) 39 | ;; Make sure the drop target has positive co-ords 40 | ;; before setting the selected frame - otherwise it 41 | ;; won't work. 42 | @@ -219,6 +218,7 @@ w32-menu-bar-open 43 | If FRAME does not have the menu bar enabled, display a text menu using 44 | `tmm-menubar'." 45 | (interactive "i") 46 | + (require 'menu-bar) 47 | (if menu-bar-mode 48 | (w32-send-sys-command ?\xf100 frame) 49 | (with-selected-frame (or frame (selected-frame)) 50 | @@ -331,8 +331,10 @@ window-system-initialization 51 | ;; that this is only annoying. 52 | (setq split-window-keep-point t) 53 | 54 | - ;; W32 expects the menu bar cut and paste commands to use the clipboard. 55 | - (menu-bar-enable-clipboard) 56 | + (when menu-bar-mode 57 | + (require 'menu-bar) 58 | + ;; W32 expects the menu bar cut and paste commands to use the clipboard. 59 | + (menu-bar-enable-clipboard)) 60 | 61 | ;; Don't show the frame name; that's redundant. 62 | (setq-default mode-line-frame-identification " ") 63 | -- 64 | 2.46.0.windows.1 65 | 66 | -------------------------------------------------------------------------------- /patches/emacs/0005-mps_gen_param_s-increase-to-256MB-for-gc.patch: -------------------------------------------------------------------------------- 1 | From 4f9a7c0ce57e3c7e98377e88767d940559773b58 Mon Sep 17 00:00:00 2001 2 | From: Kien Nguyen 3 | Date: Wed, 4 Sep 2024 09:30:49 -0700 4 | Subject: [PATCH 05/12] mps_gen_param_s: increase to 256MB for gc 5 | 6 | --- 7 | src/igc.c | 2 +- 8 | 1 file changed, 1 insertion(+), 1 deletion(-) 9 | 10 | diff --git a/src/igc.c b/src/igc.c 11 | index 6a3461053..dc769f3e5 100644 12 | --- a/src/igc.c 13 | +++ b/src/igc.c 14 | @@ -4819,7 +4819,7 @@ make_arena (struct igc *gc) 15 | MPS_ARGS_END (args); 16 | IGC_CHECK_RES (res); 17 | 18 | - mps_gen_param_s gens[] = { { 128000, 0.8 }, { 5 * 128000, 0.4 } }; 19 | + mps_gen_param_s gens[] = { { 256000, 0.8 }, { 5 * 256000, 0.4 } }; 20 | res = mps_chain_create (&gc->chain, gc->arena, ARRAYELTS (gens), gens); 21 | IGC_CHECK_RES (res); 22 | } 23 | -- 24 | 2.46.0.windows.1 25 | 26 | -------------------------------------------------------------------------------- /patches/emacs/0006-package-quickstart-refresh-dont-require-info-delay-l.patch: -------------------------------------------------------------------------------- 1 | From 6e94470af3a1f5454d453f0a9623cfd94e0f395e Mon Sep 17 00:00:00 2001 2 | From: Kien Nguyen 3 | Date: Tue, 24 Sep 2024 01:24:39 -0700 4 | Subject: [PATCH 06/12] package-quickstart-refresh: dont require info, delay 5 | load instead 6 | 7 | --- 8 | lisp/emacs-lisp/package.el | 2 +- 9 | 1 file changed, 1 insertion(+), 1 deletion(-) 10 | 11 | diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el 12 | index 82fcf439a..e8773c6cf 100644 13 | --- a/lisp/emacs-lisp/package.el 14 | +++ b/lisp/emacs-lisp/package.el 15 | @@ -4665,7 +4665,7 @@ package-quickstart-refresh 16 | (let ((info-dirs 17 | (mapcar #'package--quickstart-rel (butlast Info-directory-list)))) 18 | (when info-dirs 19 | - (pp `(progn (require 'info) 20 | + (pp `(with-eval-after-load 'info 21 | (info-initialize) 22 | (setq Info-directory-list 23 | (append (list . ,info-dirs) Info-directory-list))) 24 | -- 25 | 2.46.0.windows.1 26 | 27 | -------------------------------------------------------------------------------- /patches/emacs/0007-Stop-using-legacy-ffat-lto-objects-option-in-LTO-bui.patch: -------------------------------------------------------------------------------- 1 | From 92509bd378a532580775c5a24cc9aabfb23509ee Mon Sep 17 00:00:00 2001 2 | From: Kien Nguyen 3 | Date: Fri, 23 Aug 2024 04:51:47 -0700 4 | Subject: [PATCH 07/12] Stop using legacy -ffat-lto-objects option in LTO 5 | builds 6 | 7 | --- 8 | configure.ac | 7 ------- 9 | 1 file changed, 7 deletions(-) 10 | 11 | diff --git a/configure.ac b/configure.ac 12 | index f98974bc5..a9469ffd8 100644 13 | --- a/configure.ac 14 | +++ b/configure.ac 15 | @@ -1981,13 +1981,6 @@ AC_DEFUN 16 | # command, so plugin name is appended to ARFLAGS. 17 | ARFLAGS="cru --plugin $GOLD_PLUGIN" 18 | RANLIB="$RANLIB --plugin $GOLD_PLUGIN" 19 | - else 20 | - dnl The following is needed for GCC 4.9.0. The GCC 4.9.0 release notes 21 | - dnl suggest that instead of -ffat-lto-objects we should use gcc-ar and 22 | - dnl gcc-ranlib in place of ar and ranlib, but gcc-ar makes /usr/bin/ar 23 | - dnl dump core on Fedora 20, so play it safe for now. 24 | - gl_COMPILER_OPTION_IF([-ffat-lto-objects], 25 | - [CFLAGS="$CFLAGS -ffat-lto-objects"]) 26 | fi 27 | fi 28 | fi) 29 | -- 30 | 2.46.0.windows.1 31 | 32 | -------------------------------------------------------------------------------- /patches/emacs/0008-Fix-empty-minor-mode-doc-string-causes-error.patch: -------------------------------------------------------------------------------- 1 | From c9134f5d571a16acbc49df45a7f3de4db3c92445 Mon Sep 17 00:00:00 2001 2 | From: Kien Nguyen 3 | Date: Wed, 13 Sep 2023 19:19:41 +0900 4 | Subject: [PATCH 08/12] Fix empty minor-mode doc string causes error 5 | 6 | --- 7 | lisp/emacs-lisp/easy-mmode.el | 2 +- 8 | 1 file changed, 1 insertion(+), 1 deletion(-) 9 | 10 | diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el 11 | index e59799df3..aa67ee6bb 100644 12 | --- a/lisp/emacs-lisp/easy-mmode.el 13 | +++ b/lisp/emacs-lisp/easy-mmode.el 14 | @@ -105,7 +105,7 @@ easy-mmode--mode-docstring 15 | doc 16 | ;; Compose a new doc string. 17 | (with-temp-buffer 18 | - (let ((lines (if doc 19 | + (let ((lines (if (and doc (not (string= doc ""))) 20 | (string-lines doc) 21 | (list (format "Toggle %s on or off." mode-pretty-name))))) 22 | ;; Insert the first line from the doc string. 23 | -- 24 | 2.46.0.windows.1 25 | 26 | -------------------------------------------------------------------------------- /patches/emacs/0009-setup_w32_kbhook-ignore-it.patch: -------------------------------------------------------------------------------- 1 | From c4c8dc27c3eff7c5ebae097810800acea6736a65 Mon Sep 17 00:00:00 2001 2 | From: Kien Nguyen 3 | Date: Tue, 3 Jun 2025 14:10:46 -0700 4 | Subject: [PATCH] setup_w32_kbhook: ignore it 5 | 6 | --- 7 | src/w32console.c | 2 +- 8 | src/w32fns.c | 2 +- 9 | 2 files changed, 2 insertions(+), 2 deletions(-) 10 | 11 | diff --git a/src/w32console.c b/src/w32console.c 12 | index 1bca0cadf..e05655323 100644 13 | --- a/src/w32console.c 14 | +++ b/src/w32console.c 15 | @@ -913,7 +913,7 @@ initialize_w32_display (struct terminal *term, int *width, int *height) 16 | EnumThreadWindows (GetCurrentThreadId (), find_ime_window, (LPARAM) &hwnd); 17 | 18 | /* Set up the keyboard hook. */ 19 | - setup_w32_kbdhook (hwnd); 20 | + /* setup_w32_kbdhook (hwnd); */ 21 | } 22 | 23 | 24 | diff --git a/src/w32fns.c b/src/w32fns.c 25 | index d7444f11e..78135be1a 100644 26 | --- a/src/w32fns.c 27 | +++ b/src/w32fns.c 28 | @@ -5699,7 +5699,7 @@ #define WM_TOUCH 576 29 | 30 | #ifdef WINDOWSNT 31 | case WM_CREATE: 32 | - setup_w32_kbdhook (hwnd); 33 | + /* setup_w32_kbdhook (hwnd); */ 34 | goto dflt; 35 | #endif 36 | 37 | -- 38 | 2.46.0.windows.1 39 | 40 | -------------------------------------------------------------------------------- /patches/emacs/0010-clang-fixes.patch: -------------------------------------------------------------------------------- 1 | From 169324fd3d5447b519323019b2696abe1a78af0a Mon Sep 17 00:00:00 2001 2 | From: Kien Nguyen 3 | Date: Fri, 5 Jul 2024 02:39:23 -0700 4 | Subject: [PATCH 10/12] clang fixes 5 | 6 | --- 7 | nt/mingw-cfg.site | 4 ++++ 8 | 1 file changed, 4 insertions(+) 9 | 10 | diff --git a/nt/mingw-cfg.site b/nt/mingw-cfg.site 11 | index 16b61de3b..9dc8132f0 100644 12 | --- a/nt/mingw-cfg.site 13 | +++ b/nt/mingw-cfg.site 14 | @@ -29,6 +29,10 @@ 15 | # are necessary to steer the test in the direction you need, by 16 | # judiciously setting variables that control the test results. 17 | 18 | +# We want to use sys/wait.h from nt/inc 19 | +# https://lists.gnu.org/archive/html/help-gnu-emacs/2023-05/msg00107.html 20 | +ac_cv_header_sys_wait_h=yes 21 | + 22 | # We want to use getopt.h from gnulib 23 | ac_cv_header_getopt_h=no 24 | 25 | -- 26 | 2.46.0.windows.1 27 | 28 | -------------------------------------------------------------------------------- /patches/emacs/0011-aarch64-fixes.patch: -------------------------------------------------------------------------------- 1 | From 55448222548f1f67a03581058e4fafc4547267e4 Mon Sep 17 00:00:00 2001 2 | From: Kien Nguyen 3 | Date: Fri, 5 Jul 2024 02:50:31 -0700 4 | Subject: [PATCH 11/12] aarch64 fixes 5 | 6 | --- 7 | configure.ac | 6 ++++-- 8 | nt/emacs-ARM64.manifest | 40 ++++++++++++++++++++++++++++++++++++++++ 9 | nt/emacs.rc.in | 4 +++- 10 | nt/inc/ms-w32.h | 2 +- 11 | src/w32fns.c | 8 ++++++++ 12 | 5 files changed, 56 insertions(+), 4 deletions(-) 13 | create mode 100644 nt/emacs-ARM64.manifest 14 | 15 | diff --git a/configure.ac b/configure.ac 16 | index a9469ffd8..05d6d46eb 100644 17 | --- a/configure.ac 18 | +++ b/configure.ac 19 | @@ -1549,7 +1549,7 @@ AC_DEFUN 20 | ;; 21 | 22 | # MinGW64 23 | - x86_64-*-* ) 24 | + x86_64-*-* | aarch64-*-* ) 25 | case "${canonical}" in 26 | *-mingw* ) 27 | opsys=mingw32 28 | @@ -2273,6 +2273,7 @@ AC_DEFUN 29 | if test "$opsys" = "mingw32"; then 30 | case "$canonical" in 31 | x86_64-*-mingw*) C_SWITCH_SYSTEM="-mtune=generic" ;; 32 | + aarch64-*-mingw*) C_SWITCH_SYSTEM="-mtune=cortex-a53" ;; 33 | *) C_SWITCH_SYSTEM="-mtune=pentium4" ;; 34 | esac 35 | fi 36 | @@ -3057,6 +3058,7 @@ AC_DEFUN 37 | EMACSRES="emacs.res" 38 | case "$canonical" in 39 | x86_64-*-*) EMACS_MANIFEST="emacs-x64.manifest" ;; 40 | + aarch64-*-*) EMACS_MANIFEST="emacs-ARM64.manifest" ;; 41 | *) EMACS_MANIFEST="emacs-x86.manifest" ;; 42 | esac 43 | dnl Construct something of the form "24,4,0,0" with 4 components. 44 | @@ -7513,7 +7515,7 @@ AC_DEFUN 45 | ## If the values of -image-base are modified, the corresponding 46 | ## values of DEFAULT_IMAGE_BASE in w32fns.c should be kept in sync. 47 | case "$canonical" in 48 | - x86_64-*-*) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000 -Wl,-heap,0x00100000 -Wl,-image-base,0x400000000 -Wl,-entry,__start -Wl,-Map,./temacs.map" ;; 49 | + x86_64-*-* | aarch64-*-*) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000 -Wl,-heap,0x00100000 -Wl,-image-base,0x400000000 -Wl,-entry,__start -Wl,-Map,./temacs.map" ;; 50 | *) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000 -Wl,-heap,0x00100000 -Wl,-image-base,0x01000000 -Wl,-entry,__start -Wl,-Map,./temacs.map" ;; 51 | esac 52 | ;; 53 | diff --git a/nt/emacs-ARM64.manifest b/nt/emacs-ARM64.manifest 54 | new file mode 100644 55 | index 000000000..bb5e2d375 56 | --- /dev/null 57 | +++ b/nt/emacs-ARM64.manifest 58 | @@ -0,0 +1,40 @@ 59 | + 60 | + 61 | + 62 | + 63 | + 67 | + 68 | + 69 | + 71 | + GNU Emacs 72 | + 73 | + 74 | + 75 | + 76 | + 77 | + 78 | + 79 | + 80 | + 81 | + 82 | + 83 | + 84 | + 85 | + 86 | + 87 | + 88 | + 89 | + 90 | + 91 | + 92 | + 93 | + 94 | + 95 | + true 96 | + 97 | + 98 | + 99 | diff --git a/nt/emacs.rc.in b/nt/emacs.rc.in 100 | index 9ed948bfa..ce8a0ae7b 100644 101 | --- a/nt/emacs.rc.in 102 | +++ b/nt/emacs.rc.in 103 | @@ -1,6 +1,8 @@ 104 | Emacs ICON icons/emacs.ico 105 | 32649 CURSOR icons/hand.cur 106 | -#if defined (WIN64) || defined (__x86_64__) 107 | +#ifdef __aarch64__ 108 | +1 24 "emacs-ARM64.manifest" 109 | +#elif defined (WIN64) || defined (__x86_64__) 110 | 1 24 "emacs-x64.manifest" 111 | #else 112 | 1 24 "emacs-x86.manifest" 113 | diff --git a/nt/inc/ms-w32.h b/nt/inc/ms-w32.h 114 | index 0627c4bca..bb9e53045 100644 115 | --- a/nt/inc/ms-w32.h 116 | +++ b/nt/inc/ms-w32.h 117 | @@ -217,7 +217,7 @@ #define MAX_UTF8_PATH (MAXPATHLEN * 4) 118 | /* The following is needed for recovery from C stack overflows. */ 119 | #include 120 | typedef jmp_buf sigjmp_buf; 121 | -#ifdef MINGW_W64 122 | +#if defined(MINGW_W64) && !defined(_M_ARM64) 123 | /* Evidently, MinGW64's longjmp crashes when invoked from an exception 124 | handler, see https://sourceforge.net/p/mingw-w64/mailman/message/32421953/. 125 | This seems to be an unsolved problem in the MinGW64 runtime. So we 126 | diff --git a/src/w32fns.c b/src/w32fns.c 127 | index a199666c7..2f9055180 100644 128 | --- a/src/w32fns.c 129 | +++ b/src/w32fns.c 130 | @@ -11504,8 +11504,12 @@ stack_overflow_handler (void) 131 | if (gc_in_progress) 132 | terminate_due_to_signal (SIGSEGV, 40); 133 | #ifdef _WIN64 134 | +# ifdef _M_ARM64 135 | + longjmp(return_to_command_loop, 1); 136 | +# else 137 | /* See ms-w32.h: MinGW64's longjmp crashes if invoked in this context. */ 138 | __builtin_longjmp (return_to_command_loop, 1); 139 | +# endif 140 | #else 141 | sys_longjmp (return_to_command_loop, 1); 142 | #endif 143 | @@ -11532,7 +11536,11 @@ my_exception_handler (EXCEPTION_POINTERS * exception_data) 144 | { 145 | /* Call stack_overflow_handler (). */ 146 | #ifdef _WIN64 147 | +# ifdef _M_ARM64 148 | + exception_data->ContextRecord->Pc = (DWORD_PTR) &stack_overflow_handler; 149 | +# else 150 | exception_data->ContextRecord->Rip = (DWORD_PTR) &stack_overflow_handler; 151 | +# endif 152 | #else 153 | exception_data->ContextRecord->Eip = (DWORD_PTR) &stack_overflow_handler; 154 | #endif 155 | -- 156 | 2.46.0.windows.1 157 | 158 | -------------------------------------------------------------------------------- /patches/emacs/0012-Ensure-sys_jmp_buf-structures-are-marked-during-GC.patch: -------------------------------------------------------------------------------- 1 | From 530b096e0d21a94938a00a43f13e699ba98cb217 Mon Sep 17 00:00:00 2001 2 | From: Pip Cet 3 | Date: Wed, 21 May 2025 20:20:03 -0700 4 | Subject: [PATCH 12/12] Ensure sys_jmp_buf structures are marked during GC 5 | 6 | It's possible for a GC-relevant reference to be stored in a 7 | callee-saved register only, and for setjmp to have moved this 8 | reference into a sys_jmp_buf structure. The safe thing to do is to 9 | mark all potential pointers in sys_jmp_buf. 10 | 11 | * src/thread.c (mark_one_thread): Mark thread->m_getcjmp and 12 | handler->jmp ambiguously. 13 | --- 14 | src/thread.c | 3 +++ 15 | 1 file changed, 3 insertions(+) 16 | 17 | diff --git a/src/thread.c b/src/thread.c 18 | index 765da2141..28abf90ac 100644 19 | --- a/src/thread.c 20 | +++ b/src/thread.c 21 | @@ -672,12 +672,15 @@ mark_one_thread (struct thread_state *thread) 22 | mark_specpdl (thread->m_specpdl, thread->m_specpdl_ptr); 23 | 24 | mark_c_stack (thread->m_stack_bottom, stack_top); 25 | + mark_memory (&thread->m_getcjmp, 26 | + &thread->m_getcjmp + 1); 27 | 28 | for (struct handler *handler = thread->m_handlerlist; 29 | handler; handler = handler->next) 30 | { 31 | mark_object (handler->tag_or_ch); 32 | mark_object (handler->val); 33 | + mark_memory (&handler->jmp, &handler->jmp + 1); 34 | } 35 | 36 | if (thread->m_current_buffer) 37 | -- 38 | 2.46.0.windows.1 39 | 40 | -------------------------------------------------------------------------------- /patches/how-to-apply.md: -------------------------------------------------------------------------------- 1 | # How to apply patches notes 2 | 3 | ``` powershell 4 | dir ..\..\patches\emacs\*.patch | %{git am $_ && mv $_ ..\..\patches\emacs\.applied\ -force} 5 | 6 | # if conflicts 7 | git apply --ignore-whitespace ..\..\patches\emacs\.patch --reject 8 | # resolve conflicts 9 | # remove rej files 10 | git add . 11 | git am --continue 12 | mv ..\..\patches\emacs\.patch ..\..\patches\emacs\.applied\ -force 13 | ``` 14 | 15 | # How to export 16 | 17 | ``` powershell 18 | git format-patch - HEAD 19 | mv 00* ..\..\patches\emacs\ -Force 20 | ``` 21 | 22 | -------------------------------------------------------------------------------- /patches/mps/0001-ming-support.patch: -------------------------------------------------------------------------------- 1 | From a17e8ae082aa40c1b02699e8bc1bc260d920cdc5 Mon Sep 17 00:00:00 2001 2 | From: Kien Nguyen 3 | Date: Sat, 10 Aug 2024 12:55:10 -0700 4 | Subject: [PATCH 1/7] mingw32: support mingw32 5 | 6 | --- 7 | code/comm.gmk | 216 +++++++++++++++++++++++++----------------------- 8 | code/lockw3.c | 19 +++++ 9 | code/mingw.gmk | 79 ++++++++++++++++++ 10 | code/mps.c | 4 +- 11 | code/mpsiw3.c | 5 ++ 12 | code/mpstd.h | 16 ++++ 13 | code/protw3.c | 1 + 14 | code/spw3i3.c | 9 ++ 15 | code/testlib.c | 23 ++++-- 16 | code/testlib.h | 2 +- 17 | code/thw3.c | 4 +- 18 | code/w3i3gc.gmk | 73 ++++++++++++++++ 19 | 12 files changed, 334 insertions(+), 117 deletions(-) 20 | create mode 100644 code/mingw.gmk 21 | create mode 100644 code/w3i3gc.gmk 22 | 23 | diff --git a/code/comm.gmk b/code/comm.gmk 24 | index 05c73fb..bcb19f1 100644 25 | --- a/code/comm.gmk 26 | +++ b/code/comm.gmk 27 | @@ -72,7 +72,7 @@ endif 28 | 29 | # TELEMETRY TARGETS 30 | 31 | -EVENT_TARGETS = mpseventcnv mpseventpy mpseventsql mpseventtxt 32 | +EVENT_TARGETS = mpseventcnv$(EXEEXT) mpseventpy$(EXEEXT) mpseventsql$(EXEEXT) mpseventtxt$(EXEEXT) 33 | 34 | 35 | # EXTRA TARGETS 36 | @@ -80,7 +80,7 @@ EVENT_TARGETS = mpseventcnv mpseventpy mpseventsql mpseventtxt 37 | # Don't build mpseventsql by default (might not have sqlite3 installed), 38 | # but do build the other event target. 39 | 40 | -EXTRA_TARGETS ?= $(filter-out mpseventsql,$(EVENT_TARGETS)) 41 | +EXTRA_TARGETS ?= $(filter-out mpseventsql$(EXEEXT),$(EVENT_TARGETS)) 42 | 43 | 44 | # 45 | @@ -161,7 +161,11 @@ POOLN = pooln.c 46 | MV2 = poolmv2.c 47 | MVFF = poolmvff.c 48 | TESTLIB = testlib.c 49 | +ifneq ($(PFM),w3i3gc) 50 | TESTTHR = testthrix.c 51 | +else 52 | +TESTTHR = testthrw3.c 53 | +endif 54 | FMTDY = fmtdy.c fmtno.c 55 | FMTDYTST = fmtdy.c fmtno.c fmtdytst.c 56 | FMTHETST = fmthe.c fmtdy.c fmtno.c fmtdytst.c 57 | @@ -253,57 +257,61 @@ LIB_TARGETS=mps.a mpsplan.a 58 | # Test executables go in TEST_TARGETS. 59 | 60 | TEST_TARGETS=\ 61 | - abqtest \ 62 | - addrobj \ 63 | - airtest \ 64 | - amcss \ 65 | - amcsshe \ 66 | - amcssth \ 67 | - amsss \ 68 | - amssshe \ 69 | - apss \ 70 | - arenacv \ 71 | - awlut \ 72 | - awluthe \ 73 | - awlutth \ 74 | - btcv \ 75 | - bttest \ 76 | - djbench \ 77 | - extcon \ 78 | - finalcv \ 79 | - finaltest \ 80 | - forktest \ 81 | - fotest \ 82 | - gcbench \ 83 | - landtest \ 84 | - locbwcss \ 85 | - lockcov \ 86 | - lockut \ 87 | - locusss \ 88 | - locv \ 89 | - messtest \ 90 | - mpmss \ 91 | - mpsicv \ 92 | - mv2test \ 93 | - nailboardtest \ 94 | - poolncv \ 95 | - qs \ 96 | - sacss \ 97 | - segsmss \ 98 | - sncss \ 99 | - steptest \ 100 | - tagtest \ 101 | - teletest \ 102 | - walkt0 \ 103 | - zcoll \ 104 | - zmess \ 105 | - ztfm 106 | + abqtest$(EXEEXT) \ 107 | + addrobj$(EXEEXT) \ 108 | + airtest$(EXEEXT) \ 109 | + amcss$(EXEEXT) \ 110 | + amcsshe$(EXEEXT) \ 111 | + amcssth$(EXEEXT) \ 112 | + amsss$(EXEEXT) \ 113 | + amssshe$(EXEEXT) \ 114 | + apss$(EXEEXT) \ 115 | + arenacv$(EXEEXT) \ 116 | + awlut$(EXEEXT) \ 117 | + awluthe$(EXEEXT) \ 118 | + awlutth$(EXEEXT) \ 119 | + btcv$(EXEEXT) \ 120 | + bttest$(EXEEXT) \ 121 | + djbench$(EXEEXT) \ 122 | + extcon$(EXEEXT) \ 123 | + finalcv$(EXEEXT) \ 124 | + finaltest$(EXEEXT) \ 125 | + fotest$(EXEEXT) \ 126 | + gcbench$(EXEEXT) \ 127 | + landtest$(EXEEXT) \ 128 | + locbwcss$(EXEEXT) \ 129 | + lockcov$(EXEEXT) \ 130 | + lockut$(EXEEXT) \ 131 | + locusss$(EXEEXT) \ 132 | + locv$(EXEEXT) \ 133 | + messtest$(EXEEXT) \ 134 | + mpmss$(EXEEXT) \ 135 | + mpsicv$(EXEEXT) \ 136 | + mv2test$(EXEEXT) \ 137 | + nailboardtest$(EXEEXT) \ 138 | + poolncv$(EXEEXT) \ 139 | + qs$(EXEEXT) \ 140 | + sacss$(EXEEXT) \ 141 | + segsmss$(EXEEXT) \ 142 | + sncss$(EXEEXT) \ 143 | + steptest$(EXEEXT) \ 144 | + tagtest$(EXEEXT) \ 145 | + teletest$(EXEEXT) \ 146 | + walkt0$(EXEEXT) \ 147 | + zcoll$(EXEEXT) \ 148 | + zmess$(EXEEXT) \ 149 | + ztfm$(EXEEXT) 150 | + 151 | +ifneq ($(PFM),w3i3gc) 152 | +TEST_TARGETS = $(TEST_TARGETS) forktest$(EXEEXT) 153 | + 154 | +endif 155 | 156 | # This target records programs that we were once able to build but 157 | # can't at the moment: 158 | 159 | UNBUILDABLE_TARGETS=\ 160 | - replay # depends on the EPVM pool 161 | + replay$(EXEEXT) # depends on the EPVM pool 162 | 163 | ALL_TARGETS=$(LIB_TARGETS) $(TEST_TARGETS) $(EXTRA_TARGETS) 164 | 165 | @@ -446,154 +454,154 @@ $(PFM)/cool/mps.a: $(MPMOBJ) 166 | 167 | ifdef VARIETY 168 | 169 | -$(PFM)/$(VARIETY)/abqtest: $(PFM)/$(VARIETY)/abqtest.o \ 170 | +$(PFM)/$(VARIETY)/abqtest$(EXEEXT): $(PFM)/$(VARIETY)/abqtest.o \ 171 | $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 172 | 173 | -$(PFM)/$(VARIETY)/addrobj: $(PFM)/$(VARIETY)/addrobj.o \ 174 | +$(PFM)/$(VARIETY)/addrobj$(EXEEXT): $(PFM)/$(VARIETY)/addrobj.o \ 175 | $(FMTDYTSTOBJ) $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 176 | 177 | -$(PFM)/$(VARIETY)/airtest: $(PFM)/$(VARIETY)/airtest.o \ 178 | +$(PFM)/$(VARIETY)/airtest$(EXEEXT): $(PFM)/$(VARIETY)/airtest.o \ 179 | $(FMTSCMOBJ) $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 180 | 181 | -$(PFM)/$(VARIETY)/amcss: $(PFM)/$(VARIETY)/amcss.o \ 182 | +$(PFM)/$(VARIETY)/amcss$(EXEEXT): $(PFM)/$(VARIETY)/amcss.o \ 183 | $(FMTDYTSTOBJ) $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 184 | 185 | -$(PFM)/$(VARIETY)/amcsshe: $(PFM)/$(VARIETY)/amcsshe.o \ 186 | +$(PFM)/$(VARIETY)/amcsshe$(EXEEXT): $(PFM)/$(VARIETY)/amcsshe.o \ 187 | $(FMTHETSTOBJ) $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 188 | 189 | -$(PFM)/$(VARIETY)/amcssth: $(PFM)/$(VARIETY)/amcssth.o \ 190 | +$(PFM)/$(VARIETY)/amcssth$(EXEEXT): $(PFM)/$(VARIETY)/amcssth.o \ 191 | $(FMTDYTSTOBJ) $(TESTLIBOBJ) $(TESTTHROBJ) $(PFM)/$(VARIETY)/mps.a 192 | 193 | -$(PFM)/$(VARIETY)/amsss: $(PFM)/$(VARIETY)/amsss.o \ 194 | +$(PFM)/$(VARIETY)/amsss$(EXEEXT): $(PFM)/$(VARIETY)/amsss.o \ 195 | $(FMTDYTSTOBJ) $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 196 | 197 | -$(PFM)/$(VARIETY)/amssshe: $(PFM)/$(VARIETY)/amssshe.o \ 198 | +$(PFM)/$(VARIETY)/amssshe$(EXEEXT): $(PFM)/$(VARIETY)/amssshe.o \ 199 | $(FMTHETSTOBJ) $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 200 | 201 | -$(PFM)/$(VARIETY)/apss: $(PFM)/$(VARIETY)/apss.o \ 202 | +$(PFM)/$(VARIETY)/apss$(EXEEXT): $(PFM)/$(VARIETY)/apss.o \ 203 | $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 204 | 205 | -$(PFM)/$(VARIETY)/arenacv: $(PFM)/$(VARIETY)/arenacv.o \ 206 | +$(PFM)/$(VARIETY)/arenacv$(EXEEXT): $(PFM)/$(VARIETY)/arenacv.o \ 207 | $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 208 | 209 | -$(PFM)/$(VARIETY)/awlut: $(PFM)/$(VARIETY)/awlut.o \ 210 | +$(PFM)/$(VARIETY)/awlut$(EXEEXT): $(PFM)/$(VARIETY)/awlut.o \ 211 | $(FMTDYTSTOBJ) $(TESTLIBOBJ) $(TESTTHROBJ) $(PFM)/$(VARIETY)/mps.a 212 | 213 | -$(PFM)/$(VARIETY)/awluthe: $(PFM)/$(VARIETY)/awluthe.o \ 214 | +$(PFM)/$(VARIETY)/awluthe$(EXEEXT): $(PFM)/$(VARIETY)/awluthe.o \ 215 | $(FMTHETSTOBJ) $(TESTLIBOBJ) $(TESTTHROBJ) $(PFM)/$(VARIETY)/mps.a 216 | 217 | -$(PFM)/$(VARIETY)/awlutth: $(PFM)/$(VARIETY)/awlutth.o \ 218 | +$(PFM)/$(VARIETY)/awlutth$(EXEEXT): $(PFM)/$(VARIETY)/awlutth.o \ 219 | $(FMTDYTSTOBJ) $(TESTLIBOBJ) $(TESTTHROBJ) $(PFM)/$(VARIETY)/mps.a 220 | 221 | -$(PFM)/$(VARIETY)/btcv: $(PFM)/$(VARIETY)/btcv.o \ 222 | +$(PFM)/$(VARIETY)/btcv$(EXEEXT): $(PFM)/$(VARIETY)/btcv.o \ 223 | $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 224 | 225 | -$(PFM)/$(VARIETY)/bttest: $(PFM)/$(VARIETY)/bttest.o \ 226 | +$(PFM)/$(VARIETY)/bttest$(EXEEXT): $(PFM)/$(VARIETY)/bttest.o \ 227 | $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 228 | 229 | -$(PFM)/$(VARIETY)/djbench: $(PFM)/$(VARIETY)/djbench.o \ 230 | +$(PFM)/$(VARIETY)/djbench$(EXEEXT): $(PFM)/$(VARIETY)/djbench.o \ 231 | $(TESTLIBOBJ) $(TESTTHROBJ) 232 | 233 | -$(PFM)/$(VARIETY)/extcon: $(PFM)/$(VARIETY)/extcon.o \ 234 | +$(PFM)/$(VARIETY)/extcon$(EXEEXT): $(PFM)/$(VARIETY)/extcon.o \ 235 | $(FMTDYTSTOBJ) $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 236 | 237 | -$(PFM)/$(VARIETY)/finalcv: $(PFM)/$(VARIETY)/finalcv.o \ 238 | +$(PFM)/$(VARIETY)/finalcv$(EXEEXT): $(PFM)/$(VARIETY)/finalcv.o \ 239 | $(FMTDYTSTOBJ) $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 240 | 241 | -$(PFM)/$(VARIETY)/finaltest: $(PFM)/$(VARIETY)/finaltest.o \ 242 | +$(PFM)/$(VARIETY)/finaltest$(EXEEXT): $(PFM)/$(VARIETY)/finaltest.o \ 243 | $(FMTDYTSTOBJ) $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 244 | 245 | -$(PFM)/$(VARIETY)/forktest: $(PFM)/$(VARIETY)/forktest.o \ 246 | +$(PFM)/$(VARIETY)/forktest$(EXEEXT): $(PFM)/$(VARIETY)/forktest.o \ 247 | $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 248 | 249 | -$(PFM)/$(VARIETY)/fotest: $(PFM)/$(VARIETY)/fotest.o \ 250 | +$(PFM)/$(VARIETY)/fotest$(EXEEXT): $(PFM)/$(VARIETY)/fotest.o \ 251 | $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 252 | 253 | -$(PFM)/$(VARIETY)/gcbench: $(PFM)/$(VARIETY)/gcbench.o \ 254 | +$(PFM)/$(VARIETY)/gcbench$(EXEEXT): $(PFM)/$(VARIETY)/gcbench.o \ 255 | $(FMTDYTSTOBJ) $(TESTLIBOBJ) $(TESTTHROBJ) 256 | 257 | -$(PFM)/$(VARIETY)/landtest: $(PFM)/$(VARIETY)/landtest.o \ 258 | +$(PFM)/$(VARIETY)/landtest$(EXEEXT): $(PFM)/$(VARIETY)/landtest.o \ 259 | $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 260 | 261 | -$(PFM)/$(VARIETY)/locbwcss: $(PFM)/$(VARIETY)/locbwcss.o \ 262 | +$(PFM)/$(VARIETY)/locbwcss$(EXEEXT): $(PFM)/$(VARIETY)/locbwcss.o \ 263 | $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 264 | 265 | -$(PFM)/$(VARIETY)/lockcov: $(PFM)/$(VARIETY)/lockcov.o \ 266 | +$(PFM)/$(VARIETY)/lockcov$(EXEEXT): $(PFM)/$(VARIETY)/lockcov.o \ 267 | $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 268 | 269 | -$(PFM)/$(VARIETY)/lockut: $(PFM)/$(VARIETY)/lockut.o \ 270 | +$(PFM)/$(VARIETY)/lockut$(EXEEXT): $(PFM)/$(VARIETY)/lockut.o \ 271 | $(TESTLIBOBJ) $(TESTTHROBJ) $(PFM)/$(VARIETY)/mps.a 272 | 273 | -$(PFM)/$(VARIETY)/locusss: $(PFM)/$(VARIETY)/locusss.o \ 274 | +$(PFM)/$(VARIETY)/locusss$(EXEEXT): $(PFM)/$(VARIETY)/locusss.o \ 275 | $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 276 | 277 | -$(PFM)/$(VARIETY)/locv: $(PFM)/$(VARIETY)/locv.o \ 278 | +$(PFM)/$(VARIETY)/locv$(EXEEXT): $(PFM)/$(VARIETY)/locv.o \ 279 | $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 280 | 281 | -$(PFM)/$(VARIETY)/messtest: $(PFM)/$(VARIETY)/messtest.o \ 282 | +$(PFM)/$(VARIETY)/messtest$(EXEEXT): $(PFM)/$(VARIETY)/messtest.o \ 283 | $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 284 | 285 | -$(PFM)/$(VARIETY)/mpmss: $(PFM)/$(VARIETY)/mpmss.o \ 286 | +$(PFM)/$(VARIETY)/mpmss$(EXEEXT): $(PFM)/$(VARIETY)/mpmss.o \ 287 | $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 288 | 289 | -$(PFM)/$(VARIETY)/mpsicv: $(PFM)/$(VARIETY)/mpsicv.o \ 290 | +$(PFM)/$(VARIETY)/mpsicv$(EXEEXT): $(PFM)/$(VARIETY)/mpsicv.o \ 291 | $(FMTDYTSTOBJ) $(FMTHETSTOBJ) $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 292 | 293 | -$(PFM)/$(VARIETY)/mv2test: $(PFM)/$(VARIETY)/mv2test.o \ 294 | +$(PFM)/$(VARIETY)/mv2test$(EXEEXT): $(PFM)/$(VARIETY)/mv2test.o \ 295 | $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 296 | 297 | -$(PFM)/$(VARIETY)/nailboardtest: $(PFM)/$(VARIETY)/nailboardtest.o \ 298 | +$(PFM)/$(VARIETY)/nailboardtest$(EXEEXT): $(PFM)/$(VARIETY)/nailboardtest.o \ 299 | $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 300 | 301 | -$(PFM)/$(VARIETY)/poolncv: $(PFM)/$(VARIETY)/poolncv.o \ 302 | +$(PFM)/$(VARIETY)/poolncv$(EXEEXT): $(PFM)/$(VARIETY)/poolncv.o \ 303 | $(POOLNOBJ) $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 304 | 305 | -$(PFM)/$(VARIETY)/qs: $(PFM)/$(VARIETY)/qs.o \ 306 | +$(PFM)/$(VARIETY)/qs$(EXEEXT): $(PFM)/$(VARIETY)/qs.o \ 307 | $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 308 | 309 | -$(PFM)/$(VARIETY)/sacss: $(PFM)/$(VARIETY)/sacss.o \ 310 | +$(PFM)/$(VARIETY)/sacss$(EXEEXT): $(PFM)/$(VARIETY)/sacss.o \ 311 | $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 312 | 313 | -$(PFM)/$(VARIETY)/segsmss: $(PFM)/$(VARIETY)/segsmss.o \ 314 | +$(PFM)/$(VARIETY)/segsmss$(EXEEXT): $(PFM)/$(VARIETY)/segsmss.o \ 315 | $(FMTDYTSTOBJ) $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 316 | 317 | -$(PFM)/$(VARIETY)/sncss: $(PFM)/$(VARIETY)/sncss.o \ 318 | +$(PFM)/$(VARIETY)/sncss$(EXEEXT): $(PFM)/$(VARIETY)/sncss.o \ 319 | $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 320 | 321 | -$(PFM)/$(VARIETY)/steptest: $(PFM)/$(VARIETY)/steptest.o \ 322 | +$(PFM)/$(VARIETY)/steptest$(EXEEXT): $(PFM)/$(VARIETY)/steptest.o \ 323 | $(FMTDYTSTOBJ) $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 324 | 325 | -$(PFM)/$(VARIETY)/tagtest: $(PFM)/$(VARIETY)/tagtest.o \ 326 | +$(PFM)/$(VARIETY)/tagtest$(EXEEXT): $(PFM)/$(VARIETY)/tagtest.o \ 327 | $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 328 | 329 | -$(PFM)/$(VARIETY)/teletest: $(PFM)/$(VARIETY)/teletest.o \ 330 | +$(PFM)/$(VARIETY)/teletest$(EXEEXT): $(PFM)/$(VARIETY)/teletest.o \ 331 | $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 332 | 333 | -$(PFM)/$(VARIETY)/walkt0: $(PFM)/$(VARIETY)/walkt0.o \ 334 | +$(PFM)/$(VARIETY)/walkt0$(EXEEXT): $(PFM)/$(VARIETY)/walkt0.o \ 335 | $(FMTDYTSTOBJ) $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 336 | 337 | -$(PFM)/$(VARIETY)/zcoll: $(PFM)/$(VARIETY)/zcoll.o \ 338 | +$(PFM)/$(VARIETY)/zcoll$(EXEEXT): $(PFM)/$(VARIETY)/zcoll.o \ 339 | $(FMTDYTSTOBJ) $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 340 | 341 | -$(PFM)/$(VARIETY)/zmess: $(PFM)/$(VARIETY)/zmess.o \ 342 | +$(PFM)/$(VARIETY)/zmess$(EXEEXT): $(PFM)/$(VARIETY)/zmess.o \ 343 | $(FMTDYTSTOBJ) $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 344 | 345 | -$(PFM)/$(VARIETY)/ztfm: $(PFM)/$(VARIETY)/ztfm.o \ 346 | +$(PFM)/$(VARIETY)/ztfm$(EXEEXT): $(PFM)/$(VARIETY)/ztfm.o \ 347 | $(FMTDYTSTOBJ) $(TESTLIBOBJ) $(PFM)/$(VARIETY)/mps.a 348 | 349 | -$(PFM)/$(VARIETY)/mpseventcnv: $(PFM)/$(VARIETY)/eventcnv.o \ 350 | +$(PFM)/$(VARIETY)/mpseventcnv$(EXEEXT): $(PFM)/$(VARIETY)/eventcnv.o \ 351 | $(PFM)/$(VARIETY)/mps.a 352 | 353 | -$(PFM)/$(VARIETY)/mpseventpy: $(PFM)/$(VARIETY)/eventpy.o \ 354 | +$(PFM)/$(VARIETY)/mpseventpy$(EXEEXT): $(PFM)/$(VARIETY)/eventpy.o \ 355 | $(PFM)/$(VARIETY)/mps.a 356 | 357 | -$(PFM)/$(VARIETY)/mpseventtxt: $(PFM)/$(VARIETY)/eventtxt.o \ 358 | +$(PFM)/$(VARIETY)/mpseventtxt$(EXEEXT): $(PFM)/$(VARIETY)/eventtxt.o \ 359 | $(PFM)/$(VARIETY)/mps.a 360 | 361 | -$(PFM)/$(VARIETY)/mpseventsql: $(PFM)/$(VARIETY)/eventsql.o \ 362 | +$(PFM)/$(VARIETY)/mpseventsql$(EXEEXT): $(PFM)/$(VARIETY)/eventsql.o \ 363 | $(PFM)/$(VARIETY)/mps.a 364 | 365 | -$(PFM)/$(VARIETY)/replay: $(PFM)/$(VARIETY)/replay.o \ 366 | +$(PFM)/$(VARIETY)/replay$(EXEEXT): $(PFM)/$(VARIETY)/replay.o \ 367 | $(PFM)/$(VARIETY)/eventrep.o \ 368 | $(PFM)/$(VARIETY)/table.o \ 369 | $(PFM)/$(VARIETY)/mps.a 370 | @@ -656,18 +664,18 @@ ifdef TARGET 371 | # %%VARIETY: When adding a new variety, add the dependencies files for it 372 | # here. 373 | ifeq ($(VARIETY),rash) 374 | -include $(PFM)/$(VARIETY)/mps.d 375 | +-include $(PFM)/$(VARIETY)/mps.d 376 | else 377 | ifeq ($(VARIETY),hot) 378 | -include $(PFM)/$(VARIETY)/mps.d 379 | +-include $(PFM)/$(VARIETY)/mps.d 380 | else 381 | -include $(MPM:%.c=$(PFM)/$(VARIETY)/%.d) 382 | +-include $(MPM:%.c=$(PFM)/$(VARIETY)/%.d) 383 | endif # VARIETY != hot 384 | endif # VARIETY != rash 385 | 386 | # %%PART: When adding a new part, add the dependencies file for the 387 | # new part here. 388 | -include \ 389 | +-include \ 390 | $(FMTDY:%.c=$(PFM)/$(VARIETY)/%.d) \ 391 | $(FMTDYTST:%.c=$(PFM)/$(VARIETY)/%.d) \ 392 | $(FMTHETST:%.c=$(PFM)/$(VARIETY)/%.d) \ 393 | @@ -698,11 +706,11 @@ $(PFM)/$(VARIETY)/%.a: 394 | 395 | # Executable 396 | 397 | -$(PFM)/$(VARIETY)/%: 398 | +$(PFM)/$(VARIETY)/%$(EXEEXT): 399 | $(ECHO) "$(PFM): $@" 400 | $(CC) $(CFLAGSSTRICT) $(LINKFLAGS) -o $@ $^ $(LIBS) 401 | 402 | -$(PFM)/$(VARIETY)/mpseventsql: 403 | +$(PFM)/$(VARIETY)/mpseventsql$(EXEEXT): 404 | $(ECHO) "$(PFM): $@" 405 | $(CC) $(CFLAGSLAX) $(LINKFLAGS) -o $@ $^ $(LIBS) -lsqlite3 406 | 407 | diff --git a/code/lockw3.c b/code/lockw3.c 408 | index 1945f0a..fe11042 100644 409 | --- a/code/lockw3.c 410 | +++ b/code/lockw3.c 411 | @@ -33,6 +33,25 @@ SRCID(lockw3, "$Id$"); 412 | 413 | #if defined(LOCK) 414 | 415 | +#ifdef __MINGW32__ 416 | +# if defined __MINGW32_VERSION && __MINGW32_VERSION >= 5000000L 417 | + 418 | + /* mingw.org's MinGW doesn't have this stuff in its headers. */ 419 | + typedef struct _RTL_RUN_ONCE { PVOID Ptr; } RTL_RUN_ONCE, *PRTL_RUN_ONCE; 420 | + typedef DWORD (WINAPI *PRTL_RUN_ONCE_INIT_FN)(PRTL_RUN_ONCE, PVOID, PVOID *); 421 | + 422 | +# define RTL_RUN_ONCE_INIT {0} 423 | +# define INIT_ONCE_STATIC_INIT RTL_RUN_ONCE_INIT 424 | + 425 | + typedef RTL_RUN_ONCE INIT_ONCE; 426 | + typedef PRTL_RUN_ONCE PINIT_ONCE; 427 | + typedef WINBOOL (WINAPI *PINIT_ONCE_FN) (PINIT_ONCE InitOnce, PVOID Parameter, PVOID *Context); 428 | + 429 | + WINBASEAPI WINBOOL WINAPI InitOnceExecuteOnce (PINIT_ONCE InitOnce, PINIT_ONCE_FN InitFn, PVOID Parameter, LPVOID *Context); 430 | + 431 | +# endif /* __MINGW32_VERSION >= 5000000L */ 432 | +#endif /* __MINGW32__ */ 433 | + 434 | /* .lock.win32: Win32 lock structure; uses CRITICAL_SECTION */ 435 | typedef struct LockStruct { 436 | Sig sig; /* design.mps.sig.field */ 437 | diff --git a/code/mingw.gmk b/code/mingw.gmk 438 | new file mode 100644 439 | index 0000000..fa792aa 440 | --- /dev/null 441 | +++ b/code/mingw.gmk 442 | @@ -0,0 +1,79 @@ 443 | +# -*- makefile -*- 444 | +# 445 | +# mingw.gmk: GNUMAKEFILE FRAGMENT FOR MinGW GCC 446 | +# 447 | +# $Id$ 448 | +# Copyright (c) 2001-2020 Ravenbrook Limited. See end of file for license. 449 | +# 450 | +# This file is included by platform makefiles that use the GNU CC 451 | +# compiler. It defines the compiler-specific variables that the 452 | +# common makefile fragment () requires. 453 | + 454 | +CC = gcc 455 | +CFLAGSDEBUG = -Og -gdwarf-4 -g3 456 | +CFLAGSOPT = -O2 -gdwarf-4 -g3 457 | +EXEEXT = .exe 458 | + 459 | +# Warnings that might be enabled by clients . 460 | +CFLAGSCOMPILER := \ 461 | +-Waggregate-return \ 462 | +-Wall \ 463 | +-Wcast-qual \ 464 | +-Werror \ 465 | +-Wextra \ 466 | +-Winline \ 467 | +-Wmissing-prototypes \ 468 | +-Wnested-externs \ 469 | +-Wpointer-arith \ 470 | +-Wshadow \ 471 | +-Wstrict-aliasing=2 \ 472 | +-Wstrict-prototypes \ 473 | +-Wswitch-default \ 474 | +-Wwrite-strings 475 | +CFLAGSCOMPILERSTRICT := -std=gnu89 -pedantic 476 | + 477 | +# A different set of compiler flags for less strict compilation, for 478 | +# instance when we need to #include a third-party header file that 479 | +# won't fly with -ansi -pedantic. Use sparingly! 480 | +CFLAGSCOMPILERLAX := 481 | + 482 | +# gcc -MM generates a dependency line of the form: 483 | +# thing.o : thing.c ... 484 | +# The sed line converts this into: 485 | +# //thing.o //thing.d : thing.c ... 486 | +# If interrupted, this is liable to leave a zero-length file behind. 487 | + 488 | +define gendep 489 | +$(SHELL) -ec "$(CC) $(CFLAGSSTRICT) -MM $< | \ 490 | + sed '/:/s!$*.o!$(@D)/& $(@D)/$*.d!' > $@" 491 | +[ -s $@ ] || rm -f $@ 492 | +endef 493 | + 494 | + 495 | +# C. COPYRIGHT AND LICENSE 496 | +# 497 | +# Copyright (C) 2001-2020 Ravenbrook Limited . 498 | +# 499 | +# Redistribution and use in source and binary forms, with or without 500 | +# modification, are permitted provided that the following conditions are 501 | +# met: 502 | +# 503 | +# 1. Redistributions of source code must retain the above copyright 504 | +# notice, this list of conditions and the following disclaimer. 505 | +# 506 | +# 2. Redistributions in binary form must reproduce the above copyright 507 | +# notice, this list of conditions and the following disclaimer in the 508 | +# documentation and/or other materials provided with the 509 | +# distribution. 510 | +# 511 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 512 | +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 513 | +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 514 | +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 515 | +# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 516 | +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 517 | +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 518 | +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 519 | +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 520 | +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 521 | +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 522 | diff --git a/code/mps.c b/code/mps.c 523 | index e7872b3..89047ce 100644 524 | --- a/code/mps.c 525 | +++ b/code/mps.c 526 | @@ -228,9 +228,9 @@ 527 | #include "prmclii6.c" /* x86-64 for Linux mutator context */ 528 | #include "span.c" /* generic stack probe */ 529 | 530 | -/* Windows on IA-32 with Microsoft Visual Studio or Pelles C */ 531 | +/* Windows on IA-32 with Microsoft Visual Studio or Pelles C or GCC */ 532 | 533 | -#elif defined(MPS_PF_W3I3MV) || defined(MPS_PF_W3I3PC) 534 | +#elif defined(MPS_PF_W3I3MV) || defined(MPS_PF_W3I3PC) || defined(MPS_PF_W3I3GC) 535 | 536 | #include "lockw3.c" /* Windows locks */ 537 | #include "thw3.c" /* Windows threading */ 538 | diff --git a/code/mpsiw3.c b/code/mpsiw3.c 539 | index 2f3a9d1..c847a72 100644 540 | --- a/code/mpsiw3.c 541 | +++ b/code/mpsiw3.c 542 | @@ -20,6 +20,11 @@ SRCID(mpsiw3, "$Id$"); 543 | /* This is defined in protw3.c */ 544 | extern LONG WINAPI ProtSEHfilter(LPEXCEPTION_POINTERS info); 545 | 546 | +/* These seem to be unused, but MinGW GCC complains about lack of 547 | + previous prototype. */ 548 | +LONG mps_SEH_filter(LPEXCEPTION_POINTERS, void **, size_t *); 549 | +void mps_SEH_handler(void *, size_t); 550 | + 551 | LONG mps_SEH_filter(LPEXCEPTION_POINTERS info, 552 | void **hp_o, size_t *hs_o) 553 | { 554 | diff --git a/code/mpstd.h b/code/mpstd.h 555 | index 7df1c2a..fb852c5 100644 556 | --- a/code/mpstd.h 557 | +++ b/code/mpstd.h 558 | @@ -392,6 +392,22 @@ 559 | #define MPS_PF_ALIGN 8 560 | 561 | 562 | +#elif defined(__MINGW32__) && defined(_X86_) && defined(__GNUC__) 563 | +#if defined(CONFIG_PF_STRING) && ! defined(CONFIG_PF_W3I3GC) 564 | +#error "specified CONFIG_PF_... inconsistent with detected w3i3gc" 565 | +#endif 566 | +#define MPS_PF_W3I3GC 567 | +#define MPS_PF_STRING "w3i3gc" 568 | +#define MPS_OS_W3 569 | +#define MPS_ARCH_I3 570 | +#define MPS_BUILD_GC 571 | +#define MPS_T_WORD unsigned long 572 | +#define MPS_T_ULONGEST unsigned long 573 | +#define MPS_WORD_WIDTH 32 574 | +#define MPS_WORD_SHIFT 5 575 | +#define MPS_PF_ALIGN 4 576 | + 577 | + 578 | #else 579 | #error "The MPS Kit does not have a configuration for this platform out of the box; see manual/build.txt" 580 | #endif 581 | diff --git a/code/protw3.c b/code/protw3.c 582 | index 6c57731..5c192c8 100644 583 | --- a/code/protw3.c 584 | +++ b/code/protw3.c 585 | @@ -36,6 +36,7 @@ void ProtSet(Addr base, Addr limit, AccessSet mode) 586 | NOTREACHED; 587 | } 588 | 589 | +LONG WINAPI ProtSEHfilter(LPEXCEPTION_POINTERS); 590 | 591 | LONG WINAPI ProtSEHfilter(LPEXCEPTION_POINTERS info) 592 | { 593 | diff --git a/code/spw3i3.c b/code/spw3i3.c 594 | index a43633e..a6f2060 100644 595 | --- a/code/spw3i3.c 596 | +++ b/code/spw3i3.c 597 | @@ -27,11 +27,20 @@ 598 | 599 | void StackProbe(Size depth) 600 | { 601 | +#ifdef __GNUC__ 602 | + __asm__ volatile ("mov %0, %%eax\n\t" 603 | + "neg %%eax\n\t" 604 | + "mov (%%esp,%%eax,4), %%eax" /* do the actual probe */ 605 | + : /* no outputs */ 606 | + : "r" (depth) 607 | + : "eax"); 608 | +#else /* MSVC */ 609 | __asm { 610 | mov eax, depth 611 | neg eax 612 | mov eax, [esp+eax*4] /* do the actual probe */ 613 | } 614 | +#endif 615 | } 616 | 617 | 618 | diff --git a/code/testlib.c b/code/testlib.c 619 | index 1e7f73b..e9aa7df 100644 620 | --- a/code/testlib.c 621 | +++ b/code/testlib.c 622 | @@ -221,7 +221,14 @@ double rnd_double(void) 623 | 624 | static unsigned sizelog2(size_t size) 625 | { 626 | +#ifdef __MINGW32__ 627 | + /* For some reason, MinGW sometimes produces a value slightly 628 | + smaller than the expected one, so we round up to the next FP 629 | + value. */ 630 | + return (unsigned)(log((double)size) / log(2.0) * (1.0 + __DBL_EPSILON__)); 631 | +#else 632 | return (unsigned)(log((double)size) / log(2.0)); 633 | +#endif 634 | } 635 | 636 | size_t rnd_grain(size_t arena_size) 637 | @@ -232,17 +239,17 @@ size_t rnd_grain(size_t arena_size) 638 | return rnd_align(sizeof(void *), (size_t)1 << sizelog2(arena_size >> MPS_WORD_SHIFT)); 639 | } 640 | 641 | -size_t rnd_align(size_t min, size_t max) 642 | +size_t rnd_align(size_t minv, size_t maxv) 643 | { 644 | - unsigned log2min = sizelog2(min); 645 | - unsigned log2max = sizelog2(max); 646 | - Insist(min <= max); 647 | - Insist((size_t)1 << log2min == min); 648 | - Insist((size_t)1 << log2max == max); 649 | + unsigned log2min = sizelog2(minv); 650 | + unsigned log2max = sizelog2(maxv); 651 | + Insist(minv <= maxv); 652 | + Insist((size_t)1 << log2min == minv); 653 | + Insist((size_t)1 << log2max == maxv); 654 | if (log2min < log2max) 655 | - return min << (rnd() % (log2max - log2min + 1)); 656 | + return minv << (rnd() % (log2max - log2min + 1)); 657 | else 658 | - return min; 659 | + return minv; 660 | } 661 | 662 | double rnd_pause_time(void) 663 | diff --git a/code/testlib.h b/code/testlib.h 664 | index 9a414f2..a06fb58 100644 665 | --- a/code/testlib.h 666 | +++ b/code/testlib.h 667 | @@ -71,7 +71,7 @@ 668 | * 669 | */ 670 | 671 | -#if defined(MPS_OS_W3) 672 | +#if defined(MPS_OS_W3) && !defined(__GNUC__) 673 | 674 | #define alloca _alloca 675 | 676 | diff --git a/code/thw3.c b/code/thw3.c 677 | index dd573df..94fd7a6 100644 678 | --- a/code/thw3.c 679 | +++ b/code/thw3.c 680 | @@ -259,7 +259,7 @@ Res ThreadDescribe(Thread thread, mps_lib_FILE *stream, Count depth) 681 | } 682 | 683 | 684 | -Res ThreadScan(ScanState ss, Thread thread, Word *stackCold, 685 | +Res ThreadScan(ScanState ss, Thread thread, void *stackCold, 686 | mps_area_scan_t scan_area, void *closure) 687 | { 688 | DWORD id; 689 | @@ -285,7 +285,7 @@ Res ThreadScan(ScanState ss, Thread thread, Word *stackCold, 690 | stackPtr = MutatorContextSP(&context); 691 | /* .stack.align */ 692 | stackBase = (Word *)AddrAlignUp(stackPtr, sizeof(Word)); 693 | - stackLimit = stackCold; 694 | + stackLimit = (Word *)stackCold; 695 | if (stackBase >= stackLimit) 696 | return ResOK; /* .stack.below-bottom */ 697 | 698 | diff --git a/code/w3i3gc.gmk b/code/w3i3gc.gmk 699 | new file mode 100644 700 | index 0000000..150c7f9 701 | --- /dev/null 702 | +++ b/code/w3i3gc.gmk 703 | @@ -0,0 +1,73 @@ 704 | +# -*- makefile-gmake -*- 705 | +# 706 | +# w3i3gc.gmk: BUILD FOR Windows/x86/MinGW PLATFORM 707 | +# 708 | +# $Id$ 709 | +# Copyright (c) 2001-2020 Ravenbrook Limited. See end of file for license. 710 | + 711 | +PFM = w3i3gc 712 | + 713 | +MPMPF = \ 714 | + lockw3.c \ 715 | + mpsiw3.c \ 716 | + prmci3.c \ 717 | + prmcw3.c \ 718 | + prmcw3i3.c \ 719 | + protw3.c \ 720 | + spw3i3.c \ 721 | + thw3.c \ 722 | + vmw3.c 723 | + 724 | +include mingw.gmk 725 | +include comm.gmk 726 | + 727 | +# Installation stuff copied from ../Makefile.in 728 | + 729 | +prefix ?= /usr 730 | +INSTALL_PROGRAM = /bin/install -c 731 | +INSTALL_DATA = /bin/install -c -m 644 732 | +MPS_TARGET_NAME = w3i3gc 733 | + 734 | +build-via-make: 735 | + $(MAKE) -f $(MPS_TARGET_NAME).gmk EXTRA_TARGETS="$(EXTRA_TARGETS)" 736 | + 737 | +install-make-build: make-install-dirs build-via-make 738 | + $(INSTALL_DATA) mps*.h $(prefix)/include/ 739 | + $(INSTALL_DATA) $(MPS_TARGET_NAME)/cool/mps.a $(prefix)/lib/libmps-debug.a 740 | + $(INSTALL_DATA) $(MPS_TARGET_NAME)/hot/mps.a $(prefix)/lib/libmps.a 741 | + for PROGRAM in $(EXTRA_TARGETS); do $(INSTALL_PROGRAM) $(MPS_TARGET_NAME)/hot/$$PROGRAM $(prefix)/bin/$$PROGRAM; done 742 | + 743 | +make-install-dirs: 744 | + mkdir -p $(prefix)/bin 745 | + mkdir -p $(prefix)/lib 746 | + mkdir -p $(prefix)/include 747 | + 748 | +install: install-make-build 749 | + 750 | +# C. COPYRIGHT AND LICENSE 751 | +# 752 | +# Copyright (C) 2001-2020 Ravenbrook Limited . 753 | +# 754 | +# Redistribution and use in source and binary forms, with or without 755 | +# modification, are permitted provided that the following conditions are 756 | +# met: 757 | +# 758 | +# 1. Redistributions of source code must retain the above copyright 759 | +# notice, this list of conditions and the following disclaimer. 760 | +# 761 | +# 2. Redistributions in binary form must reproduce the above copyright 762 | +# notice, this list of conditions and the following disclaimer in the 763 | +# documentation and/or other materials provided with the 764 | +# distribution. 765 | +# 766 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 767 | +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 768 | +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 769 | +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 770 | +# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 771 | +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 772 | +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 773 | +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 774 | +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 775 | +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 776 | +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 777 | -- 778 | 2.46.0.windows.1 779 | 780 | 781 | From 1469bacfaf7157e92009ea5c1ec4ca9e17126901 Mon Sep 17 00:00:00 2001 782 | From: Kien Nguyen 783 | Date: Sun, 11 Aug 2024 03:37:59 -0700 784 | Subject: [PATCH 2/7] mingw64: support mingw64 785 | 786 | --- 787 | code/comm.gmk | 18 ++++++++++------ 788 | code/global.c | 2 +- 789 | code/mingw.gmk | 33 +++++++++++++++-------------- 790 | code/mps.c | 2 +- 791 | code/mps.h | 14 ++----------- 792 | code/mpstd.h | 16 ++++++++++++++ 793 | code/scan.c | 1 - 794 | code/ss.c | 7 +++++++ 795 | code/testlib.h | 4 ++-- 796 | code/w3i3gc.gmk | 23 --------------------- 797 | code/w3i6gc.gmk | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ 798 | configure | 55 +++++++++++++++++++++++++++++++++++-------------- 799 | configure.ac | 27 ++++++++++++++++++++++-- 800 | 13 files changed, 176 insertions(+), 80 deletions(-) 801 | create mode 100644 code/w3i6gc.gmk 802 | 803 | diff --git a/code/comm.gmk b/code/comm.gmk 804 | index bcb19f1..3efa66a 100644 805 | --- a/code/comm.gmk 806 | +++ b/code/comm.gmk 807 | @@ -161,11 +161,15 @@ POOLN = pooln.c 808 | MV2 = poolmv2.c 809 | MVFF = poolmvff.c 810 | TESTLIB = testlib.c 811 | -ifneq ($(PFM),w3i3gc) 812 | -TESTTHR = testthrix.c 813 | -else 814 | + 815 | +ifeq ($(PFM),w3i3gc) 816 | +TESTTHR = testthrw3.c 817 | +else ifeq ($(PFM),w3i6gc) 818 | TESTTHR = testthrw3.c 819 | +else 820 | +TESTTHR = testthrix.c 821 | endif 822 | + 823 | FMTDY = fmtdy.c fmtno.c 824 | FMTDYTST = fmtdy.c fmtno.c fmtdytst.c 825 | FMTHETST = fmthe.c fmtdy.c fmtno.c fmtdytst.c 826 | @@ -222,7 +226,8 @@ MPMCOMMON = \ 827 | tree.c \ 828 | version.c \ 829 | vm.c \ 830 | - walk.c 831 | + walk.c \ 832 | + 833 | POOLS = $(AMC) $(AMS) $(AWL) $(LO) $(MV2) $(MVFF) $(SNC) 834 | MPM = $(MPMCOMMON) $(MPMPF) $(POOLS) $(PLINTH) 835 | 836 | @@ -303,8 +308,9 @@ TEST_TARGETS=\ 837 | ztfm$(EXEEXT) 838 | 839 | ifneq ($(PFM),w3i3gc) 840 | -TEST_TARGETS = $(TEST_TARGETS) forktest$(EXEEXT) 841 | - 842 | +ifneq ($(PFM),w3i6gc) 843 | +TEST_TARGETS := $(TEST_TARGETS) forktest$(EXEEXT) 844 | +endif 845 | endif 846 | 847 | # This target records programs that we were once able to build but 848 | diff --git a/code/global.c b/code/global.c 849 | index 6c7cd39..50dd41a 100644 850 | --- a/code/global.c 851 | +++ b/code/global.c 852 | @@ -825,7 +825,7 @@ Bool ArenaStep(Globals globals, double interval, double multiplier) 853 | Res ArenaFinalize(Arena arena, Ref obj) 854 | { 855 | Res res; 856 | - Pool refpool; 857 | + Pool refpool = NULL; 858 | 859 | AVERT(Arena, arena); 860 | AVER(PoolOfAddr(&refpool, arena, (Addr)obj)); 861 | diff --git a/code/mingw.gmk b/code/mingw.gmk 862 | index fa792aa..229e8b6 100644 863 | --- a/code/mingw.gmk 864 | +++ b/code/mingw.gmk 865 | @@ -10,26 +10,27 @@ 866 | # common makefile fragment () requires. 867 | 868 | CC = gcc 869 | -CFLAGSDEBUG = -Og -gdwarf-4 -g3 870 | -CFLAGSOPT = -O2 -gdwarf-4 -g3 871 | +CFLAGSDEBUG = -Og -g3 872 | +CFLAGSOPT = -O2 -g3 873 | EXEEXT = .exe 874 | 875 | # Warnings that might be enabled by clients . 876 | CFLAGSCOMPILER := \ 877 | --Waggregate-return \ 878 | --Wall \ 879 | --Wcast-qual \ 880 | --Werror \ 881 | --Wextra \ 882 | --Winline \ 883 | --Wmissing-prototypes \ 884 | --Wnested-externs \ 885 | --Wpointer-arith \ 886 | --Wshadow \ 887 | --Wstrict-aliasing=2 \ 888 | --Wstrict-prototypes \ 889 | --Wswitch-default \ 890 | --Wwrite-strings 891 | + -Waggregate-return \ 892 | + -Wall \ 893 | + -Wcast-qual \ 894 | + -Werror \ 895 | + -Wextra \ 896 | + -Winline \ 897 | + -Wmissing-prototypes \ 898 | + -Wnested-externs \ 899 | + -Wpointer-arith \ 900 | + -Wshadow \ 901 | + -Wstrict-aliasing=2 \ 902 | + -Wstrict-prototypes \ 903 | + -Wswitch-default \ 904 | + -Wwrite-strings \ 905 | + 906 | CFLAGSCOMPILERSTRICT := -std=gnu89 -pedantic 907 | 908 | # A different set of compiler flags for less strict compilation, for 909 | diff --git a/code/mps.c b/code/mps.c 910 | index 89047ce..edd7438 100644 911 | --- a/code/mps.c 912 | +++ b/code/mps.c 913 | @@ -244,7 +244,7 @@ 914 | 915 | /* Windows on x86-64 with Microsoft Visual Studio or Pelles C */ 916 | 917 | -#elif defined(MPS_PF_W3I6MV) || defined(MPS_PF_W3I6PC) 918 | +#elif defined(MPS_PF_W3I6MV) || defined(MPS_PF_W3I6PC) || defined(MPS_PF_W3I6GC) 919 | 920 | #include "lockw3.c" /* Windows locks */ 921 | #include "thw3.c" /* Windows threading */ 922 | diff --git a/code/mps.h b/code/mps.h 923 | index 700c414..46df73f 100644 924 | --- a/code/mps.h 925 | +++ b/code/mps.h 926 | @@ -28,20 +28,10 @@ 927 | #include 928 | #include 929 | #include 930 | +#include "mpstd.h" 931 | 932 | 933 | -/* Platform Dependencies 934 | - * 935 | - * We went for over ten years without any platform ifdefs in this header. 936 | - * Then Microsoft made unsigned long shorter than a pointer on Win64. Ugh. 937 | - */ 938 | - 939 | -#if defined(_MSC_VER) && defined(_WIN32) && defined(_WIN64) && defined(_M_X64) 940 | -typedef unsigned __int64 mps_word_t; 941 | -#else 942 | -typedef unsigned long mps_word_t; 943 | -#endif 944 | - 945 | +typedef MPS_T_WORD mps_word_t; 946 | 947 | /* Abstract Types */ 948 | 949 | diff --git a/code/mpstd.h b/code/mpstd.h 950 | index fb852c5..cc78104 100644 951 | --- a/code/mpstd.h 952 | +++ b/code/mpstd.h 953 | @@ -408,6 +408,22 @@ 954 | #define MPS_PF_ALIGN 4 955 | 956 | 957 | +#elif defined(__MINGW64__) && defined(__x86_64) && defined(__GNUC__) 958 | +# if defined(CONFIG_PF_STRING) && ! defined(CONFIG_PF_W3I6GC) 959 | +# error "specified CONFIG_PF_... inconsistent with detected w3i6gc" 960 | +# endif 961 | +#define MPS_PF_W3I6GC 962 | +#define MPS_PF_STRING "w3i6gc" 963 | +#define MPS_OS_W3 964 | +#define MPS_ARCH_I6 965 | +#define MPS_BUILD_GC 966 | +#define MPS_T_WORD unsigned __int64 967 | +#define MPS_T_ULONGEST unsigned __int64 968 | +#define MPS_WORD_WIDTH 64 969 | +#define MPS_WORD_SHIFT 6 970 | +#define MPS_PF_ALIGN 16 971 | + 972 | + 973 | #else 974 | #error "The MPS Kit does not have a configuration for this platform out of the box; see manual/build.txt" 975 | #endif 976 | diff --git a/code/scan.c b/code/scan.c 977 | index 308cffc..c9c6d6b 100644 978 | --- a/code/scan.c 979 | +++ b/code/scan.c 980 | @@ -22,7 +22,6 @@ 981 | #pragma warning( disable : 4127 ) 982 | #endif 983 | 984 | - 985 | #define MPS_SCAN_AREA(test) \ 986 | MPS_SCAN_BEGIN(ss) { \ 987 | mps_word_t *p = base; \ 988 | diff --git a/code/ss.c b/code/ss.c 989 | index ce08810..2694a05 100644 990 | --- a/code/ss.c 991 | +++ b/code/ss.c 992 | @@ -32,12 +32,19 @@ SRCID(ss, "$Id$"); 993 | * is a hot stack pointer. . 994 | */ 995 | 996 | +#pragma GCC diagnostic push 997 | + 998 | +#if defined(MPS_BUILD_GC) && (__GNUC__ >= 12) 999 | +#pragma GCC diagnostic ignored "-Wdangling-pointer" 1000 | +#endif 1001 | + 1002 | ATTRIBUTE_NOINLINE 1003 | void StackHot(void **stackOut) 1004 | { 1005 | *stackOut = &stackOut; 1006 | } 1007 | 1008 | +#pragma GCC diagnostic pop 1009 | 1010 | /* StackScan -- scan the mutator's stack and registers */ 1011 | 1012 | diff --git a/code/testlib.h b/code/testlib.h 1013 | index a06fb58..7432faf 100644 1014 | --- a/code/testlib.h 1015 | +++ b/code/testlib.h 1016 | @@ -118,8 +118,8 @@ 1017 | #define SCNuLONGEST "llu" 1018 | #define SCNXLONGEST "llX" 1019 | #define PRIXLONGEST "llX" 1020 | -typedef unsigned long long ulongest_t; 1021 | -typedef long long longest_t; 1022 | +typedef unsigned __int64 ulongest_t; 1023 | +typedef __int64 longest_t; 1024 | #define MPS_WORD_CONST(n) (n##ull) 1025 | #else 1026 | #define PRIuLONGEST "lu" 1027 | diff --git a/code/w3i3gc.gmk b/code/w3i3gc.gmk 1028 | index 150c7f9..7ad5915 100644 1029 | --- a/code/w3i3gc.gmk 1030 | +++ b/code/w3i3gc.gmk 1031 | @@ -21,29 +21,6 @@ MPMPF = \ 1032 | include mingw.gmk 1033 | include comm.gmk 1034 | 1035 | -# Installation stuff copied from ../Makefile.in 1036 | - 1037 | -prefix ?= /usr 1038 | -INSTALL_PROGRAM = /bin/install -c 1039 | -INSTALL_DATA = /bin/install -c -m 644 1040 | -MPS_TARGET_NAME = w3i3gc 1041 | - 1042 | -build-via-make: 1043 | - $(MAKE) -f $(MPS_TARGET_NAME).gmk EXTRA_TARGETS="$(EXTRA_TARGETS)" 1044 | - 1045 | -install-make-build: make-install-dirs build-via-make 1046 | - $(INSTALL_DATA) mps*.h $(prefix)/include/ 1047 | - $(INSTALL_DATA) $(MPS_TARGET_NAME)/cool/mps.a $(prefix)/lib/libmps-debug.a 1048 | - $(INSTALL_DATA) $(MPS_TARGET_NAME)/hot/mps.a $(prefix)/lib/libmps.a 1049 | - for PROGRAM in $(EXTRA_TARGETS); do $(INSTALL_PROGRAM) $(MPS_TARGET_NAME)/hot/$$PROGRAM $(prefix)/bin/$$PROGRAM; done 1050 | - 1051 | -make-install-dirs: 1052 | - mkdir -p $(prefix)/bin 1053 | - mkdir -p $(prefix)/lib 1054 | - mkdir -p $(prefix)/include 1055 | - 1056 | -install: install-make-build 1057 | - 1058 | # C. COPYRIGHT AND LICENSE 1059 | # 1060 | # Copyright (C) 2001-2020 Ravenbrook Limited . 1061 | diff --git a/code/w3i6gc.gmk b/code/w3i6gc.gmk 1062 | new file mode 100644 1063 | index 0000000..fa70844 1064 | --- /dev/null 1065 | +++ b/code/w3i6gc.gmk 1066 | @@ -0,0 +1,54 @@ 1067 | +# -*- makefile-gmake -*- 1068 | +# 1069 | +# w3i6gc.gmk: BUILD FOR Windows/x64/MinGW/UCRT64 PLATFORM 1070 | +# 1071 | +# $Id$ 1072 | +# Copyright (c) 2001-2020 Ravenbrook Limited. See end of file for license. 1073 | + 1074 | +PFM = w3i6gc 1075 | + 1076 | +CFLAGS = -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast 1077 | + 1078 | +MPMPF = \ 1079 | + lockw3.c \ 1080 | + mpsiw3.c \ 1081 | + prmci6.c \ 1082 | + prmcw3.c \ 1083 | + prmcw3i6.c \ 1084 | + protw3.c \ 1085 | + spw3i6.c \ 1086 | + thw3.c \ 1087 | + vmw3.c \ 1088 | + 1089 | +include mingw.gmk 1090 | +include comm.gmk 1091 | + 1092 | +CFLAGSCOMPILERSTRICT := -std=gnu99 -pedantic 1093 | + 1094 | +# C. COPYRIGHT AND LICENSE 1095 | +# 1096 | +# Copyright (C) 2001-2020 Ravenbrook Limited . 1097 | +# 1098 | +# Redistribution and use in source and binary forms, with or without 1099 | +# modification, are permitted provided that the following conditions are 1100 | +# met: 1101 | +# 1102 | +# 1. Redistributions of source code must retain the above copyright 1103 | +# notice, this list of conditions and the following disclaimer. 1104 | +# 1105 | +# 2. Redistributions in binary form must reproduce the above copyright 1106 | +# notice, this list of conditions and the following disclaimer in the 1107 | +# documentation and/or other materials provided with the 1108 | +# distribution. 1109 | +# 1110 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1111 | +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1112 | +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1113 | +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1114 | +# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1115 | +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1116 | +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1117 | +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 1118 | +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1119 | +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 1120 | +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1121 | diff --git a/configure b/configure 1122 | index 9f06a0d..78657f7 100755 1123 | --- a/configure 1124 | +++ b/configure 1125 | @@ -1461,7 +1461,7 @@ else 1126 | /* end confdefs.h. */ 1127 | $4 1128 | int 1129 | -main () 1130 | +main (void) 1131 | { 1132 | #ifndef $as_decl_name 1133 | #ifdef __cplusplus 1134 | @@ -2405,7 +2405,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext 1135 | /* end confdefs.h. */ 1136 | 1137 | int 1138 | -main () 1139 | +main (void) 1140 | { 1141 | 1142 | ; 1143 | @@ -2545,7 +2545,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext 1144 | /* end confdefs.h. */ 1145 | #include 1146 | int 1147 | -main () 1148 | +main (void) 1149 | { 1150 | FILE *f = fopen ("conftest.out", "w"); 1151 | return ferror (f) || fclose (f) != 0; 1152 | @@ -2609,7 +2609,7 @@ else 1153 | /* end confdefs.h. */ 1154 | 1155 | int 1156 | -main () 1157 | +main (void) 1158 | { 1159 | 1160 | ; 1161 | @@ -2660,7 +2660,7 @@ else 1162 | /* end confdefs.h. */ 1163 | 1164 | int 1165 | -main () 1166 | +main (void) 1167 | { 1168 | #ifndef __GNUC__ 1169 | choke me 1170 | @@ -2701,7 +2701,7 @@ else 1171 | /* end confdefs.h. */ 1172 | 1173 | int 1174 | -main () 1175 | +main (void) 1176 | { 1177 | 1178 | ; 1179 | @@ -2716,7 +2716,7 @@ else 1180 | /* end confdefs.h. */ 1181 | 1182 | int 1183 | -main () 1184 | +main (void) 1185 | { 1186 | 1187 | ; 1188 | @@ -2732,7 +2732,7 @@ else 1189 | /* end confdefs.h. */ 1190 | 1191 | int 1192 | -main () 1193 | +main (void) 1194 | { 1195 | 1196 | ; 1197 | @@ -2781,9 +2781,7 @@ struct stat; 1198 | /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ 1199 | struct buf { int x; }; 1200 | FILE * (*rcsopen) (struct buf *, struct stat *, int); 1201 | -static char *e (p, i) 1202 | - char **p; 1203 | - int i; 1204 | +static char *e (char **p, int i) 1205 | { 1206 | return p[i]; 1207 | } 1208 | @@ -2818,7 +2816,7 @@ int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, i 1209 | int argc; 1210 | char **argv; 1211 | int 1212 | -main () 1213 | +main (void) 1214 | { 1215 | return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; 1216 | ; 1217 | @@ -3245,7 +3243,7 @@ else 1218 | #include 1219 | 1220 | int 1221 | -main () 1222 | +main (void) 1223 | { 1224 | 1225 | ; 1226 | @@ -3315,7 +3313,7 @@ else 1227 | 1228 | #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) 1229 | int 1230 | -main () 1231 | +main (void) 1232 | { 1233 | int i; 1234 | for (i = 0; i < 256; i++) 1235 | @@ -3453,6 +3451,7 @@ BUILD_TARGET=build-via-make 1236 | CLEAN_TARGET=clean-make-build 1237 | INSTALL_TARGET=install-make-build 1238 | TEST_TARGET=test-make-build 1239 | +EXEEXT= 1240 | case $host/$CLANG in 1241 | aarch64-*-linux*/no) 1242 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: Linux ARM64" >&5 1243 | @@ -3585,6 +3584,30 @@ $as_echo "FreeBSD x86_64" >&6; } 1244 | CPP="$CC -I/usr/local/include -E" 1245 | PFMCFLAGS="$CFLAGS_LL" 1246 | ;; 1247 | + i*86-*-mingw*/*) 1248 | + { $as_echo "$as_me:${as_lineno-$LINENO}: result: Mingw x86" >&5 1249 | +$as_echo "Mingw x86" >&6; } 1250 | + MPS_OS_NAME=w3 1251 | + MPS_ARCH_NAME=i3 1252 | + MPS_BUILD_NAME=gc 1253 | + # Need /usr/local/include in order to find sqlite3.h 1254 | + CFLAGS="-I/usr/local/include" 1255 | + CPP="$CC -I/usr/local/include -E" 1256 | + PFMCFLAGS="$CFLAGS_GC" 1257 | + EXEEXT=.exe 1258 | + ;; 1259 | + x86_64-*-mingw*/*) 1260 | + { $as_echo "$as_me:${as_lineno-$LINENO}: result: Mingw x86_64" >&5 1261 | +$as_echo "Mingw x86_64" >&6; } 1262 | + MPS_OS_NAME=w3 1263 | + MPS_ARCH_NAME=i6 1264 | + MPS_BUILD_NAME=gc 1265 | + # Need /usr/local/include in order to find sqlite3.h 1266 | + CFLAGS="-I/usr/local/include" 1267 | + CPP="$CC -I/usr/local/include -E" 1268 | + PFMCFLAGS="$CFLAGS_GC" 1269 | + EXEEXT=.exe 1270 | + ;; 1271 | *) 1272 | as_fn_error $? "MPS does not support this platform out of the box. See manual/build.txt" "$LINENO" 5 1273 | esac 1274 | @@ -3636,10 +3659,10 @@ if ! $MAKE --version | grep -q "GNU" 2> /dev/null; then 1275 | as_fn_error $? "MPS requires GNU make to build from configure, but see manual/build.txt" "$LINENO" 5 1276 | fi 1277 | 1278 | -EXTRA_TARGETS="mpseventcnv mpseventpy mpseventtxt" 1279 | +EXTRA_TARGETS="mpseventcnv$EXEEXT mpseventpy$EXEEXT mpseventtxt$EXEEXT" 1280 | ac_fn_c_check_header_mongrel "$LINENO" "sqlite3.h" "ac_cv_header_sqlite3_h" "$ac_includes_default" 1281 | if test "x$ac_cv_header_sqlite3_h" = xyes; then : 1282 | - EXTRA_TARGETS="$EXTRA_TARGETS mpseventsql" 1283 | + EXTRA_TARGETS="$EXTRA_TARGETS mpseventsql$EXEEXT" 1284 | fi 1285 | 1286 | 1287 | diff --git a/configure.ac b/configure.ac 1288 | index e10e832..765df99 100644 1289 | --- a/configure.ac 1290 | +++ b/configure.ac 1291 | @@ -44,6 +44,7 @@ BUILD_TARGET=build-via-make 1292 | CLEAN_TARGET=clean-make-build 1293 | INSTALL_TARGET=install-make-build 1294 | TEST_TARGET=test-make-build 1295 | +EXEEXT= 1296 | case $host/$CLANG in 1297 | aarch64-*-linux*/no) 1298 | AC_MSG_RESULT([Linux ARM64]) 1299 | @@ -163,6 +164,28 @@ case $host/$CLANG in 1300 | CPP="$CC -I/usr/local/include -E" 1301 | PFMCFLAGS="$CFLAGS_LL" 1302 | ;; 1303 | + i*86-*-mingw*/*) 1304 | + AC_MSG_RESULT([Mingw x86]) 1305 | + MPS_OS_NAME=w3 1306 | + MPS_ARCH_NAME=i3 1307 | + MPS_BUILD_NAME=gc 1308 | + # Need /usr/local/include in order to find sqlite3.h 1309 | + CFLAGS="-I/usr/local/include" 1310 | + CPP="$CC -I/usr/local/include -E" 1311 | + PFMCFLAGS="$CFLAGS_GC" 1312 | + EXEEXT=.exe 1313 | + ;; 1314 | + x86_64-*-mingw*/*) 1315 | + AC_MSG_RESULT([Mingw x86_64]) 1316 | + MPS_OS_NAME=w3 1317 | + MPS_ARCH_NAME=i6 1318 | + MPS_BUILD_NAME=gc 1319 | + # Need /usr/local/include in order to find sqlite3.h 1320 | + CFLAGS="-I/usr/local/include" 1321 | + CPP="$CC -I/usr/local/include -E" 1322 | + PFMCFLAGS="$CFLAGS_GC" 1323 | + EXEEXT=.exe 1324 | + ;; 1325 | *) 1326 | AC_MSG_ERROR([MPS does not support this platform out of the box. See manual/build.txt]) 1327 | esac 1328 | @@ -172,8 +195,8 @@ if ! $MAKE --version | grep -q "GNU" 2> /dev/null; then 1329 | AC_MSG_ERROR([MPS requires GNU make to build from configure, but see manual/build.txt]) 1330 | fi 1331 | 1332 | -EXTRA_TARGETS="mpseventcnv mpseventpy mpseventtxt" 1333 | -AC_CHECK_HEADER([sqlite3.h], [EXTRA_TARGETS="$EXTRA_TARGETS mpseventsql"]) 1334 | +EXTRA_TARGETS="mpseventcnv$EXEEXT mpseventpy$EXEEXT mpseventtxt$EXEEXT" 1335 | +AC_CHECK_HEADER([sqlite3.h], [EXTRA_TARGETS="$EXTRA_TARGETS mpseventsql$EXEEXT"]) 1336 | 1337 | # Put platform compiler flags like -ansi -pedantic into CFLAGS only 1338 | # after checking for sqlite3.h -- that header doesn't compile with 1339 | -- 1340 | 2.46.0.windows.1 1341 | -------------------------------------------------------------------------------- /patches/mps/0003-adding-quick-build-option.patch: -------------------------------------------------------------------------------- 1 | From f39f93bd72341001ed65908162ff17961ed7610c Mon Sep 17 00:00:00 2001 2 | From: Kien Nguyen 3 | Date: Tue, 13 Aug 2024 20:22:21 -0700 4 | Subject: [PATCH 3/7] adding quick build option 5 | 6 | --- 7 | Makefile.in | 11 ++++++++--- 8 | code/comm.gmk | 2 ++ 9 | configure | 3 +++ 10 | configure.ac | 2 ++ 11 | 4 files changed, 15 insertions(+), 3 deletions(-) 12 | 13 | diff --git a/Makefile.in b/Makefile.in 14 | index a1e8759..7b5ad0c 100644 15 | --- a/Makefile.in 16 | +++ b/Makefile.in 17 | @@ -28,17 +28,22 @@ XCODEBUILD=xcrun xcodebuild -project code/mps.xcodeproj 18 | 19 | all: @BUILD_TARGET@ 20 | 21 | +quick: @QUICK_BUILD_TARGET@ 22 | + 23 | build-via-make: 24 | $(MAKE) $(TARGET_OPTS) 25 | 26 | +quick-build-via-make: 27 | + $(MAKE) $(TARGET_OPTS) lib 28 | + 29 | clean-make-build: 30 | $(MAKE) $(TARGET_OPTS) clean 31 | 32 | -install-make-build: make-install-dirs build-via-make 33 | +install-make-build: make-install-dirs quick-build-via-make 34 | $(INSTALL_DATA) code/mps*.h $(prefix)/include/ 35 | - $(INSTALL_DATA) code/$(MPS_TARGET_NAME)/cool/mps.a $(prefix)/lib/libmps-debug.a 36 | + $(INSTALL_DATA) code/$(MPS_TARGET_NAME)/cool/mps.a $(prefix)/lib/libmps-debug.a || true 37 | $(INSTALL_DATA) code/$(MPS_TARGET_NAME)/hot/mps.a $(prefix)/lib/libmps.a 38 | - for PROGRAM in $(EXTRA_TARGETS); do $(INSTALL_PROGRAM) code/$(MPS_TARGET_NAME)/hot/$$PROGRAM $(prefix)/bin/$$PROGRAM; done 39 | + for PROGRAM in $(EXTRA_TARGETS); do $(INSTALL_PROGRAM) code/$(MPS_TARGET_NAME)/hot/$$PROGRAM $(prefix)/bin/$$PROGRAM; done || true 40 | 41 | build-via-xcode: 42 | $(XCODEBUILD) -config Debug 43 | diff --git a/code/comm.gmk b/code/comm.gmk 44 | index 3efa66a..7680f7a 100644 45 | --- a/code/comm.gmk 46 | +++ b/code/comm.gmk 47 | @@ -326,6 +326,8 @@ ALL_TARGETS=$(LIB_TARGETS) $(TEST_TARGETS) $(EXTRA_TARGETS) 48 | 49 | all: $(ALL_TARGETS) 50 | 51 | +lib: $(LIB_TARGETS) 52 | + 53 | 54 | # == Automated test suites == 55 | # 56 | diff --git a/configure b/configure 57 | index 78657f7..0e5a7a9 100755 58 | --- a/configure 59 | +++ b/configure 60 | @@ -628,6 +628,7 @@ EXTRA_TARGETS 61 | TEST_TARGET 62 | INSTALL_TARGET 63 | CLEAN_TARGET 64 | +QUICK_BUILD_TARGET 65 | BUILD_TARGET 66 | MPS_BUILD_NAME 67 | MPS_ARCH_NAME 68 | @@ -3448,6 +3449,7 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac 69 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking target platform" >&5 70 | $as_echo_n "checking target platform... " >&6; } 71 | BUILD_TARGET=build-via-make 72 | +QUICK_BUILD_TARGET=quick-build-via-make 73 | CLEAN_TARGET=clean-make-build 74 | INSTALL_TARGET=install-make-build 75 | TEST_TARGET=test-make-build 76 | @@ -3683,6 +3685,7 @@ CFLAGS="$CFLAGS $PFMCFLAGS" 77 | 78 | 79 | 80 | + 81 | ac_config_files="$ac_config_files Makefile example/scheme/Makefile" 82 | 83 | 84 | diff --git a/configure.ac b/configure.ac 85 | index 765df99..e6fb182 100644 86 | --- a/configure.ac 87 | +++ b/configure.ac 88 | @@ -41,6 +41,7 @@ CFLAGS_LL="$CFLAGS_GC" 89 | AC_CANONICAL_HOST 90 | AC_MSG_CHECKING([target platform]) 91 | BUILD_TARGET=build-via-make 92 | +QUICK_BUILD_TARGET=quick-build-via-make 93 | CLEAN_TARGET=clean-make-build 94 | INSTALL_TARGET=install-make-build 95 | TEST_TARGET=test-make-build 96 | @@ -207,6 +208,7 @@ AC_SUBST(MPS_OS_NAME) 97 | AC_SUBST(MPS_ARCH_NAME) 98 | AC_SUBST(MPS_BUILD_NAME) 99 | AC_SUBST(BUILD_TARGET) 100 | +AC_SUBST(QUICK_BUILD_TARGET) 101 | AC_SUBST(CLEAN_TARGET) 102 | AC_SUBST(INSTALL_TARGET) 103 | AC_SUBST(TEST_TARGET) 104 | -- 105 | 2.46.0.windows.1 106 | 107 | -------------------------------------------------------------------------------- /patches/mps/0004-Fix-register-scanning-on-FreeBSD-and-Linux.patch: -------------------------------------------------------------------------------- 1 | From c66667bad9b3b044d929a50362f571050aed1bfa Mon Sep 17 00:00:00 2001 2 | From: Kien Nguyen 3 | Date: Sat, 24 Aug 2024 12:51:02 -0700 4 | Subject: [PATCH 4/7] Fix register scanning on FreeBSD and Linux 5 | 6 | Author: Richard Brooksby 7 | Date: Mon Jan 16 23:21:04 2023 +0000 8 | 9 | Catch-up merge master into branch/2020-09-01/regscan to get full CI build and test, and prepare for review and merge. 10 | 11 | Author: Gareth Rees 12 | Date: Tue Jun 4 14:09:05 2019 +0100 13 | 14 | Restore assembly code for spilling callee-save registers. 15 | 16 | This code was previously removed in change 194595 but the result was 17 | not reliable as noted in job004158. 18 | --- 19 | code/ss.h | 60 ++++++++++++---- 20 | design/stack-scan-areas.svg | 23 +++--- 21 | design/stack-scan.txt | 121 ++++++++++++++------------------ 22 | manual/source/topic/porting.rst | 9 ++- 23 | 4 files changed, 114 insertions(+), 99 deletions(-) 24 | 25 | diff --git a/code/ss.h b/code/ss.h 26 | index f05ff67..32b0830 100644 27 | --- a/code/ss.h 28 | +++ b/code/ss.h 29 | @@ -14,18 +14,9 @@ 30 | #include "mpm.h" 31 | 32 | 33 | -/* StackContext -- some of the mutator's state 34 | - * 35 | - * The jumpBuffer is used to capture most of the mutator's state on 36 | - * entry to the MPS, but can't capture it all. See 37 | - * . 38 | - */ 39 | +/* StackContext -- some of the mutator's state */ 40 | 41 | -#include 42 | - 43 | -typedef struct StackContextStruct { 44 | - jmp_buf jumpBuffer; 45 | -} StackContextStruct; 46 | +typedef struct StackContextStruct StackContextStruct; 47 | 48 | 49 | /* StackHot -- capture a hot stack pointer 50 | @@ -33,6 +24,7 @@ typedef struct StackContextStruct { 51 | * Sets *stackOut to a stack pointer that includes the current frame. 52 | */ 53 | 54 | +ATTRIBUTE_NOINLINE 55 | void StackHot(void **stackOut); 56 | 57 | 58 | @@ -59,6 +51,46 @@ void StackHot(void **stackOut); 59 | 60 | /* STACK_CONTEXT_SAVE -- save the callee-saves and stack pointer */ 61 | 62 | +#if (defined(MPS_BUILD_GC) || defined(MPS_BUILD_LL)) && defined(MPS_ARCH_I3) 63 | + 64 | +struct StackContextStruct { 65 | + Word calleeSave[4]; 66 | +}; 67 | + 68 | +#define STACK_CONTEXT_SAVE(sc) \ 69 | + BEGIN \ 70 | + Word *_save = (sc)->calleeSave; \ 71 | + __asm__ volatile ("mov %%ebx, %0" : "=m" (_save[0])); \ 72 | + __asm__ volatile ("mov %%esi, %0" : "=m" (_save[1])); \ 73 | + __asm__ volatile ("mov %%edi, %0" : "=m" (_save[2])); \ 74 | + __asm__ volatile ("mov %%ebp, %0" : "=m" (_save[3])); \ 75 | + END 76 | + 77 | +#elif (defined(MPS_BUILD_GC) || defined(MPS_BUILD_LL)) && defined(MPS_ARCH_I6) 78 | + 79 | +struct StackContextStruct { 80 | + Word calleeSave[6]; 81 | +}; 82 | + 83 | +#define STACK_CONTEXT_SAVE(sc) \ 84 | + BEGIN \ 85 | + Word *_save = (sc)->calleeSave; \ 86 | + __asm__ volatile ("mov %%rbp, %0" : "=m" (_save[0])); \ 87 | + __asm__ volatile ("mov %%rbx, %0" : "=m" (_save[1])); \ 88 | + __asm__ volatile ("mov %%r12, %0" : "=m" (_save[2])); \ 89 | + __asm__ volatile ("mov %%r13, %0" : "=m" (_save[3])); \ 90 | + __asm__ volatile ("mov %%r14, %0" : "=m" (_save[4])); \ 91 | + __asm__ volatile ("mov %%r15, %0" : "=m" (_save[5])); \ 92 | + END 93 | + 94 | +#else /* jmp_buf platforms */ 95 | + 96 | +#include 97 | + 98 | +struct StackContextStruct { 99 | + jmp_buf jumpBuffer; 100 | +}; 101 | + 102 | #if defined(MPS_OS_XC) 103 | 104 | /* We call _setjmp rather than setjmp because we can be confident what 105 | @@ -74,7 +106,9 @@ void StackHot(void **stackOut); 106 | 107 | #define STACK_CONTEXT_SAVE(sc) ((void)setjmp((sc)->jumpBuffer)) 108 | 109 | -#endif /* platform defines */ 110 | +#endif /* jmp_buf platforms */ 111 | + 112 | +#endif /* platform specific code */ 113 | 114 | 115 | /* StackScan -- scan the mutator's stack and registers 116 | @@ -84,7 +118,7 @@ void StackHot(void **stackOut); 117 | */ 118 | 119 | extern Res StackScan(ScanState ss, void *stackCold, 120 | - mps_area_scan_t scan_area, void *closure); 121 | + mps_area_scan_t scan_area, void *closure); 122 | 123 | 124 | #endif /* ss_h */ 125 | diff --git a/design/stack-scan-areas.svg b/design/stack-scan-areas.svg 126 | index 285cdad..020bc43 100644 127 | --- a/design/stack-scan-areas.svg 128 | +++ b/design/stack-scan-areas.svg 129 | @@ -13,7 +13,7 @@ 130 | height="441.15668pt" 131 | id="svg1343" 132 | sodipodi:docname="stack-scan-areas.svg" 133 | - inkscape:version="0.92.2 5c3e80d, 2017-08-06"> 134 | + inkscape:version="0.91 r13725"> 135 | image/svg+xml 149 | 151 | - 152 | + 153 | 154 | 155 | 156 | @@ -346,16 +346,15 @@ 157 | style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1" /> 158 | 163 | + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:12px;line-height:125%;font-family:Verdana;-inkscape-font-specification:'Verdana, Normal';text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-dasharray:none;stroke-opacity:1" 164 | + x="176.9048" 165 | + y="231.14665" 166 | + sodipodi:linespacing="125%"> 167 | jmp_buf 174 | + sodipodi:role="line" 175 | + id="tspan4344" 176 | + x="176.9048" 177 | + y="231.14665">StackContextStruct 178 | 179 | 3 | Date: Sat, 24 Aug 2024 12:54:11 -0700 4 | Subject: [PATCH 5/7] Fix some race conditions in xca6ll/hot/amcssth 5 | 6 | commit 14adaee7ba1b460606eb5a225daf62a779eacdda 7 | Merge: e089937 081d79e 8 | Author: Richard Brooksby 9 | Date: Mon Jan 30 02:49:12 2023 +0000 10 | 11 | Catch-up merge branch 'master' into 59-memory-aware to apply CI and prepare for review 12 | 13 | commit e0899374f81f3e51d7b3b637cf683accca998387 14 | Author: Gareth Rees 15 | Date: Sat Dec 24 14:16:10 2022 +0000 16 | 17 | Fix some race conditions in xca6ll/hot/amcssth. 18 | 19 | * Use memory-model-aware builtins in GCC and Clang when a memory 20 | location may be written by one thread and read by another, avoiding 21 | race conditions due to out-of-order updates on ARM. 22 | * Call dylan_make_wrappers while the test is still single-threaded, 23 | preventing multiple threads from racing to call it. 24 | * Prevent dylan_init from creating a padding object, as we must not 25 | have an exact root pointing at a padding object. 26 | --- 27 | code/amcssth.c | 38 ++++++++++++++++++++++++-------------- 28 | code/fmtdytst.c | 9 +++------ 29 | code/testlib.h | 19 +++++++++++++++++++ 30 | 3 files changed, 46 insertions(+), 20 deletions(-) 31 | 32 | diff --git a/code/amcssth.c b/code/amcssth.c 33 | index 35bd6a1..56011ac 100644 34 | --- a/code/amcssth.c 35 | +++ b/code/amcssth.c 36 | @@ -108,19 +108,22 @@ static mps_res_t area_scan(mps_ss_t ss, void *base, void *limit, void *closure) 37 | 38 | static void churn(mps_ap_t ap, size_t roots_count) 39 | { 40 | - size_t i; 41 | - size_t r; 42 | + size_t i, j, r; 43 | 44 | ++objs; 45 | r = (size_t)rnd(); 46 | if (r & 1) { 47 | + mps_addr_t root; 48 | i = (r >> 1) % exactRootsCOUNT; 49 | - if (exactRoots[i] != objNULL) 50 | - cdie(dylan_check(exactRoots[i]), "dying root check"); 51 | - exactRoots[i] = make(ap, roots_count); 52 | - if (exactRoots[(exactRootsCOUNT-1) - i] != objNULL) 53 | - dylan_write(exactRoots[(exactRootsCOUNT-1) - i], 54 | - exactRoots, exactRootsCOUNT); 55 | + atomic_load(&exactRoots[i], &root); 56 | + if (root != objNULL) 57 | + cdie(dylan_check(root), "dying root check"); 58 | + root = make(ap, roots_count); 59 | + atomic_store(&exactRoots[i], &root); 60 | + j = exactRootsCOUNT - i - 1; 61 | + atomic_load(&exactRoots[j], &root); 62 | + if (root != objNULL) 63 | + dylan_write(root, exactRoots, exactRootsCOUNT); 64 | } else { 65 | i = (r >> 1) % ambigRootsCOUNT; 66 | ambigRoots[(ambigRootsCOUNT-1) - i] = make(ap, roots_count); 67 | @@ -221,9 +224,11 @@ static void test_pool(const char *name, mps_pool_t pool, size_t roots_count) 68 | (unsigned long)collections, objs, 69 | (unsigned long)mps_arena_committed(arena)); 70 | 71 | - for (i = 0; i < exactRootsCOUNT; ++i) 72 | - cdie(exactRoots[i] == objNULL || dylan_check(exactRoots[i]), 73 | - "all roots check"); 74 | + for (i = 0; i < exactRootsCOUNT; ++i) { 75 | + mps_addr_t root; 76 | + atomic_load(&exactRoots[i], &root); 77 | + cdie(root == objNULL || dylan_check(root), "all roots check"); 78 | + } 79 | 80 | if (collections >= collectionsCOUNT / 2 && !walked) 81 | { 82 | @@ -248,9 +253,12 @@ static void test_pool(const char *name, mps_pool_t pool, size_t roots_count) 83 | ramping = 0; 84 | /* kill half of the roots */ 85 | for(i = 0; i < exactRootsCOUNT; i += 2) { 86 | - if (exactRoots[i] != objNULL) { 87 | - cdie(dylan_check(exactRoots[i]), "ramp kill check"); 88 | - exactRoots[i] = objNULL; 89 | + mps_addr_t root; 90 | + atomic_load(&exactRoots[i], &root); 91 | + if (root != objNULL) { 92 | + cdie(dylan_check(root), "ramp kill check"); 93 | + root = objNULL; 94 | + atomic_store(&exactRoots[i], &root); 95 | } 96 | } 97 | } 98 | @@ -298,6 +306,8 @@ static void test_arena(void) 99 | mps_pool_t amc_pool, amcz_pool; 100 | void *marker = ▮ 101 | 102 | + die(dylan_make_wrappers(), "make wrappers"); 103 | + 104 | MPS_ARGS_BEGIN(args) { 105 | MPS_ARGS_ADD(args, MPS_KEY_ARENA_SIZE, testArenaSIZE); 106 | MPS_ARGS_ADD(args, MPS_KEY_ARENA_GRAIN_SIZE, rnd_grain(testArenaSIZE)); 107 | diff --git a/code/fmtdytst.c b/code/fmtdytst.c 108 | index 6a48860..97b1f30 100644 109 | --- a/code/fmtdytst.c 110 | +++ b/code/fmtdytst.c 111 | @@ -68,7 +68,7 @@ mps_res_t dylan_make_wrappers(void) 112 | return MPS_RES_OK; 113 | } 114 | 115 | -/* dylan_init -- turn raw memory into initialised dylan-vector (or pad) 116 | +/* dylan_init -- turn raw memory into initialised dylan-vector 117 | * 118 | * If the raw memory is large enough, initialises it to a dylan-vector, 119 | * whose slots are initialised to either dylan-ints, or valid refs, at 120 | @@ -78,8 +78,6 @@ mps_res_t dylan_make_wrappers(void) 121 | * and "nr_refs" arguments. If "nr_refs" is 0, all slots are 122 | * initialized to dylan-ints: this may be useful for making leaf 123 | * objects. 124 | - * 125 | - * (Makes a pad if the raw memory is too small to hold a dylan-vector) 126 | */ 127 | 128 | mps_res_t dylan_init(mps_addr_t addr, size_t size, 129 | @@ -93,8 +91,7 @@ mps_res_t dylan_init(mps_addr_t addr, size_t size, 130 | if (res != MPS_RES_OK) 131 | return res; 132 | 133 | - /* If there is enough room, make a vector, otherwise just */ 134 | - /* make a padding object. */ 135 | + /* If there is enough room, make a vector. */ 136 | if(size >= sizeof(mps_word_t) * 2) { 137 | mps_word_t *p = (mps_word_t *)addr; 138 | mps_word_t i, t = (size / sizeof(mps_word_t)) - 2; 139 | @@ -110,7 +107,7 @@ mps_res_t dylan_init(mps_addr_t addr, size_t size, 140 | p[2+i] = (mps_word_t)refs[(r >> 1) % nr_refs]; /* random ptr */ 141 | } 142 | } else { 143 | - dylan_pad(addr, size); 144 | + return MPS_RES_UNIMPL; 145 | } 146 | 147 | return MPS_RES_OK; 148 | diff --git a/code/testlib.h b/code/testlib.h 149 | index 7432faf..0d0dc44 100644 150 | --- a/code/testlib.h 151 | +++ b/code/testlib.h 152 | @@ -294,6 +294,25 @@ extern void randomize(int argc, char *argv[]); 153 | extern void testlib_init(int argc, char *argv[]); 154 | 155 | 156 | +/* Memory-model-aware operations */ 157 | + 158 | +#if defined(MPS_BUILD_GC) || defined(MPS_BUILD_LL) 159 | + 160 | +/* See 161 | + * and */ 162 | +#define atomic_load(SRC, DEST) __atomic_load(SRC, DEST, __ATOMIC_ACQUIRE) 163 | +#define atomic_store(DEST, SRC) __atomic_store(DEST, SRC, __ATOMIC_RELEASE) 164 | + 165 | +#elif defined(MPS_BUILD_MV) 166 | + 167 | +/* Microsoft Visual C/C++ does not need memory-model-aware load and store as 168 | + * loads and stores of register-sized values are atomic on Intel. */ 169 | +#define atomic_load(SRC, DEST) (*(DEST) = *(SRC)) 170 | +#define atomic_store(DEST, SRC) (*(DEST) = *(SRC)) 171 | + 172 | +#endif 173 | + 174 | + 175 | #endif /* testlib_h */ 176 | 177 | 178 | -- 179 | 2.46.0.windows.1 180 | 181 | -------------------------------------------------------------------------------- /patches/mps/0006-fix-MSP_PROT_INNER-TO-sync-with-RootModePROTECTABLE_.patch: -------------------------------------------------------------------------------- 1 | From 13325144e33b54a8905c72f7a384967b41199dbe Mon Sep 17 00:00:00 2001 2 | From: Kien Nguyen 3 | Date: Sat, 24 Aug 2024 12:57:53 -0700 4 | Subject: [PATCH 6/7] fix: MSP_PROT_INNER TO sync with 5 | RootModePROTECTABLE_INNER 6 | 7 | --- 8 | code/mps.h | 2 +- 9 | 1 file changed, 1 insertion(+), 1 deletion(-) 10 | 11 | diff --git a/code/mps.h b/code/mps.h 12 | index 46df73f..14b75bf 100644 13 | --- a/code/mps.h 14 | +++ b/code/mps.h 15 | @@ -318,7 +318,7 @@ extern mps_rank_t mps_rank_weak(void); 16 | 17 | #define MPS_RM_CONST (((mps_rm_t)1<<0)) 18 | #define MPS_RM_PROT (((mps_rm_t)1<<1)) 19 | -#define MPS_RM_PROT_INNER (((mps_rm_t)1<<1)) 20 | +#define MPS_RM_PROT_INNER (((mps_rm_t)1<<2)) 21 | 22 | 23 | /* Allocation Point */ 24 | -- 25 | 2.46.0.windows.1 26 | 27 | -------------------------------------------------------------------------------- /patches/mps/0007-build-make-warnings-error-only-in-debug-build.patch: -------------------------------------------------------------------------------- 1 | From 5bb31c48276833e800a582820fead0bd9177fca4 Mon Sep 17 00:00:00 2001 2 | From: Kien Nguyen 3 | Date: Sun, 20 Apr 2025 18:05:43 -0700 4 | Subject: [PATCH 7/7] build: make warnings error only in debug build 5 | 6 | --- 7 | code/gc.gmk | 3 +-- 8 | code/gp.gmk | 4 ++-- 9 | code/ll.gmk | 3 +-- 10 | code/mingw.gmk | 3 +-- 11 | 4 files changed, 5 insertions(+), 8 deletions(-) 12 | 13 | diff --git a/code/gc.gmk b/code/gc.gmk 14 | index 1ab9fbd..c2e1b8e 100644 15 | --- a/code/gc.gmk 16 | +++ b/code/gc.gmk 17 | @@ -10,7 +10,7 @@ 18 | # common makefile fragment () requires. 19 | 20 | CC = gcc 21 | -CFLAGSDEBUG = -O -g3 22 | +CFLAGSDEBUG = -O -g3 -Werror 23 | CFLAGSOPT = -O2 -g3 24 | 25 | # Warnings that might be enabled by clients . 26 | @@ -18,7 +18,6 @@ CFLAGSCOMPILER := \ 27 | -Waggregate-return \ 28 | -Wall \ 29 | -Wcast-qual \ 30 | --Werror \ 31 | -Wextra \ 32 | -Winline \ 33 | -Wmissing-prototypes \ 34 | diff --git a/code/gp.gmk b/code/gp.gmk 35 | index 1b22a9f..af5f707 100644 36 | --- a/code/gp.gmk 37 | +++ b/code/gp.gmk 38 | @@ -12,11 +12,11 @@ 39 | 40 | CC = gcc 41 | CFLAGSCOMPILER = \ 42 | - -ansi -pedantic -Wall -Wextra -Werror -Wpointer-arith \ 43 | + -ansi -pedantic -Wall -Wextra -Wpointer-arith \ 44 | -Wstrict-prototypes -Wmissing-prototypes \ 45 | -Winline -Waggregate-return -Wnested-externs \ 46 | -Wcast-qual -Wshadow -Wwrite-strings -pg 47 | -CFLAGSDEBUG = -g -ggdb3 48 | +CFLAGSDEBUG = -g -ggdb3 -Werror 49 | CFLAGSOPT = -O -g -ggdb3 50 | 51 | # gcc -MM generates a dependency line of the form: 52 | diff --git a/code/ll.gmk b/code/ll.gmk 53 | index 16ebf0e..0bd8b83 100644 54 | --- a/code/ll.gmk 55 | +++ b/code/ll.gmk 56 | @@ -10,7 +10,7 @@ 57 | # common makefile fragment () requires. 58 | 59 | CC = clang 60 | -CFLAGSDEBUG = -O0 -g3 61 | +CFLAGSDEBUG = -O0 -g3 -Werror 62 | CFLAGSOPT = -O2 -g3 63 | 64 | # Warnings that might be enabled by clients . 65 | @@ -21,7 +21,6 @@ CFLAGSCOMPILER := \ 66 | -Wcast-qual \ 67 | -Wconversion \ 68 | -Wduplicate-enum \ 69 | - -Werror \ 70 | -Wextra \ 71 | -Winline \ 72 | -Wmissing-prototypes \ 73 | diff --git a/code/mingw.gmk b/code/mingw.gmk 74 | index 229e8b6..00a9feb 100644 75 | --- a/code/mingw.gmk 76 | +++ b/code/mingw.gmk 77 | @@ -10,7 +10,7 @@ 78 | # common makefile fragment () requires. 79 | 80 | CC = gcc 81 | -CFLAGSDEBUG = -Og -g3 82 | +CFLAGSDEBUG = -Og -g3 -Werror 83 | CFLAGSOPT = -O2 -g3 84 | EXEEXT = .exe 85 | 86 | @@ -19,7 +19,6 @@ CFLAGSCOMPILER := \ 87 | -Waggregate-return \ 88 | -Wall \ 89 | -Wcast-qual \ 90 | - -Werror \ 91 | -Wextra \ 92 | -Winline \ 93 | -Wmissing-prototypes \ 94 | -- 95 | 2.46.0.windows.1 96 | 97 | -------------------------------------------------------------------------------- /scripts/aspell.sh: -------------------------------------------------------------------------------- 1 | function action3_aspell () 2 | { 3 | local aspell_zip_file="$emacs_build_zip_dir/aspell-${architecture}.zip" 4 | if test -f "$aspell_zip_file"; then 5 | echo File $aspell_zip_file already exists. 6 | else 7 | local packages="${mingw_prefix}-aspell ${mingw_prefix}-aspell-en" 8 | ensure_packages "$packages" \ 9 | && msys2_extra_package "$packages" "$mingw_dir" "" "$aspell_zip_file" \ 10 | && emacs_extensions="$aspell_zip_file $emacs_extensions" \ 11 | && return 0 12 | return -1 13 | fi 14 | } 15 | 16 | function test_aspell () 17 | { 18 | local aspell="$emacs_full_install_dir/bin/aspell.exe" 19 | test -x "$aspell" \ 20 | && "$aspell" dicts | grep en_US >/dev/null 2>&1 21 | } 22 | -------------------------------------------------------------------------------- /scripts/create_msix.ps1: -------------------------------------------------------------------------------- 1 | # this script convert a directory to a msix package file 2 | # take two parameters of the directory path and the output msix file 3 | param( 4 | [string] $manifesTemplate, 5 | [string] $version, 6 | [string] $directory, 7 | [string] $package, 8 | [string] $cert, 9 | [string] $secret 10 | ) 11 | 12 | # create a manifest file 13 | $content = [System.IO.File]::ReadAllText($manifesTemplate).Replace("{{version}}", $version) 14 | [System.IO.File]::WriteAllText("$directory\AppxManifest.xml", $content) 15 | 16 | $msixcli = if ($env:MSIXHeroCLI) { $env:MSIXHeroCLI } else { "MSIXHeroCLI.exe" } 17 | # create the msix package 18 | & $msixcli pack -d $directory -p $package 19 | 20 | # sign the msix package 21 | & $msixcli sign -f $cert -p $secret -t "http://timestamp.comodoca.com" "$package" 22 | -------------------------------------------------------------------------------- /scripts/gnutls.sh: -------------------------------------------------------------------------------- 1 | # 2 | # GNU TLS library below 3.7.0 has problems connecting to MELPA 3 | # via https secure connections. This file downloads a more recent 4 | # version of the library. 5 | # 6 | 7 | function action2_patch_gnutls () 8 | { 9 | return 0 10 | # 11 | # If gnutls is not used or has a recent version, return 12 | if [[ ! "$features" =~ .*gnutls.* ]]; then 13 | return 0 14 | fi 15 | tls_version=`pacman -Qi ${mingw_prefix}-gnutls | grep Version | sed 's,Version[ ]*:[ ]*\([^ ]*\)$,\1,'` 16 | if [[ ! "$tls_version" < "3.7.0" ]]; then 17 | return 0 18 | fi 19 | echo Patching gnutls library because version ${tls_version} is too old. 20 | # 21 | # Download the official gnutls distribution and replace the 22 | # existing libraries with this one. We assume this can be done 23 | # because gnutls from mingw pulled the right dependencies 24 | if test "$architecture" = "i686"; then 25 | gnutls_link="https://gitlab.com/gnutls/gnutls/builds/artifacts/3.7.0/download?job=MinGW32.DLLs" 26 | gnutls_dir="win32-build" 27 | else 28 | gnutls_link="https://gitlab.com/gnutls/gnutls/builds/artifacts/3.7.0/download?job=MinGW64.DLLs" 29 | gnutls_dir="win64-build" 30 | fi 31 | (cd "$emacs_install_dir/" \ 32 | && rm -rf "$gnutls_dir" gnutls.zip \ 33 | && curl -L "$gnutls_link" > gnutls.zip \ 34 | && unzip -x gnutls.zip \ 35 | && mv "$gnutls_dir/bin/"* bin/ \ 36 | && rm -rf "$gnutls_dir" gnutls.zip) 37 | } 38 | -------------------------------------------------------------------------------- /scripts/gzip.sh: -------------------------------------------------------------------------------- 1 | function action3_gzip () { 2 | gzip_build_dir="$emacs_build_build_dir/gzip" 3 | gzip_zip_file="$emacs_build_zip_dir/gzip-${architecture}.zip" 4 | 5 | if test ! -f "${gzip_zip_file}"; then 6 | (mkdir -p "$gzip_build_dir/usr/bin" \ 7 | && echo '%~dp0\gzip.exe -d %*' > "${gzip_build_dir}/usr/bin/gunzip.cmd" \ 8 | && cp /usr/bin/gzip.exe "${gzip_build_dir}/usr/bin/gzip.exe" \ 9 | && ensure_packages gzip \ 10 | && msys2_extra_package "msys2-runtime" "/" "" "$gzip_zip_file" \ 11 | && cd "${gzip_build_dir}" \ 12 | && zip -9r "$gzip_zip_file" "usr") || return -1 13 | fi 14 | emacs_extensions="$gzip_zip_file $emacs_extensions" 15 | } 16 | -------------------------------------------------------------------------------- /scripts/help.txt: -------------------------------------------------------------------------------- 1 | Usage: 2 | emacs-build [--version] [--help] [--features] 3 | [--branch b] [--clone] [--build] [--deps] 4 | [--slim] [--[no-]compress] [--[no-]strip] 5 | [--with-all] [--without-X] [--with-X] 6 | [--pdf-tools] [--aspell] [--hunspell] [--mu] [--isync] 7 | [--pack-emacs] [--pack-all] 8 | Actions: 9 | --build Configure and build Emacs from sources. 10 | --clean Remove all directories except sources and zip files. 11 | --clone Download Savannah's git repository for Emacs. 12 | --deps Create a ZIP file with all the Mingw64/32 dependencies. 13 | --help Output this help message, --features and exit. 14 | --pack-emacs Package an Emacs previously built with the --build option. 15 | --pack-all Package an Emacs previously built, with all the Mingw64/32 16 | dependencies, as well as all extensions (see Extensions below). 17 | --features Shows all active and inactive features for the selected options. 18 | --version Output emacs-build version number and exit. 19 | 20 | Multiple actions can be selected. The default is to run them all in a logical 21 | order: clone, build, deps and pack-all. 22 | 23 | Build options: 24 | --branch b Select Emacs branch (or tag) 'b' for the remaining operations. 25 | --compress Ship Emacs with gunzip and compress documentation and Emacs 26 | script files. 27 | --debug Output all statements run by the script. 28 | --debug-dependencies 29 | Describe which MSYS/MINGW packages depend on which, and 30 | which files are discarded from the ZIP files. 31 | --no-strip Disable the --strip option. 32 | --no-compress Disable the --compress option. 33 | --slim Remove Cairo, SVG and TIFF support for a slimmer build. 34 | Remove also documentation files and other support files 35 | from the dependencies file. Activate --compress and 36 | --strip. (Default configuration) 37 | --strip Strip executables and DLL's from debug information. 38 | --with-all Add all Emacs features. 39 | --with-* Add requested feature in the dependencies and build 40 | * is any of the known features for emacs in Windows/Mingw 41 | (see --features). 42 | --without-* Remove requested feature in the dependencies and build. 43 | 44 | Options are processed in order. Thus --slim followed by --with-cairo 45 | would enable Cairo, even though --slim removes it. 46 | 47 | Extensions: 48 | --pdf-tools Build and package PDF-TOOLS. 49 | --hunspell Install Hunspell spell checker. 50 | --aspell Install Aspell spell checker. 51 | --mu Mail search system and supporting Emacs mu4e libraries. 52 | --isync Synchronize email from IMAP/POP to Maildir format (mbsync). 53 | 54 | Environment variables: 55 | msys2_dir Windows path to a preexisting MSY2 installation 56 | -------------------------------------------------------------------------------- /scripts/hunspell.sh: -------------------------------------------------------------------------------- 1 | function action3_hunspell () 2 | { 3 | local hunspell_zip_file="$emacs_build_zip_dir/hunspell-${architecture}.zip" 4 | if test -f "$hunspell_zip_file"; then 5 | echo File $hunspell_zip_file already exists. 6 | else 7 | local packages="${mingw_prefix}-hunspell ${mingw_prefix}-hunspell-en" 8 | ensure_packages "$packages" \ 9 | && msys2_extra_package "$packages" "$mingw_dir" "" "$hunspell_zip_file" \ 10 | && emacs_extensions="$hunspell_zip_file $emacs_extensions" \ 11 | && return 0 12 | return -1 13 | fi 14 | } 15 | -------------------------------------------------------------------------------- /scripts/msys2.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | setlocal 3 | if not defined MSYSTEM set MSYSTEM=UCRT64 4 | set CHERE_INVOKING=1 5 | set emacs_build_dir=%~dp0.. 6 | if not defined msys2_dir set msys2_dir=%emacs_build_dir%\msys64 7 | %msys2_dir%\usr\bin\bash.exe --norc -leo pipefail %* 8 | -------------------------------------------------------------------------------- /scripts/msys2_extra.sh: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Juan Jose Garcia-Ripoll 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in all 11 | # copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | # SOFTWARE. 20 | # 21 | ######################################## 22 | # 23 | # MU + XAPIAN + ISYNC 24 | # 25 | # Mail synchronization and mail indexing 26 | # 27 | 28 | function msys2_extra_environment () 29 | { 30 | msys2_extra_repo="https://github.com/msys2-unofficial/MSYS2-packages.git" 31 | msys2_extra_source_dir="$emacs_build_git_dir/MSYS2-packages" 32 | } 33 | 34 | function action3_mu () 35 | { 36 | local mu_zip_file="$emacs_build_zip_dir/mu-${architecture}.zip" 37 | msys2_extra_environment 38 | ensure_msys2_devel \ 39 | && msys2_extra_clone \ 40 | && msys2_extra_build_and_install_package gmime3 \ 41 | && msys2_extra_build_and_install_package xapian-core \ 42 | && msys2_extra_build_and_install_package mu \ 43 | && emacs_extensions="$mu_zip_file $emacs_extensions" \ 44 | && msys2_extra_package mu-git "/" "glib2 xapian-core gmime3" "$mu_zip_file" 45 | } 46 | 47 | function test_mu () 48 | { 49 | local mu="$emacs_full_install_dir/usr/bin/mu.exe" 50 | test -x "$mu" \ 51 | && "$mu" --help | grep "mu general options" >/dev/null 2>&1 52 | } 53 | 54 | function action3_isync () 55 | { 56 | local isync_zip_file="$emacs_build_zip_dir/isync-${architecture}.zip" 57 | msys2_extra_environment 58 | ensure_msys2_devel \ 59 | && msys2_extra_clone \ 60 | && msys2_extra_build_and_install_package isync \ 61 | && emacs_extensions="$isync_zip_file $emacs_extensions" \ 62 | && msys2_extra_package isync-git "/" "gcc-libs ca-certificates" "$isync_zip_file" "$isync_zip_file" 63 | } 64 | 65 | function test_isync () 66 | { 67 | local mbsync="$emacs_full_install_dir/usr/bin/mbsync.exe" 68 | test -x "$mbsync" \ 69 | && "$mbsync" --help | grep "mailbox synchronizer" >/dev/null 2>&1 70 | } 71 | 72 | function ensure_msys2_devel () 73 | { 74 | local required_packages="base-devel msys2-devel" 75 | pacman -S --noconfirm --needed $required_packages >/dev/null 2>&1 76 | if test "$?" != 0; then 77 | echo Unable to install MSYS2 packages $required_packages 78 | echo Giving up 79 | return -1 80 | fi 81 | } 82 | 83 | function msys2_makepkg () 84 | { 85 | $SHELL -c "source shell msys; makepkg $* EMACS=$emacs_install_dir/bin/emacs.exe" 86 | } 87 | 88 | function msys2_extra_build_and_install_package () 89 | { 90 | #set -x 91 | local package_name="$1" 92 | local package_dir="$msys2_extra_source_dir/$package_name" 93 | local package_file=`ls "${package_dir}/"*.zst 2>/dev/null` 94 | if test ! -f "$emacs_install_dir/bin/emacs.exe"; then 95 | echo Please build and package Emacs before the extensions 96 | exit -1 97 | fi 98 | if test ! -f "$package_file"; then 99 | echo Building package $package_dir on directory $package_dir 100 | (cd "$package_dir" && rm -f *.zst && msys2_makepkg --noconfirm -rsf -p PKGBUILD) 101 | if test "$?" != 0; then 102 | echo Unable to build package. Aborting. 103 | return -1 104 | fi 105 | package_file=`ls "${package_dir}/"*.zst` 106 | fi 107 | if test -f "$package_file" && pacman -U --noconfirm "$package_file"; then 108 | echo Installed $package_name 109 | return 0 110 | else 111 | echo Failed to build and install package $package_name 112 | return -1 113 | fi 114 | } 115 | 116 | function msys2_extra_package () 117 | { 118 | local base="$1" 119 | local prefix="$2" 120 | local dependencies="$3" 121 | local zip_file="$4" 122 | # List all dependencies 123 | local all_dependencies=`full_dependency_list "$base $dependencies gcc-libs" "sh coreutils" "$base" "msys2-no-prefix"` 124 | echo Packaging $base and dependencies into $zip_file 125 | (mingw_dir="$prefix"; package_dependencies "$zip_file" "$all_dependencies") \ 126 | && zip -9r "$zip_file" /etc/fstab 127 | } 128 | 129 | function msys2_extra_clone () 130 | { 131 | echo Cloning repository $msys2_extra_repo 132 | clone_repo "master" "$msys2_extra_repo" "$msys2_extra_source_dir" \ 133 | && (cd "$msys2_extra_source_dir" && git reset --hard && git checkout . ) \ 134 | && msys2_extra_mu_pkg_description \ 135 | && msys2_extra_gmime3_pkg_description \ 136 | && msys2_extra_xapian_pkg_description \ 137 | && msys2_extra_isync_pkg_description 138 | 139 | } 140 | 141 | function msys2_build_isync () 142 | { 143 | cd "$msys2_extra_source_dir/isync" \ 144 | && makepkg -sf 145 | } 146 | 147 | function msys2_extra_mu_pkg_description () 148 | { 149 | cat > "$msys2_extra_source_dir/mu/PKGBUILD" <<\EOF 150 | # Maintainer: damon-kwok 151 | # Modification by Juan Jose Garcia Ripoll to fix dependencies 152 | 153 | _realname=mu 154 | # _date="`date +%Y-%m-%d@%H-%M-%S`" 155 | pkgname=${_realname}-git #-${_date} 156 | pkgver=20201202 157 | pkgrel=1 158 | pkgdesc="'mu' is a tool for dealing with e-mail messages stored in the Maildir-format." 159 | arch=('i686' 'x86_64') 160 | groups=('net-utils') 161 | license=('GPL-3.0') 162 | url="https://www.djcbsoftware.nl/code/mu/" 163 | # depends=(xapian-core libiconv libguile guile gmp libgc libcrypt) 164 | # makedepends=(git glib2-devel libiconv-devel libguile-devel gmp-devel libgc-devel libcrypt-devel xapian-core gmime3) 165 | depends=(glib2 xapian-core libiconv ) 166 | makedepends=(git glib2-devel libiconv-devel xapian-core gmime3 diffutils) 167 | source=("git+https://github.com/djcb/mu") 168 | sha256sums=('SKIP') 169 | 170 | pkgver() { 171 | cd "${srcdir}"/${_realname} 172 | # printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" 173 | git log -1 --format="%cd" --date=short | sed 's|-||g' 174 | } 175 | 176 | build() { 177 | cd "${srcdir}"/${_realname} 178 | if grep '^AX_LIB_READLINE' configure.ac; then 179 | patch -p1 < ../../mu-readline.patch 180 | fi 181 | if test -f Makefile; then 182 | make distclean 183 | fi 184 | chmod +x ./autogen.sh 185 | echo Using EMACS=$EMACS 186 | ./autogen.sh --disable-gtk --disable-webkit --disable-guile --disable-readline 187 | make 188 | } 189 | 190 | package() { 191 | cd "${srcdir}"/${_realname} 192 | make DESTDIR="${pkgdir}" install 193 | install -Dm644 COPYING "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE 194 | } 195 | 196 | EOF 197 | cat > "$msys2_extra_source_dir/mu/mu-readline.patch" <<\EOF 198 | diff --git a/configure.ac b/configure.ac 199 | index 9d8ebf2f..cbeb2e19 100644 200 | --- a/configure.ac 201 | +++ b/configure.ac 202 | @@ -246,10 +246,13 @@ AM_COND_IF([BUILD_GUILE],[AC_DEFINE(BUILD_GUILE,[1], [Do we support Guile?])]) 203 | 204 | ############################################################################### 205 | # optional readline 206 | -saved_libs=$LIBS 207 | -AX_LIB_READLINE 208 | -AC_SUBST(READLINE_LIBS,${LIBS}) 209 | -LIBS=$saved_libs 210 | +AC_ARG_ENABLE([readline], AS_HELP_STRING([--disable-readline],[Disable readline])) 211 | +AS_IF([test "x$enable_readline" != "xno"], [ 212 | + saved_libs=$LIBS 213 | + AX_LIB_READLINE 214 | + AC_SUBST(READLINE_LIBS,${LIBS}) 215 | + LIBS=$saved_libs 216 | +]) 217 | ############################################################################### 218 | 219 | ############################################################################### 220 | EOF 221 | } 222 | 223 | function msys2_extra_gmime3_pkg_description () 224 | { 225 | cat > "$msys2_extra_source_dir/gmime3/PKGBUILD" <<\EOF 226 | # Maintainer: damon-kwok 227 | 228 | pkgname=gmime3 229 | pkgver=3.2.7 230 | pkgrel=1 231 | pkgdesc="The GMime package contains a set of utilities for parsing and creating messages using the Multipurpose Internet Mail Extension (MIME) as defined by the applicable RFCs." 232 | arch=('i686' 'x86_64') 233 | groups=('libraries') 234 | license=('GPL') 235 | url="https://github.com/jstedfast/gmime" 236 | depends=(glib2 libiconv zlib libgpg-error) 237 | makedepends=(gcc gcc-libs make libtool autoconf automake pkg-config glib2-devel libiconv-devel zlib-devel libgpg-error-devel) 238 | provides=(libgmime-3.0.so) 239 | source=(http://ftp.gnome.org/pub/gnome/sources/gmime/3.2/gmime-${pkgver}.tar.xz) 240 | sha256sums=('2aea96647a468ba2160a64e17c6dc6afe674ed9ac86070624a3f584c10737d44') 241 | 242 | # depends=(glib2 gpgme zlib libidn2) 243 | # makedepends=(gobject-introspection gtk-doc git vala docbook-utils) 244 | # provides=(libgmime-3.0.so) 245 | # _commit=6546ed5e2935e5f99e99e0311ea6cec6d6101aaf # tags/3.2.6^0 246 | # source=("git+https://github.com/jstedfast/gmime#commit=$_commit") 247 | # sha256sums=('SKIP') 248 | 249 | 250 | build() { 251 | cd "gmime-${pkgver}" 252 | patch -p0 < ../../install.patch 253 | autoreconf --install -f --verbose 254 | ./configure --prefix=/usr --disable-static --enable-shared 255 | make 256 | } 257 | 258 | package() { 259 | cd "${srcdir}/gmime-${pkgver}" 260 | make DESTDIR="${pkgdir}" install 261 | install -Dm644 COPYING "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE 262 | } 263 | EOF 264 | 265 | } 266 | 267 | function msys2_extra_xapian_pkg_description () 268 | { 269 | cat > "$msys2_extra_source_dir/xapian-core/PKGBUILD" <<\EOF 270 | # Maintainer: damon-kwok 271 | 272 | pkgname=xapian-core 273 | # epoch=1 274 | pkgver=1.4.15 275 | pkgrel=1 276 | pkgdesc='Open source search engine library.' 277 | arch=('i686' 'x86_64') 278 | url='https://www.xapian.org/' 279 | license=('GPL') 280 | depends=('libutil-linux' zlib) 281 | makedepends=(gcc gcc-libs make libtool autoconf automake 'libutil-linux-devel' 'zlib-devel') 282 | # xapian config requires libxapian.la 283 | options=('libtool') 284 | source=("https://oligarchy.co.uk/xapian/${pkgver}/${pkgname}-${pkgver}.tar.xz") 285 | #{,.asc}) 286 | sha512sums=('f28209acae12a42a345382668f7f7da7a2ce5a08362d0e2af63c9f94cb2adca95366499a7afa0bd9008fbfcca4fd1f2c9221e594fc2a2c740f5899e9f03ecad3') 287 | 288 | # 1.4.14 sha512sums=('c08c9abe87e08491566b7cfa8cda9e2a80e4959a647428b6d82bce7af1c967b4cb463607ffb8976372a980c163923ced36117a66e0b5a1f35659393def3d371b') 289 | # 'SKIP') 290 | # validpgpkeys=('08E2400FF7FE8FEDE3ACB52818147B073BAD2B07') # Olly Betts 291 | 292 | build() { 293 | cd ${pkgname}-${pkgver} 294 | autoreconf --install -f --verbose 295 | ./configure --prefix=/usr --disable-dependency-tracking 296 | make 297 | } 298 | 299 | package() { 300 | cd ${pkgname}-${pkgver} 301 | make DESTDIR="${pkgdir}" install 302 | } 303 | EOF 304 | 305 | } 306 | 307 | 308 | function msys2_extra_isync_pkg_description () 309 | { 310 | cat > "$msys2_extra_source_dir/isync/PKGBUILD" <<\EOF 311 | # Maintainer: damon-kwok 312 | 313 | _realname=isync 314 | # _date="`date +%Y-%m-%d`" 315 | pkgname=${_realname}-git #-${_date} 316 | pkgver=20200804 317 | pkgrel=1 318 | pkgdesc="isync is a command line application which synchronizes mailboxes." 319 | arch=('i686' 'x86_64') 320 | groups=('net-utils') 321 | license=('GPL-2.0') 322 | url="http://isync.sourceforge.net/" 323 | depends=('openssl' 'libsasl' 'zlib' 'libdb') 324 | makedepends=('openssl-devel' 'libsasl-devel' 'zlib-devel' 'libdb') 325 | source=("git+https://git.code.sf.net/p/isync/isync") 326 | sha256sums=('SKIP') 327 | 328 | pkgver() { 329 | cd "${srcdir}"/${_realname} 330 | # printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" 331 | git log -1 --format="%cd" --date=short | sed 's|-||g' 332 | } 333 | 334 | build() { 335 | cd "${srcdir}"/${_realname} 336 | chmod +x ./autogen.sh 337 | ./autogen.sh 338 | ./configure --prefix=/usr 339 | make 340 | } 341 | 342 | package() { 343 | cd "${srcdir}"/${_realname} 344 | make DESTDIR="${pkgdir}" install 345 | install -Dm644 COPYING "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE 346 | } 347 | EOF 348 | 349 | } 350 | -------------------------------------------------------------------------------- /scripts/pdf-tools.sh: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Juan Jose Garcia-Ripoll 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in all 11 | # copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | # SOFTWARE. 20 | # 21 | ######################################## 22 | # 23 | # PDF-TOOLS 24 | # 25 | # Extra components to build and configure PDF-TOOLS in MSYS2/Mingw64 26 | # 27 | 28 | function action3_pdf_tools () 29 | { 30 | local pdf_tools_repo="https://github.com/politza/pdf-tools" 31 | local pdf_tools_branch="master" 32 | local pdf_tools_packages="${mingw_prefix}-poppler ${mingw_prefix}-glib2" 33 | 34 | local pdf_tools_source_dir="$emacs_build_git_dir/pdf-tools" 35 | local pdf_tools_server_dir="$pdf_tools_source_dir/server" 36 | local pdf_tools_build_dir="$emacs_build_build_dir/pdf-tools-$architecture" 37 | local pdf_tools_install_dir="$emacs_build_install_dir/pdf-tools-$architecture" 38 | local pdf_tools_zip_file="$emacs_build_zip_dir/pdf-tools-${architecture}.zip" 39 | local pdf_tools_skip_packages="${mingw_prefix}-python ${mingw_prefix}-tk ${mingw_prefix}-tcl" 40 | 41 | pdf_tools_dependencies="" 42 | 43 | if test -f $pdf_tools_zip_file; then 44 | echo File $pdf_tools_zip_file already exists. Refusing to rebuild. 45 | return 0 46 | fi 47 | 48 | pdf_tools_ensure_packages \ 49 | && pdf_tools_clone \ 50 | && prepare_source_dir "$pdf_tools_server_dir" \ 51 | && rm -rf "$pdf_tools_build_dir" \ 52 | && prepare_build_dir "$pdf_tools_build_dir" \ 53 | && pdf_tools_configure \ 54 | && pdf_tools_build \ 55 | && pdf_tools_install \ 56 | && pdf_tools_package \ 57 | && emacs_extensions="$pdf_tools_zip_file $emacs_extensions" 58 | } 59 | 60 | function pdf_tools_ensure_packages () 61 | { 62 | ensure_packages `pdf_tools_dependencies` 63 | } 64 | 65 | function pdf_tools_clone () 66 | { 67 | clone_repo $pdf_tools_branch $pdf_tools_repo $pdf_tools_source_dir 68 | if test "$?" = 0; then 69 | echo Prepping the PDF-TOOLS server for running 70 | cd $pdf_tools_server_dir 71 | ./autogen.sh 72 | fi 73 | return $? 74 | } 75 | 76 | function pdf_tools_dependencies () 77 | { 78 | # Print the list of all mingw/msys packages required for running emacs with 79 | # the selected features. Cache the result value. 80 | # 81 | if test -z "$pdf_tools_dependencies"; then 82 | errcho "Inspecting required packages for PDF-TOOLS: $pdf_tools_packages" 83 | local pdf_tools_all_dependencies=`full_dependency_list "$pdf_tools_packages" "$pdf_tools_skip_packages" "pdf-tools"` 84 | local emacs_all_dependencies=`emacs_dependencies` 85 | pdf_tools_dependencies=`elements_not_in_list "$pdf_tools_all_dependencies" "$emacs_all_dependencies"` 86 | errcho Total packages required: 87 | errcho `echo $pdf_tools_dependencies | sed -e 's, ,\n,g' -` 88 | fi 89 | echo $pdf_tools_dependencies 90 | } 91 | 92 | function pdf_tools_configure () 93 | { 94 | cd $pdf_tools_build_dir && "$pdf_tools_server_dir/configure" "--prefix=$pdf_tools_install_dir" 95 | } 96 | 97 | function pdf_tools_build () 98 | { 99 | echo Building PDF-TOOLS into directory $pdf_tools_build_dir 100 | make -C $pdf_tools_build_dir 101 | } 102 | 103 | function pdf_tools_byte_compile () 104 | { 105 | local lispdir="$pdf_tools_install_dir/share/emacs/site-lisp/" 106 | cd $lispdir 107 | $emacs_install_dir/bin/emacs -Q -batch -L . -f batch-byte-compile *.el || echo Failed 108 | } 109 | 110 | function pdf_tools_install () 111 | { 112 | local lispdir="$pdf_tools_install_dir/share/emacs/site-lisp/pdf-tools" 113 | local bindir="$pdf_tools_install_dir/bin" 114 | local docdir="$pdf_tools_install_dir/share/doc/pdf-tools" 115 | echo Installing PDF-TOOLS into directory $pdf_tools_install_dir 116 | mkdir -p $bindir $lispdir $docdir \ 117 | && cp $pdf_tools_source_dir/{README*,COPYING*,NEWS} $docdir/ \ 118 | && cp -rf $pdf_tools_source_dir/lisp/* $lispdir \ 119 | && cp $pdf_tools_build_dir/epdfinfo.exe $bindir 120 | } 121 | 122 | function pdf_tools_package () 123 | { 124 | package_dependencies "$pdf_tools_zip_file" "`pdf_tools_dependencies`" \ 125 | && cd "$pdf_tools_install_dir" \ 126 | && zip -9r "$pdf_tools_zip_file" * 127 | } 128 | 129 | 130 | function test_epdfinfo () 131 | { 132 | local empty_page="$emacs_build_root/tmp/empty.pdf" 133 | local epdfinfo="$emacs_full_install_dir/bin/epdfinfo.exe" 134 | test -x $epdfinfo \ 135 | && mkdir -p `dirname "$empty_page"` \ 136 | && pdf_tools_empty_page > "$empty_page" \ 137 | && (echo renderpage:$empty_page:1:100; echo quit) | $epdfinfo >/dev/null 2>&1 138 | } 139 | 140 | function pdf_tools_empty_page () 141 | { 142 | cat <<\EOF 143 | %PDF-1.0\n1 0 obj<>endobj 2 0 obj<>endobj 3 0 obj<>endobj\nxref\n0 4\n000000000065535 f\n0000000010 00000 n\n0000000053 00000 n\n0000000102 00000 n\ntrailer<>\nstartxref\n149\n%EOF 144 | EOF 145 | } 146 | -------------------------------------------------------------------------------- /scripts/setup-msys2.ps1: -------------------------------------------------------------------------------- 1 | # Ensure a minimal MSYS2/MINGW64 environment. We follow the recipes 2 | # from the GitHub Action setup-msys2, found at 3 | # https://github.com/msys2/setup-msys2/blob/master/main.js 4 | 5 | $emacs_build_dir = $PSScriptRoot + '\..' 6 | $msys2_dir = $env:msys2_dir 7 | if ($msys2_dir) 8 | { 9 | if (!(Test-Path "$msys2_dir")) 10 | { 11 | Write-Output "Environment variable msys2_dir suggests that MSYS2 is installed in" 12 | Write-Output " $msys2_dir" 13 | Write-Output "but there is no valid MSYS2 system there." 14 | exit -1 15 | } 16 | } 17 | else 18 | { 19 | # Location of MSYS can be overriden 20 | $msys2_dir = $emacs_build_dir + '\msys64' 21 | $env:msys2_dir = $msys2_dir 22 | if ( !(Test-Path "$msys2_dir") ) 23 | { 24 | Write-Output "Creating MSYS2 directory $msys2_dir" 25 | mkdir $msys2_dir 26 | } 27 | } 28 | 29 | if (!(Test-Path "$msys2_dir\msys2_shell.cmd")) 30 | { 31 | $release_url = 'https://api.github.com/repos/msys2/msys2-installer/releases/latest' 32 | # $inst_url = 'https://github.com/msys2/msys2-installer/releases/download/2022-09-04/msys2-base-x86_64-20220904.sfx.exe' 33 | # $installer_checksum = 'BB92718BCE932398A2E236D60C53EF35C3BC9A96999A26DD5814E66A2F4BAF1F' 34 | $installer = $msys2_dir + '\msys2-base.exe' 35 | 36 | if (!(Test-Path $installer)) 37 | { 38 | Write-Output "Downloading MSYS2 installer to $installer" 39 | [Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls" 40 | $installer_obj = (Invoke-RestMethod -Uri $release_url).assets | Where-Object { $_.name -match 'sfx.exe$' } 41 | Invoke-WebRequest -Uri $installer_obj.browser_download_url -OutFile $installer -UseBasicParsing 42 | } 43 | 44 | # $checksum = (Get-FileHash $installer -Algorithm SHA256)[0].Hash 45 | # if ($checksum -ne $installer_checksum) 46 | # { 47 | # Write-Output "Downloaded file $installer has checksum $checksum" 48 | # Write-Output "which differs from $installer_checksum" 49 | # } 50 | 51 | Write-Output "Emacs build root: $emacs_build_dir" 52 | Set-Location "$emacs_build_dir" 53 | Write-Output "Unpack MSYS2" 54 | & $installer -y 55 | 56 | Set-Location $emacs_build_dir 57 | # Reduce time required to install packages by disabling pacman's disk space checking 58 | .\scripts\msys2.cmd -c 'sed -i "s/^CheckSpace/#CheckSpace/g" /etc/pacman.conf' 59 | # Force update packages 60 | Write-Output "First forced update" 61 | .\scripts\msys2.cmd -c 'pacman --noprogressbar --noconfirm -Syuu' 62 | # We have changed /etc/pacman.conf above which means on a pacman upgrade 63 | # pacman.conf will be installed as pacman.conf.pacnew 64 | #.\scripts\msys2.cmd -c 'mv -f /etc/pacman.conf.pacnew /etc/pacman.conf' 65 | .\scripts\msys2.cmd -c 'sed -i "s/^CheckSpace/#CheckSpace/g" /etc/pacman.conf' 66 | # Kill remaining tasks 67 | taskkill /f /fi 'MODULES EQ msys-2.0.dll' 68 | } 69 | -------------------------------------------------------------------------------- /scripts/site-start.el: -------------------------------------------------------------------------------- 1 | (let* ((emacs-libexec-path (car (last exec-path))) 2 | (emacs-libexec-ndx (string-match "libexec" emacs-libexec-path)) 3 | (emacs-root (substring emacs-libexec-path 0 emacs-libexec-ndx)) 4 | (msys2-dir (expand-file-name "usr/bin/" emacs-root)) 5 | (mingw-dir (expand-file-name "bin/" emacs-root))) 6 | (add-to-list 'exec-path msys2-dir) 7 | (add-to-list 'exec-path mingw-dir) 8 | (setenv "PATH" (concat mingw-dir ";" msys2-dir ";" (getenv "PATH"))) 9 | (let ((default-directory (expand-file-name "usr/share/emacs/site-lisp/" emacs-root))) 10 | (when (file-exists-p default-directory) 11 | (if (fboundp 'normal-top-level-add-subdirs-to-load-path) 12 | (normal-top-level-add-subdirs-to-load-path))))) 13 | 14 | ;; This is for MSYS2 tools 15 | (setenv "TMPDIR" (getenv "TEMP")) 16 | -------------------------------------------------------------------------------- /scripts/tools.sh: -------------------------------------------------------------------------------- 1 | function errcho () 2 | { 3 | echo "$@" >&2 4 | } 5 | 6 | function unique_list () 7 | { 8 | # To preserve order, we use awk to remove duplicates `awk '!seen[$0]++'` 9 | echo $* | sed -e 's,[[:space:]][[:space:]]*,\n,g' | sort | uniq | sed -e '/^$/d' 10 | } 11 | 12 | function elements_not_in_list () 13 | { 14 | local listb=`echo $2 | sed 's,[[:space:]][[:space:]]*,|,g'` 15 | echo $1 | sed 's,[[:space:]],\n,g' | sort | uniq | grep -E -v "($listb)" 16 | } 17 | 18 | function git_branch_name_to_file_name () 19 | { 20 | echo $1 | sed -e 's,[^-a-zA-Z0-9],_,g' 21 | } 22 | 23 | function git_version () 24 | { 25 | local source_dir="$1" 26 | pushd . >/dev/null 27 | cd $source_dir 28 | echo `date +'%Y%m%d'`.`git rev-parse --short=7 HEAD` 29 | popd >/dev/null 30 | } 31 | 32 | function clone_repo () 33 | { 34 | # Download a Git repo 35 | # 36 | local branch="$1" 37 | local repo="$2" 38 | local source_dir="$3" 39 | 40 | pushd . >/dev/null 41 | local error 42 | if test -d "$source_dir"; then 43 | echo Updating repository 44 | cd "$source_dir" 45 | git pull && git reset --hard && git checkout 46 | error=$? 47 | if test $? != 0; then 48 | echo Source repository update failed. 49 | fi 50 | else 51 | echo Cloning Emacs repository $repo. 52 | git clone --filter=tree:0 "$repo" "$source_dir" --no-checkout && \ 53 | cd "$source_dir" && git config pull.rebase false && git checkout "$branch" 54 | error=$? 55 | if test $? != 0; then 56 | echo Git clone failed. Deleting source directory. 57 | rm -rf "$source_dir" 58 | fi 59 | fi 60 | # 61 | # If there was a 'configure' script, remove it, to force running autoreconf 62 | # again before builds. 63 | rm -f "$source_dir/configure" 64 | popd >/dev/null 65 | return $error 66 | } 67 | 68 | function apply_patches () 69 | { 70 | local source_dir="$1" 71 | local patches_dir="$emacs_build_root/patches/emacs" 72 | pushd . >/dev/null 73 | local error 74 | if test -d "$source_dir"; then 75 | echo Applying patches in $patches_dir 76 | cd $source_dir 77 | find $patches_dir/*.patch | xargs -I % $SHELL -c 'git apply --ignore-space-change --ignore-whitespace % || true' 78 | error=$? 79 | fi 80 | 81 | popd >/dev/null 82 | return $error 83 | } 84 | 85 | function list_filter () { 86 | while test -n "$*"; do 87 | case $1 in 88 | -e) shift; 89 | grep -P -v "^(`echo $1 | sed 's,[ \n],|,g'`)" -; 90 | return 0;; 91 | -i) shift; 92 | grep -P "`echo $1 | sed 's,[ \n],|,g'`" -; 93 | return 0;; 94 | *) echo "Unknown option: $1"; return -1;; 95 | esac 96 | shift 97 | done 98 | 99 | cat - 100 | } 101 | 102 | function raw_dependencies_wo_versions () 103 | { 104 | local munge_pgks=" 105 | s,$mingw_prefix-libwinpthread\$,$mingw_prefix-libwinpthread-git,g; 106 | s,$mingw_prefix-libtre\$,$mingw_prefix-libtre-git,g;" 107 | pacman -Qii $* | grep Depends | sed -e 's,[>=][^ ]*,,g;s,Depends[^:]*:,,g;s,None,,g' -e "$munge_pgks" 108 | } 109 | 110 | function full_dependency_list () 111 | { 112 | # Given a list of packages, print a list of all dependencies 113 | # 114 | # Input 115 | # $1 = list of packages without dependencies 116 | # $2 = list of packages to skip 117 | # $3 = Origin of this list 118 | # $4 = If non-empty, add mingw prefix 119 | # 120 | # Packages that have to be replaced by others for distribution 121 | local packages="$1" 122 | local skip_pkgs="$2" 123 | local context="$3" 124 | local avoid_prefix="$4" 125 | local oldpackages 126 | local dependencies 127 | if test "$debug_dependency_list" = "yes"; then 128 | local newpackages 129 | errcho "Debugging package list for $3" 130 | newpackages="$1" 131 | packages="" 132 | while [ -n "$newpackages" ]; do 133 | oldpackages=`unique_list $newpackages` 134 | packages=`unique_list $newpackages $packages` 135 | newpackages="" 136 | for p in $oldpackages; do 137 | dependencies=`raw_dependencies_wo_versions $p` 138 | dependencies=`elements_not_in_list "$dependencies" "$skip_pkgs $packages"` 139 | if [ -n "$dependencies" ]; then 140 | errcho "Package $p introduces" 141 | for i in $dependencies; do errcho " $i"; done 142 | newpackages="$dependencies $newpackages" 143 | fi 144 | done 145 | done 146 | else 147 | while test "$oldpackages" != "$packages" ; do 148 | oldpackages="$packages" 149 | dependencies=`raw_dependencies_wo_versions $oldpackages` 150 | test -n "$skip_pkgs" && \ 151 | dependencies=`elements_not_in_list "$dependencies" "$skip_pkgs"` 152 | packages=`unique_list $oldpackages $dependencies` 153 | done 154 | fi 155 | echo $packages 156 | } 157 | 158 | function ensure_packages () 159 | { 160 | local packages=$@ 161 | echo Ensuring packages are installed 162 | if pacman -Qi $packages >/dev/null 2>&1; then 163 | echo All packages are installed. 164 | else 165 | echo Some packages are missing. Installing them with pacman. 166 | pacman -S --needed --noconfirm -q $packages 167 | fi 168 | } 169 | 170 | function cp_bindeps_to () 171 | { 172 | local dest="$1" 173 | local bins="${@:2}" 174 | echo Copying $bins to $dest with dependencies 175 | echo $bins | xargs -n1 | xargs which | xargs -I{} cp -pf {} $dest/ 176 | echo $bins | xargs -n1 | xargs which | xargs ldd \ 177 | | awk -F' ' '!/ \/c\//{print $3}' \ 178 | | xargs -I{} cp -pf {} $dest/ 179 | } 180 | 181 | function package_dependencies () 182 | { 183 | local zipfile="$1" 184 | local dependencies="$2" 185 | rm -f "$zipfile" 186 | mkdir -p `dirname "$zipfile"` 187 | cd $mingw_dir 188 | if test "$debug_dependency_list" = "yes"; then 189 | echo Files prior to filter 190 | pacman -Ql $dependencies | cut -d ' ' -f 2 | sort | uniq \ 191 | | grep "^$mingw_dir" | sed -e "s,^$mingw_dir,,g" 192 | echo Filter 193 | echo $slim_exclusions 194 | echo Files to package 195 | pacman -Ql $dependencies | cut -d ' ' -f 2 | sort | uniq \ 196 | | grep "^$mingw_dir" | sed -e "s,^$mingw_dir,,g" | list_filter -e "$dependency_exclusions" 197 | fi 198 | echo Packing dependency files from root dir $mingw_dir 199 | pacman -Ql $dependencies | cut -d ' ' -f 2 | sort | uniq \ 200 | | grep "^$mingw_dir" | sed -e "s,^$mingw_dir,,g" \ 201 | | list_filter -e "$dependency_exclusions" | xargs zip -9 $zipfile 202 | } 203 | 204 | function prepare_source_dir () 205 | { 206 | local source_dir="$1" 207 | if test -d "$source_dir"; then 208 | if test -f "$source_dir/configure"; then 209 | echo Configure script exists. Nothing to do in source directory $source_dir 210 | echo 211 | return 0 212 | fi 213 | cd "$source_dir" && ./autogen.sh && return 0 214 | echo Unable to prepare source directory. Autoreconf failed. 215 | else 216 | echo Source directory $source_dir missing 217 | echo Run script with --clone first 218 | echo 219 | fi 220 | return -1 221 | } 222 | 223 | function prepare_build_dir () 224 | { 225 | local build_dir="$1" 226 | if test -d "$build_dir"; then 227 | if test -f "$build_dir/config.log"; then 228 | rm -rf "$build_dir/*" 229 | else 230 | echo Cannot rebuild on existing directory $build_dir 231 | return -1 232 | fi 233 | else 234 | mkdir -p "$build_dir" 235 | fi 236 | } 237 | 238 | function try_download () 239 | { 240 | local url="$1" 241 | local destination="$2" 242 | local attempts="$3" 243 | if [ -z "$attempts" ]; then 244 | attempts=3 245 | fi 246 | while [ $attempts -gt 0 ]; do 247 | curl --progress-bar --retry 3 --output "$destination" "$url" && return 0 248 | attempts=$(($attempts - 1)) 249 | done 250 | return -1 251 | } 252 | -------------------------------------------------------------------------------- /scripts/trackdlls.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # trackdlls.sh executable_name 4 | # 5 | # Recursively scan the executable file and all the libraries it depends 6 | # on, to ensure that the libraries can be found in the path. This is used 7 | # to verify that we build the right installation. 8 | # 9 | dlls="" 10 | olddlls="none" 11 | exes="$1" 12 | PATH="`dirname $1`:$PATH" 13 | exesdone="" 14 | extract_DLLs='s,[ ]*DLL Name: ,,g' 15 | clean_spaces='s,\n, ,g;s,[ \t\n][ \t\n]*, ,g' 16 | split='s,[ ][ ]*,\n,g' 17 | while [ "$olddlls" != "$dlls" ]; do 18 | olddlls="$dlls" 19 | exesdone="$exes $exesdone" 20 | for p in $exes; do 21 | truep=`which $p` 22 | newdlls=`objdump -x $truep | grep "DLL Name" | sed -e "$extract_DLLs;$clean_spaces"` 23 | dlls=`echo $dlls $newdlls | sed -e "$split" | sort | uniq` 24 | done 25 | exes="" 26 | for i in $dlls; do 27 | if [[ " $exesdone $exes " =~ [[:space:]]$i[[:space:]] ]]; then 28 | true # echo File $i already checked or will be checked 29 | else 30 | truename=`which $i` 31 | if [ -z "$truename" ]; then 32 | echo DLL not found in path 33 | missing="$i $missing" 34 | elif [[ "$truename" =~ .*/Windows/System32.* ]]; then 35 | echo DLL $i from Windows, not scanning further. 36 | exesdone="$i $exesdone" 37 | else 38 | echo Adding $i to tests 39 | exes="$i $exes" 40 | fi 41 | fi 42 | done 43 | done 44 | for i in $missing; do 45 | echo "*** Missing library $i" 46 | done 47 | -------------------------------------------------------------------------------- /template/appxmanifest.t.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 12 | 13 | Emacs 14 | GNU 15 | EmacsDev 16 | share\icons\hicolor\128x128\apps\emacs.png 17 | 18 | 19 | 20 | 21 | 22 | 24 | 25 | 26 | 27 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | --------------------------------------------------------------------------------