Forum > Other

FPC + Lazarus on DragonflyBSD: sanity check needed!

(1/2) > >>

guest64953:
DFBSD forked the FreeBSD ports tree to create DPorts and also use pkg, so these annoyance also applied: https://forum.lazarus.freepascal.org/index.php/topic,47662.msg341767/topicseen.html

But the most important is the insane big binary generated by FPC. For a project create by select Application without added anything, the resulted binary is 31.1 mb! It's riddiculous! This is too big! On Linux, it's just 25 mb or so. I also discovered that the option Link Smart and Smart Linking of Lazarus, usually helped to reduce the binary size, not worked. Even the Os option, when checked and rebuild, has no affect at all! The binary itself, when properly stripped with:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---strip --strip-all project1
is only 5.8 mb, still too big compared to a 2 mb or so binary on Linux.

I checked the binary itself with ldd and discovered it is a dynamic linked binary. It's stranged. This binary usually statically linked. When you see the result of ldd, you can not keep from surprising: it was linked with so many library, even libstdc++. What? WTF my simple application has anything to do with libstdc++ after all?  >:(


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---$ ldd tmp/project1tmp/project1:        libpthread.so.0 => /usr/lib/libpthread.so.0 (0x800a48000)        libgdk-x11-2.0.so.0 => /usr/local/lib/libgdk-x11-2.0.so.0 (0x800a62000)        libX11.so.6 => /usr/local/lib/libX11.so.6 (0x800b14000)        libgdk_pixbuf-2.0.so.0 => /usr/local/lib/libgdk_pixbuf-2.0.so.0 (0x800c4f000)        libgtk-x11-2.0.so.0 => /usr/local/lib/libgtk-x11-2.0.so.0 (0x800c73000)        libgobject-2.0.so.0 => /usr/local/lib/libgobject-2.0.so.0 (0x8010a7000)        libglib-2.0.so.0 => /usr/local/lib/libglib-2.0.so.0 (0x8010f7000)        libgthread-2.0.so.0 => /usr/local/lib/libgthread-2.0.so.0 (0x80120a000)        libgmodule-2.0.so.0 => /usr/local/lib/libgmodule-2.0.so.0 (0x80120c000)        libpango-1.0.so.0 => /usr/local/lib/libpango-1.0.so.0 (0x801210000)        libcairo.so.2 => /usr/local/lib/libcairo.so.2 (0x801257000)        libatk-1.0.so.0 => /usr/local/lib/libatk-1.0.so.0 (0x801381000)        libc.so.8 => /lib/libc.so.8 (0x8013b0000)        libpangocairo-1.0.so.0 => /usr/local/lib/libpangocairo-1.0.so.0 (0x80150f000)        libgio-2.0.so.0 => /usr/local/lib/libgio-2.0.so.0 (0x80151c000)        libfontconfig.so.1 => /usr/local/lib/libfontconfig.so.1 (0x8016b1000)        libfreetype.so.6 => /usr/local/lib/libfreetype.so.6 (0x8016f4000)        libXrender.so.1 => /usr/local/lib/libXrender.so.1 (0x80179b000)        libXinerama.so.1 => /usr/local/lib/libXinerama.so.1 (0x8017a5000)        libXi.so.6 => /usr/local/lib/libXi.so.6 (0x8017a8000)        libXrandr.so.2 => /usr/local/lib/libXrandr.so.2 (0x8017b8000)        libXcursor.so.1 => /usr/local/lib/libXcursor.so.1 (0x8017c3000)        libXcomposite.so.1 => /usr/local/lib/libXcomposite.so.1 (0x8017cd000)        libXdamage.so.1 => /usr/local/lib/libXdamage.so.1 (0x8017d0000)        libXfixes.so.3 => /usr/local/lib/libXfixes.so.3 (0x8017d3000)        libintl.so.8 => /usr/local/lib/libintl.so.8 (0x8017d9000)        libXext.so.6 => /usr/local/lib/libXext.so.6 (0x8017e3000)        libm.so.4 => /lib/libm.so.4 (0x8017f5000)        libxcb.so.1 => /usr/local/lib/libxcb.so.1 (0x801820000)        libpangoft2-1.0.so.0 => /usr/local/lib/libpangoft2-1.0.so.0 (0x801845000)        libiconv.so.2 => /usr/local/lib/libiconv.so.2 (0x80185a000)        libpcre.so.1 => /usr/local/lib/libpcre.so.1 (0x801956000)        libffi.so.6 => /usr/local/lib/libffi.so.6 (0x8019cf000)        libfribidi.so.0 => /usr/local/lib/libfribidi.so.0 (0x8019d4000)        libpixman-1.so.0 => /usr/local/lib/libpixman-1.so.0 (0x8019ea000)        libEGL.so.1 => /usr/local/lib/libEGL.so.1 (0x801a8d000)        libpng16.so.16 => /usr/local/lib/libpng16.so.16 (0x801b08000)        libxcb-shm.so.0 => /usr/local/lib/libxcb-shm.so.0 (0x801b3d000)        libxcb-render.so.0 => /usr/local/lib/libxcb-render.so.0 (0x801b40000)        libz.so.3 => /lib/libz.so.3 (0x801b4c000)        libGL.so.1 => /usr/local/lib/libGL.so.1 (0x801b61000)        libexpat.so.1 => /usr/local/lib/libexpat.so.1 (0x801c2b000)        libbz2.so.2 => /usr/lib/libbz2.so.2 (0x801c64000)        libXau.so.6 => /usr/local/lib/libXau.so.6 (0x801c75000)        libXdmcp.so.6 => /usr/local/lib/libXdmcp.so.6 (0x801c78000)        libharfbuzz.so.0 => /usr/local/lib/libharfbuzz.so.0 (0x801c7e000)        libxcb-dri2.so.0 => /usr/local/lib/libxcb-dri2.so.0 (0x801d78000)        libX11-xcb.so.1 => /usr/local/lib/libX11-xcb.so.1 (0x801d7c000)        libxcb-dri3.so.0 => /usr/local/lib/libxcb-dri3.so.0 (0x801d7e000)        libxcb-xfixes.so.0 => /usr/local/lib/libxcb-xfixes.so.0 (0x801d82000)        libxcb-present.so.0 => /usr/local/lib/libxcb-present.so.0 (0x801d89000)        libxcb-sync.so.1 => /usr/local/lib/libxcb-sync.so.1 (0x801d8c000)        libxshmfence.so.1 => /usr/local/lib/libxshmfence.so.1 (0x801d92000)        libwayland-client.so.0 => /usr/local/lib/libwayland-client.so.0 (0x801d95000)        libgbm.so.1 => /usr/local/lib/libgbm.so.1 (0x801da4000)        libwayland-server.so.0 => /usr/local/lib/libwayland-server.so.0 (0x801df3000)        libdrm.so.2 => /usr/local/lib/libdrm.so.2 (0x801e0f000)        libglapi.so.0 => /usr/local/lib/libglapi.so.0 (0x801e1e000)        libxcb-glx.so.0 => /usr/local/lib/libxcb-glx.so.0 (0x801e77000)        libXxf86vm.so.1 => /usr/local/lib/libXxf86vm.so.1 (0x801e8f000)        libgraphite2.so.3 => /usr/local/lib/libgraphite2.so.3 (0x801e94000)        librt.so.0 => /usr/lib/librt.so.0 (0x801ec6000)        libstdc++.so.9 => /usr/lib/gcc80/libstdc++.so.9 (0x801ec9000)
You see how much library this simple app has linked with. If it's a statically linked version, it should be 100 mb in size or so!

guest64953:
Lazarus's binary size after rebuilt with anchordocking and spartadockedformeditor also insane. It's 311.1 mb or so.

Here is the result of ldd on it, this binary is also a dynamic linked binary:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---$ ldd .lazarus/bin/lazarus.lazarus/bin/lazarus:        libpthread.so.0 => /usr/lib/libpthread.so.0 (0x801ae3000)        libgdk-x11-2.0.so.0 => /usr/local/lib/libgdk-x11-2.0.so.0 (0x801afd000)        libX11.so.6 => /usr/local/lib/libX11.so.6 (0x801baf000)        libgdk_pixbuf-2.0.so.0 => /usr/local/lib/libgdk_pixbuf-2.0.so.0 (0x801cea000)        libgtk-x11-2.0.so.0 => /usr/local/lib/libgtk-x11-2.0.so.0 (0x801d0e000)        libgobject-2.0.so.0 => /usr/local/lib/libgobject-2.0.so.0 (0x802142000)        libglib-2.0.so.0 => /usr/local/lib/libglib-2.0.so.0 (0x802192000)        libgthread-2.0.so.0 => /usr/local/lib/libgthread-2.0.so.0 (0x8022a5000)        libgmodule-2.0.so.0 => /usr/local/lib/libgmodule-2.0.so.0 (0x8022a7000)        libpango-1.0.so.0 => /usr/local/lib/libpango-1.0.so.0 (0x8022ab000)        libcairo.so.2 => /usr/local/lib/libcairo.so.2 (0x8022f2000)        libatk-1.0.so.0 => /usr/local/lib/libatk-1.0.so.0 (0x80241c000)        libpangocairo-1.0.so.0 => /usr/local/lib/libpangocairo-1.0.so.0 (0x80244b000)        libc.so.8 => /lib/libc.so.8 (0x802458000)        libgio-2.0.so.0 => /usr/local/lib/libgio-2.0.so.0 (0x8025b7000)        libfontconfig.so.1 => /usr/local/lib/libfontconfig.so.1 (0x80274c000)        libfreetype.so.6 => /usr/local/lib/libfreetype.so.6 (0x80278f000)        libXrender.so.1 => /usr/local/lib/libXrender.so.1 (0x802836000)        libXinerama.so.1 => /usr/local/lib/libXinerama.so.1 (0x802840000)        libXi.so.6 => /usr/local/lib/libXi.so.6 (0x802843000)        libXrandr.so.2 => /usr/local/lib/libXrandr.so.2 (0x802853000)        libXcursor.so.1 => /usr/local/lib/libXcursor.so.1 (0x80285e000)        libXcomposite.so.1 => /usr/local/lib/libXcomposite.so.1 (0x802868000)        libXdamage.so.1 => /usr/local/lib/libXdamage.so.1 (0x80286b000)        libXfixes.so.3 => /usr/local/lib/libXfixes.so.3 (0x80286e000)        libintl.so.8 => /usr/local/lib/libintl.so.8 (0x802874000)        libXext.so.6 => /usr/local/lib/libXext.so.6 (0x80287e000)        libm.so.4 => /lib/libm.so.4 (0x802890000)        libxcb.so.1 => /usr/local/lib/libxcb.so.1 (0x8028bb000)        libpangoft2-1.0.so.0 => /usr/local/lib/libpangoft2-1.0.so.0 (0x8028e0000)        libiconv.so.2 => /usr/local/lib/libiconv.so.2 (0x8028f5000)        libpcre.so.1 => /usr/local/lib/libpcre.so.1 (0x8029f1000)        libffi.so.6 => /usr/local/lib/libffi.so.6 (0x802a6a000)        libfribidi.so.0 => /usr/local/lib/libfribidi.so.0 (0x802a6f000)        libpixman-1.so.0 => /usr/local/lib/libpixman-1.so.0 (0x802a85000)        libEGL.so.1 => /usr/local/lib/libEGL.so.1 (0x802b28000)        libpng16.so.16 => /usr/local/lib/libpng16.so.16 (0x802ba3000)        libxcb-shm.so.0 => /usr/local/lib/libxcb-shm.so.0 (0x802bd8000)        libxcb-render.so.0 => /usr/local/lib/libxcb-render.so.0 (0x802bdb000)        libz.so.3 => /lib/libz.so.3 (0x802be7000)        libGL.so.1 => /usr/local/lib/libGL.so.1 (0x802bfc000)        libexpat.so.1 => /usr/local/lib/libexpat.so.1 (0x802cc6000)        libbz2.so.2 => /usr/lib/libbz2.so.2 (0x802cff000)        libXau.so.6 => /usr/local/lib/libXau.so.6 (0x802d10000)        libXdmcp.so.6 => /usr/local/lib/libXdmcp.so.6 (0x802d13000)        libharfbuzz.so.0 => /usr/local/lib/libharfbuzz.so.0 (0x802d19000)        libxcb-dri2.so.0 => /usr/local/lib/libxcb-dri2.so.0 (0x802e13000)        libX11-xcb.so.1 => /usr/local/lib/libX11-xcb.so.1 (0x802e17000)        libxcb-dri3.so.0 => /usr/local/lib/libxcb-dri3.so.0 (0x802e19000)        libxcb-xfixes.so.0 => /usr/local/lib/libxcb-xfixes.so.0 (0x802e1d000)        libxcb-present.so.0 => /usr/local/lib/libxcb-present.so.0 (0x802e24000)        libxcb-sync.so.1 => /usr/local/lib/libxcb-sync.so.1 (0x802e27000)        libxshmfence.so.1 => /usr/local/lib/libxshmfence.so.1 (0x802e2d000)        libwayland-client.so.0 => /usr/local/lib/libwayland-client.so.0 (0x802e30000)        libgbm.so.1 => /usr/local/lib/libgbm.so.1 (0x802e3f000)        libwayland-server.so.0 => /usr/local/lib/libwayland-server.so.0 (0x802e8e000)        libdrm.so.2 => /usr/local/lib/libdrm.so.2 (0x802eaa000)        libglapi.so.0 => /usr/local/lib/libglapi.so.0 (0x802eb9000)        libxcb-glx.so.0 => /usr/local/lib/libxcb-glx.so.0 (0x802f12000)        libXxf86vm.so.1 => /usr/local/lib/libXxf86vm.so.1 (0x802f2a000)        libgraphite2.so.3 => /usr/local/lib/libgraphite2.so.3 (0x802f2f000)        librt.so.0 => /usr/lib/librt.so.0 (0x802f61000)        libstdc++.so.9 => /usr/lib/gcc80/libstdc++.so.9 (0x802f64000)

