Code Monkey home page Code Monkey logo

Comments (5)

ivandavidov avatar ivandavidov commented on August 15, 2024

Good catch!

I need to research deeper how easy (or hard) it would be to improve the build process of the currently available overlay bundles and if it is possible to introduce general fix, e.g. perhaps set some global shell properties which will guide GCC...

from minimal.

bauen1 avatar bauen1 commented on August 15, 2024

I looked around in gcc and came up with a very very ugly solution that doesn't link / interact with the host in any way (part of bundle.sh for nweb):

cd $MAIN_SRC_DIR/work/overlay/nweb
# our sysroot
SYSROOT="$MAIN_SRC_DIR/work/glibc/glibc_prepared"

# gcc has a "internal" path that needs to be added to find the static versions of libgcc_*
GCC_INTERNAL_PATH=$(dirname $(gcc -print-libgcc-file-name))

# create a specs file to overwrite /usr/lib and so on
# this specs file should ideally reside in src/work/sysroot.specs along with the sysroot
cat << CEOF > test.specs
*link_libgcc:
-L$SYSROOT/lib -L$SYSROOT/lib64 -L$SYSROOT/usr/lib -L$SYSROOT/usr/lib64 -L$SYSROOT/usr/local/lib -L$SYSROOT/usr/local/lib64 -L$GCC_INTERNAL_PATH
CEOF

## -specs could maybe be moved to CFLAGS
#CC="gcc -specs=$PWD/test.specs"
#
## -nostdlib prevents ld's linker script from adding /usr/lib
#LDFLAGS="-Wl,--verbose,-nostdlib"
#
## we don't have gcc-libs for our guest/minimal system so we have to force static linking for libgcc
#CFLAGS="--verbose -static-libgcc"
CC="gcc -specs=$PWD/test.specs -Wl,-nostdlib -static-libgc"

set -x

#strace \
$CC $SRC_DIR/nweb23.c -o nweb

# uncomment strace and run
#  ./bundle.sh &>/dev/fd/1 | grep "[^d]/usr/lib" --color=auto
# to see that it doesn't access host files in /usr/lib in anway (apart from the compilers own files in /usr/lib/gcc/...)

Since we already have to redo the sysroot, what about moving the sysroot from src/work/glibc/glibc_prepared to src/work/sysroot so future libraries can be added easily (and maybe solve the extra flags for bundles that depend on each other)

Still needs to be tested for other bundles

from minimal.

ivandavidov avatar ivandavidov commented on August 15, 2024

Good research! The only drawback I see for now is that this complicates the build process quite a lot. Nevertheless, this is an interesting approach and personally I am willing to experiment with this.

The idea to move the sysroot to its own work folder is OK and it actually makes sense.

Implementing this might complement very well with #58 and more precisely the part where custom linker needs to be added as separate step in MLL. This also leaves room for further size optimizations where the object "stripping" could be done on linker level instead of relying on the strip command.

Just as a side note - I believe this should be done as a best effort to support the overlay bundle build structure. The MLL build structure should not be affected by these changes. I know from personal experience that playing with the GCC related shell variables easily leads to compilation issues which are hard to find/debug and I would like to keep the original MLL build process as simple as possible. At least for now.

The above note does not apply for the overlay bundles and there we can do all kinds of experimental stuff and optimizations.

from minimal.

bauen1 avatar bauen1 commented on August 15, 2024

Look at https://github.com/bauen1/minimal/tree/misc-changes

from minimal.

ivandavidov avatar ivandavidov commented on August 15, 2024

Yes, that's exactly what I had in mind with my last comment. Feel free to submit PR when you believe it is ready. I'll review and test it as soon as possible.

from minimal.

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.