This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: mips asm-unistd.h patch for glibc-2.3.5


TheNop wrote:
I successfully build a crosstoolchain (with Steven's patches)

Which patches were those, exactly?


for a mips target with crosstool-0.32.
-binutils-2.16
-gcc-3.4.3
-glibc-2.3.5
-linux-2.6.8
But to build application (eg. strace-4.5.9) using the old syscall macros I had to applay the attached patch.


Hopefully it helps someone else and Dan can include it to the next crosstool release.

When submitting patches for crosstool, please include a comment at the top saying where you got it, and give verbatim the error message it fixes, if possible. That makes it much easier for me to include, and more likely to help other random people searching for a fix for that error message.

A little google searching for text from that patch pulls up
http://dev.gentoo.org/~halcy0n/glibc/patches/6640_mips_unistd_h-fixes.patch
Is that were you got it, or did you grab it from cvs?

Thanks,
Dan



Best regards
TheNop


------------------------------------------------------------------------


--- glibc-2.3.5/sysdeps/unix/sysv/linux/mips/Makefile 2004-11-24 05:38:15.000000000 +0100
+++ glibc-2.3.5-patched/sysdeps/unix/sysv/linux/mips/Makefile 2005-05-16 13:54:57.000000000 +0200
@@ -9,11 +9,73 @@
no_syscall_list_h = 1
-# Generate the list of SYS_* macros for the system calls (__NR_* macros).
-# We generate not only SYS_<syscall>, pointing at SYS_<abi>_<syscall> if
-# it exists, but also define SYS_<abi>_<syscall> for all ABIs.
+# A callable macro that expands to a shell command. Preprocess file $(1)
+# using ABI option $(2) and see which macros it defines. Print FOO for each
+# macro of the form __NR$(3)_FOO, filtering out ABI-specific __NR macros
+# that have a prefix other than $(3).
+mips_list_syscalls = $(filter-out -m%,$(CC)) -E -x c $(+includes) \
+ $(sysincludes) -D_LIBC -dM -mabi=$(2) $(1) | \
+ sed -n 's@^\#define __NR$(3)_\([^ ]*\) .*@\1@p' | \
+ sed -e '/^[ON]32_/d' -e '/^N64_/d' -e '/^64_/d' | \
+ LC_ALL=C sort
+
+# Generate a list of SYS_* macros from the linux __NR macros.
+#
+# Before version 2.6, linux had separate 32-bit and 64-bit MIPS ports,
+# each with its own set of headers. The ports were merged for 2.6 and
+# this merged port defines the syscalls in a slightly different way.
+# There are therefore three sets of headers that we need to consider:
+#
+# (1) Headers from the separate 32-bit MIPS port. They just define
+# a single list of __NR macros.
+#
+# (2) Headers from the separate 64-bit MIPS port. They unconditionally
+# define syscalls for all three ABIs, with o32 syscalls prefixed
+# by __NR_O32, n32 syscalls prefixed by __NR_N32 and n64 syscalls
+# prefixed by plain __NR.
+#
+# (3) Headers from the combined port. They use the _MIPS_SIM macro to
+# define the right set of syscalls for the current ABI. The syscalls
+# themselves have no special ABI prefix, but the headers also define:
+#
+# __NR_O32_Linux{,_syscalls}
+# __NR_N32_Linux{,_syscalls}
+# __NR_64_Linux{,_syscalls}
+#
+# In case (1) we just want a simple list of SYS_* macros. In cases (2)
+# and (3) we want a file that will work for all three ABIs, regardless
+# of which ABI we are currently using. We also want the file to work
+# if the user later moves from (2) to (3). Thus the file we create
+# for (2) and (3) has the form:
+#
+# #if _MIPS_SIM == _MIPS_SIM_NABI32
+# # ifdef __NR_N32_open
+# # define SYS_n32syscall1 __NR_N32_n32syscall1
+# # ...
+# # else
+# # define SYS_n32syscall1 __NR_n32syscall1
+# # ...
+# # endif
+# #elif _MIPS_SIM == _MIPS_SIM_ABI64
+# # define SYS_n64syscall1 __NR_n64syscall1
+# # ...
+# #else
+# # ifdef __NR_O32_open
+# # define SYS_o32syscall1 __NR_O32_o32syscall1
+# # ...
+# # else
+# # define SYS_o32syscall1 __NR_o32syscall1
+# # ...
+# # endif
+# #endif
+#
+# Here, __NR_N32_open and __NR_O32_open are used to detect case (2)
+# over case (3). The n64 SYS_* macros can always use the normal
+# ABI-less names.
$(objpfx)syscall-%.h $(objpfx)syscall-%.d: ../sysdeps/unix/sysv/linux/mips/sys/syscall.h
$(make-target-directory)
+ $(CC) -E -x c $(+includes) $(sysincludes) -D_LIBC $< -MD -MP \
+ -MF $(@:.h=.d)-t -MT '$(@:.d=.h) $(@:.h=.d)' > /dev/null
{ \
echo '/* Generated at libc build time from kernel syscall list. */';\
echo ''; \
@@ -22,28 +84,38 @@
echo '#endif'; \
echo ''; \
echo '#include <sgidefs.h>'; \
- rm -f $(@:.d=.h).newt; \
- $(CC) -E -MD -MP -MF $(@:.h=.d)-t -MT '$(@:.d=.h) $(@:.h=.d)' \
- -x c $(+includes) $(sysincludes) $< -D_LIBC -dM | \
- sed -n 's@^#define __NR_\([^ ]*\) .*$$@#define SYS_\1 __NR_\1@p' \
- > $(@:.d=.h).newt; \
- if grep SYS_O32_ $(@:.d=.h).newt > /dev/null; then \
+ rm -f $(@:.d=.h).new32 $(@:.d=.h).newn32 $(@:.d=.h).new64; \
+ $(call mips_list_syscalls,$<,n32,_N32) > $(@:.d=.h).newn32; \
+ if test -s $(@:.d=.h).newn32; then \
+ if grep open $(@:.d=.h).newn32 > /dev/null; then \
+ $(call mips_list_syscalls,$<,32,_O32) > $(@:.d=.h).new32; \
+ $(call mips_list_syscalls,$<,64,) > $(@:.d=.h).new64; \
+ else \
+ $(call mips_list_syscalls,$<,32,) > $(@:.d=.h).new32; \
+ $(call mips_list_syscalls,$<,n32,) > $(@:.d=.h).newn32; \
+ $(call mips_list_syscalls,$<,64,) > $(@:.d=.h).new64; \
+ fi; \
echo '#if _MIPS_SIM == _ABIN32'; \
- sed -n 's/^\(#define SYS_\)N32_/\1/p' < $(@:.d=.h).newt | \
- LC_ALL=C sort; \
+ echo '# ifdef __NR_N32_open'; \
+ sed 's@\(.*\)@# define SYS_\1 __NR_N32_\1@' < $(@:.d=.h).newn32; \
+ echo '# else'; \
+ sed 's@\(.*\)@# define SYS_\1 __NR_\1@' < $(@:.d=.h).newn32; \
+ echo '# endif'; \
echo '#elif _MIPS_SIM == _ABI64'; \
- sed -n 's/^\(#define SYS_\)N64_/\1/p' < $(@:.d=.h).newt | \
- LC_ALL=C sort; \
+ sed 's@\(.*\)@# define SYS_\1 __NR_\1@' < $(@:.d=.h).new64; \
echo '#else'; \
- sed -n 's/^\(#define SYS_\)O32_/\1/p' < $(@:.d=.h).newt | \
- LC_ALL=C sort; \
+ echo '# ifdef __NR_O32_open'; \
+ sed 's@\(.*\)@# define SYS_\1 __NR_O32_\1@' < $(@:.d=.h).new32; \
+ echo '# else'; \
+ sed 's@\(.*\)@# define SYS_\1 __NR_\1@' < $(@:.d=.h).new32; \
+ echo '# endif'; \
echo '#endif'; \
- sed -n '/^#define SYS_\([ON]32\|N64\)_/p' < $(@:.d=.h).newt | \
- LC_ALL=C sort +1.8; \
else \
- cat $(@:.d=.h).newt; \
+ $(CC) -E -x c $(+includes) $(sysincludes) -D_LIBC -dM $< | \
+ sed -n 's@^\#define __NR_\([^ ]*\) .*@\#define SYS_\1 __NR_\1@p' | \
+ LC_ALL=C sort; \
fi; \
- rm $(@:.d=.h).newt; \
+ rm -f $(@:.d=.h).new32 $(@:.d=.h).newn32 $(@:.d=.h).new64; \
} > $(@:.d=.h).new
mv -f $(@:.d=.h).new $(@:.d=.h)
ifneq (,$(objpfx))




------------------------------------------------------------------------

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com


------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]