Skip to Content.
Sympa Menu

freetds - [freetds] Re: Patch for Mac OS X (configure script)

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Jonathan Monroe <monroej_freetds AT actualtechnologies.com>
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] Re: Patch for Mac OS X (configure script)
  • Date: Wed, 10 Mar 2004 20:31:00 -0600

On Dec 30, 2003, at 5:58 PM, Frediano ZIGLIO wrote:

I searched where to apply patch in distribution and I found this code
(in ltcf-c.sh)

darwin* | rhapsody*)
case "$host_os" in
rhapsody* | darwin1.[012])
allow_undefined_flag='-undefined suppress'
;;
*) # Darwin 1.3 on
allow_undefined_flag='-flat_namespace -undefined suppress'
;;
esac
archive_cmds='$CC $(if test .$module = .yes; then echo -bundle; else
echo -dynamiclib; fi) $allow_undefined_flag -o $lib $libobjs $deplibs
$linkopts -install_name $rpath/$soname $verstring'
# We need to add '_' to the symbols in $export_symbols first
#archive_expsym_cmds="$archive_cmds"' && strip -s $export_symbols
$lib'
hardcode_direct=yes
hardcode_shlibpath_var=no
whole_archive_flag_spec='-all_load $convenience'
;;

so the line is processed only on Apple machines (rhapsody is another
Apple platform)... I don't have this file, the code it's in my configure
script, however is much more complex:

darwin* | rhapsody*)
if $CC -v 2>&1 | grep 'Apple' >/dev/null ; then
archive_cmds_need_lc=no
case "$host_os" in
rhapsody* | darwin1.[012])
allow_undefined_flag='-undefined suppress'
;;
*) # Darwin 1.3 on
test -z ${LD_TWOLEVEL_NAMESPACE} &&
allow_undefined_flag='-flat_namespace -undefined suppress'
;;
esac
# FIXME: Relying on posixy $() will cause problems for
# cross-compilation, but unfortunately the echo tests do
not
# yet detect zsh echo's removal of \ escapes. Also zsh
mangles
# `"' quotes if we put them in here... so don't!
lt_int_apple_cc_single_mod=no
output_verbose_link_cmd='echo'
if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then
lt_int_apple_cc_single_mod=yes
fi
if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
archive_cmds='$CC -dynamiclib -single_module
$allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags
-install_name $rpath/$soname $verstring'
else
archive_cmds='$CC -r ${wl}-bind_at_load -keep_private_externs
-nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib
$allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags
-install_name $rpath/$soname $verstring'
fi
module_cmds='$CC -bundle ${wl}-bind_at_load $allow_undefined_flag
-o $lib $libobjs $deplibs$compiler_flags'
# Don't fix this by using the ld -exported_symbols_list flag, it
doesn't exist in older darwin ld's
if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e
"s,^\(..*\),_&," < $export_symbols >
$output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module
$allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags
-install_name $rpath/$soname $verstring~nmedit -s
$output_objdir/${libname}-symbols.expsym ${lib}'
else
archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e
"s,^\(..*\),_&," < $export_symbols >
$output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load
-keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC
-dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs
$compiler_flags -install_name $rpath/$soname $verstring~nmedit -s
$output_objdir/${libname}-symbols.expsym ${lib}'
fi
module_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e
"s,^\(..*\),_&," < $export_symbols >
$output_objdir/${libname}-symbols.expsym~$CC -bundle
$allow_undefined_flag -o $lib $libobjs $deplibs$compiler_flags~nmedit
-s $output_objdir/${libname}-symbols.expsym ${lib}'
hardcode_direct=no
hardcode_automatic=yes
hardcode_shlibpath_var=unsupported
whole_archive_flag_spec='-all_load $convenience'
link_all_deplibs=yes
fi
;;

I don't understand why darwin it's so different !!! I hope one day will
have more compatible tools >:-<

This patch assumes that the linker should be building darwin dylibs with a flat namespace. This document from Apple discusses why they should actually be built using two level namespaces starting in OS X 10.1 (darwin 5.0): http://developer.apple.com/documentation/ReleaseNotes/DeveloperTools/ TwoLevelNamespaces.html

The main reason for using two level namespaces is to avoid namespace collisions when the same symbol is used in multiple modules. In the case of an app that links to the darwin libiodbc.dylib, the ODBC functions would exist in both libiodbc.dylib and libtdsodbc.dylib. Since libtdsodbc.dylib is built using a flat namespace, the library loader gets confused and can't resolve the symbol.

I'd like to propose a patch, but I don't understand anything about these config scripts or even where they are maintained (this particular script doesn't appear to be in CVS), so I'll just describe what I think it should do and hopefully a toolsmith can pick this up and incorporate it into the build:

For versions of darwin earlier than 5.0, keep the script the way it is.
For 5.0 or later, allow_undefined_flag='-twolevel_namespace'

I think its OK to remove the "-undefined" flag.

Jonathan Monroe




  • [freetds] Re: Patch for Mac OS X (configure script), Jonathan Monroe, 03/10/2004

Archive powered by MHonArc 2.6.24.

Top of Page