Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question About Compiling to 64KB #262

Closed
liusuchao opened this issue Aug 13, 2024 · 3 comments
Closed

Question About Compiling to 64KB #262

liusuchao opened this issue Aug 13, 2024 · 3 comments

Comments

@liusuchao
Copy link

liusuchao commented Aug 13, 2024

Hello,

First of all, thank you for creating such a wonderful library that greatly simplifies our application development. It's fantastic!

I have a question regarding the GitHub homepage, which mentions compiling down to 64KB. I'm only able to achieve a compilation size of 180KB. Could you please help me understand how to compile it to 64KB?

Here are my compilation environment details:

Linux 7737b1369220 6.6.32-linuxkit #1 SMP Thu Jun 13 14:13:01 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux
tbox version 8ada0ab7f7eb98fa5eb4928b61b7701b0126a721

Here are the commands I used for compilation:

cd ${RE_LIB_PACKAGES_DIR}/tbox
xmake  f -p linux --micro=y --demo=n --small=y --info=n --force-utf8=n --xml=n --sqlite3=n --openssl=n --polarssl=n --mode=release --mysql=n  --exception=n --cc=${ZZ_CROSS_COMPILER_CC} --cflags="-Os " 
xmake 

xmake install -o ${RE_LIB_ROOTFS_DIR}

Here are the logs printed during compilation:

