Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Generate .cargo/config #192

Merged
merged 1 commit into from
Mar 6, 2019
Merged

Generate .cargo/config #192

merged 1 commit into from
Mar 6, 2019

Conversation

scrogson
Copy link
Member

@scrogson scrogson commented Mar 6, 2019

This PR adds a .cargo/config to the generated skeleton to avoid issues
with running cargo build on macOS.

I've added a warning to the compiler task if compiling on macOS and the
.cargo/config does not exist.

Here is an example warning when the file doesn't exist:

λ mix compile
==> rustler
Compiling 1 file (.ex)
==> hyper
Compiling NIF crate :hyperbeam (native/hyperbeam)...

Compiling on macOS requires special link args in order to compile
correctly.

Rustler is currently working around this issue in the compiler task.
This will be removed in v1.0.0 in favor of a user supplied .cargo/config
file.

To remove this warning, please create /Users/scrogson/github/rusterlium/hyper/native/hyperbeam/.cargo/config
with the following content:

      [target.x86_64-apple-darwin]
      rustflags = [
          "-C", "link-arg=-undefined",
          "-C", "link-arg=dynamic_lookup",
      ]

See https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/MachOTopics/1-Articles/executing_files.html
for more details.


    Finished release [optimized] target(s) in 0.15s

Fixes #191

@scrogson scrogson requested a review from hansihe March 6, 2019 03:36
@evnu
Copy link
Member

evnu commented Mar 6, 2019

Does the config need to be replicated for all crates in a workspace, or is a single configuration per workspace enough?

@scrogson
Copy link
Member Author

scrogson commented Mar 6, 2019

Does the config need to be replicated for all crates in a workspace, or is a single configuration per workspace enough?

@evnu I believe a single .cargo/config will work at the root of the workspace (as seen in the rustler repository itself).

@evnu
Copy link
Member

evnu commented Mar 6, 2019

I believe a single .cargo/config will work at the root of the workspace (as seen in the rustler repository itself).

Should the test here than traverse the directories to find any matching config?

@scrogson
Copy link
Member Author

scrogson commented Mar 6, 2019

Should the test here than traverse the directories to find any matching config?

Not sure what you mean. It appears that a top-level .cargo/config would suffice.

Do you have a workspace-based NIF project you could test this hypothesis with?

Copy link
Member

@hansihe hansihe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@scrogson scrogson merged commit 6f5030e into master Mar 6, 2019
@evnu
Copy link
Member

evnu commented Mar 7, 2019

Not sure what you mean. It appears that a top-level .cargo/config would suffice.

I think that the test for the configuration file here might output an "incorrect" warning, if the .cargo/config is not at the exact place where it is expected. This doesn't hurt, but might be confusing at first.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants