Fix Illegal instruction (SIGILL) error when loading pgvector extension
Problem
By default, the pgvector makefile implicitly applies host-specific CPU optimizations (often translating to -march=native) when compiling the extension from source. While this creates a highly optimized binary for the machine where the Docker image is built, it breaks portability. If the resulting Docker image is executed on a different host with a less capable or different CPU architecture (missing specific instructions like AVX-512 or AVX2), PostgreSQL immediately crashes with a signal 4: Illegal instruction error when attempting to run CREATE EXTENSION vector;.
Solution
This commit overrides the default behavior by passing OPTFLAGS="" directly to the make and make install commands. This disables hardware-specific compiler optimizations, ensuring that the generated pgvector binary remains generic and safely portable across any standard CPU architecture supported by the base image.
Replace line 27 & 28 with:
&& make OPTFLAGS="" PG_CONFIG=/usr/local/bin/pg_config
&& make install OPTFLAGS="" PG_CONFIG=/usr/local/bin/pg_config; \
Fix
Illegal instruction(SIGILL) error when loading pgvector extensionProblem
By default, the
pgvectormakefile implicitly applies host-specific CPU optimizations (often translating to-march=native) when compiling the extension from source. While this creates a highly optimized binary for the machine where the Docker image is built, it breaks portability. If the resulting Docker image is executed on a different host with a less capable or different CPU architecture (missing specific instructions like AVX-512 or AVX2), PostgreSQL immediately crashes with asignal 4: Illegal instructionerror when attempting to runCREATE EXTENSION vector;.Solution
This commit overrides the default behavior by passing
OPTFLAGS=""directly to themakeandmake installcommands. This disables hardware-specific compiler optimizations, ensuring that the generatedpgvectorbinary remains generic and safely portable across any standard CPU architecture supported by the base image.Replace line 27 & 28 with:
&& make OPTFLAGS="" PG_CONFIG=/usr/local/bin/pg_config
&& make install OPTFLAGS="" PG_CONFIG=/usr/local/bin/pg_config; \