1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/llvm/llvm.conf
3 # Copyright (C) 2009 - 2022 The T2 SDE Project
5 # This Copyright note is generated by scripts/Create-CopyPatch,
6 # more information can be found in the files COPYING and README.
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License version 2.
10 # --- T2-COPYRIGHT-NOTE-END ---
13 var_append cmakeopt " " "-DCMAKE_BUILD_TYPE:STRING=Release"
15 create_llvm_config_x() {
16 # TODO: check -lz -lnucrses deps!
18 [[ $arch = x86* ]] && host=NaN # TODO: != native llvm target
19 cat <<-EOT > $root/TOOLCHAIN/$toolsdir/bin/llvm-config-x
23 -e 's, $host[^ ]*,,g' \\
24 -e 's,-L$root/TOOLCHAIN/tools.cross/lib,-L$root$libdir,g' \\
25 -e 's,-I$root/TOOLCHAIN/tools.cross/include,,g' \\
26 -e 's,-lLLVM,-lz -lncurses &,'
28 chmod +x $root/TOOLCHAIN/$toolsdir/bin/llvm-config-x
31 # AArch64 AMDGPU ARM BPF Hexagon Lanai Mips MSP430 NVPTX PowerPC RISCV Sparc SystemZ WebAssembly X86 XCore
32 # keep in sync w/ rustc! ;-)
33 targets="AMDGPU;BPF;WebAssembly;host" # host for cross compilation
36 arm) var_insert targets ';' 'ARM' ;;
37 arm64) var_insert targets ';' 'AArch64' ;;
38 mips*) var_insert targets ';' 'Mips' ;;
39 sparc*) var_insert targets ';' 'Sparc' ;;
40 powerpc*) var_insert targets ';' 'PowerPC' ;;
41 riscv*) var_insert targets ';' 'RISCV' ;;
42 x86*) var_insert targets ';' 'X86' ;;
43 *) var_insert targets ';' 'X86'; target=x86-t2-linux-gnu ;;
46 # TODO: config.in option
47 #var_append cmakeopt " " "-DLLVM_TARGETS_TO_BUILD='$targets'"
48 var_append cmakeopt " " "-DLLVM_DEFAULT_TARGET_TRIPLE=$target"
50 if atstage toolchain; then
51 var_append cmakeopt " " "-DLLVM_HOST_TRIPLE=$arch_build"
52 elif atstage cross; then
53 var_append cmakeopt " " "-DLLVM_TABLEGEN=$root/TOOLCHAIN/$toolsdir/bin/llvm-tblgen"
54 var_append GCC_WRAPPER_FILTER '|' "sed 's,^/lib64/libcurses.so,-lcurses,'"
55 var_append GCC_WRAPPER_FILTER '|' "sed 's,$root/lib64/libcurses.so,-lcurses,'"
57 hook_add premake 5 "create_llvm_config_x"
60 [ "${libdir##*/lib}" ] && var_append cmakeopt " " "-DLLVM_LIBDIR_SUFFIX=${libdir##*/lib}"
61 # builds libraries as static and links all of them into an unique shared one
62 var_append cmakeopt " " "-DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON"
63 #var_append cmakeopt " " "-DBUILD_SHARED_LIBS=ON"
65 var_append cmakeopt " " "-DLLVM_ENABLE_RTTI=ON" # for Mesa?
66 var_append cmakeopt " " "-DLLVM_INCLUDE_BENCHMARKS=OFF" # -DLLVM_BUILD_UTILS=OFF"
67 var_append cmakeopt " " "-DLLVM_ENABLE_BINDINGS=OFF -DLLVM_INCLUDE_GO_TESTS=OFF"
69 [[ $arch = sparc* ]] && var_append GCC_WRAPPER_APPEND ' ' '-c?:-latomic'
70 [ $arch = powerpc64 ] && var_append GCC_WRAPPER_APPEND ' ' -mminimal-toc