In our case, I take my role as friendship facilitator seriously. I arrange playdates at the science museum, enroll DS in many enrichment activities in a group setting (academic as well as art and sports) and have started a local lego league and a local science group for him and his friends. DS has been around peers that are older than him and above him in abilities through these activities. He gets exposure to how other gifted kids think and at the same time works on bettering his own skills. And he has been around the same set of kids for a while now that they have become friends.
At school, we let him figure things out on his own. Sometimes, he dumbs down to make friends, sometimes he acts goofy and becomes the class clown to be popular, sometimes he does not care, but most recently, he has been playing alone.