Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling numpy 1.17 on cygwin fails with `Error: invalid register for .seh_savexmm #14787

Closed
DWesl opened this issue Oct 26, 2019 · 20 comments
Closed

Comments

@DWesl
Copy link
Contributor

DWesl commented Oct 26, 2019

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?

@charris
Copy link
Member

charris commented Oct 26, 2019

Sounds like a hardware detection or compiler problem. What GCC version do you have? Are you running 32 or 64 bits?

@DWesl
Copy link
Contributor Author

DWesl commented Oct 26, 2019

64-bit Cygwin with GCC 8.3.0.

@DWesl
Copy link
Contributor Author

DWesl commented Oct 26, 2019

Numpy 1.17.3 installs fine on 32-bit Cygwin with gcc 7.4.0 and python 3.6.9

@DWesl
Copy link
Contributor Author

DWesl commented Oct 26, 2019

Installing numpy 1.17.3 from source with pip on 64-bit WSL-debian using python 3.7.3 and gcc 8.3.0 worked fine.
All trials here were on the same machine.

@DWesl
Copy link
Contributor Author

DWesl commented Oct 27, 2019

Running git bisect points to the following commit:

651e03c0019d4c4c6ca8c43cb7d7c0d344a72cc1 is the first bad commit
commit 651e03c0019d4c4c6ca8c43cb7d7c0d344a72cc1
Author: Raghuveer Devulapalli
Date:   Thu Mar 28 15:07:35 2019 -0700

    BUG: Adding macro HAVE_ATTRIBUTE_TARGET_@ISA@_WITH_INTRINSICS

    1) use __builtin_cpu_supports("avx512f") only for gcc ver >= 5

    2) Introduced two new macro's:
    HAVE_ATTRIBUTE_TARGET_@ISA@_WITH_INTRINSICS for ensuring compiler can
    compile functions that use intrinsics and are compiled with avx2/avx512f
    attributes

:040000 040000 17c469bd32baf93f8306d76ea3d7bcec9b98f286 5c129001b713ed2edf09f2e98c8c0fa61316d985 M      numpy
bisect run success

I restricted attention to numpy/core/src/umath/loops.c.src, so it might also be a tad before this commit.

@charris
Copy link
Member

charris commented Oct 27, 2019

What is your cpu? I think this is a compiler/configuration problem. Are you running in a virtual environment by any chance.

@DWesl
Copy link
Contributor Author

DWesl commented Oct 27, 2019

Four commits before that one works; three before does not.
That is, it would appear 9754a20 is the first to fail in this way.
I don't know what to do next.

@DWesl
Copy link
Contributor Author

DWesl commented Oct 27, 2019

No virtual environment, Intel core i5. /proc/cpuinfo lists avx2 but not avx512f. I think the chip is 6th generation/Skylake. Manually running the probes for avx2 and avx512f target attribute support both succeed.

@mattip
Copy link
Member

mattip commented Oct 27, 2019

In order to freeze the build, you can do this, the -b should then have the results of the failed build.

python3 -m pip install numpy==1.17.3 -b /tmp/numpy

This stack overflow suggests adding -fno-asynchronous-unwind-tables. You could try just running the line that fails once with that flag and once without

@DWesl
Copy link
Contributor Author

DWesl commented Oct 27, 2019

Thank you, -fno-asynchronous-unwind-tables fixed it. I'll report back once the tests have run.

@mattip
Copy link
Member

mattip commented Oct 28, 2019

According to gcc bug report, it has not been fixed. We could add the flag unconditionally when cygwin is detected, but then it would get lost inside distutils and we would not know to update it when gcc fixes the problem.

@eric-wieser
Copy link
Member

Should we add a config test for the need for this flag, which is what I did last time I got a compiler bug?

@mattip
Copy link
Member

mattip commented Oct 28, 2019

sure, maybe we should have done that with the -std=c99 fix as well. It is a flag, not a "HAVE" test. Where would we add that?

@eric-wieser
Copy link
Member

Hmm, I hadn't thought of that. This is the change I'd made before I was thinking about: https://github.com/numpy/numpy/pull/13739/files#diff-33315af1a22893e97676ee134db5ce1cR466-R471

@mattip
Copy link
Member

mattip commented Oct 28, 2019

We could some new moredefs.append('NPY_DO_NOT_OPTIMIZE_XXX'). While I don't think we should add a cygwin Azure run, maybe I can set up an environment somewhere

@DWesl
Copy link
Contributor Author

DWesl commented Feb 16, 2020 via email

@DWesl
Copy link
Contributor Author

DWesl commented May 14, 2020

I got 1.18.4 to pass all tests expected, with

CFLAGS="-fno-asynchronous-unwind-tables
-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 think I also tested it with just the -ffixed-xmm16-30 flags, and that also worked.
I'll get my environment set up to submit the patches for that to work: I'm not sure where I would add the flags.

@DWesl
Copy link
Contributor Author

DWesl commented May 15, 2020

I forgot to pass the flags when testing a PR, so apparently this is gone. The GCC bug report above now says "fixed", so I'm not sure whether it's GCC or NumPy that did something to make this go away.

Current NumPy master (will be 1.19) on 64-bit Cygwin 3.1.4 with GCC 9.3.0.

1.17.3 compiles just fine now as well, so I'm suspecting this is a GCC fix.

@DWesl
Copy link
Contributor Author

DWesl commented May 18, 2020

This is still an issue on older GCC (<8.4), see #16290.

@DWesl DWesl reopened this May 18, 2020
embray added a commit to embray/numpy that referenced this issue Oct 13, 2020
… flags

when building the numpy.core._multiarray_umath module

This adds the extra compile args to the extension needed to work around
the bug but only in the known case where the bug is relevant.
mattip added a commit that referenced this issue Oct 14, 2020
BUG: Workaround for #14787 on affected platforms
charris pushed a commit to charris/numpy that referenced this issue Oct 15, 2020
… flags

when building the numpy.core._multiarray_umath module

This adds the extra compile args to the extension needed to work around
the bug but only in the known case where the bug is relevant.
charris added a commit that referenced this issue Oct 15, 2020
BUG: Cygwin Workaround for #14787 on affected platforms
@DWesl
Copy link
Contributor Author

DWesl commented Oct 20, 2020

Given #17548 and friends, I think this issue is resolved in trunk and a few older release branches, so it's time to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants