gobo-eiffel / gobo

The Gobo Eiffel Project provides the Eiffel community with free and portable Eiffel tools and libraries.
https://sourceforge.net/projects/gobo-eiffel/
Other
59 stars 24 forks source link

is it possible to support: **** language not recognized: C Macro use <ev_gtk.h> #72

Open mw66 opened 6 months ago

mw66 commented 6 months ago
         I don't know if it can compile everything in EiffelVision2, but I have an application which uses some parts of it and I managed to compile and run it under Windows. I can see that you are under Linux (I guess). I never tried to compile an application using EiffelVision2 on this platform.

Originally posted by @ebezault in https://github.com/gobo-eiffel/gobo/issues/70#issuecomment-1975284478

I tried

/Eiffel_23.09/examples/docking/simple$ gec docking_simple.ecf 
Degree 6: 0/0/0 0:0:0.112
Degree 5: 0/0/0 0:0:0.473
Degree 4: 0/0/0 0:0:0.449
Degree 3: 0/0/0 0:0:0.226

....

Degree -2: 0/0/0 0:0:2.149
**** language not recognized: C [macro <ev_gtk.h>] | "eif_argv.h"
[GIAAA] internal error.
----
**** language not recognized: C Macro use <ev_gtk.h>
Degree -3: 0/0/0 0:0:1.164
Total Time: 0/0/0 0:0:4.576

I'm wondering if it possible to support: **** language not recognized: C Macro use

So I can compile this project?

Thanks.

ebezault commented 6 months ago

I just fixed these external routine issues.

But when I see these messages:

Dynamic type set not built for external feature [detachable] EV_TITLED_WINDOW_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_RICH_TEXT_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_GTK_CALLBACK_MARSHAL.c_get_eif_reference_from_object_id
Dynamic type set not built for external feature detachable EV_ANY_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_CELL_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_VIEWPORT_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_FIXED_IMP.eif_object_from_c
Dynamic type set not built for external feature detachable EV_VERTICAL_BOX_IMP.eif_object_from_c
Dynamic type set not built for external feature detachable EV_POPUP_WINDOW_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_BUTTON_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] MEMORY.find_instance_of
Dynamic type set not built for external feature [detachable] EV_HORIZONTAL_BOX_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_DIALOG_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_FRAME_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] SD_DRAWING_AREA_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_SCROLLABLE_AREA_IMP.eif_object_from_c
Dynamic type set not built for external feature detachable EV_PIXMAP_IMP.eif_object_from_c
Dynamic type set not built for external feature detachable EV_WINDOW_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_TEXT_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_LABEL_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_HORIZONTAL_SPLIT_AREA_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_VERTICAL_SPLIT_AREA_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_LIST_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_DRAWING_AREA_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] SD_WINDOW_IMP.eif_object_from_c
Dynamic type set not built for external feature detachable EV_TOOL_BAR_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_DOCKABLE_SOURCE_HINT_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_TEXT_FIELD_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_MENU_IMP.eif_object_from_c

there is a good chance that the program will not work as expected (and probably crash). I can see how to figure out what would be the dynamic type set of eif_object_from_c, but it will take some time and effort to implement it in gec.

mw66 commented 6 months ago

OK, thanks.

mw66 commented 6 months ago

On a second thought: I don't need the GUI application to run (correctly), I only need to be able to build the project binary: I will just create a object, and do some reference equality check and print, that's all.

Esp., I'm trying this example now: /Eiffel_23.09/examples/docking/simple

Is it possible to make the gec build work for this project?

Currently the error is:

/Eiffel_23.09/examples/docking/simple$ gec ./docking_simple.ecf
Degree 6: 0/0/0 0:0:0.130
Degree 5: 0/0/0 0:0:0.481
Degree 4: 0/0/0 0:0:0.440
Degree 3: 0/0/0 0:0:0.226
Dynamic type set not built for external feature [detachable] EV_TITLED_WINDOW_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_RICH_TEXT_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_GTK_CALLBACK_MARSHAL.c_get_eif_reference_from_object_id
Dynamic type set not built for external feature [detachable] EV_CELL_IMP.eif_object_from_c
Dynamic type set not built for external feature detachable EV_ANY_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_VIEWPORT_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_FIXED_IMP.eif_object_from_c
Dynamic type set not built for external feature detachable EV_VERTICAL_BOX_IMP.eif_object_from_c
Dynamic type set not built for external feature detachable EV_POPUP_WINDOW_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_BUTTON_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] MEMORY.find_instance_of
Dynamic type set not built for external feature [detachable] EV_HORIZONTAL_BOX_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_DIALOG_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_FRAME_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] SD_DRAWING_AREA_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_SCROLLABLE_AREA_IMP.eif_object_from_c
Dynamic type set not built for external feature detachable EV_PIXMAP_IMP.eif_object_from_c
Dynamic type set not built for external feature detachable EV_WINDOW_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_TEXT_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_LABEL_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_HORIZONTAL_SPLIT_AREA_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_VERTICAL_SPLIT_AREA_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_LIST_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_DRAWING_AREA_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] SD_WINDOW_IMP.eif_object_from_c
Dynamic type set not built for external feature detachable EV_TOOL_BAR_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_DOCKABLE_SOURCE_HINT_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_TEXT_FIELD_IMP.eif_object_from_c
Dynamic type set not built for external feature [detachable] EV_MENU_IMP.eif_object_from_c
[CATCALL] class detachable SD_TOOL_BAR_ZONE (592,14): type '[detachable] SD_TOOL_BAR_NARROW_BUTTON' of actual argument #1 does not conform to type '[attached] SD_TOOL_BAR_MENU_ITEM' of formal argument in feature `has' in class '[detachable] SD_MENU_BAR'
[CATCALL] class detachable SD_TOOL_BAR_ZONE (592,14): type '[detachable] SD_TOOL_BAR_BUTTON' of actual argument #1 does not conform to type '[attached] SD_TOOL_BAR_MENU_ITEM' of formal argument in feature `has' in class '[detachable] SD_MENU_BAR'
[CATCALL] class detachable SD_TOOL_BAR_ZONE (592,14): type '[detachable] SD_TOOL_BAR_SEPARATOR' of actual argument #1 does not conform to type '[attached] SD_TOOL_BAR_MENU_ITEM' of formal argument in feature `has' in class '[detachable] SD_MENU_BAR'
[CATCALL] class detachable SD_TOOL_BAR_ZONE (592,14): type '[detachable] SD_TOOL_BAR_WIDTH_BUTTON' of actual argument #1 does not conform to type '[attached] SD_TOOL_BAR_MENU_ITEM' of formal argument in feature `has' in class '[detachable] SD_MENU_BAR'
[CATCALL] class detachable SD_TOOL_BAR_ZONE (592,14): type '[detachable] SD_TOOL_BAR_FONT_BUTTON' of actual argument #1 does not conform to type '[attached] SD_TOOL_BAR_MENU_ITEM' of formal argument in feature `has' in class '[detachable] SD_MENU_BAR'
[CATCALL] class detachable SD_TOOL_BAR_ZONE (464,4): type '[detachable] SD_TOOL_BAR_NARROW_BUTTON' of actual argument #1 does not conform to type '[attached] SD_TOOL_BAR_MENU_ITEM' of formal argument in feature `prune' in class '[detachable] SD_MENU_BAR'
[CATCALL] class detachable SD_TOOL_BAR_ZONE (464,4): type '[detachable] SD_TOOL_BAR_BUTTON' of actual argument #1 does not conform to type '[attached] SD_TOOL_BAR_MENU_ITEM' of formal argument in feature `prune' in class '[detachable] SD_MENU_BAR'
[CATCALL] class detachable SD_TOOL_BAR_ZONE (464,4): type '[detachable] SD_TOOL_BAR_SEPARATOR' of actual argument #1 does not conform to type '[attached] SD_TOOL_BAR_MENU_ITEM' of formal argument in feature `prune' in class '[detachable] SD_MENU_BAR'
[CATCALL] class detachable SD_TOOL_BAR_ZONE (464,4): type '[detachable] SD_TOOL_BAR_WIDTH_BUTTON' of actual argument #1 does not conform to type '[attached] SD_TOOL_BAR_MENU_ITEM' of formal argument in feature `prune' in class '[detachable] SD_MENU_BAR'
[CATCALL] class detachable SD_TOOL_BAR_ZONE (464,4): type '[detachable] SD_TOOL_BAR_FONT_BUTTON' of actual argument #1 does not conform to type '[attached] SD_TOOL_BAR_MENU_ITEM' of formal argument in feature `prune' in class '[detachable] SD_MENU_BAR'
[CATCALL] class [detachable] SD_TOOL_BAR_ZONE_ASSISTANT (174,7): type '[detachable] SD_TOOL_BAR_NARROW_BUTTON' of actual argument #1 does not conform to type '[attached] SD_TOOL_BAR_MENU_ITEM' of formal argument in feature `extend' in class '[detachable] SD_MENU_BAR'
[CATCALL] class [detachable] SD_TOOL_BAR_ZONE_ASSISTANT (172,7): type '[detachable] SD_TOOL_BAR_NARROW_BUTTON' of actual argument #1 does not conform to type '[attached] SD_TOOL_BAR_MENU_ITEM' of formal argument in feature `prune' in class '[detachable] SD_MENU_BAR'
[CATCALL] class detachable SD_TOOL_BAR_ZONE (803,5): type '[detachable] SD_TOOL_BAR_NARROW_BUTTON' of actual argument #1 does not conform to type '[attached] SD_TOOL_BAR_MENU_ITEM' of formal argument in feature `extend' in class '[detachable] SD_MENU_BAR'
[CATCALL] class detachable SD_TOOL_BAR_ZONE (803,5): type '[detachable] SD_TOOL_BAR_BUTTON' of actual argument #1 does not conform to type '[attached] SD_TOOL_BAR_MENU_ITEM' of formal argument in feature `extend' in class '[detachable] SD_MENU_BAR'
[CATCALL] class detachable SD_TOOL_BAR_ZONE (803,5): type '[detachable] SD_TOOL_BAR_SEPARATOR' of actual argument #1 does not conform to type '[attached] SD_TOOL_BAR_MENU_ITEM' of formal argument in feature `extend' in class '[detachable] SD_MENU_BAR'
[CATCALL] class detachable SD_TOOL_BAR_ZONE (803,5): type '[detachable] SD_TOOL_BAR_WIDTH_BUTTON' of actual argument #1 does not conform to type '[attached] SD_TOOL_BAR_MENU_ITEM' of formal argument in feature `extend' in class '[detachable] SD_MENU_BAR'
[CATCALL] class detachable SD_TOOL_BAR_ZONE (803,5): type '[detachable] SD_TOOL_BAR_FONT_BUTTON' of actual argument #1 does not conform to type '[attached] SD_TOOL_BAR_MENU_ITEM' of formal argument in feature `extend' in class '[detachable] SD_MENU_BAR'
Degree -2: 0/0/0 0:0:2.119
**** language not recognized: C [macro <ev_gtk.h>] | "eif_argv.h"
[GIAAA] internal error.
----
**** language not recognized: C Macro use <ev_gtk.h>
Degree -3: 0/0/0 0:0:1.156
Total Time: 0/0/0 0:0:4.553
ebezault commented 6 months ago

Yesterday I fixed these errors:

**** language not recognized: C [macro <ev_gtk.h>] | "eif_argv.h"
[GIAAA] internal error.
----
**** language not recognized: C Macro use <ev_gtk.h>

The CATCALL messages are just warnings. The Dynamic type set are more problematic, but they should not prevent from generating the executable. So if you get the latest version of the repository, you should be able to generate an executable.

mw66 commented 6 months ago

So if you get the latest version of the repository, you should be able to generate an executable.

Thanks. I will give it a try tomorrow.

mw66 commented 6 months ago

With the latest github repo, got this error

Degree -3: 0/0/0 0:0:0.569
docking_simple5.c: In function ‘T596s6’:
docking_simple5.c:57248:58: error: expected ‘;’ before ‘}’ token
57248 | gtk_paned_set_wide_handle ((GtkPaned*) a1, (gboolean) a2)
      |                                                          ^
      |                                                          ;
57249 | #endif
57250 |         }
      |         ~                                                 

we can see the gtk_paned_set_wide_handle(...) statement missing ;:

/* GTK3.gtk_paned_set_wide_handle */
void T596s6(TC* ac, T479 a1, T453 a2)
{
        {
#if GTK_CHECK_VERSION(3,16,0)
gtk_paned_set_wide_handle ((GtkPaned*) a1, (gboolean) a2)
#endif
        }
}
ebezault commented 6 months ago

The semicolon is also missing in the Eiffel code:

    frozen gtk_paned_set_wide_handle (a_paned: POINTER; a_wide: BOOLEAN)
        external
            "C inline use <ev_gtk.h>"
        alias
            "[
                #if GTK_CHECK_VERSION(3,16,0)
                gtk_paned_set_wide_handle ((GtkPaned*) $a_paned, (gboolean) $a_wide)
                #endif
            ]"
        ensure
            is_class: class
        end

I'll see what I can do to let the Eiffel compiler add this missing semicolon in the generated C code.

mw66 commented 6 months ago

Also got error:

docking_simple4.c: In function ‘T211f2sc1’:
docking_simple4.c:49016:17: error: ‘t1’ undeclared (first use in this function); did you mean ‘tr’?
49016 |                 t1 = (T444)(GE_int8(2));
      |                 ^~

I checked that generated C func, var t1 indeed is undeclared.

ebezault commented 6 months ago

It looks like an inlining problem. I need to investigate. In the meantime, add this command-line option to gec:

--setting=inlining=False
mw66 commented 6 months ago

added --setting=inlining=False, now the remaining errors:

In file included from docking_simple3.c:1:
docking_simple3.c: In function ‘T691f211’:
docking_simple3.c:13715:39: error: ‘eif_argc’ undeclared (first use in this function); did you mean ‘eif_proc’?
13715 |         R = EIF_TEST(gtk_init_check (&eif_argc, &eif_argv));
      |                                       ^~~~~~~~
docking_simple.h:259:23: note: in definition of macro ‘EIF_TEST’
  259 | #define EIF_TEST(x) ((x) ? EIF_TRUE : EIF_FALSE)
      |                       ^
docking_simple3.c:13715:39: note: each undeclared identifier is reported only once for each function it appears in
13715 |         R = EIF_TEST(gtk_init_check (&eif_argc, &eif_argv));
      |                                       ^~~~~~~~
docking_simple.h:259:23: note: in definition of macro ‘EIF_TEST’
  259 | #define EIF_TEST(x) ((x) ? EIF_TRUE : EIF_FALSE)
      |                       ^
docking_simple3.c:13715:50: error: ‘eif_argv’ undeclared (first use in this function)
13715 |         R = EIF_TEST(gtk_init_check (&eif_argc, &eif_argv));
      |                                                  ^~~~~~~~
docking_simple.h:259:23: note: in definition of macro ‘EIF_TEST’
  259 | #define EIF_TEST(x) ((x) ? EIF_TRUE : EIF_FALSE)
      |                       ^
Degree -4: 0/0/0 0:0:8.089
Total Time: 0/0/0 0:0:10.131
mw66 commented 6 months ago

The semicolon is also missing in the Eiffel code:

... I'll see what I can do to let the Eiffel compiler add this missing semicolon in the generated C code.

I manually add ; at line 274 of

/Eiffel_23.09/library/vision2/implementation/gtk3/support/externals/gtk3.e

as temp fix.

ebezault commented 6 months ago

added --setting=inlining=False, now the remaining errors:

In file included from docking_simple3.c:1:
docking_simple3.c: In function ‘T691f211’:
docking_simple3.c:13715:39: error: ‘eif_argc’ undeclared (first use in this function); did you mean ‘eif_proc’?
13715 |         R = EIF_TEST(gtk_init_check (&eif_argc, &eif_argv));
      |                                       ^~~~~~~~
docking_simple.h:259:23: note: in definition of macro ‘EIF_TEST’
  259 | #define EIF_TEST(x) ((x) ? EIF_TRUE : EIF_FALSE)
      |                       ^
docking_simple3.c:13715:39: note: each undeclared identifier is reported only once for each function it appears in
13715 |         R = EIF_TEST(gtk_init_check (&eif_argc, &eif_argv));
      |                                       ^~~~~~~~
docking_simple.h:259:23: note: in definition of macro ‘EIF_TEST’
  259 | #define EIF_TEST(x) ((x) ? EIF_TRUE : EIF_FALSE)
      |                       ^
docking_simple3.c:13715:50: error: ‘eif_argv’ undeclared (first use in this function)
13715 |         R = EIF_TEST(gtk_init_check (&eif_argc, &eif_argv));
      |                                                  ^~~~~~~~
docking_simple.h:259:23: note: in definition of macro ‘EIF_TEST’
  259 | #define EIF_TEST(x) ((x) ? EIF_TRUE : EIF_FALSE)
      |                       ^
Degree -4: 0/0/0 0:0:8.089
Total Time: 0/0/0 0:0:10.131

It looks like you chose some Eiffel application which uses C code which itself relies on ISE Eiffel's runtime. Not the best choice to start with :-) I'll address this issues one after the other...

mw66 commented 6 months ago

added --setting=inlining=False, now the remaining errors:

In file included from docking_simple3.c:1:
docking_simple3.c: In function ‘T691f211’:
docking_simple3.c:13715:39: error: ‘eif_argc’ undeclared (first use in this function); did you mean ‘eif_proc’?
13715 |         R = EIF_TEST(gtk_init_check (&eif_argc, &eif_argv));
      |                                       ^~~~~~~~
docking_simple.h:259:23: note: in definition of macro ‘EIF_TEST’
  259 | #define EIF_TEST(x) ((x) ? EIF_TRUE : EIF_FALSE)
      |                       ^
docking_simple3.c:13715:39: note: each undeclared identifier is reported only once for each function it appears in
13715 |         R = EIF_TEST(gtk_init_check (&eif_argc, &eif_argv));
      |                                       ^~~~~~~~
docking_simple.h:259:23: note: in definition of macro ‘EIF_TEST’
  259 | #define EIF_TEST(x) ((x) ? EIF_TRUE : EIF_FALSE)
      |                       ^
docking_simple3.c:13715:50: error: ‘eif_argv’ undeclared (first use in this function)
13715 |         R = EIF_TEST(gtk_init_check (&eif_argc, &eif_argv));
      |                                                  ^~~~~~~~
docking_simple.h:259:23: note: in definition of macro ‘EIF_TEST’
  259 | #define EIF_TEST(x) ((x) ? EIF_TRUE : EIF_FALSE)
      |                       ^
Degree -4: 0/0/0 0:0:8.089
Total Time: 0/0/0 0:0:10.131

It looks like you chose some Eiffel application which uses C code which itself relies on ISE Eiffel's runtime. Not the best choice to start with :-) I'll address this issues one after the other...

Since I won't pass in any program args, I will just hard code 0 and null.

Please let me know which file to change?

ebezault commented 6 months ago

Since I won't pass in any program args, I will just hard code 0 and null.

Please let me know which file to change?

Here, in EV_APPLICATION_IMP.gtk_init_check.

mw66 commented 6 months ago

OK, I change it to return 1 (as boolean):

                        "/* gtk_init_check (&eif_argc, &eif_argv) */ 1"

Now, the final problem:

/usr/bin/ld: /lib/x86_64-linux-gnu/libgtk-3.so: undefined reference to symbol 'gdk_window_hide'
/usr/bin/ld: /lib/x86_64-linux-gnu/libgdk-3.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Degree -4: 0/0/0 0:0:9.261

Do you know which lib have gdk_window_hide defined?

ebezault commented 6 months ago

Do you know which lib have gdk_window_hide defined?

No.

mw66 commented 6 months ago

fixed by add to /gobo/tool/gec/backend/c/config/gcc.cfg link:

`pkg-config --libs gdk-3.0` `pkg-config --libs gtk+-3.0` `pkg-config --libs glib-2.0` `pkg-config --libs gmodule-2.0` `pkg-config --libs x11`
mw66 commented 6 months ago
(.text+0x45): undefined reference to `eif_adopt'
/usr/bin/ld: (.text+0x57): undefined reference to `eif_wean'
(.text+0x8b): undefined reference to `eif_id_object'
(.text+0x6c9): undefined reference to `eif_protect'

I saw /gobo/tool/gec/runtime/c/ge_gc.h macro for eif_protect eif_wean eif_adopt

How to let the build see these macros first? (Ideally, GOBO should also define these as functions instead of macros, so user won't have link error when compile ISE project.)

And what's the GOBO equivalent of eif_id_object?

ebezault commented 6 months ago

fixed by add to /gobo/tool/gec/backend/c/config/gcc.cfg link:

`pkg-config --libs gdk-3.0` `pkg-config --libs gtk+-3.0` `pkg-config --libs glib-2.0` `pkg-config --libs gmodule-2.0` `pkg-config --libs x11`

I wonder what they do for that in the ISE Eiffel compiler. It should be somewhere in the ECF files! Ideally gec should add all these on the fly when needed, and not all the time even for non-gtk applications.

mw66 commented 6 months ago

fixed by add to /gobo/tool/gec/backend/c/config/gcc.cfg link:

`pkg-config --libs gdk-3.0` `pkg-config --libs gtk+-3.0` `pkg-config --libs glib-2.0` `pkg-config --libs gmodule-2.0` `pkg-config --libs x11`

I wonder what they do for that in the ISE Eiffel compiler. It should be somewhere in the ECF files! Ideally gec should add all these on the fly when needed, and not all the time even for non-gtk applications.

(I know I'm just hacking here).

./docking_simple.ecf does not have these libraries.

ebezault commented 6 months ago
(.text+0x45): undefined reference to `eif_adopt'
/usr/bin/ld: (.text+0x57): undefined reference to `eif_wean'
(.text+0x8b): undefined reference to `eif_id_object'
(.text+0x6c9): undefined reference to `eif_protect'

I saw /gobo/tool/gec/runtime/c/ge_gc.h macro for eif_protect eif_wean eif_adopt

How to let the build see these macros first?

And what's the GOBO equivalent of eif_id_object?

For eif_adopt, eif_protect and eif_wean, you should get and build the latest version of gec. It works for the cURL example. For eif_id_object I need to look at the ISE Eiffel code to see what it does in order to provide an equivalent implementation in gec.

mw66 commented 6 months ago

For eif_adopt, eif_protect and eif_wean, you should get and build the latest version of gec. It works for the cURL example.

I'm using the latest version of gec:

$ gec --version
gec version xx.xx.xx+xxxxxxxxx

Ideally, GOBO should also define these as functions instead of macros, so user won't have link error when compiling ISE project.

ebezault commented 6 months ago

I'm using the latest version of gec:

SHA 824c7e779f1e712bd085842438d3820ae188929f

Ideally, GOBO should also define these as functions instead of macros, so user won't have link error when compiling ISE project.

Why? You would still have to make sure that the C code of these functions are compiled into the resulting executable. They are also macros in the ISE Eiffel implementation.

mw66 commented 6 months ago

I'm using the latest version of gec:

SHA 824c7e7

Yes, I'm using this, just synced 10-minutes ago. Maybe you want to update gec version xx.xx.xx+xxxxxxxxx with some stamp even during dev.

Ideally, GOBO should also define these as functions instead of macros, so user won't have link error when compiling ISE project.

Why? You would still have to make sure that the C code of these functions are compiled into the resulting executable. They are also macros in the ISE Eiffel implementation.

Oh, then why we have link error here? For macros, it will be expanded on the spot, at most compile error, but not link error.

Basically what I mean is the GOBO external C impl structure better to match ISE external C impl structure, so no link surprise.

ebezault commented 6 months ago

Basically what I mean is the GOBO external C impl structure better to match ISE external C impl structure, so no link surprise.

Yes, so they are macros in ISE. You get links error because I did not include these macros in the right header files. But this can be fixed easily. The eif_*.h in Gobo are just here to make ISE's code compile with gec. But I will certainly not replicate ISE's runtime in Gobo.

mw66 commented 6 months ago

But I will certainly not replicate ISE's runtime in Gobo.

Yes, that I know. They are just stubs in GOBO.

ebezault commented 6 months ago

In other worlds, the eif_*.h files are a bridge between the Gobo Eiffel runtime and what is expected to compile ISE's libraries.

ebezault commented 6 months ago

I provide them as needed. Sometimes they don't end up in the right eif_*.h file my assumption was wrong (they were added here because it allowed one ISE library to compile, but they need to be moved somewhere else to compile another ISE library). That's what happened with eif_wean and others.

ebezault commented 6 months ago

I figured out what is the equivalent of eif_id_object in Gobo. So I will be able to provide a fix.

mw66 commented 6 months ago

FYI, found 27 diamonds in ISE Vision Smart Docking library

library/docking/package.iron

/Eiffel_23.09$ grep "diamond:" diamond.txt  | sort  | uniq 
diamond:  EV_ANY.implementation  =>  SD_DOCKING_ZONE_UPPER
diamond:  EV_ANY.implementation  =>  SD_PLACE_HOLDER_ZONE
diamond:  EV_ANY.implementation  =>  SD_TAB_ZONE_UPPER
diamond:  EV_COLORIZABLE.implementation  =>  SD_DOCKING_ZONE_UPPER
diamond:  EV_COLORIZABLE.implementation  =>  SD_PLACE_HOLDER_ZONE
diamond:  EV_COLORIZABLE.implementation  =>  SD_TAB_ZONE_UPPER
diamond:  EV_DOCKABLE_SOURCE.implementation  =>  SD_DOCKING_ZONE_UPPER
diamond:  EV_DOCKABLE_SOURCE.implementation  =>  SD_PLACE_HOLDER_ZONE
diamond:  EV_DOCKABLE_SOURCE.implementation  =>  SD_TAB_ZONE_UPPER
diamond:  EV_HELP_CONTEXTABLE.implementation  =>  SD_DOCKING_ZONE_UPPER
diamond:  EV_HELP_CONTEXTABLE.implementation  =>  SD_PLACE_HOLDER_ZONE
diamond:  EV_HELP_CONTEXTABLE.implementation  =>  SD_TAB_ZONE_UPPER
diamond:  EV_PICK_AND_DROPABLE.implementation  =>  SD_DOCKING_ZONE_UPPER
diamond:  EV_PICK_AND_DROPABLE.implementation  =>  SD_PLACE_HOLDER_ZONE
diamond:  EV_PICK_AND_DROPABLE.implementation  =>  SD_TAB_ZONE_UPPER
diamond:  EV_PIXMAPABLE.implementation  =>  SD_DOCKING_ZONE_UPPER
diamond:  EV_PIXMAPABLE.implementation  =>  SD_PLACE_HOLDER_ZONE
diamond:  EV_PIXMAPABLE.implementation  =>  SD_TAB_ZONE_UPPER
diamond:  EV_POSITIONED.implementation  =>  SD_DOCKING_ZONE_UPPER
diamond:  EV_POSITIONED.implementation  =>  SD_PLACE_HOLDER_ZONE
diamond:  EV_POSITIONED.implementation  =>  SD_TAB_ZONE_UPPER
diamond:  EV_SENSITIVE.implementation  =>  SD_DOCKING_ZONE_UPPER
diamond:  EV_SENSITIVE.implementation  =>  SD_PLACE_HOLDER_ZONE
diamond:  EV_SENSITIVE.implementation  =>  SD_TAB_ZONE_UPPER
diamond:  EV_WIDGET.implementation  =>  SD_DOCKING_ZONE_UPPER
diamond:  EV_WIDGET.implementation  =>  SD_PLACE_HOLDER_ZONE
diamond:  EV_WIDGET.implementation  =>  SD_TAB_ZONE_UPPER

$ grep "diamond:" diamond.txt  | sort  | uniq | wc
     27     108    1758

If we can make gec compile /Eiffel_23.09/examples/docking/simple, then we can test its behavior under gec.

mw66 commented 6 months ago

Hi @ebezault I saw to commits about eif_id_object

https://github.com/gobo-eiffel/gobo/commit/7e6102cea44270cf801778f1a0ba7a2dc6fe5ec9

is this done or not?

with the latest git pull update, I still saw undefined symbols:

/usr/bin/ld: /Eiffel/library/vision2/spec/linux-x86-64/lib/gtk3_eiffel.o: in function `add_watch_callback':
(.text+0x45): undefined reference to `eif_adopt'
/usr/bin/ld: (.text+0x57): undefined reference to `eif_wean'
/usr/bin/ld: /Eiffel/library/vision2/spec/linux-x86-64/lib/gtk3_eiffel.o: in function `c_ev_any_imp_c_object_dispose':
(.text+0x8b): undefined reference to `eif_id_object'
/usr/bin/ld: /Eiffel/library/vision2/spec/linux-x86-64/lib/gtk3_eiffel.o: in function `c_ev_any_imp_get_eif_reference_from_object_id':
(.text+0xec): undefined reference to `eif_id_object'
/usr/bin/ld: /Eiffel/library/vision2/spec/linux-x86-64/lib/gtk3_eiffel.o: in function `gclosure_notify_eif_wean':
(.text+0x5ea): undefined reference to `eif_wean'
/usr/bin/ld: /Eiffel/library/vision2/spec/linux-x86-64/lib/gtk3_eiffel.o: in function `gdestroy_notify_eif_wean':
(.text+0x60a): undefined reference to `eif_wean'
/usr/bin/ld: /Eiffel/library/vision2/spec/linux-x86-64/lib/gtk3_eiffel.o: in function `c_ev_gtk_callback_marshal_init':
(.text+0x6c9): undefined reference to `eif_protect'
/usr/bin/ld: /Eiffel/library/vision2/spec/linux-x86-64/lib/gtk3_eiffel.o: in function `c_ev_gtk_callback_marshal_signal_connect':
(.text+0x73a): undefined reference to `eif_adopt'
/usr/bin/ld: /Eiffel/library/vision2/spec/linux-x86-64/lib/gtk3_eiffel.o: in function `c_ev_gtk_callback_marshal_timeout_connect':
(.text+0x79b): undefined reference to `eif_adopt'
collect2: error: ld returned 1 exit status
Degree -4: 0/0/0 0:0:9.258

Thanks.

ebezault commented 6 months ago

Try version 5b1101009a182286665028752e6bef89dbce5cf5

I should fix:

ericb@yate:~/ise/Eiffel_23.09/examples/docking/simple$ gec docking_simple.ecf
Degree 6: 0/0/0 0:0:0.041
Degree 5: 0/0/0 0:0:0.504
Degree 4: 0/0/0 0:0:0.174
Degree 3: 0/0/0 0:0:0.066
Degree -2: 0/0/0 0:0:1.168
Degree -3: 0/0/0 0:0:0.900
docking_simple6.c:86033:8: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
 86033 | printf((char*) a1);
       |        ^       ~~
docking_simple6.c:86033:8: note: treat the string as an argument to avoid this
 86033 | printf((char*) a1);
       |        ^
       |        "%s",
1 warning generated.
Degree -4: 0/0/0 0:0:14.821
Total Time: 0/0/0 0:0:17.675

ericb@yate:~/ise/Eiffel_23.09/examples/docking/simple$ ./docking_simple

(docking_simple:19671): Gtk-WARNING **: 18:19:53.195: gtk_widget_event(): unhandled event type: 34
Gdk-Message: 18:19:56.207: Unable to load fleur from the cursor theme

(docking_simple:19671): GLib-GObject-CRITICAL **: 18:19:56.207: g_object_unref: assertion 'G_IS_OBJECT (object)' failed

I don't know if the messages that I get when executing are expected. I'm not running on a native Linux box but from WSL Ubuntu on Windows. I'll try compiling with ISE Eiffel to see if I get the same messages.

mw66 commented 6 months ago

Thanks. Trying now, will keep you updated ...

(BTW, ISE runs fine; but for my purpose, I don't need the GUI, I just want to print out some info during program init.)

Unfortunately, it Segmentation fault:

/Eiffel_23.09/examples/docking/simple$ make gobo 
gec --setting=inlining=False ./docking_simple.ecf
Degree 6: 0/0/0 0:0:0.075
Degree 5: 0/0/0 0:0:0.294
Degree 4: 0/0/0 0:0:0.168
Degree 3: 0/0/0 0:0:0.099
Degree -2: 0/0/0 0:0:1.359
Degree -3: 0/0/0 0:0:0.676
docking_simple6.c: In function ‘T243s45’:
docking_simple6.c:15241:1: warning: format not a string literal and no format arguments [-Wformat-security]
15241 | printf((char*) a1);
      | ^~~~~~
Degree -4: 0/0/0 0:0:11.004
Total Time: 0/0/0 0:0:13.676

/Eiffel_23.09/examples/docking/simple$ ./docking_simple
Segmentation fault (core dumped)

/Eiffel_23.09/examples/docking/simple$ gdb ./docking_simple
GNU gdb (Ubuntu 12.1-0ubuntu1~22.04) 12.1
(gdb) r
....

[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff5f14640 (LWP 2574041)]
[New Thread 0x7ffff5713640 (LWP 2574042)]
[New Thread 0x7ffff4f12640 (LWP 2574043)]
[New Thread 0x7ffff4711640 (LWP 2574044)]
[New Thread 0x7ffff3f10640 (LWP 2574045)]
[New Thread 0x7ffff370f640 (LWP 2574046)]
[New Thread 0x7ffff2f0e640 (LWP 2574047)]
[New Thread 0x7ffff26fd640 (LWP 2574048)]

Thread 1 "docking_simple" received signal SIGSEGV, Segmentation fault.
0x00007ffff738ccf4 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
(gdb) where
#0  0x00007ffff738ccf4 in  () at /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#1  0x00007ffff73a4664 in  () at /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#2  0x00007ffff7396754 in  () at /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#3  0x00007ffff7bd7f83 in g_type_create_instance () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#4  0x00007ffff7bbf0ed in  () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#5  0x00007ffff7bc034d in g_object_new_with_properties () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#6  0x00007ffff7bc0e51 in g_object_new () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#7  0x00007ffff759d2d8 in  () at /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#8  0x00007ffff7bd7f83 in g_type_create_instance () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#9  0x00007ffff7bbf0ed in  () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#10 0x00007ffff7bc034d in g_object_new_with_properties () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#11 0x00007ffff7bc0e51 in g_object_new () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#12 0x000055555577d7f4 in T441s5 ()
#13 0x0000555555c04263 in T708f241 ()
#14 0x0000555555be3e7a in T708c231 ()
#15 0x0000555555be37db in T596f5 ()
#16 0x0000555555be2c36 in T596f6 ()
#17 0x000055555576b4a8 in T581f26 ()
#18 0x000055555576b216 in T581f23 ()
#19 0x0000555555b5e2b1 in T581c22 ()
#20 0x00005555557b1553 in GE_main ()
#21 0x00005555557b5d96 in main ()
mw66 commented 6 months ago

BTW, if you want to try: my small modification of the program to test diamond is:

in main_window.e, method prepare_content_1(), add

local
                       zone: SD_PLACE_HOLDER_ZONE
                        impl, impl2: EV_WIDGET_I

and append at the end of do:

                        io.put_string ("Hello, diamond!%N")
                        create zone.make(content_1, manager)
                        impl := zone.implementation
                        impl2 := zone.implementation_upper_zone
                        print($impl)
                        io.put_string("%N")
                        print($impl2)
                        io.put_string("%N")
                        if zone.implementation /= Void then
                                if zone.implementation = zone.implementation_upper_zone then
                                        io.put_string ("zone.implementation = zone.implementation_upper_zone%N")
                                end
                                if zone.implementation_upper_zone.is_equal(zone.implementation) then
                                        io.put_string ("zone.implementation_upper_zone.is_equal(zone.implementation)%N")
                                end
                        end

With ISE compiler it outputs:

/Eiffel/examples/docking/simple$ Hello, diamond!
0x7FA55E6F6018
0x7FA55E6F6018
zone.implementation = zone.implementation_upper_zone
zone.implementation_upper_zone.is_equal(zone.implementation)
ebezault commented 6 months ago

Unfortunately, it Segmentation fault:

Try gec --gc=no docking_simple.ecf

ebezault commented 6 months ago

And also:

 gec --capability=concurrency=none docking_simple.ecf

or both.

mw66 commented 6 months ago

Unfortunately, it Segmentation fault:

Try gec --gc=no docking_simple.ecf

Same problem:

/Eiffel/examples/docking/simple$ make
gec --gc=no ./docking_simple.ecf
Degree 6: 0/0/0 0:0:0.073
Degree 5: 0/0/0 0:0:0.267
Degree 4: 0/0/0 0:0:0.175
Degree 3: 0/0/0 0:0:0.091
Degree -2: 0/0/0 0:0:1.378
Degree -3: 0/0/0 0:0:0.837
docking_simple5.c: In function ‘T243s45’:
docking_simple5.c:86171:1: warning: format not a string literal and no format arguments [-Wformat-security]
86171 | printf((char*) a1);
      | ^~~~~~
Degree -4: 0/0/0 0:0:10.740
Total Time: 0/0/0 0:0:13.562

...

[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff6014640 (LWP 2575162)]

Thread 1 "docking_simple" received signal SIGSEGV, Segmentation fault.
0x00007ffff738ccf4 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
(gdb) where
#0  0x00007ffff738ccf4 in  () at /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#1  0x00007ffff73a4664 in  () at /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#2  0x00007ffff7396754 in  () at /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#3  0x00007ffff7bd7f83 in g_type_create_instance () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#4  0x00007ffff7bbf0ed in  () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#5  0x00007ffff7bc034d in g_object_new_with_properties () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#6  0x00007ffff7bc0e51 in g_object_new () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#7  0x00007ffff759d2d8 in  () at /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#8  0x00007ffff7bd7f83 in g_type_create_instance () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#9  0x00007ffff7bbf0ed in  () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#10 0x00007ffff7bc034d in g_object_new_with_properties () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#11 0x00007ffff7bc0e51 in g_object_new () at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#12 0x00005555557edd43 in T441s5 ()
#13 0x0000555555c03c99 in T708f241 ()
#14 0x0000555555be42f1 in T708c231 ()
#15 0x0000555555be3bd5 in T596f5 ()
#16 0x0000555555be3030 in T596f6 ()
#17 0x00005555557dbd87 in T581f26 ()
#18 0x00005555557dbad0 in T581f23 ()
#19 0x0000555555b5c883 in T581c22 ()
#20 0x000055555572c207 in GE_main ()
#21 0x0000555555730975 in main ()
mw66 commented 6 months ago

And also:

 gec --capability=concurrency=none docking_simple.ecf

or both.

ok, trying ...

ebezault commented 6 months ago

Note that on my machine (WSL Ubuntu under Windows 11) I don't get a Segmentation fault and it displays a small window on the screen. Did you get this window?

I'm using zig cc as C compiler, not gcc.

mw66 commented 6 months ago

Note that on my machine (WSL Ubuntu under Windows 11) I don't get a Segmentation fault and it displays a small window on the screen. Did you get this window?

I'm using zig cc as C compiler, not gcc.

No, I didn't get any window.

Can you try my small modification, and copy the output here?

I will try zig cc myself ...

mw66 commented 6 months ago

BTW, what's the command to gec to use zig cc?

ebezault commented 6 months ago

To install zig cc, download it from https://ziglang.org/download/ (use the latest version). Unzip it in $GOBO/tool/gec/backend/c. Make sure to rename the folder as $GOBO/tool/gec/backend/c/zig. Update $GOBO/tool/gec/backend/c/config/default.cfg to be just zig. Recompile the docking example with gec.

ebezault commented 6 months ago

No environment variable to be set, no need to change $PATH, and no new command-line argument to use zig cc.

ebezault commented 6 months ago

Can you try my small modification, and copy the output here?

Hello, diamond!
0x2964560
0x29608B0
mw66 commented 6 months ago

Can you try my small modification, and copy the output here?

Hello, diamond!
0x2964560
0x29608B0

OK, verified in real code, that ISE and GOBO use different semantics in this diamond field renaming. Thanks.

ebezault commented 6 months ago

I wonder whether there is a real (i.e. chosen) semantics, or whether it depends on the order in the inherit clause.

mw66 commented 6 months ago

To install zig cc, download it from https://ziglang.org/download/ (use the latest version). Unzip it in $GOBO/tool/gec/backend/c. Make sure to rename the folder as $GOBO/tool/gec/backend/c/zig. Update $GOBO/tool/gec/backend/c/config/default.cfg to be just zig. Recompile the docking example with gec.

I followed this instruction on

$ cat /etc/issue
Ubuntu 22.04.3 LTS \n \l

/Eiffel/examples/docking/simple$ make
gec ./docking_simple.ecf
Degree 6: 0/0/0 0:0:0.078
Degree 5: 0/0/0 0:0:0.291
Degree 4: 0/0/0 0:0:0.198
Degree 3: 0/0/0 0:0:0.085
Degree -2: 0/0/0 0:0:1.368
Degree -3: 0/0/0 0:0:0.882
docking_simple6.c:86171:8: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
 86171 | printf((char*) a1);
       |        ^       ~~
docking_simple6.c:86171:8: note: treat the string as an argument to avoid this
 86171 | printf((char*) a1);
       |        ^
       |        "%s", 
1 warning generated.
Degree -4: 0/0/0 0:0:12.760
Total Time: 0/0/0 0:0:15.663

From the 2nd note message, (which is absent in gcc) looks like the backend is using zig cc.

But the result is the same:

Thread 1 "docking_simple" received signal SIGSEGV, Segmentation fault.

I will try on WSL as your system later. BTW, which WSL version you are using?

ebezault commented 6 months ago

WSL 2:

PS C:\> wsl --list --verbose
  NAME      STATE           VERSION
* Ubuntu    Running         2
ericb@yate:~$ cat /etc/issue
Ubuntu 20.04.2 LTS \n \l
ebezault commented 6 months ago

From the 2nd note message, (which is absent in gcc) looks like the backend is using zig cc.

If you recompile, the Degree -4 should be faster, and it will not show the C warning messages.

ebezault commented 6 months ago

Thread 1 "docking_simple" received signal SIGSEGV, Segmentation fault.

If you use:

gec --gc=no --capability=concurrency=none docking_simple.ecf

not thread should be created.