Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add documentation for compiling binaries on OSX #191

Closed
wants to merge 1 commit into from

Conversation

KevinCybura
Copy link

When attempting to Link on OSX ive been getting linker errors similar to this Issue
#151
I've done some investigation and saw that there was an attempt to solve this problem here
#174
However it didn't solve it for me until I add the .cargo/config to my project. So I think add this documentation would be useful

@scrogson
Copy link
Member

scrogson commented Mar 5, 2019

Hi @KevinCybura, can you add some context around the issue you're having? The previous issues you linked to were to solve issues with running cargo build from within the rustler repository itself. Can you provide a link to an example repo so we can reproduce the error you're having?

@KevinCybura
Copy link
Author

Sorry let me give you some context. Currently Ive written a NIF and it works fine when running it in elixir. However I would also like to use my workspace for running just rust code as well so I would have to run compile my rust code using cargo build however if I do so I get the same linker error

  = note: Undefined symbols for architecture x86_64:
            "_enif_snprintf", referenced from:
                rustler::wrapper::term::fmt::hd9de1f4455b98448 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.t3wc3ngapyvghfi.rcgu.o)
            "_enif_get_local_pid", referenced from:
                rustler::wrapper::pid::get_local_pid::hcac7580812b2c73a in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.2ylrdwbbpcdaezf5.rcgu.o)
            "_enif_map_iterator_get_pair", referenced from:
                rustler::wrapper::map::map_iterator_get_pair::h6d9b72fe71d12961 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.3le968n251d32616.rcgu.o)
            "_enif_map_iterator_destroy", referenced from:
                rustler::wrapper::map::map_iterator_destroy::hbf24ca1d7cc4a04c in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.3le968n251d32616.rcgu.o)
            "_enif_map_iterator_create", referenced from:
                rustler::wrapper::map::map_iterator_create::h5f651890107b579c in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.3le968n251d32616.rcgu.o)
            "_enif_make_ulong", referenced from:
                erlang_nif_sys::erlang_nif_sys_api::enif_make_uint64::h2cbcb4675d60aefa in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.12t83mjc4eegvzuq.rcgu.o)
            "_enif_inspect_binary", referenced from:
                rustler::wrapper::nif_interface::enif_inspect_binary::h02c63e516ae96c27 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_make_long", referenced from:
                erlang_nif_sys::erlang_nif_sys_api::enif_make_int64::h6c8fac1105a331ac in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.12t83mjc4eegvzuq.rcgu.o)
            "_enif_get_atom_length", referenced from:
                rustler::wrapper::nif_interface::enif_get_atom_length_latin1::h6ddd1e02454bc0f4 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_get_ulong", referenced from:
                erlang_nif_sys::erlang_nif_sys_api::enif_get_uint64::h07d9d4027ee5dc7b in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.12t83mjc4eegvzuq.rcgu.o)
            "_enif_get_long", referenced from:
                erlang_nif_sys::erlang_nif_sys_api::enif_get_int64::h0a049285337d67d5 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.12t83mjc4eegvzuq.rcgu.o)
            "_enif_get_map_value", referenced from:
                rustler::wrapper::nif_interface::enif_get_map_value::h498e18f116facfcd in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_send", referenced from:
                rustler::wrapper::nif_interface::enif_send::hae8c732992b75392 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_keep_resource", referenced from:
                rustler::wrapper::nif_interface::enif_keep_resource::h61f26b2b483d060a in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_release_resource", referenced from:
                rustler::wrapper::nif_interface::enif_release_resource::hf414a7d61e80090b in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_make_resource", referenced from:
                rustler::wrapper::nif_interface::enif_make_resource::hc0db35cf219f0ee4 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_make_reverse_list", referenced from:
                rustler::wrapper::nif_interface::enif_make_reverse_list::h3f477e1793c344fe in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_make_uint", referenced from:
                rustler::types::primitive::_$LT$impl$u20$rustler..types..Encoder$u20$for$u20$u32$GT$::encode::he14c965548d2ae7d in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.2whv8nfaa5dbe3kz.rcgu.o)
                rustler::types::primitive::_$LT$impl$u20$rustler..types..Encoder$u20$for$u20$u8$GT$::encode::h5f0f1671284c0067 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.2whv8nfaa5dbe3kz.rcgu.o)
            "_enif_release_binary", referenced from:
                rustler::wrapper::nif_interface::enif_release_binary::hfce7facdf249d0c2 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_alloc_resource", referenced from:
                rustler::wrapper::nif_interface::enif_alloc_resource::h7eb852d38457d507 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_thread_type", referenced from:
                rustler::wrapper::nif_interface::enif_thread_type::h25a0a0f291050088 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_make_int", referenced from:
                rustler::types::primitive::_$LT$impl$u20$rustler..types..Encoder$u20$for$u20$i32$GT$::encode::he9476de4141a812e in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.2whv8nfaa5dbe3kz.rcgu.o)
            "_enif_make_list_from_array", referenced from:
                rustler::wrapper::nif_interface::enif_make_list_from_array::hec89e310d4dfe2f7 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_make_tuple_from_array", referenced from:
                rustler::wrapper::nif_interface::enif_make_tuple_from_array::ha49238bf2f128d65 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_open_resource_type", referenced from:
                rustler::wrapper::nif_interface::enif_open_resource_type::h19f271d6cafbc041 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_make_new_map", referenced from:
                rustler::wrapper::nif_interface::enif_make_new_map::h53858f2b880aa325 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_make_map_put", referenced from:
                rustler::wrapper::nif_interface::enif_make_map_put::h2ec2f2b444be67ad in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_make_binary", referenced from:
                rustler::wrapper::nif_interface::enif_make_binary::h7ec37aaab780736b in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_realloc_binary", referenced from:
                rustler::wrapper::nif_interface::enif_realloc_binary::hc1fd24a49cb1e7be in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_is_empty_list", referenced from:
                rustler::wrapper::nif_interface::enif_is_empty_list::h58837a1d84450de9 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_get_atom", referenced from:
                rustler::wrapper::nif_interface::enif_get_atom_latin1::hfa61e13ab63fd93d in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_is_identical", referenced from:
                rustler::wrapper::nif_interface::enif_is_identical::he890c36f62535252 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_get_list_cell", referenced from:
                rustler::wrapper::nif_interface::enif_get_list_cell::h02b37bd54ab26507 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_make_sub_binary", referenced from:
                rustler::wrapper::nif_interface::enif_make_sub_binary::h0e403fa099bcc9bb in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_get_uint", referenced from:
                rustler::types::primitive::_$LT$impl$u20$rustler..types..Decoder$LT$$u27$a$GT$$u20$for$u20$u32$GT$::decode::habc330846e8a6748 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.2whv8nfaa5dbe3kz.rcgu.o)
                rustler::types::primitive::_$LT$impl$u20$rustler..types..Decoder$LT$$u27$a$GT$$u20$for$u20$u8$GT$::decode::hc9a05dc804892688 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.2whv8nfaa5dbe3kz.rcgu.o)
            "_enif_is_atom", referenced from:
                rustler::wrapper::nif_interface::enif_is_atom::ha5e95b4fb7f5aa4a in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_make_copy", referenced from:
                rustler::wrapper::nif_interface::enif_make_copy::h481846b797b1c7f3 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_is_list", referenced from:
                rustler::wrapper::nif_interface::enif_is_list::hb1ede9b3e8bca14f in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_make_list_cell", referenced from:
                rustler::wrapper::nif_interface::enif_make_list_cell::hafe5abe53b63b6a4 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_get_double", referenced from:
                rustler::types::primitive::_$LT$impl$u20$rustler..types..Decoder$LT$$u27$a$GT$$u20$for$u20$f64$GT$::decode::hf14952e6fd559588 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.2whv8nfaa5dbe3kz.rcgu.o)
            "_enif_raise_exception", referenced from:
                rustler::wrapper::nif_interface::enif_raise_exception::haeebcd2fb5ba4d54 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_get_tuple", referenced from:
                rustler::wrapper::nif_interface::enif_get_tuple::he97792aa26a0efc3 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_make_badarg", referenced from:
                rustler::wrapper::nif_interface::enif_make_badarg::hfa5b31057b7938c7 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_alloc_binary", referenced from:
                rustler::wrapper::nif_interface::enif_alloc_binary::h6a04dfe902713cd7 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_make_double", referenced from:
                rustler::types::primitive::_$LT$impl$u20$rustler..types..Encoder$u20$for$u20$f64$GT$::encode::hc78f7a38e4168c2a in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.2whv8nfaa5dbe3kz.rcgu.o)
            "_enif_free_env", referenced from:
                _$LT$rustler..env..OwnedEnv$u20$as$u20$core..ops..drop..Drop$GT$::drop::h27f7be652b5eabff in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.7ve22dj4c6tgj5o.rcgu.o)
            "_enif_get_resource", referenced from:
                rustler::wrapper::nif_interface::enif_get_resource::h03be5cda294a98aa in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_map_iterator_next", referenced from:
                rustler::wrapper::map::map_iterator_next::h9ae785eb23900019 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.3le968n251d32616.rcgu.o)
            "_enif_make_atom_len", referenced from:
                rustler::wrapper::nif_interface::enif_make_atom_len::h0417e18b209a3da7 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_compare", referenced from:
                rustler::wrapper::nif_interface::enif_compare::he746541a04a4610e in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_get_int", referenced from:
                rustler::types::primitive::_$LT$impl$u20$rustler..types..Decoder$LT$$u27$a$GT$$u20$for$u20$i32$GT$::decode::hfab4831f49031cd7 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.2whv8nfaa5dbe3kz.rcgu.o)
            "_enif_alloc_env", referenced from:
                rustler::wrapper::nif_interface::enif_alloc_env::h531bee338e720370 in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.1oag4ktxo6t0wz1b.rcgu.o)
            "_enif_self", referenced from:
                rustler::types::pid::_$LT$impl$u20$rustler..env..Env$LT$$u27$a$GT$$GT$::pid::h8bbc50419a9ec36b in librustler-11859f1af9338cc0.rlib(rustler-11859f1af9338cc0.7ve22dj4c6tgj5o.rcgu.o)
          ld: symbol(s) not found for architecture x86_64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
          

