[ODBC-154] FTBFS on Fedora Created: 2018-06-29  Updated: 2020-06-08  Resolved: 2018-07-04

Status: Closed
Project: MariaDB Connector/ODBC
Component/s: General
Affects Version/s: 3.0.5
Fix Version/s: 3.0.6

Type: Bug Priority: Blocker
Reporter: Michal Schorm Assignee: Lawrin Novitsky
Resolution: Fixed Votes: 0
Labels: None
Environment:

Fedora - all



 Description   

Hello,
version 3.0.3 is fine, but in 3.0.5 a compile time error has appeared and I'd need to fix it.

[ 51%] Linking C shared library libmaodbc.so
/usr/bin/cmake -E cmake_link_script CMakeFiles/maodbc.dir/link.txt --verbose=1
/usr/bin/cc -fPIC -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -O2 -g -DNDEBUG -Wl,--version-script=/builddir/build/BUILD/mariadb-connector-odbc-3.0.5-ga-src/maodbc.def -Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -shared -Wl,-soname,libmaodbc.so -o libmaodbc.so CMakeFiles/maodbc.dir/odbc_3_api.c.o CMakeFiles/maodbc.dir/ma_error.c.o CMakeFiles/maodbc.dir/ma_connection.c.o CMakeFiles/maodbc.dir/ma_helper.c.o CMakeFiles/maodbc.dir/ma_debug.c.o CMakeFiles/maodbc.dir/ma_dsn.c.o CMakeFiles/maodbc.dir/ma_driver.c.o CMakeFiles/maodbc.dir/ma_info.c.o CMakeFiles/maodbc.dir/ma_environment.c.o CMakeFiles/maodbc.dir/ma_parse.c.o CMakeFiles/maodbc.dir/ma_statement.c.o CMakeFiles/maodbc.dir/ma_desc.c.o CMakeFiles/maodbc.dir/ma_string.c.o CMakeFiles/maodbc.dir/ma_result.c.o CMakeFiles/maodbc.dir/ma_common.c.o CMakeFiles/maodbc.dir/ma_server.c.o CMakeFiles/maodbc.dir/ma_legacy_helpers.c.o CMakeFiles/maodbc.dir/ma_typeconv.c.o CMakeFiles/maodbc.dir/ma_bulk.c.o CMakeFiles/maodbc.dir/ma_platform_posix.c.o -Wl,-rpath,/builddir/build/BUILD/mariadb-connector-odbc-3.0.5-ga-src/libmariadb/libmariadb: libmariadb/libmariadb/libmariadb.so.3 -lodbcinst -lm -ldl -lpthread -ldl -lpthread -lssl -lcrypto -Wl,--no-undefined libmariadb/libmariadb/mariadbclient.def -lm 
/usr/bin/ld: anonymous version tag cannot be combined with other version tags
/usr/bin/ld: anonymous version tag cannot be combined with other version tags
/usr/bin/ld: anonymous version tag cannot be combined with other version tags
/usr/bin/ld: libmaodbc.so: version node not found for symbol mysql_num_rows@libmariadbclient_18
/usr/bin/ld: failed to set dynamic section sizes: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/maodbc.dir/build.make:376: libmaodbc.so] Error 1
make[2]: Leaving directory '/builddir/build/BUILD/mariadb-connector-odbc-3.0.5-ga-src'
make[1]: *** [CMakeFiles/Makefile2:71: CMakeFiles/maodbc.dir/all] Error 2
make[1]: Leaving directory '/builddir/build/BUILD/mariadb-connector-odbc-3.0.5-ga-src'
make: *** [Makefile:155: all] Error 2
error: Bad exit status from /var/tmp/rpm-tmp.aqNWzQ (%install)


I already tried to take latest CONC/C project and build the CONC/CODBC on the top of it, but that didn't solved the issue.

Fedora sources: (for 3.0.3)
https://src.fedoraproject.org/rpms/mariadb-connector-odbc/tree/master

Build:
https://copr.fedorainfracloud.org/coprs/mschorm/connector/builds/

Full build log:
https://copr-be.cloud.fedoraproject.org/results/mschorm/connector/fedora-rawhide-x86_64/00772340-mariadb-connector-odbc/build.log.gz


btw in the 3.0.5 release, there is also forgotten CMake cache file from you, which has to me manually removed before the build:

CMake Error: The current CMakeCache.txt directory /home/faramos/work/MDB/PATCHES/MDB_CONC-ODBC/mariadb-connector-odbc/mariadb-connector-odbc-3.0.5-ga-src/CMakeCache.txt is different than the directory /home/lawrin/mariadb-connector-odbc-3.0.5-ga-src/mariadb-connector-odbc-3.0.5-ga-src where CMakeCache.txt was created. This may result in binaries being created in the wrong place. If you are not sure, reedit the CMakeCache.txt


Feel free to ask for more resources you'd find usefull.



 Comments   
Comment by Lawrin Novitsky [ 2018-06-29 ]

Thank you for the report. That is strange though.
And sorry for CMakeCache file - I assembled source package almost manually this time. But I believe I tested the build from it. So, also strange. I will remove it from the package.

Comment by Lawrin Novitsky [ 2018-06-29 ]

The updated source package has been published(without CMakeCache.txt). The main issue we haven't looked into yet

Comment by Lawrin Novitsky [ 2018-07-03 ]

Well, I found the reason, and know why I didn't hit it.
The thing is that in C/C's libmariadb/CMakeLists.txt there is
TARGET_LINK_LIBRARIES (libmariadb "${CC_BINARY_DIR}/libmariadb/mariadbclient.def"
That makes libmariadb/libmariadb/mariadbclient.def to appear in libmaodbc linking command
The solution would be to substitute that line with smth like
SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES LINK_FLAGS "Wl,-version-script=${CC_BINARY_DIR}/libmariadb/mariadbclient.def")

I will push this change tomorrow, but unlikely you can use it. I am not sure if we can make this change in source package of 3.0.5 release. It's already released. But on other hand that is not really change in a source, but in build process.

p.s. there is no need in -DMARIADB_LINK_DYNAMIC=/usr/lib64/libmariadb.so - it won't take library from there. MARIADB_LINK_DYNAMIC is an option. If it evaluates to "True", libmariadb is linked dynamically. But the library is built in the subproject.

Comment by Michal Schorm [ 2018-07-04 ]

Please do not (ever) change already released content.

I'm fine with it appearing after few weeks in the next version.
What's more - I don't really depend on specific released tarball. If really necessary, I still can make my own tarball from specific GitHub commit, and use it in Fedora & RHEL as well. We take the source from upstream, upload it to our own system and use the uploaded one forever. That means, we are not affected by upstream for example changing released content as long as we have an information, from which exact sources the package was build.

I'll take a look at it next week (vacation + public holiday this week) and I'll test the latest GitHub commit.

Comment by Lawrin Novitsky [ 2018-07-04 ]

The fix has been pushed into C/C repo. C/ODBC commit 6d526c1 updates C/C subroject to use commit with that fix.
But latest commit will already contain fixes, that 3.0.5 does not have.

Comment by Michal Schorm [ 2018-07-08 ]

Hi,
I did following steps:

  • prepare the space which simulates Fedora ecosystem (Fedora Rawhide buildroot for building CONC/ODBC on the top of CONC/C)
  • prepare latest CONC/C sources
    • GitHub -> master branch -> download ZIP -> create tarball; marking it as 3.0.6 to be distinguishable from release 3.0.5 version
  • build CONC/C
  • prepare latest CONC/ODBC sources
    • GitHub -> master branch -> FAIL
      • the fix was made only to "3.0" branch
    • GitHub -> "3.0" branch -> download ZIP
    • fix CMakeList.txt; comment out the inclusion of the CONC/C subproject
    • fix ma_odbc.h and test/tap.h to use "#include <mysql/mysql.h> #include <mysql/errmsg.h>" instead of "#include <mysql.h> #include <errmsg.h>"
    • create tarball; marking it as 3.0.6 to be distinguishable from release 3.0.5 version
  • build CONC/C -> FAIL with

[ 29%] Linking C shared library libmaodbc.so
/usr/bin/cmake -E cmake_link_script CMakeFiles/maodbc.dir/link.txt --verbose=1
/usr/bin/cc -fPIC -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -O2 -g -DNDEBUG -Wl,--version-script=/builddir/build/BUILD/mariadb-connector-odbc-3.0.6-ga-src/maodbc.def -Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -shared -Wl,-soname,libmaodbc.so -o libmaodbc.so CMakeFiles/maodbc.dir/odbc_3_api.c.o CMakeFiles/maodbc.dir/ma_error.c.o CMakeFiles/maodbc.dir/ma_connection.c.o CMakeFiles/maodbc.dir/ma_helper.c.o CMakeFiles/maodbc.dir/ma_debug.c.o CMakeFiles/maodbc.dir/ma_dsn.c.o CMakeFiles/maodbc.dir/ma_driver.c.o CMakeFiles/maodbc.dir/ma_info.c.o CMakeFiles/maodbc.dir/ma_environment.c.o CMakeFiles/maodbc.dir/ma_parse.c.o CMakeFiles/maodbc.dir/ma_statement.c.o CMakeFiles/maodbc.dir/ma_desc.c.o CMakeFiles/maodbc.dir/ma_string.c.o CMakeFiles/maodbc.dir/ma_result.c.o CMakeFiles/maodbc.dir/ma_common.c.o CMakeFiles/maodbc.dir/ma_server.c.o CMakeFiles/maodbc.dir/ma_legacy_helpers.c.o CMakeFiles/maodbc.dir/ma_typeconv.c.o CMakeFiles/maodbc.dir/ma_bulk.c.o CMakeFiles/maodbc.dir/ma_platform_posix.c.o -llibmariadb -lodbcinst -lm 
BUILDSTDERR: /usr/bin/ld: cannot find -llibmariadb
BUILDSTDERR: collect2: error: ld returned 1 exit status
make[2]: Leaving directory '/builddir/build/BUILD/mariadb-connector-odbc-3.0.6-ga-src'
BUILDSTDERR: make[2]: *** [CMakeFiles/maodbc.dir/build.make:372: libmaodbc.so] Error 1
BUILDSTDERR: make[1]: *** [CMakeFiles/Makefile2:71: CMakeFiles/maodbc.dir/all] Error 2
make[1]: Leaving directory '/builddir/build/BUILD/mariadb-connector-odbc-3.0.6-ga-src'
BUILDSTDERR: make: *** [Makefile:155: all] Error 2


1) Is there faster way to create the CONC/ODBC release tarball (with fixed content) ?
2) Do you spot any fault in my process?
3) Can we reopen this issue?

Comment by Lawrin Novitsky [ 2018-07-08 ]

I have merged everything into master branch.
1) You mean source or binaries?
2) C/ODBC's cmake does not look for libmariadb now - it builds it as a sub-project. Thus, the easiest way would be to let it to do that. With git checkout that works out of the box. With source packages you need to put C/C files into libmariadb folder of c/odbc source tree, and everything should work. And you don't need to change CMakeLists.txt Or you must build C/ODBC only with C/C installed on the system?
3) Sure, if you think this is a bug. Well, this s not a bug, but can be a feature request

Comment by Michal Schorm [ 2018-07-09 ]

1)
I meant the source (tarball).

In the case of CONC/C it is still fairly easy. Download ZIP from GitHub and repack it as a properly named *.tar.gz archive.
However, since you made CONC/C a git submodule for the other projects (server and CONC/ODBC), I need to deal with that first.
I want to have pure sources - for the CONC/ODBC only - the exact same way, as the tarball is released (without the libmariadb dircectory at all).

And I encountered two issues:
A) Even after removal of the libmariadb directory, the CMake will fail beacuse it can't find the CONC/C sources.
Which is wrong, since I expect it to build on the top of already built CONC/C package (the mariadb-connector-c-devel package in Fedora, which places the source files somewhere into /usr/include ).
When I pick a released tarball, it builds fine that way. When I build my own tarball, it fails on CMake which can't find CONC/C sources in libmariadb directory amongst the other CONC/ODBC sources.

B) Beacuse of division of sources for server and client, the mysql.h (and errmsg.h) file is placed in /usr/share/mysql/mysql.h instead of /usr/share directly. Thus some sources has to be patched to reflect such place.
Again, this issue isn't present in the released tarball, somehow.

2)
I can't allow that.
It's the easiest way, when building for myself "on the knee", but in operating systems we rely on building on the top of already released packages (and sources).
That requires having CONC/C packages built and (for fedora) mariadb-connector-c-devel package (which contains CONC/C source files) installed in the buildroot.


How do you prepare the source tarball for release from github sources?

Comment by Lawrin Novitsky [ 2018-07-19 ]

I've created ODBC-164. I guess that should work for you. I don't want to have any search for libmariadb, and/or checks if version is correct, though. I'll only add -lmariadb to the linking command, if libmariadb folder is not present

Comment by Michal Schorm [ 2018-08-02 ]

I tried with today's GitHub master branches for CONC/C & CONC/ODBC.

CONC/C built fine; CONC/ODBC dies on following error:

[ 31%] Linking C executable odbc_multistatement
cd /home/faramos/work/ISSUES/NEW/mariadb-connector-odbc/mariadb-connector-odbc-3.0.6-ga-src/test && /usr/bin/cmake -E cmake_link_script CMakeFiles/odbc_multistatement.dir/link.txt --verbose=1
/usr/bin/cc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -O2 -g -DNDEBUG  -Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -rdynamic CMakeFiles/odbc_multistatement.dir/multistatement.c.o  -o odbc_multistatement -lodbc -lmariadbclient -lm -lpthread -ldl 
/usr/bin/ld: cannot find -lmariadbclient
collect2: error: ld returned 1 exit status

Second issue is a patch I need to apply beforehand.
Otherwise it searches the /usr/include directly? not sure why. Maybe I created the tarball some weird way. Can you please show me how do you create release tarballs?

--- mariadb-connector-odbc-3.0.5-ga-src/test/tap.h      2018-07-31 13:39:02.000000000 +0200
+++ mariadb-connector-odbc-3.0.5-ga-src/test/tap.h_patched      2018-08-01 16:00:45.992610338 +0200
@@ -109,7 +109,7 @@ int strcpy_s(char *dest, size_t buffer_s
 #include <time.h>
 #include <assert.h>
 /* We need mysql for MARIADB_CHARSET_INFO type and conversion routine */
-#include <mysql.h>
+#include <mysql/mysql.h>
 
 static SQLCHAR *my_dsn=        (SQLCHAR *)"test";
 static SQLCHAR *my_uid=        (SQLCHAR *)"root";
--- mariadb-connector-odbc-3.0.5-ga-src/ma_odbc.h       2018-07-31 13:39:02.000000000 +0200
+++ mariadb-connector-odbc-3.0.5-ga-src/ma_odbc.h_patched       2018-08-01 16:10:09.962798000 +0200
@@ -29,7 +29,7 @@
 
 #include <stdlib.h>
 
-#include <mysql.h>
+#include <mysql/mysql.h>
 
 #include <ma_legacy_helpers.h>
 
@@ -37,7 +37,7 @@
 #include <sqlext.h>
 #include <odbcinst.h>
 
-#include <errmsg.h>
+#include <mysql/errmsg.h>
 #include <string.h>
 #include <stdio.h>
 #include <math.h>

Comment by Michal Schorm [ 2018-08-03 ]

I tried the freshly released tarball for CONC/ODBC 3.0.6 and it builds fine with the following patch:

--- mariadb-connector-odbc-3.0.6-ga-src/ma_odbc.h	2018-07-31 13:39:02.000000000 +0200
+++ mariadb-connector-odbc-3.0.6-ga-src/ma_odbc.h_patched	2018-08-01 16:10:09.962798000 +0200
@@ -29,7 +29,7 @@
 
 #include <stdlib.h>
 
-#include <mysql.h>
+#include <mysql/mysql.h>
 
 #include <ma_legacy_helpers.h>
 
@@ -37,7 +37,7 @@
 #include <sqlext.h>
 #include <odbcinst.h>
 
-#include <errmsg.h>
+#include <mysql/errmsg.h>
 #include <string.h>
 #include <stdio.h>
 #include <math.h>

That means all of the issues has been resolved, but the patch I need now. (but that does not seem to be related to the previous issues)

Comment by Lawrin Novitsky [ 2018-08-03 ]

I build source package making "package_source" target, which deploys cpack in its turn.

We don't include test folder into source package. Thus the build error.

As for you headers problem. I am not sure what to do here. I think we install C/C headers into 'mariadb' subdirectory, you have them in 'mysql'. I am quite happy to have C/C as a subproject, and not having to look for headers anywhere at all. And that is what c/odbc cmake config does now - it does not look neither for headers nor for libraries. And I'd prefer to keep it this way.
Would something like 'cmake -DCMAKE_C_FLAGS_RELWITHDEBINFO="-I/usr/local/include/mysql"...' be acceptable for you? You could build this way, but I suspect you won't like this.
Another thing I could think of is to introduce new cmake parameter something like "HEADERS_LOCATION_PREFIX", that will be empty string by defauld, and will be used in C/C headers inclusion directives, if set. I guess that is something you may like.

And I think we do need new JIRA issue for that.

btw, 3.0.6 has been published yesterday

Comment by Lawrin Novitsky [ 2020-06-08 ]

I've made small change related to the discussion here.
mariadb dir in /usr(/local)/include is added to include directories if connector is built without libmariadb submodule in the source tree.

Generated at Thu Feb 08 03:26:37 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.