In a saucepan, bring the mushrooms and 3 cups of water to a boil. Simmer over moderate heat until the broth is reduced to 1 cup, 1 hour. Strain and discard the mushrooms.
Meanwhile, in a small saucepan, bring the garlic and olive oil to a boil. Simmer over moderately low heat, stirring, until the garlic is very tender and golden, about 30 minutes.
In a large enameled cast-iron casserole or Dutch oven, bring the tomatoes and the garlic and oil to a boil. Add the mushroom broth and, using an immersion blender, puree the sauce until smooth. Bring the sauce back to a boil, then simmer over moderately low heat until thickened, about 1 hour. Season the sauce with salt and pepper.
Cook the spaghetti in a large pot of salted boiling water until al dente. Drain the spaghetti and return to the pot. Add 2 cups of the sauce and cook, tossing, for 1 minute. Transfer the spaghetti to bowls, top with the basil and serve with grated cheese.