Skip to content

Instantly share code, notes, and snippets.

@SamYaple
Last active December 29, 2022 22:10
Show Gist options
  • Save SamYaple/d95dcd99c45649f8e65de0a0c3d89807 to your computer and use it in GitHub Desktop.
Save SamYaple/d95dcd99c45649f8e65de0a0c3d89807 to your computer and use it in GitHub Desktop.
Fully static, no-pic, no-pie, musl+clang+llvm+lld
[sam@compy686 scripts]$ ../../working/roots/stage6/usr/bin/clang -v
clang version 15.0.5 (file:////mnt/mirror/git/github.com/llvm/llvm-project.git 154e88af7ec97d9b9f389e55d45bf07108a9a097)
Target: x86_64-unknown-linux-musl
Thread model: posix
InstalledDir: /opt/yinux/scripts/../../working/roots/stage6/usr/bin
[sam@compy686 scripts]$ echo -e '#include <stdio.h>\nint main() {printf("using stdio!\\n");return 0;}' | ../../working/roots/stage6/usr/bin/clang -x c - -lc -static -o hi -v
clang version 15.0.5 (file:////mnt/mirror/git/github.com/llvm/llvm-project.git 154e88af7ec97d9b9f389e55d45bf07108a9a097)
Target: x86_64-unknown-linux-musl
Thread model: posix
InstalledDir: /opt/yinux/scripts/../../working/roots/stage6/usr/bin
"/opt/working/roots/stage6/usr/bin/clang-15" -cc1 -triple x86_64-unknown-linux-musl -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name - -static-define -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -v -fcoverage-compilation-dir=/opt/yinux/scripts -resource-dir /opt/working/roots/stage6/usr/lib/clang/15.0.5 -isysroot /opt/working/roots/stage6 -internal-isystem /opt/working/roots/stage6/usr/local/include -internal-externc-isystem /opt/working/roots/stage6/include -internal-externc-isystem /opt/working/roots/stage6/usr/include -internal-isystem /opt/working/roots/stage6/usr/lib/clang/15.0.5/include -fdebug-compilation-dir=/opt/yinux/scripts -ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/--b4b753.o -x c -
clang -cc1 version 15.0.5 based upon LLVM 15.0.5 default target x86_64-unknown-linux-musl
ignoring nonexistent directory "/opt/working/roots/stage6/usr/local/include"
ignoring nonexistent directory "/opt/working/roots/stage6/include"
#include "..." search starts here:
#include <...> search starts here:
/opt/working/roots/stage6/usr/include
/opt/working/roots/stage6/usr/lib/clang/15.0.5/include
End of search list.
"/opt/yinux/scripts/../../working/roots/stage6/usr/bin/ld.lld" --sysroot=/opt/working/roots/stage6 -z relro --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -static -o hi /opt/working/roots/stage6/usr/lib/crt1.o /opt/working/roots/stage6/usr/lib/crti.o /opt/working/roots/stage6/usr/lib/crtbeginT.o -L/opt/working/roots/stage6/usr/bin/../lib/x86_64-unknown-linux-musl -L/opt/working/roots/stage6/usr/lib /tmp/--b4b753.o -lc --start-group /opt/working/roots/stage6/usr/lib/clang/15.0.5/lib/x86_64-unknown-linux-musl/libclang_rt.builtins.a -l:libunwind.a -lc --end-group /opt/working/roots/stage6/usr/lib/crtend.o /opt/working/roots/stage6/usr/lib/crtn.o
[sam@compy686 scripts]$ ldd ./hi
not a dynamic executable
[sam@compy686 scripts]$ chmod +x ./hi
[sam@compy686 scripts]$ ./hi
using stdio!
[sam@compy686 scripts]$
[sam@compy686 scripts]$ ldd ../../working/roots/stage6/usr/bin/clang
not a dynamic executable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment