I upgraded from Mohave to Big Sur and found that homebrew is not working any more. I installed the command line tools using the command
xcode-select --install
If you run brew upgrade still meet the error, maybe you should run brew update first.
brew upgrade
brew update
My experience is:
1. brew update 2. brew doctor 3. brew upgrade