-
Notifications
You must be signed in to change notification settings - Fork 65
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
[native_toolchain_c] Support clang on Windows #1892
Comments
The Clang for Windows on the Dart SDK seems to not have batteries included:
Searching the web for this error message mostly leads to reinstalls of toolchains or a reference to having to run vcvars.bat. The Clang installed via the LLVM installer, or the Clang installed from MSVC have batteries included. The clang pulled in the Dart SDK is a custom built one that maybe does not come with batteries included. Judging from https://github.com/dart-lang/sdk/blob/b5232ac632e26ffc4b4ca3d20afd51d337dbb39b/build/toolchain/win/BUILD.gn#L39-L58, we pull in the msvc parts via build/toolchain/win/msvc_toolchain.gni's Given that these errors do not occur on GitHub nor on my local installation, I think it's safe to say that the Clang-for-Windows on the Dart CI is the odd one out. |
@dcharkes Are you sure about this? I would assume that Clang for Windows cannot re-distribute microsoft's artifacts (e.g. header files or libraries). Reading through clang manual seems to indicate that clang on windows will try to auto-detect it by looking up things in arguments (e.g. passed In any case, it does seem clang on windows does support some of the same things as msvc does (e.g. In general we'd need the capability to allow cross-compiling, which reading e.g. this means we'd need
The question is if we should
It may make sense to look into how cross compiling is done for Rust/Cargo. |
True, it might be smart and figuring it out by itself. Probably both my local machine and the GitHub bots have something in the registry. (It could also be the environment, but then it has to find it via one of the env vars that we allowlist.) Let me try if I can spin up completely clean windows VM, only install LLVM Clang, and see if it fails to compile.
We have everything we need for all Dart and Flutter cross compilation targets at the moment.
So currently, we only have the minimal info in the protocol, and construct things such as the target triple and the sysroot path for iOS/MacOS inside If we're talking about cpu/fpu/api, I'm not even sure if that should be in the
https://rust-lang.github.io/rustup/cross-compilation.html It also uses target triples. @mosuem has been using this in icu4x: https://github.com/unicode-org/icu4x/blob/bfa1ddffd72783eb437f5a2ace25e165625020a9/ffi/dart/tool/build_libs.dart#L99 Also here But indeed if we'd like to have an embedder to be able to target softfp-linux-arm, that softfp needs to be part of the
I'd say things that can be consumed by other native compilers (Rust compiler) need to be explicitly modeled. The embedder doesn't know if a hook will use the provided C-toolchain from Another thing to consider is if a hook decides to be funky and uses multiple compilers. For example, if you use We can probably postpone adding sysroot/abi. But we need Windows "sysroot" now, so we need to decide how to model that. Maybe the |
Yes, that was meant as a general note. The reason I mentioned softfp vs hardfp is that flutter engine (as well as Dart VM) actually allows building with hardfp or softfp (see tools/gn)
Agreed! We only want the hook to produce a ELf/MachO/PE binary that is correctly built, whether it's with Rust or with C compiler. So it probably should be at
It may be that a |
Yeah, but
Perfect, then we are on the same page!
Wish me luck on another day of Windows VMs while I try to nail the behavior of Windows Clang down. 😅 |
The developer command prompt is the Hardcoding an env-script (that is not registered in the Windows registry) indeed makes compilation with clang succeed: Future<Map<String, String>> resolveEnvironment(ToolInstance compiler) async {
return await environmentFromBatchFile(
Uri.file(
r'C:\src\depot_tools\win_toolchain\vs_files\27370823e7\Windows Kits\10\bin/SetEnv.cmd'),
arguments: ['/x86'],
); We can't test this on GitHub CI, it comes with MSVC pre-installed. |
We should add support for using Clang on Windows.
Using Clang on Windows will require passing in a "sysroot" from visual studio or cygwin for the system headers and system libraries to link against.
This will then inform what the
native_assets_cli
CCompilerConfig
should look like to cover this use case.CCompiler.{envScript,envScriptArgs}
and replace by other means #1606TODO:
clang
if OS is Windows inpackage:native_toolchain_c
.The text was updated successfully, but these errors were encountered: