Code Monkey home page Code Monkey logo

Comments (15)

landley avatar landley commented on July 3, 2024

Does LDFLAGS="--static -Wl,--start-group" work?

from toybox.

landley avatar landley commented on July 3, 2024

The problem I'm having is I can dynamically pull in libssl from my host, but when I try to statically link additional libraries my build goes all /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/libgcc_eh.a(unwind-dw2.o): in function uw_init_context_1': (.text+0x1de5): undefined reference to pthread_once'
which is libgcc_eh.a trying to pull in pthreads, and from there it goes /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): in function dlfcn_globallookup': (.text+0x11): undefined reference to dlopen' which CAN'T work (you can't dlopen() from a static binary)...

You're saying you have a build environment in which statically linking libssl is possible in the first place, and I'm going... alpine maybe?

I tried to use the android NDK to statically build android_defconfig but that went ./lib/lsm.h:7:10: fatal error: 'selinux/selinux.h' file not found NDK r25c doesn't have selinux.h.

So I tried to set up a fedora kvm to test static libselinux building, but "sudo yum install glibc-static" there didn't give me static libraries for anything else (still only libselinux.so not .a)...

This is part of the reason I try to minimize build dependencies. The accelerators are available for android to use them, and Elliott tests them, but they tend to tangle for me.

from toybox.

enh-google avatar enh-google commented on July 3, 2024

I tried to use the android NDK to statically build android_defconfig but that went ./lib/lsm.h:7:10: fatal error: 'selinux/selinux.h' file not found NDK r25c doesn't have selinux.h.

yeah, libselinux (which is code you should only look at on a strong stomach: SELinuxProject/selinux#417) is not part of the NDK.

This is part of the reason I try to minimize build dependencies. The accelerators are available for android to use them, and Elliott tests them, but they tend to tangle for me.

the rules around building these libraries are weird because of FIPS, but i can report "works for me!".

from toybox.

landley avatar landley commented on July 3, 2024

Link order only matters for static libraries. I can maintain a magic link order (although I'd rather have the compiler just do --start-group and resolve it itself if that still works), but can't test it...

from toybox.

terefang avatar terefang commented on July 3, 2024

yes i am using musl static toolchain ... will try the option

from toybox.

terefang avatar terefang commented on July 3, 2024

TBO ... my build environment currently looks like this:

  • Linux Mint 21.x aka. Ubuntu 22.04.x (glibc)
  • static musl toolchain build using musl-cross-make
  • maven based airlock build system

from toybox.

terefang avatar terefang commented on July 3, 2024

ok with the option the toybox binary builds fine.

the only warning i get is:

/toolchain/bin/../lib/gcc/x86_64-linux-musl/10.2.1/../../../../x86_64-linux-musl/bin/ld: 
missing --end-group; added as last command line option

from toybox.

terefang avatar terefang commented on July 3, 2024

i also tested the wget bugger, i was getting the build errors in the first place.

a simple toybox wget https://www.google.com worked.

from toybox.

terefang avatar terefang commented on July 3, 2024

could it make sense to add a STATIC_BUILD option to config that would set LDFLAGS="--static -Wl,--start-group" automatically ?

from toybox.

landley avatar landley commented on July 3, 2024

Does commit 1b6d64f work for you?

from toybox.

terefang avatar terefang commented on July 3, 2024

test compiles ... ok
wget on https://www.google.com ... works

good work !

from toybox.

oliverkwebb avatar oliverkwebb commented on July 3, 2024

In case this is not known yet, this apparently breaks the build on MacOS:

ld: unknown option: --start-group

from toybox.

terefang avatar terefang commented on July 3, 2024

In case this is not known yet, this apparently breaks the build on MacOS:

ld: unknown option: --start-group

is that a missing feature of clang ?

from toybox.

oliverkwebb avatar oliverkwebb commented on July 3, 2024

Apparently, the fix for this seems pretty simple though. Some
stuff in portability.sh should fix it.

Actually, since we are doing -l, I don't even think we need the
start-group stuff, it compiles fine without it on my system

from toybox.

terefang avatar terefang commented on July 3, 2024

@landley after reading your blog, please pardon me as i was not observing enough.

i will keep using custom LDFLAGS for my buildsystem.

please keep up the good work !

from toybox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.