Skip to content

jiffy.so: undefined symbol: _nif_init with LTO #244

@ldgabbay

Description

@ldgabbay

When I compile and run a project with jiffy 1.1.0+ on Ubuntu 24.04 and actually try to call jiffy functions, I get the error:

1> jiffy:module_info().
=WARNING REPORT==== 1-Feb-2026::18:20:55.091035 ===
The on_load function for module jiffy returned:
{error,{bad_lib,"Failed to find library init function: '.../_build/default/lib/jiffy/priv/jiffy.so: undefined symbol: _nif_init'"}}

** exception error: undefined function jiffy:module_info/0

I have determined this is caused by Link Time Optimization (LTO), which is enabled by default on Ubuntu and possibly other Linux based systems. The rebar.config.script looks for LTO support and automatically enables it, but the aggressive optimization strips symbols that it thinks are not used and removes _nif_init and others.

I have been able to patch the problem by including:

{overrides, [
  {override, jiffy, [
    {port_env, [
      {".*", "FLTO_FLAG", "-fno-lto"}
    ]}
  ]}
]}.

in my project's rebar.config, but this should be fixed in the jiffy library itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions