summaryrefslogtreecommitdiffstats
path: root/configure
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-04-07 22:12:41 -0700
committerKaz Kylheku <kaz@kylheku.com>2012-04-07 22:12:41 -0700
commit1171e7042fbcedb95eecda2856275fc2a119b212 (patch)
tree17de075e44a417c2f4b1ce05a7b0e964535016b6 /configure
parentf5ce48225c096a8fade377c3c6648970fa38a5a3 (diff)
downloadtxr-1171e7042fbcedb95eecda2856275fc2a119b212.tar.gz
txr-1171e7042fbcedb95eecda2856275fc2a119b212.tar.bz2
txr-1171e7042fbcedb95eecda2856275fc2a119b212.zip
Fixes to get configure ccname=g++ working on OSX Lion.
* Makefile (conftest.syms): Use -n flag in nm so that the output is not alphabetically sorted, but numerically. We need this to get the symbols ordered by increasing offset. * configure (read_syms): New function. Factors out logic used in two places for reading the output of nm. On OSX Lion, it looks like we do not get symbol sizes but offsets only, when compiling with g++. The symbols are in an S section. When compiling with gcc, we get a common C section with symbol sizes. So the hack is to use the deltas between offsets to get the sizes. The objects had to be re-ordered in decreasing rank so alignment doesn't create padding that will get counted as the size. Interleaved dummy objects of type char should also work.
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure93
1 files changed, 57 insertions, 36 deletions
diff --git a/configure b/configure
index ebd02aec..46667045 100755
--- a/configure
+++ b/configure
@@ -711,19 +711,61 @@ fi
printf "Checking what C integer type can hold a pointer ... "
+read_syms()
+{
+ print_into_config=${1-}
+ deferred_offset=
+
+ while read symbol type offset size ; do
+ size=$(( 0$size + 0 ))
+ offset=$(( 0$offset + 0 ))
+ symbol=${symbol#_}
+ case "$type" in
+ C )
+ size=$(( offset + 0 ))
+ ;;
+ S )
+ if [ -n "$deferred_offset" ] ; then
+ size=$(( offset - deferred_offset ))
+ case "$deferred_sym" in
+ SIZEOF* )
+ eval $(printf "%s=%d\n" "$deferred_sym" "$size")
+ if [ -n "$print_into_config" ] ; then
+ printf "#define %s %s\n" "$deferred_sym" "$size" >> config.h
+ fi
+ ;;
+ esac
+ fi
+ deferred_sym=$symbol
+ deferred_offset=$offset
+ continue
+ ;;
+ esac
+ case "$symbol" in
+ SIZEOF* )
+ eval $(printf "%s=%d\n" "$symbol" "$size")
+ if [ -n "$print_into_config" ] ; then
+ printf "#define %s %s\n" "$symbol" "$size" >> config.h
+ fi
+ ;;
+ esac
+ done < conftest.syms
+}
+
if [ -z "$intptr" ] ; then
cat > conftest.c <<!
#include "config.h"
-char SIZEOF_PTR[sizeof (char *)];
-char SIZEOF_SHORT[sizeof (short)];
-char SIZEOF_INT[sizeof (int)];
-char SIZEOF_LONG[sizeof (long)];
-#ifdef HAVE_LONGLONG_T
-char SIZEOF_LONGLONG_T[sizeof (longlong_t)];
-#endif
#ifdef HAVE_SUPERLONG_T
char SIZEOF_SUPERLONG_T[sizeof (superlong_t)];
#endif
+#ifdef HAVE_LONGLONG_T
+char SIZEOF_LONGLONG_T[sizeof (longlong_t)];
+#endif
+char SIZEOF_PTR[sizeof (char *)];
+char SIZEOF_LONG[sizeof (long)];
+char SIZEOF_INT[sizeof (int)];
+char SIZEOF_SHORT[sizeof (short)];
+char DUMMY;
!
rm -f conftest.o conftest.syms
@@ -742,19 +784,7 @@ char SIZEOF_SUPERLONG_T[sizeof (superlong_t)];
SIZEOF_LONGLONG_T=0
SIZEOF_SUPERLONG_T=0
- while read symbol type offset size ; do
- size=$(( 0$size + 0 ))
- symbol=${symbol#_}
- if [ "$type" = "C" ] ; then
- size=$(( 0$offset + 0 ))
- fi
- case "$symbol" in
- SIZEOF* )
- eval $(printf "%s=%d\n" "$symbol" "$size")
- printf "#define %s %s\n" "$symbol" "$size" >> config.h
- ;;
- esac
- done < conftest.syms
+ read_syms y
rm -f conftest.syms conftest.o
@@ -823,7 +853,8 @@ printf "Conservatively guessing the alignment of wide literals ... "
if [ -z "$lit_align" ] ; then
cat > conftest.c <<!
#include <wchar.h>
-char sizeof_wchar_t[sizeof (wchar_t)];
+char SIZEOF_WCHAR_T[sizeof (wchar_t)];
+char DUMMY;
!
rm -f conftest.o conftest.syms
@@ -835,29 +866,19 @@ char sizeof_wchar_t[sizeof (wchar_t)];
exit 1
fi
- sizeof_wchar_t=0
+ SIZEOF_WCHAR_T=0
+ deferred_offset=
- while read symbol type offset size ; do
- size=$(( 0$size + 0 ))
- symbol=${symbol#_}
- if [ "$type" = "C" ] ; then
- size=$(( 0$offset + 0 ))
- fi
- case "$symbol" in
- sizeof* )
- eval $(printf "%s=%d\n" "$symbol" "$size")
- ;;
- esac
- done < conftest.syms
+ read_syms
rm -f conftest.syms conftest.o
- if [ $sizeof_wchar_t -eq 0 ] ; then
+ if [ $SIZEOF_WCHAR_T -eq 0 ] ; then
printf "failed\n"
exit 1
fi
- lit_align=$sizeof_wchar_t
+ lit_align=$SIZEOF_WCHAR_T
fi
printf "%d\n" "$lit_align"