Skip to content

Compilation flags to ensure small binary size? #1

@wjakob

Description

@wjakob

There are a few compilation flags that make a huge difference with respect to unnecessary bloat in the resulting binaries when compiling stuff using pybind11. In particular, that is -fvisibility=hidden on GCC/Clang (>50% difference).

It's also good to turn on C++14 support if possible, since that pushes some precomputation to the compile phase. In CMake, I would just do:

      if (HAS_CPP14_FLAG)
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
      elseif (HAS_CPP11_FLAG)
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
      else()
        message(FATAL_ERROR "Unsupported compiler -- at least C++11 support is needed!")
      endif()

Is it possible to enable these flags here as well?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions