Ticket #30 (new enhancement)

Opened 7 months ago

Last modified 4 weeks ago

Mac support for gtkD

Reported by: afb Assigned to: JJR
Priority: major Milestone:
Component: Loader System Version: TRUNK
Keywords: Cc:

Description

I fixed the wrong spelling of "version(darwin)", and added the required libraries...

These symbols could not be found:

failed (/opt/gtk/lib/libglib-2.0.dylib) g_atomic_int_inc
failed (/opt/gtk/lib/libglib-2.0.dylib) g_atomic_int_dec_and_test
failed (/opt/gtk/lib/libglib-2.0.dylib) g_io_channel_win32_new_fd
failed (/opt/gtk/lib/libglib-2.0.dylib) g_io_channel_win32_new_socket
failed (/opt/gtk/lib/libglib-2.0.dylib) g_io_channel_win32_new_messages
failed (/opt/gtk/lib/libglib-2.0.dylib) g_ascii_isalnum
failed (/opt/gtk/lib/libglib-2.0.dylib) g_ascii_isalpha
failed (/opt/gtk/lib/libglib-2.0.dylib) g_ascii_iscntrl
failed (/opt/gtk/lib/libglib-2.0.dylib) g_ascii_isdigit
failed (/opt/gtk/lib/libglib-2.0.dylib) g_ascii_isgraph
failed (/opt/gtk/lib/libglib-2.0.dylib) g_ascii_islower
failed (/opt/gtk/lib/libglib-2.0.dylib) g_ascii_isprint
failed (/opt/gtk/lib/libglib-2.0.dylib) g_ascii_ispunct
failed (/opt/gtk/lib/libglib-2.0.dylib) g_ascii_isspace
failed (/opt/gtk/lib/libglib-2.0.dylib) g_ascii_isupper
failed (/opt/gtk/lib/libglib-2.0.dylib) g_ascii_isxdigit
failed (/opt/gtk/lib/libglib-2.0.dylib) g_checksum_type_get_length
failed (/opt/gtk/lib/libglib-2.0.dylib) g_format_size_for_display
failed (/opt/gtk/lib/libglib-2.0.dylib) g_uri_parse_scheme
failed (/opt/gtk/lib/libglib-2.0.dylib) g_win32_error_message
failed (/opt/gtk/lib/libglib-2.0.dylib) g_win32_getlocale
failed (/opt/gtk/lib/libglib-2.0.dylib) g_win32_get_package_installation_directory
failed (/opt/gtk/lib/libglib-2.0.dylib) g_win32_get_package_installation_directory_of_module
failed (/opt/gtk/lib/libglib-2.0.dylib) g_win32_get_package_installation_subdirectory
failed (/opt/gtk/lib/libglib-2.0.dylib) g_win32_get_windows_version
failed (/opt/gtk/lib/libglib-2.0.dylib) g_win32_locale_filename_from_utf8
failed (/opt/gtk/lib/libpango-1.0.dylib) pango_layout_set_height
failed (/opt/gtk/lib/libpango-1.0.dylib) pango_layout_get_height
failed (/opt/gtk/lib/libpango-1.0.dylib) script_engine_list
failed (/opt/gtk/lib/libpango-1.0.dylib) script_engine_init
failed (/opt/gtk/lib/libpango-1.0.dylib) script_engine_exit
failed (/opt/gtk/lib/libpango-1.0.dylib) script_engine_create
failed (/opt/gtk/lib/libgthread-2.0.dylib) g_mutex_new
failed (/opt/gtk/lib/libgthread-2.0.dylib) g_mutex_lock
failed (/opt/gtk/lib/libgthread-2.0.dylib) g_mutex_trylock
failed (/opt/gtk/lib/libgthread-2.0.dylib) g_mutex_unlock
failed (/opt/gtk/lib/libgthread-2.0.dylib) g_mutex_free
failed (/opt/gtk/lib/libgthread-2.0.dylib) g_static_mutex_lock
failed (/opt/gtk/lib/libgthread-2.0.dylib) g_static_mutex_trylock
failed (/opt/gtk/lib/libgthread-2.0.dylib) g_static_mutex_unlock
failed (/opt/gtk/lib/libgthread-2.0.dylib) g_static_mutex_get_mutex
failed (/opt/gtk/lib/libgthread-2.0.dylib) g_cond_new
failed (/opt/gtk/lib/libgthread-2.0.dylib) g_cond_signal
failed (/opt/gtk/lib/libgthread-2.0.dylib) g_cond_broadcast
failed (/opt/gtk/lib/libgthread-2.0.dylib) g_cond_wait
failed (/opt/gtk/lib/libgthread-2.0.dylib) g_cond_timed_wait
failed (/opt/gtk/lib/libgthread-2.0.dylib) g_cond_free
failed (/opt/gtk/lib/libgthread-2.0.dylib) g_private_new
failed (/opt/gtk/lib/libgthread-2.0.dylib) g_private_get
failed (/opt/gtk/lib/libgthread-2.0.dylib) g_private_set
failed (/opt/gtk/lib/libgthread-2.0.dylib) g_thread_supported
failed (/opt/gtk/lib/libgthread-2.0.dylib) g_thread_create
failed (/opt/gtk/lib/libgthread-2.0.dylib) g_thread_yield
failed (/opt/gtk/lib/libgdk-quartz-2.0.dylib) gdk_xid_table_lookup
failed (/opt/gtk/lib/libgdk-quartz-2.0.dylib) gdk_x11_get_server_time
failed (/opt/gtk/lib/libgdk-quartz-2.0.dylib) gdk_x11_window_set_user_time
failed (/opt/gtk/lib/libgdk-quartz-2.0.dylib) gdk_x11_window_move_to_current_desktop
failed (/opt/gtk/lib/libgdk-quartz-2.0.dylib) gdk_x11_display_broadcast_startup_message
failed (/opt/gtk/lib/libgdk-quartz-2.0.dylib) gdk_x11_display_get_startup_notification_id
failed (/opt/gtk/lib/libgdk-quartz-2.0.dylib) gdk_x11_drawable_get_xid
failed (/opt/gtk/lib/libgdk-quartz-2.0.dylib) gdk_x11_font_get_name
failed (/opt/gtk/lib/libgdk-quartz-2.0.dylib) gdk_x11_font_get_xfont
failed (/opt/gtk/lib/libgdk-quartz-2.0.dylib) gdk_x11_get_default_screen
failed (/opt/gtk/lib/libgdk-quartz-2.0.dylib) gdk_x11_grab_server
failed (/opt/gtk/lib/libgdk-quartz-2.0.dylib) gdk_x11_ungrab_server

The program crashes on startup, in "g_malloc0" or similar threaded allocation attempt.

Attachments

gtkD-Mac.patch (5.7 kB) - added by afb on 03/16/08 06:06:03.
gtkD-Mac.patch
gtkD-Mac.2.patch (8.3 kB) - added by Mike Wey on 09/18/08 15:54:05.
new patch posted by afb on the D newsgroup
Mac.patch (8.3 kB) - added by Mike Wey on 09/18/08 15:56:17.
new patch posted by afb on the D newsgroup

Change History

03/16/08 06:06:03 changed by afb

  • attachment gtkD-Mac.patch added.

gtkD-Mac.patch

03/16/08 06:07:37 changed by afb

(that "win32" and "x11" functions fail to load shouldn't be too surprising)

03/16/08 10:59:50 changed by Mike Wey

The failed functions look similar to the ones that fail on my system. except for the x11 functions. That shouldn't be a problem as long as the program you're running doesn't use them.

(in reply to: ↑ description ) 03/16/08 12:08:24 changed by Mike Wey

Replying to afb:

The program crashes on startup, in "g_malloc0" or similar threaded allocation attempt.

If this only happens with the TestWindow? demo it might be a gdc bug (Bugzilla: 1751) witch causes the TestWindow? demo to segfault when build with gdc 0.24

03/16/08 12:53:51 changed by afb

That seems to be the same thing, yes. I'm using r199 but same thing happens.

true
Error: AssertError Failure test.d(8) test is only null in gdc 0.24

03/16/08 12:54:43 changed by afb

(GDC pre-release 0.25 svn r199 that is, not gtkd's changeset 199)

(follow-up: ↓ 7 ) 03/16/08 14:25:05 changed by afb

Still crashes in the same place when using GDC 0.23.

#0  0x001241d9 in g_malloc0 ()
#1  0x00000246 in ?? ()
#2  0x00b61ed7 in g_thread_init_glib ()
#3  0x0097c820 in g_thread_init ()
#4  0x00042456 in gtk.GtkD.GtkD.initMultiThread(char[][]) (args={length = 1, ptr = 0xc00550}) at src/gtk/GtkD.d:161

(in reply to: ↑ 6 ) 03/17/08 15:06:47 changed by Mike Wey

Replying to afb:

Still crashes in the same place when using GDC 0.23. {{{ #0 0x001241d9 in g_malloc0 () #1 0x00000246 in ?? () #2 0x00b61ed7 in g_thread_init_glib () #3 0x0097c820 in g_thread_init () #4 0x00042456 in gtk.GtkD.GtkD.initMultiThread(char[][]) (args={length = 1, ptr = 0xc00550}) at src/gtk/GtkD.d:161 }}}

I am able to reproduce this on linux when i use "-q,-rdynamic" when linking the executable.

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb7dc8ae0 (LWP 7976)]
0x082b6655 in g_malloc ()

(gdb) backtrace
#0  0x082b6655 in g_malloc ()
#1  0xb7f56253 in g_mutex_new_posix_impl () from /usr/lib/libgthread-2.0.so
#2  0xb76e3499 in g_thread_init_glib () from /usr/lib/libglib-2.0.so.0
#3  0xb7f5653a in g_thread_init () from /usr/lib/libgthread-2.0.so
#4  0x081c6aea in _D7gthread6Thread6Thread4initFPS4gtkc12gthreadtypes16GThreadFunctionsZv (vtable=0x0) at gthread/Thread.d:160
#5  0x081a35fc in _D3gtk4GtkD4GtkD15initMultiThreadFAAaZ

03/25/08 06:03:48 changed by afb

I wouldn't know, GTK works fine from D when using the bindings instead of function pointers...

03/25/08 15:34:12 changed by Mike Wey

The -rdynamic switch somehow messes with the dynamically loaded symbols in gtkD.

If you are using a similar switch on OSX then that is probably causing the segfault. i asume you are using -Wl,-undefined,dynamic_lookup since they are in the makefile, i haven't found what they do.

for a description of the -rdynamic switch:

-rdynamic
Pass the flag -export-dynamic to the ELF linker, on targets that support it. This instructs the linker to add all symbols, not only used ones, to the dynamic symbol table. This option is needed for some uses of dlopen or to allow obtaining backtraces from within a program.

and for -export-dynamic

--export-dynamic
When creating a dynamically linked executable, add all symbols to the dynamic symbol table. The dynamic symbol table is the set of symbols which are visible from dynamic objects at run time. If you do not use this option, the dynamic symbol table will normally contain only those symbols which are referenced by some dynamic object mentioned in the link. If you use dlopen to load a dynamic object which needs to refer back to the symbols defined by the program, rather than some other dynamic object, then you will probably need to use this option when linking the program itself.

(follow-up: ↓ 11 ) 04/13/08 11:49:29 changed by Mike Wey

i found the meaning of -undefined,dynamic_lookup:

-undefined treatment

Specifies how undefined symbols are to be treated. Options are: error, warning, suppress, or dynamic_lookup. The default is error.

I don't know how this relates to the -rdynamic flag on linux, what heapen when you don't pass those flags to the linker?

(in reply to: ↑ 10 ) 04/13/08 13:00:28 changed by Mike Wey

and for dynamic_lookup

-undefined dynamic_lookup, if a symbol is not found, we will link anyway and hope to find it later in a dynlib.

09/18/08 15:54:05 changed by Mike Wey

  • attachment gtkD-Mac.2.patch added.

new patch posted by afb on the D newsgroup

09/18/08 15:56:17 changed by Mike Wey

  • attachment Mac.patch added.

new patch posted by afb on the D newsgroup

09/18/08 15:58:15 changed by Mike Wey

Having problems uploading the patch.

09/18/08 15:59:30 changed by Mike Wey

It seems it's only a problem with viewing the patch online.