From 3852a6b6c2791731ad0690db499001cd2d20b835 Mon Sep 17 00:00:00 2001 From: Alexander B Date: Sat, 18 Mar 2023 09:28:47 +0300 Subject: [PATCH] Solaris.build fix #3843 and #3643 (#3939) * try fix compilation for solaris * this commit for issue #3843 and #3643 changes in Types.h allow ignore problem with declaration of std::int8_t. int8_t can be defined as char or signed char. IMHO we need strong types for Poco::Int's Envelop.cpp contains initializer for EVP_CIPHER_CTX_init, because this function prototype depends on openssl version. Application.cpp contains includes especial for SOLARIS, for ioctl support ClassLoaderTest.cpp and SharedLibraryTest.cpp contains changes because loadlibrary(dlopen) doesn't load library from current directory by default LocalDateTimeTest.cpp contains changes because SOLARIS use std::tm without tm_gmtoff * fix : define of SOLARIOS OS in LocalDateTimeTest * remove unnecessary wrapper * fix output dir for windows build with multi-config build * try to fix bug with unixodbc version in linux-builds [read here](https://github.com/microsoft/linux-package-repositories/issues/36) * try to fix bug with unixodbc version in linux-builds [read here](https://github.com/microsoft/linux-package-repositories/issues/36) * fix : warning in main cmake for if-condition for multi-config build fix : error for linux-gcc-make-cxx20, use --allow-downgrades for unixodbc * fix : warning for cmake windows builds revert changes for linux-gcc-make-cxx20 * revert ci.yml, remove unixodbc version * try re-run build --------- Co-authored-by: Aleksandar Fabijanic --- .github/workflows/ci.yml | 4 +- CMakeLists.txt | 8 ++++ Foundation/include/Poco/Types.h | 5 ++- Foundation/testsuite/src/ClassLoaderTest.cpp | 42 ++++++++++--------- .../testsuite/src/LocalDateTimeTest.cpp | 4 ++ .../testsuite/src/SharedLibraryTest.cpp | 19 ++++++--- Util/src/Application.cpp | 4 ++ 7 files changed, 57 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ae691ab35..96570fa53 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -153,7 +153,7 @@ jobs: CPPUNIT_IGNORE: class CppUnit::TestCaller.testFind,class CppUnit::TestCaller.testSendToReceiveFrom,class CppUnit::TestCaller.testPing,class CppUnit::TestCaller.testBigPing,class CppUnit::TestCaller.testMTU,class CppUnit::TestCaller.testProxy,class CppUnit::TestCaller.testProxy steps: - uses: actions/checkout@v2 - - run: cmake -S. -Bcmake-build -DENABLE_NETSSL_WIN=ON -DENABLE_NETSSL=OFF -DENABLE_CRYPTO=OFF -DENABLE_JWT=OFF -DENABLE_DATA=ON -DENABLE_DATA_ODBC=ON -DENABLE_DATA_MYSQL=OFF -DENABLE_DATA_POSTGRESQL=OFF -DENABLE_TESTS=ON + - run: cmake -S. -Bcmake-build -DENABLE_NETSSL_WIN=ON -DENABLE_NETSSL=OFF -DENABLE_CRYPTO=OFF -DENABLE_JWT=OFF -DENABLE_DATA=ON -DENABLE_DATA_ODBC=ON -DENABLE_DATA_MYSQL=OFF -DENABLE_DATA_POSTGRESQL=OFF -DENABLE_TESTS=ON -DCMAKE_CXX_FLAGS="/MP /EHsc" -DCMAKE_C_FLAGS=/MP - run: cmake --build cmake-build --config Release - run: >- cd cmake-build; @@ -197,7 +197,7 @@ jobs: CPPUNIT_IGNORE: class CppUnit::TestCaller.testFind,class CppUnit::TestCaller.testSendToReceiveFrom,class CppUnit::TestCaller.testPing,class CppUnit::TestCaller.testBigPing,class CppUnit::TestCaller.testMTU,class CppUnit::TestCaller.testProxy,class CppUnit::TestCaller.testProxy steps: - uses: actions/checkout@v2 - - run: cmake -S. -Bcmake-build -DENABLE_NETSSL_WIN=ON -DENABLE_NETSSL=OFF -DENABLE_CRYPTO=OFF -DENABLE_JWT=OFF -DENABLE_DATA=ON -DENABLE_DATA_ODBC=ON -DENABLE_DATA_MYSQL=OFF -DENABLE_DATA_POSTGRESQL=OFF -DENABLE_TESTS=ON + - run: cmake -S. -Bcmake-build -DENABLE_NETSSL_WIN=ON -DENABLE_NETSSL=OFF -DENABLE_CRYPTO=OFF -DENABLE_JWT=OFF -DENABLE_DATA=ON -DENABLE_DATA_ODBC=ON -DENABLE_DATA_MYSQL=OFF -DENABLE_DATA_POSTGRESQL=OFF -DENABLE_TESTS=ON -DCMAKE_CXX_FLAGS="/MP /EHsc" -DCMAKE_C_FLAGS=/MP - run: cmake --build cmake-build --config Release - run: >- cd cmake-build; diff --git a/CMakeLists.txt b/CMakeLists.txt index 976ff1344..3b2658273 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,14 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) # Windows DLLs are "runtime" for CMake. Output them to "bin" like the Visual Studio projects do. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +# Reset output dirs for multi-config builds +foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/bin) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/lib) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/lib) +endforeach(OUTPUTCONFIG) + # Append our module directory to CMake list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) diff --git a/Foundation/include/Poco/Types.h b/Foundation/include/Poco/Types.h index 55e21b765..8aa919e3d 100644 --- a/Foundation/include/Poco/Types.h +++ b/Foundation/include/Poco/Types.h @@ -20,12 +20,13 @@ #include "Poco/Foundation.h" #include +#include namespace Poco { -using Int8 = std::int8_t; +using Int8 = std::conditional::value, std::int8_t, signed char>::type; using UInt8 = std::uint8_t; using Int16 = std::int16_t; using UInt16 = std::uint16_t; @@ -49,7 +50,7 @@ using UIntPtr = std::uintptr_t; #if defined(__LP64__) #define POCO_PTR_IS_64_BIT 1 #define POCO_LONG_IS_64_BIT 1 - #if POCO_OS == POCO_OS_LINUX || POCO_OS == POCO_OS_FREE_BSD || POCO_OS == POCO_OS_ANDROID || POCO_OS == POCO_OS_AIX || POCO_OS == POCO_OS_QNX + #if POCO_OS == POCO_OS_LINUX || POCO_OS == POCO_OS_FREE_BSD || POCO_OS == POCO_OS_ANDROID || POCO_OS == POCO_OS_AIX || POCO_OS == POCO_OS_QNX || POCO_OS == POCO_OS_SOLARIS #define POCO_INT64_IS_LONG 1 #endif #endif diff --git a/Foundation/testsuite/src/ClassLoaderTest.cpp b/Foundation/testsuite/src/ClassLoaderTest.cpp index a9250dfd8..93c149a05 100644 --- a/Foundation/testsuite/src/ClassLoaderTest.cpp +++ b/Foundation/testsuite/src/ClassLoaderTest.cpp @@ -14,6 +14,7 @@ #include "Poco/ClassLoader.h" #include "Poco/Manifest.h" #include "Poco/Exception.h" +#include "Poco/Path.h" #include "TestPlugin.h" @@ -39,14 +40,15 @@ void ClassLoaderTest::testClassLoader1() { std::string path = "TestLibrary"; path.append(SharedLibrary::suffix()); - + Poco::Path libraryPath = Poco::Path::current(); + libraryPath.append(path); ClassLoader cl; assertTrue (cl.begin() == cl.end()); assertNullPtr (cl.findClass("PluginA")); - assertNullPtr (cl.findManifest(path)); + assertNullPtr (cl.findManifest(libraryPath.toString())); - assertTrue (!cl.isLibraryLoaded(path)); + assertTrue (!cl.isLibraryLoaded(libraryPath.toString())); try { @@ -63,7 +65,7 @@ void ClassLoaderTest::testClassLoader1() try { - const ClassLoader::Manif& POCO_UNUSED manif = cl.manifestFor(path); + const ClassLoader::Manif& POCO_UNUSED manif = cl.manifestFor(libraryPath.toString()); fail("not found - must throw exception"); } catch (NotFoundException&) @@ -80,22 +82,23 @@ void ClassLoaderTest::testClassLoader2() { std::string path = "TestLibrary"; path.append(SharedLibrary::suffix()); - + Poco::Path libraryPath = Poco::Path::current(); + libraryPath.append(path); ClassLoader cl; - cl.loadLibrary(path); + cl.loadLibrary(libraryPath.toString()); assertTrue (cl.begin() != cl.end()); assertNotNullPtr (cl.findClass("PluginA")); assertNotNullPtr (cl.findClass("PluginB")); assertNotNullPtr (cl.findClass("PluginC")); - assertNotNullPtr (cl.findManifest(path)); + assertNotNullPtr (cl.findManifest(libraryPath.toString())); - assertTrue (cl.isLibraryLoaded(path)); - assertTrue (cl.manifestFor(path).size() == 3); + assertTrue (cl.isLibraryLoaded(libraryPath.toString())); + assertTrue (cl.manifestFor(libraryPath.toString()).size() == 3); ClassLoader::Iterator it = cl.begin(); assertTrue (it != cl.end()); - assertTrue (it->first == path); + assertTrue (it->first == libraryPath.toString()); assertTrue (it->second->size() == 3); ++it; assertTrue (it == cl.end()); @@ -162,7 +165,7 @@ void ClassLoaderTest::testClassLoader2() meta2.destroy(pPlugin); assertTrue (!meta2.isAutoDelete(pPlugin)); - cl.unloadLibrary(path); + cl.unloadLibrary(libraryPath.toString()); } @@ -170,23 +173,24 @@ void ClassLoaderTest::testClassLoader3() { std::string path = "TestLibrary"; path.append(SharedLibrary::suffix()); - + Poco::Path libraryPath = Poco::Path::current(); + libraryPath.append(path); ClassLoader cl; - cl.loadLibrary(path); - cl.loadLibrary(path); - cl.unloadLibrary(path); + cl.loadLibrary(libraryPath.toString()); + cl.loadLibrary(libraryPath.toString()); + cl.unloadLibrary(libraryPath.toString()); - assertTrue (cl.manifestFor(path).size() == 3); + assertTrue (cl.manifestFor(libraryPath.toString()).size() == 3); ClassLoader::Iterator it = cl.begin(); assertTrue (it != cl.end()); - assertTrue (it->first == path); + assertTrue (it->first == libraryPath.toString()); assertTrue (it->second->size() == 3); ++it; assertTrue (it == cl.end()); - cl.unloadLibrary(path); - assertNullPtr (cl.findManifest(path)); + cl.unloadLibrary(libraryPath.toString()); + assertNullPtr (cl.findManifest(libraryPath.toString())); } diff --git a/Foundation/testsuite/src/LocalDateTimeTest.cpp b/Foundation/testsuite/src/LocalDateTimeTest.cpp index f8d86c1b4..3e12c3940 100644 --- a/Foundation/testsuite/src/LocalDateTimeTest.cpp +++ b/Foundation/testsuite/src/LocalDateTimeTest.cpp @@ -477,7 +477,11 @@ void LocalDateTimeTest::testTimezone2() std::time_t t = ldt.timestamp().epochTime(); std::tm then; then = *std::localtime(&t); +#if POCO_OS == POCO_OS_SOLARIS + assertTrue((mktime(&then)-t) * 1000 == ldt.tzd()); +#else assertTrue (then.tm_gmtoff == ldt.tzd()); +#endif } unsetenv("TZ"); } diff --git a/Foundation/testsuite/src/SharedLibraryTest.cpp b/Foundation/testsuite/src/SharedLibraryTest.cpp index 4f6c70f63..27ee375b9 100644 --- a/Foundation/testsuite/src/SharedLibraryTest.cpp +++ b/Foundation/testsuite/src/SharedLibraryTest.cpp @@ -13,6 +13,7 @@ #include "CppUnit/TestSuite.h" #include "Poco/SharedLibrary.h" #include "Poco/Exception.h" +#include "Poco/Path.h" using Poco::SharedLibrary; @@ -38,10 +39,12 @@ void SharedLibraryTest::testSharedLibrary1() { std::string path = "TestLibrary"; path.append(SharedLibrary::suffix()); + Poco::Path libraryPath = Poco::Path::current(); + libraryPath.append(path); SharedLibrary sl; assertTrue (!sl.isLoaded()); - sl.load(path); - assertTrue (sl.getPath() == path); + sl.load(libraryPath.toString()); + assertTrue (sl.getPath() == libraryPath.toString()); assertTrue (sl.isLoaded()); assertTrue (sl.hasSymbol("pocoBuildManifest")); assertTrue (sl.hasSymbol("pocoInitializeLibrary")); @@ -72,8 +75,10 @@ void SharedLibraryTest::testSharedLibrary2() { std::string path = "TestLibrary"; path.append(SharedLibrary::suffix()); - SharedLibrary sl(path); - assertTrue (sl.getPath() == path); + Poco::Path libraryPath = Poco::Path::current(); + libraryPath.append(path); + SharedLibrary sl(libraryPath.toString()); + assertTrue (sl.getPath() == libraryPath.toString()); assertTrue (sl.isLoaded()); GimmeFiveFunc gimmeFive = (GimmeFiveFunc) sl.getSymbol("gimmeFive"); @@ -105,12 +110,14 @@ void SharedLibraryTest::testSharedLibrary3() path = "TestLibrary"; path.append(SharedLibrary::suffix()); - sl.load(path); + Poco::Path libraryPath = Poco::Path::current(); + libraryPath.append(path); + sl.load(libraryPath.toString()); assertTrue (sl.isLoaded()); try { - sl.load(path); + sl.load(libraryPath.toString()); failmsg("library already loaded - must throw exception"); } catch (LibraryAlreadyLoadedException&) diff --git a/Util/src/Application.cpp b/Util/src/Application.cpp index fe61dddab..605b2cf7c 100644 --- a/Util/src/Application.cpp +++ b/Util/src/Application.cpp @@ -42,6 +42,10 @@ #include "Poco/SignalHandler.h" #include #include +#if POCO_OS == POCO_OS_SOLARIS +#include +#include +#endif #endif #include "Poco/UnicodeConverter.h"