Rev 10 | Rev 12 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 10 | Rev 11 | ||
|---|---|---|---|
| Line 76... | Line 76... | ||
| 76 | export TARGET_ARCH="${BUILD_TARGET_ARCH}"  | 
            76 | export TARGET_ARCH="${BUILD_TARGET_ARCH}"  | 
          
| 77 | test "${BUILD_TARGET_ARCH}" = "x86_64" && export TARGET_VENDOR="pc" || export TARGET_VENDOR="unknown"  | 
            77 | test "${BUILD_TARGET_ARCH}" = "x86_64" && export TARGET_VENDOR="pc" || export TARGET_VENDOR="unknown"  | 
          
| 78 | export TARGET_KERNEL="nto"  | 
            78 | export TARGET_KERNEL="nto"  | 
          
| 79 | export TARGET_SYSTEM="qnx${QNXSDK_VERSION}"  | 
            79 | export TARGET_SYSTEM="qnx${QNXSDK_VERSION}"  | 
          
| 80 | export TARGET_TRIPLE="${TARGET_ARCH}-${TARGET_VENDOR}-${TARGET_KERNEL}-${TARGET_SYSTEM}"  | 
            80 | export TARGET_TRIPLE="${TARGET_ARCH}-${TARGET_VENDOR}-${TARGET_KERNEL}-${TARGET_SYSTEM}"  | 
          
| 81 | echo "Will build  | 
            81 | echo "Will build for ${TARGET_TRIPLE}"  | 
          
| 82 | 82 | ||
| 83 | # change to an immediately visible path, i.e. the user's desktop (failsafe to $HOME if xdg-user-dir is unavailable) | 
            83 | # change to an immediately visible path, i.e. the user's desktop (failsafe to $HOME if xdg-user-dir is unavailable) | 
          
| 84 | STAGING_PATH="$(xdg-user-dir DESKTOP 2>/dev/null || echo "${HOME}")"  | 
            84 | STAGING_PATH="$(xdg-user-dir DESKTOP 2>/dev/null || echo "${HOME}")"  | 
          
| 85 | cd "${STAGING_PATH}"  | 
            85 | cd "${STAGING_PATH}"  | 
          
| 86 | 86 | ||
| Line 100... | Line 100... | ||
| 100 | 100 | ||
| 101 | # download the involved source packages and unpack them if not done yet | 
            101 | # download the involved source packages and unpack them if not done yet | 
          
| 102 | download_and_unpack_if_necessary()  | 
            102 | download_and_unpack_if_necessary()  | 
          
