Issue 1:
I encountered this issue at build time while testing #16246 on a Haswell-based CPU supporting AVX2.

This is due to a confirmed bug in GCC that is fixed since GCC 8.4: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65782

One suggested workaround on Stack Overflow was to pass a number of -ffixed-<reg> flags to prevent GCC from producing code using the unsupported registers:

-ffixed-xmm16 -ffixed-xmm17 -ffixed-xmm18 -ffixed-xmm19
-ffixed-xmm20 -ffixed-xmm21 -ffixed-xmm22 -ffixed-xmm23
-ffixed-xmm24 -ffixed-xmm25 -ffixed-xmm26 -ffixed-xmm27
-ffixed-xmm28 -ffixed-xmm29 -ffixed-xmm30 -ffixed-xmm31

I found that this workaround worked for me. So a possible workaround in Numpy would be to automatically add these flags to CFLAGS, at least on Cygwin and GCC < 8.4 (does Numpy's build system have an existing routine to check the compiler version?)

Error message:

numpy/core/src/umath/loops.c.src:3058:1: warning: AVX512F vector return without AVX512F enabled changes the ABI [-Wpsabi]
}
^
numpy/core/src/umath/loops.c.src:3058:1: warning: AVX vector return without AVX enabled changes the ABI [-Wpsabi]
{standard input}: Assembler messages:
{standard input}:9023: Error: invalid register for .seh_savexmm
{standard input}:9025: Error: invalid register for .seh_savexmm
{standard input}:9027: Error: invalid register for .seh_savexmm
... several more similar lines ...

Numpy/Python version information:

1.20.0.dev0+7f7d19d 3.6.8 (default, Feb 14 2019, 22:09:48)
[GCC 7.4.0]

Issue 2:
Attempting to install numpy 1.17.3 on cygwin fails, with the only reported error message being invalid register for .seh_savexmm.

I can't figure out where this would be getting called, since the reported file is standard input and grepping the source for savexmm does not produce any obvious clues.

Reproducing code example:

python3 -m pip install numpy==1.17.3

Error message:

Error message on third and subsequent compilations

...
gcc: build/src.cygwin-3.0.7-x86_64-3.5/numpy/core/src/umath/loops.c
{standard input}: Assembler messages:
{standard input}:4612: Error: invalid register for .seh_savexmm
{standard input}:4614: Error: invalid register for .seh_savexmm
{standard input}:4616: Error: invalid register for .seh_savexmm
{standard input}:4618: Error: invalid register for .seh_savexmm
{standard input}:4620: Error: invalid register for .seh_savexmm
{standard input}:4622: Error: invalid register for .seh_savexmm
{standard input}:6493: Error: invalid register for .seh_savexmm
{standard input}:6495: Error: invalid register for .seh_savexmm
{standard input}:6497: Error: invalid register for .seh_savexmm
{standard input}:6499: Error: invalid register for .seh_savexmm
{standard input}:6501: Error: invalid register for .seh_savexmm
{standard input}:6503: Error: invalid register for .seh_savexmm
{standard input}:6505: Error: invalid register for .seh_savexmm
numpy/core/src/umath/loops.c.src: In function ‘PyUFunc_e_e’:
numpy/core/src/umath/loops.c.src:77:1: warning: visibility attribute not supported in this configuration; ignored [-Wattributes]
}
^
...
numpy/core/src/umath/loops.c.src: In function ‘OBJECT_sign’:
numpy/core/src/umath/loops.c.src:2919:1: warning: visibility attribute not supported in this configuration; ignored [-Wattributes]
}
^
error: Command "gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -ggdb -O2 -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -fdebug-prefix-map=/usr/src/ports/python36/python36-3.6.9-1.x86_64/build=/usr/src/debug/python36-3.6.9-1 -fdebug-prefix-map=/usr/src/ports/python36/python36-3.6.9-1.x86_64/src/Python-3.6.9=/usr/src/debug/python36-3.6.9-1 -ggdb -O2 -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -fdebug-prefix-map=/usr/src/ports/python36/python36-3.6.9-1.x86_64/build=/usr/src/debug/python36-3.6.9-1 -fdebug-prefix-map=/usr/src/ports/python36/python36-3.6.9-1.x86_64/src/Python-3.6.9=/usr/src/debug/python36-3.6.9-1 -DNPY_INTERNAL_BUILD=1 -DHAVE_NPY_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -DNO_ATLAS_INFO=1 -DHAVE_CBLAS -I/usr/local/include -I/usr/include -I/usr/include/suitesparse -Ibuild/src.cygwin-3.0.7-x86_64-3.6/numpy/core/src/umath -Ibuild/src.cygwin-3.0.7-x86_64-3.6/numpy/core/src/npymath -Ibuild/src.cygwin-3.0.7-x86_64-3.6/numpy/core/src/common -Inumpy/core/include -Ibuild/src.cygwin-3.0.7-x86_64-3.6/numpy/core/include/numpy -Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -I/usr/include/python3.6m -Ibuild/src.cygwin-3.0.7-x86_64-3.6/numpy/core/src/common -Ibuild/src.cygwin-3.0.7-x86_64-3.6/numpy/core/src/npymath -Ibuild/src.cygwin-3.0.7-x86_64-3.6/numpy/core/src/common -Ibuild/src.cygwin-3.0.7-x86_64-3.6/numpy/core/src/npymath -c build/src.cygwin-3.0.7-x86_64-3.6/numpy/core/src/umath/loops.c -o build/temp.cygwin-3.0.7-x86_64-3.6/build/src.cygwin-3.0.7-x86_64-3.6/numpy/core/src/umath/loops.o -MMD -MF build/temp.cygwin-3.0.7-x86_64-3.6/build/src.cygwin-3.0.7-x86_64-3.6/numpy/core/src/umath/loops.o.d" failed with exit status 1
...

The first and second compilations produce different output before the block of errors, but are otherwise identical.

Numpy/Python version information:

Compiling numpy 1.17.3 on python 3.5.7 fails as described above.

Compiling numpy 1.17.0 on python 3.7.4 fails in the manner described above.

Numpy 1.16.5 built just fine and passed most tests.

How would I go about debugging this?