Skip to content

Comments

Fix compilation on Windows#207

Merged
dimpase merged 10 commits intosagemath:mainfrom
tobiasdiez:win-support
Nov 19, 2024
Merged

Fix compilation on Windows#207
dimpase merged 10 commits intosagemath:mainfrom
tobiasdiez:win-support

Conversation

@tobiasdiez
Copy link
Contributor

@tobiasdiez tobiasdiez commented Oct 29, 2024

Based on #206, we make cysignals compile nicely on Windows. The tests (that are meaningful for windows) are passing, but I'm not sure if further work is necessary to handle Windows specifics. In either case, this should serve as a good start.

Windows (mingw) is added to ci to make sure that it keeps working.

Fixes #201 and fixes #198

@tobiasdiez
Copy link
Contributor Author

@dimpase @fchapoton Tests are passing, so this is good to go from my side. Please have a careful look at the changes to make sure I'm not breaking anything on linux and macos here (I really don't have a strong understanding of signal processing on unix).

@dimpase
Copy link
Member

dimpase commented Nov 18, 2024

you've removed cysignals_config.h.in - are you sure we don't need something like cysignals_config.h ?

@tobiasdiez
Copy link
Contributor Author

cysignals_config

It's now generated by meson: configure_file(output: 'cysignals_config.h', configuration: config, install_dir: py.get_install_dir(pure: false) / 'cysignals', install: true). No need to have a cysignals_config.h.in as source.

from gc import collect

# On Windows, some signals are not pre-defined.
# We define them here with values that will never occur in practice
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://stackoverflow.com/a/8420498/557937 shows how to do a sort of SIGALRM on Windows
(outdated, - python 2.7 - so perhaps there are better ways now)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's for a future consideration - this PR doesn't need to do anything here.

Copy link
Member

@dimpase dimpase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@dimpase dimpase merged commit 6633f1e into sagemath:main Nov 19, 2024
@tobiasdiez tobiasdiez deleted the win-support branch November 20, 2024 06:34
@tobiasdiez
Copy link
Contributor Author

Thanks Dima!

vbraun pushed a commit to vbraun/sage that referenced this pull request May 17, 2025
sagemathgh-38872: Native Windows build
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

The goal of this PR is to provide a native Windows build of Sage using
MSVC (using the new Meson build system).

Instructions on how to test are under the `Windows` tab at https://doc-
pr-38872--sagemath.netlify.app/html/en/installation/meson.
Afterwards, you should be able to import some sage modules in a normal
`python` install (but most modules actually don't properly import due to
various errors that will be fixed peu a peu in follow-up PRs)

## State of Windows support of dependencies

- m4rie: upstream (https://github.com/malb/m4rie) doesn't provide win
build
- ec: not sure if upstream (https://github.com/JohnCremona/eclib)
provide win build
- ecm: upstream (https://gitlab.inria.fr/zimmerma/ecm) doesn't provide
native win build (only Cygwin)
- ntl: upstream provides win build (kind of), but it's not yet available
on conda (conda-forge/ntl-feedstock#16)
- maxima/ecl: upstream provides win build, but it's not yet available on
conda (conda-forge/maxima-feedstock#38)
- GAP: only cygiwn build exists https://github.com/gap-
system/gap/issues/4157
- [pari](http://pari.math.u-bordeaux.fr/pub/pari): now available on
conda (conda-forge/pari-feedstock#45)
- cypari2: no windows support yet
sagemath/cypari2#19
- lrcalc
- pplpy
- primecountpy
- fpylll
- rw
- cliquer
- lcalc
- ecl
- braiding
- gc
- homfly
- iml
- brial_groebner

## Conda Issues:
- Meson cannot find libraries without pkg-config files.
     - Workaround: Check that `set LIB` includes the conda env (e.g.
`...\.conda\envs\sage-dev\Library\lib`). If not, run `conda deactivate`
followed by `conda activate sage-dev` and then check again.
     - Alternatively, `set LIB=%CONDA_PREFIX%\Library\lib;%LIB%`
     - Possible upstream improvement: the compilers conda package should
set `LIB`
- If you don't have the debug version of Python installed, you may get
"LINK : fatal error LNK1104: cannot open file 'python311_d.lib'"
     - Workaround: `meson setup builddir -Dbuildtype=release`
     - Alternatively, in `<path to conda>\sage-dev\include\pyconfig.h`
uncomment: `//#       define Py_DEBUG` and change `python311_d.lib` to
`python311.lib`
     - Possible upstream improvement: conda should either ship a debug
version of python or a correct `pyconfig.h`
- conda-forge/gsl-feedstock#63
     - Workaround: Fallback to find_library in meson and/or change the
`gsl.pc` to match:
       ```
       prefix=C:/Users/Tobia/.conda/envs/sage-dev/Library
       exec_prefix=C:/Users/Tobia/.conda/envs/sage-dev/Library
       libdir=C:/Users/Tobia/.conda/envs/sage-dev/Library/lib
       sharedlibdir=C:/Users/Tobia/.conda/envs/sage-dev/Library/lib
       includedir=C:/Users/Tobia/.conda/envs/sage-dev/Library/include
       GSL_CBLAS_LIB=-lgslcblas

       Name: GSL
       Description: GNU Scientific Library
       Version: 2.7
       Libs: -L${libdir} -lgsl ${GSL_CBLAS_LIB}
       Cflags: -I${includedir}
       ```
- conda-forge/compilers-feedstock#66
     - Workaround: Run everything in "VS x64 Native Tools Command
Prompt" (for 64bit) or "Developer Command Prompt for VS2022 (or 2019)"
(for 32bit)
- conda-forge/libgd-feedstock#55
     - Workaround: Fallback to find_library in meson
- conda-forge/m4ri-feedstock#15
    - Workaround: Don't try to use m4ri on windows
- conda-forge/libflint-feedstock#38
    - Workaround: Don't try to use flint on windows

## Upstream issues
Singular
- Singular/Singular#1245
- Singular/Singular#1246
- Singular/Singular#1247

Flint:
- flintlib/flint#2100
- mingw-w64/mingw-w64#65 (indirectly since
pthread is flint dependency). Would be fixed by
conda-forge/libflint-feedstock#38.
   -> Workaround: Change `typedef __int64 pid_t;` to `typedef int
pid_t;` in `.conda\envs\sage-dev\Library\include\pthread_compat.h`
- flintlib/flint#2101:
   -> Workaround: disable compilation of fraction_field_FpT for now

Cysignals:
- sagemath/cysignals#207
- sagemath/cysignals#206


### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [ ] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#38872
Reported by: Tobias Diez
Reviewer(s): Dima Pasechnik
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Problems building cysignal on Windows 11 Failing to build (2 windows machines so far)

2 participants