On Thu, Jun 30, 2022 at 10:29 AM Matthew Brett <matthew.brett@gmail.com> wrote:
Hi,

On Thu, Jun 30, 2022 at 12:42 AM Kevin Sheppard
<kevin.k.sheppard@gmail.com> wrote:
>>
>>
>> Hi,
>>
>> I am very sorry - I feel I should know this, or be able to work it
>> out, but is there a way of setting the flags to the C compiler and the
>> linker, for the Numpy build, on Windows?
>>
>> I'm trying to set the flags for a build with Windows mingw-w64 - but I
>> believe Numpy is ignoring $env:LDFLAGS, $env:CFLAGS and $env:OPT - and
>> I can't see any way of setting these options from the command line.
>> Am I missing something?
>>
>> Cheers,
>>
>> Matthew

>> Member address: kevin.k.sheppard@gmail.com
>
>
> I think these are all hard coded and non-changable.  This was the case when I got NumPy building with clang-cl.

That was my impression too, but I was delayed by the text at:

https://numpy.org/doc/stable/user/building.html#supplying-additional-compiler-flags

which says:

"""
Additional compiler flags can be supplied by setting the OPT, FOPT
(for Fortran), and CC environment variables. When providing options
that should improve the performance of the code ensure that you also
set -DNDEBUG so that debugging code is not executed.
"""

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.

Cheers,
Ralf