golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
122.97k stars 17.53k forks source link

misc/cgo/testcshared: TestGo2C2Go fails on some Android systems #29087

Open ianlancetaylor opened 5 years ago

ianlancetaylor commented 5 years ago

android/arm64: https://build.golang.org/log/09e1a4ff3ef9aa281563ad09ca97456f76947b13:

--- FAIL: TestGo2C2Go (3.18s)
    cshared_test.go:622: run: [go build -buildmode=c-shared -o /var/folders/f6/d2bhfqss2716nxm8gkv1fmb80000gn/T/cshared-TestGo2C2Go159080790/libtestgo2c2go.so go2c2go/go]
    cshared_test.go:647: command failed: [go build -o /var/folders/f6/d2bhfqss2716nxm8gkv1fmb80000gn/T/cshared-TestGo2C2Go159080790/m1 go2c2go/m1]
        exit status 2
        # go2c2go/m1
        /Users/elias/android-ndk-standalone-arm64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: warning: liblog.so, needed by /var/folders/f6/d2bhfqss2716nxm8gkv1fmb80000gn/T/cshared-TestGo2C2Go159080790/libtestgo2c2go.so, not found (try using -rpath or -rpath-link)
        /var/folders/f6/d2bhfqss2716nxm8gkv1fmb80000gn/T/cshared-TestGo2C2Go159080790/libtestgo2c2go.so: undefined reference to `__android_log_vprint'
        clang38: error: linker command failed with exit code 1 (use -v to see invocation)

android/386: https://build.golang.org/log/4e90ced0da91bfcfa07b3acced63beea3829d137:

--- FAIL: TestGo2C2Go (4.11s)
    cshared_test.go:622: run: [go build -buildmode=c-shared -o /var/folders/f6/d2bhfqss2716nxm8gkv1fmb80000gn/T/cshared-TestGo2C2Go737454438/libtestgo2c2go.so go2c2go/go]
    cshared_test.go:647: run: [go build -o /var/folders/f6/d2bhfqss2716nxm8gkv1fmb80000gn/T/cshared-TestGo2C2Go737454438/m1 go2c2go/m1]
    cshared_test.go:195: adb command failed: exit status 127
        /system/bin/sh: /var/folders/f6/d2bhfqss2716nxm8gkv1fmb80000gn/T/cshared-TestGo2C2Go737454438/m1: not found
gopherbot commented 5 years ago

Change https://golang.org/cl/152162 mentions this issue: misc/cgo/testcshared: skip TestGo2C2Go on Android

eliasnaur commented 5 years ago

I took a look. The first problem was that the m1 and m2 executables were not pushed to the device, and neither was their dependency library, libtestgo2c2go.so. However, even after hacking around that, the test failed with runtime/cgo: pthread_key_create failed. That makes sense: on Android, the Go runtime uses a hardcoded offset from %gs for storing the current g, which means that two instances of the runtime cannot coexist in the same process. In short, this issue is the Android version of #29061 .