Add musl defaults in bp2build

Bug: 261657184
Test: Unit Tests
Test: Manual Inspection of generated files
Change-Id: I69864abb410fddecd530fc75f2531aff33b33c97
diff --git a/cc/bp2build.go b/cc/bp2build.go
index d331d89..f031f42 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -813,6 +813,8 @@
 	features := compilerAttrs.features.Clone().Append(linkerAttrs.features).Append(bp2buildSanitizerFeatures(ctx, module))
 	features.DeduplicateAxesFromBase()
 
+	addMuslSystemDynamicDeps(ctx, linkerAttrs)
+
 	return baseAttributes{
 		compilerAttrs,
 		linkerAttrs,
@@ -823,6 +825,16 @@
 	}
 }
 
+// As a workaround for b/261657184, we are manually adding the default value
+// of system_dynamic_deps for the linux_musl os.
+// TODO: Solve this properly
+func addMuslSystemDynamicDeps(ctx android.Bp2buildMutatorContext, attrs linkerAttributes) {
+	systemDynamicDeps := attrs.systemDynamicDeps.SelectValue(bazel.OsConfigurationAxis, "linux_musl")
+	if attrs.systemDynamicDeps.HasAxisSpecificValues(bazel.OsConfigurationAxis) && systemDynamicDeps.IsNil() {
+		attrs.systemDynamicDeps.SetSelectValue(bazel.OsConfigurationAxis, "linux_musl", android.BazelLabelForModuleDeps(ctx, config.MuslDefaultSharedLibraries))
+	}
+}
+
 type fdoProfileAttributes struct {
 	Absolute_path_profile string
 }