Skip to content

-mmcu= not passed while generating dependencies #106

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

Closed
matthijskooijman opened this issue Feb 2, 2016 · 9 comments
Closed

-mmcu= not passed while generating dependencies #106

matthijskooijman opened this issue Feb 2, 2016 · 9 comments
Labels
type: imperfection Perceived defect in any part of project

Comments

@matthijskooijman
Copy link
Collaborator

I haven't thoroughly verified this, but arduino/Arduino#4512 (comment) seems to indicate that, while running the preprocessor to collect dependencies, the -mmcu= option is not passed to gcc. You would say that this is not needed for preprocessing, but this also prevents defines like __AVR_ATmega328p__ from being present, which could be used to determine what libraries to use (as happens in this library).

@matthijskooijman
Copy link
Collaborator Author

@cmaglie, I think this is something to fix for the next release.

@cmaglie
Copy link
Member

cmaglie commented Feb 3, 2016

There is a smaller sketch that we can use to reproduce the problem? (sorry I didn't read the full thread yet...)

@matthijskooijman
Copy link
Collaborator Author

I had a closer look, and it seems the problem is that digistup does not define the recipe.preproc.macros value. arduino-builder has a default value for it, but that does not seem to include -mmcu (at least not when combined with the digistump platform.txt.

Looking through the history, the arduino-builder version never had the -mmcu option, and the Arduino version always had it, so I'm not sure what happened there.

I was going to suggest to remove the recipe.preproc.macros entry from Arduino's platform.txt and use the below sketch, but that doesn't seem to break it somehow (-mmcu is still passed). Not sure if that's a problem on my setup (possibly it's using a different platform.txt than I think it is), but no more time to test now. So, here's the sketch:

#if defined(__AVR__)
#include<Wire.h>
#endif

void setup() {
    Wire.begin();
}

void loop() {
}

@per1234
Copy link
Contributor

per1234 commented Feb 28, 2016

I think that test sketch doesn't cause the issue because __AVR__ is defined by -DARDUINO_ARCH_{build.arch} which is in the arduino-builder default recipe.preproc.macros. edit: I'm wrong on this, that's not what defines __AVR__

  • Comment recipe.preproc.macros in the Arduino AVR Boards platform.txt.
  • Tools > Board > Arduino/Genuino Uno
  • Compile:
#ifndef __AVR_ATmega328P__
#error
#endif
void setup() {}
void loop() {}

Arduino IDE 1.6.8 2016/02/24 06:33:

sketch_feb28a:2: error: #error 

 #error

  ^

exit status 1
#error 

Note that the arduino-builder default recipe.preproc.includes is also missing -mmcu={build.mcu} which is in Arduino AVR Boards 1.6.9 platform.txt but I haven't found a case where that causes a problem.

facchinm added a commit to facchinm/arduino-builder that referenced this issue Mar 4, 2016
facchinm added a commit to facchinm/arduino-builder that referenced this issue Mar 4, 2016
facchinm added a commit to facchinm/arduino-builder that referenced this issue Mar 22, 2016
@matthijskooijman
Copy link
Collaborator Author

I finally managed to find why I could not reproduce this issue before: I was changing the platform.txt in my git checkout, but there was still a "cached" version in build/linux/work/hardware. I had set up symlinks from my sketchbook into my git checkout to make sure any changes to source files would be picked up without having to update the build folder copy, but it turns out both versions of the platform.txt are removed, so uncommenting the recipe didn't work.

In any case, now that I can reliably reproduce the problem, I can confirm it no longer occurs with the latest git master of arduino-builder, so I'm closing this issue.

@calendulish
Copy link

calendulish commented Aug 30, 2016

I have the same problem today (arduino-builder 1.3.21), but only when I set the fqbn to arduino:avr:nano.

It's working fine with arduino:avr:uno.

@matthijskooijman
Copy link
Collaborator Author

Could you post the full verbose log of an attempt with both the nano and the uno? Are you using the IDE, or calling builder directly?

@calendulish
Copy link

Uno Log: http://termbin.com/jm64
Nano Log: http://termbin.com/p4sx

I'm using cmake to build, but the CMakeLists (Here: http://termbin.com/yaxd) just run the arduino-builder command.

@cmaglie
Copy link
Member

cmaglie commented Aug 30, 2016

You must use arduino:avr:nano:cpu=atmega328 as FQBN, that determines the value of -mcpu (that can be also atmega168 depending on the version of the nano).

An easy way to debug this kind of issues is to enable the "verbose compile" from the preferences of the IDE and see how arduino-builder is called when you compile.

@rsora rsora added the type: imperfection Perceived defect in any part of project label Sep 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

5 participants