I think the society and culture needs to work a bit harder to promote the idea of a girl as a professor, scientist, hacker, math wiz etc. Not just lip service but change the stories, the cartoons, movies, games etc. For too long in popular culture, starting early on girls are just princesses, then then later just a romantic interest side-kick. I noticed with my own daughter, she really wants identify with bad guys in the cartoons because even though they are naughty they have the coolest toys, rule the world and tell their minions what to do. But she finds it hard because the majority of the "cool" roles are taken by boys.
Yes by the time it comes to apply for tenure track positions, girls have already been told verbally and non-verbally many times -- "this is not for you, probably".
I remember in Eastern Europe in primary education, girls and women were more interested in math than boys. I was getting help with calculus homework from them. My high school CS teacher was a professional programmer before and she was an inspiration many girls and to boys alike, including me. She had a large book on Pascal and if we were good we could stay after school and do exercises from it. So I have seen it work in practice -- it is possible to have a culture and attitude where girls see math, science and CS as appealing disciplines.
On the other hand, I think it is worth to acknowledge that maybe there is also an element were women just don't want to do CS or math. Even if they had positive role models. I know we all think tech is super awesome, getting paid to do what we love, implement and develop cool algorithms, etc. But what if sitting in a cubicle inverting binary trees all day, mostly in isolation, doesn't appeal to others, and maybe those other are more likely to be women. Is that controversial to say? I imagine it might be soul crushing for some even if they were promised to get RSUs, options and a large salary.