Skip to content

Comments

[Stormlib] UNICODE needs to be PUBLIC#38696

Closed
Lectem wants to merge 3 commits intomicrosoft:masterfrom
Lectem:stormlib-unicode-feature
Closed

[Stormlib] UNICODE needs to be PUBLIC#38696
Lectem wants to merge 3 commits intomicrosoft:masterfrom
Lectem:stormlib-unicode-feature

Conversation

@Lectem
Copy link
Contributor

@Lectem Lectem commented May 11, 2024

Usually UNICODE can be set or not without issues. However in the case of stormlib, TCHAR is part of the API, which can lead to issues.

By default CMake uses MBCS instead of unicode:

This means that a project using CMake defaults would see sizeof(TCHAR)==1 while stormlib would see sizeof(TCHAR)==2.

Make the define PUBLIC so that targets linking stormlib::stormlib will automatically define it too.

Ideally, we would remove the use of this define entirely (this is something that must be controlled by the user, for example using a toolchain file), but this would break current users. We also can not use a feature to togggle this behaviour due to https://github.com/microsoft/vcpkg-docs/blob/main/vcpkg/contributing/maintainer-guide.md#features

  • Changes comply with the maintainer guide.
  • SHA512s are updated for each updated download.
  • The "supports" clause reflects platforms that may be fixed by this new version.
  • Any fixed CI baseline entries are removed from that file.
  • Any patches that are no longer applied are deleted from the port's directory.
  • The version database is fixed by rerunning ./vcpkg x-add-version --all and committing the result.
  • Only one version is added to each modified port's versions file.

@Lectem
Copy link
Contributor Author

Lectem commented May 11, 2024

@microsoft-github-policy-service agree

Usually UNICODE can be set or not without issues. However in the case of
stormlib, TCHAR is part of the API, which can lead to issues.

By default CMake uses MBCS instead of unicode:
- https://gitlab.kitware.com/cmake/cmake/-/blob/v3.27.7/Source/cmLocalVisualStudio7Generator.cxx#L805
- https://gitlab.kitware.com/cmake/cmake/-/blob/v3.27.7/Source/cmVisualStudio10TargetGenerator.cxx#L1516
- https://gitlab.kitware.com/cmake/cmake/-/blob/v3.27.7/Source/cmVisualStudioGeneratorOptions.cxx#L137

This means that a project using CMake defaults would see sizeof(TCHAR)==1
while stormlib would see sizeof(TCHAR)==2.

Make the define PUBLIC so that targets linking stormlib::stormlib will automatically define it too.

Ideally, we would remove the use of this define entirely (this is something that must be controlled by the user, for example using a toolchain file), but this would break current users.
We also can not use a feature to togggle this behaviour due to https://github.com/microsoft/vcpkg-docs/blob/main/vcpkg/contributing/maintainer-guide.md#features
@Lectem Lectem force-pushed the stormlib-unicode-feature branch from e7efe7d to fccdb49 Compare May 11, 2024 12:13
@JonLiu1993 JonLiu1993 self-assigned this May 13, 2024
@JonLiu1993 JonLiu1993 added the category:port-bug The issue is with a library, which is something the port should already support label May 13, 2024
@JonLiu1993
Copy link
Contributor

"port-version": 5,

Please change port-version to 6 and run command ./vcpkg x-add-version stormlib and commitr again

@JonLiu1993
Copy link
Contributor

Note: I will be converting your PR to draft status. When you respond, please revert to "ready for review". That way, I can be aware that you've responded since you can't modify the tags.

@JonLiu1993 JonLiu1993 marked this pull request as draft May 13, 2024 09:11
@Lectem
Copy link
Contributor Author

Lectem commented Jun 7, 2024

#38834 removed the CMakeLists.txt entirely to replace it with the upstream version.
The upstream version does not seem to set the UNICODE macros anymore (which is thus a breaking change), so I will close this pull request.

However I still find it a bit concerning that such changes to ABI (as opposed to API) can happen so easily. But I think that we now have the correct behaviour (keep CMake/toolchain defaults). Perhaps ports with libraries that use TCHAR in their interface should have UNICODE be part of the ABI checks somehow ?

@Lectem Lectem closed this Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category:port-bug The issue is with a library, which is something the port should already support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants