Illegal Instruction: 4 building Python3


(Jeff Rizzo) #1

Lots of moving parts here, so I’m not sure which piece is the culprit. I’d like to resolve with a minimum of disruption, but I definitely need to resolve it.

I just moved to a new computer; a MBP (Mid-2015) running 10.12.5 from a MacBook Air running 10.11 - I used a Time Machine backup to restore all my files, including Homebrew. Occasionally, I’d run into a homebrew-built binary which died with an “Illegal Instruction: 4”. In all cases before this, rebuilding the formula would result in a working binary. (shocker, I know)

However, turns out my python3 is broken. So, I’m trying to rebuild it, but DURING THE BUILD I get the dreaded error. I’ve updated brew repeatedly; I’ve tried reinstalling the Xcode commandline tools (not 100% sure I got that right), but nothing has helped so far. I’d really, really prefer not to need to rebuild everything I installed with homebrew if I can avoid it.

Other possibly-complicating factors: I’ve got homebrew installed in /opt/brew (/usr/local should be LOCAL. I don’t want any other packagers assuming they can mess with it).

Here are the last few lines when trying “brew install python3”:

clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -DUNIVERSAL=1 -I/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Modules/_decimal/libmpdec -I./Include -I. -I/usr/local/include -I/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Include -I/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1 -c /private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Modules/_decimal/libmpdec/mpdecimal.c -o build/temp.macosx-10.12-x86_64-3.6/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Modules/_decimal/libmpdec/mpdecimal.o
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -DUNIVERSAL=1 -I/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Modules/_decimal/libmpdec -I./Include -I. -I/usr/local/include -I/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Include -I/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1 -c /private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Modules/_decimal/libmpdec/numbertheory.c -o build/temp.macosx-10.12-x86_64-3.6/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Modules/_decimal/libmpdec/numbertheory.o
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -DUNIVERSAL=1 -I/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Modules/_decimal/libmpdec -I./Include -I. -I/usr/local/include -I/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Include -I/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1 -c /private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Modules/_decimal/libmpdec/sixstep.c -o build/temp.macosx-10.12-x86_64-3.6/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Modules/_decimal/libmpdec/sixstep.o
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -DUNIVERSAL=1 -I/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Modules/_decimal/libmpdec -I./Include -I. -I/usr/local/include -I/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Include -I/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1 -c /private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Modules/_decimal/libmpdec/transpose.c -o build/temp.macosx-10.12-x86_64-3.6/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Modules/_decimal/libmpdec/transpose.o
clang -bundle -undefined dynamic_lookup build/temp.macosx-10.12-x86_64-3.6/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Modules/_decimal/_decimal.o build/temp.macosx-10.12-x86_64-3.6/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Modules/_decimal/libmpdec/basearith.o build/temp.macosx-10.12-x86_64-3.6/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Modules/_decimal/libmpdec/constants.o build/temp.macosx-10.12-x86_64-3.6/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Modules/_decimal/libmpdec/context.o build/temp.macosx-10.12-x86_64-3.6/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Modules/_decimal/libmpdec/convolute.o build/temp.macosx-10.12-x86_64-3.6/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Modules/_decimal/libmpdec/crt.o build/temp.macosx-10.12-x86_64-3.6/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Modules/_decimal/libmpdec/difradix2.o build/temp.macosx-10.12-x86_64-3.6/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Modules/_decimal/libmpdec/fnt.o build/temp.macosx-10.12-x86_64-3.6/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Modules/_decimal/libmpdec/fourstep.o build/temp.macosx-10.12-x86_64-3.6/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Modules/_decimal/libmpdec/io.o build/temp.macosx-10.12-x86_64-3.6/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Modules/_decimal/libmpdec/memory.o build/temp.macosx-10.12-x86_64-3.6/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Modules/_decimal/libmpdec/mpdecimal.o build/temp.macosx-10.12-x86_64-3.6/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Modules/_decimal/libmpdec/numbertheory.o build/temp.macosx-10.12-x86_64-3.6/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Modules/_decimal/libmpdec/sixstep.o build/temp.macosx-10.12-x86_64-3.6/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1/Modules/_decimal/libmpdec/transpose.o -L/usr/local/lib -o build/lib.macosx-10.12-x86_64-3.6/_decimal.cpython-36m-darwin.so
/bin/sh: line 1: 94795 Illegal instruction: 4  DYLD_FRAMEWORK_PATH=/private/tmp/python3-20170619-87183-1c9r3ql/Python-3.6.1 CC='clang' LDSHARED='clang -bundle -undefined dynamic_lookup  ' OPT='-DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes' _TCLTK_INCLUDES='' _TCLTK_LIBS='' ./python.exe -E ./setup.py $quiet build
make: *** [sharedmods] Error 132

READ THIS: http://docs.brew.sh/Troubleshooting.html

These open issues may also help:
SIGABRT with python3 --with-tcl-tk https://github.com/Homebrew/homebrew-core/issues/12808

(Joshua McKinney) #2

Have you done the following steps?

run brew update twice
run brew doctor

Additionally as noted in http://docs.brew.sh/Common-Issues.html:

Following a macOS upgrade it may be necessary to reinstall the Xcode Command Line Tools and brew upgrade all installed formula:

brew upgrade```

You said you’d installed the xcode tools, but that first command should be fine to run again if you’re unsure if you got it right.


(Jeff Rizzo) #3

Yep, I’d already read that and done all those steps. python3 still refuses to build. :frowning:


(Joshua McKinney) #4

Take a look at the python’s build dependencies and reinstall those first.

$ brew deps --tree python3
python3 (required dependencies)
├── pkg-config
├── sphinx-doc
├── openssl
│   └── makedepend
│       └── pkg-config
├── readline
├── sqlite
│   └── readline
├── gdbm
└── xz

A quick oneliner for the reinstall:

$ brew reinstall $(brew deps --include-build python3)