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

Make static ns_string!s work inside closures #258

Open
madsmtm opened this issue Aug 31, 2022 · 7 comments
Open

Make static ns_string!s work inside closures #258

madsmtm opened this issue Aug 31, 2022 · 7 comments
Labels
A-framework Affects the framework crates and the translator for them bug Something isn't working

Comments

@madsmtm
Copy link
Owner

madsmtm commented Aug 31, 2022

They don't currently for some reason!

Discovered in #254.

@madsmtm madsmtm added bug Something isn't working A-framework Affects the framework crates and the translator for them labels Aug 31, 2022
@madsmtm
Copy link
Owner Author

madsmtm commented Sep 28, 2022

Similar error when using:

RUSTFLAGS="-Clink-dead-code" cargo build --example basic_usage

@madsmtm madsmtm mentioned this issue Sep 28, 2022
@madsmtm madsmtm added A-objc2 Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` crates and removed A-framework Affects the framework crates and the translator for them labels Dec 23, 2022
@madsmtm madsmtm added the I-unsound A soundness hole label Jan 7, 2023
@madsmtm madsmtm removed the I-unsound A soundness hole label Jan 15, 2023
@madsmtm
Copy link
Owner Author

madsmtm commented Jan 15, 2023

I've cfg-gated the functionality behind the feature flag unstable-static-nsstring for now: #350

@madsmtm
Copy link
Owner Author

madsmtm commented Jan 28, 2023

objrs adds special export_names, so perhaps that's required?

@madsmtm
Copy link
Owner Author

madsmtm commented Aug 27, 2023

A change in rustc dead code elimination causes the UTF16 to appear in the assembly output, even though it's known statically that the symbol is unused.

Note that this happens even if the #[link_section = "..."] attribute is removed.

Will probably need to bisect rustc to find the regression, it's somewhere between nightly-2023-05-25 and nightly-2023-08-27.

@madsmtm
Copy link
Owner Author

madsmtm commented Aug 27, 2023

I bisected it to rust-lang/rust#115126, probably rust-lang/rust#115114, but also found that it only appears if you place the string in another static, not if you just use it as an expression.

So probably not worth doing more about.

@madsmtm madsmtm added A-framework Affects the framework crates and the translator for them and removed A-objc2 Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` crates labels Sep 5, 2023
@madsmtm madsmtm changed the title Make ns_string! macro work inside closures Make static ns_string!s work inside closures Sep 11, 2023
@complexspaces
Copy link

Sorry to necropost, but given the Rust bisection work you did last year what is the status of the unstable-static-nsstring flag? Is this something that can be tested as correct now?

@madsmtm
Copy link
Owner Author

madsmtm commented Sep 4, 2024

I doubt it, I suspect the two statics that's needed for this, the one in __DATA,__cfstring and the one in __TEXT,__cstring,cstring_literals, still need to end up in the same codegen unit for the linker to be able to pick this up for sure, and I'm not sure how to make rustc guarantee that happens?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-framework Affects the framework crates and the translator for them bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants