Re: [Mesa-dev] [PATCH] gen_matypes: fix cross-compiling with gcc

2013-08-24 Thread Mike Frysinger
On Thursday 18 July 2013 16:59:52 Matt Turner wrote:
> On Mon, Feb 4, 2013 at 6:27 PM, Mike Frysinger  wrote:
> > The current gen_matypes logic assumes that the host compiler will produce
> > information that is useful for the target compiler.  Unfortunately, this
> > is not the case whenever cross-compiling.
> > 
> > When we detect that we're cross-compiling and using GCC, use the target
> > compiler to produce assembly from the gen_matypes.c source, then process
> > it with a shell script to create a usable header.  This is similar to how
> > the linux kernel creates its asm-offsets.c file.
> > 
> > Signed-off-by: Mike Frysinger 
> > ---
> 
> Thanks, committed (finally).

hmm, i'm glad it still applied :)
-mike


signature.asc
Description: This is a digitally signed message part.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] gen_matypes: fix cross-compiling with gcc

2013-02-05 Thread Eric Anholt
Mike Frysinger  writes:

> The current gen_matypes logic assumes that the host compiler will produce
> information that is useful for the target compiler.  Unfortunately, this
> is not the case whenever cross-compiling.
>
> When we detect that we're cross-compiling and using GCC, use the target
> compiler to produce assembly from the gen_matypes.c source, then process
> it with a shell script to create a usable header.  This is similar to how
> the linux kernel creates its asm-offsets.c file.

Oh, cool.  But is there any reason to keep producing gen_matypes as a
binary instead of just always using this script?


pgpkOS8AYZQAu.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] gen_matypes: fix cross-compiling with gcc

2013-07-18 Thread Matt Turner
On Mon, Feb 4, 2013 at 6:27 PM, Mike Frysinger  wrote:
> The current gen_matypes logic assumes that the host compiler will produce
> information that is useful for the target compiler.  Unfortunately, this
> is not the case whenever cross-compiling.
>
> When we detect that we're cross-compiling and using GCC, use the target
> compiler to produce assembly from the gen_matypes.c source, then process
> it with a shell script to create a usable header.  This is similar to how
> the linux kernel creates its asm-offsets.c file.
>
> Signed-off-by: Mike Frysinger 
> ---

Thanks, committed (finally).
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] gen_matypes: fix cross-compiling with gcc

2012-02-01 Thread Jose Fonseca
I'm not familiar with with autotools to comment on those bits, but I think this 
is a pretty neat idea.

This could be also when when cross compiling for windows w/ mingw.

Jose

- Original Message -
> The current gen_matypes logic assumes that the host compiler will
> produce
> information that is useful for the target compiler.  Unfortunately,
> this
> is not the case whenever cross-compiling.
> 
> When we detect that we're cross-compiling and using GCC, use the
> target
> compiler to produce assembly from the gen_matypes.c source, then
> process
> it with a shell script to create a usable header.  This is similar to
> how
> the linux kernel creates its asm-offsets.c file.
> 
> Signed-off-by: Mike Frysinger 
> ---
> Note: please keep me on cc as i'm not subscribed
> 
>  configs/autoconf.in|2 ++
>  configure.ac   |6 ++
>  src/mesa/x86/Makefile  |   18 +++---
>  src/mesa/x86/gen_matypes.c |   35
>  +--
>  4 files changed, 52 insertions(+), 9 deletions(-)
> 
> diff --git a/configs/autoconf.in b/configs/autoconf.in
> index bb8f2c3..4ad49ea 100644
> --- a/configs/autoconf.in
> +++ b/configs/autoconf.in
> @@ -213,3 +213,5 @@ ifneq ($(LLVM_VERSION),)
>  endif
>  
>  HAVE_XF86VIDMODE = @HAVE_XF86VIDMODE@
> +
> +GEN_ASM_OFFSETS = @GEN_ASM_OFFSETS@
> diff --git a/configure.ac b/configure.ac
> index 0e03af7..25c30d9 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -106,6 +106,7 @@ AC_MSG_RESULT([$acv_mesa_CLANG])
>  
>  dnl If we're using GCC, make sure that it is at least version 3.3.0.
>   Older
>  dnl versions are explictly not supported.
> +GEN_ASM_OFFSETS=no
>  if test "x$GCC" = xyes -a "x$acv_mesa_CLANG" = xno; then
>  AC_MSG_CHECKING([whether gcc version is sufficient])
>  major=0
> @@ -123,7 +124,12 @@ if test "x$GCC" = xyes -a "x$acv_mesa_CLANG" =
> xno; then
>  else
>  AC_MSG_RESULT([yes])
>  fi
> +
> +if test "x$cross_compiling" = xyes; then
> +GEN_ASM_OFFSETS=yes
> +fi
>  fi
> +AC_SUBST([GEN_ASM_OFFSETS])
>  
>  
>  MKDEP_OPTIONS=-fdepend
> diff --git a/src/mesa/x86/Makefile b/src/mesa/x86/Makefile
> index 9716dc2..0dba5a2 100644
> --- a/src/mesa/x86/Makefile
> +++ b/src/mesa/x86/Makefile
> @@ -13,8 +13,7 @@ INCLUDE_DIRS = \
>   -I../math \
>   -I../tnl
>  
> -
> -default: gen_matypes matypes.h
> +default: matypes.h
>  
>  clean:
>   -rm -f matypes.h gen_matypes
> @@ -24,9 +23,22 @@ gen_matypes: gen_matypes.c
>   $(HOST_CC) $(ARCH_FLAGS) $(INCLUDE_DIRS) $(HOST_CFLAGS)
>   gen_matypes.c -o gen_matypes
>  
>  # need some special rules here, unfortunately
> -matypes.h: ../main/mtypes.h ../tnl/t_context.h gen_matypes
> +matypes.h: ../main/mtypes.h ../tnl/t_context.h
> +
> +ifeq ($(GEN_ASM_OFFSETS),yes)
> +
> +matypes.h: gen_matypes.c
> + $(CC) $(ARCH_FLAGS) $(INCLUDE_DIRS) $(CFLAGS) gen_matypes.c
> -DASM_OFFSETS -S -o - | \
> + sed -n '/^->/{s:^->::;/[$$]/{s:^:#define :;s:[$$]::};p}' > $@
> +
> +else
> +
> +default: gen_matypes
> +matypes.h: gen_matypes
>   ./gen_matypes > matypes.h
>  
> +endif
> +
>  common_x86_asm.o: matypes.h
>  3dnow_normal.o: matypes.h
>  3dnow_xform1.o: matypes.h
> diff --git a/src/mesa/x86/gen_matypes.c b/src/mesa/x86/gen_matypes.c
> index 97f71f9..b359bb8 100644
> --- a/src/mesa/x86/gen_matypes.c
> +++ b/src/mesa/x86/gen_matypes.c
> @@ -52,7 +52,7 @@ do {
> \
> printf( "\n" );   \
> printf( "/*
> ="\
>  "\n" );  \
> -   printf( " * Offsets for %s\n", x );   
> \
> +   printf( " * Offsets for " x "\n" );   
> \
> printf( " */\n" );
> \
> printf( "\n" );   \
>  } while (0)
> @@ -61,20 +61,43 @@ do {  
> \
>  do { \
> printf( "\n" );   \
> printf( "/*\n" ); \
> -   printf( " * Flags for %s\n", x ); \
> +   printf( " * Flags for " x "\n" ); \
> printf( " */\n" );
> \
> printf( "\n" );   \
>  } while (0)
>  
> -#define OFFSET( s, t, m )\
> -   printf( "#define %s\t%lu\n", s, (unsigned long) offsetof( t, m )
> );
> +#ifdef ASM_OFFSETS
>  
> -#define SIZEOF( s, t )   
> \
> -   printf( "#define %s

Re: [Mesa-dev] [PATCH] gen_matypes: fix cross-compiling with gcc

2012-02-01 Thread Matt Turner
On Tue, Jan 31, 2012 at 6:07 PM, Mike Frysinger  wrote:
> The current gen_matypes logic assumes that the host compiler will produce
> information that is useful for the target compiler.  Unfortunately, this
> is not the case whenever cross-compiling.
>
> When we detect that we're cross-compiling and using GCC, use the target
> compiler to produce assembly from the gen_matypes.c source, then process
> it with a shell script to create a usable header.  This is similar to how
> the linux kernel creates its asm-offsets.c file.
>
> Signed-off-by: Mike Frysinger 
> ---
> Note: please keep me on cc as i'm not subscribed
>
>  configs/autoconf.in        |    2 ++
>  configure.ac               |    6 ++
>  src/mesa/x86/Makefile      |   18 +++---
>  src/mesa/x86/gen_matypes.c |   35 +--
>  4 files changed, 52 insertions(+), 9 deletions(-)
>
> diff --git a/configs/autoconf.in b/configs/autoconf.in
> index bb8f2c3..4ad49ea 100644
> --- a/configs/autoconf.in
> +++ b/configs/autoconf.in
> @@ -213,3 +213,5 @@ ifneq ($(LLVM_VERSION),)
>  endif
>
>  HAVE_XF86VIDMODE = @HAVE_XF86VIDMODE@
> +
> +GEN_ASM_OFFSETS = @GEN_ASM_OFFSETS@
> diff --git a/configure.ac b/configure.ac
> index 0e03af7..25c30d9 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -106,6 +106,7 @@ AC_MSG_RESULT([$acv_mesa_CLANG])
>
>  dnl If we're using GCC, make sure that it is at least version 3.3.0.  Older
>  dnl versions are explictly not supported.
> +GEN_ASM_OFFSETS=no
>  if test "x$GCC" = xyes -a "x$acv_mesa_CLANG" = xno; then
>     AC_MSG_CHECKING([whether gcc version is sufficient])
>     major=0
> @@ -123,7 +124,12 @@ if test "x$GCC" = xyes -a "x$acv_mesa_CLANG" = xno; then
>     else
>         AC_MSG_RESULT([yes])
>     fi
> +
> +    if test "x$cross_compiling" = xyes; then
> +        GEN_ASM_OFFSETS=yes
> +    fi
>  fi
> +AC_SUBST([GEN_ASM_OFFSETS])
>
>
>  MKDEP_OPTIONS=-fdepend
> diff --git a/src/mesa/x86/Makefile b/src/mesa/x86/Makefile
> index 9716dc2..0dba5a2 100644
> --- a/src/mesa/x86/Makefile
> +++ b/src/mesa/x86/Makefile
> @@ -13,8 +13,7 @@ INCLUDE_DIRS = \
>        -I../math \
>        -I../tnl
>
> -
> -default: gen_matypes matypes.h
> +default: matypes.h
>
>  clean:
>        -rm -f matypes.h gen_matypes
> @@ -24,9 +23,22 @@ gen_matypes: gen_matypes.c
>        $(HOST_CC) $(ARCH_FLAGS) $(INCLUDE_DIRS) $(HOST_CFLAGS) gen_matypes.c 
> -o gen_matypes
>
>  # need some special rules here, unfortunately
> -matypes.h: ../main/mtypes.h ../tnl/t_context.h gen_matypes
> +matypes.h: ../main/mtypes.h ../tnl/t_context.h
> +
> +ifeq ($(GEN_ASM_OFFSETS),yes)
> +
> +matypes.h: gen_matypes.c
> +       $(CC) $(ARCH_FLAGS) $(INCLUDE_DIRS) $(CFLAGS) gen_matypes.c 
> -DASM_OFFSETS -S -o - | \
> +               sed -n '/^->/{s:^->::;/[$$]/{s:^:#define :;s:[$$]::};p}' > $@
> +
> +else
> +
> +default: gen_matypes
> +matypes.h: gen_matypes
>        ./gen_matypes > matypes.h
>
> +endif
> +
>  common_x86_asm.o: matypes.h
>  3dnow_normal.o: matypes.h
>  3dnow_xform1.o: matypes.h
> diff --git a/src/mesa/x86/gen_matypes.c b/src/mesa/x86/gen_matypes.c
> index 97f71f9..b359bb8 100644
> --- a/src/mesa/x86/gen_matypes.c
> +++ b/src/mesa/x86/gen_matypes.c
> @@ -52,7 +52,7 @@ do {                                                        
>           \
>    printf( "\n" );                                                     \
>    printf( "/* ="  \
>           "\n" );                                              \
> -   printf( " * Offsets for %s\n", x );                                 \
> +   printf( " * Offsets for " x "\n" );                                 \
>    printf( " */\n" );                                                  \
>    printf( "\n" );                                                     \
>  } while (0)
> @@ -61,20 +61,43 @@ do {                                                      
>                   \
>  do {                                                                   \
>    printf( "\n" );                                                     \
>    printf( "/*\n" );                                                   \
> -   printf( " * Flags for %s\n", x );                                   \
> +   printf( " * Flags for " x "\n" );                                   \
>    printf( " */\n" );                                                  \
>    printf( "\n" );                                                     \
>  } while (0)
>
> -#define OFFSET( s, t, m )                                              \
> -   printf( "#define %s\t%lu\n", s, (unsigned long) offsetof( t, m ) );
> +#ifdef ASM_OFFSETS
>
> -#define SIZEOF( s, t )                                                 \
> -   printf( "#define %s\t%lu\n", s, (unsigned long) sizeof(t) );
> +/*
> + * Format the asm output in a special way that we can manipulate
> + * after the fact and turn into the final header for the target.
> + */
> +
> +#define DEFINE_UL( s, ul )