Sure, this ought to be fixed to use gcc's option to not delete files, but...
You really need to stop building stuff as root. That's nuts. This is not a Windows system. Use the fakeroot tools if you must, but that should not be required. There are lots of errors that could wipe out /dev/null, and even worse, so we have this idea of not using the root account to do random odd unprivileged tasks. Some call it "least privilege". Here's a classic disaster you'll love: rm -rf $FOO/* What if $FOO is not set?