woboq / qmetaobject-rs

Integrate Qml and Rust by building the QMetaObject at compile time.
MIT License
620 stars 89 forks source link

Unable to load qmetaobject based QML Plugins in KDE6 #310

Open brummer-simon opened 4 months ago

brummer-simon commented 4 months ago

Hi,

I am not sure where to place this, but maybe this is a qmetaobject issue or at least I might get a hint in the right direction. I am using qmetaobject to write rust based backends for KDE Plasmoids (Desktop widgets). A Plasmoid is a QML Application and building the backend in Rust worked flawlessly in KDE5.

Now KDE6 was published and QML plugins written with qmetaobject are not loaded anymore. The error message is:

lib/qt6/qml/org/kde/plasma/private/todo_txt/libqml_plugin_todo_txt.so': '/usr/lib/qt6/qml/org/kde/plasma/private/todo_txt/libqml_plugin_todo_txt.so' is not a valid ELF object (.qtmetadata section has incorrect magic)

To investigate further, here are all ELF sections for a working plugin shipped wird KDE6:

╰─➤  readelf -S libcolorpickerplugin.so
There are 28 section headers, starting at offset 0x7500:

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .note.gnu.pr[...] NOTE             00000000000002a8  000002a8
       0000000000000050  0000000000000000   A       0     0     8
  [ 2] .note.qt.metadata NOTE             00000000000002f8  000002f8
       0000000000000088  0000000000000000   A       0     0     8
  [ 3] .note.gnu.bu[...] NOTE             0000000000000380  00000380
       0000000000000024  0000000000000000   A       0     0     4
  [ 4] .gnu.hash         GNU_HASH         00000000000003a8  000003a8
       000000000000002c  0000000000000000   A       5     0     8
  [ 5] .dynsym           DYNSYM           00000000000003d8  000003d8
       00000000000009c0  0000000000000018   A       6     1     8
  [ 6] .dynstr           STRTAB           0000000000000d98  00000d98
       0000000000000ef5  0000000000000000   A       0     0     1
  [ 7] .gnu.version      VERSYM           0000000000001c8e  00001c8e
       00000000000000d0  0000000000000002   A       5     0     2
  [ 8] .gnu.version_r    VERNEED          0000000000001d60  00001d60
       0000000000000110  0000000000000000   A       6     6     8
  [ 9] .rela.dyn         RELA             0000000000001e70  00001e70
       0000000000000be8  0000000000000018   A       5     0     8
  [10] .relr.dyn         RELR             0000000000002a58  00002a58
       0000000000000038  0000000000000008   A       0     0     8
  [11] .init             PROGBITS         0000000000003000  00003000
       000000000000001b  0000000000000000  AX       0     0     4
  [12] .text             PROGBITS         0000000000003020  00003020
       0000000000001bda  0000000000000000  AX       0     0     16
  [13] .fini             PROGBITS         0000000000004bfc  00004bfc
       000000000000000d  0000000000000000  AX       0     0     4
  [14] .rodata           PROGBITS         0000000000005000  00005000
       0000000000000748  0000000000000000   A       0     0     32
  [15] .eh_frame_hdr     PROGBITS         0000000000005748  00005748
       00000000000001f4  0000000000000000   A       0     0     4
  [16] .eh_frame         PROGBITS         0000000000005940  00005940
       00000000000007b8  0000000000000000   A       0     0     8
  [17] .init_array       INIT_ARRAY       0000000000007648  00006648
       0000000000000010  0000000000000008  WA       0     0     8
  [18] .fini_array       FINI_ARRAY       0000000000007658  00006658
       0000000000000008  0000000000000008  WA       0     0     8
  [19] .data.rel.ro      PROGBITS         0000000000007660  00006660
       00000000000004c8  0000000000000000  WA       0     0     32
  [20] .dynamic          DYNAMIC          0000000000007b28  00006b28
       0000000000000230  0000000000000010  WA       6     0     8
  [21] .got              PROGBITS         0000000000007d58  00006d58
       00000000000002a0  0000000000000008  WA       0     0     8
  [22] .data             PROGBITS         0000000000008000  00007000
       0000000000000390  0000000000000000  WA       0     0     32
  [23] .qtversion        PROGBITS         0000000000008390  00007390
       0000000000000010  0000000000000000  WA       0     0     16
  [24] .bss              NOBITS           00000000000083a0  000073a0
       0000000000000050  0000000000000000  WA       0     0     16
  [25] .comment          PROGBITS         0000000000000000  000073a0
       000000000000001b  0000000000000001  MS       0     0     1
  [26] .gnu_debuglink    PROGBITS         0000000000000000  000073bc
       0000000000000024  0000000000000000           0     0     4
  [27] .shstrtab         STRTAB           0000000000000000  000073e0
       0000000000000120  0000000000000000           0     0     1

and here are all ELF sections for a my plugin built with qmetaobject:

╰─➤  readelf -S libqml_plugin_todo_txt.so 
There are 41 section headers, starting at offset 0x3f12740:

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .note.gnu.bu[...] NOTE             0000000000000270  00000270
       0000000000000024  0000000000000000   A       0     0     4
  [ 2] .gnu.hash         GNU_HASH         0000000000000298  00000298
       000000000000016c  0000000000000000   A       3     0     8
  [ 3] .dynsym           DYNSYM           0000000000000408  00000408
       00000000000018d8  0000000000000018   A       4     1     8
  [ 4] .dynstr           STRTAB           0000000000001ce0  00001ce0
       0000000000001f88  0000000000000000   A       0     0     1
  [ 5] .gnu.version      VERSYM           0000000000003c68  00003c68
       0000000000000212  0000000000000002   A       3     0     2
  [ 6] .gnu.version_r    VERNEED          0000000000003e80  00003e80
       0000000000000210  0000000000000000   A       4     7     8
  [ 7] .rela.dyn         RELA             0000000000004090  00004090
       00000000000838b0  0000000000000018   A       3     0     8
  [ 8] .rela.plt         RELA             0000000000087940  00087940
       0000000000000738  0000000000000018  AI       3    25     8
  [ 9] .init             PROGBITS         0000000000089000  00089000
       000000000000001b  0000000000000000  AX       0     0     4
  [10] .plt              PROGBITS         0000000000089020  00089020
       00000000000004e0  0000000000000010  AX       0     0     16
  [11] .plt.got          PROGBITS         0000000000089500  00089500
       0000000000000020  0000000000000008  AX       0     0     8
  [12] .text             PROGBITS         0000000000089520  00089520
       000000000061eb81  0000000000000000  AX       0     0     16
  [13] .fini             PROGBITS         00000000006a80a4  006a80a4
       000000000000000d  0000000000000000  AX       0     0     4
  [14] .rodata           PROGBITS         00000000006a9000  006a9000
       00000000000722a8  0000000000000000   A       0     0     32
  [15] .qtmetadata       PROGBITS         000000000071b2a8  0071b2a8
       00000000000000a4  0000000000000000   A       0     0     1
  [16] .eh_frame_hdr     PROGBITS         000000000071b34c  0071b34c
       000000000002cdc4  0000000000000000   A       0     0     4
  [17] .eh_frame         PROGBITS         0000000000748110  00748110
       000000000009aa18  0000000000000000   A       0     0     8
  [18] .gcc_except_table PROGBITS         00000000007e2b28  007e2b28
       00000000000270f0  0000000000000000   A       0     0     4
  [19] .tdata            PROGBITS         000000000080ae40  00809e40
       0000000000000028  0000000000000000 WAT       0     0     8
  [20] .tbss             NOBITS           000000000080ae68  00809e68
       0000000000000170  0000000000000000 WAT       0     0     8
  [21] .init_array       INIT_ARRAY       000000000080ae68  00809e68
       0000000000000010  0000000000000008  WA       0     0     8
  [22] .fini_array       FINI_ARRAY       000000000080ae78  00809e78
       0000000000000008  0000000000000008  WA       0     0     8
  [23] .data.rel.ro      PROGBITS         000000000080ae80  00809e80
       000000000004ae68  0000000000000000  WA       0     0     8
  [24] .dynamic          DYNAMIC          0000000000855ce8  00854ce8
       0000000000000270  0000000000000010  WA       4     0     8
  [25] .got              PROGBITS         0000000000855f58  00854f58
       000000000000e0a8  0000000000000008  WA       0     0     8
  [26] .data             PROGBITS         0000000000864000  00863000
       0000000000000160  0000000000000000  WA       0     0     32
  [27] .bss              NOBITS           0000000000864180  00863160
       0000000000002908  0000000000000000  WA       0     0     128
  [28] .comment          PROGBITS         0000000000000000  00863160
       000000000000001b  0000000000000001  MS       0     0     1
  [29] .debug_aranges    PROGBITS         0000000000000000  0086317b
       000000000009fa10  0000000000000000           0     0     1
  [30] .debug_pubnames   PROGBITS         0000000000000000  00902b8b
       000000000064b01a  0000000000000000           0     0     1
  [31] .debug_info       PROGBITS         0000000000000000  00f4dba5
       0000000000fa284c  0000000000000000           0     0     1
  [32] .debug_abbrev     PROGBITS         0000000000000000  01ef03f1
       0000000000043183  0000000000000000           0     0     1
  [33] .debug_line       PROGBITS         0000000000000000  01f33574
       0000000000419c54  0000000000000000           0     0     1
  [34] .debug_str        PROGBITS         0000000000000000  0234d1c8
       0000000000dcdd2f  0000000000000001  MS       0     0     1
  [35] .debug_loc        PROGBITS         0000000000000000  0311aef7
       000000000004d478  0000000000000000           0     0     1
  [36] .debug_pubtypes   PROGBITS         0000000000000000  0316836f
       00000000007e989f  0000000000000000           0     0     1
  [37] .debug_ranges     PROGBITS         0000000000000000  03951c0e
       00000000002b61c0  0000000000000000           0     0     1
  [38] .symtab           SYMTAB           0000000000000000  03c07dd0
       00000000000a97e8  0000000000000018          39   28663     8
  [39] .strtab           STRTAB           0000000000000000  03cb15b8
       0000000000260fee  0000000000000000           0     0     1
  [40] .shstrtab         STRTAB           0000000000000000  03f125a6
       0000000000000199  0000000000000000           0     0     1

