Skip to content

Illegal instruction (SIGILL) error when loading pgvector extensionΒ #36

@martinllanos

Description

@martinllanos

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; \

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions