gcc vs XC8 for AVR

Go To Last Post
54 posts / 0 new

Pages

Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As you know, XC8 also supports AVR devices. I wonder how is its PRO version compared to gcc?

I didn't have good experience with MPLAB X IDE and XC8 free 2.20 on my PIC project because they both had some annoying bugs.

Slow and Steady!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I had the same question, following is what I was told in the other thread.

 

gchapman wrote:

MPLAB XC8 v2 for AVR for aprroximately 2m30s :

Coffee Break | S2E5 | All Compilers Are Not Created Equal - YouTube (Microchip Technology)

 

“Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?” - Brian W. Kernighan

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for your reply. However, YouTube isn't accessible in my location. sad

Slow and Steady!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well let's see - how does one compare a stable 20 year old compiler that has maybe seen 100,000+ bug fixes during it's existence compared to something of unknown provenance that maybe just feel out of the tree ? I don't know. Tricky choice.

 

(the one driving force behind all this is that, unless something magic happens, the AVR variant will be dropped from GCC in V10 so it may be a "dying compiler". Having said that people are still using the 11 year old WinAVR (avr-gcc v4.5.3) so I guess nothing says "you must use the very latest version". The exception to that being when you want to use a new model of AVR that is not supported by some old version of compiler.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
(the one driving force behind all this is that, unless something magic happens, the AVR variant will be dropped from GCC in V10 so it may be a "dying compiler". Having said that people are still using the 11 year old WinAVR (avr-gcc v4.5.3) so I guess nothing says "you must use the very latest version". The exception to that being when you want to use a new model of AVR that is not supported by some old version of compiler.

 

In laymans terms does this mean "You better start embracing MPLAB sooner than later"?

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But you could try searching the forum for "XC8" to find that thread - and other recent discussions ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I searched but didn't find what I want.

(Maybe such thread exists and I'm too lazy to find it! cheeky)

Slow and Steady!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Look at this thread - where the addition of XC8 to Studio was anounced: https://www.avrfreaks.net/forum/microchip-studio-702542

 

In particular: https://www.avrfreaks.net/commen...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jgmdesign wrote:
"You better start embracing MPLAB sooner than later"?
Yup...

Richard Blain wrote:

you'll regret it. Maybe not today. Maybe not tomorrow, but soon and for the rest of your life. 

Last Edited: Wed. Dec 2, 2020 - 02:37 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Question from Jared :
"Regards to the XC, they're based on GCC, so where is the incentive to switch from AVR Arm GCC to the XC Pro compiler if support and/or specific certifications aren't a hard requirement?"

Summary of the answers :
1. FSF test suite is based on DejaGNU; Microchip test suite is very more stringent and ran on Microchip MCU.  So, reduced quantity of defects.
2. MPLAB XC8 v2 for AVR - const implies the __flash attribute
3. Tests - 22+ years of test suite development, nearly one million tests, complete test suite ran for every release
 

re YouTube, a VPN may enable access though am uncertain VPN are VPN aren't available to you.

You're missing the banter and jokeswink

 


DejaGnu - GNU Test Framework

 

22+ years - Microchip Technology acquired HI-TECH Software and their toolchains.

HI-TECH Software | Microchip Technology - Wikipedia

 

Best VPN service in 2020: Safe and fast don't come for free | ZDNet

 

edit : strikethru and

https://www.cyberghostvpn.com/privacyhub/countries-banning-vpn/#iran

 

"Dare to be naïve." - Buckminster Fuller

Last Edited: Wed. Dec 2, 2020 - 04:43 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

pajuhesh80 wrote:
I didn't have good experience with MPLAB X IDE and XC8 free 2.20 on my PIC project because they both had some annoying bugs.
Can do an end run around MPLAB X; MDB may be the only part of MPLAB X that's necessary.

MPLAB XC8 v2 for PIC is relatively recent (based on LLVM); the presence of defects isn't surprising.

 

Working Outside of MPLAB® X IDE - Developer Help

MDB: The Microchip Debugger - Developer Help

UltraEdit / UltraStudio as an alternative to MPLAB-X? | Microchip

UEStudio is a powerful IDE combined with UltraEdit text editor

 

AVR and MDB :
Trouble Flashing ATtiny3217 Xplained Pro board with MDB | AVR Freaks

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

pajuhesh80 wrote:

I searched but didn't find what I want.

(Maybe such thread exists and I'm too lazy to find it! cheeky)

 

Andy must have the holiday spirit in him...(scotch, brandy or wine we do not know)

awneil wrote:

Look at this thread - where the addition of XC8 to Studio was anounced: https://www.avrfreaks.net/forum/microchip-studio-702542

 

In particular: https://www.avrfreaks.net/commen...

 

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jgmdesign wrote:
scotch, brandy or wine

Yes, please!

 

smiley yes

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gchapman wrote:

re YouTube, a VPN may enable access though am uncertain VPN are VPN aren't available to you.

You're missing the banter and jokeswink

I can use a VPN to access YouTube but I didn't till now. However, older students at university say that YouTube is required to continue learning; Specially for a computer engineering student.

 

jgmdesign wrote:

Andy must have the holiday spirit in him...(scotch, brandy or wine we do not know)

I can't understand this sentence. Is it something related to Christmas?

 

Thanks for all you replies. But I prefer to compare using numbers. Compile time, Program size, Program speed, Different optimization levels etc.

If anyone has both gcc and XC8 PRO, would you please do some simple tests and send results here?

Slow and Steady!

Last Edited: Thu. Dec 3, 2020 - 07:14 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did you read the particular post I linked to?

 

If that's a feature you need, that probably makes all the other numbers irrelevant ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 3

pajuhesh80 wrote:

...I prefer to compare using numbers. Compile time, Program size, Program speed, Different optimization levels etc. If anyone has both gcc and XC8 PRO, would you please do some simple tests and send results here?

 

But does it really matter?

 

If your final binary is 2% smaller, and that matters, then you are using the wrong chip.

If your code runs 2% faster, and that matters, then you have chosen the wrong chip.

 

Pick a tool and learn to use it; you will be more productive.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

The only time this is an issue is when you have the budget for a 4K micro and you can't get the compiler to build your application at anything less than 4150 bytes and you need to squeeze it back to 4096. Maybe then a more efficient programmer might just push it over the brink. But otherwise if your program builds to 3700 or 3900 bytes what does it really matter?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Brian Fairchild wrote:

But does it really matter?

If your final binary is 2% smaller, and that matters, then you are using the wrong chip.

Usually doesn't matter. But as clawson said in #17, sometimes it matters.

I was writing a USB bootloader for a PIC device. Bootloader size got a little more than intended size limit and I was forced to exclude some features of bootloader. Compiler was XC8 free so I couldn't use -Os.

Actually it doesn't matter for me now because currently not working on any project. Even if I want to work on an AVR project, I'll use GCC without a doubt as it's currently much more reliable than XC. 

I'm just curious about those numbers. smiley

Slow and Steady!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well the only way to know is to compile your program with both. Some things might optimize better with one compiler than the other simply depending on your programming style.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Yes,  code size and efficiency is important for a 2kB AVR.   And very important for a Bootloader.

 

Many AVRs come in "families" e.g. ATmega48, 88, 168, 328 or ATmega164, 324, 644, 1284.

 

So for the Application area you can trade up or down within the family.

 

Personally,   I would feel much happier with regular avr-gcc than risk my life with XC8.

The videos hint at stricter test-suites but do not provide any examples that show avr-gcc failure.

They just emphasise that the "free" XC8 has been crippled.

I would have more confidence in an XC8_PRO that was shown to be "better" than avr-gcc.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

pajuhesh80 wrote:
However, older students at university say that YouTube is required to continue learning; Specially for a computer engineering student.
Part of a USA COVID-19 response is a content creator using YouTube who is unaware of access restrictions on YouTube.

Once a content creator becomes aware of that issue, they (professor, lecturer) might use web methods to copy the video, peer-to-peer to share the video, or further.

pajuhesh80 wrote:
If anyone has both gcc and XC8 PRO, would you please do some simple tests and send results here?
Is benchmarking simple? (rhetorical)

Such may be the genesis of a new threadwink

 


GitHub reinstates youtube-dl library after EFF intervention | ZDNet

by November 16, 2020 -- 17:05 GMT (09:05 PST) | Topic: Open Source

GitHub also establishes a $1 million "developer defense fund" to help open source developers fight against abusive DMCA Section 1201 takedown claims.

...

Electronic Frontier Foundation | Defending your rights in the digital world

IPFS is the Distributed Web - why

 

Embench™: A Modern Embedded Benchmark Suite (AVR is in-work in Embench)

FAQ | CPU Benchmark – MCU Benchmark – CoreMark – EEMBC Embedded Microprocessor Benchmark Consortium (AVR exists in the scores)

 


Quote by Thomas Jefferson: “He who receives an idea from me, receives instr...”

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
Personally,   I would feel much happier with regular avr-gcc than risk my life with XC8.
Conversely, some aren't risk-adverse and others apply risk analysis along with risk reduction, risk mitigation, etc.

david.prentice wrote:
They just emphasise that the "free" XC8 has been crippled.
May you consider 'limited'?

 


Microchip Studio 7.0.2542 | AVR Freaks

 

GitHub - cv007/XC3216: GCC compiler restrictions removal

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Seriously.    Microchip could publish a test-suite that reveals all of the avr-gcc faults.   Alongside XC8_PRO and XC8_FREE successful results.

 

Then there would be some evidence.

 

Yes,  of course "limited" sounds better than "crippled".

 

A test-suite for conformance is preferable to a BenchMark for speed/size.

 

It is relatively easy to create a BenchMark that favours one Toolchain.    Old people can remember the PC C Compiler Wars.     That ended up with "better" tools being produced by the "cheaper" vendor who sold the most software.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

pajuhesh80 wrote:
If anyone has both gcc and XC8 PRO, would you please do some simple tests and send results here?

Isn't there an "evaluation" version available - for you to try it yourself with your own code ?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

XC8 is licensed under gpl, so just change a few bytes in a few files and you have whatever version you want, and can then compare to anything else. The source is available as required so its easy to see what you need to do, and there is no need to go through the whole compile process again.

 

I'm not sold on the 'millions of tests' as being something great, as the only two compiler problems I ever had were XC8-pic and XC8-avr. If the tests were working I wouldn't have seen these problems, and whatever testing was in place did me little good. The pic version was restoring a prologue saved register back to the wrong address in the epilogue when a specific option was enabled. The unexplainable things that were happening from time to time was indicating I just didn't know how to use one of the simplest mcu's around. I was about to give up using pic until I simply took the asm listing and went through it instruction by instruction, eventually discovering the problem with the compiler generated isr epilogue. Submitted a case, and was eventually fixed. The XC8-avr in an early version would sometimes allocate the same address to 2 var's, which also took a while to figure out, and in that case I simply just switched to gcc 7.3.0 and have used since without any problems.

 

I like the Arm model- get the gcc compiler from Arm, get your mcu's from those that make the mcu's. You end up with a compiler that is used by everyone, and the mcu manufacturer can then work on the things it should be working on.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

curtvm wrote:
XC8 is licensed under gpl, ...
mostly (MPLAB XC8 v2 for AVR)

curtvm wrote:
If the tests were working I wouldn't have seen these problems, and whatever testing was in place did me little good.
Testing covers some of the problem-solution space; operators are essential in covering some of the remainder ... the more operators the better ... the more operator-years the better.

Static analysis can aid in covering that which isn't tested; unsound static analysis is prevalent though still useful.

curtvm wrote:
Submitted a case, and was eventually fixed.
Likewise though twenty years ago (GCC, GMGPL); the front-end didn't catch my mangling of a computer language ... discovered during unit testing ... excellent customer service in a near immediate work-around.

 


MPLAB Ecosystem Downloads Archive | Microchip Technology

[3/4 page]

Source Archives

 

MPLAB® XC8 C Compiler Version 2.30 Release Notes for AVR® MCU

...

 

1.5. Component Licenses and Versions

[GPL]

[next to last sentence]

Support code provided for the header files, linker scripts, and runtime libraries are proprietary code and not covered under the GPL.

...

 

GCC | Coverity Scan - Static Analysis

...

Lines of code analyzed    3,011,599

...

 

GNAT Reference Manual: Pragma License (GMGPL - GNAT Modified GPL)

GNAT Pro Comparison - AdaCore

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

>mostly (MPLAB XC8 v2 for AVR)

 

Yeah, one needs to use XC8-avr/XC8-pic to distinguish the two sometimes.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do we have some sort of a "compatibility library" between Studio and XC8? Or, is it even possible? At the very least, if we are going to run comparisons between the two environments, seems like something will be different and its probably useful to know what. #10 mentioned constant syntax. What else is there?

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ka7ehk wrote:
What else is there?
MPLAB XC8 C Compiler User’s Guide for AVR MCU

  • PROGMEM and its alternatives; const implies __memx
  • significant differences between sets of options
  • Common Code Interface (CCI) improves portability between MPLAB XC
  • recommendations to use limits.h, stdint.h, and float.h
  • va_end
  • C90 or C99 though C11's anonymous is available (MPLAB XC8 v2 for PIC is up to C99)

A context for CCI would be an XMEGA B configuration item and its follow-on in PIC24F GU/GL with both items being maintained with configuration control.

 


C Language | Using the GNU Compiler Collection (GCC): Standards

New PIC24F MCUs Feature Low-power Animated Display Driver for Battery-powered Devices | Microchip Technology

 

edit :

Anonymous Structures And Unions | MPLAB® XC8 C Compiler User’s Guide for PIC® MCU

 

edit2 : CCI isn't Common C Interface

 

"Dare to be naïve." - Buckminster Fuller

Last Edited: Wed. Jan 20, 2021 - 12:33 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

pajuhesh80 wrote:
Specially for a computer engineering student.
though not computer architecture

Tools and Tips | The Embedded Muse 411 by Jack Ganssle

Phil Koopman, noted Carnegie Mellon professor, has made his embedded software course material available online. The course covers software quality, safety, and security. For those who don't do YouTube, videos and handouts are here as well.

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

A brief comparison for real application (ATTINY404), Microchip Studio

 

GCC  optimize for size (-Os)

Program Memory Usage     :    3822 bytes   93,3 % Full
  Data Memory Usage         :    46 bytes   18,0 % Full

XC8 (V2.31 PRO 30-days trial version)  optimize for size (-Os)

Program Memory Usage     :    4003 bytes   97,7 % Full
  Data Memory Usage         :    46 bytes   18,0 % Full

I was expecting rather opposite results.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are both applications functional?

Reason : complete, precise, correct; correctness before precision

Thanks!

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

>I was expecting rather opposite results.

 

XC8-avr does startup code in a different way- they init data/bss in chunks/sections for some reason, and probably accounts for some of the difference (was most/all of the difference in what I briefly tested). I presume there is some grand scheme in mind where they want to take advantage of being able to have data/bss sections in non-contiguous locations (hence the need to store each 'chunk' info in flash and process them one by one). 

 

 

>Do we have some sort of a "compatibility library" between Studio and XC8?

 

There are probably only a few differences when using cci syntax (cci.h), and only one of them has no gcc equivalent (__at). You can mostly 'define' your way back to gcc if cci was in use.

 

They now have an __interrupt attribute that still differs from every other __interrupt they already have (xc16/xc32/xc8-pic) so not sure why the need to make the names all the same... but all still are different. They could have simply made __interrupt a define like ISR and would have been better off. The __interrupt define in cci.h use a non-gcc 'handler' attribute that takes in a vector number instead of a name, so you end up needing to use SOME_ISR_vect_num instead of SOME_ISR_vect, in addition you now need to create a function name of your choosing which will transform into __vector_N (you don't even get to see the name), and specify a return type (void). They still document the use of ISR in the user manual, so could have saved everyone the trouble by just defining __interrupt into something already in use.

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

this my cut from text's and project's, some tests, avr-gcc vs xc8-avr

 

///////////////////////////////////////////
optimisation / size *.hex-file
///////////////////////////////////////////
gcc1 - avr-gcc-3.6.2 custom Makefile
gcc2 - avr-gcc-3.6.2 build on mplabx
xc8  - xc8-2.10      build on mplabx
///////////////////////////////////////////
opt  |  gcc1   |  gcc2   | xc8
///////////////////////////////////////////
s    |  5,496  |  5,696  | 6,357
g    |  5,508  |         |
fast |  5,504  |         |
0    |  5,966  |  8,433  | 9,188
1    |  5,508  |  5,721  | 6,386
2    |  5,500  |  5,700  | 6,361
3    |  5,504  |  5,717  | 6,365
///////////////////////////////////////////

and

///////////////////////////////////////////
avr-gcc toolchain
- avr_gcc      4.9.2
- avr_binutils 2.25
- avr_gdb      7.8.1
- avr_libc     1.8.1
////////////////////////////////////////////////
gcc  - avr-gcc  build on mplabx
xc8  - xc8-2.20 build on mplabx
////////////////////////////////////////////////
opt  |  gcc    |  xc8    |
////////////////////////////////////////////////
0    |  8,024  |  8,971  |
1    |  5,402  |  6,169  |
2    |  5,381  |  6,144  |
3    |  5,385  |  6,148  |
s    |  5,377  |  6,140  |
////////////////////////////////////////////////

and

////////////////////////////////////////////////
optimisation -S2
////////////////////////////////////////////////
gcc  - avr-gcc  build on mplabx
xc8  - xc8-2.20 build on mplabx
////////////////////////////////////////////////
    avr-gcc   | xc8 2.20 |
////////////////////////////////////////////////
3.6.2 - 5,496 |   6,144  |
7.3.0 - 5,361 |          |
9.2.0 - 5,336 |          |
////////////////////////////////////////////////

 

if I'm wrong, correct this and do not criticize :o)

Last Edited: Fri. Jan 15, 2021 - 10:33 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avr-gcc is the clear optimization winner here. Also avr-gcc has some flags like flto and others which help to sometimes squeeze size even smaller.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But is size the best measure of how good a compiler is? I'd argue that speed matters more.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In tinyavr size matters, xmega not so much. Bloated code does not mean it's faster. an assembly comparison would be in order to investigate... in the compile flag for minimal size gcc beat xc8 in minimal size... Likely when compiling for speed gcc may beat it as well... gcc has been around for decades and is continually developed by an opensource community. If I find a bug I can submit a fix and it will be fixed. If I discover an improvement I can contribute that as well. Not so much in corporate "paid" product world.... been using gcc for decades and found it to be more reliable than paid compliers in my experiences

Last Edited: Sat. Jan 16, 2021 - 07:19 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

speed matters more

I agree, this is especially important for microcontrollers!

but... for speed - argumen is -Os ?

 

I have a desire to test for speed, but I am currently busy building compiler хс8-avr (from sources)

doing work, collecting and ... I understand what nasty and nasty guys a microchip ... made self-assembly from source as impossible as possible... :о(

 

main$ md5 XC8_v2.30_AVR_Sources.zip
MD5(XC8_v2.30_AVR_Sources.zip)= c1d0e90761ad6c2d2517d0a7989edd44

main$ md5 XC8_v2.31_AVR_Sources.zip
MD5(XC8_v2.31_AVR_Sources.zip)= c1d0e90761ad6c2d2517d0a7989edd44

and

on arc:
XC8_v2.10_AVR_Source.zip

void/trash
- avr-libc.tar.bz2
- SOURCES.README

p.s. I also have confidence to avr-gcc

if I'm wrong, correct this and do not criticize :o)

Last Edited: Tue. Feb 9, 2021 - 03:06 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

12oclocker wrote:

If I find a bug I can submit a fix and it will be fixed....been using gcc for decades and found it to be more reliable than paid compliers in my experiences

 

I use a paid-for AVR compiler. The last time I discovered a problem it was fixed within 24 hours. It also now contains a couple of features that I suggested.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't understand the emphasis on program size or speed.

 

I want to know whether the Compiler creates the correct code.   i.e. it translates legal source code according to the C or C++ language specification.
 

The size only matters if you are hitting the Flash limit for your target AVR.

The execution speed only matters for very small "inside loop" sequences that are called millions of times.

 

Most of us are familiar with avr-gcc.   Few people use XC8.   I would like to see evidence that XC8 works.

e.g. a test-suite for conformance

 

If and when XC8 and avr-gcc have passed conformance tests,  size and execution speed would be of general interest.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Brian Fairchild wrote:
But is size the best measure

Size is so often over-rated ;-)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:

I don't understand the emphasis on program size or speed.

...

I would like to see evidence that XC8 works. e.g. a test-suite for conformance

 

it looks like you are the best at this topic! please write tests, I will do them (if you help me can run out the workflow, how to run it all, save the results, etc.) Thank you 

 

 

if I'm wrong, correct this and do not criticize :o)

Last Edited: Sat. Jan 16, 2021 - 11:12 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Often size and speed go hand in hand, small code often has good r(use) of registers and branches are therefore more likely to be within the ASM branch size. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
gcc1 - avr-gcc-3.6.2 custom Makefile
gcc2 - avr-gcc-3.6.2 build on mplabx
///////////////////////////////////////////
opt  |  gcc1   |  gcc2   | xc8
///////////////////////////////////////////
0    |  5,966  |  8,433  | 9,188

Do you have an explanation for why the -O0 build is so much smaller with your makefile than with either MPLABX build?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm not a magician: o) ... and not such a great specialist, over time I put together my universal makefile with the help of brains, articles, forums and magic words ... and now I use ...

 

There is no desire and time to crawl into the jungle of makefiles keys and the subtleties of the compiler, I can repeat the exhaust of the makefile and mplabx assembly

 

or I can post a project, but with the obligatory condition that you write in detail, what do you find out ?! comments, fortunately, in Russian: o)

if I'm wrong, correct this and do not criticize :o)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
I want to know whether the Compiler creates the correct code.
Concur

Though not for AVR :

Performance | CompCert - The CompCert C compiler

 


CompCert/test/c at master · AbsInt/CompCert · GitHub

QEMU AVR | AVR Freaks

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
  • Common Code Interface (CCI) improves portability between MPLAB XC

MPLAB® XC8 User's Guide for Embedded Engineers - AVR MCUs

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gchapman wrote:
PROGMEM and its alternatives; const implies __memx

This is a joke.

avrfreaks does not support Opera. Profile inactive.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

From my experience avr-gcc tends to produce some more outlandish errors while xc8 compiles better and has more manageable errors. 

 

Both of them produce working code and I've never experienced an issue with either. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The_time wrote:
avr-gcc tends to produce some more outlandish errors while xc8 compiles better and has more manageable errors. 

Not quite sure what you mean by that?

 

Are you talking about compiler diagnostics (error & warning messages) ?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
Not quite sure what you mean by that?
+1

 

One of the great things that has happened to GCC over the last 10 years is that the error messages have got really good. These days they leave you in almost no doubt as to what is wrong and they even do that thing now where the line in question is reprinted with a caret on the line below saying exactly where in the line the compiler thinks the error is so when you see error (213:17) meaning line 213, column 17 you no longer have to count across to work out exactly where character 17 falls - the compiler shows you. It's very good. Also these day many of the errors and especially the warning include detail in the text of a compiler switch you might want to use to over-ride the thing being called out.

 

OTOH I do have to say that I like MSVC too (not for AVR obviously) but for every error it will include a 4 digit error code like 

error C2040: 'pThis' : 'int' differs in levels of indirection from 'int *'

so if you don't know what it means you can just google "C2040" and arrive at:

 

https://docs.microsoft.com/en-us...

 

which explains further. All other compiler could benefit from something like this!

Pages