[spdlog] Fix the non-Windows build issue by scoping the define to Windows targets.#27740
Conversation
|
CC @diablodale |
|
good catch, logic makes sense. |
|
The better fix would be to add an |
Code snippet? |
--- a/ports/spdlog/vcpkg.json
+++ b/ports/spdlog/vcpkg.json
@@ -24,7 +24,8 @@
]
},
"wchar": {
- "description": "Build with wchar_t (Windows only)"
+ "description": "Build with wchar_t (Windows only)",
+ "supports": "windows"
}
}
} |
|
Thanks for the tip! Looks simpler too. will update the PR shortly |
|
@JonLiu1993 does someone on your team understand why CI didn't catch this bug on linux, osx, etc.? |
|
after trying @autoantwort's patch locally, one downside of using This forces users to split their dependency definition in two if they're targeting multiple platforms, which feels a little clunky tbh: I still appreciate that the intent of I'm undecided on which fix is better: the first fix that's backwards-compatible, or the |
|
You can use |
looking at the logs from the checks, I think the reason it didn't catch it is that the test builds don't specify additional features, they just build with default features (which in this case wouldn't include |
|
Maybe vcpkg should just skip features that are not supported for a triplet, but that can lead to surprising results as well. {
"features": [{"name": "wchar", "platform": "windows"}]
} |
{
"features": [{"name": "wchar", "platform": "windows"}]
}Yes that would be my preferred workaround. I'm afraid passing a blanket Anyway, I can live with adding the separate dependency to avoid the error from |
- Defining SPDLOG_WCHAR_TO_UTF8_SUPPORT on non-Windows platforms triggers an #error, restrict the wchar feature to Windows - update port-version + vcpkg x-add-version spdlog
e71a74d
b6a256a to
e71a74d
Compare
Hmmm. Is testing only the default features of a port a vcpkg-wide rule? Or is this something specific to this port? |
Yes |
@kromain, ci will only test the default features. We need to manually test other features locally. the wchar feature will not be tested on ci, so no error is reported in ci test, In principle, we need to test these features locally. |
|
FTR there are examples of features which are documented to do nothing in certain contexts. So this approach can be acceptable but then it it should really do nothing ;-) With an explicit "spdlog",
{
"name": "spdlog",
"features": [ "wchar" ],
"platform": "windows"
}(But it gets complicated again as soon as you want/need to add |
|
@kromain, When I tested the features by command "./vcpkg install spdlog[*]:x86-windows" I got the error: Please take a look. |
|
Indeed, I see the same error when using I've tracked it down to the There was actually a long-standing warning in that header to include a different file, but I guess nobody noticed it on the spdlog side. It's a trivial fix, I can submit a patch to spdlog and wait for the update to the next release, or if you think it's critical enough we can also add the patch to the port in the meantime. In any case, I think it should be addressed in a separate PR as it's specific to the |
|
Feature
|
|
PR title:
Review:
Find the problem! |
|
FYI the fix for the issue with |
BillyONeal
left a comment
There was a problem hiding this comment.
one downside of using
"supports": "windows"is that it breaks vcpkg install on non-windows platforms if the feature is enabled for the dependency:
You say downside, I would argue this is an upside. If someone explicitly asks for wchar_t and that can't be provided, the right behavior is to tell them that doesn't work, not ignore what they asked for.
I think it would also be reasonable to remove the feature entirely, and just make the choice that this is on for Windows and off for everyone else. Then the user hasn't made an explicit request we need to honor or fail for.
Thanks for the fix!
PR title:
Fix non-Windows builds with wchar feature enabled
Review:
Feature wchar tested successfully in the following triplet:
- x86-windows
- x64-windows
- x64-windows-static
Find the problem!
The PR makes building the feature on non-Windows triplets impossible, so I'm not sure what you would expect @JonLiu1993 to have done here. He checked that Windows didn't regress given that CI doesn't check that for us automatically.
@JonLiu1993 Thanks for checking that things still work!
| "#ifndef SPDLOG_FMT_EXTERNAL\n#define SPDLOG_FMT_EXTERNAL\n#endif" | ||
| ) | ||
| if(SPDLOG_WCHAR_SUPPORT) | ||
| if(SPDLOG_WCHAR_SUPPORT AND VCPKG_TARGET_IS_WINDOWS) |
There was a problem hiding this comment.
I'm weakly against defending against unsupported configurations like this but I don't think it's that "harmful". I would not expect future edits to this port to preserve this behavior, for instance.
Describe the pull request
What does your PR fix?
The previous portfile update (840f701d83d5019aa5033c9d) broke non-Windows builds when thewcharfeature is enabled. The feature is allowed for non-Windows systems, just getting ignored in that case. But the change that adds the#define SPDLOG_WCHAR_TO_UTF8_SUPPORTis not scoped to Windows, and having that define in a non-Windows build triggers an #error:This PR fixes the non-Windows build issue by scoping the define to Windows targets.
Which triplets are supported/not supported? Have you updated the CI baseline?
all, No
Does your PR follow the maintainer guide?
Yes
If you have added/updated a port: Have you run
./vcpkg x-add-version --alland committed the result?Yes