Compile mysql with CFI enabled - mysql

I want to compile mysql with CFI enabled by LLVM. The version of the softwares are as following:
clang-6.0
mysql-5.6.26
binutils-2.28.1
I can compile mysql successfully with the following configration:
CC="clang" CXX="clang++" CFLAGS="-g" cmake -DCMAKE_INSTALL_PREFIX=../mysql -DWITH_BOOST=./boost .
However, I can not compile mysql with the below configuration:
CC="clang" CXX="clang++" CFLAGS="-g -flto" CXXFLAGS="-g -flto" cmake -DCMAKE_INSTALL_PREFIX=../mysql -DWITH_BOOST=./boost .
The reported error is as following:
../mysys/libmysys.a: error adding symbols: Archive has no index; run ranlib to add one
clang-6.0: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [extra/comp_err] Error 1
The ../mysys/libmysys.a is constructed by the following command:
cd /home/zhangjun/work/mysql/mysql-5.6.26/mysys_ssl
&& /home/zhangjun/tools/cmake/cmake-3.9.1-Linux-x86_64/bin/cmake -P
CMakeFiles/mysys_ssl.dir/cmake_clean_target.cmake
cd /home/zhangjun/work/mysql/mysql-5.6.26/mysys_ssl && /home/zhangjun/tools/cmake/cmake-3.9.1-Linux-x86_64/bin/cmake -E cmake_link_script CMakeFiles/mysys_ssl.dir/link.txt --verbose=1
/usr/bin/ar qc libmysys_ssl.a CMakeFiles/mysys_ssl.dir/crypt_genhash_impl.cc.o CMakeFiles/mysys_ssl.dir/my_default.cc.o CMakeFiles/mysys_ssl.dir/my_getopt.cc.o CMakeFiles/mysys_ssl.dir/my_aes.cc.o CMakeFiles/mysys_ssl.dir/my_sha1.cc.o CMakeFiles/mysys_ssl.dir/my_sha2.cc.o CMakeFiles/mysys_ssl.dir/my_md5.cc.o CMakeFiles/mysys_ssl.dir/my_rnd.cc.o CMakeFiles/mysys_ssl.dir/my_murmur3.cc.o CMakeFiles/mysys_ssl.dir/my_aes_yassl.cc.o
/usr/bin/ranlib libmysys_ssl.a
How can I fix this error?
To fix this error, I sent a email to Caroline Tice, the author of "Enforcing Forward-Edge Control-Flow Integrity in GCC & LLVM"
He said I should use the ar and runlib of llvm. The above error is fixed by using the following configuration:
CC="clang" CXX="clang++" CFLAGS="-g -flto -fvisibility=hidden -fsanitize=cfi" CXXFLAGS="-g -flto -fvisibility=hidden -fsanitize=cfi" cmake -DCMAKE_{EXE,SHARED,MODULE}_LINKER_FLAGS="-flto -fsanitize=cfi" -DCMAKE_AR=/home/zhangjun/work/llvm/llvm-3.7.1/bin/llvm-ar -DCMAKE_RANLIB=/home/zhangjun/work/llvm/llvm-3.7.1/bin/llvm-ranlib -DCMAKE_NM=/home/zhangjun/work/llvm/llvm-3.7.1/bin/llvm-nm -DCMAKE_INSTALL_PREFIX=../mysql -DWITH_BOOST=./boost .
Unfortunately, there is anotehr error:
ld: /home/zhangjun/work/llvm/llvm/tools/gold/gold-plugin.cpp:879: ld_plugin_status allSymbolsReadHook(): Assertion `ObjFilename.second' failed.
clang-6.0: error: unable to execute command: Aborted (core dumped)
clang-6.0: error: linker command failed due to signal (use -v to see invocation)
make[2]: *** [extra/comp_err] Error 254
make[2]: Leaving directory `/home/zhangjun/work/mysql/mysql-5.6.26'
make[1]: *** [extra/CMakeFiles/comp_err.dir/all] Error 2
make[1]: Leaving directory `/home/zhangjun/work/mysql/mysql-5.6.26'
make: *** [all] Error 2
Can any body help me fix this error?

Try removing -flto from the flags. For some reason, with clang, I've had the link-time optimisation cause that problem.

Related

Mysql 80 client setup

Hi everyone I don't understand BSD . MySQL client setup error .Do not try to explain the cause of the error because I won't understand just code thank's.(my English is bad)
/usr/ports/databases/mysql80-client/work/mysql-
8.0.14/mysys/stacktrace.cc:258:11: error: use of undeclared identifier
'backtrace'
int n = backtrace(addrs, array_elements(addrs));
^
/usr/ports/databases/mysql80-client/work/mysql-
8.0.14/mysys/stacktrace.cc:262:18: error: use of undeclared identifier
'backtrace_symbols'
if ((strings = backtrace_symbols(addrs, n))) {
^
/usr/ports/databases/mysql80-client/work/mysql-
8.0.14/mysys/stacktrace.cc:268:5: error: use of undeclared identifier 'backtrace_symbols_fd'
backtrace_symbols_fd(addrs, n, fileno(stderr));
^
3 errors generated.
*** [mysys/CMakeFiles/mysys.dir/stacktrace.cc.o] Error code 1
make[3]: stopped in /usr/ports/databases/mysql80-client/work/.build
1 error
make[3]: stopped in /usr/ports/databases/mysql80-client/work/.build
*** [mysys/CMakeFiles/mysys.dir/all] Error code 2
make[2]: stopped in /usr/ports/databases/mysql80-client/work/.build
1 error
make[2]: stopped in /usr/ports/databases/mysql80-client/work/.build
*** [all] Error code 2
make[1]: stopped in /usr/ports/databases/mysql80-client/work/.build
1 error
make[1]: stopped in /usr/ports/databases/mysql80-client/work/.build
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1
Stop.
make: stopped in /usr/ports/databases/mysql80-client
root#black:/usr/ports/databases/mysql80-client #
Install the binary package(as root)
# pkg install mysql80-client
See 4.4.3. Installing and Removing Packages.

Compiling MariaDB Connector v1.0.5 and/or Mysql Connection v 5.3.4

I am trying to compile MariaDB Connector v1.0.5 and/or Mysql Connection v 5.3.4.
I have MariaDB Server v.10.0.21 installed on a Slackware server. I just need to get a MYSQL connector working, doesn't matter which one.
Also applied the patch mentioned in Is there compatible ODBC driver with Mariadb 10 on Linux?
When I compile the MariaDB Connector I get an error saying "MariaDB not found".
When I compile the Mysql Connector I get the following error:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
MYSQL_LIB
linked by target "myodbc5a" in directory /downloads/mysql-connector-odbc-5.3.4-src/driver
linked by target "myodbc5w" in directory /downloads/mysql-connector-odbc-5.3.4-src/driver
linked by target "myodbc5S" in directory /downloads/mysql-connector-odbc-5.3.4-src/setupgui
linked by target "myodbc-installer" in directory /downloads/mysql-connector-odbc-5.3.4-src/installer
OUTOUT from Error File
Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /downloads/mysql-connector-odbc-5.3.4-src/CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/gmake "cmTryCompileExec3523358880/fast"
/usr/bin/gmake -f CMakeFiles/cmTryCompileExec3523358880.dir/build.make CMakeFiles/cmTryCompileExec3523358880.dir/build
gmake1: Entering directory /downloads/mysql-connector-odbc-5.3.4-src/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /downloads/mysql-connector-odbc-5.3.4-src/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec3523358880.dir/CheckFunctionExists.c.o
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTryCompileExec3523358880.dir/CheckFunctionExists.c.o -c /usr/share/cmake-2.8/Modules/CheckFunct
ionExists.c
Linking C executable cmTryCompileExec3523358880
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec3523358880.dir/link.txt --verbose=1
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create CMakeFiles/cmTryCompileExec3523358880.dir/CheckFunctionExists.c.o -o cmTryCompileExec3523358880 -rdynamic -lpth
reads
/usr/lib64/gcc/x86_64-slackware-linux/4.8.2/../../../../x86_64-slackware-linux/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
gmake[1]: *** [cmTryCompileExec3523358880] Error 1
gmake[1]: Leaving directory/downloads/mysql-connector-odbc-5.3.4-src/CMakeFiles/CMakeTmp'
gmake: *** [cmTryCompileExec3523358880/fast] Error 2
Determining if the function dlopen exists failed with the following output:
Change Dir: /downloads/mysql-connector-odbc-5.3.4-src/CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/gmake "cmTryCompileExec1888052970/fast"
/usr/bin/gmake -f CMakeFiles/cmTryCompileExec1888052970.dir/build.make CMakeFiles/cmTryCompileExec1888052970.dir/build
gmake1: Entering directory /downloads/mysql-connector-odbc-5.3.4-src/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /downloads/mysql-connector-odbc-5.3.4-src/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec1888052970.dir/CheckFunctionExists.c.o
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=dlopen -o CMakeFiles/cmTryCompileExec1888052970.dir/CheckFunctionExists.c.o -c /usr/share/cmake-2.8/Modules/CheckFunctionExist
s.c
Linking C executable cmTryCompileExec1888052970
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec1888052970.dir/link.txt --verbose=1
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=dlopen CMakeFiles/cmTryCompileExec1888052970.dir/CheckFunctionExists.c.o -o cmTryCompileExec1888052970 -rdynamic
CMakeFiles/cmTryCompileExec1888052970.dir/CheckFunctionExists.c.o: In functionmain':
CheckFunctionExists.c:(.text+0x15): undefined reference to dlopen'
collect2: error: ld returned 1 exit status
gmake[1]: *** [cmTryCompileExec1888052970] Error 1
gmake[1]: Leaving directory/downloads/mysql-connector-odbc-5.3.4-src/CMakeFiles/CMakeTmp'
gmake: *** [cmTryCompileExec1888052970/fast] Error 2
Blockquote
Just use the precompiled versions. Copy the libraries to the lib and include directories.

ld: library not found for -lPods-AutomatorSampleApp-Illuminator clang: error: linker command failed with exit code 1 (use -v to see invocation)

While running AutomatorSampleApp.xcodeproj , I am getting error:--
ld: library not found for -lPods-AutomatorSampleApp-Illuminator clang:
error: linker command failed with exit code 1 (use -v to see
invocation)
When using illuminator for my iOS project, I had to add -l"Illuminator" to Build Settings > PODS_OTHER_LDFLAGS under the Debug section.

Error building couchbase: fatal error cbsasl/cbsasl.h: No such file or directory

Following the instructions in https://github.com/membase/manifest I obtain the error:
daemon/memcached.h:12:27: fatal error: cbsasl/cbsasl.h: No such file or directory
after:
$ repo init -u git://github.com/membase/manifest.git -m branch-2.1.0.xml
$ repo sync
$ make
Also in branch-2.0.1.xml
Thanks in advance!!!
Not compiling support for Ubuntu 13.10

Unable to build pdftk from source on fedora machine

I am trying to build pdftk from source on fedora machine. I have unzip pdftk jar and trying to execute
make -f Makefile.Redhat
But i am getting following error on my console.
gcjh-4.7.2 -force --classpath="/usr/share/java/libgcj-4.7.2.jar:/home/tw1/pdftk-1.45-dist/java:." org/bouncycastle/asn1/ASN1ObjectParser
/bin/sh: gcjh-4.7.2: command not found
make[1]: [org/bouncycastle/asn1/ASN1ObjectParser.h] Error 127 (ignored)
gcj-4.7.2 -Wall -Wextra -O2 --encoding=UTF-8 --classpath="/usr/share/java/libgcj-4.7.2.jar:/home/tw1/pdftk-1.45-dist/java:." -C org/bouncycastle/asn1/IndefiniteLengthInputStream.java
/bin/sh: gcj-4.7.2: command not found
make[1]: [org/bouncycastle/asn1/IndefiniteLengthInputStream.class] Error 127 (ignored)
gcjh-4.7.2 -force --classpath="/usr/share/java/libgcj-4.7.2.jar:/home/tw1/pdftk-1.45-dist/java:." org/bouncycastle/asn1/IndefiniteLengthInputStream
/bin/sh: gcjh-4.7.2: command not found
make[1]: [org/bouncycastle/asn1/IndefiniteLengthInputStream.h] Error 127 (ignored)
fastjar-4.7.2 -cf java_lib.jar com/lowagie/*/*/*/*.class com/lowagie/*/*/*.class com/lowagie/*/*.class org/bouncycastle/*/*.class org/bouncycastle/*/*/*.class com/lowagie/text/pdf/fonts/Helvetica-Oblique.afm com/lowagie/text/pdf/fonts/Courier.afm com/lowagie/text/pdf/fonts/Helvetica-BoldOblique.afm com/lowagie/text/pdf/fonts/Courier-Bold.afm com/lowagie/text/pdf/fonts/Times-Roman.afm com/lowagie/text/pdf/fonts/Times-Bold.afm com/lowagie/text/pdf/fonts/Courier-Oblique.afm com/lowagie/text/pdf/fonts/Symbol.afm com/lowagie/text/pdf/fonts/Courier-BoldOblique.afm com/lowagie/text/pdf/fonts/Helvetica.afm com/lowagie/text/pdf/fonts/Helvetica-Bold.afm com/lowagie/text/pdf/fonts/Times-Italic.afm com/lowagie/text/pdf/fonts/ZapfDingbats.afm com/lowagie/text/pdf/fonts/Times-BoldItalic.afm
/bin/sh: fastjar-4.7.2: command not found
make[1]: [java_lib.o] Error 127 (ignored)
gcj-4.7.2 -Wall -Wextra -O2 --encoding=UTF-8 --classpath="/usr/share/java/libgcj-4.7.2.jar:/home/tw1/pdftk-1.45-dist/java:." -c java_lib.jar
/bin/sh: gcj-4.7.2: command not found
make[1]: [java_lib.o] Error 127 (ignored)
make[1]: Leaving directory `/home/tw1/pdftk-1.45-dist/java'
make: *** No rule to make target `../java/java_lib.o', needed by `pdftk.o'. Stop.
From the output i can infer that it is not able to find gcjh,gcj path. I am not able to find out what path should be given into the Makefile.
TOOLPATH=
export VERSUFF=
Additional information
gcc --version
gcc (GCC) 4.7.2 20120921 (Red Hat 4.7.2-2)
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
locate gcjh-4.7.2 | less
Nothing
locate gcj-4.7.2 | less
/usr/lib64/gcj-4.7.2
/usr/lib64/gcj-4.7.2/classmap.db
/usr/lib64/gcj-4.7.2/classmap.db.d
/usr/lib64/gcj-4.7.2/libgjsmalsa.so
/usr/lib64/gcj-4.7.2/libgtkpeer.so
/usr/lib64/gcj-4.7.2/libjavamath.so
/usr/lib64/gcj-4.7.2/libjawt.so
/usr/lib64/gcj-4.7.2/libjvm.so
/usr/share/java/libgcj-4.7.2.jar
Do you actually have the gcc-java package installed? That is what provides the gcj and gcjh executables (though not gcj-4.7.2 or gcjh-4.7.2).