These goals aren't in tension. Merit comes from who you hire. Diversity comes from who you interview. Cast a wide net, give opportunities to diverse candidates, and you'll end up right.
For example, 90+% of programmers are male, so not all firms can meet a 50-50 gender balance. Top firms try, but that will pull from somewhere. The same goes for race/ethnicity.
Diversity begins in schools.