checking for architecture ... arm64
checking for wchar ... no
checking for libc_memcpy ... ok
checking for libc_strlen ... ok
checking for libc_strnlen ... no
checking for libc_strstr ... ok
checking for libc_strchr ... ok
checking for libc_strrchr ... ok
checking for libc_strcasestr ... no
checking for libc_strcmp ... ok
checking for libc_strcasecmp ... no
checking for libc_strncmp ... ok
checking for libc_strncasecmp ... no
checking for libc_wcscat ... ok
checking for libc_wcsncat ... ok
checking for libc_wcscpy ... ok
checking for libc_memmem ... no
checking for libc_memmove ... ok
checking for libc_memset ... ok
checking for libc_memcmp ... ok
checking for libc_strcat ... ok
checking for libc_strlcpy ... no
checking for libc_strcpy ... ok
checking for libc_strncat ... ok
checking for libc_strncpy ... ok
checking for libc_wcsncpy ... ok
checking for libc_wcslen ... ok
checking for libc_wcslcpy ... no
checking for libc_wcsnlen ... no
checking for libc_wcsstr ... ok
checking for libc_wcscmp ... ok
checking for libc_wcscasestr ... no
checking for libc_wcscasecmp ... no
checking for libc_wcsncmp ... ok
checking for libc_wcsncasecmp ... no
checking for libc_wcstombs ... ok
checking for libc_mbstowcs ... ok
checking for libc_gmtime ... ok
checking for libc_mktime ... ok
checking for libc_localtime ... ok
checking for libc_gettimeofday ... ok
checking for libc_signal ... ok
checking for libc_setjmp ... ok
checking for libc_kill ... no
checking for libc_sigsetjmp ... no
checking for libc_backtrace ... ok
checking for libc_setlocale ... ok
checking for libc_fputs ... ok
checking for libc_fgets ... ok
checking for libc_ungetc ... ok
checking for libc_fgetc ... ok
checking for libc_fputc ... ok
checking for libc_fread ... ok
checking for libc_srandom ... no
checking for libc_random ... no
checking for libc_fwrite ... ok
checking for libm_sincos ... no
checking for libm_sincosf ... no
checking for libm_log2 ... ok
checking for libm_sqrt ... ok
checking for libm_log2f ... ok
checking for libm_sqrtf ... ok
checking for libm_acos ... ok
checking for libm_acosf ... ok
checking for libm_asin ... ok
checking for libm_asinf ... ok
checking for libm_pow ... ok
checking for libm_powf ... ok
checking for libm_fmod ... ok
checking for libm_fmodf ... ok
checking for libm_tanf ... ok
checking for libm_tan ... ok
checking for libm_atan ... ok
checking for libm_atanf ... ok
checking for libm_atan2 ... ok
checking for libm_atan2f ... ok
checking for libm_cos ... ok
checking for libm_cosf ... ok
checking for libm_sin ... ok
checking for libm_sinf ... ok
checking for libm_exp ... ok
checking for libm_expf ... ok
checking for posix_select ... ok
checking for posix_poll ... ok
checking for posix_pthread_mutex_init ... ok
checking for posix_pthread_create ... ok
checking for posix_pthread_setspecific ... ok
checking for posix_pthread_getspecific ... ok
checking for posix_pthread_key_create ... ok
checking for posix_pthread_key_delete ... ok
checking for posix_pthread_setaffinity_np ... no
checking for posix_opendir ... ok
checking for posix_socket ... ok
checking for posix_dlopen ... ok
checking for posix_open ... ok
checking for posix_stat64 ... no
checking for posix_gethostname ... no
checking for posix_lstat64 ... no
checking for posix_sysconf ... ok
checking for posix_getifaddrs ... no
checking for posix_getpagesize ... no
checking for posix_sched_setaffinity ... no
checking for posix_regcomp ... ok
checking for posix_readv ... ok
checking for posix_sched_yield ... ok
checking for posix_regexec ... ok
checking for posix_writev ... ok
checking for posix_preadv ... no
checking for posix_pwritev ... no
checking for posix_pread64 ... no
checking for posix_copyfile ... no
checking for posix_pwrite64 ... no
checking for posix_fdatasync ... no
checking for posix_sendfile ... ok
checking for posix_epoll_wait ... ok
checking for posix_execvpe ... no
checking for posix_epoll_create ... ok
checking for posix_execvp ... ok
checking for posix_vfork ... no
checking for posix_waitpid ... ok
checking for posix_fork ... ok
checking for posix_getrlimit ... ok
checking for posix_getdtablesize ... no
checking for posix_getaddrinfo ... no
checking for posix_fcntl ... ok
checking for posix_mkfifo ... ok
checking for posix_pipe ... ok
checking for posix_pipe2 ... no
checking for posix_futimens ... no
checking for posix_getnameinfo ... no
checking for posix_mmap ... ok
checking for posix_gethostbyname ... ok
checking for posix_gethostbyaddr ... ok
checking for posix_utimensat ... no
checking for valgrind_VALGRIND_STACK_REGISTER ... no
checking for posix_posix_spawnp ... ok
checking for posix_sem_init ... ok
checking for bsd_flock ... ok
checking for posix_posix_spawn_file_actions_addchdir_np ... no
checking for systemv_semget ... ok
checking for linux_inotify_init ... ok
checking for systemv_semtimedop ... no
checking for feature_anonymous_union ... no
checking for keyword_thread_local ... ok
checking for keyword_thread ... ok
checking for linux_ifaddrs ... ok
generating src/tbox/tbox.config.h.in ... ok
[  3%]: cache compiling.release src/tbox/tbox.c
[  4%]: cache compiling.release src/tbox/libc/string/memset.c
[  6%]: cache compiling.release src/tbox/libc/string/memmov.c
[  8%]: cache compiling.release src/tbox/libc/string/memcpy.c
[  9%]: cache compiling.release src/tbox/libc/string/memcmp.c
[ 11%]: cache compiling.release src/tbox/libc/string/strstr.c
[ 12%]: cache compiling.release src/tbox/libc/string/strdup.c
[ 14%]: cache compiling.release src/tbox/libc/string/strlen.c
[ 16%]: cache compiling.release src/tbox/libc/string/strnlen.c
[ 17%]: cache compiling.release src/tbox/libc/string/strcmp.c
[ 19%]: cache compiling.release src/tbox/libc/string/strncmp.c
[ 20%]: cache compiling.release src/tbox/libc/string/stricmp.c
[ 22%]: cache compiling.release src/tbox/libc/string/strnicmp.c
[ 24%]: cache compiling.release src/tbox/libc/string/strlcpy.c
[ 25%]: cache compiling.release src/tbox/libc/string/strncpy.c
[ 27%]: cache compiling.release src/tbox/libc/stdio/vsnprintf.c
[ 29%]: cache compiling.release src/tbox/libc/stdio/snprintf.c
[ 30%]: cache compiling.release src/tbox/libc/stdio/printf.c
[ 32%]: cache compiling.release src/tbox/libc/stdlib/stdlib.c
[ 33%]: cache compiling.release src/tbox/libc/impl/libc.c
[ 35%]: cache compiling.release src/tbox/libm/impl/libm.c
[ 37%]: cache compiling.release src/tbox/math/impl/math.c
[ 38%]: cache compiling.release src/tbox/utils/used.c
[ 40%]: cache compiling.release src/tbox/utils/bits.c
[ 41%]: cache compiling.release src/tbox/utils/trace.c
[ 43%]: cache compiling.release src/tbox/utils/singleton.c
[ 45%]: cache compiling.release src/tbox/memory/allocator.c
[ 46%]: cache compiling.release src/tbox/memory/native_allocator.c
[ 48%]: cache compiling.release src/tbox/memory/static_allocator.c
[ 50%]: cache compiling.release src/tbox/memory/fixed_pool.c
[ 51%]: cache compiling.release src/tbox/memory/impl/static_fixed_pool.c
[ 53%]: cache compiling.release src/tbox/memory/impl/static_large_allocator.c
[ 54%]: cache compiling.release src/tbox/memory/impl/memory.c
[ 56%]: cache compiling.release src/tbox/network/ipv4.c
[ 58%]: cache compiling.release src/tbox/network/ipv6.c
[ 59%]: cache compiling.release src/tbox/network/unixaddr.c
[ 61%]: cache compiling.release src/tbox/network/ipaddr.c
[ 62%]: cache compiling.release src/tbox/network/impl/network.c
[ 64%]: cache compiling.release src/tbox/platform/page.c
[ 66%]: cache compiling.release src/tbox/platform/time.c
[ 67%]: cache compiling.release src/tbox/platform/file.c
[ 69%]: cache compiling.release src/tbox/platform/path.c
[ 70%]: cache compiling.release src/tbox/platform/sched.c
[ 72%]: cache compiling.release src/tbox/platform/print.c
[ 74%]: cache compiling.release src/tbox/platform/thread.c
[ 75%]: cache compiling.release src/tbox/platform/socket.c
[ 77%]: cache compiling.release src/tbox/platform/addrinfo.c
[ 79%]: cache compiling.release src/tbox/platform/poller.c
[ 80%]: cache compiling.release src/tbox/platform/mutex.c
[ 82%]: cache compiling.release src/tbox/platform/semaphore.c
[ 83%]: cache compiling.release src/tbox/platform/native_memory.c
[ 85%]: cache compiling.release src/tbox/platform/impl/platform.c
[ 87%]: cache compiling.release src/tbox/platform/impl/pollerdata.c
[ 88%]: cache compiling.release src/tbox/container/iterator.c
[ 90%]: cache compiling.release src/tbox/container/list_entry.c
[ 91%]: cache compiling.release src/tbox/container/single_list_entry.c
[ 93%]: cache compiling.release src/tbox/container/array_iterator.c
[ 95%]: cache compiling.release src/tbox/algorithm/binary_find.c
[ 96%]: cache compiling.release src/tbox/algorithm/binary_find_if.c
[ 98%]: archiving.release libtbox.a
[100%]: build ok, spent 1.403s
installing tbox ..
installing tbox to /home/user/data/re_lib/arch/aarch64/rootfs ..
install ok!
user@7737b1369220:~/data/re_lib/arch/aarch64/packages/tbox$ ls ./build/linux/arm64/release/libtbox.a -lh
-rw-r--r-- 1 user user 180K Aug 13 15:31 ./build/linux/arm64/release/libtbox.a`

Thank you!

@waruqi
Copy link
Member

waruqi commented Aug 14, 2024

不是说的库本身大小,是实际 link 后的可执行文件大小。

-rwxr-xr-x  1 ruki  staff  67344  8 14 09:19 build/macosx/x86_64/release/demo

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


It does not mean the size of the library itself, but the actual size of the executable file after linking.

-rwxr-xr-x 1 ruki staff 67344 8 14 09:19 build/macosx/x86_64/release/demo

@liusuchao
Copy link
Author

Thank you very much for your reply. Very well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants