[MDEV-20248] Build error rocksdb storage mariadb-10.4.7 on FreeBSD 12.0-p8 Created: 2019-08-04  Updated: 2023-08-17  Resolved: 2023-08-17

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - RocksDB
Affects Version/s: 10.4.7, 10.4.8, 10.6.3, 10.6.4, 10.6.5, 10.5
Fix Version/s: 11.3.0

Type: Bug Priority: Major
Reporter: Sebastian Assignee: Andrew Hutchings
Resolution: Fixed Votes: 0
Labels: None
Environment:

System: FreeBSD 12.0 - p8
Compiler: clang 6.0.1 with cmake 3.15.1
Build: cmake -DWITHOUT_TOKUDB=1 .



 Description   

System: FreeBSD 12.0 - p8
Compiler: clang 6.0.1 with cmake 3.15.1

Build: cmake -DWITHOUT_TOKUDB=1 .

make Error:

[ 74%] Built target rocksdb_tools
[ 75%] Building CXX object storage/rocksdb/CMakeFiles/rocksdblib.dir/rocksdb/db/malloc_stats.cc.o
c++: warning: -Wl,-z,relro,-z,now: 'linker' input unused [-Wunused-command-line-argument]
In file included from /usr/local/src/mariadb-10.4.7/storage/rocksdb/rocksdb/db/malloc_stats.cc:16:
/usr/local/src/mariadb-10.4.7/storage/rocksdb/rocksdb/port/jemalloc_helper.h:44:19: error: redefinition of
      'malloc_usable_size' as different kind of symbol
extern "C" size_t malloc_usable_size(JEMALLOC_USABLE_SIZE_CONST void*)
                  ^
/usr/include/malloc_np.h:71:8: note: previous definition is here
size_t  malloc_usable_size(const void *ptr);
        ^
In file included from /usr/local/src/mariadb-10.4.7/storage/rocksdb/rocksdb/db/malloc_stats.cc:16:
/usr/local/src/mariadb-10.4.7/storage/rocksdb/rocksdb/port/jemalloc_helper.h:44:38: error: use of undeclared
      identifier 'JEMALLOC_USABLE_SIZE_CONST'
extern "C" size_t malloc_usable_size(JEMALLOC_USABLE_SIZE_CONST void*)
                                     ^
/usr/local/src/mariadb-10.4.7/storage/rocksdb/rocksdb/port/jemalloc_helper.h:44:71: error: expected ';' after top
      level declarator
extern "C" size_t malloc_usable_size(JEMALLOC_USABLE_SIZE_CONST void*)
                                                                      ^
                                                                      ;
/usr/local/src/mariadb-10.4.7/storage/rocksdb/rocksdb/port/jemalloc_helper.h:45:24: warning: declaration does not
      declare anything [-Wmissing-declarations]
    JEMALLOC_CXX_THROW __attribute__((__weak__));
                       ^
/usr/local/src/mariadb-10.4.7/storage/rocksdb/rocksdb/port/jemalloc_helper.h:58:43: warning: comparison of function
      'malloc_usable_size' not equal to a null pointer is always true [-Wtautological-pointer-compare]
         malloc_stats_print != nullptr && malloc_usable_size != nullptr;
                                          ^~~~~~~~~~~~~~~~~~    ~~~~~~~
/usr/local/src/mariadb-10.4.7/storage/rocksdb/rocksdb/port/jemalloc_helper.h:58:43: note: prefix with the address-of
      operator to silence this warning
         malloc_stats_print != nullptr && malloc_usable_size != nullptr;
                                          ^
                                          &
2 warnings and 3 errors generated.
*** Error code 1
 
Stop.
make[2]: stopped in /usr/local/src/mariadb-10.4.7
*** Error code 1
 
Stop.
make[1]: stopped in /usr/local/src/mariadb-10.4.7
*** Error code 1
 
Stop.
make: stopped in /usr/local/src/mariadb-10.4.7



 Comments   
Comment by Bernard Spil [ 2019-08-05 ]

FreeBSD ships with jemalloc in the OS. Likely the root of this issue...

PS. I'm the maintainer of the MariaDB ports on FreeBSD..

Comment by Bernard Spil [ 2019-08-20 ]

See also FreeBSD PR239653

Patch provided there

JEMALLOC_USABLE_SIZE_CONST is not defined in FreeBSD's jemalloc(3), define the
macro to "const".
 
This prevents build failures in FreeBSD.
 
Reference upstream bug report: https://jira.mariadb.org/browse/MDEV-20248
--- storage/rocksdb/rocksdb/port/jemalloc_helper.h.orig	2019-08-12 02:20:55 UTC
+++ storage/rocksdb/rocksdb/port/jemalloc_helper.h
@@ -12,6 +12,10 @@
 #include <jemalloc/jemalloc.h>
 #endif
 
+#ifdef __FreeBSD__
+#define JEMALLOC_USABLE_SIZE_CONST const
+#endif
+
 #ifndef JEMALLOC_CXX_THROW
 #define JEMALLOC_CXX_THROW
 #endif

Comment by Sebastian [ 2019-08-25 ]

I still had to use MDEV-20258 but patch works thanks to Bernard Spil.

Is the patch also added to facebook github or should it be done by the ticket creator with reference to this ticket?

Comment by Andrew Hutchings [ 2022-08-25 ]

Upstream pull request created: https://github.com/facebook/rocksdb/pull/10575

Comment by Andrew Hutchings [ 2022-08-31 ]

Fix has been merged upstream

Generated at Thu Feb 08 08:58:00 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.