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

build: enable compiling fluentd-bit static binary #2558

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sztanyoo
Copy link

@sztanyoo sztanyoo commented Sep 16, 2020

Enable compiling fluentd-bit static binary by using -DFLB_STATIC_BINARY cmake option

CMakeLists.txt extended with a new option FLB_STATIC_BINARY. This adds link-time compiler switches to have a statically linked binary.

Example use:

cmake -DFLB_OUT_AZURE=Off -DFLB_OUT_AZURE_BLOB=Off -DFLB_STATIC_BINARY=On -DFLB_BACKTRACE=Off -DFLB_EXAMPLES=Off -DFLB_LUAJIT=Off -DFLB_SQLDB=Off ../
make fluent-bit-bin -j8

Fixes #2561

Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • [N/A] Example configuration file for the change
  • Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found

Documentation

  • Documentation required for this feature

I need guidance where to put the following extension to the documentation:

FLB_STATIC_BINARY

This can be useful when fluentd-bit is running on a limited-access host missing the latest libraries.

*Note*: The following options are not compatible when using FLB_STATIC_BINARY:
- FLB_BACKTRACE
- FLB_EXAMPLES
- FLB_LUAJIT
- FLB_SQLDB

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

@sztanyoo
Copy link
Author

$ ldd bin/fluent-bit
	not a dynamic executable

$ bin/fluent-bit -vvv -i cpu -o stdout -f 1  
Fluent Bit v1.6.0
* Copyright (C) 2019-2020 The Fluent Bit Authors
* Copyright (C) 2015-2018 Treasure Data
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io

[2020/09/17 21:21:17] [ info] Configuration:
[2020/09/17 21:21:17] [ info]  flush time     | 1.000000 seconds
[2020/09/17 21:21:17] [ info]  grace          | 5 seconds
[2020/09/17 21:21:17] [ info]  daemon         | 0
[2020/09/17 21:21:17] [ info] ___________
[2020/09/17 21:21:17] [ info]  inputs:
[2020/09/17 21:21:17] [ info]      cpu
[2020/09/17 21:21:17] [ info] ___________
[2020/09/17 21:21:17] [ info]  filters:
[2020/09/17 21:21:17] [ info] ___________
[2020/09/17 21:21:17] [ info]  outputs:
[2020/09/17 21:21:17] [ info]      stdout.0
[2020/09/17 21:21:17] [ info] ___________
[2020/09/17 21:21:17] [ info]  collectors:
[2020/09/17 21:21:17] [ info] [engine] started (pid=420597)
[2020/09/17 21:21:17] [debug] [engine] coroutine stack size: 24576 bytes (24.0K)
[2020/09/17 21:21:17] [debug] [storage] [cio stream] new stream registered: cpu.0
[2020/09/17 21:21:17] [ info] [storage] version=1.0.5, initializing...
[2020/09/17 21:21:17] [ info] [storage] in-memory
[2020/09/17 21:21:17] [ info] [storage] normal synchronization mode, checksum disabled, max_chunks_up=128
[2020/09/17 21:21:17] [debug] [router] default match rule cpu.0:stdout.0
[2020/09/17 21:21:17] [ info] [sp] stream processor started
[2020/09/17 21:21:18] [trace] [input:cpu:cpu.0 at plugins/in_cpu/cpu.c:413] CPU 3.12%
[0] cpu.0: [1600370478.407943279, {"cpu_p"=>3.125000, "user_p"=>2.375000, "system_p"=>0.750000, "cpu0.p_cpu"=>2.000000, "cpu0.p_user"=>2.000000, "cpu0.p_system"=>0.000000, "cpu1.p_cpu"=>4.000000, "cpu1.p_user"=>2.000000, "cpu1.p_system"=>2.000000, "cpu2.p_cpu"=>4.000000, "cpu2.p_user"=>2.000000, "cpu2.p_system"=>2.000000, "cpu3.p_cpu"=>3.000000, "cpu3.p_user"=>2.000000, "cpu3.p_system"=>1.000000, "cpu4.p_cpu"=>2.000000, "cpu4.p_user"=>2.000000, "cpu4.p_system"=>0.000000, "cpu5.p_cpu"=>1.000000, "cpu5.p_user"=>1.000000, "cpu5.p_system"=>0.000000, "cpu6.p_cpu"=>4.000000, "cpu6.p_user"=>3.000000, "cpu6.p_system"=>1.000000, "cpu7.p_cpu"=>3.000000, "cpu7.p_user"=>3.000000, "cpu7.p_system"=>0.000000}]
[2020/09/17 21:21:19] [debug] [task] created task=0x2263af0 id=0 OK
[2020/09/17 21:21:19] [trace] [input:cpu:cpu.0 at plugins/in_cpu/cpu.c:413] CPU 4.38%
[2020/09/17 21:21:19] [debug] [task] destroy task=0x2263af0 (task_id=0)
[0] cpu.0: [1600370479.408258387, {"cpu_p"=>4.375000, "user_p"=>3.250000, "system_p"=>1.125000, "cpu0.p_cpu"=>4.000000, "cpu0.p_user"=>2.000000, "cpu0.p_system"=>2.000000, "cpu1.p_cpu"=>4.000000, "cpu1.p_user"=>3.000000, "cpu1.p_system"=>1.000000, "cpu2.p_cpu"=>1.000000, "cpu2.p_user"=>1.000000, "cpu2.p_system"=>0.000000, "cpu3.p_cpu"=>11.000000, "cpu3.p_user"=>10.000000, "cpu3.p_system"=>1.000000, "cpu4.p_cpu"=>4.000000, "cpu4.p_user"=>3.000000, "cpu4.p_system"=>1.000000, "cpu5.p_cpu"=>3.000000, "cpu5.p_user"=>2.000000, "cpu5.p_system"=>1.000000, "cpu6.p_cpu"=>2.000000, "cpu6.p_user"=>1.000000, "cpu6.p_system"=>1.000000, "cpu7.p_cpu"=>5.000000, "cpu7.p_user"=>4.000000, "cpu7.p_system"=>1.000000}]
[2020/09/17 21:21:20] [debug] [task] created task=0x2264220 id=0 OK
[2020/09/17 21:21:20] [trace] [input:cpu:cpu.0 at plugins/in_cpu/cpu.c:413] CPU 5.88%
[2020/09/17 21:21:20] [debug] [task] destroy task=0x2264220 (task_id=0)
[0] cpu.0: [1600370480.408240210, {"cpu_p"=>5.875000, "user_p"=>4.500000, "system_p"=>1.375000, "cpu0.p_cpu"=>5.000000, "cpu0.p_user"=>3.000000, "cpu0.p_system"=>2.000000, "cpu1.p_cpu"=>3.000000, "cpu1.p_user"=>3.000000, "cpu1.p_system"=>0.000000, "cpu2.p_cpu"=>7.000000, "cpu2.p_user"=>4.000000, "cpu2.p_system"=>3.000000, "cpu3.p_cpu"=>7.000000, "cpu3.p_user"=>5.000000, "cpu3.p_system"=>2.000000, "cpu4.p_cpu"=>13.000000, "cpu4.p_user"=>11.000000, "cpu4.p_system"=>2.000000, "cpu5.p_cpu"=>5.000000, "cpu5.p_user"=>4.000000, "cpu5.p_system"=>1.000000, "cpu6.p_cpu"=>2.000000, "cpu6.p_user"=>2.000000, "cpu6.p_system"=>0.000000, "cpu7.p_cpu"=>6.000000, "cpu7.p_user"=>4.000000, "cpu7.p_system"=>2.000000}]
[2020/09/17 21:21:21] [debug] [task] created task=0x2264310 id=0 OK
[2020/09/17 21:21:21] [trace] [input:cpu:cpu.0 at plugins/in_cpu/cpu.c:413] CPU 3.12%
[2020/09/17 21:21:21] [debug] [task] destroy task=0x2264310 (task_id=0)
^C[engine] caught signal (SIGINT)
[2020/09/17 21:21:22] [ info] [input] pausing cpu.0

@sztanyoo
Copy link
Author

Implementation breaks valgrind result, some help would be welcomed.

==440837== Memcheck, a memory error detector
==440837== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==440837== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==440837== Command: bin/fluent-bit -vvv -i cpu -o stdout -f 1
==440837== 
==440837== Syscall param set_robust_list(head) points to uninitialised byte(s)
==440837==    at 0x442545: __pthread_initialize_minimal (nptl-init.c:272)
==440837==    by 0x5D87AE: (below main) (in /home/sztanyoo/workspace/fluent-bit/build/bin/fluent-bit)
==440837==  Address 0x4000df0 is in the brk data segment 0x4000000-0x400143f
==440837== 
==440837== Conditional jump or move depends on uninitialised value(s)
==440837==    at 0x60CEF0: __register_atfork (in /home/sztanyoo/workspace/fluent-bit/build/bin/fluent-bit)
==440837==    by 0x60CEBC: __libc_pthread_init (in /home/sztanyoo/workspace/fluent-bit/build/bin/fluent-bit)
==440837==    by 0x442736: __pthread_initialize_minimal (nptl-init.c:368)
==440837==    by 0x5D87AE: (below main) (in /home/sztanyoo/workspace/fluent-bit/build/bin/fluent-bit)
==440837== 
==440837== Conditional jump or move depends on uninitialised value(s)
==440837==    at 0x60CF74: __register_atfork (in /home/sztanyoo/workspace/fluent-bit/build/bin/fluent-bit)
==440837==    by 0x60CEBC: __libc_pthread_init (in /home/sztanyoo/workspace/fluent-bit/build/bin/fluent-bit)
==440837==    by 0x442736: __pthread_initialize_minimal (nptl-init.c:368)
==440837==    by 0x5D87AE: (below main) (in /home/sztanyoo/workspace/fluent-bit/build/bin/fluent-bit)
==440837== Conditional jump or move depends on uninitialised value(s)
==440837==    at 0x60EE6A: _int_free (in /home/sztanyoo/workspace/fluent-bit/build/bin/fluent-bit)
==440837==    by 0x67B0AF: fillin_rpath (in /home/sztanyoo/workspace/fluent-bit/build/bin/fluent-bit)
... <--- truncated --->
==440837== Use of uninitialised value of size 8
==440837==    at 0x60AAF8: _IO_default_finish (in /home/sztanyoo/workspace/fluent-bit/build/bin/fluent-bit)
==440837==    by 0x5FFC30: fclose (in /home/sztanyoo/workspace/fluent-bit/build/bin/fluent-bit)
==440837==    by 0x655456: __tzfile_read (in /home/sztanyoo/workspace/fluent-bit/build/bin/fluent-bit)
==440837==    by 0x653E4C: tzset_internal (in /home/sztanyoo/workspace/fluent-bit/build/bin/fluent-bit)
==440837==    by 0x6547BB: __tz_convert (in /home/sztanyoo/workspace/fluent-bit/build/bin/fluent-bit)
==440837==    by 0x405E7D: flb_log_print (in /home/sztanyoo/workspace/fluent-bit/build/bin/fluent-bit)
==440837==    by 0x414E17: flb_utils_print_setup (in /home/sztanyoo/workspace/fluent-bit/build/bin/fluent-bit)
==440837==    by 0x4045B3: flb_main (in /home/sztanyoo/workspace/fluent-bit/build/bin/fluent-bit)
==440837==    by 0x404653: main (in /home/sztanyoo/workspace/fluent-bit/build/bin/fluent-bit)
==440837== 
==440837== 
==440837== More than 1000 different errors detected.  I'm not reporting any more.
==440837== Final error counts will be inaccurate.  Go fix your program!
==440837== Rerun with --error-limit=no to disable this cutoff.  Note
==440837== that errors may occur in your program without prior warning from
==440837== Valgrind, because errors are no longer being displayed.
==440837== 
[2020/09/17 21:30:35] [ info] Configuration:
[2020/09/17 21:30:35] [ info]  flush time     | 1.000000 seconds
[2020/09/17 21:30:35] [ info]  grace          | 5 seconds
[2020/09/17 21:30:35] [ info]  daemon         | 0
[2020/09/17 21:30:35] [ info] ___________
[2020/09/17 21:30:35] [ info]  inputs:
[2020/09/17 21:30:35] [ info]      cpu
[2020/09/17 21:30:35] [ info] ___________
[2020/09/17 21:30:35] [ info]  filters:
[2020/09/17 21:30:35] [ info] ___________
[2020/09/17 21:30:35] [ info]  outputs:
[2020/09/17 21:30:35] [ info]      stdout.0
[2020/09/17 21:30:35] [ info] ___________
[2020/09/17 21:30:35] [ info]  collectors:
[2020/09/17 21:30:35] [ info] [engine] started (pid=440837)
[2020/09/17 21:30:35] [debug] [engine] coroutine stack size: 24576 bytes (24.0K)
[2020/09/17 21:30:35] [debug] [storage] [cio stream] new stream registered: cpu.0
[2020/09/17 21:30:35] [ info] [storage] version=1.0.5, initializing...
[2020/09/17 21:30:35] [ info] [storage] in-memory
[2020/09/17 21:30:35] [ info] [storage] normal synchronization mode, checksum disabled, max_chunks_up=128
[2020/09/17 21:30:35] [debug] [router] default match rule cpu.0:stdout.0
[2020/09/17 21:30:35] [ info] [sp] stream processor started
[2020/09/17 21:30:35] [trace] [input:cpu:cpu.0 at plugins/in_cpu/cpu.c:413] CPU 7.75%
[0] cpu.0: [1600371035.418205586, {"cpu_p"=>7.750000, "user_p"=>5.000000, "system_p"=>2.750000, "cpu0.p_cpu"=>23.000000, "cpu0.p_user"=>15.000000, "cpu0.p_system"=>8.000000, "cpu1.p_cpu"=>11.000000, "cpu1.p_user"=>6.000000, "cpu1.p_system"=>5.000000, "cpu2.p_cpu"=>6.000000, "cpu2.p_user"=>4.000000, "cpu2.p_system"=>2.000000, "cpu3.p_cpu"=>5.000000, "cpu3.p_user"=>3.000000, "cpu3.p_system"=>2.000000, "cpu4.p_cpu"=>0.000000, "cpu4.p_user"=>0.000000, "cpu4.p_system"=>0.000000, "cpu5.p_cpu"=>4.000000, "cpu5.p_user"=>2.000000, "cpu5.p_system"=>2.000000, "cpu6.p_cpu"=>5.000000, "cpu6.p_user"=>3.000000, "cpu6.p_system"=>2.000000, "cpu7.p_cpu"=>6.000000, "cpu7.p_user"=>5.000000, "cpu7.p_system"=>1.000000}]
[2020/09/17 21:30:36] [debug] [task] created task=0x400f6a0 id=0 OK
[2020/09/17 21:30:36] [trace] [input:cpu:cpu.0 at plugins/in_cpu/cpu.c:413] CPU 31.87%
[2020/09/17 21:30:36] [debug] [task] destroy task=0x400f6a0 (task_id=0)
[0] cpu.0: [1600371036.454557909, {"cpu_p"=>31.875000, "user_p"=>20.750000, "system_p"=>11.125000, "cpu0.p_cpu"=>95.000000, "cpu0.p_user"=>65.000000, "cpu0.p_system"=>30.000000, "cpu1.p_cpu"=>23.000000, "cpu1.p_user"=>15.000000, "cpu1.p_system"=>8.000000, "cpu2.p_cpu"=>24.000000, "cpu2.p_user"=>15.000000, "cpu2.p_system"=>9.000000, "cpu3.p_cpu"=>30.000000, "cpu3.p_user"=>19.000000, "cpu3.p_system"=>11.000000, "cpu4.p_cpu"=>28.000000, "cpu4.p_user"=>15.000000, "cpu4.p_system"=>13.000000, "cpu5.p_cpu"=>22.000000, "cpu5.p_user"=>15.000000, "cpu5.p_system"=>7.000000, "cpu6.p_cpu"=>20.000000, "cpu6.p_user"=>15.000000, "cpu6.p_system"=>5.000000, "cpu7.p_cpu"=>13.000000, "cpu7.p_user"=>9.000000, "cpu7.p_system"=>4.000000}]
[2020/09/17 21:30:37] [debug] [task] created task=0x40109d0 id=0 OK
[2020/09/17 21:30:37] [trace] [input:cpu:cpu.0 at plugins/in_cpu/cpu.c:413] CPU 26.88%
[2020/09/17 21:30:37] [debug] [task] destroy task=0x40109d0 (task_id=0)
[0] cpu.0: [1600371037.410051052, {"cpu_p"=>26.875000, "user_p"=>17.125000, "system_p"=>9.750000, "cpu0.p_cpu"=>25.000000, "cpu0.p_user"=>16.000000, "cpu0.p_system"=>9.000000, "cpu1.p_cpu"=>16.000000, "cpu1.p_user"=>9.000000, "cpu1.p_system"=>7.000000, "cpu2.p_cpu"=>18.000000, "cpu2.p_user"=>10.000000, "cpu2.p_system"=>8.000000, "cpu3.p_cpu"=>13.000000, "cpu3.p_user"=>8.000000, "cpu3.p_system"=>5.000000, "cpu4.p_cpu"=>95.000000, "cpu4.p_user"=>62.000000, "cpu4.p_system"=>33.000000, "cpu5.p_cpu"=>19.000000, "cpu5.p_user"=>15.000000, "cpu5.p_system"=>4.000000, "cpu6.p_cpu"=>15.000000, "cpu6.p_user"=>10.000000, "cpu6.p_system"=>5.000000, "cpu7.p_cpu"=>13.000000, "cpu7.p_user"=>6.000000, "cpu7.p_system"=>7.000000}]
[2020/09/17 21:30:38] [debug] [task] created task=0x4010ac0 id=0 OK
[2020/09/17 21:30:38] [trace] [input:cpu:cpu.0 at plugins/in_cpu/cpu.c:413] CPU 25.00%
[2020/09/17 21:30:38] [debug] [task] destroy task=0x4010ac0 (task_id=0)
[0] cpu.0: [1600371038.409591837, {"cpu_p"=>25.000000, "user_p"=>13.625000, "system_p"=>11.375000, "cpu0.p_cpu"=>21.000000, "cpu0.p_user"=>10.000000, "cpu0.p_system"=>11.000000, "cpu1.p_cpu"=>16.000000, "cpu1.p_user"=>6.000000, "cpu1.p_system"=>10.000000, "cpu2.p_cpu"=>10.000000, "cpu2.p_user"=>5.000000, "cpu2.p_system"=>5.000000, "cpu3.p_cpu"=>15.000000, "cpu3.p_user"=>10.000000, "cpu3.p_system"=>5.000000, "cpu4.p_cpu"=>99.000000, "cpu4.p_user"=>57.000000, "cpu4.p_system"=>42.000000, "cpu5.p_cpu"=>13.000000, "cpu5.p_user"=>5.000000, "cpu5.p_system"=>8.000000, "cpu6.p_cpu"=>12.000000, "cpu6.p_user"=>8.000000, "cpu6.p_system"=>4.000000, "cpu7.p_cpu"=>15.000000, "cpu7.p_user"=>8.000000, "cpu7.p_system"=>7.000000}]
[2020/09/17 21:30:39] [debug] [task] created task=0x4010bb0 id=0 OK
[2020/09/17 21:30:39] [trace] [input:cpu:cpu.0 at plugins/in_cpu/cpu.c:413] CPU 22.75%
[2020/09/17 21:30:39] [debug] [task] destroy task=0x4010bb0 (task_id=0)
[0] cpu.0: [1600371039.409165340, {"cpu_p"=>22.750000, "user_p"=>11.625000, "system_p"=>11.125000, "cpu0.p_cpu"=>20.000000, "cpu0.p_user"=>10.000000, "cpu0.p_system"=>10.000000, "cpu1.p_cpu"=>11.000000, "cpu1.p_user"=>5.000000, "cpu1.p_system"=>6.000000, "cpu2.p_cpu"=>13.000000, "cpu2.p_user"=>5.000000, "cpu2.p_system"=>8.000000, "cpu3.p_cpu"=>15.000000, "cpu3.p_user"=>5.000000, "cpu3.p_system"=>10.000000, "cpu4.p_cpu"=>100.000000, "cpu4.p_user"=>59.000000, "cpu4.p_system"=>41.000000, "cpu5.p_cpu"=>5.000000, "cpu5.p_user"=>1.000000, "cpu5.p_system"=>4.000000, "cpu6.p_cpu"=>10.000000, "cpu6.p_user"=>4.000000, "cpu6.p_system"=>6.000000, "cpu7.p_cpu"=>6.000000, "cpu7.p_user"=>2.000000, "cpu7.p_system"=>4.000000}]
[2020/09/17 21:30:40] [debug] [task] created task=0x4010ca0 id=0 OK
[2020/09/17 21:30:40] [trace] [input:cpu:cpu.0 at plugins/in_cpu/cpu.c:413] CPU 25.37%
[2020/09/17 21:30:40] [debug] [task] destroy task=0x4010ca0 (task_id=0)
[engine] caught signal (SIGINT)
[2020/09/17 21:30:40] [ info] [input] pausing cpu.0
==440837== 
==440837== HEAP SUMMARY:
==440837==     in use at exit: 0 bytes in 0 blocks
==440837==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==440837== 
==440837== All heap blocks were freed -- no leaks are possible
==440837== 
==440837== Use --track-origins=yes to see where uninitialised values come from
==440837== For lists of detected and suppressed errors, rerun with: -s
==440837== ERROR SUMMARY: 21129 errors from 1000 contexts (suppressed: 0 from 0)

@nigels-com
Copy link
Contributor

There some discussion that suggests -static -pthread -Wl,--whole-archive -lpthread -Wl,--no-whole-archive might work.
https://stackoverflow.com/questions/35116327/when-g-static-link-pthread-cause-segmentation-fault-why

…IC_BINARY cmake option

This can be useful when fluentd-bit is running on a limited-access host missing the latest libraries.

Note: The following options are not compatible when using FLB_STATIC_BINARY:
- FLB_BACKTRACE
- FLB_EXAMPLES
- FLB_LUAJIT
- FLB_SQLDB

Signed-off-by: Bence Sztankovszky <[email protected]>
@sztanyoo
Copy link
Author

Thanks @nigels-com . Finally I found some time to check this issue. Maybe there won't be a solution for the Valgind report due to this: https://stackoverflow.com/questions/7506134/valgrind-errors-when-linked-with-static-why?rq=1

To summarize, these issues are coming from glibc. These issues are ignored by default by Valgrind when glibc is linked dynamically. In case of static linking it can't ignore these problem.

I've been using this binary for a month with no problem anyway.

Travis fails due to timeout.

@sztanyoo sztanyoo changed the title WIP build: enable compiling fluentd-bit static binary build: enable compiling fluentd-bit static binary Oct 15, 2020
@dmarkey
Copy link

dmarkey commented Dec 16, 2020

I'm trying to get this build using the docker image.. I'm getting:

/usr/bin/ld: ../library/libfluent-bit.a(flb_plugin.c.o): in function get_handle': flb_plugin.c:(.text+0x27f): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/bin/ld: cannot find -lsystemd /usr/bin/ld: ../library/libfluent-bit.a(flb_network.c.o): in function flb_net_tcp_connect':
flb_network.c:(.text+0x557): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
collect2: error: ld returned 1 exit status
make[3]: *** [src/CMakeFiles/fluent-bit-bin.dir/build.make:253: bin/fluent-bit] Error 1
make[2]: *** [CMakeFiles/Makefile2:4917: src/CMakeFiles/fluent-bit-bin.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:4929: src/CMakeFiles/fluent-bit-bin.dir/rule] Error 2
make: *** [Makefile:1291: fluent-bit-bin] Error 2

How did you get your branch to build?

@sztanyoo
Copy link
Author

sztanyoo commented Dec 23, 2020

I'm trying to get this build using the docker image.. I'm getting:

/usr/bin/ld: ../library/libfluent-bit.a(flb_plugin.c.o): in function get_handle': flb_plugin.c:(.text+0x27f): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/bin/ld: cannot find -lsystemd /usr/bin/ld: ../library/libfluent-bit.a(flb_network.c.o): in function flb_net_tcp_connect':
flb_network.c:(.text+0x557): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
collect2: error: ld returned 1 exit status
make[3]: *** [src/CMakeFiles/fluent-bit-bin.dir/build.make:253: bin/fluent-bit] Error 1
make[2]: *** [CMakeFiles/Makefile2:4917: src/CMakeFiles/fluent-bit-bin.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:4929: src/CMakeFiles/fluent-bit-bin.dir/rule] Error 2
make: *** [Makefile:1291: fluent-bit-bin] Error 2

How did you get your branch to build?

@dmarkey, I have checked the issue, it's failing for me as well in Docker. Actually, I compile it on the host machine with the build tools installed. There's some difference between the linux distros and the package versions:
I use Ubuntu 20.04:

$ g++ --version g++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
$ ld --version GNU ld (GNU Binutils for Ubuntu) 2.34
$ cmake --version cmake version 3.16.3

In the Docker image:

# g++ --version g++ (Debian 8.3.0-6) 8.3.0
# ld --version GNU ld (GNU Binutils for Debian) 2.31.1
# cmake --version cmake version 3.13.4

This could be one issue, I'll check it eventually (libsystemd is installed in the Docker image, so this shouldn't be the problem).

Please note, that I had a chat with Eduardo Silva earlier this year about this change. He had some concerns about the legal aspects of this change. Static linking can raise some non-technical issues regarding the GPL licensing. I'm not a legal expert to judge this, so it can happen that this PR will never get merged. However, I'll leave this PR open, as it's a valid technical solution for a real problem - so if your use-case is GPL compliant then you can still use it.

@github-actions
Copy link
Contributor

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Mar 23, 2021
@sambercovici
Copy link

if anyone needs to build docker images with statically linked fluent-bit based on scratch or on distroless/static, I have an ugly patched branch of fluent-bit-docker-image at https://github.com/sambercovici/fluent-bit-docker-image.
for example:
docker build -f Dockerfile.x86_64-scratch-static-debug -t fluent-bit:1.8.3-scratch-static .

@brian-maloney
Copy link

I'm doing automated fully-statically-linked multi-arch Docker images as well as making the bare binaries available (which is how I actually use it for my Alpine Linux ARM use case). My builds are available at https://github.com/brian-maloney/fluent-bit-static

@github-actions github-actions bot removed the Stale label Jan 4, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Apr 4, 2022

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Apr 4, 2022
@github-actions github-actions bot removed the Stale label Aug 15, 2024
Copy link
Contributor

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Static fluent-bit binary build
5 participants