Skip to content

Conversation

@cocoa-xu
Copy link
Contributor

This PR allows users to set application-specific make_force_build values in config.exs for the following reasons:

  1. when the precompiled artefacts are linked with a higher version of glibc. In such case, the shared library will fail to load even if the target triplet matches.

    iex> Mix.install([{:exqlite, "~> 0.13.4"}])
    iex> {:ok, conn} = Exqlite.Sqlite3.open(":memory:")
    ** (UndefinedFunctionError) function Exqlite.Sqlite3NIF.open/2 is undefined (module Exqlite.Sqlite3NIF is not available)
        (exqlite 0.13.4) Exqlite.Sqlite3NIF.open(':memory:', 6)
        iex:1: (file)
    iex>
    16:47:22.044 [warning] The on_load function for module Elixir.Exqlite.Sqlite3NIF returned:
    {:error,
     {:load_failed,
      'Failed to load NIF library: \'/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28\' not found (required by 
    /root/myapp/_build/dev/lib/exqlite/priv/sqlite3_nif.so)\''}}
  2. When the user wants to compile a NIF library natively on the host (to get better optimization, etc).

With this patch applied, users can set make_force_build option for each app. For example, to opt out of using precompiled artefacts of exqlite, they can have the following settings in their config/config.exs:

import Config

config :exqlite, make_force_build: true

Related issue: elixir-sqlite/exqlite#238

@warmwaffles
Copy link

Awesome! @cocoa-xu could you submit a PR about that configuration option?

@cocoa-xu
Copy link
Contributor Author

Awesome! @cocoa-xu could you submit a PR about that configuration option?

Sure! In a minute!

@josevalim
Copy link
Member

I would prefer to not assume we can hijack the application environment. I think instead sqlite3 could do make_force_build: Application.get_env(:exsqlite3, :force_build, false) in its mix.exs. WDYT?

@cocoa-xu
Copy link
Contributor Author

I would prefer to not assume we can hijack the application environment. I think instead sqlite3 could do make_force_build: Application.get_env(:exsqlite3, :force_build, false) in its mix.exs. WDYT?

I'm okay with either one. But I agree that it seems easier to do make_force_build: Application.get_env(:exqlite, :force_build, false) in its mix.exs.

@josevalim
Copy link
Member

So let's go that route and, if for some reason it does not work, let me know!

@josevalim josevalim closed this Feb 27, 2023
@cocoa-xu cocoa-xu deleted the cx-allow-force-build branch February 27, 2023 18:16
@warmwaffles
Copy link

@josevalim are you suggesting that goes in the project/0 function call in mix.exs like this elixir-sqlite/exqlite#241 ?

@josevalim
Copy link
Member

Correct!

@warmwaffles
Copy link

Thanks!

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants