Compute profiling/shared based on library deps only.
Previously we'd build Cabal and custom setup dependencies with profiling even though it wasn't necessary. Using a refined dependency graph fixes the problem. If looking at a Graph with different set of neighbors becomes a common op, maybe we should add some functions to handle this specific case. Fixes #3789. Signed-off-by: Edward Z. Yang <firstname.lastname@example.org>