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

Building a pure C program produces a binary with unneded dependencies #687

Open
alxrmorozov opened this issue Dec 17, 2020 · 1 comment
Open
Labels
bug transition Transition to bfgroup/b2

Comments

@alxrmorozov
Copy link

alxrmorozov commented Dec 17, 2020

a.c:

int main() { return 0; }

jamroot.jam:

exe a : a.c ;

Build:

$ b2 toolset=gcc -d+2
common.mkdir bin

        mkdir -p "bin"

common.mkdir bin/gcc-8

        mkdir -p "bin/gcc-8"

common.mkdir bin/gcc-8/debug

        mkdir -p "bin/gcc-8/debug"

gcc.compile.c bin/gcc-8/debug/a.o

    "g++" -x c -fPIC -O0 -fno-inline -Wall -g     -c -o "bin/gcc-8/debug/a.o" "a.c"

gcc.link bin/gcc-8/debug/a

    "g++"    -o "bin/gcc-8/debug/a" -Wl,--start-group "bin/gcc-8/debug/a.o"  -Wl,-Bstatic  -Wl,-Bdynamic  -Wl,--end-group -fPIC -g

Resulting binary dependencies:

$ ldd bin/gcc-8/debug/a
        linux-vdso.so.1 (0x00007ffd25cf3000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f7373bab000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f7373a28000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f7373a0e000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f737384d000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f7373d5e000)

If I build with gcc I get much less dependencies:

$ gcc a.c -o a
$ ldd ./a
        linux-vdso.so.1 (0x00007ffce34e5000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1774547000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f1774737000)
$ b2 --version
B2 4.2-git

$ g++ --version
g++ (Debian 8.3.0-6) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ cat /etc/debian_version
10.7
$ arch
x86_64
@stale
Copy link

stale bot commented May 29, 2021

Thank you for your contributions. Main development of B2 has moved to https://github.com/bfgroup/b2
This issue has been automatically marked as "transition" to indicate the potential for needing transition to the new B2 development project.

@stale stale bot added the transition Transition to bfgroup/b2 label May 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug transition Transition to bfgroup/b2
Projects
None yet
Development

No branches or pull requests

2 participants