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

Segfault when building with Apple Clang 15 #474

Closed
adamjstewart opened this issue Oct 29, 2023 · 12 comments
Closed

Segfault when building with Apple Clang 15 #474

adamjstewart opened this issue Oct 29, 2023 · 12 comments

Comments

@adamjstewart
Copy link

I'm seeing a segfault when building from the master branch:

[ 16%] Building C object src/libm/CMakeFiles/sleefsvenofma.dir/sleefsimdsp.c.o
cd /private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-sleef-master-bkjovz22gqqp45s2ymskxx4dcu6azr5y/spack-build-bkjovz2/src/libm && /Users/Adam/spack/lib/spack/env/clang/clang -DDORENAME=1 -DENABLE_BUILTIN_MATH=1 -DENABLE_SVENOFMA=1 -I/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-sleef-master-bkjovz22gqqp45s2ymskxx4dcu6azr5y/spack-src/src/common -I/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-sleef-master-bkjovz22gqqp45s2ymskxx4dcu6azr5y/spack-src/src/arch -I/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-sleef-master-bkjovz22gqqp45s2ymskxx4dcu6azr5y/spack-build-bkjovz2/src/libm/include -I/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-sleef-master-bkjovz22gqqp45s2ymskxx4dcu6azr5y/spack-src/src/libm -Wall -Wno-unused-function -Wno-attributes -Wno-unused-result -ffp-contract=off -fno-math-errno -fno-trapping-math -O3 -DNDEBUG -std=gnu99 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -mmacosx-version-min=14.0 -fPIC -march=armv8-a+sve -MD -MT src/libm/CMakeFiles/sleefsvenofma.dir/sleefsimdsp.c.o -MF CMakeFiles/sleefsvenofma.dir/sleefsimdsp.c.o.d -o CMakeFiles/sleefsvenofma.dir/sleefsimdsp.c.o -c /var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-sleef-master-bkjovz22gqqp45s2ymskxx4dcu6azr5y/spack-src/src/libm/sleefsimdsp.c
clang: error: unable to execute command: Segmentation fault: 11
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Apple clang version 15.0.0 (clang-1500.0.40.1)
Target: arm64-apple-darwin23.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/sleefsimdsp-e26a4a.c
clang: note: diagnostic msg: /var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/sleefsimdsp-e26a4a.sh
clang: note: diagnostic msg: Crash backtrace is located in
clang: note: diagnostic msg: /Users/Adam/Library/Logs/DiagnosticReports/clang_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
clang: note: diagnostic msg: (choose the .crash file that corresponds to your crash)
clang: note: diagnostic msg: 

********************
make[2]: *** [src/libm/CMakeFiles/sleefsvenofma.dir/build.make:84: src/libm/CMakeFiles/sleefsvenofma.dir/sleefsimdsp.c.o] Error 1
make[2]: Leaving directory '/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-sleef-master-bkjovz22gqqp45s2ymskxx4dcu6azr5y/spack-build-bkjovz2'
make[1]: *** [CMakeFiles/Makefile2:609: src/libm/CMakeFiles/sleefsvenofma.dir/all] Error 2
make[1]: Leaving directory '/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-sleef-master-bkjovz22gqqp45s2ymskxx4dcu6azr5y/spack-build-bkjovz2'
make: *** [Makefile:149: all] Error 2

See the full build log: spack-build-out.txt

I'm on macOS Sonoma 14.0 (Apple M2 Pro, arm64) using Apple Clang 15.0.0.

@blapie
Copy link
Collaborator

blapie commented Oct 30, 2023

Hello! Thanks for reporting this. I don't have access to an Apple M2 atm, but spack install sleef@master on x86 seems functional (with same OS and compiler version). Will let you know if I'm able to reproduce on M2.

In the meantime would you be able to provide crash backtrace (.crash)?
Maybe a list of dependencies (full spack install log, with steps prior cmake)?
What version of XCode are you using? Does updating help?

Here is the version I used

$> /usr/bin/xcodebuild -version
Xcode 15.0.1
Build version 15A507

@adamjstewart
Copy link
Author

In the meantime would you be able to provide crash backtrace (.crash)?

Here are all files mentioned in the error message:
clang-2023-10-31-131600.000.ips.txt
clang-2023-10-31-131600.0002.ips.txt
clang-2023-10-31-131600.0003.ips.txt
clang-2023-10-31-131600.0004.ips.txt
clang-2023-10-31-131600.ips.txt
sleefsimdsp-5a4b1a.c.txt
sleefsimdsp-5a4b1a.sh.txt

Maybe a list of dependencies (full spack install log, with steps prior cmake)?

> spack spec sleef@master
Input spec
--------------------------------
 -   sleef@master

Concretized
--------------------------------
 -   sleef@master%[email protected]~ipo build_system=cmake build_type=Release generator=ninja arch=darwin-sonoma-m2
[+]      ^[email protected]%[email protected]~doc+ncurses+ownlibs build_system=generic build_type=Release arch=darwin-sonoma-m2
[+]          ^[email protected]%[email protected]~gssapi~ldap~libidn2~librtmp~libssh~libssh2+nghttp2 build_system=autotools libs=shared,static tls=secure_transport arch=darwin-sonoma-m2
[+]              ^gnuconfig@2022-09-17%[email protected] build_system=generic arch=darwin-sonoma-m2
[+]              ^[email protected]%[email protected] build_system=autotools arch=darwin-sonoma-m2
[+]              ^[email protected]%[email protected] build_system=autotools arch=darwin-sonoma-m2
[+]          ^[email protected]%[email protected]~symlinks+termlib abi=none build_system=autotools arch=darwin-sonoma-m2
[+]          ^[email protected]%[email protected]+compat+opt build_system=autotools patches=299b958,86c3f5b,ae9077a,b692621 arch=darwin-sonoma-m2
[+]      ^[email protected]%[email protected]+re2c build_system=generic arch=darwin-sonoma-m2
[-]          ^[email protected]%[email protected]+bz2+crypt+ctypes+dbm~debug+libxml2+lzma~nis+optimizations+pic+pyexpat+pythoncmd+readline+shared+sqlite3+ssl~tkinter+uuid+zlib build_system=generic patches=13fa8bf,b0615b2,ebdca64,f2fd060 arch=darwin-sonoma-m2
[e]              ^[email protected]%[email protected] build_system=bundle arch=darwin-sonoma-m2
[+]              ^[email protected]%[email protected]~debug~pic+shared build_system=generic arch=darwin-sonoma-m2
[+]                  ^[email protected]%[email protected] build_system=autotools arch=darwin-sonoma-m2
[+]              ^[email protected]%[email protected]~libbsd build_system=autotools arch=darwin-sonoma-m2
[+]              ^[email protected]%[email protected] build_system=autotools arch=darwin-sonoma-m2
[-]              ^[email protected]%[email protected]+bzip2+curses+git~libunistring+libxml2+tar+xz build_system=autotools arch=darwin-sonoma-m2
[+]                  ^[email protected]%[email protected] build_system=autotools libs=shared,static arch=darwin-sonoma-m2
[+]                  ^[email protected]%[email protected]+pic~python+shared build_system=autotools arch=darwin-sonoma-m2
[+]                  ^[email protected]%[email protected] build_system=autotools zip=pigz arch=darwin-sonoma-m2
[+]                      ^[email protected]%[email protected] build_system=makefile arch=darwin-sonoma-m2
[+]                      ^[email protected]%[email protected]+programs build_system=makefile compression=none libs=shared,static arch=darwin-sonoma-m2
[+]              ^[email protected]%[email protected] build_system=autotools arch=darwin-sonoma-m2
[+]              ^[email protected]%[email protected]~obsolete_api build_system=autotools patches=4885da3 arch=darwin-sonoma-m2
[+]                  ^[email protected]%[email protected]+cpanm+opcode+open+shared+threads build_system=generic patches=714e4d1 arch=darwin-sonoma-m2
[+]                      ^[email protected]%[email protected]+cxx~docs+stl build_system=autotools patches=26090f4,b231fcc arch=darwin-sonoma-m2
[+]              ^[email protected]%[email protected]~docs+shared build_system=generic certs=mozilla arch=darwin-sonoma-m2
[+]                  ^ca-certificates-mozilla@2023-05-30%[email protected] build_system=generic arch=darwin-sonoma-m2
[+]              ^[email protected]%[email protected] build_system=autotools patches=bbf97f1 arch=darwin-sonoma-m2
[+]              ^[email protected]%[email protected]+column_metadata+dynamic_extensions+fts~functions+rtree build_system=autotools arch=darwin-sonoma-m2
[+]              ^[email protected]%[email protected]~pic build_system=autotools libs=shared,static arch=darwin-sonoma-m2
[+]          ^[email protected]%[email protected] build_system=generic arch=darwin-sonoma-m2

What version of XCode are you using?

> /usr/bin/xcodebuild -version
Xcode 15.0.1
Build version 15A507

Does updating help?

Already up-to-date.

@blapie
Copy link
Collaborator

blapie commented Oct 31, 2023

Thanks! There seems to be quite a few bugs flagged on Sonoma lately, so since this looks like a compiler error I would recommend filing a report to Apple Clang directly (as suggested by the error message). You will increase your chances to get a fix soon. In the meantime we will try to reproduce and maybe find a workaround.

@adamjstewart
Copy link
Author

Filed a report.

@adamjstewart
Copy link
Author

Finally got a reply from Apple 3 months later:

We’ve seen this issue with sleef before. The problem is you're trying to build with SVE on Darwin, which isn’t supported. Even if you could successfully build it, it won’t run because no Mac has SVE hardware.

Is there a CMake flag to disable SVE?

@blapie
Copy link
Collaborator

blapie commented Feb 8, 2024

Hello! Sorry for the late reply. You might have found your answer already but yes there is a flag to disable SVE, simply pass -DSLEEF_DISABLE_SVE=ON to cmake. We can try to integrate that to the build system.

@adamjstewart
Copy link
Author

Thanks, this worked great to build the master branch.

Unfortunately it doesn't work to build e0a003e, which is the version used by PyTorch. Maybe this flag didn't exist at the time? Was there a different flag available?

@adamjstewart
Copy link
Author

Ah, looks like it was previously called DISABLE_SVE, let me try that.

@adamjstewart
Copy link
Author

Yes, this worked great! I'll keep this issue open until your CMake configuration is able to auto-detect whether or not SVE is supported.

@blapie
Copy link
Collaborator

blapie commented Feb 8, 2024

Cheers! Will try to sort that out ASAP.

@blapie
Copy link
Collaborator

blapie commented Feb 9, 2024

Merged #512. Let me know if this is good for you, and please close issue! Cheers for the precious help on this!

@adamjstewart
Copy link
Author

Confirmed that the build works out of the box now (barring my other issues #458 and #475). Thanks for the fix!

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

2 participants