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

Accessing std::env::args from a Rust library in a C++ binary fails on FreeBSD #1306

Open
zanchey opened this issue Jan 13, 2024 · 0 comments

Comments

@zanchey
Copy link

zanchey commented Jan 13, 2024

I'm not sure that this is definitely a cxx problem, but here's the investigation I've done so far.

std::env::args when called from a Rust library, linked to a C++ binary, returns an empty array on FreeBSD.

There's a minimal reproducing repo at https://github.com/zanchey/argstest/ (clone and run make to produce an argstest binary) which:

  • has a C++ entrypoint, that
  • calls a Rust library function, that
  • prints the contents of std::env::args

On Linux/glibc this correctly produces (say) Args { inner: ["./argstest", "foo", "bar", "baz"] }, but on FreeBSD returns Args { inner: [] }.

I don't know if cxx does any magic with the args vector to make it visible from Rust? I couldn't see anything obvious.

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

1 participant