Skip to content

Incorrect compiler selected by Arduino-cli #1876

Closed
@zaphodbe

Description

@zaphodbe

Describe the problem

Arduino-cli version 0.27.1 and previous versions. Have both Arduino core and a custom SAMD based core installed. Arduino core has arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-gcc and the SAMD based core has things/tools/arm-none-eabi-gcc/9-2019q4/bin/arm-none-eabi-gcc. On each successive run of Arduino-cli it will randomly select which one of those compilers to use. Similar thing happens for bossac.

I added some debug output to the Arduino-cli code in setup_build_properties.go around line 99 ... here

	for _, tool := range ctx.AllTools {
                println("ctx.AllTools: tool:",tool.Tool.Name,"  ver:",tool.Version.String());
		buildProperties.SetPath("runtime.tools."+tool.Tool.Name+".path", tool.InstallDir)
                buildProperties.SetPath("runtime.tools."+tool.Tool.Name+".path2", tool.InstallDir)
		buildProperties.SetPath("runtime.tools."+tool.Tool.Name+"-"+tool.Version.String()+".path", tool.InstallDir)
	}
	for _, tool := range ctx.RequiredTools {
                println("ctx.RequiredTools: tool:",tool.Tool.Name,"  ver:",tool.Version.String());
		buildProperties.SetPath("runtime.tools."+tool.Tool.Name+".path", tool.InstallDir)
                buildProperties.SetPath("runtime.tools."+tool.Tool.Name+".path3", tool.InstallDir)
		buildProperties.SetPath("runtime.tools."+tool.Tool.Name+"-"+tool.Version.String()+".path", tool.InstallDir)
	}

Basically what appears to be happening is that the AllTools and RequiredTools arrays are created non-deterministically and so depending on the order of entries in those arrays depends on which version of the tool is ultimately selected. With the one from RequiredTools finally taking dominance.

This is the output of Arduino-cli with the println's shown and the output grep'd for the .path variables from 2 consecutive runs...

% arduino-cli -v compile --clean ... --show-properties | grep runtime.tools.arm-none-eabi-gcc
ctx.AllTools: tool: avr-gcc   ver: 7.3.0-atmel3.6.1-arduino7
ctx.AllTools: tool: avrdude   ver: 6.3.0-arduino17
ctx.AllTools: tool: CMSIS-Atmel   ver: 1.2.0
ctx.AllTools: tool: openocd   ver: 0.10.0-arduino7
ctx.AllTools: tool: arduinoOTA   ver: 1.3.0
ctx.AllTools: tool: arduinoOTA   ver: 1.2.1
ctx.AllTools: tool: arm-none-eabi-gcc   ver: 4.8.3-2014q1
ctx.AllTools: tool: bossac   ver: 1.8.0-48-gb176eee
ctx.AllTools: tool: bossac   ver: 1.7.0-arduino3
ctx.AllTools: tool: ctags   ver: 5.8-arduino11
ctx.AllTools: tool: mdns-discovery   ver: 1.0.5
ctx.AllTools: tool: mdns-discovery   ver: 1.0.6
ctx.AllTools: tool: serial-discovery   ver: 1.3.2
ctx.AllTools: tool: serial-monitor   ver: 0.9.1
ctx.AllTools: tool: STM32Tools   ver: 2.1.1
ctx.AllTools: tool: arm-none-eabi-gcc   ver: 9-2019q4
ctx.AllTools: tool: bossac   ver: 1.9.1-thing
ctx.AllTools: tool: CMSIS   ver: 5.4.0
ctx.RequiredTools: tool: openocd   ver: 0.10.0-arduino7
ctx.RequiredTools: tool: arduinoOTA   ver: 1.3.0
ctx.RequiredTools: tool: mdns-discovery   ver: 1.0.6
ctx.RequiredTools: tool: serial-discovery   ver: 1.3.2
ctx.RequiredTools: tool: serial-monitor   ver: 0.9.1
ctx.RequiredTools: tool: arm-none-eabi-gcc   ver: 4.8.3-2014q1
ctx.RequiredTools: tool: CMSIS   ver: 5.4.0
ctx.RequiredTools: tool: CMSIS-Atmel   ver: 1.2.0
ctx.RequiredTools: tool: ctags   ver: 5.8-arduino11
ctx.RequiredTools: tool: bossac   ver: 1.8.0-48-gb176eee
ctx.RequiredTools: tool: STM32Tools   ver: 2.1.1
ctx.RequiredTools: tool: avr-gcc   ver: 7.3.0-atmel3.6.1-arduino7
ctx.RequiredTools: tool: avrdude   ver: 6.3.0-arduino17
compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/
runtime.tools.arm-none-eabi-gcc-4.8.3-2014q1.path=~/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1
runtime.tools.arm-none-eabi-gcc-9-2019q4.path=~/Library/Arduino15/packages/things/tools/arm-none-eabi-gcc/9-2019q4
runtime.tools.arm-none-eabi-gcc.path=~/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1
runtime.tools.arm-none-eabi-gcc.path2=~/Library/Arduino15/packages/things/tools/arm-none-eabi-gcc/9-2019q4
runtime.tools.arm-none-eabi-gcc.path3=~/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1
% arduino-cli -v compile --clean ... --show-properties | grep runtime.tools.arm-none-eabi-gcc
ctx.AllTools: tool: arm-none-eabi-gcc   ver: 9-2019q4
ctx.AllTools: tool: bossac   ver: 1.9.1-thing
ctx.AllTools: tool: CMSIS   ver: 5.4.0
ctx.AllTools: tool: STM32Tools   ver: 2.1.1
ctx.AllTools: tool: arduinoOTA   ver: 1.2.1
ctx.AllTools: tool: arduinoOTA   ver: 1.3.0
ctx.AllTools: tool: arm-none-eabi-gcc   ver: 4.8.3-2014q1
ctx.AllTools: tool: avr-gcc   ver: 7.3.0-atmel3.6.1-arduino7
ctx.AllTools: tool: bossac   ver: 1.8.0-48-gb176eee
ctx.AllTools: tool: bossac   ver: 1.7.0-arduino3
ctx.AllTools: tool: CMSIS-Atmel   ver: 1.2.0
ctx.AllTools: tool: avrdude   ver: 6.3.0-arduino17
ctx.AllTools: tool: openocd   ver: 0.10.0-arduino7
ctx.AllTools: tool: ctags   ver: 5.8-arduino11
ctx.AllTools: tool: mdns-discovery   ver: 1.0.6
ctx.AllTools: tool: mdns-discovery   ver: 1.0.5
ctx.AllTools: tool: serial-discovery   ver: 1.3.2
ctx.AllTools: tool: serial-monitor   ver: 0.9.1
ctx.RequiredTools: tool: bossac   ver: 1.9.1-thing
ctx.RequiredTools: tool: avrdude   ver: 6.3.0-arduino17
ctx.RequiredTools: tool: mdns-discovery   ver: 1.0.6
ctx.RequiredTools: tool: serial-discovery   ver: 1.3.2
ctx.RequiredTools: tool: serial-monitor   ver: 0.9.1
ctx.RequiredTools: tool: ctags   ver: 5.8-arduino11
ctx.RequiredTools: tool: arm-none-eabi-gcc   ver: 9-2019q4
ctx.RequiredTools: tool: avr-gcc   ver: 7.3.0-atmel3.6.1-arduino7
ctx.RequiredTools: tool: CMSIS-Atmel   ver: 1.2.0
ctx.RequiredTools: tool: openocd   ver: 0.10.0-arduino7
ctx.RequiredTools: tool: arduinoOTA   ver: 1.3.0
ctx.RequiredTools: tool: CMSIS   ver: 5.4.0
ctx.RequiredTools: tool: STM32Tools   ver: 2.1.1
compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/
runtime.tools.arm-none-eabi-gcc-4.8.3-2014q1.path=~/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1
runtime.tools.arm-none-eabi-gcc-9-2019q4.path=~/Library/Arduino15/packages/things/tools/arm-none-eabi-gcc/9-2019q4
runtime.tools.arm-none-eabi-gcc.path=~/Library/Arduino15/packages/things/tools/arm-none-eabi-gcc/9-2019q4
runtime.tools.arm-none-eabi-gcc.path2=~/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1
runtime.tools.arm-none-eabi-gcc.path3=~/Library/Arduino15/packages/things/tools/arm-none-eabi-gcc/9-2019q4

To reproduce

arduino-cli -v compile --fqbn things:samd: file.ino --show-properties

Expected behavior

Correct compiler and bossac should be selected.

Arduino CLI version

0.27.1

Operating system

macOS

Operating system version

12.5

Additional context

No response

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the nightly build
  • My report contains all necessary details

Metadata

Metadata

Assignees

Labels

criticality: highOf high impacttopic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions