OSDN Git Service

[Build][CMake] .
[csp-qt/common_source_project-fm7.git] / source / setup-scripts / additional_defines_llvm_generic.sh
1 #!/bin/bash
2
3
4 function detect_llvm_version () {
5         if [ "__xx__${TOOLCHAIN_VERSION}" = "__xx__" ] ; then
6                 TEST_CC="clang"
7         else
8                 TEST_CC="clang-${TOOLCHAIN_VERSION}"
9         fi
10         CC_VERSION=`${TEST_CC} -dumpversion | cut -d "." -f 1`
11         echo "${CC_VERSION}"
12 }
13
14 C_MAJOR_VERSION=`detect_llvm_version`
15
16 if [ __x__"${BUILD_TYPE}" = __x__Debug ] ; then
17         USE_LTO=0
18         OPTIMIZE_LEVEL="-O0"
19 elif [ __x__"${BUILD_TYPE}" = __x__Relwithdebinfo ] ; then
20         OPTIMIZE_LEVEL="-O3"
21 else
22         OPTIMIZE_LEVEL="-O3"
23 fi
24
25 BASICOPTS+=(${OPTIMIZE_LEVEL})
26
27 if [ "__x__${OPTIMIZE_LEVEL}" != "__x__-O0" ] ; then
28         if [ $C_MAJOR_VERSION -le 12 ] ; then
29                 COPTS+=(-fslp-vectorize)
30                 COPTS+=(-fvectorize)
31                 COPTS+=(-fstrict-vtable-pointers)
32                 COPTS+=(-fstrict-enums)
33         fi
34 fi
35
36 if [ $USE_LTO -ne 0 ] ; then
37         BASICOPTS+=(-flto)
38 fi
39
40 . ${SCRIPTS_DIR}/additional_defines_simd_types_llvm.sh
41
42 BASICOPTS+=(-Wreserved-user-defined-literal)
43
44 if [ "__xx__${TOOLCHAIN_VERSION}" != "__xx__" ] ; then
45         DLL_LDOPTS+=(-fuse-ld=lld-${TOOLCHAIN_VERSION})
46         EXE_LDOPTS+=(-fuse-ld=lld-${TOOLCHAIN_VERSION})
47 else
48         DLL_LDOPTS+=(-fuse-ld=lld)
49         EXE_LDOPTS+=(-fuse-ld=lld)
50 fi
51 if [ $USE_LTO -ne 0 ] ; then
52         DLL_LDOPTS+=(-flto=jobserver)
53         EXE_LDOPTS+=(-flto=jobserver)
54 fi
55 if [ __x__"${BUILD_TYPE}" != __x__Release ] ; then
56         DEBUGFLAGS+=(-gdwarf)
57         DEBUGFLAGS+=(-gz)
58         DLL_LDOPTS+=(-Wl,--compress-debug-sections=zlib)
59         EXE_LDOPTS+=(-Wl,--compress-debug-sections=zlib)
60         if [ $C_MAJOR_VERSION -le 11 ] ; then
61                 COPTS+=(-Wa,--compress-debug-sections=zlib)
62         fi
63 else
64         DLL_LDOPTS+=(-s)
65         EXE_LDOPTS+=(-s)
66 fi
67
68 if [ __x__"${BUILD_TYPE}" != __x__Debug ] ; then
69         if [ $USE_LTO -ne 0 ] ; then
70                 DLL_LDOPTS+=(-Wl,--lto-O3)
71                 EXE_LDOPTS+=(-Wl,--lto-O3)
72         fi
73         EXE_LDOPTS+=(-fwhole-program-vtables)
74 fi
75 #EXE_LDOPTS+=(-Wl,--allow-shlib-undefined)
76
77