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

Ubuntu Jammy(22.04) and Debian 11 fail to build zcash for Windows #6193

Closed
mdr0id opened this issue Oct 4, 2022 · 5 comments · Fixed by #6517
Closed

Ubuntu Jammy(22.04) and Debian 11 fail to build zcash for Windows #6193

mdr0id opened this issue Oct 4, 2022 · 5 comments · Fixed by #6517
Labels
A-build Area: Build system O-windows Operating system: Windows
Milestone

Comments

@mdr0id
Copy link
Contributor

mdr0id commented Oct 4, 2022

Testing cross compile targets for the new Ubuntu 22.04, it was notice that zcash doesn't compile as expected using:
HOST=x86_64-w64-mingw32 ./zcutil/build.sh -j16

Error:

configure:4346: clang -target x86_64-w64-mingw32 -B/home/zcash/depends/x86_64-w64-mingw32/native/bin -pipe -O3 -I/home/zcash/depends/x86_64-w64-mingw32/include -D_WIN32_WINNT=0x0601  -fuse-ld=lld  -L/home/zcash/depends/x86_64-w64-mingw32/lib conftest.c  >&5
lld: error: unable to find library -lgcc
lld: error: unable to find library -lgcc_eh
lld: error: unable to find library -lgcc
lld: error: unable to find library -lgcc_eh
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
configure:4350: $? = 1
configure:4390: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "libevent"
| #define PACKAGE_TARNAME "libevent"
| #define PACKAGE_VERSION "2.1.12-stable"
| #define PACKAGE_STRING "libevent 2.1.12-stable"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define PACKAGE "libevent"
| #define VERSION "2.1.12-stable"
| #define NUMERIC_VERSION 0x02010c00
| /* end confdefs.h.  */
| 
| int
| main (void)
| {
| 
|   ;
|   return 0;
| }
configure:4395: error: in `/home/zcash/depends/work/build/x86_64-w64-mingw32/libevent/2.1.12-e18ca86a2d5':
configure:4397: error: C compiler cannot create executables
See `config.log' for more details

## ---------------- ##
## Cache variables. ##
## ---------------- ##

ac_cv_env_CC_set=set
ac_cv_env_CC_value='clang -target x86_64-w64-mingw32 -B/home/zcash/depends/x86_64-w64-mingw32/native/bin'
ac_cv_env_CFLAGS_set=set
ac_cv_env_CFLAGS_value='-pipe -O3'
ac_cv_env_CPPFLAGS_set=set
ac_cv_env_CPPFLAGS_value='-I/home/zcash/depends/x86_64-w64-mingw32/include -D_WIN32_WINNT=0x0601 '
ac_cv_env_CPP_set=
ac_cv_env_CPP_value=
ac_cv_env_DOXYGEN_PAPER_SIZE_set=
ac_cv_env_DOXYGEN_PAPER_SIZE_value=
ac_cv_env_LDFLAGS_set=set
ac_cv_env_LDFLAGS_value='-fuse-ld=lld  -L/home/zcash/depends/x86_64-w64-mingw32/lib'
ac_cv_env_LIBS_set=
ac_cv_env_LIBS_value=
ac_cv_env_LT_SYS_LIBRARY_PATH_set=
ac_cv_env_LT_SYS_LIBRARY_PATH_value=
ac_cv_env_build_alias_set=
ac_cv_env_build_alias_value=
ac_cv_env_host_alias_set=set
ac_cv_env_host_alias_value=x86_64-w64-mingw32
ac_cv_env_target_alias_set=
ac_cv_env_target_alias_value=
ac_cv_path_install='/usr/bin/install -c'
ac_cv_path_mkdir=/usr/bin/mkdir
ac_cv_prog_AWK=mawk
ac_cv_prog_CC='clang -target x86_64-w64-mingw32 -B/home/zcash/depends/x86_64-w64-mingw32/native/bin'
ac_cv_prog_STRIP=x86_64-w64-mingw32-strip
ac_cv_prog_make_make_set=yes
am_cv_make_support_nested_variables=yes

## ----------------- ##
## Output variables. ##
## ----------------- ##

ACLOCAL='${SHELL} '\''/home/zcash/depends/work/build/x86_64-w64-mingw32/libevent/2.1.12-e18ca86a2d5/build-aux/missing'\'' aclocal-1.16'
AMDEPBACKSLASH=''
AMDEP_FALSE=''
AMDEP_TRUE='#'
AMTAR='$${TAR-tar}'
AM_BACKSLASH='\'
AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
AM_DEFAULT_VERBOSITY='0'
AM_V='$(V)'
AR='llvm-ar'
AUTOCONF='${SHELL} '\''/home/zcash/depends/work/build/x86_64-w64-mingw32/libevent/2.1.12-e18ca86a2d5/build-aux/missing'\'' autoconf'
AUTOHEADER='${SHELL} '\''/home/zcash/depends/work/build/x86_64-w64-mingw32/libevent/2.1.12-e18ca86a2d5/build-aux/missing'\'' autoheader'
AUTOMAKE='${SHELL} '\''/home/zcash/depends/work/build/x86_64-w64-mingw32/libevent/2.1.12-e18ca86a2d5/build-aux/missing'\'' automake-1.16'
AWK='mawk'
BUILD_CYGWIN_FALSE=''
BUILD_CYGWIN_TRUE=''
BUILD_MIDIPIX_FALSE=''
BUILD_MIDIPIX_TRUE=''
BUILD_REGRESS_FALSE=''
BUILD_REGRESS_TRUE=''
BUILD_SAMPLES_FALSE=''
BUILD_SAMPLES_TRUE=''
BUILD_WIN32_FALSE=''
BUILD_WIN32_TRUE=''
BUILD_WITH_NO_UNDEFINED_FALSE=''
BUILD_WITH_NO_UNDEFINED_TRUE=''
CC='clang -target x86_64-w64-mingw32 -B/home/zcash/depends/x86_64-w64-mingw32/native/bin'
CCDEPMODE=''
CFLAGS='-pipe -O3'
CPP=''
CPPFLAGS='-I/home/zcash/depends/x86_64-w64-mingw32/include -D_WIN32_WINNT=0x0601 '
CSCOPE='cscope'
CTAGS='ctags'
CYGPATH_W='echo'
DEFS=''
DEPDIR='.deps'
DEVPOLL_BACKEND_FALSE=''
DEVPOLL_BACKEND_TRUE=''
DLLTOOL=''
DOT_PATH=''
DOXYGEN_PAPER_SIZE=''
DSYMUTIL=''
DUMPBIN=''
DX_CONFIG=''
DX_DOCDIR=''
DX_DOT=''
DX_DOXYGEN=''
DX_DVIPS=''
DX_EGREP=''
DX_ENV=''
DX_FLAG_chi=''
DX_FLAG_chm=''
DX_FLAG_doc=''
DX_FLAG_dot=''
DX_FLAG_html=''
DX_FLAG_man=''
DX_FLAG_pdf=''
DX_FLAG_ps=''
DX_FLAG_rtf=''
DX_FLAG_xml=''
DX_HHC=''
DX_LATEX=''
DX_MAKEINDEX=''
DX_PDFLATEX=''
DX_PERL=''
DX_PROJECT=''
DX_RULES=''
ECHO_C=''
ECHO_N='-n'
ECHO_T=''
EGREP=''
ENABLE_DOXYGEN_FALSE=''
ENABLE_DOXYGEN_MAN_FALSE=''
ENABLE_DOXYGEN_MAN_TRUE=''
ENABLE_DOXYGEN_TRUE=''
EPOLL_BACKEND_FALSE=''
EPOLL_BACKEND_TRUE=''
ETAGS='etags'
EVPORT_BACKEND_FALSE=''
EVPORT_BACKEND_TRUE=''
EV_LIB_GDI=''
EV_LIB_WS32=''
EXEEXT=''
FGREP=''
GENERATE_CHI=''
GENERATE_HTML=''
GENERATE_HTMLHELP=''
GENERATE_LATEX=''
GENERATE_MAN=''
GENERATE_RTF=''
GENERATE_XML=''
GREP=''
HAVE_DOT=''
HHC_PATH=''
INSTALL_DATA='${INSTALL} -m 644'
INSTALL_LIBEVENT_FALSE=''
INSTALL_LIBEVENT_TRUE=''
INSTALL_PROGRAM='${INSTALL}'
INSTALL_SCRIPT='${INSTALL}'
INSTALL_STRIP_PROGRAM='$(install_sh) -c -s'
KQUEUE_BACKEND_FALSE=''
KQUEUE_BACKEND_TRUE=''
LD=''
LDFLAGS='-fuse-ld=lld  -L/home/zcash/depends/x86_64-w64-mingw32/lib'
LIBEVENT_GC_SECTIONS=''
LIBOBJS=''
LIBS=''
LIBTOOL=''
LIBTOOL_DEPS=''
LIPO=''
LN_S=''
LTLIBOBJS=''
LT_SYS_LIBRARY_PATH=''
MAKEINFO='${SHELL} '\''/home/zcash/depends/work/build/x86_64-w64-mingw32/libevent/2.1.12-e18ca86a2d5/build-aux/missing'\'' makeinfo'
MANIFEST_TOOL=''
MKDIR_P='/usr/bin/mkdir -p'
NM='llvm-nm'
NMEDIT=''
OBJDUMP=''
OBJEXT=''
OPENSSL_FALSE=''
OPENSSL_INCS=''
OPENSSL_LIBADD=''
OPENSSL_LIBS=''
OPENSSL_TRUE=''
OTOOL64=''
OTOOL=''
PACKAGE='libevent'
PACKAGE_BUGREPORT=''
PACKAGE_NAME='libevent'
PACKAGE_STRING='libevent 2.1.12-stable'
PACKAGE_TARNAME='libevent'
PACKAGE_URL=''
PACKAGE_VERSION='2.1.12-stable'
PAPER_SIZE=''
PATH_SEPARATOR=':'
PERL_PATH=''
PKG_CONFIG=''
POLL_BACKEND_FALSE=''
POLL_BACKEND_TRUE=''
PROJECT=''
PTHREADS_FALSE=''
PTHREADS_TRUE=''
PTHREAD_CC=''
PTHREAD_CFLAGS=''
PTHREAD_LIBS=''
RANLIB='llvm-ranlib'
SED=''
SELECT_BACKEND_FALSE=''
SELECT_BACKEND_TRUE=''
SET_MAKE=''
SHELL='/bin/bash'
SIGNAL_SUPPORT_FALSE=''
SIGNAL_SUPPORT_TRUE=''
SRCDIR=''
STRIP='x86_64-w64-mingw32-strip'
STRLCPY_IMPL_FALSE=''
STRLCPY_IMPL_TRUE=''
THREADS_FALSE=''
THREADS_TRUE=''
VERSION='2.1.12-stable'
ZLIB_LIBS=''
ZLIB_REGRESS_FALSE=''
ZLIB_REGRESS_TRUE=''
ac_ct_AR=''
ac_ct_CC=''
ac_ct_DUMPBIN=''
acx_pthread_config=''
am__EXEEXT_FALSE=''
am__EXEEXT_TRUE=''
am__fastdepCC_FALSE=''
am__fastdepCC_TRUE=''
am__include='include'
am__isrc=''
am__leading_dot='.'
am__nodep=''
am__quote=''
am__tar='$${TAR-tar} chof - "$$tardir"'
am__untar='$${TAR-tar} xf -'
bindir='${exec_prefix}/bin'
build=''
build_alias=''
build_cpu=''
build_os=''
build_vendor=''
datadir='${datarootdir}'
datarootdir='${prefix}/share'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
dvidir='${docdir}'
exec_prefix='NONE'
host='x86_64-w64-mingw32'
host_alias='x86_64-w64-mingw32'
host_cpu=''
host_os=''
host_vendor=''
htmldir='${docdir}'
includedir='${prefix}/include'
infodir='${datarootdir}/info'
install_sh='${SHELL} /home/zcash/depends/work/build/x86_64-w64-mingw32/libevent/2.1.12-e18ca86a2d5/build-aux/install-sh'
libdir='${exec_prefix}/lib'
libexecdir='${exec_prefix}/libexec'
localedir='${datarootdir}/locale'
localstatedir='${prefix}/var'
mandir='${datarootdir}/man'
mkdir_p='$(MKDIR_P)'
oldincludedir='/usr/include'
pdfdir='${docdir}'
prefix='/home/zcash/depends/x86_64-w64-mingw32'
program_transform_name='s,x,x,'
psdir='${docdir}'
runstatedir='${localstatedir}/run'
sbindir='${exec_prefix}/sbin'
sharedstatedir='${prefix}/com'
sysconfdir='${prefix}/etc'
target_alias=''

## ----------- ##
## confdefs.h. ##
## ----------- ##

/* confdefs.h */
#define PACKAGE_NAME "libevent"
#define PACKAGE_TARNAME "libevent"
#define PACKAGE_VERSION "2.1.12-stable"
#define PACKAGE_STRING "libevent 2.1.12-stable"
#define PACKAGE_BUGREPORT ""
#define PACKAGE_URL ""
#define PACKAGE "libevent"
#define VERSION "2.1.12-stable"
#define NUMERIC_VERSION 0x02010c00

configure: exit 77
@str4d str4d added A-build Area: Build system O-windows Operating system: Windows labels Oct 11, 2022
@str4d str4d added this to the Release 5.3.0 milestone Oct 11, 2022
@daira daira changed the title Ubuntu Jammy(22.04) fails to build zcash for Windows Ubuntu Jammy(22.04) and Debian 11 fail to build zcash for Windows Oct 11, 2022
@daira
Copy link
Contributor

daira commented Oct 11, 2022

This is due to clang not finding the libgcc compiler runtime library and libgcc_eh unwind library. (It is correct that these libs have "gcc" in the name even though we're using clang; see here for context.)

On my Debian 11 system (with MinGW x86-64 libs installed), adding -L/usr/lib/gcc/x86_64-w64-mingw32/10-posix to the linker flags seemed to fix the failing compilation, which led me to believe this would work (but it does not):

HOST=x86_64-w64-mingw32 LDFLAGS=-L/usr/lib/gcc/x86_64-w64-mingw32/10-posix zcutil/build.sh -j$(nproc)

@wbaby
Copy link

wbaby commented Feb 10, 2023

same problem

@wbaby
Copy link

wbaby commented Feb 12, 2023

This is due to clang not finding the libgcc compiler runtime library and libgcc_eh unwind library. (It is correct that these libs have "gcc" in the name even though we're using clang; see here for context.)

On my Debian 11 system (with MinGW x86-64 libs installed), adding -L/usr/lib/gcc/x86_64-w64-mingw32/10-posix to the linker flags seemed to fix the failing compilation, which led me to believe this would work (but it does not):

HOST=x86_64-w64-mingw32 LDFLAGS=-L/usr/lib/gcc/x86_64-w64-mingw32/10-posix zcutil/build.sh -j$(nproc)

any other solution?

@miodragpop
Copy link
Contributor

I've been able to cross build successfully on Ubuntu 22.04 by tweaking depends/hosts/mingw32.mk

@@ -2,6 +2,7 @@ mingw32_CFLAGS=-pipe
 mingw32_CXXFLAGS=$(mingw32_CFLAGS) -isystem $(host_prefix)/include/c++/v1
 
 mingw32_LDFLAGS?=-fuse-ld=lld
+mingw32_LDFLAGS+=-L/usr/lib/gcc/x86_64-w64-mingw32/$(shell x86_64-w64-mingw32-gcc -dumpversion)
 
 mingw32_release_CFLAGS=-O3
 mingw32_release_CXXFLAGS=$(mingw32_release_CFLAGS)

Not sure if this is worth of creating a pull request, but you can try adding that one line manually. Use usual HOST=x86_64-w64-mingw32 zcutil/build.sh -j$(nproc) to build. Good luck!

@miodragpop
Copy link
Contributor

@mdr0id The tweak described above works for Debian 11 as well, tested on electriccoinco/zcashd-build-debian11v2:latest docker image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-build Area: Build system O-windows Operating system: Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants