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

Error when attempting to compile meeseeks_html5ever on M1 Macbook #46

Closed
Sgoettschkes opened this issue Oct 14, 2021 · 7 comments
Closed

Comments

@Sgoettschkes
Copy link
Contributor

I'm trying to get meeseeks to run within my project, but meeseeks_html5ever does not compile. I'm seeing the following output to deps.compile (trimmed for readability):

Compiling meeseeks_html5ever_nif v0.13.0 (/Users/sebastian/workspace/meeseeks_test/deps/meeseeks_html5ever/native/meeseeks_html5ever_nif)
error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-Wl,-exported_symbols_list,/var/folders/cs/qdvgc20x4t3_8q80jc7mylpc0000gn/T/rustcC1kRae/list" "-arch" "arm64" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/meeseeks_html5ever_nif.meeseeks_html5ever_nif.bcbdbdf5-cgu.0.rcgu.o" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/meeseeks_html5ever_nif.meeseeks_html5ever_nif.bcbdbdf5-cgu.1.rcgu.o" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/meeseeks_html5ever_nif.meeseeks_html5ever_nif.bcbdbdf5-cgu.10.rcgu.o" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/meeseeks_html5ever_nif.meeseeks_html5ever_nif.bcbdbdf5-cgu.11.rcgu.o" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/meeseeks_html5ever_nif.meeseeks_html5ever_nif.bcbdbdf5-cgu.12.rcgu.o" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/meeseeks_html5ever_nif.meeseeks_html5ever_nif.bcbdbdf5-cgu.13.rcgu.o" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/meeseeks_html5ever_nif.meeseeks_html5ever_nif.bcbdbdf5-cgu.14.rcgu.o" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/meeseeks_html5ever_nif.meeseeks_html5ever_nif.bcbdbdf5-cgu.15.rcgu.o" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/meeseeks_html5ever_nif.meeseeks_html5ever_nif.bcbdbdf5-cgu.2.rcgu.o" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/meeseeks_html5ever_nif.meeseeks_html5ever_nif.bcbdbdf5-cgu.3.rcgu.o" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/meeseeks_html5ever_nif.meeseeks_html5ever_nif.bcbdbdf5-cgu.4.rcgu.o" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/meeseeks_html5ever_nif.meeseeks_html5ever_nif.bcbdbdf5-cgu.5.rcgu.o" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/meeseeks_html5ever_nif.meeseeks_html5ever_nif.bcbdbdf5-cgu.6.rcgu.o" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/meeseeks_html5ever_nif.meeseeks_html5ever_nif.bcbdbdf5-cgu.7.rcgu.o" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/meeseeks_html5ever_nif.meeseeks_html5ever_nif.bcbdbdf5-cgu.8.rcgu.o" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/meeseeks_html5ever_nif.meeseeks_html5ever_nif.bcbdbdf5-cgu.9.rcgu.o" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/meeseeks_html5ever_nif.3z0ri4hrxkgcb8gn.rcgu.o" "-L" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps" "-L" "/opt/homebrew/Cellar/rust/1.55.0/lib/rustlib/aarch64-apple-darwin/lib" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/libxml5ever-3c9aa7844d9cd1b3.rlib" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/libtime-985408a2bd3f221f.rlib" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/liblibc-fc6d1371c9ed40c1.rlib" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/libhtml5ever-abaffb5f1ffa5956.rlib" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/libmarkup5ever-2b82eb318a29be46.rlib" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/libtendril-9bfda85fd6eef0e5.rlib" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/libutf8-68fc3322da07b3de.rlib" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/libfutf-74bb4790074c3eb2.rlib" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/libmac-0ba03350b56434cb.rlib" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/libphf-019ce30e69e481a0.rlib" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/libstring_cache-5d1a8c79842ae9d7.rlib" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/libstring_cache_shared-072590d5088db619.rlib" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/libserde-c4e7b2961eea5e89.rlib" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/libprecomputed_hash-cddb056d2cb615e9.rlib" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/libphf_shared-4987174ea7d65abd.rlib" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/libsiphasher-4f1f24e11c41652f.rlib" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/libdebug_unreachable-95ba8f269668beb9.rlib" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/liblog-20e24bd1524d8c74.rlib" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/libcfg_if-128d5c2290fa979f.rlib" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/librustler-06ed3d621db92764.rlib" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/liblazy_static-79cda6058ad2d108.rlib" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/librustler_sys-adeeafb549e0d04f.rlib" "/opt/homebrew/Cellar/rust/1.55.0/lib/rustlib/aarch64-apple-darwin/lib/libstd-fe51b9edd1d1eaed.rlib" "/opt/homebrew/Cellar/rust/1.55.0/lib/rustlib/aarch64-apple-darwin/lib/libpanic_unwind-44199c5b0b3a0970.rlib" "/opt/homebrew/Cellar/rust/1.55.0/lib/rustlib/aarch64-apple-darwin/lib/libobject-0178d92e8a45283b.rlib" "/opt/homebrew/Cellar/rust/1.55.0/lib/rustlib/aarch64-apple-darwin/lib/libaddr2line-4174108a800ed70c.rlib" "/opt/homebrew/Cellar/rust/1.55.0/lib/rustlib/aarch64-apple-darwin/lib/libgimli-f59e2e4344ad4694.rlib" "/opt/homebrew/Cellar/rust/1.55.0/lib/rustlib/aarch64-apple-darwin/lib/libstd_detect-e31dee0395c6f0ff.rlib" "/opt/homebrew/Cellar/rust/1.55.0/lib/rustlib/aarch64-apple-darwin/lib/librustc_demangle-87a8a17fb40368e9.rlib" "/opt/homebrew/Cellar/rust/1.55.0/lib/rustlib/aarch64-apple-darwin/lib/libhashbrown-3355699b7a3b475f.rlib" "/opt/homebrew/Cellar/rust/1.55.0/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_alloc-39a37ce3deee7fd0.rlib" "/opt/homebrew/Cellar/rust/1.55.0/lib/rustlib/aarch64-apple-darwin/lib/libunwind-591c7780ec815f4f.rlib" "/opt/homebrew/Cellar/rust/1.55.0/lib/rustlib/aarch64-apple-darwin/lib/libcfg_if-263742f878cd5cbc.rlib" "/opt/homebrew/Cellar/rust/1.55.0/lib/rustlib/aarch64-apple-darwin/lib/liblibc-5a0601951d9d7d33.rlib" "/opt/homebrew/Cellar/rust/1.55.0/lib/rustlib/aarch64-apple-darwin/lib/liballoc-a36b8c03c80d8f5a.rlib" "/opt/homebrew/Cellar/rust/1.55.0/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_core-347f56b9a3cedfe8.rlib" "/opt/homebrew/Cellar/rust/1.55.0/lib/rustlib/aarch64-apple-darwin/lib/libcore-ba68e6d9cc991d90.rlib" "/opt/homebrew/Cellar/rust/1.55.0/lib/rustlib/aarch64-apple-darwin/lib/libcompiler_builtins-8f4a2de164170192.rlib" "-lSystem" "-lresolv" "-lc" "-lm" "-liconv" "-L" "/opt/homebrew/Cellar/rust/1.55.0/lib/rustlib/aarch64-apple-darwin/lib" "-o" "/Users/sebastian/workspace/meeseeks_test/_build/dev/lib/meeseeks_html5ever/native/meeseeks_html5ever_nif/release/deps/libmeeseeks_html5ever_nif.dylib" "-Wl,-dead_strip" "-dynamiclib" "-Wl,-dylib" "-nodefaultlibs"
  = note: Undefined symbols for architecture arm64:
            "_enif_make_list_from_array", referenced from:
                rustler::wrapper::list::make_list::hbd1bda88eb7adf93 in librustler-06ed3d621db92764.rlib(rustler-06ed3d621db92764.rustler.8d424656-cgu.5.rcgu.o)
            "_enif_make_ulong", referenced from:
                rustler::types::primitive::_$LT$impl$u20$rustler..types..Encoder$u20$for$u20$u64$GT$::encode::he49fb40fde4f71ea in librustler-06ed3d621db92764.rlib(rustler-06ed3d621db92764.rustler.8d424656-cgu.2.rcgu.o)
            "_enif_alloc_binary", referenced from:
                rustler::types::string::_$LT$impl$u20$rustler..types..Encoder$u20$for$u20$str$GT$::encode::hf11e17216d4e209d in librustler-06ed3d621db92764.rlib(rustler-06ed3d621db92764.rustler.8d424656-cgu.6.rcgu.o)
            "_enif_free_env", referenced from:
                _$LT$rustler..env..OwnedEnv$u20$as$u20$core..ops..drop..Drop$GT$::drop::ha10c86909c3bec34 in librustler-06ed3d621db92764.rlib(rustler-06ed3d621db92764.rustler.8d424656-cgu.14.rcgu.o)
                std::sync::once::Once::call_once::_$u7b$$u7b$closure$u7d$$u7d$::hd2f7ea865264dd2e (.llvm.10254186834831073615) in librustler-06ed3d621db92764.rlib(rustler-06ed3d621db92764.rustler.8d424656-cgu.13.rcgu.o)
                core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::h1811baefb0585ec1 (.llvm.10254186834831073615) in librustler-06ed3d621db92764.rlib(rustler-06ed3d621db92764.rustler.8d424656-cgu.13.rcgu.o)
                core::ptr::drop_in_place$LT$rustler..env..OwnedEnv$GT$::hbc4f5f16205aa6fd in librustler-06ed3d621db92764.rlib(rustler-06ed3d621db92764.rustler.8d424656-cgu.13.rcgu.o)
            "_enif_alloc_env", referenced from:
                _$LT$rustler..env..OwnedEnv$u20$as$u20$core..default..Default$GT$::default::hef18b4c0c0013efa in librustler-06ed3d621db92764.rlib(rustler-06ed3d621db92764.rustler.8d424656-cgu.14.rcgu.o)
                std::sync::once::Once::call_once::_$u7b$$u7b$closure$u7d$$u7d$::hd2f7ea865264dd2e (.llvm.10254186834831073615) in librustler-06ed3d621db92764.rlib(rustler-06ed3d621db92764.rustler.8d424656-cgu.13.rcgu.o)
                core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::h1811baefb0585ec1 (.llvm.10254186834831073615) in librustler-06ed3d621db92764.rlib(rustler-06ed3d621db92764.rustler.8d424656-cgu.13.rcgu.o)
            "_enif_make_binary", referenced from:
                rustler::types::string::_$LT$impl$u20$rustler..types..Encoder$u20$for$u20$str$GT$::encode::hf11e17216d4e209d in librustler-06ed3d621db92764.rlib(rustler-06ed3d621db92764.rustler.8d424656-cgu.6.rcgu.o)
            "_enif_schedule_nif", referenced from:
                rustler::codegen_runtime::NifReturned::apply::h629cc30f6ef60938 in librustler-06ed3d621db92764.rlib(rustler-06ed3d621db92764.rustler.8d424656-cgu.6.rcgu.o)
            "_enif_raise_exception", referenced from:
                rustler::codegen_runtime::NifReturned::apply::h629cc30f6ef60938 in librustler-06ed3d621db92764.rlib(rustler-06ed3d621db92764.rustler.8d424656-cgu.6.rcgu.o)
            "_enif_release_binary", referenced from:
                core::ptr::drop_in_place$LT$rustler..types..binary..OwnedBinary$GT$::hb5354ca88619fc61 (.llvm.4781004469425706106) in librustler-06ed3d621db92764.rlib(rustler-06ed3d621db92764.rustler.8d424656-cgu.6.rcgu.o)
            "_enif_make_tuple_from_array", referenced from:
                _$LT$rustler..error..Error$u20$as$u20$rustler..codegen_runtime..NifReturnable$GT$::into_returned::h8c893fd57a00bfbb in librustler-06ed3d621db92764.rlib(rustler-06ed3d621db92764.rustler.8d424656-cgu.5.rcgu.o)
                rustler::wrapper::tuple::make_tuple::hc68c55a0bbb5c196 in librustler-06ed3d621db92764.rlib(rustler-06ed3d621db92764.rustler.8d424656-cgu.4.rcgu.o)
            "_enif_make_copy", referenced from:
                _$LT$rustler..term..Term$u20$as$u20$rustler..types..Encoder$GT$::encode::h002f059eebd0fe84 in librustler-06ed3d621db92764.rlib(rustler-06ed3d621db92764.rustler.8d424656-cgu.1.rcgu.o)
                _$LT$rustler..error..Error$u20$as$u20$rustler..codegen_runtime..NifReturnable$GT$::into_returned::h8c893fd57a00bfbb in librustler-06ed3d621db92764.rlib(rustler-06ed3d621db92764.rustler.8d424656-cgu.5.rcgu.o)
            "_enif_inspect_binary", referenced from:
                _$LT$rustler..types..binary..Binary$u20$as$u20$rustler..types..Decoder$GT$::decode::h2a8d27e915fbc323 in librustler-06ed3d621db92764.rlib(rustler-06ed3d621db92764.rustler.8d424656-cgu.7.rcgu.o)
            "_enif_make_badarg", referenced from:
                rustler::codegen_runtime::NifReturned::apply::h629cc30f6ef60938 in librustler-06ed3d621db92764.rlib(rustler-06ed3d621db92764.rustler.8d424656-cgu.6.rcgu.o)
            "_enif_make_atom_len", referenced from:
                rustler::types::atom::Atom::from_str::h9996d08dc62aee50 in librustler-06ed3d621db92764.rlib(rustler-06ed3d621db92764.rustler.8d424656-cgu.8.rcgu.o)
            "_enif_make_map_from_arrays", referenced from:
                rustler::types::map::_$LT$impl$u20$rustler..term..Term$GT$::map_from_arrays::h7d53d07ac3eb86d6 in librustler-06ed3d621db92764.rlib(rustler-06ed3d621db92764.rustler.8d424656-cgu.1.rcgu.o)
          ld: symbol(s) not found for architecture arm64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)


