From b7cc9d4fc313fb217c91413e405a2a2553ce0b96 Mon Sep 17 00:00:00 2001 From: Rohan Mars Date: Mon, 26 Oct 2015 21:50:30 -0700 Subject: [PATCH] Solaris compilation/build changes Signed-off-by: Rohan Mars --- README.solaris | 30 ++++++++++++++++++++++++++++++ configure.ac | 5 +++++ src/Makefile-env.am | 8 ++++++++ src/common/sctp_crc32.c | 3 ++- src/global/signal_handler.cc | 15 +++++++++++++++ src/include/assert.h | 3 +++ src/include/compat.h | 7 +++++++ src/include/encoding.h | 2 ++ src/include/types.h | 5 +++++ src/os/ObjectStore.h | 2 +- src/test/Makefile.am | 5 +++++ 11 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 README.solaris diff --git a/README.solaris b/README.solaris new file mode 100644 index 0000000000000..1d82d49bdf158 --- /dev/null +++ b/README.solaris @@ -0,0 +1,30 @@ + +The Solaris build will only build the librados library. + +Build Prerequisites +=================== + +The following Solaris packages are required for compilation: + + git + autoconf + libtool + automake + gcc-c++-48 + gnu-make + + (use the "pkg install " command to install, as root) + +Download and Compile Boost 1.59 (or higher) + +Building Ceph +============= + + export LDFLAGS="-L/boost_1_59_0/stage/lib" + export CPPFLAGS="-I/boost/boost_1_59_0" + + ./autogen.sh + ./configure --disable-server --without-fuse --without-tcmalloc --without-libatomic-ops --without-libaio --without-libxfs + cd src + gmake librados.la + diff --git a/configure.ac b/configure.ac index 7a8b39311178a..ee769af5763be 100644 --- a/configure.ac +++ b/configure.ac @@ -67,10 +67,14 @@ linux*) freebsd*) freebsd="yes" ;; +solaris*) + solaris="yes" + ;; esac AM_CONDITIONAL(LINUX, test x"$linux" = x"yes") AM_CONDITIONAL(FREEBSD, test x"$freebsd" = x"yes") AM_CONDITIONAL(DARWIN, test x"$darwin" = x"yes") +AM_CONDITIONAL(SOLARIS, test x"$solaris" = x"yes") # Checks for programs. AC_PROG_CXX @@ -956,6 +960,7 @@ AC_CHECK_HEADERS([ \ sys/time.h \ sys/vfs.h \ sys/xattr.h \ + sys/cdefs.h \ syslog.h \ utime.h \ ]) diff --git a/src/Makefile-env.am b/src/Makefile-env.am index 625e4621f70ac..e3b6935bbc8ec 100644 --- a/src/Makefile-env.am +++ b/src/Makefile-env.am @@ -120,6 +120,9 @@ AM_COMMON_CFLAGS = \ if !CLANG AM_COMMON_CFLAGS += -rdynamic endif +if SOLARIS + AM_COMMON_CFLAGS += -Wno-unused-local-typedefs +endif AM_CFLAGS = $(AM_COMMON_CFLAGS) $(HARDENING_CFLAGS) AM_CPPFLAGS = $(AM_COMMON_CPPFLAGS) @@ -133,6 +136,11 @@ if !CLANG AM_CXXFLAGS += -Wstrict-null-sentinel endif +# solaris harding +if SOLARIS + AM_CXXFLAGS += -lssp_nonshared +endif + # note: this is position dependant, it affects the -l options that # come after it on the command line. when you use ${AM_LDFLAGS} in # later rules, take care where you place it. for more information, see diff --git a/src/common/sctp_crc32.c b/src/common/sctp_crc32.c index 4acf5298510ab..2fa26afecc5cd 100644 --- a/src/common/sctp_crc32.c +++ b/src/common/sctp_crc32.c @@ -30,8 +30,9 @@ /* $KAME: sctp_crc32.c,v 1.12 2005/03/06 16:04:17 itojun Exp $ */ - +#ifdef HAVE_SYS_TYPES_H #include +#endif #if 0 __FBSDID("$FreeBSD: src/sys/netinet/sctp_crc32.c,v 1.8 2007/05/08 17:01:10 rrs Exp $"); diff --git a/src/global/signal_handler.cc b/src/global/signal_handler.cc index edca694f1c082..9e699ad8d88d1 100644 --- a/src/global/signal_handler.cc +++ b/src/global/signal_handler.cc @@ -40,9 +40,17 @@ void install_sighandler(int signum, signal_handler_t handler, int flags) ret = sigaction(signum, &act, &oldact); if (ret != 0) { char buf[1024]; +#if defined(__sun) + char message[SIG2STR_MAX]; + sig2str(signum,message); + snprintf(buf, sizeof(buf), "install_sighandler: sigaction returned " + "%d when trying to install a signal handler for %s\n", + ret, message); +#else snprintf(buf, sizeof(buf), "install_sighandler: sigaction returned " "%d when trying to install a signal handler for %s\n", ret, sys_siglist[signum]); +#endif dout_emergency(buf); exit(1); } @@ -79,8 +87,15 @@ static void handle_fatal_signal(int signum) // case, SA_RESETHAND specifies that the default signal handler-- // presumably dump core-- will handle it. char buf[1024]; +#if defined(__sun) + char message[SIG2STR_MAX]; + sig2str(signum,message); + snprintf(buf, sizeof(buf), "*** Caught signal (%s) **\n " + "in thread %llx\n", message, (unsigned long long)pthread_self()); +#else snprintf(buf, sizeof(buf), "*** Caught signal (%s) **\n " "in thread %llx\n", sys_siglist[signum], (unsigned long long)pthread_self()); +#endif dout_emergency(buf); pidfile_remove(); diff --git a/src/include/assert.h b/src/include/assert.h index 707cce0b3980d..89e875392c23e 100644 --- a/src/include/assert.h +++ b/src/include/assert.h @@ -11,6 +11,9 @@ #elif defined(__FreeBSD__) #include #define __GNUC_PREREQ(minor, major) __GNUC_PREREQ__(minor, major) +#elif defined(__sun) +#include "include/compat.h" +#include #endif #ifdef __CEPH__ diff --git a/src/include/compat.h b/src/include/compat.h index a533b3a71272a..dcb5f6f284237 100644 --- a/src/include/compat.h +++ b/src/include/compat.h @@ -53,4 +53,11 @@ #define lseek64(fd, offset, whence) lseek(fd, offset, whence) #endif +#if defined(__sun) +#define LOG_AUTHPRIV (10<<3) +#define LOG_FTP (11<<3) +#define __STRING(x) "x" +#define IFTODT(mode) (((mode) & 0170000) >> 12) +#endif + #endif /* !CEPH_COMPAT_H */ diff --git a/src/include/encoding.h b/src/include/encoding.h index 6fa12f90925c6..3ba53274bd2aa 100644 --- a/src/include/encoding.h +++ b/src/include/encoding.h @@ -62,7 +62,9 @@ inline void decode_raw(T& t, bufferlist::iterator &p) inline void decode(type &v, bufferlist::iterator& p) { __ASSERT_FUNCTION decode_raw(v, p); } WRITE_RAW_ENCODER(__u8) +#ifndef _CHAR_IS_SIGNED WRITE_RAW_ENCODER(__s8) +#endif WRITE_RAW_ENCODER(char) WRITE_RAW_ENCODER(ceph_le64) WRITE_RAW_ENCODER(ceph_le32) diff --git a/src/include/types.h b/src/include/types.h index f913af6df4ec8..33e85437b11a2 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -83,6 +83,11 @@ typedef off_t loff_t; typedef off_t off64_t; #endif +#ifdef __sun +typedef off_t loff_t; +#endif + + // -- io helpers -- template diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index 3d49e1199a7aa..3b00ac73ebe8f 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -27,7 +27,7 @@ #include #include -#if defined(DARWIN) || defined(__FreeBSD__) +#if defined(DARWIN) || defined(__FreeBSD__) || defined(__sun) #include #else #include /* or */ diff --git a/src/test/Makefile.am b/src/test/Makefile.am index 448c9b46609b3..3d6353534d14c 100644 --- a/src/test/Makefile.am +++ b/src/test/Makefile.am @@ -136,6 +136,11 @@ UNITTEST_LDADD = \ $(top_builddir)/src/gmock/gtest/lib/libgtest.la \ $(PTHREAD_LIBS) +if SOLARIS +UNITTEST_LDADD += \ + -lsocket -lnsl +endif + unittest_addrs_SOURCES = test/test_addrs.cc unittest_addrs_CXXFLAGS = $(UNITTEST_CXXFLAGS) unittest_addrs_LDADD = $(UNITTEST_LDADD) $(CEPH_GLOBAL) -- 2.39.5