[MDEV-4607] NetBSD compiler errors concerning HIST_ENTRY Created: 2013-06-01  Updated: 2013-06-02  Resolved: 2013-06-01

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: 5.5.31
Fix Version/s: 5.5.32

Type: Bug Priority: Major
Reporter: Anthony Howe Assignee: Vladislav Vaintroub
Resolution: Fixed Votes: 0
Labels: netbsd
Environment:

NetBSD 6.1, gcc 4.5.3, readline-6.2


Attachments: Text File CMakeCache.txt    

 Description   

After applying previous patches (MDEV-4553) to 5.5.31 the following also fails to compile:

[ 96%] Building CXX object client/CMakeFiles/mysql.dir/mysql.cc.o
/usr/local/src/mariadb-5.5.31/client/mysql.cc:1057:12: error: 'HIST_ENTRY' does not name a type
/usr/local/src/mariadb-5.5.31/client/mysql.cc: In function 'int not_in_history(const char*)':
/usr/local/src/mariadb-5.5.31/client/mysql.cc:2434:3: error: 'HIST_ENTRY' was not declared in this scope
/usr/local/src/mariadb-5.5.31/client/mysql.cc:2434:15: error: 'oldhist' was not declared in this scope
/usr/local/src/mariadb-5.5.31/client/mysql.cc:2434:51: error: 'history_get' was not declared in this scope

Proposed patch:

92a93,95
> #ifdef HAVE_HIST_ENTRY
> # include <readline/history.h>
> #endif
1049c1052
< extern "C" int add_history(const char command); / From readline directory */

> extern "C" void add_history(const char command); / From readline directory */



 Comments   
Comment by Vladislav Vaintroub [ 2013-06-01 ]

Looking at cmake/readline.cmake, HAVE_HIST_ENTRY is set only if following code compiles.
CHECK_CXX_SOURCE_COMPILES("
#include <stdio.h>
#include <readline/readline.h>
int main(int argc, char **argv)

{ HIST_ENTRY entry; return 0; }

"
HAVE_HIST_ENTRY)

In other words, including <readline/readline.h> alone must be sufficient for HIST_ENTRY to be found (at least the test is written is this way)

I presume that there is some kind of conflict between system header and the header in cmd-line-utils/readline.h. Would it be possible for you to find out which one gets included during compilation? Could you also attach CMakeCache.txt from the build directory , for diagnostics ?
Thanks!

Comment by Anthony Howe [ 2013-06-01 ]

Here's the cmake what's it. I'll look in the other part shortly.

Comment by Anthony Howe [ 2013-06-01 ]

There are two readlines it appears:

/usr/include/readline/readline.h

which defines HIST_ENTRY directly, and

/usr/pkg/include/readline/readline.h

installed by the package system (pkgin, similar to apt/yum) probably as a dependency with other packages. My cmake configure command was:

cmake -DCMAKE_C_FLAGS="-Wno-char-subscripts -I/usr/pkg/include" -DCMAKE_EXE_LINKER_FLAGS=-L/usr/pkg/lib .

I suspect that your readline test does not include the extra -I and -L paths when testing and so picks up the system readline.h instead of the package installed one.

Comment by Vladislav Vaintroub [ 2013-06-01 ]

If you also set -DREADLINE_INCLUDE_DIR=/usr/pkg/include , and rebuild, will this work? to me it looks like it should

Can you also tell why are you using you actually /usr/pkg/include, if you have the header already installed in standard place? Also is this necessary to use /usr/pkg/lib, rather than /usr/lib ? I
Are those more standard places in NetBSD that the usual /usr/include and /usr/lib ? then you probably need to talk to gcc folks to set the default header path on that platform (or CMake folks.. I cannot imagine every program would need to add -I and -L flags to workaround cmake and gcc)

Comment by Anthony Howe [ 2013-06-01 ]

All the extra packages that get installed, similar to what rpm, apt, or yum do, go under the /usr/pkg tree, which is a standard location for NetBSD packages. I didn't know that NetBSD already included readline in the stock installation and the package one was added as a dependency, and by force of habit I include /usr/pkg. I'm currently trying a build without using /usr/pkg, if that fails I'll try with your suggested change for readline directory.

BTW these warnings also appear during compile:

[ 13%] Building C object mysys/CMakeFiles/mysys.dir/my_gethwaddr.c.o
/usr/local/src/mariadb-5.5.31/mysys/my_gethwaddr.c:26:16: warning: 'memcpy_and_test' defined but not used

[ 61%] Building C object sql/CMakeFiles/sql.dir/__/sql-common/client_plugin.c.o
/usr/local/src/mariadb-5.5.31/sql-common/client_plugin.c: In function 'mysql_client_register_plugin':
/usr/local/src/mariadb-5.5.31/sql-common/client_plugin.c:327:11: warning: 'unused' may be used uninitialized in this function
/usr/local/src/mariadb-5.5.31/sql-common/client_plugin.c: In function 'mysql_client_plugin_init':
/usr/local/src/mariadb-5.5.31/sql-common/client_plugin.c:263:15: warning: 'unused' may be used uninitialized in this function

[ 67%] Building CXX object sql/CMakeFiles/sql.dir/sql_test.cc.o
/usr/local/src/mariadb-5.5.31/sql/sql_test.cc: In function 'void mysql_print_status()':
/usr/local/src/mariadb-5.5.31/sql/sql_test.cc:630:29: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'time_t'
/usr/local/src/mariadb-5.5.31/sql/sql_test.cc:630:29: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'time_t'

Comment by Anthony Howe [ 2013-06-01 ]

Without explicit reference to /usr/pkg, cmake appears to discover /usr/pkg/include/readline/readline.h, but still fails to build. With explicit reference using -I and -L to /usr/pkg, it fails to build. Applying my patch, rectifies the issue.

If you require, I can create a user account on my NetBSD file server for you to conduct your own build experiments. Contact me directly by email for details.

Comment by Vladislav Vaintroub [ 2013-06-02 ]

Anthony,
If you would like to contribute a machine to MariaDB's buildbot, it is described in "Volunteering to run a build slave" section in https://kb.askmonty.org/en/about-buildbot/.
The basic requirement for slave is that it needs to be online (have prerequisites for the build installed of course, too)

PS. This is followup to mail exchange, you mail server seems to reject montyprogram.com mails now

Generated at Thu Feb 08 06:57:42 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.