error: could not compile `meeseeks_html5ever_nif` due to previous error

I have installed rust using brew install rust and rust is available:

$ rustc --version
rustc 1.55.0

I'm pretty sure I'm missing something, but I've never worked with Rust or NIFs so I can't really debug the issue.

@Sgoettschkes
Copy link
Contributor Author

The test project with only meeseeks as a dependency works on my old macbook, but not on the new one with an m1 processor, so this might be the issue. Again, without Rust/NIF knowledge, I'm not sure how to solve this.

@mischov
Copy link
Owner

mischov commented Oct 14, 2021

Thanks for the report.

I don't have access to an M1 so testing is going to be a little tricky for me, but let's see what we can figure out.

There are a number of issues around that document linker issues when compiling Rust related things for both Mac in general and M1 in particular.

The Rustler library has issues/PRs (rusterlium/rustler#151, rusterlium/rustler#174, rusterlium/rustler#191) relating to a similar set of linker errors, but for the x86_64-apple-darwin target.

Meeseeks_Html5ever has a .cargo/config file discussed in the issues above, but it only applies to the x86 target.

A different issue (PyO3/pyo3#1330 (comment)) suggests that a problem similar to yours can be resolved by adding an additional target to our .cargo/config

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

Do you think you would be able to clone MeeseeksHtml5ever locally, attempt to run tests (mix test) to confirm the compilation error exists, attempt that fix, and run tests again to see if the problem is resolved?

@Sgoettschkes
Copy link
Contributor Author

Thanks @mischov for the detailed explanation and attempt at solving my problem.

I'll try the steps you suggested (running the MeeseeksHtml5ever tests locally before and after the fix suggested around the cargo config) and report back!

@Sgoettschkes
Copy link
Contributor Author

@mischov Running mix.test without any changes in the MeeseeksHtml5ever project produced the same error as above.

Applying the fix suggested in PyO3/pyo3#1330 (comment) and running mix test again solved the issue!

Changing the .cargo/config to the following should do the trick (with the correct config for x86_64 as well as aarch64):

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

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

With this config I was able to run mix test again after deleting the _build folder. I'm not a rust developer, so I'm not sure if there are any side effects to this change. I can test with an x86_64 apple and this patch applied if you like!

I'm happy to do a PR if you think it's ready and I'm also ok with you committing this yourself.

@mischov
Copy link
Owner

mischov commented Oct 14, 2021

Yes, please test on x86 as well, but I don't believe there should be any side effects.

And yes, please do make a PR.

@mischov mischov changed the title mix deps.compile fails because of Error when attempting to compile meeseeks_html5ever on M1 Macbook Oct 14, 2021
@Sgoettschkes
Copy link
Contributor Author

Issue is resolved with PR #47

@mischov
Copy link
Owner

mischov commented Oct 20, 2021

Fix is released as of meeseeks_html5ever v0.13.1 and meeseeks v0.16.1.

Thank you again, @Sgoettschkes.

philss added a commit to rusterlium/html5ever_elixir that referenced this issue Nov 1, 2021
This fixes the compilation on x86_64 and Arm (M1) machines
running macOS.

Reference: mischov/meeseeks_html5ever#46
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

No branches or pull requests

2 participants