[freetds] Building under UnixWare 2.0 (no joking)
wandwand at mail.ru
Tue Feb 21 06:37:17 EST 2006
SQL Server version: Microsoft SQL Server 2000, protocol v8.0
FreeTDS version: freetds-0.63
Language: ANSI C
Client OS, architecture: Novel UnixWare 2.0.3 for Intel x86
Yes, I do know that this beast is not supported
for a long time now, but I critically need connectivity between it and MS-SQL.
Yes, I understand, I am on my own now, using an unsupported commercial closed-
source system. But here are some things I bumped on, while building FreeTDS,
partly to serve those few (if any) people, hoping to build it on this platform,
partly to assure myself I am right when doing so:
First and foremost, the question: Is UnixWare 2.0 gethostbyname(3N) reentrant?
Here's an excerpt from the manpage:
All information is contained in a static area so it must be
copied if it is to be saved. For multi-threaded applications,
this must be done on a per-thread basis.
Functions that provide successive entries in files on
successive calls must be called from a single thread.
(Hope no one would sue me for reproducing it here). I suppose the answer is YES.
One sure way could be to provide --disable-threadsafe option to configure, but,
alas, I need multithreading support.
So, after configure'ing, I just set
#define NETDB_REENTRANT 1
Alternatively (and possibly, even better), I could write a wrapper around
gethostbyname(3N) (some variant of _r) with malloc() and add it to
Second, the native CCS doesn't have long long, hence the configure message:
configure: WARNING: SQL Server 2000 "bigint" 8-byte integer will not work.
Third, the libtool script chokes, when building in shared library mode,
Making all in unittests
/bin/ksh ../../libtool --mode=link cc -g -o libtds.la -rpath /usr/local/lib -version-info 4:0:0 \
-export-symbols-regex '^(tds_|tdsdump_|tds5_|tds7_).*' libtds_objects.la ../replacements/libreplacements.la \
*** Warning: inter-library dependencies are not known to be supported.
*** All declared inter-library dependencies are being dropped.
*** The inter-library dependencies that have been dropped here will be
*** automatically added whenever a program is linked with this library
*** or is declared to -dlopen it.
UX:ksh: ERROR: shift: bad number
*** Error code 1 (bu21)
UX:make: ERROR: fatal error.
so I had to provide the --disable-shared option to configure.
The problem, I suppose, is with its arguments, as borne/korn shells complain
'shift: bad number' to be the offending code - the $#
is 0 at some point. If wrapped with if [ $# -ne 0 ], subsequent execution of
the script yelds 'ln -s dummy' error. So I guess the source argument to ln
is lost or omitted somehow. This is not too painfull, and it relates only to
libtool (I still would very much appreciate having the shared versions at hand).
I might need to hack libtool myself, though.
Fourth, there is no basename() function replacement in src/apps/defncopy.c!
I copied it from bsqldb.c (can post the patch).
Fifth, the strcasecmp is in libucb.a on this platform, so I had to edit the
Makefiles in srs/pool, src/server, src/apps to add
LIBS = -lc /usr/ucblib/libucb.a
Finally, after building the tsql binary, creating a test tds.conf and trying to
tsql -Itds.conf -Stest -U sa -P pass
locale is "en_US"
locale charset is "ISO8859-1"
Assertion failed: ret == 0, file iconv.c, line 357
Stack Trace for p1, Program tsql
 _kill(0x5b4b, 0x6) [0xbffb82ef]
 abort(presumed: 0x8047b4c, 0x80728ec, 0) [0xbffe6c15]
 __assert(0x806d400, 0x806d40c, 0x165) [0xbffe7490]
 tds_iconv_open(tds=0x8072598, charset="ISO8859-1") [iconv.c at 357]
 tds_connect(tds=0x8072598, connection=0x80728ec) [login.c at 239]
 main(argc=7, argv=0x8047da4, 0x8047dc4) [tsql.c at 512]
 _start() [0x804946c]
So I had to re-configure with the --disable-iconv and re-make.
And, it worked!
Now I use IP addresses instead of hostnames, to ensure I won't trigger any
problems with gethostbyname(3N).
Probably, there is also no decent UNICODE et al support, because of disabling
PREREQUISITES: Native UnixWare CCS (incl. make).
OPTIONS TO CONFIGURE: --disable-shared --disable-libiconv
HAND-EDITING: include/config.h: #define NETDB_REENTRANT 1
src/app/Makefile: LIBS = -lc /usr/ucblib/libucb.a
UNSUPPORTED OPTIONS: libiconv, shared libraries, probably some sort of problems
with name-to-IP-address resolution.
The rest of the package should be OK. I appreciate very highly the degree of
FreeTDS portability, as it is capable to be built on an ancient system as
UnixWare 2.0 now is.
I can post the patch & the config.log, as well as the cores I got.
All I ask is:
1. some hints on how to enable libtool to generate shared libraries,
2. some hints on guarranteed/decent support for character conversions,
3. confirming my thoughts about gethostbyname(3N)
in that order of importance.
Please note, that I am ready to do at least part of the programming tasks
myself and open to share the results with the rest of the community.
More information about the FreeTDS