Heat the olive oil in a large Dutch oven over medium heat. Stir in the onions, butter, thyme and bay leaves. Cook, adding some water and scraping up any brown bits from the bottom of the pot occasionally, until the onions are deep golden brown, about 45 minutes.
Stir the flour into the onions and then add the beef stock, wine and some salt, and simmer for 30 minutes. Discard the bay leaves.
While the soup cooks, slice a few inches from the tops of the boules and pull out the bread inside, leaving a 1-inch thick crust. Reserve the insides for serving with the soup.
Preheat the broiler. Put the bread bowls on a baking sheet. Ladle the soup into the bread bowls. Divide the Gruyere among the bowls and broil until the cheese is melted and bubbly, 2 to 3 minutes. Transfer the soup bowls to plates and serve hot with the reserved bread, for dipping in the soup.
Homemade Beef Stock:
Preheat the oven to 450 degrees F. Put enough olive oil in a heavy-bottomed roasting pan to coat the bottom, then add the beef bones. Roast until browned, turning occasionally, 35 to 40 minutes.
Put the carrots, celery, onions, bay leaves, garlic and peppercorns in a large stock pot . Add the beef bones, making sure to scrape off and add any brown bits from the roasting pan. Add 8 cups water and bring to a boil over medium-high heat, skimming any scum on the surface. Lower the heat and simmer, skimming every hour or so, for 4 1/2 hours.
Strain the stock through a fine strainer into a metal container. Set the container in an ice bath to cool. If not using right away, refrigerate in an airtight container for up to 1 week, or freeze for 4 months.