Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F-Droid can't build #8987

Closed
licaon-kter opened this issue Aug 21, 2023 · 12 comments
Closed

F-Droid can't build #8987

licaon-kter opened this issue Aug 21, 2023 · 12 comments

Comments

@licaon-kter
Copy link

licaon-kter commented Aug 21, 2023

What is the issue?

Looks like Java 17 is now needed, per https://monitor.f-droid.org/builds/log/com.tailscale.ipn/176#site-footer

Ok, let's add that... oh... Makefile has been redone drastically... let me try...

  - versionName: 1.48.0-t77c732357-g388b71affe8
    versionCode: 176
    commit: fcab2211ef57398f0042b422178ab796e258177c
    subdir: android
    sudo:
      - apt-get update
      - apt-get install -y -t bullseye-backports golang-go
      - apt-get install -y build-essential
      - apt-get install -y openjdk-17-jdk-headless
      - update-java-alternatives -a
    gradle:
      - fdroid
    srclibs:
      - tailscale-go@e6ce5b50036022c91783161890eabecfddc5ae79
    prebuild:
      - sdkmanager 'platforms;android-31' 'platform-tools' 'build-tools;33.0.2'
      - sed -i -e '/rm -rf/,+2d' -e 's!$(ANDROID_HOME)/cmdline-tools/latest/bin/sdkmanager!sdkmanager!g' -e 's/list_installed/list/' ../Makefile
    build:
      - export TOOLCHAINREV=$(go run tailscale.com/cmd/printdep --go)
      - export TOOLCHAINDIR=${HOME}/.cache/tailscale-android-go-$TOOLCHAINREV
      - pushd $$tailscale-go$$
      - git checkout $TOOLCHAINREV
      - pushd src
      - ./make.bash
      - popd
      - popd
      - mkdir -p $TOOLCHAINDIR
      - ln -s $$tailscale-go$$ $TOOLCHAINDIR/go
      - export PATH=$TOOLCHAINDIR/go/bin:$PATH
      - ANDROID_NDK_ROOT=$$NDK$$ make -C .. tailscale-fdroid.apk
    ndk: r23b

umm, looks good but

...
+ make -C .. tailscale-fdroid.apk
make: Entering directory '/home/vagrant/build/com.tailscale.ipn'
mkdir -p android/libs
go: downloading go4.org/mem v0.0.0-20220726221520-4f986261bf13
go: downloading github.com/google/uuid v1.3.0
go: downloading golang.org/x/mod v0.11.0
go: downloading golang.org/x/crypto v0.11.0
go: downloading golang.org/x/exp v0.0.0-20230725093048-515e97ebf090
go: downloading go4.org/netipx v0.0.0-20230728180743-ad4cb58a6516
go: downloading golang.org/x/sys v0.10.0
go run gioui.org/cmd/gogio \
        -ldflags "-X tailscale.com/version.longStamp=1.48.0-t77c732357-g388b71affe8 -X tailscale.com/version.shortStamp=1.48.0 -X tailscale.com/version.gitCommitStamp=77c732357 -X tailscale.com/version.extraGitCommitStamp=fcab2211ef57398f0042b422178ab796e258177c-dirty" \
        -buildmode archive -target android -appid com.tailscale.ipn -tags novulkan,tailscale_go -o android/libs/ipn.aar github.com/tailscale/tailscale-android/cmd/tailscale
go: downloading gioui.org/cmd v0.0.0-20210925100615-41f3a7e74ee6
go: downloading gioui.org v0.0.0-20230206180804-32c6a9b10d0b
go: downloading github.com/akavel/rsrc v0.10.1
go: downloading golang.org/x/image v0.7.0
go: downloading golang.org/x/sync v0.2.0
go: downloading golang.org/x/tools v0.9.1
go: downloading golang.org/x/text v0.11.0
gogio: go build -ldflags=-w -s -X tailscale.com/version.longStamp=1.48.0-t77c732357-g388b71affe8 -X tailscale.com/version.shortStamp=1.48.0 -X tailscale.com/version.gitCommitStamp=77c732357 -X tailscale.com/version.extraGitCommitStamp=fcab2211ef57398f0042b422178ab796e258177c-dirty -X gioui.org/app/internal/log.appID=com.tailscale.ipn -buildmode=c-shared -tags novulkan,tailscale_go -o /tmp/gogio-814326569/jni/armeabi-v7a/libgio.so github.com/tailscale/tailscale-android/cmd/tailscale failed: ../../go/pkg/mod/tailscale.com@v1.48.0/wgengine/magicsock/endpoint_tracker.go:8:2: package slices is not in GOROOT (/usr/lib/go-1.19/src/slices)

exit status 1

Which make command should I use exactly? Why is Go failing? full log:
com.tailscale.ipn_176.log.gz

/LE: fyi https://gitlab.com/fdroid/fdroiddata/-/commit/8cb6d1fcc173478eee95ca67254ccff952959a89

@DentonGentry
Copy link
Contributor

The hope was that setting TOOLCHAINDIR to the location of a Go 1.21 toolchain would be sufficient.

It shouldn't require Java 17. We generally use Java 11.

@bradfitz
Copy link
Member

@raggi, can you assist?

@licaon-kter
Copy link
Author

It shouldn't require Java 17. We generally use Java 11.

Really? tailscale/tailscale-android@11a0d21

@raggi
Copy link
Member

raggi commented Aug 21, 2023

We do now require a more recent Java than 11. We're using 17 in our builds. The gradle releases supporting Java 11 are no longer in maintenance, and I upgraded gradle as part of maintenance to bring our build toolchain up to a supported version, which includes moving away from jcenter, that is in shutdown.

@licaon-kter I was aware that the Makefile refactoring would have some impact. I'd be happy to make some more best-effort to coordinate on those kinds of changes. If there's some good way to reach out to do that, let me know.

The error in the output here appears to be from the Go toolchain. Tailscale tracks Go very closely, and is now using 1.21 features, in particular here the introduction of the slices package to the stdlib. I believe part of the error output being less than ideal stems from my not having bumped the toolchain version in go.mod. That was done in tailscale/tailscale-android@88d006f

@licaon-kter
Copy link
Author

If there's some good way to reach out to do that, let me know.

We're on Github, Gitlab and Codeberg at least, ping us :)

@licaon-kter
Copy link
Author

Tailscale tracks Go very closely, and is now using 1.21 features, in particular here the introduction of the slices package to the stdlib.

Yes, but I guess the error message is clear, package slices is not in GOROOT (/usr/lib/go-1.19/src/slices) meaning that even if you did the right thing, Go is trying to use older system wide installed slices and not your freshly 1.21 built ones, yes?

raggi added a commit to tailscale/tailscale-android that referenced this issue Aug 29, 2023
This should provide an earlier error for cases such as
tailscale/tailscale#8987 if the error comes from a failure to fetch the
toolchain, or a change that forces an alternative GOROOT by some other
means.

Updates tailscale/tailscale#8987
@raggi
Copy link
Member

raggi commented Aug 29, 2023

@licaon-kter based on this line here: https://gitlab.com/fdroid/fdroiddata/-/blob/8cb6d1fcc173478eee95ca67254ccff952959a89/metadata/com.tailscale.ipn.yml#L1003 it looks like TOOLCHAINDIR may be one directory too low, the flag expects it to be equivalent to a GOROOT path, i.e. it needs to include that go last directory component. It should contain $TOOLCHAINDIR/bin/go.

@licaon-kter
Copy link
Author

licaon-kter commented Aug 30, 2023

...
+ export TOOLCHAINREV=593313088f6e5297cba5d5e3f392f15251bd5915
+ export TOOLCHAINDIR=/home/vagrant/.cache/tailscale-android-go-593313088f6e5297cba5d5e3f392f15251bd5915
+ export PATH=/home/vagrant/.cache/tailscale-android-go-593313088f6e5297cba5d5e3f392f15251bd5915/go/bin:/opt/android-sdk/ndk/r23b:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/opt/android-sdk/tools:/opt/android-sdk/platform-tools:/opt/gradle/bin
+ ls -la /home/vagrant/.cache/tailscale-android-go-593313088f6e5297cba5d5e3f392f15251bd5915/go/
total 96
drwxr-xr-x 12 vagrant vagrant  4096 Aug 30 09:50 .
drwxr-xr-x  3 vagrant vagrant  4096 Aug 30 09:41 ..
drwxr-xr-x  8 vagrant vagrant  4096 Aug 30 09:50 .git
-rw-r--r--  1 vagrant vagrant   639 Aug 30 09:42 .gitattributes
drwxr-xr-x  4 vagrant vagrant  4096 Aug 30 09:50 .github
-rw-r--r--  1 vagrant vagrant   958 Aug 30 09:50 .gitignore
-rw-r--r--  1 vagrant vagrant  1337 Aug 30 09:50 CONTRIBUTING.md
-rw-r--r--  1 vagrant vagrant  1479 Aug 30 09:42 LICENSE
-rw-r--r--  1 vagrant vagrant  1303 Aug 30 09:42 PATENTS
-rw-r--r--  1 vagrant vagrant  1455 Aug 30 09:50 README.md
-rw-r--r--  1 vagrant vagrant   419 Aug 30 09:42 SECURITY.md
-rw-r--r--  1 vagrant vagrant    35 Aug 30 09:50 VERSION
drwxr-xr-x  2 vagrant vagrant  4096 Aug 30 09:50 api
drwxr-xr-x  2 vagrant vagrant  4096 Aug 30 09:53 bin
-rw-r--r--  1 vagrant vagrant    52 Aug 30 09:50 codereview.cfg
drwxr-xr-x  2 vagrant vagrant  4096 Aug 30 09:50 doc
-rw-r--r--  1 vagrant vagrant   505 Aug 30 09:50 go.env
drwxr-xr-x  3 vagrant vagrant  4096 Aug 30 09:41 lib
drwxr-xr-x  8 vagrant vagrant  4096 Aug 30 09:50 misc
drwxr-xr-x  4 vagrant vagrant  4096 Aug 30 09:53 pkg
drwxr-xr-x 52 vagrant vagrant  4096 Aug 30 09:50 src
drwxr-xr-x 26 vagrant vagrant 12288 Aug 30 09:50 test
+ ls -la /home/vagrant/.cache/tailscale-android-go-593313088f6e5297cba5d5e3f392f15251bd5915/go/bin/
total 14580
drwxr-xr-x  2 vagrant vagrant     4096 Aug 30 09:53 .
drwxr-xr-x 12 vagrant vagrant     4096 Aug 30 09:50 ..
-rwxr-xr-x  1 vagrant vagrant 12403901 Aug 30 09:53 go
-rwxr-xr-x  1 vagrant vagrant  2513259 Aug 30 09:53 gofmt
+ ANDROID_NDK_ROOT=/opt/android-sdk/ndk/r23b
+ make -C .. tailscale-fdroid.apk
make: Entering directory '/home/vagrant/build/com.tailscale.ipn'
# Assert that the go toolchain referred to by TOOLCHAINDIR is in fact the
# one that `go` in the current ATH is using.
test `go env GOROOT` = /home/vagrant/.cache/tailscale-android-go-593313088f6e5297cba5d5e3f392f15251bd5915
make: *** [Makefile:123: toolchain] Error 1
make: Leaving directory '/home/vagrant/build/com.tailscale.ipn'

What's next?

@raggi
Copy link
Member

raggi commented Aug 30, 2023

Thanks @licaon-kter, per the above, the line:

+ export TOOLCHAINDIR=/home/vagrant/.cache/tailscale-android-go-593313088f6e5297cba5d5e3f392f15251bd5915

Should be adjusted in your source-build layout like so:

+ export TOOLCHAINDIR=/home/vagrant/.cache/tailscale-android-go-593313088f6e5297cba5d5e3f392f15251bd5915/go

This is a change from the past - earlier versions of this build unpacked our binary distributions of our go toolchain into a directory with a subdirectory called go, and the Makefile had an embedded dependency on that layout, but this is inconsistent with what we do in tailscale/tailscale, and how our dist tooling uses the path.

TOOLCHAINDIR now has equivalent expectations to GOROOT, i.e. what is typically in that directory is:

api  codereview.cfg   doc     lib      misc     pkg        SECURITY.md  test
bin  CONTRIBUTING.md  go.env  LICENSE  PATENTS  README.md  src          VERSION

rather than just go.

The $PATH entry would then effectively be $TOOLCHAINDIR/bin, with the expectation that $TOOLCHAINDIR/bin/go env GOROOT returns a string equal to $TOOLCHAINDIR.

I don't have a build setup locally yet, but https://gitlab.com/fdroid/fdroiddata/-/merge_requests/13641 may be close.

@raggi
Copy link
Member

raggi commented Aug 31, 2023

@licaon-kter the above patch is making it further, but (cd android && ./gradlew) is failing. I noticed in the build output: 2023-08-31 03:43:27,168 INFO: Removing gradle-wrapper.jar at android/gradle/wrapper/gradle-wrapper.jar.

I kicked off another test substituting in bash -x to execute gradlew to gather some more information.

raggi added a commit to tailscale/tailscale-android that referenced this issue Aug 31, 2023
This should provide an earlier error for cases such as
tailscale/tailscale#8987 if the error comes from a failure to fetch the
toolchain, or a change that forces an alternative GOROOT by some other
means.

Updates tailscale/tailscale#8987
@raggi
Copy link
Member

raggi commented Aug 31, 2023

@raggi
Copy link
Member

raggi commented Aug 31, 2023

And the above was merged! thanks for the bug and pointers @licaon-kter

@raggi raggi closed this as completed Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants