compiling static binaries

2022-06-09 Thread Niv Waizer via rsync
For anybody trying to build a static binary:

Thanks to Han Boetes for the post here, advising to use musl.
Thanks to Florian Dejonckheere for posting this script:
https://github.com/JBBgameich/rsync-static

Here is my small contrib on this, for the lazy folks.
I download the musl prebuild binaries for my arch from
skarnet.org/toolchains
My script is posted here:
https://github.com/nwaizer/rsync-static/blob/main/build_static.sh

or below:
#!/bin/bash
# based on the solution by Florian Dejonckheere <
flor...@floriandejonckheere.be>
# at https://github.com/JBBgameich/rsync-static

mkdir toolchain
echo "I: Downloading prebuilt toolchain"
wget --continue
https://skarnet.org/toolchains/native/x86_64-linux-musl_pc-11.3.0.tar.xz -O
/tmp/x86_64-linux-musl_pc.tar.xz|| echo "Failed to find
x86_64-linux-musl_pc-11.3.0.tar.xz. Please open your browser at
https://skarnet.org/toolchains/native and find the correct file to fix this"
tar -xf /tmp/x86_64-linux-musl_pc.tar.xz -C toolchain

echo "Native compiler is called gcc"
TOOLCHAIN_PATH="$(readlink -f $(dirname $(find . -name "gcc"))/..)"
echo "Use local gcc instead of the OS installed one"
export PATH=$TOOLCHAIN_PATH/bin:$PATH

echo "Get rsync source"
git clone https://github.com/WayneD/rsync.git

echo "Build rsync"
cd rsync/
make clean
export CC="gcc"
echo "Disable openssl xxhash zstd and lz4 as they did not configure even
after consulting the INSTALL"
./configure CFLAGS="-static" --host="x86" --disable-openssl
--disable-xxhash --disable-zstd --disable-lz4
make
strip rsync

Thanks for rsync,
Niv
-- 
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html


compiling static binaries

2018-04-03 Thread Han Boetes via rsync

For anybody trying to build a static binary:


Glibc static binaries are not backwards compatible: to get really
static binaries you'd have to compile them with musl libc.

The easiest way for me was to set up a VM with alpine linux. Then I
configured and build rsync and at the end ran these commands to get a
static binary:

cp /usr/lib/libacl.a .
gcc -static -O2 -Wall -static-libgcc -W -o rsync $(find . -name '*.o') libacl.a
strip rsync

And the resulting binary works fine on an ancient (2008) machine.



# Han

-- 
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html