Tag: MySQL Server

Raspberry Pi – Building mysql server on FreeBSD 10 Stable

When building mysql server for FreeBSD 10 from the ports collection on the Raspberry Pi the compile fails with:
mysqld.cc error: use of undeclared identifier ‘fpsetmask’; did you mean ‘sigsetmask’?

This happens for all three versions, mysql51-server, mysql55-server and mysql56-server.

Researching this I found that <ieeefp.h> for the Raspberry Pi is missing some code notably the function prototype declarations of the builtin fp functions:
#if !defined(_IEEEFP_INLINED_)
__BEGIN_DECLS
extern fp_rnd_t fpgetround(void);
extern fp_rnd_t fpsetround(fp_rnd_t);
extern fp_except_t fpgetmask(void);
extern fp_except_t fpsetmask(fp_except_t);
extern fp_except_t fpgetsticky(void);
extern fp_except_t fpsetsticky(fp_except_t);
__END_DECLS
#endif /* !_IEEEFP_INLINED_ */

If you have encountered this problem already there are two steps to fix:

  • First, Rename your /usr/includes/ieeefp.h to ieeefp.h.orig and create a new ieeefp.h with this code (might be wise to make a copy of the new ieeefp.h file too naming it as ieeefp.h.works in case you run an freebsd-update which might clobber the ieeefp.h file):

    /* $NetBSD: ieeefp.h,v 1.4 1998/01/09 08:03:43 perry Exp $ */
    /* $FreeBSD: stable/10/include/ieeefp.h 226607 2011-10-21 06:41:46Z das $ */
    /*
    * Written by J.T. Conklin, Apr 6, 1995
    * Public domain.
    */
    #ifndef _IEEEFP_H_
    #define _IEEEFP_H_
    #include <sys/cdefs.h>
    #include <machine/ieeefp.h>
    #if !defined(_IEEEFP_INLINED_)
    __BEGIN_DECLS
    extern fp_rnd_t fpgetround(void);
    extern fp_rnd_t fpsetround(fp_rnd_t);
    extern fp_except_t fpgetmask(void);
    extern fp_except_t fpsetmask(fp_except_t);
    extern fp_except_t fpgetsticky(void);
    extern fp_except_t fpsetsticky(fp_except_t);
    __END_DECLS
    #endif /* !_IEEEFP_INLINED_ */
    #endif /* _IEEEFP_H_ */

  • Then find this code in the ports tree under work/mysql5x-server/sql/mysqld.cc (x is 1,5, or 6 depending on your version) near line 176 on mysql51-server (since I’m using 5.1, my absolute path is /usr/ports/databases/mysql51-server/work/mysql-5.1.73/sql/mysqld.cc) — always good to make a copy before editing!:
    #ifdef HAVE_FP_EXCEPT // Fix type conflict
    typedef fp_except fp_except_t;
    #endif

    And comment out the typedef (as it’s also in the include file /usr/includes/machine/ieeefp.h). Code should look like whats below.
    #ifdef HAVE_FP_EXCEPT // Fix type conflict
    /* typedef fp_except fp_except_t; */
    #endif

Here is a tarball with the 3 ieeefp.* header files for your pleasure

Here is a tarball with the three header files ieeefp.h, ieeefp.h.orig and ieeefp.h.works (in case your browser is having trouble rendering the code above in the HTML and hiding code): Replacement ieeefp.h files for FreeBSD Stable Raspberry Pi. Download it and extract to usr/includes as root, edit the duplicate definition of fp_except out of mysqld.cc as described above, and restart the make of mysql server make sure to return to /usr/ports/databases/mysql5x-server before restarting make! That way you build the port with the FreeBSD modifications such as adding user mysql and setting the startup file in /usr/local/etc/rc.d so you can add mysql_enable and mysql_flags to /etc/rc.conf).

To beat the Floating Point fpsetmask() problem before it happens during the build of mysql server on FreeBSD on the Pi

  1. Install the attached ieeefp.h files from the tarball in /usr/include (or edit and paste in the code from above).
  2. Start make of mysql5x-server and once you get the message:
    ===> mysql5x-server depends on mysql5x-client
    edit the file mysqld.cc under the ports (i.e. /usr/ports/databases/mysql51-server/work/mysql-5.1.73/sql/mysqld.cc note the version number is in two places in the path and it must match the version you choose) using another ssh session. You have plenty of time to do this as the Raspberry Pi will make the mysql-client first.
Raspberry Pi under FreeBSD running mysqld Server
Success! Raspberry Pi running mysqld server on FreeBSD 10