vmagnin/gtk-fortran

With Intel ifort/ifx, gtkbuilder, gtkbuilder2 and gtkf-sketcher could not open gtkbuilder.glade

vmagnin opened this issue · 16 comments

Describe the bug
When gtk-fortran is built with ifort, gtkbuilder, gtkbuilder2 and gtkf-sketcher don't work and just print that error:
Could not open gtkbuilder.glade

Your system:

  • OS version: Ubuntu 21.04 64 bits
  • Compiler version: ifort (IFORT) 2021.2.0 20210228
  • GTK branch: tested only in gtk4.

Additional context
No problem with gfortran.

Under MSYS2/Windows 10, and compiled with gfortran, gtkbuilder don't work and prints the same message.
But gtkbuilder2 and gtkf-sketcher have no problem, probably because they contain the GCC$ ATTRIBUTES DLLEXPORT.

gtkbuilder.f90 has been removed from the gtk4 branch, as it is now a duplicate of gtkbuilder2.f90 (they were using two different GTK 3 functions, removed in GTK 4).

Same problem with GTK 4.4 and ifort 2021.4.0

After replacing gtk_builder_add_from_file() by gtk_builder_new_from_file(), the ifort 2021.4.0 error message is:

(process:24055): Gtk-ERROR **: 18:43:29.082: failed to add UI from file gtkbuilder.glade: No function named `hello`.
Trappe pour point d'arrêt et de trace (core dumped)

although there is a subroutine hello(widget, gdata ) bind(c) in the code.

https://docs.gtk.org/gtk4/class.Builder.html

Same error message now with GTK 4.6.2: GFortran 12.0.1 in Fedora Rawhide, GFortran 11.2.0 in FreeBSD 13.

[osboxes@localhost examples]$ ./gtkbuilder2

(process:14648): Gtk-ERROR **: 14:56:45.953: failed to add UI from file gtkbuilder.glade: No function named `hello`.

Program received signal SIGTRAP: Trace/breakpoint trap.

Backtrace for this error:
#0  0x7f0a97623a22 in ???
#1  0x7f0a97622bb5 in ???
#2  0x7f0a97242a2f in ???
#3  0x7f0a9799bd80 in ???
#4  0x7f0a979957f0 in ???
#5  0x7f0a97995a41 in ???
#6  0x7f0a97ed616f in ???
#7  0x4013f7 in gtkbuilder
	at /home/osboxes/gtk-fortran/examples/gtkbuilder2.f90:95
#8  0x401496 in main
	at /home/osboxes/gtk-fortran/examples/gtkbuilder2.f90:86
Trace/breakpoint trap (core dumped)

Line 86 is:

  use handlers

Line 95 is:

builder=gtk_builder_new_from_file("gtkbuilder.glade"//c_null_char)

But it works under MSYS2/Windows 10, with GFortran 11.2.0 and GTK 4.6.2.

No problem with GTK 4.6.3 and GFortran 12.0.1 in latest Fedora Rawhide.

Same problem with ifx 2022.1.0 20220316 ; gtk-fortran 4.2.1, GTK 4.6.3

The same error message occurs under MSYS2/Windows 10 if I remove the !GCC$ ATTRIBUTES DLLEXPORT :: attributes in gtkbuilder2.f90, and use GFortran to build it.

Ubuntu 22.04 with GTK 4.6.6 and ifx (IFORT) 2022.1.0 20220316:

$ ./gtkbuilder2

(process:22056): Gtk-ERROR **: 09:29:25.298: failed to add UI from file gtkbuilder.ui: No function named `hello`.

$ gtk4-builder-tool preview gtkbuilder.ui
No function named `hello`.

Idem with GTK 4.8.1, ifx 2023.0.0, Ubuntu 22.10.

$ readelf --wide --syms  ./gtkbuilder2 | grep hello
...
Symbol table '.symtab' contains 917 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
...
   818: 0000000000405270    81 FUNC    GLOBAL DEFAULT   16 hello
...

Could it be because GTK is not built with an Intel compiler?

Or should we use a specific Intel compiler flag?