| 103 | { | 
            103 | { | 
          
| 104 |         # helper function that downloads a sources tarball, extracts it and patches it if necessary | 
            104 |         # helper function that downloads a sources tarball, extracts it and patches it if necessary | 
          
| 105 |         # args: <sources dirname> <sources filename> <download URL>  | 
            105 |         # args: <sources dirname> <sources filename> <download URL> [optional patchset URL] | 
          
| 106 | 
  | 
            106 | test -d "${1}" && return 0 # if sources directory already exists, nothing to do  | 
          
| 107 | 
  | 
            107 | if [ ! -s "${CURRENT_DIR}/${2}" ]; then # if sources archive isn't a nonempty file...  | 
          
| 108 | 
  | 
            108 | echo "Downloading ${1} sources from ${3}..."  | 
          
| 109 | 
  | 
            109 | if ! wget -O "${CURRENT_DIR}/${2}" "${3}"; then  | 
          
| 110 |                 fi | 
            - | |
| 111 | echo "Extracting ${1} sources..."  | 
            - | |
| 112 | cd "$(dirname "${1}")"  | 
            - | |
| 113 | 
  | 
            110 |                         # remove output file in case an error occurs | 
          
| 114 | tar xjf "${CURRENT_DIR}/${2}" || exit 1  | 
            - | |
| 115 | elif echo "${2}"|grep -q "\.tar\.xz$"; then  | 
            - | |
| 116 | tar xJf "${CURRENT_DIR}/${2}" || exit 1  | 
            - | |
| 117 | elif echo "${2}"|grep -q "\.tar\.gz$"; then  | 
            - | |
| 118 | 
  | 
            111 | rm -f "${CURRENT_DIR}/${2}"  | 
          
| 119 |                 else | 
            - | |
| 120 | echo "Error: unsupported file extension. Please improve the download_and_unpack_if_necessary() shell function to support it."  | 
            - | |
| 121 | exit 1  | 
            112 | exit 1  | 
          
| 122 |                 fi | 
            113 |                 fi | 
          
| - | 114 |         fi | 
          |
| - | 115 | echo "Extracting ${1} sources..."  | 
          |
| - | 116 | cd "$(dirname "${1}")"  | 
          |
| - | 117 | if echo "${2}"|grep -q "\.tar\.bz2$"; then  | 
          |
| - | 118 |                 # BZip2 tarball | 
          |
| - | 119 | tar xjf "${CURRENT_DIR}/${2}" || exit 1  | 
          |
| - | 120 | elif echo "${2}"|grep -q "\.tar\.xz$"; then  | 
          |
| - | 121 |                 # XZ tarball | 
          |
| - | 122 | tar xJf "${CURRENT_DIR}/${2}" || exit 1  | 
          |
| - | 123 | elif echo "${2}"|grep -q "\.tar\.gz$"; then  | 
          |
| - | 124 |                 # GZipped tarball | 
          |
| - | 125 | tar xzf "${CURRENT_DIR}/${2}" || exit 1  | 
          |
| - | 126 |         else | 
          |
| - | 127 | echo "Error: unsupported file extension. Please improve the download_and_unpack_if_necessary() shell function to support it."  | 
          |
| - | 128 | exit 1  | 
          |
| - | 129 |         fi | 
          |
| - | 130 |         # make sure the expected directory is here after extraction | 
          |
| 123 | 
  | 
            131 | if [ ! -d "${1}" ]; then  | 
          
| 124 | 
  | 
            132 | echo "Error: couldn't find ${1} in extracted sources."  | 
          
| 125 | 
  | 
            133 | exit 1  | 
          
| 126 | 
  | 
            134 |         fi | 
          
| - | 135 |         # do we have a patchset to apply ? | 
          |
| 127 | 
  | 
            136 | if [ -n "${4}" ]; then  | 
          
| 128 | 
  | 
            137 | echo "Downloading ${1} patchset from ${4}..."  | 
          
| 129 | 
  | 
            138 | wget -O "${CURRENT_DIR}/${2}.patchset" "${4}" || exit 1  | 
          
| 130 | 
  | 
            139 | echo "Applying patchset..."  | 
          
| 131 | 
  | 
            140 | OLDDIR="$(pwd)"  | 
          
| 132 | 
  | 
            141 | cd "${1}"  | 
          
| 133 | 
  | 
            142 | patch -N -Z -p1 < "${CURRENT_DIR}/${2}.patchset" || exit 1  | 
          
| 134 | 
  | 
            143 | cd "${OLDDIR}"  | 
          
| 135 | 
  | 
            144 |                 unset OLDDIR | 
          
| 136 |                 fi | 
            - | |
| 137 |         fi | 
            145 |         fi | 
          
| 138 | return 0  | 
            146 | return 0  | 
          
| 139 | } | 
            147 | } | 
          
| 140 | download_and_unpack_if_necessary "${LLVM_SOURCES_DIR}" "${LLVM_SOURCES_FILE}" "${LLVM_SOURCES_URL}" || exit 1  | 
            148 | download_and_unpack_if_necessary "${LLVM_SOURCES_DIR}" "${LLVM_SOURCES_FILE}" "${LLVM_SOURCES_URL}" || exit 1  | 
          
| 141 | 149 | ||
| Line 213... | Line 221... | ||
| 213 | ' > "${TARGET_TRIPLE}.cmake"  | 
            221 | ' > "${TARGET_TRIPLE}.cmake"  | 
          
| 214 | 222 | ||
| 215 | backup_and_patch_if_necessary()  | 
            223 | backup_and_patch_if_necessary()  | 
          
| 216 | { | 
            224 | { | 
          
| 217 |         # handy function that patches a file in LLVM_SOURCES_DIR with a given sed replacement regex if necessary, creating backups | 
            225 |         # handy function that patches a file in LLVM_SOURCES_DIR with a given sed replacement regex if necessary, creating backups | 
          
| 218 |         # args: <file pathname> <grep_string_to_test_for_presence_of_patch> <sed regex> | 
            226 |         # args: <file pathname> <grep_string_to_test_for_presence_of_patch> <sed regex> [<second regex> [...]] | 
          
| - | 227 | _PATCHEE_PATHNAME="${1}"  | 
          |
| - | 228 | _PATCHED_PATTERN="${2}"  | 
          |
| 219 |         # test if already patched | 
            229 |         # test if already patched | 
          
| 220 | grep -q "${  | 
            230 | grep -q "${_PATCHED_PATTERN}" "../${LLVM_SOURCES_DIR}/${_PATCHEE_PATHNAME}" && return  | 
          
| 221 |         # tell what we're about to do | 
            231 |         # tell what we're about to do | 
          
| 222 | echo "Patching ${  | 
            232 | echo "Patching ${_PATCHEE_PATHNAME}..."  | 
          
| - | 233 | _DOTTED_NAME="$(echo "${_PATCHEE_PATHNAME}"|tr '/' '.')"  | 
          |
| 223 |         # have a backup first | 
            234 |         # have a backup first | 
          
| 224 | test -f "${CURRENT_DIR}/  | 
            235 | test -f "${CURRENT_DIR}/${_DOTTED_NAME} [ORIGINAL]" || cp "../${LLVM_SOURCES_DIR}/${_PATCHEE_PATHNAME}" "${CURRENT_DIR}/${_DOTTED_NAME} [ORIGINAL]" || exit 1  | 
          
| 225 |         # perform the patch | 
            236 |         # perform the patch | 
          
| 226 | 
  | 
            237 | cp -f "${CURRENT_DIR}/${_DOTTED_NAME} [ORIGINAL]" "${CURRENT_DIR}/${_DOTTED_NAME} [PATCHED]" || exit 1  | 
          
| - | 238 | while [ -n "${3}" ]; do  | 
          |
| - | 239 | sed -E -i "${3}" "${CURRENT_DIR}/${_DOTTED_NAME} [PATCHED]"  | 
          |
| - | 240 |                 shift | 
          |
| - | 241 |         done | 
          |
| 227 |         # verify that we did it successfully | 
            242 |         # verify that we did it successfully | 
          
| 228 | if ! grep -q "${  | 
            243 | if ! grep -q "${_PATCHED_PATTERN}" "${CURRENT_DIR}/${_DOTTED_NAME} [PATCHED]"; then  | 
          
| 229 | echo "Error: the file ${  | 
            244 | echo "Error: the file ${_PATCHEE_PATHNAME} could not be patched. Please investigate and fix manually." | fold -s -w 79; exit 1  | 
          
| 230 |         fi | 
            245 |         fi | 
          
| 231 |         # and put the patched file in place | 
            246 |         # and put the patched file in place | 
          
| 232 | cp -f "${CURRENT_DIR}/  | 
            247 | cp -f "${CURRENT_DIR}/${_DOTTED_NAME} [PATCHED]" "../${LLVM_SOURCES_DIR}/${_PATCHEE_PATHNAME}" || exit 1  | 
          
| 233 | } | 
            248 | } | 
          
| 234 | 249 | ||
| 235 | # patch llvm/Support/Unix/Path.inc if not done yet | 
            250 | # patch llvm/Support/Unix/Path.inc if not done yet | 
          
| 236 | # replace [defined(__FreeBSD_kernel__)] with [(defined(__FreeBSD_kernel__) || defined(__QNXNTO__))] | 
            251 | # replace [defined(__FreeBSD_kernel__)] with [(defined(__FreeBSD_kernel__) || defined(__QNXNTO__))] | 
          
| 237 | # 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. | 
            252 | # 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. | 
          
| Line 239... | Line 254... | ||
| 239 | # 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). | 
            254 | # 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). | 
          
| 240 | # 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 | 
            255 | # 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 | 
          
| 241 | # 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. | 
            256 | # 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. | 
          
| 242 | # 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. | 
            257 | # 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. | 
          
| 243 | # FIXME: these hacks should be moved elsewhere not to pollute the QNX8 platform SDK -- it *SHOULD* be possible to build without devs | 
            258 | # FIXME: these hacks should be moved elsewhere not to pollute the QNX8 platform SDK -- it *SHOULD* be possible to build without devs | 
          
| - | 259 | backup_and_patch_if_necessary "llvm/lib/Support/Unix/Path.inc" __QNXNTO__ \ | 
          |
| 244 | 
  | 
            260 |         's/defined\(__FreeBSD_kernel__\)/\(defined\(__FreeBSD_kernel__\) \|\| \defined\(__QNXNTO__\)\)/g' | 
          
| 245 | 261 | ||
| 246 | # patch lldb/Source/Host/common/Host.cpp if not done yet | 
            262 | # patch lldb/Source/Host/common/Host.cpp if not done yet | 
          
| 247 | # replace [defined(SIGINFO)] with [(defined(SIGINFO) && !defined(__QNXNTO__))] | 
            263 | # replace [defined(SIGINFO)] with [(defined(SIGINFO) && !defined(__QNXNTO__))] | 
          
| 248 | # RATIONALE: the QNX people defined SIGINFO to the value of SIGUSR1 for a mysterious reason, defeating the purpose of SIGUSR1 | 
            264 | # RATIONALE: the QNX people defined SIGINFO to the value of SIGUSR1 for a mysterious reason, defeating the purpose of SIGUSR1 | 
          
| 249 | # which should be a User-Definable signal as mandated by POSIX. Consequently, userland code that enumerates POSIX signals | 
            265 | # which should be a User-Definable signal as mandated by POSIX. Consequently, userland code that enumerates POSIX signals | 
          
| 250 | # hits twice the same value and all is left to solve this problem is to filter either one out. Since SIGINFO, contrarily to SIGUSR1, | 
            266 | # hits twice the same value and all is left to solve this problem is to filter either one out. Since SIGINFO, contrarily to SIGUSR1, | 
          
| 251 | # is an optional signal, this is the value that will be left out - even if on QNX nobody can actually use SIGUSR1's value. | 
            267 | # is an optional signal, this is the value that will be left out - even if on QNX nobody can actually use SIGUSR1's value. | 
          
| 252 | backup_and_patch_if_necessary "lldb/source/Host/common/Host.cpp" __QNXNTO__  | 
            268 | backup_and_patch_if_necessary "lldb/source/Host/common/Host.cpp" __QNXNTO__ \ | 
          
| - | 269 |         's/defined\(SIGINFO\)/\(defined\(SIGINFO\) \&\& \!defined\(__QNXNTO__\)\)/g' | 
          |
| 253 | 270 | ||
| 254 | # FIXME: another patch is needed for LLDB. Basically, the ptrace() POSIX system call doesn't exist on QNX. Instead | 
            271 | # FIXME: another patch is needed for LLDB. Basically, the ptrace() POSIX system call doesn't exist on QNX. Instead | 
          
| 255 | # QNX use their own debug utility: pdebug. Note the /proc filesystem can be used to access a debuggee's virtual memory space. | 
            272 | # QNX use their own debug utility: pdebug. Note the /proc filesystem can be used to access a debuggee's virtual memory space. | 
          
| 256 | # in lldb/source/Host/posix/ProcessLauncherPosixFork.cpp line 196: | 
            273 | # in lldb/source/Host/posix/ProcessLauncherPosixFork.cpp line 196: | 
          
| 257 | #   if (ptrace(PT_TRACE_ME, 0, nullptr, 0) == -1) // <--- undefined: ptrace, PT_TRACE_ME | 
            274 | #   if (ptrace(PT_TRACE_ME, 0, nullptr, 0) == -1) // <--- undefined: ptrace, PT_TRACE_ME | 
          
| Line 262... | Line 279... | ||
| 262 | # replace [#include "int_lib.h"] with [#ifdef __QNXNTO__\n#define _QNX_SOURCE 1\n#endif\n#include "int_lib.h"] | 
            279 | # replace [#include "int_lib.h"] with [#ifdef __QNXNTO__\n#define _QNX_SOURCE 1\n#endif\n#include "int_lib.h"] | 
          
| 263 | # RATIONALE: the QNX people decided to hide most of the UNIX APIs of their libc behind a mandatory _QNX_SOURCE definition to separate the Neutrino primitives from the rest maybe. | 
            280 | # RATIONALE: the QNX people decided to hide most of the UNIX APIs of their libc behind a mandatory _QNX_SOURCE definition to separate the Neutrino primitives from the rest maybe. | 
          
| 264 | # This name does not "enforce" any standard at all (like _POSIX_SOURCE and similar names), it's just a convenient hack for the QNX people to hide stuff. | 
            281 | # This name does not "enforce" any standard at all (like _POSIX_SOURCE and similar names), it's just a convenient hack for the QNX people to hide stuff. | 
          
| 265 | # To put things back on track and expose the POSIX interfaces of their libc to the world, _QNX_SOURCE has been added to the toolchain CMake file, but it happens that | 
            282 | # To put things back on track and expose the POSIX interfaces of their libc to the world, _QNX_SOURCE has been added to the toolchain CMake file, but it happens that | 
          
| 266 | # when building compiler-rt specifically, the CMAKE_C_FLAGS directive is ignored. Patching the source file seems like the best option to fix that. | 
            283 | # when building compiler-rt specifically, the CMAKE_C_FLAGS directive is ignored. Patching the source file seems like the best option to fix that. | 
          
| - | 284 | backup_and_patch_if_necessary "compiler-rt/lib/builtins/enable_execute_stack.c" __QNXNTO__ \ | 
          |
| 267 | 
  | 
            285 |         's/#include "int_lib.h"/#ifdef __QNXNTO__\n#define _QNX_SOURCE 1\n#endif\n#include "int_lib.h"/g' | 
          
| 268 | 286 | ||
| 269 | # patch libunwind/src/RWMutex.hpp | 
            287 | # patch libunwind/src/RWMutex.hpp | 
          
| 270 | # replace [#include <pthread.h>] with [#ifdef __QNXNTO__\n#define __EXT_QNX\n#define __EXT_POSIX1_200112\n#endif\n#include <pthread.h>] | 
            288 | # replace [#include <pthread.h>] with [#ifdef __QNXNTO__\n#define __EXT_QNX\n#define __EXT_POSIX1_200112\n#endif\n#include <pthread.h>] | 
          
| 271 | # RATIONALE: the pthreads implementation in QNX 'steals' things from the POSIX.1 standard and hides them behind the __EXT_QNX macro, | 
            289 | # RATIONALE: the pthreads implementation in QNX 'steals' things from the POSIX.1 standard and hides them behind the __EXT_QNX macro, | 
          
| 272 | # which is defined when either _QNX_SOURCE or __EXT without anything else is defined. This is not correct and low-level libraries | 
            290 | # which is defined when either _QNX_SOURCE or __EXT without anything else is defined. This is not correct and low-level libraries | 
          
| 273 | # such as libunwind that do not define either of those fail to build. Also note that a FreeBSD-compatible header was added to the QNX8 | 
            291 | # such as libunwind that do not define either of those fail to build. Also note that a FreeBSD-compatible header was added to the QNX8 | 
          
| 274 | # platform SDK: /usr/include/link.h, which defines Elf types as Elf64/Elf32 types depending on the architecture and adds some glue. | 
            292 | # platform SDK: /usr/include/link.h, which defines Elf types as Elf64/Elf32 types depending on the architecture and adds some glue. | 
          
| - | 293 | backup_and_patch_if_necessary "libunwind/src/RWMutex.hpp" __QNXNTO__ \ | 
          |
| 275 | 
  | 
            294 |         's/#include <pthread.h>/#ifdef __QNXNTO__\n#define __EXT_QNX\n#define __EXT_POSIX1_200112\n#endif\n#include <pthread.h>/g' | 
          
| 276 | 295 | ||
| 277 | # patch libunwind/src/libunwind.cpp | 
            296 | # patch libunwind/src/libunwind.cpp | 
          
| 278 | # replace [#include <libunwind.h>] with [#ifdef __QNXNTO__\n#include <sys/link.h>\n#include <link.h>\n#endif\n#include <libunwind.h>] | 
            297 | # replace [#include <libunwind.h>] with [#ifdef __QNXNTO__\n#include <sys/link.h>\n#include <link.h>\n#endif\n#include <libunwind.h>] | 
          
| 279 | # RATIONALE: the ELF type definitions for QNX are incomplete. They renamed everything to Elf32 and Elf64, and now the original Elf type names point to nowhere. | 
            298 | # RATIONALE: the ELF type definitions for QNX are incomplete. They renamed everything to Elf32 and Elf64, and now the original Elf type names point to nowhere. | 
          
| 280 | # Additionally, since QNX claims to be a " | 
            299 | # Additionally, since QNX claims to be a "__FreeBSD_kernel__", it must expose a /usr/include/link.h file too, and the workaround for the aforementioned problem is there. | 
          
| 281 | # Consequently, load the QNX <sys/link.h> THEN our BSD glue <link.h> headers before compiling libunwind.cpp which needs common ELF definitions (and not Elf32/Elf64). | 
            300 | # Consequently, load the QNX <sys/link.h> THEN our BSD glue <link.h> headers before compiling libunwind.cpp which needs common ELF definitions (and not Elf32/Elf64). | 
          
| - | 301 | backup_and_patch_if_necessary "libunwind/src/libunwind.cpp" __QNXNTO__ \ | 
          |
| - | 302 |         's,#include <libunwind.h>,#ifdef __QNXNTO__\n#include <sys/link.h>\n#include <link.h>\n#endif\n#include <libunwind.h>,g' | 
          |
| - | 303 | ||
| - | 304 | # patch libcxx/include/__config | 
          |
| - | 305 | # replace [define _LIBCPP_HAS_THREAD_API_WIN32] with [define _LIBCPP_HAS_THREAD_API_WIN32\n#    elif defined(__QNXNTO__)\n#      define _LIBCPP_HAS_THREAD_API_PTHREAD] | 
          |
| - | 306 | # RATIONALE: simply bring QNX among the list of systems known by libc++ to expose a pthreads API, and inform it that pthread_cond_clockwait() is available (pah!) | 
          |
| - | 307 | backup_and_patch_if_necessary "libcxx/include/__config" __QNXNTO__ \ | 
          |
| - | 308 |         's/define _LIBCPP_HAS_THREAD_API_WIN32/define _LIBCPP_HAS_THREAD_API_WIN32\n#    elif defined(__QNXNTO__)\n#      define _LIBCPP_HAS_THREAD_API_PTHREAD\n#      define _LIBCPP_HAS_COND_CLOCKWAIT/g' | 
          |
| - | 309 | ||
| - | 310 | # patch libcxx/include/__locale, libcxx/include/CMakeLists.txt and add __support/qnx/xlocale.h to the libc++ source tree | 
          |
| - | 311 | # replace [# include <__support/openbsd/xlocale.h>] with [# include <__support/openbsd/xlocale.h>\n#elif defined(__QNXNTO__)\n# include <__support/qnx/xlocale.h>] | 
          |
| - | 312 | # RATIONALE: add QNX-specific locale C++ bindings and definitions | 
          |
| - | 313 | backup_and_patch_if_necessary "libcxx/include/__locale" __QNXNTO__ \ | 
          |
| - | 314 |         's,# include <__support/openbsd/xlocale.h>,# include <__support/openbsd/xlocale.h>\n#elif defined\(__QNXNTO__\)\n# include <__support/qnx/xlocale.h>,g' \ | 
          |
| 282 | 
  | 
            315 |         's/#elif defined\(__MVS__\)/#elif defined\(__QNXNTO__\)\n    typedef short mask;\n    static const mask space  = \(_CN\|_SP\|_XS\);\n    static const mask print  = \(_DI\|_LO\|_PU\|_SP\|_UP\|_XA\);\n    static const mask cntrl  = _BB;\n    static const mask upper  = _UP;\n    static const mask lower  = _LO;\n    static const mask alpha  = \(_LO\|_UP\|_XA\);\n    static const mask digit  = _DI;\n    static const mask punct  = _PU;\n    static const mask xdigit = _XD;\n    static const mask blank  = \(_SP\|_XB\);\n    static const mask __regex_word = 0x1000;\n#elif defined\(__MVS__\)/g' | 
          
| - | 316 | backup_and_patch_if_necessary "libcxx/include/CMakeLists.txt" qnx/xlocale.h 's, __support/openbsd/xlocale.h, __support/openbsd/xlocale.h\n __support/qnx/xlocale.h,g'  | 
          |
| - | 317 | test -d "../${LLVM_SOURCES_DIR}/libcxx/include/__support/qnx" || mkdir "../${LLVM_SOURCES_DIR}/libcxx/include/__support/qnx" || exit 1  | 
          |
| - | 318 | test -f "../${LLVM_SOURCES_DIR}/libcxx/include/__support/qnx/xlocale.h" || cp "${QNX_TARGET}/usr/include/c++/v1/__support/qnx/xlocale.h" "../${LLVM_SOURCES_DIR}/libcxx/include/__support/qnx/xlocale.h" || exit 1  | 
          |
| - | 319 | ||
| - | 320 | # patch libcxx/include/locale | 
          |
| - | 321 | # replace [!defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__)] with [!defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__) && !defined(__QNX__)] | 
          |
| - | 322 | # RATIONALE: QNX doesn't have catopen() to open a "message catalog" | 
          |
| - | 323 | backup_and_patch_if_necessary "libcxx/include/locale" __QNXNTO__ \ | 
          |
| - | 324 |         's/\!defined\(__BIONIC__\) \&\& \!defined\(_NEWLIB_VERSION\) \&\& \!defined\(__EMSCRIPTEN__\)/\!defined\(__BIONIC__\) \&\& \!defined\(_NEWLIB_VERSION\) \&\& \!defined\(__EMSCRIPTEN__\) \&\& \!defined\(__QNX__\)/g' | 
          |
| 283 | 325 | ||
| 284 | # now configure LLVM -- and use ccache | 
            326 | # now configure LLVM -- and use ccache | 
          
| - | 327 | # TAKE NOTE: THE VALUE OF LIBCXX*_ADDITIONAL_COMPILE_FLAGS CAN ONLY HAVE ONE FLAG! It is passed by CMake surrounded by quotes to the compiler, e.g. -Dflag "-Dflag1 -Dflag2" -Dflag which is WRONG. | 
          |
| 285 | echo "Configuring LLVM build..."  | 
            328 | echo "Configuring LLVM build..."  | 
          
| 286 | export CCACHE_DIR="$(realpath "../${LLVM_SOURCES_DIR}/.ccache")"  | 
            329 | export CCACHE_DIR="$(realpath "../${LLVM_SOURCES_DIR}/.ccache")"  | 
          
| 287 | cmake \  | 
            330 | cmake \  | 
          
| 288 | -D CMAKE_TOOLCHAIN_FILE="${TARGET_TRIPLE}.cmake" \  | 
            331 | -D CMAKE_TOOLCHAIN_FILE="${TARGET_TRIPLE}.cmake" \  | 
          
| 289 | -D CMAKE_BUILD_TYPE="MinSizeRel" \  | 
            332 | -D CMAKE_BUILD_TYPE="MinSizeRel" \  | 
          
| Line 294... | Line 337... | ||
| 294 | -D LLVM_HOST_TRIPLE="${TARGET_TRIPLE}" \  | 
            337 | -D LLVM_HOST_TRIPLE="${TARGET_TRIPLE}" \  | 
          
| 295 | -D LLVM_ENABLE_PROJECTS="clang;lld" \  | 
            338 | -D LLVM_ENABLE_PROJECTS="clang;lld" \  | 
          
| 296 | -D LLVM_ENABLE_RUNTIMES="compiler-rt;libcxx;libcxxabi;libunwind" \  | 
            339 | -D LLVM_ENABLE_RUNTIMES="compiler-rt;libcxx;libcxxabi;libunwind" \  | 
          
| 297 | -D LLVM_TARGETS_TO_BUILD="AArch64;X86" \  | 
            340 | -D LLVM_TARGETS_TO_BUILD="AArch64;X86" \  | 
          
| 298 | -D COMPILER_RT_BUILD_SANITIZERS="OFF" \  | 
            341 | -D COMPILER_RT_BUILD_SANITIZERS="OFF" \  | 
          
| - | 342 | -D LIBCXX_ADDITIONAL_COMPILE_FLAGS="-D_QNX_SOURCE=1" \  | 
          |
| - | 343 | -D LIBCXXABI_ADDITIONAL_COMPILE_FLAGS="-D_QNX_SOURCE=1" \  | 
          |
| 299 |     -G Ninja \ | 
            344 |     -G Ninja \ | 
          
| 300 | "../${LLVM_SOURCES_DIR}/llvm" || exit 1  | 
            345 | "../${LLVM_SOURCES_DIR}/llvm" || exit 1  | 
          
| 301 | 346 | ||
| 302 | # hijack the "bin" and "lib/clang" output directories and redirect them to the hypervisor's filesystem | 
            347 | # hijack the "bin" and "lib/clang" output directories and redirect them to the hypervisor's filesystem | 
          
| 303 | test -e "${CURRENT_DIR}/llvm-build" && rm -rf "${CURRENT_DIR}/llvm-build"  | 
            348 | test -e "${CURRENT_DIR}/llvm-build" && rm -rf "${CURRENT_DIR}/llvm-build"  | 
          
| Line 310... | Line 355... | ||
| 310 | 355 | ||
| 311 | # and do the Lord's work. https://youtu.be/jcyYmCnkbEE | 
            356 | # and do the Lord's work. https://youtu.be/jcyYmCnkbEE | 
          
| 312 | echo "Building LLVM..."  | 
            357 | echo "Building LLVM..."  | 
          
| 313 | cmake --build . || exit 1  | 
            358 | cmake --build . || exit 1  | 
          
| 314 | 359 | ||
| - | 360 | # TODO: port lldb bindings | 
          |
| - | 361 | # TODO: port compiler_rt sanitizer bindings | 
          |
| 315 | echo "Champagne, James. Champagne."  | 
            362 | echo "Champagne, James. Champagne."  | 
          
| 316 | exit 0  | 
            363 | exit 0  |