Sergei Trofimovich | 10 Mar 21:48 2012
Picon

tk2hsC2hs version 0.13.5 sometimes fails with 'gtk2hsC2hs: UName: root name supply used after saving'

Sometime I'm getting weird error in latest gtk2hs-buildtools:

/usr/bin/gtk2hsC2hs --include=dist/build --include=/usr/lib64/ghc-7.0.4/base-4.3.1.0
--include=/usr/lib64/glib-0.12.3/ghc-7.0.4 --include=/usr/lib64/gtk-0.12.3/ghc-7.0.4
--cpp=/usr/bin/gcc --cppopts=-E --cppopts=-Idist/build/autogen --cppopts=-Idist/build
--cppopts=-I/usr/include/libglade-2.0 --cppopts=-I/usr/include/gtk-2.0
--cppopts=-I/usr/include/libxml2 --cppopts=-I/usr/lib64/gtk-2.0/include
--cppopts=-I/usr/include/atk-1.0 --cppopts=-I/usr/include/cairo
--cppopts=-I/usr/include/gdk-pixbuf-2.0 --cppopts=-I/usr/include/pango-1.0
--cppopts=-I/usr/include/glib-2.0 --cppopts=-I/usr/lib64/glib-2.0/include
--cppopts=-I/usr/include/pixman-1 --cppopts=-I/usr/include/freetype2
--cppopts=-I/usr/include/libpng15 --cppopts=-I/usr/include/libdrm
--output-dir=dist/build/Graphics/UI/Gtk/Glade/ --output=Types.hs
--precomp=dist/build/precompchs.bin glade/glade.h ./Graphics/UI/Gtk/Glade/Types.chs

gtk2hsC2hs: UName: root name supply used after saving

If it run the command manually _twice_ it succeeds.

What could it be?

--

-- 

  Sergei
Attachment (build.log): text/x-log, 8 KiB
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
(Continue reading)

Sergei Trofimovich | 10 Mar 22:02 2012
Picon

Re: tk2hsC2hs version 0.13.5 sometimes fails with 'gtk2hsC2hs: UName: root name supply used after saving'

> Sometime I'm getting weird error in latest gtk2hs-buildtools:
> 
> /usr/bin/gtk2hsC2hs --include=dist/build --include=/usr/lib64/ghc-7.0.4/base-4.3.1.0
--include=/usr/lib64/glib-0.12.3/ghc-7.0.4 --include=/usr/lib64/gtk-0.12.3/ghc-7.0.4
--cpp=/usr/bin/gcc --cppopts=-E --cppopts=-Idist/build/autogen --cppopts=-Idist/build
--cppopts=-I/usr/include/libglade-2.0 --cppopts=-I/usr/include/gtk-2.0
--cppopts=-I/usr/include/libxml2 --cppopts=-I/usr/lib64/gtk-2.0/include
--cppopts=-I/usr/include/atk-1.0 --cppopts=-I/usr/include/cairo
--cppopts=-I/usr/include/gdk-pixbuf-2.0 --cppopts=-I/usr/include/pango-1.0
--cppopts=-I/usr/include/glib-2.0 --cppopts=-I/usr/lib64/glib-2.0/include
--cppopts=-I/usr/include/pixman-1 --cppopts=-I/usr/include/freetype2
--cppopts=-I/usr/include/libpng15 --cppopts=-I/usr/include/libdrm
--output-dir=dist/build/Graphics/UI/Gtk/Glade/ --output=Types.hs
--precomp=dist/build/precompchs.bin glade/glade.h ./Graphics/UI/Gtk/Glade/Types.chs
> 
> gtk2hsC2hs: UName: root name supply used after saving
> 
> If it run the command manually _twice_ it succeeds.
> 
> What could it be?

More observations: removing 'dist/build/precompchs.bin' allows the issue pop-up consistently:

$ /usr/bin/gtk2hsC2hs ... --precomp=dist/build/precompchs.bin glade/glade.h ./Graphics/UI/Gtk/Glade/Types.chs
<OK>
$ rm dist/build/precompchs.bin
$/usr/bin/gtk2hsC2hs ... --precomp=dist/build/precompchs.bin glade/glade.h ./Graphics/UI/Gtk/Glade/Types.chs
gtk2hsC2hs: UName: root name supply used after saving
$ /usr/bin/gtk2hsC2hs ... --precomp=dist/build/precompchs.bin glade/glade.h ./Graphics/UI/Gtk/Glade/Types.chs
<OK>
(Continue reading)