marcov:
The FreeBSD (current version) and DragonFly (FreeBSD4 reborn) ports are nearly the same. If there are humongous difference in binary size, the most likely culprit is a defective linker.

Try to install a proper linker on DFly.

Note that dfly is only a (somewhat) official target in FPC3.2+, not in the current release (which is STILL 3.0.4)

guest64953:

--- Quote from: marcov on December 06, 2019, 05:57:36 pm ---The FreeBSD (current version) and DragonFly (FreeBSD4 reborn) ports are nearly the same. If there are humongous difference in binary size, the most likely culprit is a defective linker.

Try to install a proper linker on DFly.

Note that dfly is only a (somewhat) official target in FPC3.2+, not in the current release (which is STILL 3.0.4)

--- End quote ---

This binary was built with FPC 3.0.4 and Lazarus 2.0.2 installed from pkg on DFBSD. I have never possible to get fpcupdeluxe correctly build FPC + Lazarus for me on DFBSD. I always choose to build trunk versions of both FPC + Lazarus but always failed with missing unit lnet.

You could search Dports to see that they really patched FPC to correctly select the ld.bfd linker. But I think the patches are never upstreamed, as the bootstrap FPC on fpcupdeluxe always default to the gold linker even though ld.bfd also available. I don't know if this is the fault of FPC or fpcupdeluxe, though  >:(

guest64953:
/usr/local/bin/lazarus is just a shell script. Lazarus is actually located at /usr/local/share/lazarus-2.0.4

The binaries are not big (the lazarus binary is just 30.9 mb), but they are already stripped.

I run ldd on them, it's the same as the above results. It seemed the Lazarus package on DFBSD was built this way, as dynamic binary which linked nearly everything, including libstdc++. It could be a faulty linker as marcov said. Anyway, it's the port maintainer's fault, not the fault of Lazarus and FPC devs, but please fix the missing unit lnet issue when building FPC with fpcupdeluxe, so I could test the latest trunk versions of both Lazarus + FPC on this OS the easier way, thanks.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---ldd /usr/local/share/lazarus-2.0.4/lazarus/usr/local/share/lazarus-2.0.4/lazarus:        libpthread.so.0 => /usr/lib/libpthread.so.0 (0x801a77000)        libgdk-x11-2.0.so.0 => /usr/local/lib/libgdk-x11-2.0.so.0 (0x801a91000)        libX11.so.6 => /usr/local/lib/libX11.so.6 (0x801b43000)        libgdk_pixbuf-2.0.so.0 => /usr/local/lib/libgdk_pixbuf-2.0.so.0 (0x801c7e000)        libgtk-x11-2.0.so.0 => /usr/local/lib/libgtk-x11-2.0.so.0 (0x801ca2000)        libgobject-2.0.so.0 => /usr/local/lib/libgobject-2.0.so.0 (0x8020d6000)        libglib-2.0.so.0 => /usr/local/lib/libglib-2.0.so.0 (0x802126000)        libgthread-2.0.so.0 => /usr/local/lib/libgthread-2.0.so.0 (0x802239000)        libgmodule-2.0.so.0 => /usr/local/lib/libgmodule-2.0.so.0 (0x80223b000)        libpango-1.0.so.0 => /usr/local/lib/libpango-1.0.so.0 (0x80223f000)        libcairo.so.2 => /usr/local/lib/libcairo.so.2 (0x802286000)        libatk-1.0.so.0 => /usr/local/lib/libatk-1.0.so.0 (0x8023b0000)        libpangocairo-1.0.so.0 => /usr/local/lib/libpangocairo-1.0.so.0 (0x8023df000)        libc.so.8 => /lib/libc.so.8 (0x8023ec000)        libgio-2.0.so.0 => /usr/local/lib/libgio-2.0.so.0 (0x80254b000)        libfontconfig.so.1 => /usr/local/lib/libfontconfig.so.1 (0x8026e0000)        libfreetype.so.6 => /usr/local/lib/libfreetype.so.6 (0x802723000)        libXrender.so.1 => /usr/local/lib/libXrender.so.1 (0x8027ca000)        libXinerama.so.1 => /usr/local/lib/libXinerama.so.1 (0x8027d4000)        libXi.so.6 => /usr/local/lib/libXi.so.6 (0x8027d7000)        libXrandr.so.2 => /usr/local/lib/libXrandr.so.2 (0x8027e7000)        libXcursor.so.1 => /usr/local/lib/libXcursor.so.1 (0x8027f2000)        libXcomposite.so.1 => /usr/local/lib/libXcomposite.so.1 (0x8027fc000)        libXdamage.so.1 => /usr/local/lib/libXdamage.so.1 (0x8027ff000)        libXfixes.so.3 => /usr/local/lib/libXfixes.so.3 (0x802802000)        libintl.so.8 => /usr/local/lib/libintl.so.8 (0x802808000)        libXext.so.6 => /usr/local/lib/libXext.so.6 (0x802812000)        libm.so.4 => /lib/libm.so.4 (0x802824000)        libxcb.so.1 => /usr/local/lib/libxcb.so.1 (0x80284f000)        libpangoft2-1.0.so.0 => /usr/local/lib/libpangoft2-1.0.so.0 (0x802874000)        libiconv.so.2 => /usr/local/lib/libiconv.so.2 (0x802889000)        libpcre.so.1 => /usr/local/lib/libpcre.so.1 (0x802985000)        libffi.so.6 => /usr/local/lib/libffi.so.6 (0x8029fe000)        libfribidi.so.0 => /usr/local/lib/libfribidi.so.0 (0x802a03000)        libpixman-1.so.0 => /usr/local/lib/libpixman-1.so.0 (0x802a19000)        libEGL.so.1 => /usr/local/lib/libEGL.so.1 (0x802abc000)        libpng16.so.16 => /usr/local/lib/libpng16.so.16 (0x802b37000)        libxcb-shm.so.0 => /usr/local/lib/libxcb-shm.so.0 (0x802b6c000)        libxcb-render.so.0 => /usr/local/lib/libxcb-render.so.0 (0x802b6f000)        libz.so.3 => /lib/libz.so.3 (0x802b7b000)        libGL.so.1 => /usr/local/lib/libGL.so.1 (0x802b90000)        libexpat.so.1 => /usr/local/lib/libexpat.so.1 (0x802c5a000)        libbz2.so.2 => /usr/lib/libbz2.so.2 (0x802c93000)        libXau.so.6 => /usr/local/lib/libXau.so.6 (0x802ca4000)        libXdmcp.so.6 => /usr/local/lib/libXdmcp.so.6 (0x802ca7000)        libharfbuzz.so.0 => /usr/local/lib/libharfbuzz.so.0 (0x802cad000)        libxcb-dri2.so.0 => /usr/local/lib/libxcb-dri2.so.0 (0x802da7000)        libX11-xcb.so.1 => /usr/local/lib/libX11-xcb.so.1 (0x802dab000)        libxcb-dri3.so.0 => /usr/local/lib/libxcb-dri3.so.0 (0x802dad000)        libxcb-xfixes.so.0 => /usr/local/lib/libxcb-xfixes.so.0 (0x802db1000)        libxcb-present.so.0 => /usr/local/lib/libxcb-present.so.0 (0x802db8000)        libxcb-sync.so.1 => /usr/local/lib/libxcb-sync.so.1 (0x802dbb000)        libxshmfence.so.1 => /usr/local/lib/libxshmfence.so.1 (0x802dc1000)        libwayland-client.so.0 => /usr/local/lib/libwayland-client.so.0 (0x802dc4000)        libgbm.so.1 => /usr/local/lib/libgbm.so.1 (0x802dd3000)        libwayland-server.so.0 => /usr/local/lib/libwayland-server.so.0 (0x802e22000)        libdrm.so.2 => /usr/local/lib/libdrm.so.2 (0x802e3e000)        libglapi.so.0 => /usr/local/lib/libglapi.so.0 (0x802e4d000)        libxcb-glx.so.0 => /usr/local/lib/libxcb-glx.so.0 (0x802ea6000)        libXxf86vm.so.1 => /usr/local/lib/libXxf86vm.so.1 (0x802ebe000)        libgraphite2.so.3 => /usr/local/lib/libgraphite2.so.3 (0x802ec3000)        librt.so.0 => /usr/lib/librt.so.0 (0x802ef5000)        libstdc++.so.9 => /usr/lib/gcc80/libstdc++.so.9 (0x802ef8000)

Navigation

[0] Message Index

[#] Next page

Go to full version