Add Solaris support in cmake build

Add SOLARIS cmake platform definition.
Add settings for QT_DEFAULT_MKSPEC so that qplatformdefs.h can be found.
Solaris has its gssapi symbols in libgss.
Solaris supports @ORIGIN.

Solaris ld does not support --dynamic-list needed for reduce relocations.
Make solaris fail the reduce relocation test.

getauxval is specific to GNU libc and some other libc implementations on
Linux but sys/auxv.h is not. The bootstrap uses sys/aux.h as the only
indication for getauxval. This breaks builds on Solaris, so only make
sys/auxv.h an indicator for getauxval on linux or glibc based systems.

Solaris uses X11 so add it to the X11_SUPPORTED list.

Solaris network libraries for sockets etc are in socket and nsl.
ifreq does not have a member ifr_ifindex on Solaris, it uses
ifr_index. Add test to check if ifr_index is a member of ifreq.
The first struct in the in_addr union on solaris is defined as four
uint8_t, therefore four arguments are needed for its initializer list.

Change-Id: Ieed4c1bbac8559a7ae1db9c4e1e91f609f150270
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Niclas Rosenvik 2021-04-14 08:09:17 +00:00
parent 284d4e7125
commit fadd87ed15
13 changed files with 75 additions and 5 deletions

View File

@ -9,6 +9,7 @@ find_path(GSSAPI_INCLUDE_DIRS
find_library(GSSAPI_LIBRARIES
NAMES
GSS # framework
gss # solaris
gssapi_krb5
HINTS ${PC_GSSAPILIBDIR}
)

View File

@ -329,6 +329,20 @@ elseif(NETBSD)
set(QT_DEFAULT_MKSPEC netbsd-g++)
elseif(OPENBSD)
set(QT_DEFAULT_MKSPEC openbsd-g++)
elseif(SOLARIS)
if(GCC)
if(QT_64BIT)
set(QT_DEFAULT_MKSPEC solaris-g++-64)
else()
set(QT_DEFAULT_MKSPEC solaris-g++)
endif()
else()
if(QT_64BIT)
set(QT_DEFAULT_MKSPEC solaris-cc-64)
else()
set(QT_DEFAULT_MKSPEC solaris-cc)
endif()
endif()
endif()
if(NOT QT_QMAKE_TARGET_MKSPEC)

View File

@ -17,6 +17,7 @@ qt_set01(OPENBSD CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") # FIXME: How to identify
qt_set01(FREEBSD CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") # FIXME: How to identify this?
qt_set01(NETBSD CMAKE_SYSTEM_NAME STREQUAL "NetBSD") # FIXME: How to identify this?
qt_set01(WASM CMAKE_SYSTEM_NAME STREQUAL "Emscripten" OR EMSCRIPTEN)
qt_set01(SOLARIS CMAKE_SYSTEM_NAME STREQUAL "SunOS")
qt_set01(BSD APPLE OR OPENBSD OR FREEBSD OR NETBSD)

View File

@ -20,7 +20,7 @@ function(qt_compute_relative_rpath_base rpath install_location out_var)
# needed in the .prf files, but for CMake we need to prepend them ourselves.
if(APPLE)
set(rpath_rel_base "@loader_path")
elseif(LINUX)
elseif(LINUX OR SOLARIS)
set(rpath_rel_base "$ORIGIN")
else()
message(WARNING "No known RPATH_REL_BASE for target platform.")

View File

@ -143,7 +143,7 @@ qt_config_linker_supports_flag_test(gdb_index
qt_config_compile_test(reduce_relocations
LABEL "-Bsymbolic-functions support"
CODE
"#if !(defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) || defined(__amd64))
"#if !(defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) || defined(__amd64)) || defined (__sun)
# error Symbolic function binding on this architecture may be broken, disabling it (see QTBUG-36129).
#endif

View File

@ -451,7 +451,7 @@
"type": "compile",
"test": {
"head": [
"#if !(defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) || defined(__amd64))",
"#if !(defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) || defined(__amd64)) || defined(__sun)",
"# error Symbolic function binding on this architecture may be broken, disabling it (see QTBUG-36129).",
"#endif"
],

View File

@ -84,7 +84,11 @@
#define QT_FEATURE_datetimeparser -1
#define QT_FEATURE_easingcurve -1
#define QT_FEATURE_etw -1
#if defined(__linux__) || defined(__GLIBC__)
#define QT_FEATURE_getauxval (__has_include(<sys/auxv.h>) ? 1 : -1)
#else
#define QT_FEATURE_getauxval -1
#endif
#define QT_FEATURE_getentropy -1
#define QT_NO_GEOM_VARIANT
#define QT_FEATURE_hijricalendar -1

View File

@ -25,7 +25,7 @@ set_property(CACHE INPUT_libpng PROPERTY STRINGS undefined no qt system)
#### Libraries
qt_set01(X11_SUPPORTED LINUX OR HPUX OR FREEBSD OR NETBSD OR OPENBSD) # special case
qt_set01(X11_SUPPORTED LINUX OR HPUX OR FREEBSD OR NETBSD OR OPENBSD OR SOLARIS) # special case
qt_find_package(ATSPI2 PROVIDED_TARGETS PkgConfig::ATSPI2 MODULE_NAME gui QMAKE_LIB atspi)
qt_find_package(DirectFB PROVIDED_TARGETS PkgConfig::DirectFB MODULE_NAME gui QMAKE_LIB directfb)
qt_find_package(Libdrm PROVIDED_TARGETS Libdrm::Libdrm MODULE_NAME gui QMAKE_LIB drm)

View File

@ -427,6 +427,8 @@ qt_internal_extend_target(Network CONDITION WIN32 PUBLIC_LIBRARIES ws2_32) # spe
qt_internal_extend_target(Network CONDITION QNX PUBLIC_LIBRARIES socket) # special case: mkspecs/common/qcc-base-qnx.conf
qt_internal_extend_target(Network CONDITION SOLARIS PUBLIC_LIBRARIES socket nsl) # special case
# include the snippet projects for developer-builds
if(QT_FEATURE_private_tests)
add_subdirectory(doc/snippets/network)

View File

@ -81,6 +81,22 @@ freeifaddrs(list);
"# FIXME: use: unmapped library: network
)
# ifr_index
qt_config_compile_test(ifr_index
LABEL "ifr_index"
CODE
"#include <net/if.h>
int main(void)
{
/* BEGIN TEST: */
struct ifreq req;
req.ifr_index = 0;
/* END TEST: */
return 0;
}
")
# ipv6ifname
qt_config_compile_test(ipv6ifname
LABEL "IPv6 ifname"
@ -220,6 +236,10 @@ qt_feature("getifaddrs" PUBLIC
CONDITION TEST_getifaddrs
)
qt_feature_definition("getifaddrs" "QT_NO_GETIFADDRS" NEGATE VALUE "1")
qt_feature("ifr_index" PRIVATE
LABEL "ifr_index"
CONDITION TEST_ifr_index
)
qt_feature("ipv6ifname" PUBLIC
LABEL "IPv6 ifname"
CONDITION TEST_ipv6ifname

View File

@ -142,6 +142,17 @@
},
"use": "network"
},
"ifr_index": {
"label": "ifr_index",
"type": "compile",
"test": {
"include": "net/if.h",
"main": [
"struct ifreq req;",
"req.ifr_index = 0;"
]
}
},
"ipv6ifname": {
"label": "IPv6 ifname",
"type": "compile",
@ -238,6 +249,11 @@
"condition": "tests.getifaddrs",
"output": [ "feature" ]
},
"ifr_index": {
"label": "ifr_index",
"condition": "tests.ifr_index",
"output": [ "privateFeature" ]
},
"ipv6ifname": {
"label": "IPv6 ifname",
"condition": "tests.ipv6ifname",

View File

@ -111,7 +111,11 @@ uint QNetworkInterfaceManager::interfaceIndexFromName(const QString &name)
uint id = 0;
if (qt_safe_ioctl(socket, SIOCGIFINDEX, &req) >= 0)
# if QT_CONFIG(ifr_index)
id = req.ifr_index;
# else
id = req.ifr_ifindex;
# endif
qt_safe_close(socket);
return id;
#else
@ -130,7 +134,11 @@ QString QNetworkInterfaceManager::interfaceNameFromIndex(uint index)
int socket = qt_safe_socket(AF_INET, SOCK_STREAM, 0);
if (socket >= 0) {
memset(&req, 0, sizeof(ifreq));
# if QT_CONFIG(ifr_index)
req.ifr_index = index;
# else
req.ifr_ifindex = index;
# endif
if (qt_safe_ioctl(socket, SIOCGIFNAME, &req) >= 0) {
qt_safe_close(socket);
@ -216,7 +224,7 @@ static QNetworkInterfacePrivate *findInterface(int socket, QList<QNetworkInterfa
// Get the interface index
# ifdef SIOCGIFINDEX
if (qt_safe_ioctl(socket, SIOCGIFINDEX, &req) >= 0)
# if defined(Q_OS_HAIKU)
# if QT_CONFIG(ifr_index)
ifindex = req.ifr_index;
# else
ifindex = req.ifr_ifindex;

View File

@ -783,7 +783,11 @@ QNetworkInterface QNativeSocketEnginePrivate::nativeMulticastInterface() const
return QNetworkInterface::interfaceFromIndex(v);
}
#if defined(Q_OS_SOLARIS)
struct in_addr v = { 0, 0, 0, 0};
#else
struct in_addr v = { 0 };
#endif
QT_SOCKOPTLEN_T sizeofv = sizeof(v);
if (::getsockopt(socketDescriptor, IPPROTO_IP, IP_MULTICAST_IF, &v, &sizeofv) == -1)
return QNetworkInterface();