Test llvm and clang

root@OpenWrt:~# clang -target aarch64 OpenWrt.c -o OpenWrt
root@OpenWrt:~# ls
OpenWrt                               hello-world
OpenWrt.c                             libllvm_17.0.6-1_aarch64_generic.ipk
a.out                                 llvm_17.0.6-1_aarch64_generic.ipk
root@OpenWrt:~#
root@OpenWrt:~#
root@OpenWrt:~#
root@OpenWrt:~# ./hello-world
Hello World
root@OpenWrt:~# ./OpenWrt
Welcome OpenWrt
root@OpenWrt:~#
root@OpenWrt:~#
root@OpenWrt:~#
root@OpenWrt:~# llvm-config --version
17.0.6
root@OpenWrt:~#
root@OpenWrt:~#
root@OpenWrt:~# clang --version
clang version 17.0.6
Target: unknown
Thread model: posix
InstalledDir: /usr/bin
root@OpenWrt:~# cd /usr/bin
root@OpenWrt:/usr/bin# ldd llvm-config
        /lib/ld-musl-aarch64.so.1 (0x7f81ebc000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x7f81ce8000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x7f81cb7000)
        libc.so => /lib/ld-musl-aarch64.so.1 (0x7f81ebc000)
root@OpenWrt:/usr/bin# ldd clang
        /lib/ld-musl-aarch64.so.1 (0x7f80f34000)
        libclang-cpp.so.17 => /usr/lib/libclang-cpp.so.17 (0x7f7e0dd000)
        libLLVM-17.so => /usr/lib/libLLVM-17.so (0x7f7b117000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x7f7af43000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x7f7af12000)
        libc.so => /lib/ld-musl-aarch64.so.1 (0x7f80f34000)
        libffi.so.8 => /usr/lib/libffi.so.8 (0x7f7aee1000)
root@OpenWrt:/usr/bin#

llvm update

root@OpenWrt:~# llvm-config --version
18.1.5
root@OpenWrt:~#
root@OpenWrt:~#
root@OpenWrt:~#
root@OpenWrt:~# clang --version
clang version 18.1.5
Target: aarch64-openwrt-linux-musl
Thread model: posix
InstalledDir: /usr/bin
root@OpenWrt:~# clang -fuse-ld=lld -v hello-world.c
clang version 18.1.5
Target: aarch64-openwrt-linux-musl
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/aarch64-openwrt-linux-musl/12.3.0Found candidate GCC installation: /usr/bin/../lib64/gcc/aarch64-openwrt-linux-musl/12.3.0
Selected GCC installation: /usr/bin/../lib64/gcc/aarch64-openwrt-linux-musl/12.3.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
 "/usr/bin/clang-18" -cc1 -triple aarch64-openwrt-linux-musl -emit-obj -mrelax-all -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name hello-world.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -target-feature +v8a -target-feature +fp-armv8 -target-feature +neon -target-abi aapcs -debugger-tuning=gdb -fdebug-compilation-dir=/root -v -fcoverage-compilation-dir=/root -resource-dir /usr/lib/clang/18 -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib64/gcc/aarch64-openwrt-linux-musl/12.3.0/../../../../aarch64-openwrt-linux-musl/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -internal-isystem /usr/lib/clang/18/include -ferror-limit 19 -fno-signed-char -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -target-feature +outline-atomics -target-feature -fmv -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/hello-world-482e66.o -x c hello-world.c
clang -cc1 version 18.1.5 based upon LLVM 18.1.5 default target aarch64-openwrt-linux-musl
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/bin/../lib64/gcc/aarch64-openwrt-linux-musl/12.3.0/../../../../aarch64-openwrt-linux-musl/include"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include
 /usr/lib/clang/18/include
End of search list.
 "/usr/bin/ld.lld" -EL --hash-style=gnu --eh-frame-hdr -m aarch64linux -pie -dynamic-linker /lib/ld-musl-aarch64.so.1 -o a.out /usr/bin/../lib64/gcc/aarch64-openwrt-linux-musl/12.3.0/Scrt1.o /usr/bin/../lib64/gcc/aarch64-openwrt-linux-musl/12.3.0/crti.o /usr/bin/../lib64/gcc/aarch64-openwrt-linux-musl/12.3.0/crtbeginS.o -L/usr/bin/../lib64/gcc/aarch64-openwrt-linux-musl/12.3.0 -L/usr/bin/../lib64/gcc/aarch64-openwrt-linux-musl/12.3.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/lib -L/usr/lib /tmp/hello-world-482e66.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/bin/../lib64/gcc/aarch64-openwrt-linux-musl/12.3.0/crtendS.o /usr/bin/../lib64/gcc/aarch64-openwrt-linux-musl/12.3.0/crtn.o
root@OpenWrt:~#
root@OpenWrt:~# clang hello-world.c -S -emit-llvm -o -
; ModuleID = 'hello-world.c'
source_filename = "hello-world.c"
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64-openwrt-linux-musl"
@.str = private unnamed_addr constant [13 x i8] c"Hello World\0A\00", align 1
; Function Attrs: noinline nounwind optnone uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  store i32 %0, ptr %3, align 4
  store ptr %1, ptr %4, align 8
  %5 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  ret i32 0
}
declare i32 @printf(ptr noundef, ...) #1
attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="non-leaf" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+fp-armv8,+neon,+outline-atomics,+v8a,-fmv" }
attributes #1 = { "frame-pointer"="non-leaf" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+fp-armv8,+neon,+outline-atomics,+v8a,-fmv" }
!llvm.module.flags = !{!0, !1, !2, !3, !4}
!llvm.ident = !{!5}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{i32 7, !"frame-pointer", i32 1}
!5 = !{!"clang version 18.1.5"}
root@OpenWrt:~#