cifsd-team / ksmbd-tools

ksmbd kernel server userspace utilities
GNU General Public License v2.0
94 stars 27 forks source link

drop depenancy on glib2 possible? #266

Open ptpt52 opened 2 years ago

ptpt52 commented 2 years ago

@namjaejeon for now ksmbd-tools run depends on glib2 could it possible to provide an option to drop glib2?

glib2 is about 1MB size and hard to install into small flash openwrt.

namjaejeon commented 2 years ago

Ah, 1MB of glib2 is stripped binary size ? ksmbd-tools is fully tied with glib2 so that's not easy.

ptpt52 commented 2 years ago

@namjaejeon looking into the ksmbd-tools code, what it use of glib2 is about somewhat basic data-type/struct or list operations I think this could be replace by basic c type and basic c list operations

943K is size of glib2, and it is gzip compressed size

ptpt52 commented 2 years ago

943K is the size on openwrt glib2 could be 1.3M on debian: see https://packages.debian.org/buster/libglib2.0-0

ptpt52 commented 2 years ago

@namjaejeon any update on this ? Please drop glib2 depenancy on glib2, it is a large lib for openwrt.

namjaejeon commented 2 years ago

@ptpt52 It is impossible for now. glib is already used tightly by ksmbd-tools.

namjaejeon commented 2 years ago

@ptpt52 And ksmbd-tools built-in glib has been used in openWRT for a long time. Why is this suddenly a problem?

ptpt52 commented 2 years ago
install -m0600 ./files/ksmbd.config /mnt/Data/Sources/openwrt/x-wrt/build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/ksmbd-tools-3.4.5/ipkg-arm_cortex-a7_neon-vfpv4/ksmbd-server/etc/config/ksmbd
install -m0644 ./files/smb.conf.template /mnt/Data/Sources/openwrt/x-wrt/build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/ksmbd-tools-3.4.5/ipkg-arm_cortex-a7_neon-vfpv4/ksmbd-server/etc/ksmbd/
install -m0755 ./files/ksmbd.init /mnt/Data/Sources/openwrt/x-wrt/build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/ksmbd-tools-3.4.5/ipkg-arm_cortex-a7_neon-vfpv4/ksmbd-server/etc/init.d/ksmbd
# copy examples until we have a wiki page
install -m0644 ./files/ksmbd.config.example /mnt/Data/Sources/openwrt/x-wrt/build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/ksmbd-tools-3.4.5/ipkg-arm_cortex-a7_neon-vfpv4/ksmbd-server/etc/ksmbd/
find /mnt/Data/Sources/openwrt/x-wrt/build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/ksmbd-tools-3.4.5/ipkg-arm_cortex-a7_neon-vfpv4/ksmbd-server -name 'CVS' -o -name '.svn' -o -name '.#*' -o -name '*~'| xargs -r rm -rf
Package ksmbd-server is missing dependencies for the following libraries:
libglib-2.0.so.0
Makefile:140: recipe for target '/mnt/Data/Sources/openwrt/x-wrt/bin/packages/arm_cortex-a7_neon-vfpv4/packages/ksmbd-server_3.4.5-20221003_arm_cortex-a7_neon-vfpv4.ipk' failed
make[2]: *** [/mnt/Data/Sources/openwrt/x-wrt/bin/packages/arm_cortex-a7_neon-vfpv4/packages/ksmbd-server_3.4.5-20221003_arm_cortex-a7_neon-vfpv4.ipk] Error 1
make[2]: Leaving directory '/mnt/Data/Sources/openwrt/openwrt-feeds/packages/net/ksmbd-tools'
time: package/feeds/packages/ksmbd-tools/compile#4.47#0.64#5.06
    ERROR: package/feeds/packages/ksmbd-tools failed to build.
package/Makefile:114: recipe for target 'package/feeds/packages/ksmbd-tools/compile' failed
make[1]: *** [package/feeds/packages/ksmbd-tools/compile] Error 1
make[1]: Leaving directory '/mnt/Data/Sources/openwrt/x-wrt'
/mnt/Data/Sources/openwrt/x-wrt/include/toplevel.mk:229: recipe for target 'package/feeds/packages/ksmbd-tools/compile' failed
make: *** [package/feeds/packages/ksmbd-tools/compile] Error 2
ptpt52 commented 2 years ago

@namjaejeon the openwrt version now is 3.4.5 if update to git HEAD, it build failed, need libglib-2.0.so.0 but I think the glib2 is a huge file for openwrt, it is about 1MB size.

for version 3.4.5 glib2 is not needed.

ptpt52 commented 2 years ago

the glib2_2.74.0-2_arm_cortex-a7_neon-vfpv4.ipk package is 1.1M size. this is really large for small flash device of openwrt.

According to my observation, you only use a few C API functions in glib2, but these functions can be replaced by standard C lib, especially some data structures and functions We don't have to import a huge redundant glib2 library in order to call an unneeded glib2

namjaejeon commented 2 years ago

for version 3.4.5 glib2 is not needed.

I can not understand this. ksmbd-tools 3.4.5 need glib2.0. @neheb Is it true that openWRT has this issue ?

neheb commented 2 years ago

glib2 is linked statically with LTO. Size is 55KB: https://downloads.openwrt.org/snapshots/packages/mips_24kc/packages/

Why are you linking to the shared library?

ptpt52 commented 2 years ago

glib2 is linked statically with LTO. Size is 55KB: https://downloads.openwrt.org/snapshots/packages/mips_24kc/packages/

Why are you linking to the shared library?

but how to patch it to link statically?

neheb commented 2 years ago

https://github.com/openwrt/packages/blob/master/net/ksmbd-tools/patches/010-meson.patch#L99

neheb commented 2 years ago

oh I see what you're doing. updating to HEAD and getting rid of that patch. it has a silent addition to link glib2 statically.

ptpt52 commented 2 years ago

ok, let me try it out.