Skip to content
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

adafruit:samd:adafruit_feather_m4 Cannot use --build-property build.extra_flags property with Arduino CLI #330

Closed
zfields opened this issue May 18, 2022 · 5 comments

Comments

@zfields
Copy link

zfields commented May 18, 2022

If I compile my sketch using the Arduino CLI without specifying --build-propery.extra_flags, then it compiles correctly:

$ arduino-cli compile --fqbn=adafruit:samd:adafruit_feather_m4 --warnings all ./examples/Example1_NotecardBasics/Example1_NotecardBasics.ino
Sketch uses 26592 bytes (5%) of program storage space. Maximum is 507904 bytes.

When I add --build-propery.extra_flags, then it goes sideways:

$ arduino-cli compile --build-property build.extra_flags=-Werror --fqbn=adafruit:samd:adafruit_feather_m4 --warnings all ./examples/Example1_NotecardBasics/Example1_NotecardBasics.ino
In file included from /root/.arduino15/packages/adafruit/hardware/samd/1.7.10/cores/arduino/Arduino.h:65,
                 from /tmp/arduino-sketch-2136EA99E4E95C26D41A391DD84A8876/sketch/Example1_NotecardBasics.ino.cpp:1:
/root/.arduino15/packages/adafruit/hardware/samd/1.7.10/cores/arduino/WVariant.h:257:36: error: 'TCC_INST_NUM' was not declared in this scope
  257 | extern const void* g_apTCInstances[TCC_INST_NUM+TC_INST_NUM] ;
      |                                    ^~~~~~~~~~~~
...
Error during build: exit status 1

(see compile.txt for more details)

This is a known issue with the Arduino CLI. Some vendors, like ST, provide workarounds like build_opt.h. Does Adafruit support such a workaround, or is there anyway to pass additional flags to the compiler?

@per1234
Copy link

per1234 commented May 19, 2022

Hi @zfields. You have misinterpreted arduino/arduino-cli#846. That is not about a defect in Arduino CLI.

You might argue that it is partly about a deficiency in the documentation hosted in the Arduino CLI repository. If the set of build properties reserved for arbitrary use by the user was clearly documented, as I proposed in arduino/arduino-cli#846, then users like yourself would be aware of which properties you can use in this manner, and might then refrain from using properties that can only be overridden safely after carefully studying the platform configuration files.

The build.extra_flags property you overrode in your command falls into the latter category. Your command is the cause of the error, not any issue with Arduino CLI.

As mentioned in arduino/arduino-cli#846, there is an existing convention to reserve a standardized set of flags for the user. That was done in this platform:

# These can be overridden in platform.local.txt
compiler.c.extra_flags=
compiler.c.elf.extra_flags=
#compiler.c.elf.extra_flags=-v
compiler.cpp.extra_flags=
compiler.S.extra_flags=
compiler.ar.extra_flags=
compiler.elf2hex.extra_flags=

@hathach
Copy link
Member

hathach commented May 19, 2022

@zfields please edit your first post to have compile log as attached txt for readability.

@zfields zfields changed the title adafruit:samd:adafruit_feather_m4 Cannot use --build-propery flag with Arduino CLI adafruit:samd:adafruit_feather_m4 Cannot use --build-propery.extra_flags property with Arduino CLI May 20, 2022
@zfields
Copy link
Author

zfields commented May 20, 2022

FWIW, --build-property.extra_flags is available to all the standard Arduino platforms. Apparently, whether it's poor documentation or not, the general public seems to be gravitating toward this flag.

@per1234 I'm not suggesting that it is a "defect", but rather a known point of confusion for Arduino CLI users. I'll add my thoughts regarding this issue to the linked Arduino CLI issue to keep from polluting this thread.

@zfields zfields changed the title adafruit:samd:adafruit_feather_m4 Cannot use --build-propery.extra_flags property with Arduino CLI adafruit:samd:adafruit_feather_m4 Cannot use --build-propery build.extra_flags property with Arduino CLI May 21, 2022
@zfields zfields changed the title adafruit:samd:adafruit_feather_m4 Cannot use --build-propery build.extra_flags property with Arduino CLI adafruit:samd:adafruit_feather_m4 Cannot use --build-property build.extra_flags property with Arduino CLI May 21, 2022
@zfields
Copy link
Author

zfields commented May 21, 2022

I have validated the build-property compiler.cpp.extra_flags (suggested by @per1234) does work with the adafruit:samd:adafruit_feather_m4.

As stated by @per1234 build.extra_flags is reserved for the platform vendor (e.g. Adafruit), while compiler.cpp.extra_flags is to be used by the end-user.

@zfields zfields closed this as completed May 21, 2022
@ladyada
Copy link
Member

ladyada commented May 21, 2022

thanks for the quick resolution @zfields and help @per1234 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants