Closed maxgerhardt closed 2 years ago
Addendum: This issue also applies to platform-ststm8 if someone tries to actually use the sdasstm8
assembler with assembly files.
Addendum 2: The current behavior is okay for all GCC toolchains, it's just wrong for the SDCC toolchain.
Thanks for the report! It is a very interesting issue, mainly related to the SCons. See https://github.com/SCons/scons/blob/master/SCons/Tool/asm.py#L44 As you can see, a default ASM tool declares ".s" and ".S" extensions on Windows (non-case-sensitive) for ASCOM. This is classic behavior for native compilers but not for GCC. The https://github.com/platformio/platformio-core/commit/f63b2f79e0af3c9342401df2b19468bce5bfa83e fixes this situation.
Nevertheless, we found a historical bug in ALL dev-platforms where we overwrite ASFLAGS
with the preprocessor's data instead of ASPPFLAGS
. We will fix it soon.
My platformio just upgraded to 6.0.1 and for some reason, the build for STM32 started to fail with this message:
Compiling .pio\build\board\src\cubemx\startup_stm32f407xx.o
arm-none-eabi-as: unrecognized option `-x'
Apparently, my platformio.ini file has always contained line
src_filter =
+<cubemx/startup_stm32f407xx.s>
and it has always worked fine on Windows.
When I changed the line to uppercase ".S", the build started to work fine.
Does the fixing of this issue mean that, from now on, all projects that referenced ".s" files and worked before need to be changed and files renamed to uppercase?
Yes, it was a historical bug in SCons on Windows, and we decided to fix it on our side. See http://draskovblog.blogspot.com/2008/12/gcc-differences-between-s-and-s.html
Ok, thanks for the link.
Am I right that .S files are passed to gcc
(with -x) option, and .s files are passed to as
(also with -x option) and the latter complains about -x option? Then there is a problem for those who have rightful .s files (to be passed directly to as
).
Also, the compilation database shows arm-none-eabi-as.exe
for both .s and .S, despite calling different programs in reality. Is this a bug?
Yes, .s and .S are assembly files and as.exe is used. The only flags are different. You can check this with pio run -t envdump
. Please search for ASCOM.
Hmm, let me humbly disagree.
I'm running pio run --verbose
for both files and here are commands being executed:
here is one for .s:
arm-none-eabi-as -x assembler-with-cpp -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -o .pio\build\board\src\cubemx\startup_stm32f407xx.o src\cubemx\startup_stm32f407xx.s
here is one for .S:
arm-none-eabi-gcc -x assembler-with-cpp -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -DGIT_HASH=\"4e3680\" -DGIT_TIMESTAMP=1652884351 -DGIT_DATE=\"2022-05-18\" -DF_CPU=168000000L -DPLATFORMIO=60001 -DSTM32F407xx -DSTM32F4 -DUSE_FULL_LL_DRIVER -DUSE_HAL_DRIVER -DSTM32F407xx -DFROZEN_NO_EXCEPTIONS -Isrc -Ilib\util -Ilib\frozen\include -Ilib\frozen -Ilib\RTT -Ilib\littlefs "-I.pio\libdeps\board\Embedded Template Library\include" "-I.pio\libdeps\board\Embedded Template Library" -Isrc\drivers -Isrc\cubemx\Inc -Isrc\cubemx\Drivers\STM32F4xx_HAL_Driver\Inc -Isrc\cubemx\Drivers\STM32F4xx_HAL_Driver\Inc\Legacy -Isrc\cubemx\Middlewares\Third_Party\FreeRTOS\Source\include -Isrc\cubemx\Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS -Isrc\cubemx\Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F -Isrc\cubemx\Middlewares\Third_Party\FatFs\src -Isrc\cubemx\Middlewares\ST\STM32_USB_Host_Library\Core\Inc -Isrc\cubemx\Middlewares\ST\STM32_USB_Host_Library\Class\MSC\Inc -Isrc\cubemx\Drivers\CMSIS\Device\ST\STM32F4xx\Include -Isrc\cubemx\Drivers\CMSIS\Include -c -o .pio\build\board\src\cubemx\startup_stm32f407xx.o src\cubemx\startup_stm32f407xx.S
The first one fails since as
does not know about -x
parameter (it's from gcc). It was also reported here: https://github.com/platformio/platform-ststm32/issues/332 but again, it was fixed by changing the extension to .S.
My point is, if people use .s extension erroneously, then they need to change the case and everything will work. However, if they use .s extension rightfully and really need to pass the file directly to as
, they they will face the arm-none-eabi-as: unrecognized option '-x'
problem. It might not be relevant and everyone uses .s files that really should be .S, I don't know.
@positron96 thanks, fixed in https://github.com/platformio/platform-ststm32
Could you try the latest version of ST STM32 dev-platform?
[env:development]
platform = https://github.com/platformio/platform-ststm32.git
Please navigate to the project folder and type pio pkg update
.
Does it work now?
Yes, the assembler doesn't complain about unknown arguments anymore. It is run with these arguments now:
arm-none-eabi-as -o .pio\build\board\src\cubemx\startup_stm32f407xx.o src\cubemx\startup_stm32f407xx.s
Thank you for making very useful software!
BTW, for some reason after I changed platform
line in platformio.ini
, pio pkg update
did not update anything even after I removed ststm32 folder. Removing the platform folder and rebuilding did the trick.
You can only update installed packages. If they have not been installed yet, you will not see any updates.
Thanks for the kind words! 🙏🚀
What kind of issue is this?
You can erase any parts of this template not applicable to your Issue.
Configuration
Operating system: Windows 10 x64
PlatformIO Version (
platformio --version
):PlatformIO Core, version 5.2.0a3
Description of problem
Per https://community.platformio.org/t/mcs51-assembler-programming/20410.
When attempting to write an assembler program for a MCS51 device on Windows by creating a
src/blink.s
file, the following error occurrsSuddenly it wants to use
sdcc
, the C compiler, for the.s
file, but in the special case of SDCC, it does not know how to handle assembly files.The platform code
https://github.com/platformio/platform-intel_mcs51/blob/c52ea3a706e540df65bdc6a0caf64f1eefeb8ac9/builder/main.py#L56-L60
sets the correct
AS="sdas8051"
directive, however the code inhttps://github.com/platformio/platformio-core/blob/73d4f10f4bf88dde79148583fbfcf6914810f083/platformio/builder/tools/platformio.py#L115-L117
overwrites the assembler on non-case-sensitive operating systems to SDCC, thus causing the issue.
Steps to Reproduce
blink.s
file with empty contentActual Results
Expected Results
It uses
sdas8051
correctly, as it actually does on Llinux.(note: the assembler flags are still wrong per linked issue, but that's a different issue)
If problems with PlatformIO Build System:
The content of
platformio.ini
:Source file to reproduce issue:
Additional info
On Linux systems this issue does not occur
But final linking fails due to multiple other issues which will be filed separately in the MCS51 platform (missing
-l
assembler flag, etc.).