Subversion Repositories QNX 8.QNX8 LLVM/Clang compiler suite

Rev

Rev 5 | Rev 7 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5 Rev 6
Line 23... Line 23...
23
export CURRENT_DIR="$(pwd)"
23
export CURRENT_DIR="$(pwd)"
24
 
24
 
25
# verify we're a x86_64 Linux host
25
# verify we're a x86_64 Linux host
26
if [ ! "$(uname)" = "Linux" ] || [ ! "$(uname -m)" = "x86_64" ]; then
26
if [ ! "$(uname)" = "Linux" ] || [ ! "$(uname -m)" = "x86_64" ]; then
27
        echo ""
27
        echo ""
28
        echo "Error: this script requires a x86_64 Linux machine (possibly a virtual machine) as the build host."
28
        echo "Error: this script requires a x86_64 Linux machine (possibly a virtual machine) as the build host." | fold -s -w 79
29
        echo ""
29
        echo ""
30
        exit 1
30
        exit 1
31
fi
31
fi
32
 
32
 
33
# verify that we have the QNX platform SDK
33
# verify that we have the QNX platform SDK
34
if [ ! -d "${QNXSDK_PATH}/${QNXSDK_HOSTPATH}" ] || [ ! -d "${QNXSDK_PATH}/${QNXSDK_TARGETPATH}" ]; then
34
if [ ! -d "${QNXSDK_PATH}/${QNXSDK_HOSTPATH}" ] || [ ! -d "${QNXSDK_PATH}/${QNXSDK_TARGETPATH}" ]; then
35
        echo ""
35
        echo ""
36
        echo "Error: the ${QNXSDK_PATH} path doesn't contain a QNX SDK. It must contain the"
36
        echo "Error: the ${QNXSDK_PATH} path doesn't contain a QNX SDK. It must contain the 'host' and 'target' directories of the QNX SDP for the targeted version of QNX and the ${TARGET_ARCH} platform. Please deploy these directories and try again." | fold -s -w 79
37
        echo "'host' and 'target' directories of the QNX SDP for the targeted version of QNX"
-
 
38
        echo "and the ${TARGET_ARCH} platform. Please deploy these directories and try again."
-
 
39
        echo ""
37
        echo ""
40
        exit 1
38
        exit 1
41
fi
39
fi
42
 
40
 
43
# verify that we have wget, python3, cmake, gcc, g++ and ninja
41
# verify that we have wget, python3, cmake, gcc, g++ and ninja
Line 61... Line 59...
61
fi
59
fi
62
 
60
 
63
# verify that the symlinks are deployed in the SDK -- just test one of them
61
# verify that the symlinks are deployed in the SDK -- just test one of them
64
if [ ! -e "${QNXSDK_PATH}/${QNXSDK_TARGETPATH}/usr/include/readline.h" ]; then
62
if [ ! -e "${QNXSDK_PATH}/${QNXSDK_TARGETPATH}/usr/include/readline.h" ]; then
65
        echo ""
63
        echo ""
66
        echo "Error: the toolchain platform-specific symbolic links have not been deployed in"
64
        echo "Error: the toolchain platform-specific symbolic links have not been deployed in this QNX SDK. Please run" | fold -s -w 79
67
        echo "this QNX SDK. Please run"
-
 
68
        echo "(on a POSIX machine:)"
65
        echo "(on a POSIX machine:)"
69
        echo "  cd ${QNXSDK_PATH}"
66
        echo "  cd ${QNXSDK_PATH}" | fold -s -w 79
70
        echo "  find . -name symlinks.lst -exec ./symlinks.sh {} create \\; && printf 'present' > .symlinks-state"
67
        echo "  find . -name symlinks.lst -exec ./symlinks.sh {} create \\; && printf 'present' > .symlinks-state" | fold -s -w 79
71
        echo "(else on a Windows machine:)"
68
        echo "(else on a Windows machine:)"
72
        echo "  cd ${QNXSDK_PATH}"
69
        echo "  cd ${QNXSDK_PATH}" | fold -s -w 79
73
        echo "  host\\win64\\x86_64\\usr\\bin\\busybox.exe sh -c \"" \
70
        echo "  host\\win64\\x86_64\\usr\\bin\\busybox.exe sh -c \"" \
74
               "find . -name symlinks.lst -exec ./symlinks.sh {} create \\; && printf 'present' > .symlinks-state" \
71
               "find . -name symlinks.lst -exec ./symlinks.sh {} create \\; && printf 'present' > .symlinks-state" \
75
               "\""
72
               "\"" | fold -s -w 79
76
        echo "Note that this step WILL take time on a Win32 machine, but is only done once."
73
        echo "Note that this step WILL take time on a Win32 machine, but is only done once." | fold -s -w 79
77
        echo ""
74
        echo ""
78
        exit 1
75
        exit 1
79
fi
76
fi
80
 
77
 
81
# construct the target triple (actually a quadruple)
78
# construct the target triple (actually a quadruple)
Line 172... Line 169...
172
SET(CMAKE_FIND_ROOT_PATH "${QNX_TARGET}")
169
SET(CMAKE_FIND_ROOT_PATH "${QNX_TARGET}")
173
SET(CMAKE_FIND_ROOT_PATH_HOST_PROGRAM NEVER)
170
SET(CMAKE_FIND_ROOT_PATH_HOST_PROGRAM NEVER)
174
SET(CMAKE_FIND_ROOT_PATH_HOST_LIBRARY ONLY)
171
SET(CMAKE_FIND_ROOT_PATH_HOST_LIBRARY ONLY)
175
SET(CMAKE_FIND_ROOT_PATH_HOST_INCLUDE ONLY)
172
SET(CMAKE_FIND_ROOT_PATH_HOST_INCLUDE ONLY)
176
' > "${TARGET_TRIPLE}.cmake"
173
' > "${TARGET_TRIPLE}.cmake"
-
 
174
 
-
 
175
# patch llvm/Support/Unix/Path.inc if not done yet
-
 
176
if ! grep -q __QNXNTO__ "../${LLVM_SOURCES_DIR}/llvm/lib/Support/Unix/Path.inc"; then
-
 
177
        echo "Patching llvm/lib/Support/Unix/Path.inc..."
-
 
178
 
-
 
179
        # have a backup first
-
 
180
        test -f "${CURRENT_DIR}/Path [BEFORE PATCH].inc" || cp "../${LLVM_SOURCES_DIR}/llvm/lib/Support/Unix/Path.inc" "${CURRENT_DIR}/Path [BEFORE PATCH].inc"
-
 
181
 
-
 
182
        # replace "defined(__FreeBSD_kernel__)" with "(defined(__FreeBSD_kernel__) || defined(__QNXNTO__))"
-
 
183
        # rationale: the concerned parts of the QNX platform SDK (/usr/include/devs/*) are actually largely based on FreeBSD code, to conveniently use the FreeBSD network stack.
-
 
184
        # NONETHELESS, QNX *IS NOT* FreeBSD and "__FreeBSD_kernel__" *SHOULD NOT* be defined, else userland code may falsely assume a genuine FreeBSD include tree to be available,
-
 
185
        # which leads to compilation errors caused by include files assumed to be there whereas they are in fact nowhere to be found (ex: /usr/include/sys/user.h, among others).
-
 
186
        # The QNX8 platform SDK has thus been patched to NOT define __FreeBSD_kernel__ when the -DDONT_DEFINE___FreeBSD_kernel__ flag is passed, and the feature tests in Path.inc
-
 
187
        # that branch into FreeBSD APIs (which ones *are* exposed in the QNX libc since QNX largely shares FreeBSD code) are about to be patched right now to accept __QNXNTO__ too.
-
 
188
        # Additionally, support for statfs()/fstatfs() has been restored in the QNX8 platform SDK in /usr/include/devs/sys/mount.h where it was claimed but absent from the QNX8 libc.
-
 
189
        # FIXME: these hacks should be moved elsewhere not to pollute the QNX8 platform SDK -- it *SHOULD* be possible to build without devs
-
 
190
        sed 's/defined(__FreeBSD_kernel__)/(defined(__FreeBSD_kernel__) || defined(__QNXNTO__))/g' "${CURRENT_DIR}/Path [BEFORE PATCH].inc" > "${CURRENT_DIR}/Path [AFTER PATCH].inc"
-
 
191
 
-
 
192
        # verify that we did it successfully
-
 
193
        if ! grep -q __QNXNTO__ "${CURRENT_DIR}/Path [AFTER PATCH].inc"; then
-
 
194
                echo "Error: the LLVM support library source file llvm/Support/Unix/Path.inc could not be patched to support QNX neutrino. Please investigate and fix manually." | fold -s -w 79
-
 
195
                exit 1
-
 
196
        fi
-
 
197
 
-
 
198
        # and put the patched file in place
-
 
199
        cp -f "${CURRENT_DIR}/Path [AFTER PATCH].inc" "../${LLVM_SOURCES_DIR}/llvm/lib/Support/Unix/Path.inc" || exit 1
-
 
200
fi
177
 
201
 
178
# now configure LLVM
202
# now configure LLVM
179
echo "Configuring LLVM build..."
203
echo "Configuring LLVM build..."
180
cmake \
204
cmake \
181
    -D CMAKE_TOOLCHAIN_FILE="${TARGET_TRIPLE}.cmake" \
205
    -D CMAKE_TOOLCHAIN_FILE="${TARGET_TRIPLE}.cmake" \