After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 767463 - windows static build broken (regression)
windows static build broken (regression)
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Windows
: Normal blocker
: 1.9.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-06-09 16:47 UTC by Tim-Philipp Müller
Modified: 2016-06-24 13:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gstconfig.h.in: only use __declspec(dllimport|export) for non-static compilation (1.44 KB, patch)
2016-06-09 16:56 UTC, Tim-Philipp Müller
none Details | Review

Description Tim-Philipp Müller 2016-06-09 16:47:45 UTC
static build fails on buildbot:

libtool: link: i686-w64-mingw32-gcc -std=gnu99 -I../../../libs -I../../.. -I../../../libs -I../../.. -mms-bitfields -I/var/lib/jenkins/workspace/cerbero-cross-mingw32/workdir/dist/windows_x86/include/glib-2.0 -I/var/lib/jenkins/workspace/cerbero-cross-mingw32/workdir/dist/windows_x86/lib/glib-2.0/include -DG_THREADS_MANDATORY -DG_DISABLE_DEPRECATED -Wall -Wdeclaration-after-statement -Wvla -Wpointer-arith -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wundef -Wwrite-strings -Wformat-nonliteral -Wformat-security -Wold-style-definition -Winit-self -Wmissing-include-dirs -Waddress -Waggregate-return -Wno-multichar -Wnested-externs -g -DGST_DISABLE_DEPRECATED -Werror -Wall -g -O2 -DWINVER=0x0501 -D_WIN32_WINNT=0x0501 -Wno-error -fPIC -DPIC -o gst-completion-helper-1.0.exe gst_completion_helper_1.0-gst-completion-helper.o  -L/var/lib/jenkins/workspace/cerbero-cross-mingw32/workdir/dist/windows_x86/lib ../../../gst/.libs/libgstreamer-1.0.a /var/lib/jenkins/workspace/cerbero-cross-mingw32/workdir/dist/windows_x86/lib/libgobject-2.0.dll.a /var/lib/jenkins/workspace/cerbero-cross-mingw32/workdir/dist/windows_x86/lib/libffi.dll.a /var/lib/jenkins/workspace/cerbero-cross-mingw32/workdir/dist/windows_x86/lib/libgmodule-2.0.dll.a /var/lib/jenkins/workspace/cerbero-cross-mingw32/workdir/dist/windows_x86/lib/libglib-2.0.dll.a -lws2_32 -lole32 -lwinmm -lshlwapi /var/lib/jenkins/workspace/cerbero-cross-mingw32/workdir/dist/windows_x86/lib/libintl.dll.a -L/var/lib/jenkins/workspace/cerbero-cross-mingw32/workdir/dist/windows_x86/lib -L/var/lib/jenkins/workspace/cerbero-cross-mingw32/workdir/dist/windows_x86/lib
gst_plugin_scanner-gst-plugin-scanner.o: In function `main':
/var/lib/jenkins/workspace/cerbero-cross-mingw32/workdir/sources/windows_x86/gstreamer-1.0-static-1.9/libs/gst/helpers/gst-plugin-scanner.c:50: undefined reference to `_imp___gst_disable_registry_cache'
collect2: error: ld returned 1 exit status
Comment 1 Tim-Philipp Müller 2016-06-09 16:56:24 UTC
Created attachment 329488 [details] [review]
gstconfig.h.in: only use __declspec(dllimport|export) for non-static compilation

My understanding is that we need something like this, question is just where/when exactly to set GST_STATIC_COMPILATION.
Comment 2 Nirbheek Chauhan 2016-06-10 13:49:24 UTC
What's happening is that linking executables is failing because libtool can only find static libraries to link to, and the header has declarations for a shared library. So to fix this on the build bot, all we need to do is set GST_STATIC_COMPILATION when we have --enable-static --disable-shared.

I will note that consumers of gstreamer on Windows that need to link to gstreamer statically will have to define this in their build systems as well, so we should add a comment mentioning this to the macro definition.

AFAIK, there is no way around this and every other project has the same requirement. Windows is unique in being a platform that requires different prototype declarations for symbols in static and shared libraries.

One note about the patch. We can just do this:

- #ifdef _WIN32
+ #if defined(_WIN32) && !defined(GST_STATIC_COMPILATION)

instead of nesting the check.

I'll cook up a patch for this soon.
Comment 3 Tim-Philipp Müller 2016-06-24 00:17:03 UTC
Core:

commit 54fa564e012aa2f5aeac7fce9a6df0f592724eb3
Author: Nirbheek Chauhan <nirbheek@centricular.com>
Date:   Fri Jun 24 05:26:09 2016 +0530

    gstconfig.h: Don't use extern with dllexport
    
    GCC emits an error for this with -Werror:
    
    plugin.c:22:1: error: 'gst_plugin_desc' initialized and declared 'extern' [-Werror]
    
    This matches how glib does symbol exporting.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=767463

commit 48088867db20094c8aafc7f50ce1bc0d8c633df5
Author: Nirbheek Chauhan <nirbheek@centricular.com>
Date:   Tue Jun 21 19:49:15 2016 +0530

    win32: Don't use dllexport/import when only building statically
    
    If the prototypes in the public API have dllimport in them when building
    statically on Windows, the compiler will look for symbols with symbol
    mangling and indirection corresponding to a DLL. This will cause a build
    failure when trying to link tests/examples/etc.
    
    External users of GStreamer also need to define -DGST_STATIC_COMPILATION
    if they want to link to static gstreamer libraries on Windows.
    
    A similar version of this patch has been committed to all gstreamer
    repositories.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=767463


-base:

commit d5ceb7ebb8b3d0cd033a7e963a84aaec4c542cb8
Author: Nirbheek Chauhan <nirbheek@centricular.com>
Date:   Fri Jun 24 01:56:11 2016 +0530

    configure: Need to add -DGST_STATIC_COMPILATION when building only statically
    
    https://bugzilla.gnome.org/show_bug.cgi?id=767463



-bad: 

commit 539c032345e3f063b5c166262aa7f7346a0d1e2f
Author: Nirbheek Chauhan <nirbheek@centricular.com>
Date:   Fri Jun 24 01:57:13 2016 +0530

    configure: Need to add -DGST_STATIC_COMPILATION when building only statically
    
    https://bugzilla.gnome.org/show_bug.cgi?id=767463



rtsp-server:

commit fc4f171f0fdfbbd164137dfd0ed687809fafa757
Author: Nirbheek Chauhan <nirbheek@centricular.com>
Date:   Fri Jun 24 02:02:20 2016 +0530

    configure: Need to add -DGST_STATIC_COMPILATION when building only statically
    
    https://bugzilla.gnome.org/show_bug.cgi?id=767463


Let's see how that plays out on the build servers..
Comment 4 Tim-Philipp Müller 2016-06-24 13:59:15 UTC
Bots seem happy now.