-
-
Notifications
You must be signed in to change notification settings - Fork 814
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
Implement a way to switch stl library for clang (and maybe gcc) #4477
Comments
I think it's possible to configure it using a more generic abstract API like for example: disable stlset_cxxstl("none") or $ xmake f --cxxstl=none it will not add any stl library. gcc/clangset_cxxstl("libc++")
set_cxxstl("libstdc++") we need implement it in core.tools.gcc/clang NDKset_cxxstl("c++_static")
set_cxxstl("c++_shared")
set_cxxstl("gnustl_static")
set_cxxstl("gnustl_shared")
set_cxxstl("stlport_shared")
set_cxxstl("stlport_static") If we want to set it according to the compiler, we can do so: target("test")
on_config(function (target)
if not target:is_plat("android") and target:has_tool("ld", "clang", "clangxx") then
target:set("cxxstl", "libc++")
end
end) And we can use packageadd a bultin config And we need pass |
I like it, but maybe to keep consistency for android ndk we could do -- libc++ shared
-- clang: -stdlib=libc++
-- gcc: -nostdinc++ -nostdlib++ -I<libc++root>/include/c++/v1 -L<libc++root>/lib -lc++ -lc++abi
-- android: flags for c++_shared
set_cxxstl("libc++")
-- libc++ static
-- clang: -stdlib=libstdc++ -static-libstdc++
-- gcc: -nostdinc++ -nostdlib++ -I<libc++root>/include/c++/v1 -L<libc++root>/lib -static -lc++ -lc++abi
-- android: flags for c++_static
set_cxxstl("libc++_static")
-- libstdc++ shared
-- clang: -stdlib=libstdc++
-- gcc:
-- android: flags for gnustl_shared
set_cxxstl("libstdc++")
-- libstdc++ static
-- clang: -stdlib=libstdc++ -static-libstdc++
-- gcc: -static-libstdc++
-- android: flags for gnustl_static
set_cxxstl("libstdc++_static")
-- no stl
-- clang: -nostdlib++
-- gcc: -nostdinc++ -nostdlib++
-- msvc: /X
set_cxxstl("none")
-- android only
-- android: flags for stlport_shared
set_cxxstl("stlport")
-- android: flags for stlport_static
set_cxxstl("stlport_static") for both regular platform / android (and continue to support c++_* / gnustl_* but as deprecated values) |
Thinking about it, it's not very different from the Visual Studio runtime, I wonder if those configs could be merged with set_runtimes, or set_runtimes deprecated for set_cxxstl |
yeah and it could be use to switch all kind of runtimes, like libc set_runtimes("muslc", "libc++") |
sure, you can try. |
Can mege vs_runtime to this feature? |
That's the idea, i'm working on it, but as it is the end of the year, i don't have a lot of time to implementing it (and i'm working on a module PR too) |
I have supported it. #4630 Supported runtimes
New options and configs
Fully compatible with vs_runtime, but we added some deprecated warning tips
xmake update -s github:xmake-io/xmake#runtimes |
I have merged it. |
My CI just broke on the dev branch: https://github.com/NazaraEngine/NazaraEngine/actions/runs/7670670489/job/20907370128 which is a bit weird, it looks like a version issue |
on Windows, set_runtimes for clang seems to have no effects
|
It seems to have something with the hash changes, I can reproduce it locally
the weird thing is that it happens only on Windows |
nodeeditor.qt5gui -> latest
package:version_str() has been resolved as 5.15.2 |
Yes but why does it happen only now? and why only on Windows? And why does qt5gui takes "latest" version? |
here, it will affect package cache key.
|
try it again. |
some packages seems broken
|
It's working now, thanks! |
try it again .4d8b4ad |
By the way, wouldn't this change be a great time to change the default runtime from MT to MD on Windows? MD is the default runtime set by Visual Studio and is the less prone to having issues with DLL |
But it will break more things, especially buildhash |
If we don't set any vs runtime flags, cl.exe uses MT by default, and if we switch to MD. xmake must set MD built-in by default, even if the user doesn't configure any flags for the target. this is going to break a lot of current projects, not just packages. Also, if the user sets vs runtimes, xmake will need to determine which of the built-in MT runtimes to remove, which also adds complexity to the implementation and leads to more problems. |
the error changed, but still failing
|
try it again. |
|
it works for me. https://github.com/xmake-io/xmake-repo/actions/runs/7689614933 and on my win machine. |
Try with --toolchain=clang --runtimes=c++_shared on Windows |
Windows packages are always strongly bound to msvc, and xmake has never supported switching to another toolchain. I have fixed this error, but even though I fixed this bug, the actual msvc is still used. |
i always assumed it was working :D, the only issue i had was that clang compiled package were installing along side msvc one
i think it's because the generator used is msbuild, on some other libraries i have clang that is used so it depend of the package |
Is your feature request related to a problem? Please describe.
Currently to switch stl library for clang we need to hardcode some clang flags for targets and packages, it can cause some problems when a clang package is built with libstdc++ and the project target built with libc++
Describe the solution you'd like
i personnaly think it's better to add a global flag --cxxstl (which will be no-op on msvc, change stl library on clang and maybe gcc)
and it would be used to discriminate package (so for example we could install fmt library with libstdc++ AND libc++)
Describe alternatives you've considered
A toolchain or a policy
Additional context
the discussion of this feature begin here:
#4474
and here a first attempt to implement it with a policy
#4463
The text was updated successfully, but these errors were encountered: