On Thu, Jun 30, 2022 at 9:25 PM Matthew Brett <matthew.brett@gmail.com> wrote:
Hi,

On Thu, Jun 30, 2022 at 8:14 PM Matthew Brett <matthew.brett@gmail.com> wrote:

> >> >>
> >> >> I guess we should change that text to note these do not work on Windows.
> >> >>
> >> >> I think you can supply extra Fortran flags with the `config_gc` option
> >> >> to `setup.py`, but I don't think the others have any effect on
> >> >> Windows.
> >> >>
> >> >> I was also confused by these lines in `azure-steps-windows.yml`:
> >> >>
> >> >> """
> >> >>         $env:CFLAGS = "-m32"
> >> >>         $env:LDFLAGS = "-m32"
> >> >> """
> >> >>
> >> >> I assume these don't actually have any effect.
> >> >
> >> >
> >> > No, the above all seem wrong (unless there has been a major regression recently), and the `-m32` flags work and are necessary. CFLAGS, FFLAGS, CXXFLAGS and LDFLAGS can be used, and append compile flags. If you want to remove flags that are already hardcoded in numpy.distutils, then that's a different story - you need to edit the numpy.distutils source code then.
> >> >
> >> > I just stumbled on a Windows problem with `$env:`, and the problem was Windows CI is hopelessly weird. It matters for example if you do something in a Powershell context (`ps |` in a .yml file) or outside of it. So it may be something like that.
> >>
> >> Are you sure though - that you can append flags to the compile and
> >> link step with CFLAGS and LDFLAGS?   It didn't work for me locally.
> >> And I can't see where they would have an effect, on Windows, in the
> >> code.
> >
> >
> > Yes I'm sure, and it's even one of the few things in numpy.distutils that are tested: https://github.com/numpy/numpy/pull/14250. Maybe see if you can make that test fail when setting env vars in a couple of different ways?
>
> I've put up a minimal repo:
>
> https://github.com/matthew-brett/minnpd
>
> I ran
>
> > $env:CFLAGS = "-mbad-opt"
> > $env:LDFLAGS="-bad-option"
> > python setup.py build
>
> You can see from the `build.log` file, that the build doesn't pick up
> either flag.

Windows also ignores the CC environment variable:

$ $env:CC = "cl -mbad-opt"
$ python setup.py build

Looks like a Windows-specific bug in `distutils` then (assuming the `$env` bit is correct, I still don't trust it). I don't have a Windows machine available, but on Linux this errors out quickly:

$ CC="gcc -mbad-opt" python setup.py build
...
gcc: error: unrecognized command line option '-mbad-opt'

And same for CFLAGS, it works as advertised.

Probably not worth spending more time on, since this is all deprecated code.

Cheers,
Ralf