Place the onion, butter, oil, thyme, bay leaves, salt and sugar in a heavy-based saucepan and cook over a medium heat for 40 minutes. Stirring from time to time. The onions should be golden and soft.
Stir in the flour and cook over a low heat for a further 10 minutes. Pour in the wine stir to combine, and cook over a medium heat for a further 20 minutes. The soup can be prepared up to this point 48 hours in advance.
Set the oven to 375°F Scatter a little cheese - don't use it all - over the bottom of a large ovenproof soup tureen or 6 to 8 individual ovenproof soup bowls on a baking sheet. Pour in the soup.
Rub the toasted French bread with the raw garlic and float over the soup. Top with the remaining cheese and place in the oven for about 20 minutes, until bubbling and golden brown.
Beat together the egg yolks, cream, brandy and madeira. When the soup is ready to be served, lift up the cheesy crust and pour the cream mixture into the soup, or serve in a jug and offer separately to your guests.