GithubHelp home page GithubHelp logo

Comments (7)

knopp avatar knopp commented on July 4, 2024 1

I planned to add rpath to rustc-link-arg as soon as 1.56 becomes stable. I'll be very happy to get rid of .cargo/config.toml.

from nativeshell.

thenextman avatar thenextman commented on July 4, 2024

Alright, I tracked this down to a weird conflict with a specific dependency in our existing crate. I'll chat to the developer on that and see what I can figure out.

from nativeshell.

knopp avatar knopp commented on July 4, 2024

Perhaps there is an older version of lazy_static that requires types to be Send as well? In NativeShell we know that the static is only used from main thread so if this is a big problem maybe we could just add unsafe impl Send for Global {}, but it would be good to know why exactly is this happening.

from nativeshell.

thenextman avatar thenextman commented on July 4, 2024

@knopp I got to the bottom of this, but I don't know the appropriate fix

lazy_static is pulled in a few places, always 1.4.0. However, one of our dependencies pulls in rsa and num-bigint; both of which enable the spin_no_std feature of lazy_static. Once one dependency enables a feature, everybody gets it.

I can't find the documentation on it, but it's that feature that's requiring Send across the board.

I can fix this by adding unsafe impl Send... (at least on macOS, that's for ApplicationDelegateClass, MenuItemTargetClass, WindowClass and WindowDelegateClass. On Windows it's Global. I didn't check Linux yet). I could make a PR to that effect.

Otherwise, we could just build our own fork of nativeshell and wait until this all gets worked out upstream. In general there seems some concern over that feature of lazy_static.

Do you have another idea?

from nativeshell.

knopp avatar knopp commented on July 4, 2024

I took a look at the spin-rs crate and it seems to be that it is using a very basic spin lock under the hood that might suffer from priority inversion. I find it quite concerning that there are crates unconditionally forcing this behavior.

This might be relevant. Edit: I now noticed that you mentioned the issue already.

All this aside, I do not mind adding Send to these classes knowing now that lazy_static might be requiring this in some circumstances. If you submit the PR (preferably with a comment explaining why it there is unsafe Send) I can merge it.

from nativeshell.

thenextman avatar thenextman commented on July 4, 2024

@knopp I will go ahead and do that within the next day or two. Thanks again!

from nativeshell.

thenextman avatar thenextman commented on July 4, 2024

I raised PR#91 to correct this.

A further incompatibility arrises with workspaces: when building from the workspace, the project-level .cargo/config.toml is not consulted. Since (at least on macOS) the rpath is not properly set, the final binary fails with a dynamic linker error.

Currently we can workaround by specifying the configuration inside build.rs instead:

e.g. println!("cargo:rustc-link-arg=-Wl,-rpath,@executable_path");

That's an unstable feature until rust 1.56, so we also to use nightly and a modified build command:

e.g. cargo +nightly build -p nativeshell -Zextra-link-arg

from nativeshell.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.