-
Notifications
You must be signed in to change notification settings - Fork 166
Open
Labels
area: LLVMIssues related to LLVMIssues related to LLVMplatform: WindowsIssues related to Zephyr SDK on Windows hostsIssues related to Zephyr SDK on Windows hosts
Description
Summary
When building Zephyr with Zephyr SDK LLVM toolchain on Windows, CMake compiler flag check function (check_compiler_flag
) "randomly" returns wrong results.
Running CMake twice with the toolchain compatibility database cache cleared before each run, the compiler flag check results differ:
--- run1.log.nl 2024-10-28 01:36:58.333289400 +0000
+++ run2.log.nl 2024-10-28 01:37:04.554760200 +0000
@@ -26,20 +26,20 @@
26 -- The ASM compiler identification is Clang with GNU-like command-line
27 -- Found assembler: S:/llvm/bin/clang.exe
28 -- @@ C, , 1
- 29 -- @@ C, -Wall, 1
+ 29 -- @@ C, -Wall, 0
30 -- @@ C, -Wformat;-Wformat-security, 1
- 31 -- @@ C, -Wformat;-Wformat-zero-length, 1
- 32 -- @@ C, -Wdouble-promotion, 0
+ 31 -- @@ C, -Wformat;-Wformat-zero-length, 0
+ 32 -- @@ C, -Wdouble-promotion, 1
33 -- @@ C, -Wpointer-sign, 1
34 -- @@ C, -Wpointer-arith, 0
- 35 -- @@ C, -Wexpansion-to-defined, 0
+ 35 -- @@ C, -Wexpansion-to-defined, 1
36 -- @@ C, -Wlogical-op, 0
- 37 -- @@ C, -Wmissing-field-initializers, 0
+ 37 -- @@ C, -Wmissing-field-initializers, 1
38 -- @@ C, -Wpacked-bitfield-compat, 0
- 39 -- @@ C, -Wvla, 1
+ 39 -- @@ C, -Wvla, 0
40 -- @@ C, -Wunused-but-set-variable, 0
41 -- @@ C, -Werror=implicit-int, 1
- 42 -- @@ C, -mstack-protector-guard=global, 0
+ 42 -- @@ C, -mstack-protector-guard=global, 1
43 -- @@ C, -fno-freestanding, 0
44 -- @@ C, -ffreestanding, 1
45 -- @@ C, -gdwarf-4, 1
@@ -49,45 +49,45 @@
49 -- @@ C, -Wtypedef-redefinition, 0
50 -- @@ C, -Wdeprecated-non-prototype, 1
51 -- @@ C, -Wold-style-definition, 1
- 52 -- @@ C, -Wmissing-prototypes, 0
- 53 -- @@ C, -Wmissing-include-dirs, 1
+ 52 -- @@ C, -Wmissing-prototypes, 1
+ 53 -- @@ C, -Wmissing-include-dirs, 0
54 -- @@ C, -Wunused-but-set-variable, 0
- 55 -- @@ C, -Wmissing-field-initializers, 0
+ 55 -- @@ C, -Wmissing-field-initializers, 1
56 -- @@ C, -Wsometimes-uninitialized, 0
- 57 -- @@ C, -Wshift-overflow, 1
- 58 -- @@ C, -Wmissing-braces, 0
- 59 -- @@ C, -Wself-assign, 1
+ 57 -- @@ C, -Wshift-overflow, 0
+ 58 -- @@ C, -Wmissing-braces, 1
+ 59 -- @@ C, -Wself-assign, 0
60 -- @@ C, -Waddress-of-packed-member, 1
61 -- @@ C, -Wunused-function, 1
- 62 -- @@ C, -Winitializer-overrides, 0
- 63 -- @@ C, -Wsection, 1
- 64 -- @@ C, -Wunknown-warning-option, 0
+ 62 -- @@ C, -Winitializer-overrides, 1
+ 63 -- @@ C, -Wsection, 0
+ 64 -- @@ C, -Wunknown-warning-option, 1
65 -- @@ C, -Wunused-variable, 1
66 -- @@ C, -Wformat-invalid-specifier, 0
- 67 -- @@ C, -Wgnu, 0
+ 67 -- @@ C, -Wgnu, 1
68 -- @@ C, -Wtautological-compare, 0
69 -- @@ C, , 0
- 70 -- @@ C, , 1
+ 70 -- @@ C, , 0
71 -- @@ C, , 1
72 -- @@ C, , 1
73 -- @@ C, , 0
- 74 -- @@ C, , 0
+ 74 -- @@ C, , 1
75 -- @@ C, , 1
76 -- @@ C, , 0
77 -- @@ C, , 0
78 -- @@ C, , 1
79 -- @@ C, , 0
80 -- @@ C, , 1
- 81 -- @@ C, , 0
- 82 -- @@ C, , 1
+ 81 -- @@ C, , 1
+ 82 -- @@ C, , 0
83 -- @@ C, -fno-asynchronous-unwind-tables, 1
- 84 -- @@ C, -ftls-model=local-exec, 1
- 85 -- @@ C, -Wvla, 1
- 86 -- @@ C, -fmacro-prefix-map=C:/a/sdk-ng/sdk-ng/zephyrproject/zephyr/samples/hello_world=CMAKE_SOURCE_DIR, 0
- 87 -- @@ C, -fmacro-prefix-map=C:/a/sdk-ng/sdk-ng/zephyrproject/zephyr=ZEPHYR_BASE, 0
+ 84 -- @@ C, -ftls-model=local-exec, 0
+ 85 -- @@ C, -Wvla, 0
+ 86 -- @@ C, -fmacro-prefix-map=C:/a/sdk-ng/sdk-ng/zephyrproject/zephyr/samples/hello_world=CMAKE_SOURCE_DIR, 1
+ 87 -- @@ C, -fmacro-prefix-map=C:/a/sdk-ng/sdk-ng/zephyrproject/zephyr=ZEPHYR_BASE, 1
88 -- @@ C, -fmacro-prefix-map=C:/a/sdk-ng/sdk-ng/zephyrproject=WEST_TOPDIR, 1
- 89 -- @@ C, -ffunction-sections, 0
+ 89 -- @@ C, -ffunction-sections, 1
90 -- @@ C, -fdata-sections, 1
- 91 -- Configuring done (26.7s)
+ 91 -- Configuring done (26.4s)
92 -- Generating done (0.5s)
93 -- Build files have been written to: C:/a/sdk-ng/sdk-ng/zephyrproject/zephyr/samples/hello_world/build
For full log, see https://gist.github.com/stephanosio/515697800f63484dc94568edff48c407.
To reproduce
On Windows:
- Download Zephyr SDK LLVM toolchain and set
ZEPHYR_TOOLCHAIN_VARIANT=zephyr-llvm
. - Check out Zephyr
collab-sdk-0.18-dev
branch. - Apply the following patch on Zephyr repository:
diff --git a/cmake/modules/extensions.cmake b/cmake/modules/extensions.cmake
index d5cd84256d2..a52e793d6e8 100644
--- a/cmake/modules/extensions.cmake
+++ b/cmake/modules/extensions.cmake
@@ -1174,6 +1174,7 @@ function(zephyr_check_compiler_flag lang option check)
endif()
check_compiler_flag(${lang} "${possibly_translated_option}" inner_check)
+ message(STATUS "@@@ check_compiler_flag: ${lang} ${possibly_translated_option} ${inner_check}")
set(${check} ${inner_check} PARENT_SCOPE)
- Prepare build directory for
samples/hello_world
:
cd samples/hello_world
mkdir build
cd build
- From
build
directory, run the following commands twice, observing the CMake run results:
rm -rf ${ZEPHYR_BASE}/.cache
cmake -GNinja -DBOARD=mps2/an385 ..
Notes
- Even in the same run, the result for
zephyr_check_compiler_flag(C "" result)
differ -- this seems to be completely random:
75 -- @@ C, , 1
76 -- @@ C, , 0
77 -- @@ C, , 0
78 -- @@ C, , 1
79 -- @@ C, , 0
80 -- @@ C, , 1
- CMake version does not seem to affect this -- tested with CMake 3.22.0 and 3.30.1.
Metadata
Metadata
Assignees
Labels
area: LLVMIssues related to LLVMIssues related to LLVMplatform: WindowsIssues related to Zephyr SDK on Windows hostsIssues related to Zephyr SDK on Windows hosts
Type
Projects
Status
No status