From fa086c8a85f27b8b522478bce4a0e132372109a8 Mon Sep 17 00:00:00 2001 From: Jisi Liu Date: Tue, 15 Aug 2017 12:27:46 -0700 Subject: [PATCH 1/4] First try static linking pthread --- protoc-artifacts/build-protoc.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/protoc-artifacts/build-protoc.sh b/protoc-artifacts/build-protoc.sh index e31948e987..397933d9f9 100755 --- a/protoc-artifacts/build-protoc.sh +++ b/protoc-artifacts/build-protoc.sh @@ -215,8 +215,11 @@ fi # Statically link libgcc and libstdc++. # -s to produce stripped binary. -# And they don't work under Mac. -if [[ "$OS" != osx ]]; then +if [[ "$OS" == windows && "$ARCH" == x86_64 ]]; then + # Also static link libpthread required by mingw64 + LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -s" +elif [[ "$OS" != osx ]]; then + # And they don't work under Mac. LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++ -s" fi From f7b3dd4329145403b7de78451523700a84e33291 Mon Sep 17 00:00:00 2001 From: Jisi Liu Date: Tue, 15 Aug 2017 13:13:10 -0700 Subject: [PATCH 2/4] Update comments that cross compile is feasible now Need to install mingw-w64 on linux to cross compile --- protoc-artifacts/build-protoc.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/protoc-artifacts/build-protoc.sh b/protoc-artifacts/build-protoc.sh index 397933d9f9..b008fec355 100755 --- a/protoc-artifacts/build-protoc.sh +++ b/protoc-artifacts/build-protoc.sh @@ -185,8 +185,6 @@ elif [[ "$(uname)" == Linux* ]]; then fi elif [[ "$OS" == windows ]]; then # Cross-compilation for Windows - # TODO(zhangkun83) MinGW 64 always adds dependency on libwinpthread-1.dll, - # which is undesirable for repository deployment. CONFIGURE_ARGS="$CONFIGURE_ARGS" if [[ "$ARCH" == x86_64 ]]; then CONFIGURE_ARGS="$CONFIGURE_ARGS --host=x86_64-w64-mingw32" From d909834ec604998069c6bef5239563880aa125b7 Mon Sep 17 00:00:00 2001 From: Jisi Liu Date: Tue, 15 Aug 2017 13:15:37 -0700 Subject: [PATCH 3/4] static link for 32 bit build as well. --- protoc-artifacts/build-protoc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protoc-artifacts/build-protoc.sh b/protoc-artifacts/build-protoc.sh index b008fec355..57523a41bf 100755 --- a/protoc-artifacts/build-protoc.sh +++ b/protoc-artifacts/build-protoc.sh @@ -213,7 +213,7 @@ fi # Statically link libgcc and libstdc++. # -s to produce stripped binary. -if [[ "$OS" == windows && "$ARCH" == x86_64 ]]; then +if [[ "$OS" == windows ]]; then # Also static link libpthread required by mingw64 LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -s" elif [[ "$OS" != osx ]]; then From 6654c8dd5014c83d73c0301911f989fb9be439c1 Mon Sep 17 00:00:00 2001 From: Jisi Liu Date: Tue, 15 Aug 2017 13:46:20 -0700 Subject: [PATCH 4/4] Update readme --- protoc-artifacts/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/protoc-artifacts/README.md b/protoc-artifacts/README.md index 5062920932..17eb77f840 100644 --- a/protoc-artifacts/README.md +++ b/protoc-artifacts/README.md @@ -72,6 +72,7 @@ deployment for all platforms. Currently the following platforms are supported: - Windows (x86_32 and x86_64) with - Cygwin64 with MinGW compilers (x86_64) - MSYS with MinGW32 (x86_32) + - Cross compile in Linux with MinGW-w64 (x86_32, x86_64) - MacOSX (x86_32 and x86_64) As for MSYS2/MinGW64 for Windows: protoc will build, but it insists on @@ -98,6 +99,9 @@ $ mvn clean deploy -P release -Dstaging.repository=comgoogle-123 A 32-bit artifact can be deployed from a 64-bit host with ``-Dos.detected.arch=x86_32`` +A windows artifact can be deployed from a linux machine with +``-Dos.detected.name=windows`` + When you have done deployment for all platforms, go to https://oss.sonatype.org/#stagingRepositories, verify that the staging repository has all the binaries, close and release this repository. @@ -173,5 +177,7 @@ We have successfully built artifacts on the following environments: - Centos 6.6 (within Docker 1.6.1) - Ubuntu 14.04.2 64-bit - Windows x86_32: MSYS with ``mingw32-gcc-g++ 4.8.1-4`` on Windows 7 64-bit +- Windows x86_32: Cross compile with ``i686-w64-mingw32-g++ 4.8.2`` on Ubuntu 14.04.2 64-bit - Windows x86_64: Cygwin64 with ``mingw64-x86_64-gcc-g++ 4.8.3-1`` on Windows 7 64-bit +- Windows x86_64: Cross compile with ``x86_64-w64-mingw32-g++ 4.8.2`` on Ubuntu 14.04.2 64-bit - Mac OS X x86_32 and x86_64: Mac OS X 10.9.5