-
Notifications
You must be signed in to change notification settings - Fork 34
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
Use proper g++ options, including proper C++ std=gnu++11 #146
Comments
Getting the compilation options right is a good plan. However, we certainly do not need to copy all options, since a lot of them are only needed to make things work on an Arduino, or make things more efficient, etc. Also, not all Arduino cores and boards use the same options, so we're going to find a common subset of the different cores and use that. And then maybe additional options can be configured in a per-core or per-board manner? Maybe it would even make sense to put all the options in the (default) config file even? I can imagine something like:
This would allow three levels of compiler flags: Global, per-package, per board. I've now put some defines in flags for illustrating, but those should probably be in I also wonder if this would need maybe two values: Furthermore, we might want to consider allowing specifying filetype-specific compilation flags too. Arduino cores have different recipes (compiler commandlines) for C, CPP and assembler files and the final link, which might be relevant here as well (though that does require separate object building #113, or letting arduino-cli build #147). Flags
These select the ARM-processor to use, so not relevant.
This tells to compile but not link, so this would be hardcoded if we go for #113.
This enables debugging symbols, probably good to include (in case someone wants to debug their unittst with gdb or similar).
This enables size optimizations. Enabling some kind of optimization for the unittests might be good (though not required), but maybe not size. Maybe -Og is a good compromise, IRC that enables all optimizations that do not complicate step-by-step debugging.
These are warning options, might be good to make them user-configurable (by default, the Java IDE disables warnings, so enabling them by default would be useful, but might also produce a lot of warnings all of a sudden).
This determines the language standard version. Switching to gnu++11 would indeed be good, since most Arduino cores now use this. However, the currently used
These make sure that functions and variables end up in different sections, so they can be optimized away with
This disables a specific warning, of which I wonder if it really should be disabled (it looks like a meaningful warning). It turns out this is only needed when using the Atmel CMSIS code (which we don't), and not even really then: arduino/ArduinoCore-samd#556
This removes the standard libc libraries, which is probably needed when running on SAMD to get complete control of the startup process or so. When running unittests, this option would probably just break the build, so I don't think we need this here. Then there's a bunch of defines, where we should pick a small selection, only So, I think we need: |
A bunch of what you're suggesting is already implemented, see: https://github.com/ianfixes/arduino_ci/blob/master/REFERENCE.md#defining-new-arduino-platforms This behavior is configured in https://github.com/ianfixes/arduino_ci/blob/master/lib/arduino_ci/cpp_library.rb I prefer not to use The main expected impact is the |
I was suggesting this for the non-libasan build, since I guess that custom options for that would be needed anyway (though I haven't looked at how this libasan stuff works in detail). Also, I wonder if libasan wouldn't benefit from -Og rather than -O1, maybe the same "do not jumble debug symbols with optimizations" applies to libasan as well. OTOH, -O1 might be a subset of -Og, dunno exactly.
But I don't think this should be changed/added? Running with |
I believe so, although I don't recall what documentation I read that would have supported that view. In any case, I think we're on the same page about the optimizer really not being necessary for space or performance reasons -- it would all be to drive various features of segfault analysis during unit testing.
My memory on this is fuzzy, as this library was built up by just running into problems (at every level) and then working around them. I might be confusing stdlib problems with arduino "standard library" problems -- in other words, mocking the built-in stuff. AVR Math was definitely on that list. Also, if we compile using the Arduino CLI, I'm not sure what options we have to mock all the built-in classes. I guess we'll find out 😄 |
Issue Summary
via https://github.com/ianfixes/arduino_ci/issues/140#issuecomment-656966055
My initial reverse-engineer of arduino compilation used the wrong compiler options:
-std=c++0x
.Here is a dump of actual arduino compilation commands:
Of these, the following look like they should be swapped in immediately:
-std=gnu++11
-Wno-expansion-to-defined
-nostdlib
This will likely change the nature of the workaround for things like
String.h
andStream.h
, possibly allowing (or requiring, depending on how you look at it) a ground-up rewrite of those.The text was updated successfully, but these errors were encountered: