Bug 130219

Summary: kdelibs Cygwin build patch
Product: [Unmaintained] kdelibs Reporter: Yaakov Selkowitz <yselkowi>
Component: generalAssignee: kdelibs bugs <kdelibs-bugs>
Status: RESOLVED UNMAINTAINED    
Severity: normal CC: faure
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Cygwin   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: kdelibs-3.5.3 Cygwin patch
kdelibs-4.0.99 Cygwin patch
4.0.99 Cygwin KLibLoader patch
4.0.99 Cygwin KLibLoader patch (take 2)
KLibLoader Cygwin patch
Cygwin OpenSSL patch
Cygwin socklen_t patch
No getgrouplist on Cygwin
Cygwin CMake patch
Cygwin executablePrefix patch
No HAL on Cygwin

Description Yaakov Selkowitz 2006-07-03 22:11:42 UTC
Version:            (using KDE KDE 3.5.3)
Installed from:    Compiled From Sources
OS:                Cygwin

I'm attaching a patch which fixes numerous issues building kdelibs-3.5.3 for Cygwin.  This patch may depend on my patch for admin/acinclude.m4.in in bug 130215.
Comment 1 Yaakov Selkowitz 2006-07-03 22:12:02 UTC
Created attachment 16878 [details]
kdelibs-3.5.3 Cygwin patch
Comment 2 FiNeX 2008-06-18 23:41:09 UTC
Is KDE4 compiling right on Cygwin?
Comment 3 Yaakov Selkowitz 2008-06-19 00:41:34 UTC
> Is KDE4 compiling right on Cygwin?

I haven't tried yet.
Comment 4 Yaakov Selkowitz 2008-07-21 23:42:58 UTC
Created attachment 26321 [details]
kdelibs-4.0.99 Cygwin patch

Here's a *first run* at KDE 4.1 (RC1); it may need further work.  (It requires
patches to CMake and Qt4 as well, as found in Cygwin Ports.)

* cmake/modules/FindAutomoc4.cmake: Actually search for AUTOMOC4_EXECUTABLE.
* cmake/modules/FindKDE4Internal.cmake: Respect CMAKE_EXECUTABLE_SUFFIX for
Cygwin.
* cmake/modules/KDE4Macros.cmake: Cygwin looks for libraries in PATH.
* kdecore/network/k3socks.h: Cygwin now defines socklen_t.
* kdecore/network/k3sockssocketdevice.cpp: Ditto.
* kdecore/network/netsupp.h: Ditto.
* kio/kio/slaveinterface_p.h: include <sys/time.h> for struct timeval.
* kio/kssl/kopenssl.cpp: Update OpenSSL library paths for Cygwin.
* kjs/collector.cpp: Support Cygwin, which doesn't have pthread_getattr_np.
* kpty/kpty.cpp: Use struct utmpx only if HAVE_LOGINX. (Cygwin has the former
but not the latter.)
* kpty/kptydevice.cpp: Use TIOCINQ for FIONREAD on Cygwin.
Comment 5 Yaakov Selkowitz 2008-07-22 05:57:59 UTC
Created attachment 26323 [details]
4.0.99 Cygwin KLibLoader patch

Here's a patch to fix plugin loading; it is in addition to the first patch.

* kdecore/tests/klibloadertest.cpp (KLibLoaderTest::testFindLibrary): Use .dll
on Cygwin.
* kdecore/util/klibloader.cpp (fixLibPrefix): Adapt for Cygwin.
* kdecore/util/kpluginloader.cpp (makeLibName): Use .dll on Cygwin.
(findLibraryInternal): Use fixLibPrefix on Cygwin.
Comment 6 Stephan Kulow 2008-07-22 09:50:26 UTC
don't expect me to review them. But I don't know a good alternative assignee either ;( 

At least I would split out the cmake stuff and file it against build system.
Comment 7 Yaakov Selkowitz 2008-07-22 12:01:11 UTC
Re: comment 6
> don't expect me to review them. But I don't know a good alternative assignee 
> either ;(

The only things (non-cmake) that would affect anything but cygwin are:

* kio/kio/slaveinterface_p.h: #include <sys/time.h>.
POSIX requires struct timeval to be defined in <sys/time.h>.  AFAIK, even MinGW has it.

* kpty/kpty.cpp: Use struct utmpx only if HAVE_LOGINX.
This patch should be looked over to be sure it won't break other platforms.

Everything else is #ifdef Q_OS_CYGWIN, so they won't affect anyone else.

Would you prefer if I break out the patches into related groups?

> At least I would split out the cmake stuff and file it against build system. 

Fair enough.
Comment 8 Harri Porten 2008-07-22 23:09:33 UTC
Applied the patch for kjs/collector.cpp.
Comment 9 Yaakov Selkowitz 2008-07-23 05:53:49 UTC
Created attachment 26350 [details]
4.0.99 Cygwin KLibLoader patch (take 2)

Found a few more cases in the KLibLoader code that needed fixing.  This patch
replaces the last one.
Comment 10 Patrick Spendrin 2008-07-23 11:56:04 UTC
seems ok so far, I can't see any problems
There will probably be a lot more stuff that needs fixing for cygwin.
Comment 11 Oswald Buddenhagen 2008-07-29 23:51:12 UTC
the loginx vs utmpx stuff is pretty convoluted. i think one platform uses login with utmpx (or was is the other way round?).

what sense does that make?

+#ifdef Q_OS_CYGWIN
+    char *str_ptr = d->ttyName.data();
+#else
     const char *str_ptr = d->ttyName.data();
+#endif
Comment 12 Yaakov Selkowitz 2008-07-30 04:10:51 UTC
Re: comment 11
> the loginx vs utmpx stuff is pretty convoluted. i think one platform uses 
> login with utmpx (or was is the other way round?).

Looks like the loginx stuff was added in bug 156197 for NetBSD, quoting the OP:

> login() works with struct utmp's whereas loginx() is what you use 
> with struct utmpx's

Cygwin has both struct utmp and struct utmpx, but has only login (struct utmp *), as apparently Linux does as well.

But in this case with the original code, unless you're using utempter (which at least Debian does not have), then you would be passing a struct utmpx * to login.  Here's a simple test case:

#include <utmp.h>
#include <utmpx.h>

int main (void) {
    struct utmpx l_struct;
    login (&l_struct);
    return 0;
}

When I try this in C on both Cygwin and Linux, I just get a warning:

$ gcc -Wall -c test.c
test.c: In function `main':
test.c:6: warning: passing arg 1 of `login' from incompatible pointer type

But when I make this a C++ file and use ::login instead (as the source in question does), I get errors:

## Linux 2.6.9 i686, gcc 3.4.6
$ g++ -Wall -c test.cpp 
test.cpp: In function `int main()':
test.cpp:6: error: cannot convert `utmpx*' to `const utmp*' for argument `1' to `void login(const utmp*)'

## Cygwin 1.5.25-15, gcc 3.4.4
$ g++ -Wall -c test.cpp 
test.cpp: In function `int main()':
test.cpp:6: error: cannot convert `utmpx*' to `utmp*' for argument `1' to `void login(utmp*)'

So I see a difference in const-ness (which I'll raise with the Cygwin devs), but either way you can't pass utmpx to login on either Cygwin or Linux.

But this code must have worked on Linux before.  So what am I missing here?
Comment 13 Yaakov Selkowitz 2009-07-02 05:07:34 UTC
For anyone tracking this, I've managed to build just about everything for 4.2.4 (except for kdebase-workspace) built and mostly working.

The following patches apply to both 4.2.4 and 4.2.95, although they may have originally been made earlier.  I'll explain each one separately.
Comment 14 Yaakov Selkowitz 2009-07-02 05:11:25 UTC
Created attachment 34985 [details]
KLibLoader Cygwin patch

* kdecore/tests/klibloadertest.cpp (testFindLibrary):
* kdecore/util/kpluginloader.cpp (makeLibName): Use .dll extension on Cygwin.
Comment 15 Yaakov Selkowitz 2009-07-02 05:16:34 UTC
Created attachment 34986 [details]
Cygwin OpenSSL patch

* kio/kssl/kopenssl.cpp (KOpenSSLProxy) [__CYGWIN__]: Update to currently available openssl libraries, and remove ancient versions.
Comment 16 Yaakov Selkowitz 2009-07-02 05:21:18 UTC
Created attachment 34987 [details]
Cygwin socklen_t patch

* kdecore/network/k3socks.h:
* kdecore/network/k3sockssocketdevice.cpp:
* kdecore/network/netsupp.h: Cygwin long ago declared its own socklen_t.
Comment 17 Yaakov Selkowitz 2009-07-02 05:47:48 UTC
Created attachment 34988 [details]
No getgrouplist on Cygwin

* kio/kfile/kpropertiesdialog.cpp: Cygwin does not provide getgrouplist(3).
Comment 18 Yaakov Selkowitz 2009-07-02 06:17:42 UTC
Created attachment 34989 [details]
Cygwin CMake patch

* cmake/modules/FindKDE4Internal.cmake [_kdeBootStrapping]: Account for CMAKE_EXECUTABLE_SUFFIX in KDE4_*_EXECUTABLE .shell names, since that is how they are created.

* cmake/modules/KDE4Macros.cmake (KDE4_HANDLE_RPATH_FOR_EXECUTABLE): Cygwin uses $PATH for runtime library resolution.

(KDE4_ADD_PLUGIN) [WITH_PREFIX]: Force the prefix to "lib" so that the plugin name is sure to match the init_ symbol exactly.

* cmake/modules/SIPMacros.cmake (ADD_SIP_PYTHON_MODULE): Python modules should be MODULE, not SHARED, so they are installed correctly and not create import libs on Win32/Cygwin.

* kross/qts/CMakeLists.txt: Whie krossqtsplugin needs to be SHARED rather than MODULE so that we can link krossqtstest against it, don't version it so that it still has the correct name on non-ELF platforms.
Comment 19 Yaakov Selkowitz 2009-07-02 06:19:49 UTC
That's all I have at this time.
Comment 20 Yaakov Selkowitz 2009-07-02 19:45:43 UTC
habacker has committed these patches to trunk, except he made parts of the cmake patch conditional on CYGWIN.  

http://websvn.kde.org/trunk/KDE/kdelibs/cmake/modules/SIPMacros.cmake?r1=990262&r2=990261&pathrev=990262
http://websvn.kde.org/trunk/KDE/kdelibs/kross/qts/CMakeLists.txt?r1=990266&r2=990265&pathrev=990266

Certainly WIN32 needs these as well, but I see no reason to special-case these changes; could someone confirm that this would have no negative effect on UNIX?

As these are bug fixes and essentially affect only Cygwin, could they be  committed to 4.3 branch as well?
Comment 21 Yaakov Selkowitz 2009-07-03 11:21:13 UTC
Created attachment 35012 [details]
Cygwin executablePrefix patch

* kdecore/kernel/kstandarddirs.cpp: use the executablePrefix() code on Cygwin as well.
Comment 22 Yaakov Selkowitz 2009-07-03 11:24:19 UTC
Created attachment 35013 [details]
No HAL on Cygwin

* solid/solid/CMakeLists.txt:
* solid/solid/managerbase.cpp: HAL isn't supported on Cygwin, so disable the backend.
Comment 23 David Faure 2010-09-01 22:45:28 UTC
I'm surprised by comment #21; cygwin implements /proc on Windows??

More generally, I'm not sure if sending N patches in one bug report is really convenient, at this point I have no idea what would be needed to close this. Maybe better to use kde-core-devel and/or reviewboard for this?
Comment 24 Andrew Crouthamel 2018-11-10 03:22:40 UTC
Dear Bug Submitter,

This bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version? I am setting the status to NEEDSINFO pending your response, please change the Status back to REPORTED when you respond.

Thank you for helping us make KDE software even better for everyone!
Comment 25 Yaakov Selkowitz 2018-11-12 06:31:25 UTC
kdelibs is no longer being developed.