"And many Ubuntu packages will include the compiler version string, which will include the word``ubuntu""."
There's no risk of confusion by using the trademarks in this way, and as a consequence there would be no infringement under trademark law.