In a slow cooker, combine onions, garlic, butter, brown sugar, and flour. Cook on low for 6-8 hours, or on high for 3-4 hours, until onions are caramelized.
Stir in beef broth and sherry (if using). Continue to cook on low for 30 minutes.
Ladle soup into oven-safe bowls.
Top each bowl with a slice of toasted French bread and sprinkle with Gruyere cheese.