summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog18
-rw-r--r--Makefile2
-rwxr-xr-xconfigure93
3 files changed, 76 insertions, 37 deletions
diff --git a/ChangeLog b/ChangeLog
index 6ee07d65..abedc1ed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
2012-04-07 Kaz Kylheku <kaz@kylheku.com>
+ 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.
+
+2012-04-07 Kaz Kylheku <kaz@kylheku.com>
+
* configure: Print done and terminate line after checking for
clashing symbols.
diff --git a/Makefile b/Makefile
index 19fabd4b..f784b7e0 100644
--- a/Makefile
+++ b/Makefile
@@ -181,7 +181,7 @@ conftest2: conftest1.c conftest2.c
$(CC) $(CFLAGS) -o $@ $^
conftest.syms: conftest.o
- $(NM) -t o -P $^ > $@
+ $(NM) -n -t o -P $^ > $@
.PHONY: conftest.yacc
conftest.yacc:
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"