* TSX closes up 40.89 points, or 0.34 percent, at 12,116.92 * Gold miners lead rise, banks and energy companies also help * Optimism on Europe aids sentiment By Alastair Sharp TORONTO, Aug 21 (Reuters) - Canada's benchmark stock index held on to gains to close slightly higher on Tuesday as resurgent gold prices boosted mining stocks and investor optimism grew on prospects for European bond-buying. The Canadian market followed European markets higher, but was more subdued given the heavy weighting of commodity-related stocks that get most of their momentum from signs of growth in the world's emerging economies, such as China. "It's grinding its way slowly upward here," said Douglas Davis, chief executive officer at wealth management firm Davis-Rea. "Nothing spectacular, but I think it will continue to do that for the next couple of months unless something really blows up." The price of gold jumped to its highest level since May, and gold miners were among the top-weighted upward movers on the Toronto exchange, led by Goldcorp Inc's 2.5 percent rise to C$38.88 and Eldorado Gold Corp jumping 5.7 percent to C$12.43. In fact, four of the top five performers by market weight were gold miners, who Davis said have been able to break out of a technical trading zone on the back of the rising price of bullion. The Toronto Stock Exchange's S&P/TSX composite index unofficially closed up 40.89 points, or 0.34 percent, at 12,116.92. During the session, it had risen as much as 1 percent. The broad gains in Canadian stocks followed European listings higher as investors bet on political and monetary moves to backstop the region's most debt-ridden countries. Italy's main index closed 2.4 percent higher, while Spain and France both added 1.1 percent. Philip Petursson, director of the portfolio advisory group at Manulife Asset Management, said a string of decent corporate earnings this month and attractive valuations had given the exchange a positive tilt which could only be aided by European optimism. "The glass is half full and if things in Europe seem to be leaning a little bit more positively, that's just further upside," he said. European shares earlier hit a 13-month high and the euro climbed amid hopes that meetings on Greece's future this week and new crisis plans being drawn up by the European Central Bank will soothe the euro zone's ongoing debt crisis.