lancaster-university / microbit-v2-samples

CODAL build tools and sample programs for the micro:bit v2.x
MIT License
64 stars 83 forks source link

Compilation issues with CMake < 3.6 and 3.22 #38

Closed carlosperate closed 1 year ago

carlosperate commented 2 years ago

Based on this technically the project should be 3.3+ compatible: https://github.com/lancaster-university/microbit-v2-samples/blob/7f6be8079edf37a52d633add57ad01a3ccbced76/CMakeLists.txt#L22

However, on Windows any version below 3.6 fails to build, but it works in macOS and Ubuntu. In this example using 3.5.2:

Also, the latest release, v3.22.0-rc1, fails on Windows as well:

carlosperate commented 2 years ago

Latest CMake v3.22.1 still has the same problem on Windows (fine on macOS and Linux): https://github.com/carlosperate/microbit-v2-samples/runs/4820719389?check_suite_focus=true

[213/215] Linking CXX executable MICROBIT
FAILED: MICROBIT libMICROBIT.dll.a 
cmd.exe /C "cd . && C:\Users\runneradmin\gcc-arm-none-eabi-0.0.0-win32\gcc-arm-none-eabi-10.3-2021.10\bin\arm-none-eabi-g++.exe -std=c++11 -fwrapv -fno-rtti -fno-threadsafe-statics -fno-exceptions -fno-unwind-tables -Wl,--gc-sections -Wl,--sort-common -Wl,--sort-section=alignment -Wno-array-bounds -Wl,--no-wchar-size-warning -Wl,--gc-sections -Wl,--wrap,atexit -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -Wl,--start-group -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys -Wl,--end-group -T"D:/a/microbit-v2-samples/microbit-v2-samples/libraries/codal-microbit-v2/ld/nrf52833.ld" -Wl,-Map,MICROBIT.map -Wl,--start-group CMakeFiles/MICROBIT.dir/source/main.cpp.obj CMakeFiles/MICROBIT.dir/source/samples/AccelerometerTest.cpp.obj CMakeFiles/MICROBIT.dir/source/samples/AudioTest.cpp.obj CMakeFiles/MICROBIT.dir/source/samples/BLETest.cpp.obj CMakeFiles/MICROBIT.dir/source/samples/BlinkyTest.cpp.obj CMakeFiles/MICROBIT.dir/source/samples/ButtonTest.cpp.obj CMakeFiles/MICROBIT.dir/source/samples/CapTouchTest.cpp.obj CMakeFiles/MICROBIT.dir/source/samples/DeepSleepTest.cpp.obj CMakeFiles/MICROBIT.dir/source/samples/DisplayTest.cpp.obj CMakeFiles/MICROBIT.dir/source/samples/GPIOTest.cpp.obj CMakeFiles/MICROBIT.dir/source/samples/LightLevelTestRaw.cpp.obj CMakeFiles/MICROBIT.dir/source/samples/MicrophoneTest.cpp.obj CMakeFiles/MICROBIT.dir/source/samples/NoiseProfiler.cpp.obj CMakeFiles/MICROBIT.dir/source/samples/OOB.cpp.obj CMakeFiles/MICROBIT.dir/source/samples/PowerManagementTest.cpp.obj CMakeFiles/MICROBIT.dir/source/samples/RadioTestRx.cpp.obj CMakeFiles/MICROBIT.dir/source/samples/SerialNumber.cpp.obj CMakeFiles/MICROBIT.dir/source/samples/SerialStreamer.cpp.obj CMakeFiles/MICROBIT.dir/source/samples/SpeakerTest.cpp.obj CMakeFiles/MICROBIT.dir/source/samples/TemperatureTest.cpp.obj CMakeFiles/MICROBIT.dir/source/samples/USBFlashTest.cpp.obj  libcodal-microbit-v2.a  libcodal-core.a  libcodal-nrf52.a  libcodal-microbit-nrf5sdk.a  libcodal-nrf52.a  libcodal-core.a  ../libraries/codal-microbit-v2/lib/bootloader.o  ../libraries/codal-microbit-v2/lib/mbr.o  ../libraries/codal-microbit-v2/lib/settings.o  ../libraries/codal-microbit-v2/lib/softdevice.o  ../libraries/codal-microbit-v2/lib/uicr.o  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -lnosys -lstdc++ -lsupc++ -lm -lc -lgcc -lstdc++ -lsupc++ -lm -lc -lgcc -Wl,--end-group  --specs=nano.specs -o MICROBIT && cd ."
c:/users/runneradmin/gcc-arm-none-eabi-0.0.0-win32/gcc-arm-none-eabi-10.3-2021.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: cannot find -lkernel32
c:/users/runneradmin/gcc-arm-none-eabi-0.0.0-win32/gcc-arm-none-eabi-10.3-2021.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: cannot find -luser32
c:/users/runneradmin/gcc-arm-none-eabi-0.0.0-win32/gcc-arm-none-eabi-10.3-2021.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: cannot find -lgdi32
c:/users/runneradmin/gcc-arm-none-eabi-0.0.0-win32/gcc-arm-none-eabi-10.3-2021.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: cannot find -lwinspool
c:/users/runneradmin/gcc-arm-none-eabi-0.0.0-win32/gcc-arm-none-eabi-10.3-2021.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: cannot find -lshell32
c:/users/runneradmin/gcc-arm-none-eabi-0.0.0-win32/gcc-arm-none-eabi-10.3-2021.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: cannot find -lole32
c:/users/runneradmin/gcc-arm-none-eabi-0.0.0-win32/gcc-arm-none-eabi-10.3-2021.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: cannot find -loleaut32
c:/users/runneradmin/gcc-arm-none-eabi-0.0.0-win32/gcc-arm-none-eabi-10.3-2021.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: cannot find -luuid
c:/users/runneradmin/gcc-arm-none-eabi-0.0.0-win32/gcc-arm-none-eabi-10.3-2021.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: cannot find -lcomdlg32
c:/users/runneradmin/gcc-arm-none-eabi-0.0.0-win32/gcc-arm-none-eabi-10.3-2021.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: cannot find -ladvapi32
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
Error: Process completed with exit code 1.
carlosperate commented 2 years ago

I just remembered that it's possible Windows is the only platform using ninja, so the problem might lay there? Just a random guess.

The ninja version used in the latest CI run was 1.10.2.3, which is the latest release at the time of writting (v1.10.2).

microbit-carlos commented 1 year ago

@JohnVidler 3.3 was released in 2015 and 3.6.0 was release in 2016, more than 6 years ago https://github.com/Kitware/CMake/commit/e31084e65745f9dd422c6aff0a2ed4ada6918805.

There is not much point trying to resolve the Windows issue with 3.3 to 3.5, and because of that issue we haven't even been testing those versions in the other OS in CI either, so let's move the min version to 3.6, which we are currently testing in CI.

Our main constrain is making sure the project stays compatible with v3.8, as that's what's currently inside the MakeCode pxt yotta docker images.

JohnVidler commented 1 year ago

Changed in upstream codal as well, to align with 3.6 here.