toolchains icon indicating copy to clipboard operation
toolchains copied to clipboard

`mix firmware` fails on Nix due to hardcoded lib paths

Open danifv opened this issue 1 year ago • 2 comments

Environment

  • Elixir version (elixir -v):
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1]

Elixir 1.14.4 (compiled with Erlang/OTP 25)
  • Nerves environment: (mix nerves.env --info)
==> nerves
==> hello_nerves
|nerves_bootstrap| Environment Package List

  Pkg:         nerves_system_br
  Vsn:         1.22.5
  Type:        system_platform
  BuildRunner: {nil, []}

  Pkg:         nerves_system_x86_64
  Vsn:         1.22.2
  Type:        system
  BuildRunner: {Nerves.Artifact.BuildRunners.Docker, [make_args: ["source", "all", "legal-info"]]}

  Pkg:         nerves_toolchain_ctng
  Vsn:         1.9.3
  Type:        toolchain_platform
  BuildRunner: {nil, []}

  Pkg:         nerves_toolchain_x86_64_nerves_linux_musl
  Vsn:         1.8.0
  Type:        toolchain
  BuildRunner: {Nerves.Artifact.BuildRunners.Local, []}

|nerves_bootstrap| Loadpaths Start

|nerves_bootstrap| Precompile Start

==> nerves_toolchain_x86_64_nerves_linux_musl
|nerves_bootstrap| Compile.NervesPackage start

|nerves_bootstrap| Compile.NervesPackage end

==> nerves_system_x86_64
|nerves_bootstrap| Compile.NervesPackage start

|nerves_bootstrap| Compile.NervesPackage end

==> hello_nerves
|nerves_bootstrap| Precompile End


Nerves environment
  MIX_TARGET:   x86_64
  MIX_ENV:      dev

|nerves_bootstrap| Environment Variable List
  target:     x86_64
  toolchain:  /Users/d/.nerves/artifacts/nerves_toolchain_x86_64_nerves_linux_musl-darwin_x86_64-1.8.0
  system:     /Users/d/.nerves/artifacts/nerves_system_x86_64-portable-1.22.2
  app:        .

|nerves_bootstrap| Loadpaths End
  • Additional information about your host, target hardware or environment that may help macOS 11.7.7 using nix 2.13.3 for package management

Current behavior

CT_EXTRA_LDFLAGS_FOR_BUILD and CT_EXTRA_CFLAGS_FOR_BUILD are currently set to /usr/local/opt/... which might be incorrect, depending on user setup, e.g. on Nix. See https://github.com/nerves-project/toolchains/blob/c5039b71a54147a92feba1ce3330e1e5c3659d32/nerves_toolchain_ctng/defaults/darwin_x86_64_defconfig#L6
Of course it could be hardcoded in other places as well.

This results in mix firmware being unable to compile dependencies, due to libraries being searched in an incorrect location

==> one_dhcpd
 CC arp_set.o
dyld: Library not loaded: /usr/local/opt/gettext/lib/libintl.8.dylib

Expected behaviour

Buildscripts detect the correct location and firmware is built correctly.

danifv avatar May 31 '23 22:05 danifv