-
Notifications
You must be signed in to change notification settings - Fork 973
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
fix semi-static build flags for Win32/MSYS2 #1032
Conversation
Signed-off-by: tothi <[email protected]>
@@ -57,6 +57,8 @@ if(BUILD_STATIC) | |||
set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lcrypt32") | |||
# And sockets | |||
set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lws2_32") | |||
# And others | |||
set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lp11-kit -lidn2 -lunistring") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This unfortunately breaks some setups, including ours. Are these optional dependencies of GnuTLS?
@@ -130,7 +132,7 @@ if(BUILD_STATIC_GCC) | |||
set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -Wl,-z -Wl,muldefs -Wl,-Bstatic -ltsan -Wl,-Bdynamic -ldl -lm") | |||
endif() | |||
if(WIN32) | |||
set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -lmingw32 -lgcc_eh -lgcc -lmoldname -lmingwex -lmsvcrt") | |||
set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -lmingw32 -lgcc_eh -lgcc -lmoldname -lmingwex -lmsvcrt -lpthread") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pthread isn't used on Windows. Why was this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idk exactly, but without pthread linking of convperf.exe
fails in my setup (idk what is it and/or why it is needed):
[ 92%] Building CXX object tests/perf/CMakeFiles/fbperf.dir/__/__/vncviewer/Surface_Win32.cxx.obj
[ 93%] Linking CXX executable fbperf.exe
[ 93%] Built target fbperf
Scanning dependencies of target decperf
[ 94%] Building CXX object tests/perf/CMakeFiles/decperf.dir/decperf.cxx.obj
[ 94%] Linking CXX executable decperf.exe
[ 94%] Built target decperf
Scanning dependencies of target convperf
[ 95%] Building CXX object tests/perf/CMakeFiles/convperf.dir/convperf.cxx.obj
[ 95%] Linking CXX executable convperf.exe
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/libgcc_eh.a(emutls.o):(.text+0x71): undefined reference to `pthread_key_create'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/libgcc_eh.a(emutls.o):(.text+0xad): undefined reference to `pthread_getspecific'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/libgcc_eh.a(emutls.o):(.text+0xf7): undefined reference to `pthread_once'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/libgcc_eh.a(emutls.o):(.text+0x157): undefined reference to `pthread_setspecific'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/libgcc_eh.a(emutls.o):(.text+0x21f): undefined reference to `pthread_setspecific'
collect2.exe: error: ld returned 1 exit status
make[2]: *** [tests/perf/CMakeFiles/convperf.dir/build.make:110: tests/perf/convperf.exe] Error 1
make[1]: *** [CMakeFiles/Makefile2:979: tests/perf/CMakeFiles/convperf.dir/all] Error 2
make: *** [Makefile:150: all] Error 2
building on Windows 10 using MSYS2 (Mingw64).
FWIW, I have to make the exact same changes when I build the nightlies and
the release binaries using MXE, so I'm in favor of this PR
…On Fri, May 29, 2020 at 7:34 AM Pierre Ossman (Work account) < ***@***.***> wrote:
***@***.**** requested changes on this pull request.
------------------------------
In cmake/StaticBuild.cmake
<#1032 (comment)>:
> @@ -57,6 +57,8 @@ if(BUILD_STATIC)
set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lcrypt32")
# And sockets
set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lws2_32")
+ # And others
+ set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lp11-kit -lidn2 -lunistring")
This unfortunately breaks some setups, including ours. Are these optional
dependencies of GnuTLS?
------------------------------
In cmake/StaticBuild.cmake
<#1032 (comment)>:
> @@ -130,7 +132,7 @@ if(BUILD_STATIC_GCC)
set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -Wl,-z -Wl,muldefs -Wl,-Bstatic -ltsan -Wl,-Bdynamic -ldl -lm")
endif()
if(WIN32)
- set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -lmingw32 -lgcc_eh -lgcc -lmoldname -lmingwex -lmsvcrt")
+ set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -lmingw32 -lgcc_eh -lgcc -lmoldname -lmingwex -lmsvcrt -lpthread")
pthread isn't used on Windows. Why was this needed?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1032 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB45M3ORGDCVQVQT6AG5WUDRT6MULANCNFSM4NITUPXQ>
.
|
Sorry, slight correction - here are the changes that I make: --- a/cmake/StaticBuild.cmake 2019-12-20 02:02:02.000000000 -0500
+++ b/cmake/StaticBuild.cmake 2019-12-22 13:34:57.350524347 -0500
@@ -23,7 +23,7 @@
# gettext is included in libc on many unix systems
if(NOT LIBC_HAS_DGETTEXT)
- set(GETTEXT_LIBRARIES "-Wl,-Bstatic -lintl -liconv -Wl,-Bdynamic")
+ set(GETTEXT_LIBRARIES "-Wl,-Bstatic -lidn2 -lintl -lunistring -liconv -Wl,-Bdynamic")
if(APPLE)
set(GETTEXT_LIBRARIES "${GETTEXT_LIBRARIES} -framework Carbon")
endif()
@@ -130,7 +130,7 @@
set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -Wl,-z -Wl,muldefs -Wl,-Bstatic -ltsan -Wl,-Bdynamic -ldl -lm")
endif()
if(WIN32)
- set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -lmingw32 -lgcc_eh -lgcc -lmoldname -lmingwex -lmsvcrt")
+ set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -lmingw32 -lgcc_eh -lgcc -lmoldname -lmingwex -lmsvcrt -lpthread")
set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -luser32 -lkernel32 -ladvapi32 -lshell32")
# mingw has some fun circular dependencies that requires us to link
# these things again It's GETTEXT that I need to add those libs to, not GNUTLS |
ok, trying to make this clearer: why i had to include these flags. used MSYS2 platform for building on Windows 10, mingw64 environment exactly. tried to follow the guidelines in BUILDING.txt file, prepared the config with
started the build with
what i have done is nothing more than just added the libraries related to the missing references (without any deeper analysis of the cause of the problem) in order to completely build the semi-static binaries without any errors. if you need any more files, logs, etc. just tell me, i try to include. |
Seems to be several issues here, so let's try to get one sorted at a time. For GnuTLS it seems that idn2 and p11-kit are optional dependencies. We would need to detect that at build time somehow. Most likely the same approach as we do for nettle and such. Could you test this patch: diff --git a/cmake/StaticBuild.cmake b/cmake/StaticBuild.cmake
index 97cfcb27..ebb23678 100644
--- a/cmake/StaticBuild.cmake
+++ b/cmake/StaticBuild.cmake
@@ -38,6 +38,12 @@ if(BUILD_STATIC)
FIND_LIBRARY(TASN1_LIBRARY NAMES tasn1 libtasn1
HINTS ${PC_GNUTLS_LIBDIR} ${PC_GNUTLS_LIBRARY_DIRS})
+ # And a bunch of optional dependencies
+ FIND_LIBRARY(IDN2_LIBRARY NAMES idn2 libidn2
+ HINTS ${PC_GNUTLS_LIBDIR} ${PC_GNUTLS_LIBRARY_DIRS})
+ FIND_LIBRARY(P11KIT_LIBRARY NAMES p11-kit libp11-kit
+ HINTS ${PC_GNUTLS_LIBDIR} ${PC_GNUTLS_LIBRARY_DIRS})
+
set(GNUTLS_LIBRARIES "-Wl,-Bstatic -lgnutls")
if(TASN1_LIBRARY)
@@ -49,6 +55,12 @@ if(BUILD_STATIC)
if(GCRYPT_LIBRARY)
set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lgcrypt -lgpg-error")
endif()
+ if(IDN2_LIBRARY)
+ set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lidn2")
+ endif()
+ if(P11KIT_LIBRARY)
+ set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -lp11-kit")
+ endif()
set(GNUTLS_LIBRARIES "${GNUTLS_LIBRARIES} -Wl,-Bdynamic")
The build probably won't succeed, but let's see how the errors progress. |
#1039 has now been merged, so this should hopefully be fixed via that PR. |
Signed-off-by: tothi [email protected]