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

Patch libstd arg initialization for rust#66547 #804

Closed
bjorn3 opened this issue Nov 21, 2019 · 3 comments
Closed

Patch libstd arg initialization for rust#66547 #804

bjorn3 opened this issue Nov 21, 2019 · 3 comments

Comments

@bjorn3
Copy link
Member

bjorn3 commented Nov 21, 2019

Once rust-lang/rust#66547 lands, the linux-gnu target will use #[link_section] to initialize the list of arguments. Because cranelift-module doesn't provide an api to place functions and statics in a specific section, we will need to patch libstd to revert the rust PR.

@joshtriplett
Copy link
Member

This seems unfortunate. Is there any plan to support writing things to different sections in the cranelift backend?

@bjorn3
Copy link
Member Author

bjorn3 commented Nov 22, 2019

object does support this, so by modifying cranelift-object it should be possible to implement it. faerie however only has support for custom sections to which nobody refers to. For cranelift-simplejit it wouldn't even make sense to support this, as no object files are emitted. The SimpleJIT backend currently supports passing arguments to the jitted code, however when linking to libstd, we load the dylib for it. By using .init_array, the loaded libstd will get initialized with the arguments of the rustc process itself, instead of the content of the JIT_ARGS env var, which cg_clif passes to the generated main shim.

I think it would be the best if the args passed to main would be used whenever possible. It could for example override the args set by .init_array.

@bjorn3 bjorn3 mentioned this issue Dec 16, 2019
@bjorn3
Copy link
Member Author

bjorn3 commented Dec 16, 2019

Patched in bjorn3@b97df0b.

@bjorn3 bjorn3 closed this as completed Dec 16, 2019
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