使用M1 MacBook Pro编译GloVe时报错,完整输出如下:
mkdir -p build
gcc -c src/vocab_count.c -o build/vocab_count.o -lm -pthread -O3 -march=native -funroll-loops -Wall -Wextra -Wpedantic
clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
clang: error: the clang compiler does not support '-march=native'
make: *** [build/vocab_count.o] Error 1
执行clang --print-supported-cpus后发现M1上clang支持的cpu比较有限,无法使用-march=native参数,遂修改Makefile
CFLAGS = -lm -pthread -O3 -march=native -funroll-loops -Wall -Wextra -Wpedantic
调整为
CFLAGS = -lm -pthread -O3 -mcpu=apple-m1 -funroll-loops -Wall -Wextra -Wpedantic
修改后可以正常编译~