So obviously the QT related parts differ and are probably the cause why the Plugin is not loading. Any Idea where and how to fix it?

Cheers Simon

ratijas commented 4 months ago

I don't wanna be that person but there's no such thing as "KDE6" or "KDE5". KDE is the community. We develop and ship Plasma 6, Frameworks (KF6) and Gears (apps).

To the best of my understanding, your issue doesn't have anything to do with neither, it's just a plain Qt plugin which fails to load due to having some unexpected metadata format. Which Qt are you linking it against?

brummer-simon commented 4 months ago

I don't wanna be that person but there's no such thing as "KDE6" or "KDE5". KDE is the community. We develop and ship Plasma 6, Frameworks (KF6) and Gears (apps).

To the best of my understanding, your issue doesn't have anything to do with neither, it's just a plain Qt plugin which fails to load due to having some unexpected metadata format. Which Qt are you linking it against?

Right. Of course i run plasma 6 and I link against Qt 6.6.2. It looks like qttypes finds it after passing the QMAKE variable:

[qttypes 0.2.11] cargo:VERSION=6.6.2
[qttypes 0.2.11] cargo:LIBRARY_PATH=/usr/lib
[qttypes 0.2.11] cargo:INCLUDE_PATH=/usr/include/qt6
[qttypes 0.2.11] cargo:FOUND=1
[qttypes 0.2.11] cargo:COMPILE_FLAGS=-std=c++17
[qttypes 0.2.11] cargo:rustc-cdylib-link-arg=-Wl,-rpath,/usr/lib
[qttypes 0.2.11] cargo:rustc-link-search=/usr/lib
[qttypes 0.2.11] cargo:rustc-link-lib=Qt6Core
[qttypes 0.2.11] cargo:rustc-link-lib=Qt6Gui
[qttypes 0.2.11] cargo:rustc-link-lib=Qt6Widgets
[qttypes 0.2.11] cargo:rustc-link-lib=Qt6Quick
[qttypes 0.2.11] cargo:rustc-link-lib=Qt6Qml