-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
New props infrastructure is not portable #34090
Comments
Pipeline showing break in RNW: https://dev.azure.com/ms/react-native-windows/_build/results?buildId=323774&view=results react-native/ReactCommon/react/renderer/core/PropsMacros.h Lines 17 to 25 in 577582e
|
Cc @JoshuaGross |
Looks like it should be wrapped with
|
@asklar do you know if in React Native Windows we'll get a warning or error if we had this code as-is without the pragma? The issue with Clang was that this code could introduce variables |
if we remove the pragma, I imagine msvc might produce a warning if the right warning level flag is set, perhaps @chiaramooney can try it. #define CONSTEXPR_RAW_PROPS_KEY_HASH(s) (folly::hash::fnv32_buf(s, sizeof(s) - 1)) is the problem that folly's fnv32_buf functions aren't constexpr? take a look at the PR I made a reference to originally and see if that helps, that does everything in constexpr without any funky macros |
@asklar I should be able to change the macro into a |
thanks @JoshuaGross for taking a look! Yeah I'm using a macro to do consteval for cpp20 and constexpr otherwise; we don't yet use cpp20, so this would downgrade to constexpr for us. |
Yeah we're not on C++20 yet either, so I'll have to find something that works with just constexpr. I'll play around a little bit. If y'all get to it faster, let me know if MSVC is fine with just removing the pragmas. |
@asklar What version of C++ are you on? Can I assume at least C++17? |
yes we're on cpp17 |
I have a local diff we can try out. @asklar want to see if this works for you?
I'll have more commentary if/when I land the actual diff. I'm still trying to avoid doing this the "proper" way without macros because it results in 10x as much code and is IMO a lot less readable, though that's highly subjective. If this compiles on MSVC let's do this; if not, is there a scoped way to ignore shadowing warnings in MSVC? |
@asklar please reopen if this is still an issue on your end |
@JoshuaGross Error still present following attempt to integrate 7/4 nightly build. cc @asklar |
@chiaramooney can you confirm it's coming from the same place that @JoshuaGross modified in d1d11c7? If so, can you see if somehow |
Yes same place. @asklar Off the top of your head do you know if clang is defined in MSVC builds, otherwise I can investigate? |
Looks like I don't have permissions to reopen, @JoshuaGross mind reopening this? |
it looks like the syntax |
ok, looks like that syntax is a language extension in GCC (and clang implements it too) but it is not standard C++: https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html @JoshuaGross could we write this in a way that is portable? maybe move the "statement expression" inside of a |
an alternative approach is to use an immediate lambda instead of a statement expression: case [&]{ /* ... */ return something; }(): /* ... */ |
FYI @JoshuaGross is OOO until next week. If anyone from the MSFT side wants to put up a PR with a fix sooner, I can find someone on our side to review |
@chiaramooney can you apply the change and send a PR to here? |
Trying
still results in the same syntax errors as |
@asklar @chiaramooney I'm back from leave but not sure when I'll be able to prioritize this. The only hard requirement/goal from my end is that these blocks continue to be compile-time evaluated on iOS and Android; it would be nice if that were the case for all platforms, but there might not be a portable way of doing it. Can one of you iterate on this until it compiles for MSVC? And then we can make sure the solution is acceptable for iOS/Android as well. I don't normally compile using MSVC so I'd prefer not to drive the solution. |
Alright I believe we have a fix. Both BaseTextProps.cpp and PropsMacros.h need edits. New versions of files can be found here: These changes use the approach of replacing all ({something}) syntax with lambda expressions in both the GET_FIELD_VALUE and CONSTEXPR_RAW_PROPS_KEY_HASH(s) macros and adding a semicolon to the end of the GET_FIELD_VALUE macro. @JoshuaGross @lyahdav |
@JoshuaGross @lyahdav If you have a moment to validate that the changes also work on your end. I can put out a PR. |
@chiaramooney I'd say just put out a PR on this repo for it, and then we'll see if builds successfully in our CI. |
@chiaramooney I noticed that your PR landed - do you need this in 0.70? |
The PR was unlanded. Looks like it caused some regression. I'm awaiting some clarification internally on the status. |
Looks like a fix for the regression is landing. The fix should work on MSVC, but we'll need someone from the MSFT side to verify. You can monitor for commits touching BaseTextProps.cpp to see when it's landed. |
ok so let's postpone this to the next RC - we'll do RC2 without this, and you all can let me know if this will need to be in RC3 |
This issue is blocking ingestion into RNW, so if we can get this sorted out sooner than later (in rc1) that'd be great. |
@lyahdav can you reopen this issue if it still needs to be [re-]merged? |
Summary: Fix macro errors for Windows. Current syntax breaks the build of the React Common project on Windows because the ({...}) syntax is not supported; must be replaced with lambda expressions. Resolves facebook#34090 ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [General] [Fixed] - Fix macro errors for Windows. lyahdav JoshuaGross Pull Request resolved: facebook#34299 Test Plan: Build on react-native-windows repo. Tested in RNW app. Reviewed By: javache Differential Revision: D38272966 Pulled By: NickGerleman fbshipit-source-id: e76eac11cde173ef49465d01d793c593017f2ab7
Summary: Fix macro errors for Windows. Current syntax breaks the build of the React Common project on Windows because the ({...}) syntax is not supported; must be replaced with lambda expressions. Resolves facebook#34090 ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [General] [Fixed] - Fix macro errors for Windows. lyahdav JoshuaGross Pull Request resolved: facebook#34299 Test Plan: Build on react-native-windows repo. Tested in RNW app. Reviewed By: javache Differential Revision: D38272966 Pulled By: NickGerleman fbshipit-source-id: e76eac11cde173ef49465d01d793c593017f2ab7
Description
This commit: 47280de
Introduced a compile-time string hashing mechanism (perhaps inspired by this) to do
switch
statements on string values.However the resulting code uses clang-specific pragmas, which won't work with other compilers (e.g. MSVC).
This breaks ingestion of RN core into React Native Windows.
Version
main
Output of
npx react-native info
n/a
Steps to reproduce
n/a
Snack, code example, screenshot, or link to a repository
n/a
The text was updated successfully, but these errors were encountered: