protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

"Initialization segment must not change during translation unit" error when unity build is enabled

Open MoodieG opened this issue 3 years ago • 1 comments

What version of protobuf and what language are you using? Version: v3.20.1 (Linking to protobuf-lite but was able to reproduce with protobuf too) Language: C++

What operating system (Linux, Windows, ...) and version?

Windows 10 Enterprise 19044.1889

What runtime / compiler are you using (e.g., python version or gcc version)

MSVC 19.29

What did you do? Steps to reproduce the behavior:

  1. Unzip the attached file
  2. Run the command cmake . -B out -G "Visual Studio 16 2019" -A x64 -DCMAKE_UNITY_BUILD=ON -DCMAKE_UNITY_BUILD_BATCH_SIZE=2
  3. Navigate to the generated "out" folder.
  4. Open up the project in visual studio 16 2019.
  5. Compile the project.

What did you expect to see

I expected the project to compile successfully.

What did you see instead?

I see C2356 error code that says "Initialization segment must not change during translation unit".

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

Anything else we should know about your project / environment

ProtobufInitSegTest.zip

MoodieG avatar Aug 24 '22 19:08 MoodieG

The same issue is with MSVC 2015. Looks like generated protobuf sources should be excluded from the Unity build.

biodranik avatar Oct 05 '22 08:10 biodranik

Any updates on this?

ianeuman avatar Aug 04 '23 23:08 ianeuman

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago.

github-actions[bot] avatar Jan 07 '24 10:01 github-actions[bot]

I believe this is still an issue, so I am adding a comment to reactivate it.

MoodieG avatar Jan 08 '24 16:01 MoodieG

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago.

github-actions[bot] avatar Apr 11 '24 10:04 github-actions[bot]

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it.

This issue was closed and archived because there has been no new activity in the 14 days since the inactive label was added.

github-actions[bot] avatar Apr 25 '24 10:04 github-actions[bot]