-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Zephyr build fail with LLVM on Windows #32111
Comments
Windows support is planned and is not done yet. |
@nashif Hi Nashif, many thanks for your reply. When will zephyr could support llvm on windows platform? Do we have an ETA? Or maybe is there any workaround which I can do for using llvm compiler for zephyr on windows? |
@tejlmand any idea what is going on here and why we go into a loop? |
**Also tried with latest LLVM toolchain, error reported below: CMake Error at ../../cmake/extensions.cmake:1735 (message): **In CMakeError.log, it shows that: Checking whether the ASM compiler is GNU using "--version" did not match "(GNU assembler)|(GCC)|(Free Software Foundation)": |
hi @tejlmand Attached more log for the build error, could you please give some help for llvm build on Windows? Many thanks. |
i finally got to it and I am able to reproduce the recursive issue. |
Hi @nashif It got the below CMake error reported: In ../../cmake/extensions.cmake:1735, it has the code as: And in CMakeError.log, it shows: |
The system include directory might include spaces on windows, so quote it. Partially part of fix for zephyrproject-rtos#32111 Signed-off-by: Anas Nashif <anas.nashif@intel.com>
after fixing the path of system includes in #33945 the errors are about missing gcc. Looks like on windows llvm depends on gcc or an msvc environment. |
Yes, it seems that Clang attempts to use MSVC's standard library on Windows by default, or GCC's libraries, since Clang's own standard library doesn't work on Windows yet. |
The system include directory might include spaces on windows, so quote it. Partially part of fix for #32111 Signed-off-by: Anas Nashif <anas.nashif@intel.com>
For some reason i'm not able to re-produce the infinite loop when using llvm, but I oberserve the infinite CMake loop when working on arm-clang support in windows, and I suspect those to be related. But what I do observe during build when using clang on windows is this:
Lines 40 to 47 in 5cc20fa
On Linux,
but on windows,
and thus not And a quick search in Zephyr repo reveals 60 occurrences of
|
For current clang on Windows, use clang -v, shows: |
Thanks for the hint. When doing
but for unknown reason this triplet is not applied when building on windows. |
ok, seems to be correctly applied in later CMake versions. |
Seems we need to look at what to do for the gcc assembly:
which on my system happens because clang can't use it's built-in assembler and thus calls out to an external assembler, in my particular case:
and trying to avoid that results in:
|
Seems to be caused by this: zephyr/arch/x86/core/ia32.cmake Lines 4 to 6 in 35f52fd
|
hi @tejlmand I reproduced the error on qemu_x86 board in zephyr like below: But I installed the old version of clang for my windows 10: https://releases.llvm.org/3.7.0/LLVM-3.7.0-win64.exe |
Tried with following process: Modified in zephyr/cmake/compiler/clang/target.cmake (line 60):
And added triple in zephyr/cmake/toolchain/llvm/generic.cmake (line 25):
Add gcc_8_3\bin which contains 'i486-elf-' in the system environment path, build for target qemu_x86 with llvm on windows can pass. CMake version: 3.20.1
|
@YanzhouYu can you please retry with the current master? |
Hi @carlescufi @tejlmand @nashif I tried with latest zephyr code v2.6.0-rc1 on Windows 10,
CMake reports error: After comment 'assert' in CMakeLists.txt line 42:
Build goes to infinite loop with Re-running CMake: Could you please take a look at this problem? |
got the same issue on windows with the latest main branch aec4c49 |
waiting for the "infinite loop with Re-running CMake" and it will report an error as below finally: then run the command "ninja -C build -d explain" to get details, it reported it seems that ninja will always judge the build.ninja is not the latest, so it always regenerated it. |
hi @tejlmand Could you help take a look of this problem?
|
the compiler clang of LLVM will used external system linker in default, i.e, the linker of mingw or VC, not the ld.lld of LLVM built-in, so in my environment, it used the mingw32/bin/ld.exe, this is not a cross-compiler and I found it only support i386pe, couldn't be used to build zephyr elf file.
and I tested to use LLVM built-in linker on linux, it reported the same error. |
this error was caused that cmake couldn't find a valid linker path when checking compiler support flag, because clang won't use LLVM built-in lld in default.
the infinite loop, please use the ninja version 1.8.2, not the latest. |
@YanzhouYu I tested the LLVM built-in lld on windows and linux, it reported the same error, it seems that it couldn't support cross linker well ,so I replaced it by a cross i486-elf.ld.exe to complete link process, it's ok to generate final zpehyr.elf, so please use a cross gcc linker for link process firstly. |
tried to install Intel OneApi toolchain on Windows, but I found that icx will invoke clang-cl, rather than the clang on Windows, and the clang-cl is used to be compatible with msvc cl compiler, there are some different options with clang, so when I used icx to build zephyr binaries on windows, it reported some errors like below, because clang-cl doesn't have those options "-x assembler-with-cpp","-isystem","-include".
|
also tried to use other cmake functions "add_compiler_options, add_link_options" to solve the CMAKE_C_COMPILER_TARGET recognition problem above.
It could continue to build and compile those C source files, but I don't know why it skipped those assembly files. the original cmake script as below:
|
fixed by #37157. |
Describe the bug
I am trying to build zephyr project in Windows with llvm compiler, but it failed.
To Reproduce
Steps to reproduce the behavior:
I installed llvm version 11.0.0 for windows and set the patch to the location.
In zephyr/samples/hello_world directory, delete all the /build content,
Expected behavior
Build can be done for hello-world as cross-compile with gcc i486.
Logs and console output
-- The C compiler identification is Clang 11.0.0
-- The CXX compiler identification is Clang 11.0.0
-- The ASM compiler identification is Clang
-- Configuring done
-- Generating done
-- Build files have been written to: /zephyr/zephyr-intel/samples/hello_world/build
[0/1] Re-running CMake...
Including boilerplate (Zephyr base (cached)):
...
[0/1] Re-running CMake...
...
[0/1] Re-running CMake...
Environment (please complete the following information):
Additional context
Tried LLVM and Intel oneApi ICX compiler in Linux, both of them work.
Also tried with 'set ZEPHYR_TOOLCHAIN_VARIANT=cross-compile' and 'set CROSS_COMPILE=path to \ish_gcc_8_3\bin\i486-elf-' on Windows, samples/hello_world can be built successfully by 'west build -b qemu_x86 . '
How to build Zephyr project with clang or icx compiler on Windows?
The text was updated successfully, but these errors were encountered: