www.digitalmars.com         C & C++   DMDScript  

D.gnu - build gdc with gcc 4.2.2

reply holmescn <holmesconan gmail.com> writes:
HI,
I have tried to build gdc with gcc 4.2.2 .
I know it is not support yet.I just want to have a try.
Then the problem is :
when build the d-lang.glue.o , there are some errors in d-codegen.h
there is a function named 'build'. I can't find the declaration of it, of course
the same to the compiler.
there are also functions named 'build1' 'build2' 'build3' . and the declaration
of them are also missed.

Doesn't it strange? If the same code can work around gcc 4.1, what was happend?
How can gcc 4.1 find the functions? where are they?
anybody give me a hand?
thank you!
Nov 10 2007
next sibling parent Arthur Loiret <arthur.loiret gmail.com> writes:
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable


Hi,


On 2007/11/10, holmescn <holmesconan gmail.com> wrote:
 HI,
 I have tried to build gdc with gcc 4.2.2 .
 I know it is not support yet.I just want to have a try.
 Then the problem is :
 when build the d-lang.glue.o , there are some errors in d-codegen.h
 there is a function named 'build'. I can't find the declaration of it, of=
course
 the same to the compiler.
 there are also functions named 'build1' 'build2' 'build3' . and the decla=
ration of them are also missed.
=20
 Doesn't it strange? If the same code can work around gcc 4.1, what was ha=
ppend? How can gcc 4.1 find the functions? where are they?
 anybody give me a hand?
 thank you!
=20
The gcc internals have changes between 4.1 and 4.2, this was in 4.1's tree.h:
 /* Construct various types of nodes.  */
=20
 extern tree build (enum tree_code, tree, ...);
 extern tree build_nt (enum tree_code, ...);
=20
 #if GCC_VERSION >=3D 3000 || __STDC_VERSION__ >=3D 199901L
 /* Use preprocessor trickery to map "build" to "buildN" where N is the
    expected number of arguments.  This is used for both efficiency (no
    varargs), and checking (verifying number of passed arguments).  */
 #define build(code, ...) \
   _buildN1(build, _buildC1(__VA_ARGS__))(code, __VA_ARGS__)
 #define _buildN1(BASE, X)       _buildN2(BASE, X)
 #define
 #define _buildC1(...)           _buildC2(__VA_ARGS__,9,8,7,6,5,4,3,2,1,0,=
0)
 #define _buildC2(x,a1,a2,a3,a4,a5,a6,a7,a8,a9,c,...) c
 #endif
And here is what there is in 4.2's:
 /* Construct various types of nodes.  */
=20
 extern tree build_nt (enum tree_code, ...);
Looks like buildN are called =E2=80=9Cby hand=E2=80=9D in objc and fortan f= ront-ends. There are also in ChangeLog-2003: 2003-05-17 Kaveh R. Ghazi <ghazi caip.rutgers.edu> * builtins.c (validate_arglist): Eliminate libiberty VA_ macros, always use stdarg. [...] * tree.c (build, build_nt, build_function_type_list): Likewise. Please let us know if you get something working, it would be so nice if gdc were ported to gcc-4.2. :-) Have a nice day, Arthur.
Nov 10 2007
prev sibling parent reply Arthur Loiret <arthur.loiret gmail.com> writes:
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable


Hi,


I've been able to build gdc with gcc-4.2, it stills segfault sometimes
and is unable to build phobos/tango for now, but it's a beginning and
can compile short D files.

I've put the patches in: http://people.dunnewind.net/arthur/gdc-4.2/patches/

gdc-4.2-build.dpatch updates gcc/d/Make-lang.in for the new gcc-4.2 objs
(pr26885) and gcc/d/d-builtins.c copied from the new c-common.c.

gdc-4.2.dpatch is mostly taked from patch-gcc-4.1.x, adding this:

--- gcc/tree.h  2007-11-15 14:21:01.000000000 +0100
+++ gcc/tree.h  2007-11-15 14:22:05.000000000 +0100
   -3535,6 +3535,19   
=20
 extern tree build_nt (enum tree_code, ...);
=20
+/* Still required by gdc */
+#if GCC_VERSION >=3D 3000 || __STDC_VERSION__ >=3D 199901L
+/* Use preprocessor trickery to map "build" to "buildN" where N is the
+   expected number of arguments.  This is used for both efficiency (no
+   varargs), and checking (verifying number of passed arguments).  */
+#define build(code, ...) \
+  _buildN1(build, _buildC1(__VA_ARGS__))(code, __VA_ARGS__)
+#define _buildN1(BASE, X)       _buildN2(BASE, X)
+#define
+#define _buildC1(...)           _buildC2(__VA_ARGS__,9,8,7,6,5,4,3,2,1,0,0)
+#define _buildC2(x,a1,a2,a3,a4,a5,a6,a7,a8,a9,c,...) c
+#endif
+
 extern tree build0_stat (enum tree_code, tree MEM_STAT_DECL);
 #define build0(c,t) build0_stat (c,t MEM_STAT_INFO)
 extern tree build1_stat (enum tree_code, tree, tree MEM_STAT_DECL);



I'm currently trying to fix ICEs, the problems seems to come from
gimple.


Any help would be welcome, there is still a lot of work to get it
working. :-)


Arthur.
Nov 16 2007
parent reply Ingo Oeser <ioe-news rameria.de> writes:
Hi Arthur,

nice to see that happening!

Arthur Loiret wrote:

 I've been able to build gdc with gcc-4.2, it stills segfault sometimes
 and is unable to build phobos/tango for now, but it's a beginning and
 can compile short D files.
I've been trying to do the same some months ago.
 --- gcc/tree.h  2007-11-15 14:21:01.000000000 +0100
 +++ gcc/tree.h  2007-11-15 14:22:05.000000000 +0100
    -3535,6 +3535,19   
  
  extern tree build_nt (enum tree_code, ...);
  
 +/* Still required by gdc */
 +#if GCC_VERSION >= 3000 || __STDC_VERSION__ >= 199901L
 +/* Use preprocessor trickery to map "build" to "buildN" where N is the
 +   expected number of arguments.  This is used for both efficiency (no
 +   varargs), and checking (verifying number of passed arguments).  */
 +#define build(code, ...) \
 +  _buildN1(build, _buildC1(__VA_ARGS__))(code, __VA_ARGS__)
 +#define _buildN1(BASE, X)       _buildN2(BASE, X)
 +#define
 +#define _buildC1(...)          
 _buildC2(__VA_ARGS__,9,8,7,6,5,4,3,2,1,0,0) +#define
 _buildC2(x,a1,a2,a3,a4,a5,a6,a7,a8,a9,c,...) c +#endif
 +
  extern tree build0_stat (enum tree_code, tree MEM_STAT_DECL);
  #define build0(c,t) build0_stat (c,t MEM_STAT_INFO)
  extern tree build1_stat (enum tree_code, tree, tree MEM_STAT_DECL);
That's more (short term) maintainable than my approach. I patched the D glue layer, fixed up the callers and provided build2() and build3() for compilers below GCC 4.0.x. David, would you accept a patch from me, which does ONLY that?
 I'm currently trying to fix ICEs, the problems seems to come from
 gimple.
Yes, I have seen the same and my vacation was over, so I stopped it. I have some questions for some parts of that patch. I'll mail them to you. Best Regards Ingo Oeser
Nov 24 2007
parent Arthur Loiret <arthur.loiret gmail.com> writes:
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable


Hi Ingo,


On Sat, Nov 24, 2007 at 03:13:52PM +0100, Ingo Oeser wrote:
 --- gcc/tree.h  2007-11-15 14:21:01.000000000 +0100
 +++ gcc/tree.h  2007-11-15 14:22:05.000000000 +0100
    -3535,6 +3535,19   
 =20
  extern tree build_nt (enum tree_code, ...);
 =20
 +/* Still required by gdc */
 +#if GCC_VERSION >=3D 3000 || __STDC_VERSION__ >=3D 199901L
 +/* Use preprocessor trickery to map "build" to "buildN" where N is the
 +   expected number of arguments.  This is used for both efficiency (no
 +   varargs), and checking (verifying number of passed arguments).  */
 +#define build(code, ...) \
 +  _buildN1(build, _buildC1(__VA_ARGS__))(code, __VA_ARGS__)
 +#define _buildN1(BASE, X)       _buildN2(BASE, X)
 +#define
 +#define _buildC1(...)         =20
 _buildC2(__VA_ARGS__,9,8,7,6,5,4,3,2,1,0,0) +#define
 _buildC2(x,a1,a2,a3,a4,a5,a6,a7,a8,a9,c,...) c +#endif
 +
  extern tree build0_stat (enum tree_code, tree MEM_STAT_DECL);
  #define build0(c,t) build0_stat (c,t MEM_STAT_INFO)
  extern tree build1_stat (enum tree_code, tree, tree MEM_STAT_DECL);
=20 That's more (short term) maintainable than my approach. I patched the D g=
lue
 layer, fixed up the callers and provided build2() and build3() for compil=
ers
 below GCC 4.0.x.=20
You're right. :-)
 I'm currently trying to fix ICEs, the problems seems to come from
 gimple.
=20 Yes, I have seen the same and my vacation was over, so I stopped it.
I made a few other temporary patches to fix ICEs, here is what changed: diff -ruN gcc/gimplify.c gcc/gimplify.c --- gcc/gimplify.c 2007-11-19 11:56:50.000000000 +0000 +++ gcc/gimplify.c 2007-11-19 11:58:32.000000000 +0000 -1804,12 +1804,16 /* Divide the offset by its alignment. */ offset =3D size_binop (EXACT_DIV_EXPR, offset, factor); =20 - if (!is_gimple_min_invariant (offset)) - { - TREE_OPERAND (t, 2) =3D offset; - tret =3D gimplify_expr (&TREE_OPERAND (t, 2), pre_p, post= _p, - is_gimple_formal_tmp_reg, fb_rvalue= ); - ret =3D MIN (ret, tret); + /* Would be better to have a look at size_binop ... */ + if (offset !=3D NULL_TREE) + { + if (!is_gimple_min_invariant (offset)) + { + TREE_OPERAND (t, 2) =3D offset; + tret =3D gimplify_expr (&TREE_OPERAND (t, 2), pre_p, = post_p, + is_gimple_formal_tmp_reg, fb_rv= alue); + ret =3D MIN (ret, tret); + } } } } diff -ruN gcc/tree-inline.c gcc/tree-inline.c --- gcc/tree-inline.c 2007-11-19 15:41:33.000000000 +0000 +++ gcc/tree-inline.c 2007-11-19 15:42:24.000000000 +0000 -2636,8 +2636,9 { tree copy, type; =20 - gcc_assert (TREE_CODE (decl) =3D=3D PARM_DECL - || TREE_CODE (decl) =3D=3D RESULT_DECL); + if (cfun->naked) /* Not sure this is right ... */ + gcc_assert (TREE_CODE (decl) =3D=3D PARM_DECL + || TREE_CODE (decl) =3D=3D RESULT_DECL); =20 type =3D TREE_TYPE (decl); =20 gdc-4.2 now builds phobos and tango, see [0] and [1]. [0] http://packages.qa.debian.org/g/gdc-4.2.html [1] http://people.dunnewind.net/arthur/gdc-4.2/ Here is how to test it: 1/ Add this to your /etc/apt/sources.list deb http://ftp.fr.debian.org/debian experimental main deb-src http://ftp.fr.debian.org/debian experimental main 2/ Run sudo aptitude update && sudo aptitude install gdc-4.2 I've cleanup gdc-4.2-build.dpatch: see: http://people.dunnewind.net/arthur/gdc-4.2/patches/gdc-4.2-build.dpatch David, could you also have a look at this one?
 I have some questions for some parts of that patch. I'll mail them to you.
Sure, no problem. Have a nice day, Arthur.
Nov 24 2007