From f2fab8347d88216afa60826ea7741435d680acbb Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 8 Nov 2023 22:08:29 -0800 Subject: [PATCH 1/2] Fix TestReverseSlice for go 1.21 Go 1.21 does a better job using the same empty allocation for empty slices, check for cap > 0 before requiring slices to have different backing arrays. Bug: 309895579 Test: TestReverseSlice Change-Id: Ic48e9cf2c95ea0b810a11cdc4a794a70c02a0a61 --- android/util_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/util_test.go b/android/util_test.go index 20161e52d..699135bfc 100644 --- a/android/util_test.go +++ b/android/util_test.go @@ -811,7 +811,7 @@ func TestReverseSlice(t *testing.T) { if !reflect.DeepEqual(slice, testCase.expected) { t.Errorf("expected %#v, got %#v", testCase.expected, slice) } - if slice != nil && unsafe.SliceData(testCase.in) == unsafe.SliceData(slice) { + if cap(slice) > 0 && unsafe.SliceData(testCase.in) == unsafe.SliceData(slice) { t.Errorf("expected slices to have different backing arrays") } }) From 611a2fbdd7a01bce4046db364f7af7000d69ffa1 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 8 Nov 2023 22:09:57 -0800 Subject: [PATCH 2/2] Fix soong_ui file rlimits for go 1.21 Go 1.21 modifies the file limit but restores the original when execing subprocesses if it hasn't be overridden. Call Setrlimit even if it doesn't appear to be necessary so that the syscall package considers it set. Bug: 309895579 Test: m nothing Change-Id: I4d0b27bac90a2a88bfc68a8491d54dc106e1ec13 --- cmd/soong_ui/main.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/soong_ui/main.go b/cmd/soong_ui/main.go index 18cba776b..4484a483c 100644 --- a/cmd/soong_ui/main.go +++ b/cmd/soong_ui/main.go @@ -680,9 +680,11 @@ func setMaxFiles(ctx build.Context) { } ctx.Verbosef("Current file limits: %d soft, %d hard", limits.Cur, limits.Max) - if limits.Cur == limits.Max { - return - } + + // Go 1.21 modifies the file limit but restores the original when + // execing subprocesses if it hasn't be overridden. Call Setrlimit + // here even if it doesn't appear to be necessary so that the + // syscall package considers it set. limits.Cur = limits.Max err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &limits)