Peel onions and garlic. Cut onion into rings, chop garlic finely. Wash the rosemary, shake dry and chop finely. Heat oil in a pot.
Stew onions and garlic in it at low heat for about 10 minutes until soft, without browning. Add about 2/3 rosemary and braise briefly. Deglaze with stock and wine, season with salt, pepper and sugar. Simmer covered soup for about 15 minutes
Cut the baguette into slices and spread them on a baking tray lined with baking paper. Grate cheese, mix with remaining rosemary and spread on the slices of bread. Bake in a preheated oven (electric cooker: 225 °C/ convection oven: 200 °C/ gas: see manufacturer) for 5-7 minutes. Season soup to taste, arrange in soup bowls, cover with slices of bread