Search code examples
dockercompiler-errorsapple-m1rocksdb

Apple M1 Docker error cc1plus: error: unknown value 'armv8-a-march=armv8-a' for -march


Getting this error while building docker images on Mac OS BigSur with M1 chip.

What I've tried: Installed docker for Apple Silicon Graphic M1 from docker site

It fails while trying to install RocksDB from Docker

# docker.local
FROM golang:1.12.4-alpine3.9
RUN apk add bash build-base grep git

# Install RocksDB
RUN apk add coreutils linux-headers perl zlib-dev bzip2-dev lz4-dev snappy-dev zstd-libs zstd-dev && \
    cd /tmp && \
    wget -O - https://github.com/facebook/rocksdb/archive/v5.18.3.tar.gz | tar xz && \
    cd /tmp/rocksdb* && \
    make -j $(nproc) install-shared OPT=-g0 USE_RTTI=1 && \
    rm -R /tmp/rocksdb* && \
    apk del coreutils linux-headers perl

Errors:

#6 9.903 cc1plus: error: unknown value 'armv8-a-march=armv8-a' for -march

#6 9.903 cc1plus: note: valid arguments are: armv8-a armv8.1-a armv8.2-a armv8.3-a armv8.4-a native

#6 9.906 cc1plus: error: unknown value 'armv8-a-march=armv8-a' for -march

#6 9.906 cc1plus: note: valid arguments are: armv8-a armv8.1-a armv8.2-a armv8.3-a armv8.4-a native

#6 9.907 install -d /usr/local/lib

#6 9.908   CC       shared-objects/cache/clock_cache.o

#6 9.908   CC       shared-objects/cache/lru_cache.o

#6 9.909   CC       shared-objects/cache/sharded_cache.o

#6 9.909 for header_dir in `find "include/rocksdb" -type d`; do \

#6 9.909 install -d /usr/local/$header_dir; \

#6 9.909 done

#6 9.911 cc1plus: error: unknown value 'armv8-a-march=armv8-a' for -march

#6 9.911 cc1plus: note: valid arguments are: armv8-a armv8.1-a armv8.2-a armv8.3-a armv8.4-a native

#6 9.912 make: *** [Makefile:684: shared-objects/cache/clock_cache.o] Error 1

#6 9.912 make: *** Waiting for unfinished jobs....

#6 9.912 make: *** [Makefile:684: shared-objects/cache/lru_cache.o] Error 1

#6 9.913 make: *** [Makefile:684: shared-objects/cache/sharded_cache.o] Error 1

#6 9.914 for header in `find "include/rocksdb" -type f -name *.h`; do \

#6 9.914 install -C -m 644 $header /usr/local/$header; \

#6 9.914 done

Solution

  • There are a couple of issues to address. The dockerfile as you have it will download a base golang ARM image, and try to use that to build. That's fine, as long as the required libs "know how" to build with an arm architecture. If they don't know how to build under arm (as seems to be the case here), you may want to try building under an AMD image of golang.

    Intel / AMD containers will run under ARM docker on an M1. There are a few ways to build AMD containers on an M1. You can use buildkit, and then: docker buildx build --platform linux/amd64 . or, you can add the arch to the source image by modifying the Dockerfile to include something like:

    FROM --platform=linux/amd64 golang:1.12.4-alpine3.9
    

    which would use the amd64 arch of the golang image (assuming one exists). This is what I often use to build an image on ARM. This works even if docker is native ARM.