[uClibc]compile error with gettext-0.10.40

Ilguiz Latypov ilatypov at superbt.com
Wed Apr 3 16:12:53 UTC 2002


I could build gettext by editing the uClibc header and gettext code.  I
attached the diffs and the flags script.  The script has to be adjusted to
the cross-compiler location as outlined in README_flags.

The test "Hello, world" application will execute the usual gettext calls
on a m68k board.

However, the gettext library did not use the translation string from the
.mo machine object file.  I generated the latter file with a
cross-compiled msgfmt.  Perhaps, this has something to do with locale
aliases?  I did point gettext to my own locale directory in
bindtextdomain()  call.

Ilguiz

On Wed, 3 Apr 2002, Erik Andersen wrote:

> Could you test something for me?  Try editing
> uClibc/include/error.h and comment out the two lines that 
> reference error_print_progname
-------------- next part --------------
Index: error.c
===================================================================
RCS file: /usr/local/cvsroot/uClibc/libc/misc/error/error.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- error.c	20 Mar 2002 21:49:11 -0000	1.1.1.1
+++ error.c	23 Mar 2002 07:47:36 -0000	1.2
@@ -33,7 +33,7 @@
 unsigned int error_message_count;
 /* Sometimes we want to have at most one error per line.  This
    variable controls whether this mode is selected or not.  */
-static int error_one_per_line;
+int error_one_per_line;
 
 
 void __error (int status, int errnum, const char *message, ...)
-------------- next part --------------
Index: config.sub
===================================================================
RCS file: /usr/local/cvsroot/gettext/config.sub,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- config.sub	17 Mar 2002 19:46:15 -0000	1.1.1.1
+++ config.sub	17 Mar 2002 20:53:35 -0000	1.2
@@ -234,7 +234,7 @@
 	| fr30 \
 	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
 	| i370 | i860 | i960 | ia64 \
-	| m32r | m68000 | m68k | m88k | mcore \
+	| m32r | m68000 | m68k | m68knommu | m88k | mcore \
 	| mips16 | mips64 | mips64el | mips64orion | mips64orionel \
 	| mips64vr4100 | mips64vr4100el | mips64vr4300 \
 	| mips64vr4300el | mips64vr5000 | mips64vr5000el \
@@ -293,7 +293,7 @@
 	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
 	| i*86-* | i860-* | i960-* | ia64-* \
 	| m32r-* \
-	| m68000-* | m680[01234]0-* | m68360-* | m683?2-* | m68k-* \
+	| m68000-* | m680[01234]0-* | m68360-* | m683?2-* | m68k-* | m68knommu-* \
 	| m88110-* | m88k-* | mcore-* \
 	| mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \
 	| mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \
@@ -1184,6 +1184,8 @@
 		;;
 	# This must come after -sysvr4.
 	-sysv*)
+		;;
+	-uClinux)
 		;;
 	-ose*)
 		os=-ose
Index: configure.in
===================================================================
RCS file: /usr/local/cvsroot/gettext/configure.in,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- configure.in	17 Mar 2002 19:46:15 -0000	1.1.1.1
+++ configure.in	17 Mar 2002 20:53:35 -0000	1.2
@@ -117,7 +117,9 @@
   AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works])
   AC_LANG_SAVE
   AC_LANG_CPLUSPLUS
-  AC_TRY_COMPILER([int main(){return(0);}], ac_cv_prog_cxx_works, ac_cv_prog_cxx_cross)
+  AC_TRY_COMPILE(, [int main(){return(0);}], 
+    [ac_cv_prog_cxx_works=yes; ac_cv_prog_cxx_cross=no],
+    [ac_cv_prog_cxx_works=no; ac_cv_prog_cxx_cross=yes])
   AC_LANG_RESTORE
   AC_MSG_RESULT($ac_cv_prog_cxx_works)
   if test $ac_cv_prog_cxx_works = no; then
Index: intl/Makefile.in
===================================================================
RCS file: /usr/local/cvsroot/gettext/intl/Makefile.in,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: lib/basename.c
===================================================================
RCS file: /usr/local/cvsroot/gettext/lib/basename.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- lib/basename.c	17 Mar 2002 19:46:15 -0000	1.1.1.1
+++ lib/basename.c	17 Mar 2002 20:53:36 -0000	1.2
@@ -26,7 +26,7 @@
 /* Specification.  */
 #include "basename.h"
 
-#ifndef __GNU_LIBRARY__
+#if !defined(__GNU_LIBRARY__) || defined(__UCLIBC__)
 
 #include <stdio.h>
 #include <assert.h>
Index: lib/basename.h
===================================================================
RCS file: /usr/local/cvsroot/gettext/lib/basename.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- lib/basename.h	17 Mar 2002 19:46:15 -0000	1.1.1.1
+++ lib/basename.h	17 Mar 2002 20:53:36 -0000	1.2
@@ -22,7 +22,7 @@
 /* This is where basename() is declared.  */
 #include <string.h>
 
-#ifndef __GNU_LIBRARY__
+#if !defined(__GNU_LIBRARY__) || defined(__UCLIBC__)
 /* When not using the GNU libc we use the basename implementation we
    provide here.  */
 extern char *gnu_basename PARAMS ((const char *));
Index: lib/error.c
===================================================================
RCS file: /usr/local/cvsroot/gettext/lib/error.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- lib/error.c	17 Mar 2002 19:46:15 -0000	1.1.1.1
+++ lib/error.c	2 Apr 2002 13:59:11 -0000	1.2
@@ -62,15 +62,6 @@
 # endif
 #endif
 
-/* If NULL, error will flush stdout, then print on stderr the program
-   name, a colon and a space.  Otherwise, error will call this
-   function without parameters instead.  */
-void (*error_print_progname) (
-#if __STDC__ - 0
-			      void
-#endif
-			      );
-
 /* This variable is incremented each time `error' is called.  */
 unsigned int error_message_count;
 
Index: lib/error.h
===================================================================
RCS file: /usr/local/cvsroot/gettext/lib/error.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- lib/error.h	17 Mar 2002 19:46:15 -0000	1.1.1.1
+++ lib/error.h	2 Apr 2002 13:59:11 -0000	1.2
@@ -53,15 +53,9 @@
 			   unsigned int lineno, const char *format, ...)
      __attribute__ ((__format__ (__printf__, 5, 6)));
 
-/* If NULL, error will flush stdout, then print on stderr the program
-   name, a colon and a space.  Otherwise, error will call this
-   function without parameters instead.  */
-extern void (*error_print_progname) (void);
-
 #else
 void error ();
 void error_at_line ();
-extern void (*error_print_progname) ();
 #endif
 
 /* This variable is incremented each time `error' is called.  */
Index: lib/progname.c
===================================================================
RCS file: /usr/local/cvsroot/gettext/lib/progname.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- lib/progname.c	17 Mar 2002 19:46:15 -0000	1.1.1.1
+++ lib/progname.c	2 Apr 2002 13:59:11 -0000	1.2
@@ -67,3 +67,13 @@
   if (error_with_progname)
     fprintf (stderr, "%s: ", program_name);
 }
+
+/* If NULL, error will flush stdout, then print on stderr the program
+   name, a colon and a space.  Otherwise, error will call this
+   function without parameters instead.  */
+void (*error_print_progname) (
+#if __STDC__ - 0
+			      void
+#endif
+			      );
+
Index: lib/progname.h
===================================================================
RCS file: /usr/local/cvsroot/gettext/lib/progname.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- lib/progname.h	17 Mar 2002 19:46:15 -0000	1.1.1.1
+++ lib/progname.h	2 Apr 2002 13:59:11 -0000	1.2
@@ -45,4 +45,13 @@
    is true.  */
 extern void maybe_print_progname PARAMS ((void));
 
+/* If NULL, error will flush stdout, then print on stderr the program
+   name, a colon and a space.  Otherwise, error will call this
+   function without parameters instead.  */
+extern void (*error_print_progname) (
+#if defined (__STDC__) && __STDC__
+				    void
+#endif
+				    );
+
 #endif /* _PROGNAME_H */
Index: m4/libtool.m4
===================================================================
RCS file: /usr/local/cvsroot/gettext/m4/libtool.m4,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- m4/libtool.m4	17 Mar 2002 19:46:15 -0000	1.1.1.1
+++ m4/libtool.m4	17 Mar 2002 20:53:36 -0000	1.2
@@ -221,7 +221,7 @@
 for ac_symprfx in "" "_"; do
 
   # Write the raw and C identifiers.
-[lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ 	]\($symcode$symcode*\)[ 	][ 	]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'"]
+[lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[:blank:]]\+\($symcode\+\)[[:blank:]]\+\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'"]
 
   # Check to see that the pipe works correctly.
   pipe_works=no
@@ -290,7 +290,8 @@
 	  mv conftest.$ac_objext conftstm.$ac_objext
 	  save_LIBS="$LIBS"
 	  save_CFLAGS="$CFLAGS"
-	  LIBS="conftstm.$ac_objext"
+	  test "$cross_compiling" = yes || LIBS=""
+ 	  LIBS="conftstm.$ac_objext $LIBS"
 	  CFLAGS="$CFLAGS$no_builtin_flag"
 	  if AC_TRY_EVAL(ac_link) && test -s conftest; then
 	    pipe_works=yes
@@ -3287,6 +3288,10 @@
     lt_cv_file_magic_test_file=/lib/libc.so
     ;;
   esac
+  ;;
+
+uClinux)
+  lt_cv_deplibs_check_method=pass_all
   ;;
 esac
 ])
-------------- next part --------------
#! /bin/sh -x

autoheader && aclocal -I m4 && automake && autoconf || exit 1

flags davidm uclibc ./configure --build=i686-pc-linux-gnu \
	--host=m68knommu-SuperBT-uClinux --enable-static --disable-shared \
	|| exit 1

flags davidm uclibc make

echo "Please ignore the above error if it refers to man/gettext.1.in"

cp intl/.libs/libintl.a ../install/m68k-elf/lib/ &&
cp intl/libintl.h ../install/m68k-elf/include/ && {
	make maintainer-clean
	rm -rf config.log config.status \
		autom4te.cache unspecified_executable*
	find -name "Makefile.in" -exec rm -f \{} \;
}
-------------- next part --------------
#! /bin/sh

####################################################################################
#
# This script sets up the environment variables to compile uClinux kernel,
# libraries and user-space applications.  The compiler and the C library can be
# installed in the home directory.  Their paths are hardcoded in this script.
# The usage() function below describes they ways to run this script.  See the 
# explanations in the file README on how to install cross compiling tools in home
# directory and to correct make files.
#
####################################################################################
function usage() {
	/bin/cat 2> /dev/null <<"EOT"
Usage:
	flags COMPILER [pic] LIBC make

where 
	COMPILER	is the compiler distribution, one of 
			ungerer, fiddes or davidm.
	pic		is the optional PIC mode switch.
	LIBC		is the C library to link against, one of
			ungerer, fiddes, uclibc or -.

When building the kernel, no standard C library is required.  Put
"-" as LIBC.  It seems that PIC mode is useless, superfluous when
building the kernel.  Besides, I got a compilation error in fork.c.

When building executables, put $LDFLAGS in front of the program's
file name.  This ensures that crt0.o will be linked first.  Otherwise,
the linker will produce an executable which won't start.  Put $LDLIBS
in the end:
	$CC $CFLAGS $LDFLAGS prog.c $LDLIBS -o prog
or
	$CC $CFLAGS -c prog.c
	$CC $LDFLAGS prog.o $LDLIBS -o prog

EOT
	exit 1
}
####################################################################################

if test "$1" = "ungerer" -o "$1" = "fiddes" -o "$1" = "davidm" ; then
	dist="$1"
	shift
else
	usage
fi

pic=""
if test "$1" = "pic" ; then
	pic="pic"
	shift
fi

if test "$1" = "-" -o "$1" = "ungerer" -o "$1" = "fiddes" \
   -o "$1" = "davidm" -o "$1" = "uclibc" ; then
	libc="$1"
	shift
else
	usage
fi

case "$dist" in
  "fiddes")
	export TOOLDIR="${HOME}/tools/tools-fiddes-2001-04/"
	export GCC_ARCH_DIR="${TOOLDIR}lib/gcc-lib/m68k-elf/2.95.3/"

	# I could create symlinks to the script which sets the GCC_EXEC_PREFIX
	# for internal as/ld/cpp invokations.
	# This didn't help to run the proper assembler.  This is why I ended up
	# adding the -B${TOOLDIR}lib/gcc-lib/ option to ${CC} and creating
	# symlinks in ${GCC_ARCH_DIR} that pointed to ../../../../bin.  Besides, the
	# -B option helps gcc to read its own specs file.

	# export CROSS="${GCC_ARCH_DIR}"
	export CROSS="${TOOLDIR}m68k-elf/bin/"
	;;
  "ungerer")
	export TOOLDIR="${HOME}/tools/tools-ungerer-2001-02/"
	export GCC_ARCH_DIR="${TOOLDIR}lib/gcc-lib/m68k-elf/2.95.2/"

	# export CROSS="${GCC_ARCH_DIR}"
	export CROSS="${TOOLDIR}m68k-elf/bin/"
	;;
  "davidm")
	export TOOLDIR="${HOME}/tools/tools-davidm-2002-02/"
	export GCC_ARCH_DIR="${TOOLDIR}lib/gcc-lib/m68k-elf/2.95.3/"
	export CROSS="${GCC_ARCH_DIR}"
	;;
esac


# Defining the GCC_EXEC_PREFIX variable early confuses the host's gcc.
unset GCC_EXEC_PREFIX
export GCC_EXEC_PREFIX

if [ "$dist" = "davidm" ] ; then
	if test ".${pic}" = ".pic" ; then
		export LIBGCCDIR="${GCC_ARCH_DIR}m5307/msep-data/"
		export ARCH_FLAGS="-m5307 -msep-data -msoft-float"
	else
		export LIBGCCDIR="${GCC_ARCH_DIR}m5307/"
		export ARCH_FLAGS="-m5307 -Wa,-m5307 -msoft-float"
	fi
else
	if test ".${pic}" = ".pic" ; then
		echo "I tested the PIC mode only with davidm's compiler" >&2
		exit 1
	fi
	export LIBGCCDIR="${GCC_ARCH_DIR}m5200/"
	export ARCH_FLAGS="-m5200 -Wa,-m5200 -msoft-float"
fi


export GCC_MACHINE_FLAG="-B${TOOLDIR}lib/gcc-lib/"
export GCC_BIN="${CROSS}gcc"
export LDSCRIPT="${CROSS}elf2flt.ld"

# It is important to include an existing CFLAGS value to allow
# make files re-define CFLAGS and invoke $(MAKE) which is
# "flags DIST LIBC make"
export CFLAGS="${CFLAGS} ${GCC_MACHINE_FLAG} ${ARCH_FLAGS}"
#		" -Wl,-elf2flt,-T${LDSCRIPT}"

export CC="${GCC_BIN} ${GCC_MACHINE_FLAG} ${ARCH_FLAGS}"
export CPP="${CC} -E"
export AR="${CROSS}ar"
export AS="${CROSS}as"
export LD="${CROSS}ld"
export NM="${CROSS}nm"
export RANLIB="${CROSS}ranlib"
export STRIP="${CROSS}strip"
export STRIPTOOL="${CROSS}strip"
export OBJCOPY="${GCC_ARCH_DIR}objcopy"
export OBJDUMP="${GCC_ARCH_DIR}objdump"

# This works only with the proper gcc -B option
# export GCCINCDIR=`${CC} -v 2>&1 | sed -ne "s/^Reading specs from \(.*\)specs/\1include/gp"`
export GCCINCDIR="${GCC_ARCH_DIR}include"
echo "GCCINCDIR is \"$GCCINCDIR\""

# To compile vs an alternative libc, you may need to use/adjust
# the following lines to meet your needs.

unset EXTRALIBS ; export EXTRALIBS
unset EXTRAINCLUDES ; export EXTRAINCLUDES

case "$libc" in
  "uclibc")
	export LIBDIR="${HOME}/uc/uclinux.org/install/m68k-elf/"
	export LIBCDIR="${LIBDIR}lib/"

	# uclinux.org's userland
	export INCNET="-I../include"
	export LIBNET="-L../libns -lns"
	export MPN_PATH="generic"

	export LIBRARIES="-L${LIBCDIR} -lcrypt -lresolv -lutil -lc"
	export INCLUDES="-I${LIBDIR}include"
	;;

  "ungerer")
	export LIBDIR="${HOME}/uc/uClinux-distribution/lib/"
	export LIBCDIR="${LIBDIR}libc/"

	# There are 2 locations for extra Ungerer's libraries:

	# a) Libraries shipped in binary form with Ungerer's gcc.  I couldn't
	# find the corresponding header files.
	# The header files in ${TOOLDIR}/m68k-elf/sys-include/* are libc headers, 
	# not extra ones.  They interfere with ${LIBDIR}/include (e.g. sleep() 
	# in unistd.h).
	# export EXTRALIBS="-L${TOOLDIR}m68k-elf/lib/${GCC_ARCH} \
	# 			-liberty -lio -liostream -lstdc++"

	# b) Ungerer's uClinux-coldfire libraries
	# (I didn't verify these yet.  The libraries have to be built first.)
	# export EXTRALIBS="-L${LIBDIR}???"
	# export EXTRAINCLUDES=""

	export LIBRARIES="-L${LIBCDIR} -lc"
	export INCLUDES="-I${LIBCDIR}include"
	;;

  "fiddes")
	export LIBCDIR="${TOOLDIR}m68k-elf/lib/m5200/"
	export LIBRARIES="-L${LIBCDIR} -lc -lg -liberty -lm -lstdc++"
	export INCLUDES="-I${TOOLDIR}m68k-elf/include -I${TOOLDIR}include/g++-3"
	;;
esac

if [ "$libc" = "-" ] ; then
	unset CRTOBJ
else
	CRTOBJ="${LIBCDIR}crt0.o"
fi
export CRTOBJ

export LIBRARIES="${LIBRARIES} -L${LIBGCCDIR} -lgcc ${EXTRALIBS}"
export INCLUDES="${INCLUDES} -I${GCCINCDIR} ${EXTRAINCLUDES}"

# See the comment on including a CFLAGS value from the current environment above
# The same is true for CPPFLAGS.  
# Perhaps, LDLIBS and LDFLAGS must include existing values as well.  However,
# the latter 2 variables are sensitive to repetitive options like $CRTOBJ or
# -lXXX libraries.
export CPPFLAGS="${CPPFLAGS} -D__VFORK_MACRO__ -Dconst= -D__const= -DEMBED \
	-nostdinc ${INCLUDES}"

export CFLAGS="${CPPFLAGS} ${CFLAGS}"
#	" -O2 -fomit-frame-pointer"
export CFLAGS="${CFLAGS} -fno-builtin -nostdlib"

export LIBS="${LIBRARIES}"
export LDLIBS="${LIBRARIES}"
export LDFLAGS="-nostdlib -elf2flt -T${LDSCRIPT} ${CRTOBJ}"

export MAKE="flags $dist $pic $libc make"
export FLAGS="flags $dist $pic $libc"
# export CONFIG_SHELL="flags $dist $pic $libc /bin/sh"

typeset -i UCLINUX=1
typeset -i COLDFIRE=1
typeset -i BUILD_SUPERBTLAP=1
export UCLINUX COLDFIRE BUILD_SUPERBTLAP

export HOST="m68knommu-SuperBT-uClinux"
export KERNEL_DIR="${HOME}/uc/uclinux.org/uClinux-2.4.x/"

test -z "$*" || "$@"

-------------- next part --------------
======================================================================
Installing binary tools for cross-compiling.

   Currently, the only m68k-elf-gcc distribution tested extensively is
   the package prepared by David McCullough,
	http://uclinux.org/pub/uClinux/m68k-elf-tools/

   It is recommended to install this package under 
   ~/tools/tools-davidm-2001-07/.  Follow the directions shown below.

   After downloading a particular tools archive, ~/TOOLS_ARHIVE.tar.gz,
   do the following:

	mkdir -p ~/tools/tools-AUTHOR-YYYY-MM
	cd ~/tools/tools-AUTHOR-YYYY-MM
	tar xvzf ~/TOOL_ARCHIVE.tar.gz
	mv usr/local/* .
	rm -rf usr

	# Apply adjustments to m68k-elf-ld shell script that improve 
	# command line processing:
	cd bin
	cp -a m68k-elf-ld m68k-elf-ld.orig
	# Assuming that you unpacked colilo.tgz into ~/colilo,
	patch -i ~/colilo/build/m68k-elf-ld-2002-02.patch

	cd ../lib/gcc-lib/m68k-elf/VERSION
	for a in ../../../../bin/m68k-elf-* ; do
		ln -s $a ${a##../../../../bin/m68k-elf-}
	done
	cp -a ../../../../m68k-elf/lib/elf2flt*.ld .
	ln -s ~/tools/tools-AUTHOR-YYYY-MM/bin/elf2flt ~/bin/
	ln -s ~/tools/tools-AUTHOR-YYYY-MM/bin/genromfs ~/bin/

   Make sure ~/bin is in your $PATH.  You may need to remove system-wide
   genromfs RPM package.  The directory uclinux.org/build is the one
   where the module "build" of the company's CVS repository has been 
   checked out.

   It seems to me that the file stdio.h and sys, asm*, linux and rpc
   directories in davidm's GCC include directory must be removed.  The
   reason: these are the parts of C library and uClinux kernel.  The same
   is valid for the whole ${TOOLDIR}/m68k-elf directory.

	cd ${TOOLDIR}/lib/gcc-lib/m68k-elf/2.95.3/include
	for a in stdio.h sys rpc linux asm asm-m68knommu asm-m68k ; do
		mv $a $a.davidm
	done
	cd ${TOOLDIR}
	cp -av m68k-elf/lib/ldscripts lib/gcc-lib/m68k-elf/VERSION
	find -name "*libstdc*" -exec rm -v \{} \;
	mv m68k-elf{,.davidm}

   Please make sure that the paths specified in the flags script (see
   Installing build environment) are consistent with the location of 
   the cross-compiler.

======================================================================



More information about the uClibc mailing list