Get the olive oil hot in a large pot, add in the diced onions and sugar. Cook on low to medium heat for roughly 1 1/2 to 2 hrs. Make sure you watch them and stir through the process so they do not burn. They need to have a dark brown color in order to have the depth of flavor the soup needs.
Once the onions are brown add in the minced garlic and cook for a couple minutes. Add in the white wine and scrape up any bits that are stuck to the bottom of the pan.
Add the beef stock, bring up to a boil and then turn heat to low and let simmer for 45 minutes to an hour. Season with salt and pepper. Skim off any additinal oil that may be at the surface.
Turn the oven to 350 and turn on the top broiler as well. Cut the baguette in 1/2 inch slices on a bias cut. Spread a thin layer of butter on the bread slices. Mound a large pile of gruyere cheese on top of baquette slices. Put the slices on a sheet of foil and put under the broiler. Cook until the cheese becomes a light golden brown. This will take around 5 minutes depending on how high your broiler goes. Do not walk away, this can burn very easily. Take out of the oven.
Ladle the soup in a bowl and top with your golden baguette slice.