Skip to content

Builds with -fPIC when --enable-static is used #117

Open

Description

@yurivict

-fPIC should only be used for shared libraries.
-fPIC reduces code performance therefore defearing the purpose of static libraries.

Version 6.3.0
OS: FreeBSD 13

Activity

  1. StefanBruens commented on Apr 27, 2022

    @StefanBruens

    -fPIC is also correct for static libraries, and required when you want to build a position-independent executable.

    And when you build shared libraries with LTO (link-time-optimization), you typically end up with faster code due to cross-translation-unit optimization.

  2. zayenz commented on Nov 13, 2026

    @zayenz
    Member

    As @StefanBruens said, static libraries can also need -fPIC, for example when linked into a shared library or plugin. I would prefer to keep it enabled by default for compatibility with those uses. The performance cost depends on the platform and workload.

    Gecode 7 will use CMake only, so we can make this configurable through CMake's position-independent code settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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