The advertising can't state a discriminatory preference, or be shown in such a way as to achieve such a discriminatory preference. It would be illegal, for example, for me to advertise and tell a company "don't show me to black potential tenants".
OTOH, I've advertised jobs for developers on places like Stack Overflow, because that is where developers tend to be reachable. Unsurprisingly, Stack Overflow is around 93% male, with male developers being even higher than that, and extremely experienced developers even more biased than that.
I don't control the market, and I'll hire the qualified developers without regards to race or sex. As far as I know, I've never had an applicant who was black, but the confluence of highly experienced, developer, in this field means the applicants are near exclusively white men, asian men, and Indian men. We do get a fair number of LGBT applicants, though (especially trans applicants).
That's not discrimination, it's just the reality of the industry. I'm not going to run around trying to advertise in Better Homes and Gardens to try to find developers, because its a waste of ad money. I'm certainly ready, willing, and able to hire diverse developers - I'm just not able to create them, and not going to try. If I need to hire widget engineers with 10 years of experience, I will tell Facebook and LinkedIn and StackOverflow to target widget engineers with 10 years of experience, and hire the qualified applicants that come my way. It's not my fault or theirs if 99.5% of the people who meet those requirements for those good paying jobs are male.