error: aborting due to previous error

I added the same config as in this PR #174 to solve this problem. From my understanding if some wants to compile while using rustler on a mac that config is required to be in their workspace. Unless there is another solution that I couldn't find. If this is the only solution I think it would be good to document it for other mac users

@scrogson
Copy link
Member

scrogson commented Mar 6, 2019

@KevinCybura I see. Ok, this makes sense to me.

I wonder if a more user friendly solution would be to just generate the .cargo/config with the configuration in there by default?

@KevinCybura
Copy link
Author

KevinCybura commented Mar 6, 2019

It would be great if the end user worry about this issue at all. Could you explain what you mean by in there by default? Do you mean as in the rustler/rustler_codgen crates? Ive tried moving the .cargo/config into rustler and rustler_codgen and then set a path to them in my cargo.toml however I still get the linker error I think it would have to be inside the users project root dir.

@scrogson
Copy link
Member

scrogson commented Mar 6, 2019

What I mean is...in the rustler.new generator. We should generate the .cargo/config in the user’s generated crate.

This would allow us to remove the macOS hacks in the rustler.compile task as well.

When that change happens we’d probably want the text you’ve written to be included in the CHANGELOG instead of the README.

Does that make sense?

@hansihe, what do you think?

@scrogson scrogson mentioned this pull request Mar 6, 2019
@scrogson
Copy link
Member

scrogson commented Mar 6, 2019

@KevinCybura thanks for the PR! This really helped us see a deficiency in the current generator and compiler flags!

I'm going to close in favor of #192, which will automatically generate the .cargo/config for new projects. In addition it will print an annoying warning for existing projects to create the file if it doesn't exist.

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

Successfully merging this pull request may close these issues.

2 participants