Compilation Process Record of MySQL Version 8.4.2 on the Feiteng Platform with ARM Architecture

As a globally popularMySQL database, it has witnessed the growth ofMySQL from version3.x to the current8.x. The issue known as the2038 problem withMySQL has been resolved since version8.0.28. Recently, I downloaded the latest8.4.2 version and compiled it from source on the minimal Feiteng platform with ARM architecture, documenting some issues encountered during the process.

1.WARN_MISSING_SYSTEM_TIRPC

During thecmake process, a warning was displayed: “WARN_MISSING_SYSTEM_TIRPC” along with the message “could not find rpc/rpc.h in /usr/include or /usr/include/tirpc”.

The reason is that this environment is a minimal one, lacking many basic third-party libraries, including thelibtirpc library. Although the warning indicates that therpc/rpc.h header file cannot be found, it is actually part of thelibtirpc library, so do not be misled by the absence of thetirpc reference.

Once the cause was identified, I downloaded thelibtirpc library from the internet. The latest version is1.3.6. After manually compiling and installing it (don’t ask why I didn’t use the system package; I just prefer a handcrafted approach), I added the compilation parameter-DRPC_INCLUDE_DIRS=XXX/libtirpc/include/tirpc to thecmake command forMySQL, and then re-executed thecmake command.Note: The parameter above containsXXX, which is the installation path oflibtirpc. If it is installed in the system directory by default, there is no need to add the above compilation parameter.

2.IMPORTED_LOCATION not set for imported target “OpenSSL::SSL”

During thecmake process, a warning was displayed: “IMPORTED_LOCATION not set for imported target “OpenSSL::SSL” configuration “Release” along with “CMake Warning (dev) in CMakeLists.txt” and “Policy CMP0111 is not set ……” among other messages.

This warning was initially overlooked, but it is actually related to the issue discussed in this article: “The target pattern does not contain “%”, and will not be described separately here; it will be addressed in the subsequent issues.

3.IMPORTED_LOCATION not set for imported target “OpenSSL::Crypto”

During thecmake process, a warning was displayed: “IMPORTED_LOCATION not set for imported target “OpenSSL::Crypto” configuration “Release” along with “CMake Warning (dev) in CMakeLists.txt” and “Policy CMP0111 is not set ……” among other messages.

This warning was also initially overlooked, but it is related to the same issue discussed earlier: “The target pattern does not contain “%”, and will not be described separately here; it will be addressed in the subsequent issues.

4.The target pattern does not contain “%

During themake install process, an error occurred, indicating: “Utilities/CMakeFiles/com_err.dir/build.make:100: ***Template pattern does not contain“%”. Stopping.” among other messages.

From this error message, there is no useful information visible, leading to confusion. However, the devil is in the details. By checking the automatically generated log filesCMakeFiles/CMakeError.log and CMakeFiles/CMakeOutput.log, I found clues about the actual compilation errors, with clear and specificOpenSSL related error messages: “runtime_output_directory/comp_err: OpenSSL::SSL-NOTFOUND” and “runtime_output_directory/comp_err: OpenSSL::Crypto-NOTFOUND”.

From the issues discovered earlier, it was clear that the cause was the inability to findOpenSSL. It may seem surprising that such a commonly usedOpenSSL library is not installed. However, the actual system has theOpenSSL library installed, butMySQL could not recognize it. Why was it not recognized? BecauseOpenSSL was custom-installed in a specific directory. To avoid conflicts, the installedOpenSSL was customized, and the actualOpenSSL library file name was given a custom name, different from the standardlibcrypto.so and libssl.so, completely eliminating the possibility of conflicts.

Due to the custom modifications made toOpenSSL, what should have been a simple installation ofOpenSSL became slightly more complex. By examining thecmake/ssl.cmake configuration file in theMySQL source directory, I found the function that checksOpenSSL: FUNCTION(MYSQL_CHECK_SSL), which includes the following value retrieval and print statements forOpenSSL::SSL andOpenSSL::Crypto:

GET_TARGET_PROPERTY(foo OpenSSL::SSL IMPORTED_LOCATION)

GET_TARGET_PROPERTY(bar OpenSSL::Crypto IMPORTED_LOCATION)

MESSAGE(STATUS “OPENSSL_LIBRARIES = ${foo} ${bar}”)

Similarly, in this file, I searched for the function that queries the customOpenSSL: FUNCTION(FIND_CUSTOM_OPENSSL), and found the setting statements forOpenSSL::SSL andOpenSSL::Crypto:

SET_TARGET_PROPERTIES(OpenSSL::SSL PROPERTIES IMPORTED_LOCATION “${COPIED_OPENSSL_LIBRARY}”)

SET_TARGET_PROPERTIES(OpenSSL::Crypto PROPERTIES IMPORTED_LOCATION “${COPIED_CRYPTO_LIBRARY}”)

It can be seen that the values forOpenSSL::SSL andOpenSSL::Crypto come fromCOPIED_OPENSSL_LIBRARY andCOPIED_CRYPTO_LIBRARY. Rather than tracking each one, I opted for a straightforward approach and directly assigned the original variable values, as follows:

SET(COPIED_OPENSSL_LIBRARY ${OPENSSL_LIBRARY})

SET(COPIED_CRYPTO_LIBRARY ${CRYPTO_LIBRARY})

Of course, the necessary parameters related toOpenSSL such asWITH_SSL, OPENSSL_ROOT_DIR, OPENSSL_INCLUDE_DIR, and OPENSSL_LIBRARIES still need to be set in thecmake command. After making the above adjustments, theOpenSSL warnings during thecmake compilation process disappeared, and the variablesOPENSSL_VERSION, WITH_SSL_PATH, OPENSSL_INCLUDE_DIR, and OPENSSL_LIBRARIES all printed correct information.

5.undefined reference to ‘xdr_XXX’

About halfway through the compilation, multiple errors similar to “/usr/bin/ld: xcom_up_xdr.c: (.text .xdr_x_error+0x34): undefined reference to ‘xdr_int32_t‘” appeared.

Clearly, the relatedxdr library could not be found. However, this issue is actually an extension of the earliertirpc problem. Initially, it was just the header file fortirpc that could not be found, and now it is the corresponding library that cannot be found. The long compilation time leads to the need to regenerate thecmake files, wasting time. Alas.

Following the same approach, I opened thecmake/rpc.cmake configuration file and saw the compilation macroMACRO(MYSQL_CHECK_RPC) which includes the statementmysql_check_pkg(config). I also took a straightforward approach and executed the following command to set thepkg path forlibtirpc before executing thecmake command forMySQL (replaceXXX with the installation path oflibtirpc):

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:XXX/libtirpc/lib/pkgconfig

Additionally, in the compilation macroMACRO(MYSQL_CHECK_RPC), I found settings related toTIRPC:

SET(TIRPC_INCLUDE_DIR “${CMAKE_BINARY_DIR}/tirpc/include/tirpc”)

SET(RPC_INCLUDE_DIRS “${TIRPC_INCLUDE_DIR}”)

SET(TIRPC_VERSION “1.3.3”)

SET(TIRPC_LIBRARIES “${CMAKE_BINARY_DIR}/tirpc/lib/libtirpc.a”)

To avoid further compilation errors later, I added the followingtirpc related parameters to thecmake command (replaceXXX with the actual installation path oflibtirpc):

(1)-DWITH_TIRPC=XXX/libtirpc

(2)-DTIRPC_INCLUDE_DIR=XXX/libtirpc/include/tirpc

(3)-DTIRPC_LIBRARIES=XXX/libtirpc/lib/libtirpc.so

6.Conclusion

Without a doubt, the8.4.2 version ofMySQL was successfully compiled on the Feiteng platform with ARM architecture. Although the process was fraught with challenges, all issues were resolved smoothly. To avoid forgetting over time, I am documenting this.

7.Contact

If you have any questions, feel free to reach out. Learning is endless, and we should be pragmatic, making progress a little each day!

Leave a Comment