Rev 29 | Rev 34 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 29 | Rev 33 | ||
---|---|---|---|
Line 14... | Line 14... | ||
14 | export LLVM_VERSION="16.0.6" # version of LLVM that will be built (ideally the same version as the libc++ supplied by QNX in their platform SDK) |
14 | export LLVM_VERSION="16.0.6" # version of LLVM that will be built (ideally the same version as the libc++ supplied by QNX in their platform SDK) |
15 | export LLVM_SOURCES_FILE="llvmorg-${LLVM_VERSION}.tar.gz" # name of the file containing LLVM version LLVM_VERSION sources |
15 | export LLVM_SOURCES_FILE="llvmorg-${LLVM_VERSION}.tar.gz" # name of the file containing LLVM version LLVM_VERSION sources |
16 | export LLVM_SOURCES_URL="https://github.com/llvm/llvm-project/archive/refs/tags/${LLVM_SOURCES_FILE}" # download URL of LLVM_SOURCES_FILE |
16 | export LLVM_SOURCES_URL="https://github.com/llvm/llvm-project/archive/refs/tags/${LLVM_SOURCES_FILE}" # download URL of LLVM_SOURCES_FILE |
17 | export LLVM_SOURCES_DIR="llvm-project-llvmorg-${LLVM_VERSION}" # name of directory created when extracting LLVM_SOURCES_FILE |
17 | export LLVM_SOURCES_DIR="llvm-project-llvmorg-${LLVM_VERSION}" # name of directory created when extracting LLVM_SOURCES_FILE |
18 | 18 | ||
19 | export LLVM_PROJECTS_TO_BUILD="clang |
19 | export LLVM_PROJECTS_TO_BUILD="clang;lld;polly" # semicolon-separated list of LLVM projects to build (full list: "clang;clang-tools-extra;cross-project-tests;libc;libclc;lld;lldb;openmp;polly;pstl") |
20 | export LLVM_RUNTIMES_TO_BUILD="compiler-rt" # semicolon-separated list of LLVM runtimes to build (full list: "compiler-rt;libc;libcxx;libcxxabi;libunwind;openmp") |
20 | export LLVM_RUNTIMES_TO_BUILD="compiler-rt" # semicolon-separated list of LLVM runtimes to build (full list: "compiler-rt;libc;libcxx;libcxxabi;libunwind;openmp") |
21 | export LLVM_BUILD_CONFIGURATION_TYPE="MinSizeRel" # build configuration, one of "Debug", "Release", "RelWithDebugInfo" or "MinSizeRel" |
21 | export LLVM_BUILD_CONFIGURATION_TYPE="MinSizeRel" # build configuration, one of "Debug", "Release", "RelWithDebugInfo" or "MinSizeRel" |
22 | 22 | ||
23 | export REQUIRED_TOOLS="wget python3 cmake gcc g++ ninja ccache" # list of build tools required to build all this on the build host |
23 | export REQUIRED_TOOLS="wget python3 cmake gcc g++ ninja ccache" # list of build tools required to build all this on the build host |
24 | 24 | ||
Line 501... | Line 501... | ||
501 | -D LLVM_HOST_TRIPLE="${TARGET_TRIPLE}" \ |
501 | -D LLVM_HOST_TRIPLE="${TARGET_TRIPLE}" \ |
502 | -D LLVM_ENABLE_PROJECTS="${LLVM_PROJECTS_TO_BUILD}" \ |
502 | -D LLVM_ENABLE_PROJECTS="${LLVM_PROJECTS_TO_BUILD}" \ |
503 | -D LLVM_ENABLE_RUNTIMES="${LLVM_RUNTIMES_TO_BUILD}" \ |
503 | -D LLVM_ENABLE_RUNTIMES="${LLVM_RUNTIMES_TO_BUILD}" \ |
504 | -D LLVM_TARGETS_TO_BUILD="AArch64;X86" \ |
504 | -D LLVM_TARGETS_TO_BUILD="AArch64;X86" \ |
505 | -D DEFAULT_SYSROOT="../../../../../${QNXSDK_TARGETPATH}/${BUILD_TARGET_ARCH}" \ |
505 | -D DEFAULT_SYSROOT="../../../../../${QNXSDK_TARGETPATH}/${BUILD_TARGET_ARCH}" \ |
506 | -D CLANG_DEFAULT_LINKER=" |
506 | -D CLANG_DEFAULT_LINKER="ld" \ |
507 | -D CLANG_DEFAULT_CXX_STDLIB="libc++" \ |
507 | -D CLANG_DEFAULT_CXX_STDLIB="libc++" \ |
508 | -D COMPILER_RT_BUILD_SANITIZERS="OFF" \ |
508 | -D COMPILER_RT_BUILD_SANITIZERS="OFF" \ |
509 | -D COMPILER_RT_BUILD_XRAY="OFF" \ |
509 | -D COMPILER_RT_BUILD_XRAY="OFF" \ |
510 | -D COMPILER_RT_BUILD_MEMPROF="OFF" \ |
510 | -D COMPILER_RT_BUILD_MEMPROF="OFF" \ |
511 | -D COMPILER_RT_BUILD_LIBFUZZER="OFF" \ |
511 | -D COMPILER_RT_BUILD_LIBFUZZER="OFF" \ |
Line 517... | Line 517... | ||
517 | echo "Building LLVM..." |
517 | echo "Building LLVM..." |
518 | cmake --build . --target install || exit 1 |
518 | cmake --build . --target install || exit 1 |
519 | 519 | ||
520 | test -z "${WSL_DISTRO_NAME}" && /bin/printf "\n\xF0\x9F\x8D\xBE\x20\x43\x68\x61\x6d\x70\x61\x67\x6e\x65\x2e\n" |
520 | test -z "${WSL_DISTRO_NAME}" && /bin/printf "\n\xF0\x9F\x8D\xBE\x20\x43\x68\x61\x6d\x70\x61\x67\x6e\x65\x2e\n" |
521 | exit 0 |
521 | exit 0 |
- | 522 | ||
- | 523 | # NOTE: LLD might not produce usable executables on QNX without a GNU LD-compatible linker script (-T option) that defines |
|
- | 524 | # the *SAME* program headers as those generated by the GNU linker! (PHDRS directive). QNX is particularly picky on the layout |
|
- | 525 | # of loadable segments (PT_LOAD): whereas GNU ld generate usually two (one for code, one for data), LLD generates a lot more, |
|
- | 526 | # with different access permissions - and while this is technically correct ELF format (and even more secure), this unusual |
|
- | 527 | # program header layout can be refused by QNX ("can't load xxx: exec format error"). Same if you use ld with '-z separate-code'. |
|
- | 528 | # Also, it is likely that GCC's crti.o/crtn.o being filtered out by LLD from the output executables prevent them to run on QNX. |
|
- | 529 | # https://stackoverflow.com/questions/18091463/why-does-an-assembly-program-only-work-when-linked-with-crt1-o-crti-o-and-crtn-o |
|
522 | 530 | ||
523 | # TODO optional: port compiler_rt sanitizer bindings and build sanitizers, xray, memprof, libfuzzer and profile |
531 | # TODO optional: port compiler_rt sanitizer bindings and build sanitizers, xray, memprof, libfuzzer and profile |
524 | # TODO optional: port lldb bindings and build lldb |
532 | # TODO optional: port lldb bindings and build lldb (implement ptrace) |