fix the swab bug to compile on solaris system #6628

Merged
merged 3 commits into from Jun 24, 2016

Conversation

Projects
None yet
4 participants
Contributor

FrankYu commented Jun 23, 2016

on smartos will met below error when try to build:

In file included from /opt/local/include/python2.7/Python.h:44:0,

             from src/mplutils.h:21,

             from src/ft2font_wrapper.cpp:1:

/usr/include/unistd.h:521:75: error: declaration of C function 'void swab(const void_, void_, ssize_t)' conflicts with

In file included from /opt/local/include/python2.7/Python.h:42:0,

             from src/mplutils.h:21,

             from src/ft2font_wrapper.cpp:1:

/usr/include/stdlib.h:170:13: error: previous declaration 'void swab(const char_, char_, ssize_t)' here

error: command 'gcc' failed with exit status 1

Signed-off-by: Frank Yu flyxiaoyu@gmail.com

FrankYu added some commits Jun 23, 2016

@FrankYu FrankYu fix the swab bug to compile on solaris system
on smartos will met below error when try to build:

In file included from /opt/local/include/python2.7/Python.h:44:0,

                 from src/mplutils.h:21,

                 from src/ft2font_wrapper.cpp:1:

/usr/include/unistd.h:521:75: error: declaration of C function 'void swab(const void*, void*, ssize_t)' conflicts with

In file included from /opt/local/include/python2.7/Python.h:42:0,

                 from src/mplutils.h:21,

                 from src/ft2font_wrapper.cpp:1:

/usr/include/stdlib.h:170:13: error: previous declaration 'void swab(const char*, char*, ssize_t)' here

error: command 'gcc' failed with exit status 1

Signed-off-by: Frank Yu <flyxiaoyu@gmail.com>
761e601
@FrankYu FrankYu fix the blank space line
Signed-off-by: Frank Yu <flyxiaoyu@gmail.com>
8664865

mdboom added the needs_review label Jun 23, 2016

Owner

tacaswell commented Jun 23, 2016

Why does this work? Is this a know conflict?

We obviously have no CI on this change.

Contributor

FrankYu commented Jun 23, 2016 edited

someone has report this problem http://matplotlib.1069221.n5.nabble.com/Runtime-Error-on-Solaris-Error-Closing-Dupe-File-Handle-td45601.html

why this work:

on smartos:

#sed -n 512,525p /usr/include/unistd.h
#if !defined(XOPEN_OR_POSIX) || defined(__EXTENSIONS)
extern void setusershell(void);
#endif /* !defined(XOPEN_OR_POSIX)|| defined(__EXTENSIONS) /
extern unsigned sleep(unsigned);
#if !defined(XOPEN_OR_POSIX) || defined(__EXTENSIONS)
extern int stime(const time_t *);
#endif /
!defined(XOPEN_OR_POSIX) || defined(__EXTENSIONS) _/
#if defined(XPG4)
/
EXTENSIONS makes the SVID Third Edition prototype in stdlib.h visible _/
extern void swab(const void *_RESTRICT_KYWD, void *RESTRICT_KYWD, ssize_t);
#endif /
defined(_XPG4) */
#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(EXTENSIONS)
extern int symlink(const char *, const char *);
extern void sync(void);

swab was declared 'if defined(_XPG4)'. So add 'undef _XPG4' to avoid the twice declaration of swab.
Moreover, I find one commit d0d21 in 2010 which was related this issues

#git show d0d21
commit d0d2110
Author: John Hunter jdh2358@gmail.com
Date: Fri Jul 2 18:06:25 2010 +0000

fix swab bug so mpl will compile on solaris with cxx 6

svn path=/trunk/matplotlib/; revision=8484

diff --git a/CHANGELOG b/CHANGELOG
index c49196d..af6023d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+2010-07-02 Modified CXX/WrapPython.h to fix "swab bug" on solaris so

  •       mpl can compile on Solaris with CXX6 in the trunk.  Closes
    
  •       tracker bug 3022815 - JDH
    

    2010-06-30 Added autoscale convenience method and corresponding
    pyplot function for simplified control of autoscaling;
    and changed axis, set_xlim, and set_ylim so that by
    diff --git a/CXX/WrapPython.h b/CXX/WrapPython.h
    index 118a874..ef97cf1 100644
    --- a/CXX/WrapPython.h
    +++ b/CXX/WrapPython.h
    @@ -48,6 +48,9 @@
    #if defined(_XPG4)
    #undef _XPG4
    #endif
    +#if defined(_XPG3)
    +#undef _XPG3
    +#endif
    #endif

    // Python.h will redefine these and generate warning in the process

What should I do if we need setup CI env for this?
I believe many person who use matplotlib on Solaris well also met this problem

Member

WeatherGod commented Jun 23, 2016

Is there any links that you could include as a comment so help guide future developers?

Contributor

FrankYu commented Jun 23, 2016

no link. I can update this patch with comment about that. Is it ok?

Member

WeatherGod commented Jun 23, 2016

That'll have to do, I suppose. I don't think any of the regular developers have much experience developing on a sun-like system, so we don't know what the implications are of undef-ing that macro.

Contributor

FrankYu commented Jun 23, 2016

@WeatherGod
Ok. I find another link. I think they're same issues
https://github.com/FreeCAD/FreeCAD/blob/master/src/CXX/WrapPython.h

Owner

tacaswell commented Jun 23, 2016

For CI would would need access to a solaris (like) box to run on.

(slightly better formatted version git log)

09:43 $ git show d0d2110f3fd6ba00403f949cc519760bb3ee3e2e
commit d0d2110f3fd6ba00403f949cc519760bb3ee3e2e
Author: John Hunter <jdh2358@gmail.com>
Date:   Fri Jul 2 18:06:25 2010 +0000

    fix swab bug so mpl will compile on solaris with cxx 6

    svn path=/trunk/matplotlib/; revision=8484

diff --git a/CHANGELOG b/CHANGELOG
index c49196d..af6023d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+2010-07-02 Modified CXX/WrapPython.h to fix "swab bug" on solaris so
+           mpl can compile on Solaris with CXX6 in the trunk.  Closes
+           tracker bug 3022815 - JDH
+
 2010-06-30 Added autoscale convenience method and corresponding
            pyplot function for simplified control of autoscaling;
            and changed axis, set_xlim, and set_ylim so that by
diff --git a/CXX/WrapPython.h b/CXX/WrapPython.h
index 118a874..ef97cf1 100644
--- a/CXX/WrapPython.h
+++ b/CXX/WrapPython.h
@@ -48,6 +48,9 @@
 #if defined(_XPG4)
 #undef _XPG4
 #endif
+#if defined(_XPG3)
+#undef _XPG3
+#endif
 #endif

 // Python.h will redefine these and generate warning in the process

attn @mdboom It looks like this is something we lost in the CXX-ectomy

@FrankYu Thanks for your diligent footwork on this!

Can you put in the XDG3 undef as well?

Given that we still have not cut 1.5.2 and we now have win+mac+linux testing in this branch I think this should be backported to 1.5.x

@FrankYu FrankYu fix the swab bug to compile on solaris system
Signed-off-by: Frank Yu <flyxiaoyu@gmail.com>
8bfae27

@WeatherGod WeatherGod merged commit 5de9c44 into matplotlib:master Jun 24, 2016

1 of 3 checks passed

continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build failed
Details
coverage/coveralls Coverage remained the same at 70.283%
Details

mdboom removed the needs_review label Jun 24, 2016

@WeatherGod WeatherGod added a commit that referenced this pull request Jun 24, 2016

@WeatherGod WeatherGod Merge pull request #6628 from FrankYu/master
fix the swab bug to compile on solaris system
bf6e785
Member

WeatherGod commented Jun 24, 2016

backported to v1.5.x via bf6e785

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment