Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 633612 - dev-libs/libpcre2: please review Cygwin patch
Summary: dev-libs/libpcre2: please review Cygwin patch
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: Prefix Support (show other bugs)
Hardware: AMD64 Other
: Normal normal (vote)
Assignee: Lars Wendler (Polynomial-C) (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-06 12:07 UTC by Pietro
Modified: 2018-06-20 09:09 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
libpcre2-10.30.ebuild emerge info build error (file_633612.txt,44.78 KB, text/plain)
2017-10-06 12:07 UTC, Pietro
Details
Enable build in a gentoo prefix on cygwin (enable_build_on_cygwin_prefix.patch,950 bytes, patch)
2017-12-14 15:35 UTC, Sven Eden
Details | Diff
proposed patch for dev-libs/libpcre2 (0001-dev-libs-libpcre2-fix-cygwin-build.patch,1.82 KB, patch)
2018-01-17 15:25 UTC, Michael Haubenwallner (RETIRED)
Details | Diff
proposed patch for dev-libs/libpcre2-10.31 (0001-dev-libs-libpcre2-fix-cygwin-build.patch,1.61 KB, patch)
2018-06-20 08:40 UTC, Michael Haubenwallner (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pietro 2017-10-06 12:07:46 UTC
Created attachment 497836 [details]
libpcre2-10.30.ebuild emerge info build error

Hello,

I want to report a compile issue I am facing with a fresh built gentoo-prefix under Cygwin64 and Windows 7 Professional.

The lib failing to compile is libpcre2-10.30 and gentoo-prefix has been compiled using the regular bootstrap-prefix.sh script.

From what I can understand the error is the following: " error: '_O_BINARY' undeclared (first use in this function) _setmode(_fileno(stdout), _O_BINARY);"

Find attached `emerge -pqv '=dev-libs/libpcre2-10.30::gentoo_prefix'` and gentoo/var/tmp/portage/dev-libs/libpcre2-10.30/temp/build.log' log file.

Please let me know if more info or troubleshooting is needed from my end.

Regards,
Pietro
Comment 1 Guilherme Amadio gentoo-dev 2017-10-09 08:19:18 UTC
(In reply to Pietro from comment #0)
> From what I can understand the error is the following: " error: '_O_BINARY'
> undeclared (first use in this function) _setmode(_fileno(stdout),
> _O_BINARY);"

Dear Pietro,

You may need to patch libpcre2 to change _O_BINARY (windows) to O_BINARY (posix) or vice-versa, depending on how the code was written. You can try adding a `#define _O_BINARY O_BINARY` in the header that you see the failure.

Hope that helps.
Comment 2 Pietro 2017-10-20 09:39:23 UTC
(In reply to Guilherme Amadio from comment #1)
> (In reply to Pietro from comment #0)
> > From what I can understand the error is the following: " error: '_O_BINARY'
> > undeclared (first use in this function) _setmode(_fileno(stdout),
> > _O_BINARY);"
> 
> Dear Pietro,
> 
> You may need to patch libpcre2 to change _O_BINARY (windows) to O_BINARY
> (posix) or vice-versa, depending on how the code was written. You can try
> adding a `#define _O_BINARY O_BINARY` in the header that you see the failure.
> 
> Hope that helps.

Hello Guilherme,

thank you for getting back to me and I do apologize for the extremely late reply. For some reason your reply got lost in my email box.

Unfortunately I know nothing about code and I highly doubt I could figure this out on my own.

Do you think that dev-libs/libpcre2 Gentoo maintainer could help us out with this? 

Best Regards,
Pietro Sammarco
Comment 3 Sven Eden 2017-12-14 15:30:00 UTC
I just had this on Windows 10, cygwin-2.90 (with gentoo fork patch) and a fresh gentoo prefix install.

The reason is, that libpcre2 assumes __CYGWIN__ to be windows (generally correct), and that windows headers are then needed.

That is true for Plain Cygwin, but not for Cygwin-on-steroids (aka Gentoo Prefixed).

I'll attach a patch that will make it work and cleanly merge in A Cygwin Gentoo Prefix. That patch is only needed in the prefix, as libpcre2 *should* build fine on standard Cygwin.
Comment 4 Sven Eden 2017-12-14 15:35:31 UTC
Created attachment 510034 [details, diff]
Enable build in a gentoo prefix on cygwin

This patch generally states that windows stuff is only needed if __CYGWIN__ is *not* defined. This will make sure that the build will (AFAIK) fail on MinGW and plain cygwin, so only apply in a gentoo prefix.

Fastest way to use, as libpcre2 does not support user patches is:

$ ebuild /gentoo/usr/portage/dev-libs/libpcre2/libpcre2-10.30.ebuild prepare
$ cd /gentoo/var/tmp/portage/dev-libs/libpcre2-10.30/work/pcre2-10.30
$ patch -p 1 -i /etc/portage/patches/dev-libs/pcre2-10.30/enable_build_on_cygwin_prefix.patch
$ cd
$ ebuild /gentoo/usr/portage/dev-libs/libpcre2/libpcre2-10.30.ebuild merge
Comment 5 Michael Haubenwallner (RETIRED) gentoo-dev 2018-01-17 15:23:59 UTC
Well, my first thought is that WIN32 actually shouldn't be defined with Cygwin at all.

Then I found this upstream bug report:
https://bugs.exim.org/show_bug.cgi?id=2152

And indeed, not defining WIN32 with Cygwin does help here.
Comment 6 Michael Haubenwallner (RETIRED) gentoo-dev 2018-01-17 15:25:13 UTC
Created attachment 515160 [details, diff]
proposed patch for dev-libs/libpcre2
Comment 7 Michael Haubenwallner (RETIRED) gentoo-dev 2018-01-17 15:30:12 UTC
Please review this patch for Cygwin, proposed upstream in
https://bugs.exim.org/show_bug.cgi?id=2152#c13
Thanks!
Comment 8 Sven Eden 2018-01-18 09:04:10 UTC
(In reply to Michael Haubenwallner from comment #7)
> Please review this patch for Cygwin, proposed upstream in
> https://bugs.exim.org/show_bug.cgi?id=2152#c13
> Thanks!

The patch looks good to me.
Only the Bugzilla "diff" view is screwed, if anybody wonders.

--------

I have to correct myself. While working on a lot packages to play nicely with my gentoo prefixed cygwin, I had to do quite some research and came along some interesting information I wasn't aware of.

For instance the "cmake battle" between the cygwin folk and the cmake developers. (This thread: https://cmake.org/pipermail/cmake/2010-October/040353.html ) from 2010 is most telling.

My favourite quote is from Yaakov:
> We are the distributors of Cygwin.  We make Cygwin as a very capable
> *NIX/X11 platform.  We do not want WIN32 defined on Cygwin.  Period.

The conclusion, and cmake folks eventually gave in, is the following:

A) Some WIN32 details are true for Cygwin, too, because it has to use the Windows kernel and library loader.
B) Cygwin is *NOT* WIN32 everywhere else
C) Cygwin is as much POSIX/UNIX as it can be (apart from A)
Comment 9 Michael Haubenwallner (RETIRED) gentoo-dev 2018-06-20 08:40:43 UTC
Created attachment 536498 [details, diff]
proposed patch for dev-libs/libpcre2-10.31

The patch is committed upstream now:
https://bugs.exim.org/show_bug.cgi?id=2152#c14
https://vcs.pcre.org/pcre2?view=revision&revision=939
Comment 10 Larry the Git Cow gentoo-dev 2018-06-20 09:09:34 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fef0e0c22854d149001db13f0e8872c87a6bf68f

commit fef0e0c22854d149001db13f0e8872c87a6bf68f
Author:     Michael Haubenwallner <haubi@gentoo.org>
AuthorDate: 2018-01-17 15:21:25 +0000
Commit:     Lars Wendler <polynomial-c@gentoo.org>
CommitDate: 2018-06-20 09:09:25 +0000

    dev-libs/libpcre2: fix cygwin build
    
    Closes: https://bugs.gentoo.org/633612
    Package-Manager: Portage-2.3.13, Repoman-2.3.3
    Closes: https://github.com/gentoo/gentoo/pull/8918

 dev-libs/libpcre2/files/libpcre2-10.31-cygwin.patch | 16 ++++++++++++++++
 dev-libs/libpcre2/libpcre2-10.31.ebuild             |  4 ++++
 2 files changed, 20 insertions(+)