Skip to content

pip install fails (m1 mac, aarch64) and workaround #3

Description

@jwmay2012

mprofile is failing to compile when I try to pip install pyproff inside a container, running on Apple M1 Max.

Dockerfile

FROM python:3.9-slim

RUN apt-get -qqy update
RUN apt-get install gcc g++ -y

RUN pip install -U pip
RUN pip install pypprof

docker build .

#8 4.219   × Running setup.py install for mprofile did not run successfully.
#8 4.219   │ exit code: 1
#8 4.219   ╰─> [23 lines of output]
#8 4.219       running install
#8 4.219       running build
#8 4.219       running build_py
#8 4.219       creating build
#8 4.219       creating build/lib.linux-aarch64-3.9
#8 4.219       creating build/lib.linux-aarch64-3.9/mprofile
#8 4.219       copying mprofile/__init__.py -> build/lib.linux-aarch64-3.9/mprofile
#8 4.219       running build_ext
#8 4.219       building 'mprofile._profiler' extension
#8 4.219       creating build/temp.linux-aarch64-3.9
#8 4.219       creating build/temp.linux-aarch64-3.9/src
#8 4.219       creating build/temp.linux-aarch64-3.9/third_party
#8 4.219       creating build/temp.linux-aarch64-3.9/third_party/google
#8 4.219       creating build/temp.linux-aarch64-3.9/third_party/google/tcmalloc
#8 4.219       gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPY_SSIZE_T_CLEAN -I/tmp/pip-install-sdxxkev3/mprofile_cf51baac42a347ae9f7457a4d8ea7eb2 -Isrc -I/usr/local/include/python3.9 -c src/_profiler.cc -o build/temp.linux-aarch64-3.9/src/_profiler.o -std=c++11
#8 4.219       In file included from src/heap.h:12,
#8 4.219                        from src/_profiler.cc:7:
#8 4.219       src/spinlock.h: In member function ‘void SpinLock::lock()’:
#8 4.219       src/spinlock.h:30:9: error: ‘__builtin_ia32_pause’ was not declared in this scope; did you mean ‘__builtin_iswspace’?
#8 4.219          30 |         __builtin_ia32_pause();
#8 4.219             |         ^~~~~~~~~~~~~~~~~~~~
#8 4.219             |         __builtin_iswspace
#8 4.219       error: command '/usr/bin/gcc' failed with exit code 1
#8 4.219       [end of output]
#8 4.219   
#8 4.219   note: This error originates from a subprocess, and is likely not a problem with pip.
#8 4.221 error: legacy-install-failure
#8 4.221 
#8 4.221 × Encountered error while trying to install package.
#8 4.221 ╰─> mprofile

I don't know much about this problem, but a workaround I've found is to change the initial container image to
FROM --platform=linux/amd64 python:3.9-slim
as it usually defaults to aarch64.
There's also this DOCKER_DEFAULT_PLATFORM=linux/amd64

I felt compelled to document and share this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions