[toolchains] add handle_ds_deps function to resolve circular dependencies