Canonical Basis and Homology of Local Systems