Skip to content

Unable to package darwin-dmg when using CGo in a go-flutter-desktop plugin #499

Open
@Aurora12

Description

@Aurora12

Hover doctor

hover: Hover version v0.42.0 running on darwin
hover: Sharing flutter version
Flutter 1.20.0-7.3.pre • channel beta • https://github.com/flutter/flutter.git
Framework • revision e606910f28 (2 days ago) • 2020-07-28 16:06:37 -0700
Engine • revision ac95267aef
Tools • Dart 2.9.0 (build 2.9.0-21.10.beta)
hover: Flutter engine commit: https://github.com/flutter/engine/commit/ac95267aef5175b3f6c3387d502070c68f588ad5
hover: Finding out the C compiler version
clang version 10.0.0
Target: x86_64-apple-darwin19.5.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin

Preamble

The following does work.

I use CGo to compile xeodou/go-sqlcipher.

I use a modified version of go-flutter-plugin-sqlite to be able to use go-sqlcipher for transparent database encryption over SQLite.

~/go/bin/hover run and ~/go/bin/hover build darwin work as expected: the Flutter app runs and uses encrypted SQLite. I have env vars CGO_ENABLED, LIBRARY_PATH and CGO_CPPFLAGS set appropriately to make the compilation possible.

$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.5.0
Thread model: posix

I also have OpenSSL installed as a dependency of SQLCipher.

Error output

I'm not able to package the app on macOS Catalina 10.15.5.

Using ~/go/bin/hover build --docker darwin-dmg to build my application, I get the following
error once the compilation reaches go-sqlcipher:

hover: Compiling go binary using docker container
Running this docker command: /usr/local/bin/docker run --rm --mount type=bind,source=/Users/nox/Documents/workspace/worldr/client/desktop,target=/app --mount type=bind,source=/Users/nox/Library/Caches/hover/engine,target=/root/.cache/hover/engine --mount type=bind,source=/Users/nox/Library/Caches/hover/docker-go-cache,target=/go-cache --env GOCACHE=/go-cache --env HOVER_SAFE_CHOWN_UID=501 --env HOVER_SAFE_CHOWN_GID=20 --env GOPROXY=https://proxy.golang.org,direct
 --env GOPRIVATE=
 goflutter/hover:v0.42.0 hover-safe.sh build darwin-dmg --skip-flutter-build-bundle --skip-engine-download

<...>

docker container: github.com/xeodou/go-sqlcipher
docker container: # github.com/xeodou/go-sqlcipher
docker container: sqlite3-binding.c:24508:10: error: invalid argument type 'void' to unary expression
docker container: sqlite3-binding.c:24511:10: error: invalid argument type 'void' to unary expression
docker container: sqlite3-binding.c:24514:10: error: invalid argument type 'void' to unary expression
docker container: sqlite3-binding.c:24520:6: error: invalid argument type 'void' to unary expression
docker container: sqlite3-binding.c:24522:8: error: invalid argument type 'void' to unary expression
docker container: sqlite3-binding.c:24524:6: error: invalid argument type 'void' to unary expression
docker container: sqlite3-binding.c:24539:11: warning: implicit declaration of function 'PKCS5_PBKDF2_HMAC' is invalid in C99 [-Wimplicit-function-declaration]
docker container: hover: Go build failed: exit status 2
hover: Docker run failed: exit status 1

Attempts to fix

I figured the compiler may not know we are using CGo, so I set ENV CGO_ENABLED=1 in Hover's DockerFile to see if this changes the error. I also figured, this may be a problem with the version of GCC, so I tried building the Hover docker image with gcc:latest as a parent image instead of original ubuntu:bionic.

Nothing I did made any difference: the error remains the same, the compiler refuses the sqlite3-binding.c syntax. I can see Hover is using my local docker image by the way it complains on the CGO_CPPFLAGS.

Any ideas?

Any hints or directions are greatly appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    MacOSSpecifically concerns MacOShover

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions