From a3a0e1cb30384bebbaa64cbf899d70bea6cf1353 Mon Sep 17 00:00:00 2001 From: Rohan Mars Date: Sun, 22 Nov 2015 15:52:02 -0500 Subject: [PATCH] aix gcc librados port Signed-off-by: Rohan Mars --- README.aix | 97 +++++++++++++++ README.solaris | 6 +- configure.ac | 20 +++- src/Makefile-env.am | 19 +-- src/common/BackTrace.h | 4 + src/common/Makefile.am | 5 + src/common/MemoryModel.cc | 1 + src/common/addr_parsing.c | 2 +- src/common/aix_errno.cc | 225 +++++++++++++++++++++++++++++++++++ src/common/io_priority.cc | 2 + src/crush/CrushCompiler.cc | 4 + src/global/global_init.cc | 2 + src/global/signal_handler.cc | 7 +- src/include/assert.h | 2 +- src/include/byteorder.h | 4 + src/include/compat.h | 6 +- src/include/types.h | 4 +- src/tools/rados/rados.cc | 4 +- 18 files changed, 394 insertions(+), 20 deletions(-) create mode 100644 README.aix create mode 100644 src/common/aix_errno.cc diff --git a/README.aix b/README.aix new file mode 100644 index 00000000000..84744cb9850 --- /dev/null +++ b/README.aix @@ -0,0 +1,97 @@ + +The AIX build will only build the librados library. + +Build Prerequisites +=================== + +The following AIX packages are required for developing and compilation, they have been installed via the AIX-rpm (rpm) packages: + + AIX-rpm + tcl + tk + expect + curl + readline + libpng + mpfr + m4 + autoconf + gettext + less + perl + gdbm + pcre + rsync + zlib + gcc-cpp + libffi + pkg-config + libiconv + glib2 + info + libidn + openldap + python-tools + bzip2 + python + sed + grep + libtool + nspr + nss-util + sqlite + nss-softokn + nss-softokn-freebl + libstdc++ + gmp + coreutils + nss + nss-tools + nss-sysinit + nspr-devel + nss-util-devel + nss-softokn-devel + nss-softokn-freebl-devel + nss-devel + make + libsigsegv + automake + libmpc + libgcc + gcc + libstdc++-devel + gcc-c++ + adns + tcsh + bash + getopt + db4 + expat + tcl + freetype2 + fontconfig + libXrender + libXft + tk + python-libs + tkinter + gdb + git + + +Download and Compile Boost 1.59 (or higher) + +Building Ceph +============= + + export CXX="c++ -maix64" + export CFLAGS="-g -maix64" + export OBJECT_MODE=64 + export LDFLAGS="-L/usr/lib64 -L/opt/freeware/lib64 -L/boost_1_59_0/stage/lib -Wl,-brtl -Wl,-bbigtoc" + export CXXFLAGS="-I/opt/freeware/include -I/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/README.solaris b/README.solaris index 1d82d49bdf1..cd1d1ffc584 100644 --- a/README.solaris +++ b/README.solaris @@ -20,8 +20,10 @@ 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" + export LDFLAGS="-m64 -L/stage/lib -L/usr/lib/mps/64" + export CPPFLAGS="-m64 -I" + export CXXFLAGS="-m64" + export CFLAGS="-m64" ./autogen.sh ./configure --disable-server --without-fuse --without-tcmalloc --without-libatomic-ops --without-libaio --without-libxfs diff --git a/configure.ac b/configure.ac index 0e17c8b1a97..7af7e2d25b2 100644 --- a/configure.ac +++ b/configure.ac @@ -70,11 +70,15 @@ freebsd*) solaris*) solaris="yes" ;; +aix*) + aix="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") +AM_CONDITIONAL(AIX, test x"$aix" = x"yes") # Checks for programs. AC_PROG_CXX @@ -266,6 +270,8 @@ AC_CHECK_CC_FLAG([-Wtype-limits], [WARN_TYPE_LIMITS]) AC_CHECK_CC_FLAG([-Wignored-qualifiers], [WARN_IGNORED_QUALIFIERS]) AC_CHECK_CC_FLAG([-Werror=format-security], [WARN_ERROR_FORMAT_SECURITY]) +AC_CHECK_CC_FLAG([-rdynamic], [RDYNAMIC_FLAG]) + # Check for compiler VTA support AX_CHECK_COMPILE_FLAG([-fvar-tracking-assignments], [HAS_VTA_SUPPORT=1], [HAS_VTA_SUPPORT=0]) AM_CONDITIONAL(COMPILER_HAS_VTA, [test "$HAS_VTA_SUPPORT" = 1]) @@ -963,6 +969,7 @@ AC_CHECK_HEADERS([ \ sys/cdefs.h \ syslog.h \ utime.h \ + execinfo.h ]) # name_to_handle_at @@ -1000,9 +1007,16 @@ AC_CHECK_MEMBER([struct stat.st_mtimespec.tv_nsec], [Define if you have struct stat.st_mtimespec.tv_nsec])]) # splice/tee -AC_CHECK_FUNC([splice], - [AC_DEFINE([CEPH_HAVE_SPLICE], [], [splice(2) is supported])], - []) +case "${target_os}" in +aix*) + # AIX splice() is something else + ;; +*) + AC_CHECK_FUNC([splice], + [AC_DEFINE([CEPH_HAVE_SPLICE], [], [splice(2) is supported])], + []) + ;; +esac # F_SETPIPE_SZ in fcntl.h AC_MSG_CHECKING([for F_SETPIPE_SZ in fcntl.h]) diff --git a/src/Makefile-env.am b/src/Makefile-env.am index e3b6935bbc8..0ba648787e9 100644 --- a/src/Makefile-env.am +++ b/src/Makefile-env.am @@ -118,28 +118,30 @@ AM_COMMON_CFLAGS = \ -fno-strict-aliasing \ -fsigned-char if !CLANG - AM_COMMON_CFLAGS += -rdynamic + AM_COMMON_CFLAGS += ${RDYNAMIC_FLAG} endif if SOLARIS AM_COMMON_CFLAGS += -Wno-unused-local-typedefs endif -AM_CFLAGS = $(AM_COMMON_CFLAGS) $(HARDENING_CFLAGS) +AM_CFLAGS = $(AM_COMMON_CFLAGS) +if LINUX +AM_CFLAGS += $(HARDENING_CFLAGS) +endif AM_CPPFLAGS = $(AM_COMMON_CPPFLAGS) AM_CXXFLAGS = \ @AM_CXXFLAGS@ \ $(AM_COMMON_CFLAGS) \ -ftemplate-depth-1024 \ -Wnon-virtual-dtor \ - -Wno-invalid-offsetof $(HARDENING_CFLAGS) + -Wno-invalid-offsetof +if LINUX +AM_CXXFLAGS += $(HARDENING_CFLAGS) +endif 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 @@ -153,6 +155,9 @@ AM_LDFLAGS = if LINUX AM_LDFLAGS += -Wl,--as-needed $(HARDENING_LDFLAGS) endif +if AIX +AM_LDFLAGS += -Wl,-brtl -Wl,-bexpfull +endif if USE_BOOST_SPIRIT_OLD_HDR AM_CXXFLAGS += -DUSE_BOOST_SPIRIT_OLD_HDR diff --git a/src/common/BackTrace.h b/src/common/BackTrace.h index b5d1e1d7ba4..69eea3710b3 100644 --- a/src/common/BackTrace.h +++ b/src/common/BackTrace.h @@ -2,7 +2,9 @@ #define CEPH_BACKTRACE_H #include +#ifdef HAVE_EXECINFO_H #include +#endif #include namespace ceph { @@ -16,8 +18,10 @@ struct BackTrace { char **strings; BackTrace(int s) : skip(s) { +#ifdef HAVE_EXECINFO_H size = backtrace(array, max); strings = backtrace_symbols(array, size); +#endif } ~BackTrace() { free(strings); diff --git a/src/common/Makefile.am b/src/common/Makefile.am index 12572e679a2..ce731eb08d1 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -89,6 +89,11 @@ libcommon_internal_la_SOURCES += \ common/solaris_errno.cc endif +if AIX +libcommon_internal_la_SOURCES += \ + common/aix_errno.cc +endif + if WITH_RBD if LINUX libcommon_internal_la_SOURCES += \ diff --git a/src/common/MemoryModel.cc b/src/common/MemoryModel.cc index ddc7fa94977..336c82a8cbe 100644 --- a/src/common/MemoryModel.cc +++ b/src/common/MemoryModel.cc @@ -4,6 +4,7 @@ #include "MemoryModel.h" #include "common/config.h" #include "debug.h" +#include #include diff --git a/src/common/addr_parsing.c b/src/common/addr_parsing.c index d50b10eef45..ae755576500 100644 --- a/src/common/addr_parsing.c +++ b/src/common/addr_parsing.c @@ -16,7 +16,7 @@ #include #include #include -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || defined(_AIX) #include #include #endif diff --git a/src/common/aix_errno.cc b/src/common/aix_errno.cc new file mode 100644 index 00000000000..48ef72826e1 --- /dev/null +++ b/src/common/aix_errno.cc @@ -0,0 +1,225 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2011 New Dream Network + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#include +#include "include/types.h" + + +// converts from linux errno values to host values +__s32 ceph_to_host_errno(__s32 r) +{ + if (r < -34) { + switch (r) { + case -35: + return -EDEADLK; + case -36: + return -ENAMETOOLONG; + case -37: + return -ENOLCK; + case -38: + return -ENOSYS; + case -39: + return -ENOTEMPTY; + case -40: + return -ELOOP; + case -42: + return -ENOMSG; + case -43: + return -EIDRM; + case -44: + return -ECHRNG; + case -45: + return -EL2NSYNC; + case -46: + return -EL3HLT; + case -47: + return -EL3RST; + case -48: + return -ELNRNG; + case -49: + return -EUNATCH; + case -51: + return -EL2HLT; + case -52: + return -EPERM; //TODO EBADE + case -53: + return -EPERM; //TODO EBADR + case -54: + return -EPERM; //TODO EXFULL + case -55: + return -EPERM; //TODO ENOANO + case -56: + return -EPERM; //TODO EBADRQC + case -57: + return -EPERM; //TODO EBADSLT + case -59: + return -EPERM; //TODO EBFONT + case -60: + return -ENOSTR; + case -61: + return -ENODATA; + case -62: + return -ETIME; + case -63: + return -ENOSR; + case -64: + return -EPERM; //TODO ENONET + case -65: + return -EPERM; //TODO ENOPKG + case -66: + return -EREMOTE; + case -67: + return -ENOLINK; + case -68: + return -EPERM; //TODO EADV + case -69: + return -EPERM; //TODO ESRMNT + case -70: + return -EPERM; //TODO ECOMM + case -71: + return -EPROTO; + case -72: + return -EMULTIHOP; + case -73: + return -EPERM; //TODO EDOTDOT + case -74: + return -EBADMSG; + case -75: + return -EOVERFLOW; + case -76: + return -EPERM; //TODO ENOTUNIQ + case -77: + return -EPERM; //TODO EBADFD + case -78: + return -EPERM; //TODO EREMCHG + case -79: + return -EPERM; //TODO ELIBACC + case -80: + return -EPERM; //TODO ELIBBAD + case -81: + return -EPERM; //TODO ELIBSCN + case -82: + return -EPERM; //TODO ELIBMAX + case -83: + return -EPERM; // TODO ELIBEXEC + case -84: + return -EILSEQ; + case -85: + return -ERESTART; + case -86: + return -EPERM; //ESTRPIPE; + case -87: + return -EUSERS; + case -88: + return -ENOTSOCK; + case -89: + return -EDESTADDRREQ; + case -90: + return -EMSGSIZE; + case -91: + return -EPROTOTYPE; + case -92: + return -ENOPROTOOPT; + case -93: + return -EPROTONOSUPPORT; + case -94: + return -ESOCKTNOSUPPORT; + case -95: + return -EOPNOTSUPP; + case -96: + return -EPFNOSUPPORT; + case -97: + return -EAFNOSUPPORT; + case -98: + return -EADDRINUSE; + case -99: + return -EADDRNOTAVAIL; + case -100: + return -ENETDOWN; + case -101: + return -ENETUNREACH; + case -102: + return -ENETRESET; + case -103: + return -ECONNABORTED; + case -104: + return -ECONNRESET; + case -105: + return -ENOBUFS; + case -106: + return -EISCONN; + case -107: + return -ENOTCONN; + case -108: + return -ESHUTDOWN; + case -109: + return -ETOOMANYREFS; + case -110: + return -ETIMEDOUT; + case -111: + return -ECONNREFUSED; + case -112: + return -EHOSTDOWN; + case -113: + return -EHOSTUNREACH; + case -114: + return -EALREADY; + case -115: + return -EINPROGRESS; + case -116: + return -ESTALE; + case -117: + return -EPERM; //TODO EUCLEAN + case -118: + return -EPERM; //TODO ENOTNAM + case -119: + return -EPERM; //TODO ENAVAIL + case -120: + return -EPERM; //TODO EISNAM + case -121: + return -EPERM; //TODO EREMOTEIO + case -122: + return -EDQUOT; + case -123: + return -EPERM; //TODO ENOMEDIUM + case -124: + return -EPERM; //TODO EMEDIUMTYPE - not used + case -125: + return -ECANCELED; + case -126: + return -EPERM; //TODO ENOKEY + case -127: + return -EPERM; //TODO EKEYEXPIRED + case -128: + return -EPERM; //TODO EKEYREVOKED + case -129: + return -EPERM; //TODO EKEYREJECTED + case -130: + return -EOWNERDEAD; + case -131: + return -ENOTRECOVERABLE; + case -132: + return -EPERM; //TODO ERFKILL + case -133: + return -EPERM; //TODO EHWPOISON + + default: { + break; + } + } + } + return r; // otherwise return original value +} + + diff --git a/src/common/io_priority.cc b/src/common/io_priority.cc index be4dc2a2036..579307f4071 100644 --- a/src/common/io_priority.cc +++ b/src/common/io_priority.cc @@ -14,7 +14,9 @@ #include #include +#ifdef __linux__ #include /* For SYS_xxx definitions */ +#endif #include #include diff --git a/src/crush/CrushCompiler.cc b/src/crush/CrushCompiler.cc index e16692da479..b4c2e88264d 100644 --- a/src/crush/CrushCompiler.cc +++ b/src/crush/CrushCompiler.cc @@ -1,6 +1,10 @@ #include "CrushCompiler.h" +#if defined(_AIX) +#define EBADE ECORRUPT +#endif + #ifndef EBADE #define EBADE EFTYPE #endif diff --git a/src/global/global_init.cc b/src/global/global_init.cc index 609c7ea1e07..c55006595a6 100644 --- a/src/global/global_init.cc +++ b/src/global/global_init.cc @@ -284,6 +284,7 @@ void global_init_daemonize(CephContext *cct) if (global_init_prefork(cct) < 0) return; +#if !defined(_AIX) int ret = daemon(1, 1); if (ret) { ret = errno; @@ -294,6 +295,7 @@ void global_init_daemonize(CephContext *cct) global_init_postfork_start(cct); global_init_postfork_finish(cct); +#endif } void global_init_postfork_start(CephContext *cct) diff --git a/src/global/signal_handler.cc b/src/global/signal_handler.cc index 9e699ad8d88..560f2fdfd52 100644 --- a/src/global/signal_handler.cc +++ b/src/global/signal_handler.cc @@ -26,6 +26,11 @@ #include #include +#if defined(_AIX) +extern char *sys_siglist[]; +#endif + + void install_sighandler(int signum, signal_handler_t handler, int flags) { int ret; @@ -40,7 +45,7 @@ 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) +#if defined(__sun) char message[SIG2STR_MAX]; sig2str(signum,message); snprintf(buf, sizeof(buf), "install_sighandler: sigaction returned " diff --git a/src/include/assert.h b/src/include/assert.h index 89e875392c2..e13ab9dfbd5 100644 --- a/src/include/assert.h +++ b/src/include/assert.h @@ -11,7 +11,7 @@ #elif defined(__FreeBSD__) #include #define __GNUC_PREREQ(minor, major) __GNUC_PREREQ__(minor, major) -#elif defined(__sun) +#elif defined(__sun) || defined(_AIX) #include "include/compat.h" #include #endif diff --git a/src/include/byteorder.h b/src/include/byteorder.h index d6ff8b66dee..e76d035ed11 100644 --- a/src/include/byteorder.h +++ b/src/include/byteorder.h @@ -42,6 +42,10 @@ # endif #endif +#if defined(_AIX) +# define CEPH_BIG_ENDIAN +#endif + diff --git a/src/include/compat.h b/src/include/compat.h index dcb5f6f2842..ec5905c82cd 100644 --- a/src/include/compat.h +++ b/src/include/compat.h @@ -53,11 +53,15 @@ #define lseek64(fd, offset, whence) lseek(fd, offset, whence) #endif -#if defined(__sun) +#if defined(__sun) || defined(_AIX) #define LOG_AUTHPRIV (10<<3) #define LOG_FTP (11<<3) #define __STRING(x) "x" #define IFTODT(mode) (((mode) & 0170000) >> 12) #endif +#if defined(_AIX) +#define MSG_DONTWAIT MSG_NONBLOCK +#endif + #endif /* !CEPH_COMPAT_H */ diff --git a/src/include/types.h b/src/include/types.h index bf369f3e961..aebdc5237f7 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -83,7 +83,7 @@ typedef off_t loff_t; typedef off_t off64_t; #endif -#ifdef __sun +#if defined(__sun) || defined(_AIX) typedef off_t loff_t; #endif @@ -520,7 +520,7 @@ WRITE_EQ_OPERATORS_1(shard_id_t, id) WRITE_CMP_OPERATORS_1(shard_id_t, id) ostream &operator<<(ostream &lhs, const shard_id_t &rhs); -#if defined(__sun) +#if defined(__sun) || defined(_AIX) __s32 ceph_to_host_errno(__s32 e); #else #define ceph_to_host_errno(e) (e) diff --git a/src/tools/rados/rados.cc b/src/tools/rados/rados.cc index 6f87c688b66..0506cfe4920 100644 --- a/src/tools/rados/rados.cc +++ b/src/tools/rados/rados.cc @@ -1638,9 +1638,9 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, if (wildcard) io_ctx.set_namespace(all_nspaces); - bool stdout = (nargs.size() < 2) || (strcmp(nargs[1], "-") == 0); + bool use_stdout = (nargs.size() < 2) || (strcmp(nargs[1], "-") == 0); ostream *outstream; - if(stdout) + if(use_stdout) outstream = &cout; else outstream = new ofstream(nargs[1]);