From a37d8187269ecb29492ad47c9b0da911b4f7712b Mon Sep 17 00:00:00 2001 From: alexpeshkoff Date: Thu, 7 May 2009 14:49:40 +0000 Subject: [PATCH] AIX port - native compiler support --- builds/posix/make.defaults | 5 ++- builds/posix/prefix.aix_powerpc_xlc | 54 +++++++++++++++++++++++++---- configure.in | 20 ++++++++++- src/common/classes/alloc.h | 6 +++- src/jrd/SysFunction.cpp | 2 +- src/remote/inet.cpp | 3 ++ 6 files changed, 80 insertions(+), 10 deletions(-) diff --git a/builds/posix/make.defaults b/builds/posix/make.defaults index 0c3874ed27..b7e7d4f392 100755 --- a/builds/posix/make.defaults +++ b/builds/posix/make.defaults @@ -112,6 +112,9 @@ STD_ICU=@STD_ICU@ THR_FLAGS=@PTHREAD_CFLAGS@ THR_LIBS=@PTHREAD_LIBS@ +# thread local storage options - set by configure +TLS_OPTIONS=@TLS_OPTIONS@ + # Default programs and tools to be used in the build process SH= sh -c @@ -128,7 +131,7 @@ ECHO= echo QUIET_ECHO= @echo CD= cd CAT= cat -AR= ar crsu +AR= ar @AR_OPTIONS@ crsu LN= @LN_S@ RANLIB= @RANLIB@ BTYACC=$(ROOT)/extern/btyacc/btyacc diff --git a/builds/posix/prefix.aix_powerpc_xlc b/builds/posix/prefix.aix_powerpc_xlc index d0708ad426..1d88b095ba 100644 --- a/builds/posix/prefix.aix_powerpc_xlc +++ b/builds/posix/prefix.aix_powerpc_xlc @@ -40,21 +40,63 @@ # # export CC=cc_r # export CXX=xlC_r +# export CFLAGS="-q64 -qtls=default" +# export CXXFLAGS="-q64 -qtls=default" # +# Useful predefined macros from IBM XL C++ +# __IBMCPP__, indicates the level of the XL C++ compiler, e.g. 1010 + +# These macros are predefined by the compiler # xlC does not define _POWER or _AIX, which gcc does. xlC does define # __powerpc and __PPC, which Firebird code base doesn't check. +# __BIG_ENDIAN__ +# __powerpc +# __PPC +# __unix -# qstaticinline, http://www-01.ibm.com/support/docview.wss?uid=swg21044588 -PROD_FLAGS=-O3 -qchars=signed -qstaticinline -qlanglvl=newexcp -DNDEBUG -D_AIX -D_POWER -DEV_FLAGS=-O0 -qchars=signed -qstaticinline -qlanglvl=newexcp -D_AIX -D_POWER # AIX ld option to set run-time library path is -Wl-blibpath:path1:path2 # Additional -blibpath options are not additive! All paths must be provided as a colon separated list. -# LIB_LINK_RPATH:=-Wl-blibpath: -# LIB_PATH_OPTS = $(LIB_LINK_RPATH)$(FirebirdInstallPrefix)/lib:$(FirebirdInstallPrefix)/intl:/usr/lib:/lib +LIB_PATH_OPTS= -Wl,-blibpath:$(FirebirdInstallPrefix)/lib:$(FirebirdInstallPrefix)/intl:/usr/local/lib:/usr/lib:/lib + +# Flags shared by production and debug build +# -qstaticinline, treat inline functions as static instead of extern +# -qstaticinline removed, interferes with FB's placement new +COMMON_FLAGS= -qchars=signed -qlanglvl=newexcp -qroconst \ + -D__IBM_ALLOW_OVERRIDE_PLACEMENT_NEW \ + $(TLS_OPTIONS) + +# -qinfo=all:noppt:nopor:notrd:nouse, useful, but gives *so* many warnings! +# -qextchk, ***AVOID***, causes "type mismatches for symbol" building gpre_static +# -qcheck, generate code to perform *runtime* bounds, null-pointer, and div by zero checking +# -qformat, warn of problems with string put and output format specifiers. +# most qformat options tested useless to us, but zln (zero-length formats) and +# exarg (excess arguments) are handy +# -qinitauto, initialize uninitialized automatic vars to value for debugging +# -qwarn64, warn about data conversion problems between 32-bit and 64-bit modes +# -qstrict, ensure optimizations don't alter the semantics of the program +PROD_FLAGS=$(COMMON_FLAGS) -O3 -qstaticinline -qstrict +DEV_FLAGS=$(COMMON_FLAGS) -g -O0 \ + -qcheck -qformat=noall:exarg:zln + +LINK_OPTS= $(LDFLAGS) $(THR_FLAGS) $(UNDEF_FLAGS) $(LIB_PATH_OPTS) -Wl,-bbigtoc,-brtl +LIB_LINK_OPTIONS= $(LDFLAGS) $(THR_FLAGS) $(LIB_PATH_OPTS) -bM:SRE -bnoentry -Wl,-G,-bbigtoc,-bexpall + +# AIX ld uses "export files" to manage symbol visibility. Export files are +# functionally similar to "version files" on ELF systems and are specified +# with the "-Wl,-bE:exportfile.exp" option. +LINK_FIREBIRD_SYMBOLS=$(LIB_LINK_MAPFILE)$(ROOT)/builds/posix/firebird.exp +LINK_FIREBIRD_EMBED_SYMBOLS=$(LINK_FIREBIRD_SYMBOLS) +LINK_FIREBIRD_CLIENT_SYMBOLS=$(LINK_FIREBIRD_SYMBOLS) +LINK_TRACE_SYMBOLS=$(LIB_LINK_MAPFILE)$(ROOT)/builds/posix/fbtrace.exp +LINK_FBINTL_SYMBOLS=$(LIB_LINK_MAPFILE)$(ROOT)/builds/posix/fbintl.exp +LINK_IBUTIL_SYMBOLS=$(LIB_LINK_MAPFILE)$(ROOT)/builds/posix/ib_util.exp +LIB_LINK_MAPFILE=-Wl,-bE: + +# These options aren't used by AIX (XCOFF) object files... LIB_LINK_RPATH= -LIB_PATH_OPTS= +LIB_LINK_SONAME= OS_ServerFiles=inet_server.cpp diff --git a/configure.in b/configure.in index efa22ae7be..4b9c03d8bb 100644 --- a/configure.in +++ b/configure.in @@ -47,6 +47,9 @@ RPM64= dnl Test for realtime library presence? RT_LIB_CHECK=false +dnl Test for special ar options? +AR_OPT_CHECK=false + case "$target" in i686-*-darwin*) MAKEFILE_PREFIX=darwin_i386 @@ -79,7 +82,10 @@ dnl CPU_TYPE=ppc64 dnl ibm xlC has many invocations, like xlC, xlc++, or xlc_r7 comp=`echo "$CXX" | cut -c1-3 | dd conv=lcase 2>/dev/null` if test "$comp" = "xlc"; then + AR_OPT_CHECK=true + TLS_OPTIONS="-qtls=default" MAKEFILE_PREFIX=aix_powerpc_xlc + ICU_PLATFORM=AIXPPCXLC else MAKEFILE_PREFIX=aix_powerpc fi @@ -89,7 +95,6 @@ dnl ibm xlC has many invocations, like xlC, xlc++, or xlc_r7 AC_DEFINE(AIX, 1, [Define this if OS is AIX]) EDITLINE_FLG=N SHRLIB_EXT=so -dnl ICU_PLATFORM=AIXPPCXLC ;; amd64-*-freebsd*) @@ -304,6 +309,7 @@ fi AM_BINRELOC AC_SUBST(MAKEFILE_PREFIX) +AC_SUBST(AR_OPTIONS) AC_SUBST(PLATFORM) AC_SUBST(SHRLIB_EXT) AC_SUBST(ICU_PLATFORM) @@ -493,6 +499,7 @@ AC_CHECK_HEADERS(sys/timeb.h) AC_CHECK_HEADERS(sys/param.h) AC_CHECK_HEADERS(sys/mount.h) AC_CHECK_HEADERS(sys/ioctl.h) +AC_CHECK_HEADERS(sys/select.h) AC_CHECK_HEADERS(limits.h) AC_CHECK_HEADERS(setjmp.h) AC_CHECK_HEADERS(stdarg.h) @@ -572,6 +579,13 @@ AC_COMPILE_IFELSE( void vafun(const char* fmt, ...) {va_list par, par2; va_start(par, fmt); va_copy(par2, par); va_end(par2); va_end(par);}]], [[return 0;]])], AC_DEFINE(HAVE_VA_COPY, 1, [Define this if va_copy() is defined in stdarg.h])) + +if test "$AR_OPT_CHECK" = "true"; then +dnl if 64-bit mode, then archive tool, ar, needs -X64 option + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM(,[[int lp64 = __64BIT__; ]])], + [AR_OPTIONS=-X64],) +fi AC_LANG_POP(C++) dnl Check for functions @@ -836,9 +850,13 @@ case "$PLATFORM" in esac dnl Detect support for ISO syntax for thread-locals +pre_tls_cxxflags=$CXXFLAGS +CXXFLAGS=$TLS_OPTIONS AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[__thread int a = 42;]],[[a = a + 1;]])], AC_DEFINE(HAVE___THREAD, 1, [Define it if compiler supports ISO syntax for thread-local storage]),) +CXXFLAGS=$pre_tls_cxxflags +AC_SUBST(TLS_OPTIONS) dnl ##################### DO NOT ADD ANY TESTS BELOW ########################### diff --git a/src/common/classes/alloc.h b/src/common/classes/alloc.h index d7ec03cb86..0afb3b4313 100644 --- a/src/common/classes/alloc.h +++ b/src/common/classes/alloc.h @@ -49,7 +49,11 @@ stdlib.h (EKU) */ #endif -#if defined (_MSC_VER) || defined (__SUNPRO_CC) +#ifdef __xlC__ +#include +#endif + +#if defined (_MSC_VER) || defined (__SUNPRO_CC) || defined(__xlC__) #define THROW_BAD_ALLOC #else #define THROW_BAD_ALLOC throw (Firebird::BadAlloc) diff --git a/src/jrd/SysFunction.cpp b/src/jrd/SysFunction.cpp index 90bd68e062..007dadccf1 100644 --- a/src/jrd/SysFunction.cpp +++ b/src/jrd/SysFunction.cpp @@ -3133,7 +3133,7 @@ dsc* evlUuidToChar(Jrd::thread_db* tdbb, const SysFunction* function, Jrd::jrd_n -#if defined (_MSC_VER) || defined (__SUNPRO_CC) +#if defined (_MSC_VER) || defined (__SUNPRO_CC) || defined(__xlC__) typedef StdMathFunc VoidPtrStdMathFunc; #else typedef void* VoidPtrStdMathFunc; diff --git a/src/remote/inet.cpp b/src/remote/inet.cpp index 2c8ffe5f20..7feecdeda8 100644 --- a/src/remote/inet.cpp +++ b/src/remote/inet.cpp @@ -88,6 +88,9 @@ #include #include #include +#ifdef HAVE_SYS_SELECT_H +#include +#endif #endif // !WIN_NT const int INET_RETRY_CALL = 5;