SoftCreatR / imei

IMEI - ImageMagick Easy Install
ISC License
293 stars 35 forks source link

gcc option -march=native is dangerous for docker images #83

Closed jnweiger closed 1 year ago

jnweiger commented 1 year ago

I am compiling imagemagic-7 using imei.h to add heic support to a docker 20.04 image.

Users report illegal instruction crashes since this addition. The reason seems to be that imei.sh defaults to quite aggressive CPU optimizations:

if [ -z "$BUILD_CFLAGS" ]; then
  BUILD_CFLAGS="-O3 -march=native"
fi

if [ -z "$BUILD_CXXFLAGS" ]; then
  BUILD_CXXFLAGS="-O3 -march=native"
fi

This is great for a local compile, where we are sure, that the CPU never changes. When running as part of a docker build process, this assertion does not hold, and leads to illegal instruction crashes.

I suggest to test for the existance of /.dockerenv and switch optimization strategy to "best compatibility" then -> #84