Sergei Trofimovich | 13 Mar 20:29 2012
Picon

Re: tk2hsC2hs version 0.13.5 sometimes fails with 'gtk2hsC2hs: UName: root name supply used after saving'

> > Sometime I'm getting weird error in latest gtk2hs-buildtools:
> > 
> > /usr/bin/gtk2hsC2hs --include=dist/build --include=/usr/lib64/ghc-7.0.4/base-4.3.1.0
--include=/usr/lib64/glib-0.12.3/ghc-7.0.4 --include=/usr/lib64/gtk-0.12.3/ghc-7.0.4
--cpp=/usr/bin/gcc --cppopts=-E --cppopts=-Idist/build/autogen --cppopts=-Idist/build
--cppopts=-I/usr/include/libglade-2.0 --cppopts=-I/usr/include/gtk-2.0
--cppopts=-I/usr/include/libxml2 --cppopts=-I/usr/lib64/gtk-2.0/include
--cppopts=-I/usr/include/atk-1.0 --cppopts=-I/usr/include/cairo
--cppopts=-I/usr/include/gdk-pixbuf-2.0 --cppopts=-I/usr/include/pango-1.0
--cppopts=-I/usr/include/glib-2.0 --cppopts=-I/usr/lib64/glib-2.0/include
--cppopts=-I/usr/include/pixman-1 --cppopts=-I/usr/include/freetype2
--cppopts=-I/usr/include/libpng15 --cppopts=-I/usr/include/libdrm
--output-dir=dist/build/Graphics/UI/Gtk/Glade/ --output=Types.hs
--precomp=dist/build/precompchs.bin glade/glade.h ./Graphics/UI/Gtk/Glade/Types.chs
> > 
> > gtk2hsC2hs: UName: root name supply used after saving
> > 
> > If it run the command manually _twice_ it succeeds.
> > 
> > What could it be?
> 
> More observations: removing 'dist/build/precompchs.bin' allows the issue pop-up consistently:
> 
> $ /usr/bin/gtk2hsC2hs ... --precomp=dist/build/precompchs.bin glade/glade.h ./Graphics/UI/Gtk/Glade/Types.chs
> <OK>
> $ rm dist/build/precompchs.bin
> $/usr/bin/gtk2hsC2hs ... --precomp=dist/build/precompchs.bin glade/glade.h ./Graphics/UI/Gtk/Glade/Types.chs
> gtk2hsC2hs: UName: root name supply used after saving
> $ /usr/bin/gtk2hsC2hs ... --precomp=dist/build/precompchs.bin glade/glade.h ./Graphics/UI/Gtk/Glade/Types.chs
> <OK>
(Continue reading)

Sergei Trofimovich | 13 Mar 21:43 2012
Picon

Re: tk2hsC2hs version 0.13.5 sometimes fails with 'gtk2hsC2hs: UName: root name supply used after saving'

> One more observation: it looks like a problem in recent libglade file header.
> I have disabled creation of precomp file:
>     Main.hs: -- putBinFileWithDict preCompFile (WithNameSupply cheader)
> and have dumped something called header:
> 
> Main.hs:process: (header, strippedCHSMod, warnmsgs) <- genHeader chsMod
> Usually header is an empty list. But now it contains (already serialized!) garbage:
> "#if __GLASGOW_HASKELL__>=704"
> "\n"
> "struct "
> "C2HS_COND_SENTRY_1"
> ";\n"
> "#else\n"
> "#endif\n"
> 
> Does it look valid? What should I provide?

Now I see. Running ./setup configure in glade's repo *patches* .chs file:

diff --git a/Graphics/UI/Gtk/Glade/Types.chs b/Graphics/UI/Gtk/Glade/Types.chs
index 38574d4..4075fea 100644
--- a/Graphics/UI/Gtk/Glade/Types.chs
+++ b/Graphics/UI/Gtk/Glade/Types.chs
 <at>  <at>  -42,7 +42,11  <at>  <at>  module Graphics.UI.Gtk.Glade.Types (
   ) where

 import Foreign.ForeignPtr (ForeignPtr, castForeignPtr, unsafeForeignPtrToPtr)
+#if __GLASGOW_HASKELL__>=704
+import Foreign.C.Types    (CULong(..), CUInt(..))
+#else
(Continue reading)

Christian Maeder | 26 Apr 12:37 2012
Picon

Re: tk2hsC2hs version 0.13.5 sometimes fails with 'gtk2hsC2hs: UName: root name supply used after saving'

Hi,

I noticed that the failure

   gtk2hsC2hs: UName: root name supply used after saving

http://hackage.haskell.org/trac/gtk2hs/ticket/1259

only happens with gtk2hs-buildtools-0.12.3 but not with 
gtk2hs-buildtools-0.12.1!

The only (relevant) difference is in hierarchyGen/Hierarchy.chs.template :

  import Foreign.ForeignPtr (ForeignPtr, castForeignPtr, 
unsafeForeignPtrToPtr)
+#if __GLASGOW_HASKELL__>=704
+import Foreign.C.Types    (CULong(..), CUInt(..))
+#else
  import Foreign.C.Types    (CULong, CUInt)
+#endif
  import System.Glib.GType       (GType, typeInstanceIsA)

(darcs changes:

18: Fri Jan 20 07:50:06 CET 2012  Duncan Coutts 
<duncan <at> community.haskell.org>
   * Fix the type generator for GHC 7.4
   GHC 7.4 is stricter about FFI imports with newtypes, the newtype
   constructor must be visible at the point of import.
)
(Continue reading)

Christian Maeder | 26 Apr 12:53 2012
Picon

P.S. Re: tk2hsC2hs version 0.13.5 sometimes fails with 'gtk2hsC2hs: UName: root name supply used after saving'

P.S.
Just using the line
   import Foreign.C.Types    (CULong(..), CUInt(..))
(and avoiding CPP stuff) also works for ghc-7.0.4

C.

---
The only (relevant) difference is in hierarchyGen/Hierarchy.chs.template :

  import Foreign.ForeignPtr (ForeignPtr, castForeignPtr, 
unsafeForeignPtrToPtr)
+#if __GLASGOW_HASKELL__>=704
+import Foreign.C.Types    (CULong(..), CUInt(..))
+#else
  import Foreign.C.Types    (CULong, CUInt)
+#endif
  import System.Glib.GType       (GType, typeInstanceIsA)

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
wagnerdm | 26 Apr 18:46 2012

Re: P.S. Re: tk2hsC2hs version 0.13.5 sometimes fails with 'gtk2hsC2hs: UName: root name supply used after saving'

Quoting Christian Maeder <Christian.Maeder <at> dfki.de>:

> P.S.
> Just using the line
>    import Foreign.C.Types    (CULong(..), CUInt(..))
> (and avoiding CPP stuff) also works for ghc-7.0.4

Yes, but it doesn't work for ghc's older than GHC-7. (Hence the (>=)  
in the #if.)

I'll add the {-# LANGUAGE CPP #-} pragma in the darcs repository for  
sure, though, and this weekend I'll double-check that all the  
libraries people have reported trouble building work. Thanks for  
looking into this!

~d

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
Christian Maeder | 26 Apr 20:04 2012
Picon

Re: P.S. Re: tk2hsC2hs version 0.13.5 sometimes fails with 'gtk2hsC2hs: UName: root name supply used after saving'

Am 26.04.2012 18:46, schrieb wagnerdm <at> seas.upenn.edu:
> Quoting Christian Maeder<Christian.Maeder <at> dfki.de>:
>
>> P.S.
>> Just using the line
>>     import Foreign.C.Types    (CULong(..), CUInt(..))
>> (and avoiding CPP stuff) also works for ghc-7.0.4
>
> Yes, but it doesn't work for ghc's older than GHC-7. (Hence the (>=)
> in the #if.)

It works at least for ghc-6.12.3, too. The number 704 only address 
ghc-7.4 (not ghc-7.0.4)

C.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
wagnerdm | 26 Apr 20:48 2012

Re: P.S. Re: tk2hsC2hs version 0.13.5 sometimes fails with 'gtk2hsC2hs: UName: root name supply used after saving'

Quoting Christian Maeder <Christian.Maeder <at> dfki.de>:

> Am 26.04.2012 18:46, schrieb wagnerdm <at> seas.upenn.edu:
>> Quoting Christian Maeder<Christian.Maeder <at> dfki.de>:
>>
>>> P.S.
>>> Just using the line
>>>    import Foreign.C.Types    (CULong(..), CUInt(..))
>>> (and avoiding CPP stuff) also works for ghc-7.0.4
>>
>> Yes, but it doesn't work for ghc's older than GHC-7. (Hence the (>=)
>> in the #if.)
>
> It works at least for ghc-6.12.3, too. The number 704 only address  
> ghc-7.4 (not ghc-7.0.4)

Huh. How about that.

After some digging, it seems that the purpose of this #if is to reduce  
the number of warnings, not to make things work (since either version  
works on every version of GHC thus far produced). Unfortunately, as I  
detailed in an earlier email that didn't go to the list (and probably  
should have), the #if isn't doing its job:

> I've been having a look at reducing the number of warnings generated  
>  on recent GHCs. Currently, there's a snippet in   
> tools/hierarchyGen/Hierarchy.chs.template that looks like this:
>
> #if __GLASGOW_HASKELL__>=704
> import Foreign.C.Types    (CULong(..), CUInt(..))
(Continue reading)

Christian Maeder | 27 Apr 13:31 2012
Picon

Re: P.S. Re: tk2hsC2hs version 0.13.5 sometimes fails with 'gtk2hsC2hs: UName: root name supply used after saving'

Hi,

For some reason (that I cannot explain) gtk2hsC2hs fails with
"UName: root name supply used after saving" if the line
{-# LANGUAGE CPP #-} is missing in Graphics/UI/Gtk/Glade/Types.chs
and dist/build/precompchs.bin does not exist (which is the case when 
calling "cabal install glade")

The #if statement is always expanded to the #else case since 
__GLASGOW_HASKELL__ is not set.

One needs to pass --cppopts=-D__GLASGOW_HASKELL__=700 to gtk2hsC2hs to 
cause a difference.

So the pragma is merely needed to let gtk2hsC2hs not fail.

Since the actual branch chosen only concern warnings I would suggest to 
just take the new one.

Cheers Christian

Am 26.04.2012 20:48, schrieb wagnerdm <at> seas.upenn.edu:
> Quoting Christian Maeder<Christian.Maeder <at> dfki.de>:
>
>> Am 26.04.2012 18:46, schrieb wagnerdm <at> seas.upenn.edu:
>>> Quoting Christian Maeder<Christian.Maeder <at> dfki.de>:
>>>
>>>> P.S.
>>>> Just using the line
>>>>     import Foreign.C.Types    (CULong(..), CUInt(..))
(Continue reading)

Axel Simon | 29 Apr 20:02 2012
Picon

Re: P.S. Re: tk2hsC2hs version 0.13.5 sometimes fails with 'gtk2hsC2hs: UName: root name supply used after saving'

Hi Christian,

On 27.04.2012, at 13:31, Christian Maeder wrote:

> Hi,
> 
> For some reason (that I cannot explain) gtk2hsC2hs fails with
> "UName: root name supply used after saving" if the line
> {-# LANGUAGE CPP #-} is missing in Graphics/UI/Gtk/Glade/Types.chs
> and dist/build/precompchs.bin does not exist (which is the case when 
> calling "cabal install glade")
> 

I cringe when I think of this UName issues. All those fancy monads that clutter the code but unique names are
still generated using an unsafePerformIO. We've added this test because there is something seriously
wrong if we ask for a new name after the chi file has been saved.

The reason you see a different behaviour when you add the pragma line is that c2hs takes a completely
different route and dissects the file into bits, does it's on #ifdef processing (I think) and then runs CPP
on it. I don't think there is much harm in taking this different path via CPP inside c2hs, but it's just
something that hasn't been done for the Types.chs files. So let's keep it for now...

Cheers,
Axel

> The #if statement is always expanded to the #else case since 
> __GLASGOW_HASKELL__ is not set.
> 
> One needs to pass --cppopts=-D__GLASGOW_HASKELL__=700 to gtk2hsC2hs to 
> cause a difference.
(Continue reading)


Gmane