Issue 8383 - msys build error "portable.h:1116:19: error: two or more data types in declaration specifiers"
Summary: msys build error "portable.h:1116:19: error: two or more data types in declar...
Status: VERIFIED FIXED
Alias: None
Product: OpenLDAP
Classification: Unclassified
Component: slapd (show other issues)
Version: 2.4.44
Hardware: All All
: --- normal
Target Milestone: 2.4.50
Assignee: OpenLDAP project
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-08 08:42 UTC by fixed-term.asal.mirzaieva@boschrexroth.de
Modified: 2020-04-28 16:56 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description fixed-term.asal.mirzaieva@boschrexroth.de 2016-03-08 08:42:55 UTC
Full_Name: Asal Mirzaieva
Version: 2.4.44
OS: Windows 7
URL: http://paste.ubuntu.com/15326640/, http://paste.ubuntu.com/15326646/, http://paste.ubuntu.com/15326655/
Submission from: (NULL) (194.39.218.10)


When building openldap on windows, using msys and mingw (mingw32 v4.9.3) the
following error appears:

In file included from base64.c:38:0:../../include/portable.h:1116:19: error: two
or more data types in declaration specifiers
 #define socklen_t int

Steps to reproduce the bug:
1. Install Mingw32 with mingw-get-setup.exe.
2. Launch msys.bat in msys folder to open msys console.
3. Download and install Spencer's regex in /usr/local
4. Download openldap-2.4.44
5. Unzip and untar the openldap and go to the openldap-2.4.44's directory
6. Run configure as follows
./configure CFLAGS="-I/usr/local/include/rxspencer" LDFLAGS=2-2-L/usr/local/lib"
LIBS="-static -lrxspencer" --enable-static --disable-shared --disable-slapd
--disable-bdb --disable-hdb
7. Run make depend
8. Run make
9. Get the error, that was described above.

I haven't tried to reproduce this bug with other PCs/OS versions/MinGW
versions.
Workaround: after commenting the line 1116 in include/portable.h the error was
gone and I was able to successfully build and use openldap. Well, "successfully"
means, I could link it statically and run ldap_initialize(), but not
ldap_sals_bind(), because I haven't installed SASL.
Comment 1 Ryan Tandy 2019-09-01 19:14:11 UTC
I've run into this myself while trying to test ITS#9069 on Windows.

In my MinGW environment, <sys/socket.h> does not define socklen_t, so 
portable.h:1116 does '#define socklen_t int'. However, <ac/socket.h> 
includes <ws2tcpip.h> which does typedef socklen_t.

base64.c includes "portable.h" first and then <ac/socket.h> later. This 
second include triggers the error as the original typedef essentially 
becomes "typedef int int".

I think we can fix it by searching the Windows header as well, avoiding 
the #define appearing in "portable.h".

https://github.com/openldap/openldap/compare/openldap:master...rtandy:its8383.patch

Comment 2 Quanah Gibson-Mount 2020-03-22 07:53:36 UTC
Ryan,

That branch no longer exists in your git repo.  Did this already get fixed as something else?
Comment 3 Ryan Tandy 2020-03-22 16:31:07 UTC
(In reply to Quanah Gibson-Mount from comment #2)
> That branch no longer exists in your git repo.  Did this already get fixed
> as something else?

I moved my personal fork to Gitlab. New URL: https://git.openldap.org/ryan/openldap/-/compare/master...its8383
Comment 4 Ryan Tandy 2020-04-02 23:26:36 UTC
Thanks Quanah for spending some time on this with me. I note this bug occurs under MSYS2 when running the "MSYS2 MinGW 64-bit" environment (MSYSTEM=MINGW64). It does not occur under the "MSYS2 MSYS" environment (MSYSTEM=MSYS).

Quanah's build system seems a bit unique (MSYSTEM=MSYS but adding /mingw64/bin to PATH, possibly other differences too). I think my patch is a correct fix for people wanting to build under a pure MinGW environment.
Comment 5 Quanah Gibson-Mount 2020-04-03 17:01:14 UTC
Commits: 
  • 27545be4 
by Ryan Tandy at 2020-04-03T16:59:15+00:00 
ITS#8383 Look for socklen_t in <ws2tcpip.h> too

MinGW targets do not have the <sys/socket.h> header. The configure check
would conclude that there is no socklen_t type, resulting in portable.h
containing its own definition of socklen_t, which would later conflict
with the actual definition in <ws2tcpip.h>.

Add <ws2tcpip.h> to the configure check for socklen_t, so that the
defined type is correctly detected.
Comment 6 Quanah Gibson-Mount 2020-04-16 16:52:47 UTC
commit 6fe9b0c65479363e4f9f03dd85fc81b2940f62df
Author: Ryan Tandy <ryan@nardis.ca>
Date:   Sun Sep 1 11:53:37 2019 -0700

    ITS#8383 Look for socklen_t in <ws2tcpip.h> too

    MinGW targets do not have the <sys/socket.h> header. The configure check
    would conclude that there is no socklen_t type, resulting in portable.h
    containing its own definition of socklen_t, which would later conflict
    with the actual definition in <ws2tcpip.h>.

    Add <ws2tcpip.h> to the configure check for socklen_t, so that the
    defined type is correctly detected.