{"id":15415909,"url":"https://github.com/tombruijn/rust-elixir-linking-issue-example-project","last_synced_at":"2025-04-05T13:13:38.156Z","repository":{"id":138593663,"uuid":"152240201","full_name":"tombruijn/rust-elixir-linking-issue-example-project","owner":"tombruijn","description":"Test project to create a Rust staticlib, install it as a Erlang NIF in an Elixir project. Will fail for the musl target on Rust 1.21.0 and newer.","archived":false,"fork":false,"pushed_at":"2018-10-17T09:06:50.000Z","size":45,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-02T20:36:44.977Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tombruijn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-09T11:34:59.000Z","updated_at":"2018-10-10T09:13:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"5d3ea056-392f-4ce2-b7cd-c7805309a69a","html_url":"https://github.com/tombruijn/rust-elixir-linking-issue-example-project","commit_stats":{"total_commits":20,"total_committers":1,"mean_commits":20.0,"dds":0.0,"last_synced_commit":"09fa3cab16d370851524e0c2586d1bdb069714d2"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tombruijn%2Frust-elixir-linking-issue-example-project","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tombruijn%2Frust-elixir-linking-issue-example-project/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tombruijn%2Frust-elixir-linking-issue-example-project/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tombruijn%2Frust-elixir-linking-issue-example-project/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tombruijn","download_url":"https://codeload.github.com/tombruijn/rust-elixir-linking-issue-example-project/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247339158,"owners_count":20923014,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T17:10:11.504Z","updated_at":"2025-04-05T13:13:38.132Z","avatar_url":"https://github.com/tombruijn.png","language":"Elixir","readme":"# Rust staticlib linking with Elixir issue example app\n\n## Usage\n\n```sh\n./build_and_test \u003cRust version\u003e\n```\n\n- `\u003cRust version\u003e`: The Rust version is the version of the [Rust language](https://rust-lang.org/) to test against. It will automatically install it.\n\nThis testing tool will follow the process described in \"Build and test process details\" below. Afterwards it will open a shell in which the user can do additional debugging, such as:\n\n```sh\n./bin/elixir_app stop                    # Stop application that's currently running\n./bin/elixir_app foreground              # Run application in foreground\ncat lib/elixir_package-0.0.1/install.log # Print install log file with error (if present)\n```\n\n### Examples\n\n```sh\n./build_and_test 1.20.0\n# Works, creates a build and complains about a missing install.log file, which is fine\n\n./build_and_test 1.21.0\n# Fails, starts app but prints the error listed below\n\n./build_and_test 1.29.1\n# Fails, unrelated error that's already fixed in the latest nightly\n\n./build_and_test nightly-2018-10-08\n# Fails, starts app but prints the error listed below\n```\n\n## Unexpected error\n\nThis error occurs when linking a staticlib with the `x86_64-unknown-linux-musl` target to an Elixir app.\n\n```\nError loading NIF (host triple: x86_64-pc-linux-musl)\nError: Failed to load NIF library: 'Error loading shared library libgcc_s.so.1: No such file or directory (needed by /app/lib/elixir_package-0.0.1/priv/elixir_package_extension.so)'\n```\n\n## Testing\n\n### Requirements\n\nRequirements for running this project on a macOS host machine, see \"Build and test process details\". This project is not optimized for a Linux host machine, but will run the same.\n\n- [Virtualbox](https://www.virtualbox.org/)\n- [Vagrant](https://www.vagrantup.com/)\n\n### Build and test process details\n\nThe following steps describe the automated process this project performs. No manual steps required.\n\n1. Build extension\n    - Create a virtual machine (controlled through Vagrant) that will act as the build environment.\n      - You will be prompted for your password the first time to mount a NFS volume on the virtual machine.\n      - Install Docker on this build machine.\n    - With cross, cross compile the extension to musl.\n      - This cannot be done if the host is macOS, which is why we're running this through the virtual build machine.\n2. Install the extension as an Erlang [NIF](http://erlang.org/doc/man/erl_nif.html)\n    - Move built extension to Elixir package (`elixir_app/elixir_package/c_src`)\n    - Start a Docker image build process that compiles the Elixir app.\n      - Start the first stage that compiles the app.\n    - Make an app release with [distillery](https://github.com/bitwalker/distillery).\n      - Compile the Elixir app.\n      - Install the Erlang NIF.\n      - Package the release as a zip.\n3. Run the app.\n    - Create a second stage for the release in which the app is run. This is a slimmer version of the Docker image than the build stage. This does not include the compilation dependencies from the first stage.\n      - Copy and extract the zip file from the first stage.\n    - Run the Elixir app release (including the NIF).\n    - The error will be printed as the `install.log` file is read.\n      - If this file is not present it will warn it cannot be found. Which is good.\n\n### Clean up\n\n**Note**: This testing process will create a new Docker image per build. Be sure to clean them after you're done testing.\n\n```sh\ndocker rmi alpine-elixir-build-test:build\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftombruijn%2Frust-elixir-linking-issue-example-project","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftombruijn%2Frust-elixir-linking-issue-example-project","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftombruijn%2Frust-elixir-linking-issue-example-project/lists"}