How to use system avr-gcc instead of Arduino one

I am running Ubuntu 12.04 and note that the avr-gcc(4.5.3) in the system files is a few years more recent than the Arduino version (4.3.2 from 2008).

How can I get the Arduino IDE to use the system version (that is kept updated by the Ubuntu online updates) rather than the Arduino version. Or is the Arduino version customised for Arduino?

I believe you just need to rename/move the compiler in the Arduino tree (i.e. hardware/tools/avr/bin).

MichaelMeissner:
I believe you just need to rename/move the compiler in the Arduino tree (i.e. hardware/tools/avr/bin).

Be a man! rm -r that thing! rm -rf it if you're hardcore.

I took the bold move, manned up and tried your suggestion. Had permission problems so I changed directory to the hardware/tools/avr/bin and sudo-ed the command to overcome the problem:

sudo rm -rf /

to remove the contents of the directory but it came up with error messages, hung the PC and now it won't reboot!

How do I reverse this change?

sudo rm -rf /

So, you forced the removal of the root directory.

And everything below it.

How do I reverse this change?

Start reinstalling the operating system.

WizenedEE:
Be a man! rm -r that thing! rm -rf it if you're hardcore.

Note to self: Next time I see WizenedEE say "Be a man!", take the wimpola option.

Seriously, using rm -rf with su privileges is not a matter of manliness, rather just to be sure you know what you are doing.

Breaking it down in case there is any doubt:

rm = remove (i.e., delete)
-r = recursively (i.e., the nominated directory and any subdirectories below it)
-f = force (ignore file attributes)
/ = the root of the file system is the nominated directory
sudo = make me su, I know what I'm doing

On systems like ubuntu at least, someone should probably put rm in a wrapper to at least catch any invocation of

rm [flags] /

I mean, there is no valid reason you'd ever want to do this anyway. If an ubuntu user is trying to do this, it is almost 100% certainly a mistake.

To follow Michael's much safer original suggestion, you would have wanted to make

hardware/tools

your current directory, an invoked something like

mv avr oldavr

and then copied (or linked) the newer avr toolchain into director hardware/tools/avr

That way, if the new toolchain wasn't working for you, you can delete it (or unlink it) and mv (rename) oldavr back to avr.

lemming:
I took the bold move, manned up and tried your suggestion. Had permission problems so I changed directory to the hardware/tools/avr/bin and sudo-ed the command to overcome the problem:

sudo rm -rf /

to remove the contents of the directory but it came up with error messages, hung the PC and now it won't reboot!

How do I reverse this change?

I really hope you aren't serious...but part of me thinks you are...sigh.

Regarding your original issue (and if anyone knows better - please correct me) - the reason the avr-gcc used by the Arduino system is older than the "system supplied" one (by a lot) is because later versions broke something somewhere (with avr libc? or something) - and at any rate, it won't compile things properly, and it hasn't been patched (after all this time - no idea why) to fix it.

So - if you really b0rk3d your system - you did it for no good reason at all.

:frowning:

cr0sh:
is because later versions broke something somewhere (with avr libc? or something) - and at any rate, it won't compile things properly, and it hasn't been patched (after all this time - no idea why) to fix it.

I think it is only the 4.7.x versions where some things are definitely broken for AVR. Atmel are using a version of of 4.6.something for their gnu-based toolchain distribution, so there are definitely patched libs for later versions gcc that will work with AVR. My impression is Arduino have not been keeping up just because they don't see updating the toolchain as any kind of priority issue.

pico:

WizenedEE:
Be a man! rm -r that thing! rm -rf it if you're hardcore.

Note to self: Next time I see WizenedEE say "Be a man!", take the wimpola option.

Well it's what I do. Spending an extra fifteen seconds rebuilding Arduino isn't worth moving and re-moving the directory.

On systems like ubuntu at least, someone should probably put rm in a wrapper to at least catch any invocation of

rm [flags] /

I mean, there is no valid reason you'd ever want to do this anyway. If an ubuntu user is trying to do this, it is almost 100% certainly a mistake.

With my version of rm that's true. You have to use --no-preserve-root if you want to

$ rm -r /
rm: it is dangerous to operate recursively on ‘/’
rm: use --no-preserve-root to override this failsafe

is because later versions broke something somewhere (with avr libc? or something) - and at any rate, it won't compile things properly, and it hasn't been patched (after all this time - no idea why) to fix it.

I think it is only the 4.7.x versions where some things are definitely broken for AVR. Atmel are using a version of of 4.6.something for their gnu-based toolchain distribution, so there are definitely patched libs for later versions gcc that will work with AVR. My impression is Arduino have not been keeping up just because they don't see updating the toolchain as any kind of priority issue.

I'm currently compiling with avr-gcc 4.7.2. It's unpatched and pretty much works out of the box
distro is archlinux; I installed avr-gcc with pacman.

Nah.... sorry guys.

I didn't really do the rm thing. I was just trying to give WizenedEE the guilts for encouraging me to be gung-ho (in a good natured way).

I thank him for his input and levity.

But getting back to the original question....

Regarding cr0sh and picos posts, I renamed the bin directory "binold" and am now using the Ubuntu 4.5.3 compiler. It produces an executable a few hundred bytes smaller (for one of my sketches) than the arduino compiler. Coupled with what I assume to be other improvements in efficiency and bug fixes that newer versions bring, I would like to stick with it.

Any other views that I am going to have compatibility problems? All seems well at these early stages.

I think it's pretty much a case of suck it and see. 4.5.x is pretty conservative; Atmel is using 4.6.x, and WizenedEE is using 4.7.x (but we all know he's crazy.)

New versions don't necessarily mean fewer bugs, of course. Different bugs, usually, but not necessarily fewer.

Glad to hear things are really OK.

4.5.3 has the global ctors bug that causes sketches compiled for MEGA to fail instantly.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45263
I also recall a problem with delay(), and an arduino/math.h incompatibility issue.

In general, allowing Arduino to use the system compiler on Linux has caused quite a few issues for Linux users, sometimes because of compiler bugs, sometimes because of bad packaging (mismatched gcc/bin utils/avr-libc)

Not what I wanted to hear, but thanks for the heads-up westfw.

Suppose its back to the ol' 4.3.2 for me!

Sigh...

lemming:
Not what I wanted to hear, but thanks for the heads-up westfw.

Suppose its back to the ol' 4.3.2 for me!

Sigh...

You could always keep using it until you actually run into a bug. Just be aware that if you run into any "weird bugs" that you should try using the old compiler first.