diff --git a/.github/workflows/vcpkg_ci_aws_amd64.yml b/.github/workflows/vcpkg_ci_aws_amd64.yml index 6c8658a6..d4773aa0 100644 --- a/.github/workflows/vcpkg_ci_aws_amd64.yml +++ b/.github/workflows/vcpkg_ci_aws_amd64.yml @@ -68,7 +68,7 @@ jobs: - { name: 'ubuntu-20.04', arch: 'amd64', triplet: 'x64-linux-rel', arch_docker: '' } image: - { name: 'ubuntu', tag: '20.04' } - llvm: [ 'llvm-13', 'llvm-14' ] + llvm: [ 'llvm-14', 'llvm-15' ] container: image: docker.pkg.github.com/lifting-bits/cxx-common/vcpkg-builder-${{ matrix.image.name }}:${{ matrix.image.tag }}${{ matrix.host.arch_docker }} @@ -204,7 +204,7 @@ jobs: scripts/roundtrip.py ${INSTALL_DIR}/install/bin/rellic-decomp* $(pwd)/tests/tools/decomp "${VCPKG_ROOT}/installed/${{ matrix.host.triplet }}/tools/llvm/clang" - name: 'Remill build' - # if: ${{ matrix.llvm == 'llvm-13' }} + if: ${{ matrix.llvm == 'llvm-14' }} shell: 'bash' run: | cd remill @@ -217,7 +217,7 @@ jobs: popd - name: 'Anvill build' - # if: ${{ matrix.llvm == 'llvm-13' }} + if: ${{ matrix.llvm == 'llvm-14' }} shell: 'bash' run: | cd anvill diff --git a/.github/workflows/vcpkg_ci_aws_arm64.yml b/.github/workflows/vcpkg_ci_aws_arm64.yml index 397cd40b..8a725dca 100644 --- a/.github/workflows/vcpkg_ci_aws_arm64.yml +++ b/.github/workflows/vcpkg_ci_aws_arm64.yml @@ -68,7 +68,7 @@ jobs: - { name: 'ubuntu-20.04', arch: 'arm64', triplet: 'arm64-linux-rel', arch_docker: '_arm64' } image: - { name: 'ubuntu', tag: '20.04' } - llvm: [ 'llvm-13', 'llvm-14' ] + llvm: [ 'llvm-14', 'llvm-15' ] container: image: docker.pkg.github.com/lifting-bits/cxx-common/vcpkg-builder-${{ matrix.image.name }}:${{ matrix.image.tag }}${{ matrix.host.arch_docker }} @@ -212,7 +212,7 @@ jobs: scripts/roundtrip.py ${INSTALL_DIR}/install/bin/rellic-decomp* $(pwd)/tests/tools/decomp "${VCPKG_ROOT}/installed/${{ matrix.host.triplet }}/tools/llvm/clang" - name: 'Remill build' - # if: ${{ matrix.llvm == 'llvm-13' }} + if: ${{ matrix.llvm == 'llvm-14' }} shell: 'bash' run: | cd remill @@ -225,7 +225,7 @@ jobs: popd - name: 'Anvill build' - # if: ${{ matrix.llvm == 'llvm-13' }} + if: ${{ matrix.llvm == 'llvm-14' }} shell: 'bash' run: | cd anvill diff --git a/.github/workflows/vcpkg_ci_mac.yml b/.github/workflows/vcpkg_ci_mac.yml index ad91e773..d9b67f97 100644 --- a/.github/workflows/vcpkg_ci_mac.yml +++ b/.github/workflows/vcpkg_ci_mac.yml @@ -35,8 +35,8 @@ jobs: os: - { runner: 'macos-11', xcode: '13.0' } llvm: [ - 'llvm-13', - 'llvm-14' + 'llvm-14', + 'llvm-15' ] runs-on: ${{ matrix.os.runner }} @@ -165,7 +165,7 @@ jobs: - name: 'Remill build' shell: 'bash' - # if: ${{ matrix.llvm == 'llvm-13' }} + if: ${{ matrix.llvm == 'llvm-14' }} run: | cd remill mkdir -p build && cd build @@ -182,7 +182,7 @@ jobs: - name: 'Anvill build' shell: 'bash' - #if: ${{ matrix.llvm == 'llvm-13' }} + if: ${{ matrix.llvm == 'llvm-14' }} run: | cd anvill mkdir -p build && cd build diff --git a/.github/workflows/vcpkg_ci_windows.yml b/.github/workflows/vcpkg_ci_windows.yml index 24b5424e..ff4fe92e 100644 --- a/.github/workflows/vcpkg_ci_windows.yml +++ b/.github/workflows/vcpkg_ci_windows.yml @@ -35,8 +35,8 @@ jobs: fail-fast: false matrix: llvm: [ - 'llvm-13', - 'llvm-14' + 'llvm-14', + 'llvm-15' ] runs-on: ['self-hosted', 'Windows', 'X64'] @@ -151,7 +151,7 @@ jobs: # python ../scripts/roundtrip.py ( Get-ChildItem tools | Where-Object {$_.name -match "rellic-decomp.exe"} ) ..\tests\tools\decomp "${env:VCPKG_ROOT}\installed\${env:TRIPLET}\tools\${{ matrix.llvm }}\clang.exe" - name: 'Test remill build' - # if: ${{ matrix.llvm == 'llvm-13' }} + # if: ${{ matrix.llvm == 'llvm-14' }} run: | cd remill Remove-Item -Recurse -Force -ErrorAction SilentlyContinue .\build @@ -174,7 +174,7 @@ jobs: # env CTEST_OUTPUT_ON_FAILURE=1 cmake --build . --target test || true - name: 'Anvill build' - if: ${{ matrix.llvm == 'llvm-13' }} + # if: ${{ matrix.llvm == 'llvm-14' }} run: | cd anvill Remove-Item -Recurse -Force -ErrorAction SilentlyContinue .\build diff --git a/README.md b/README.md index ac3ab553..e1006039 100644 --- a/README.md +++ b/README.md @@ -15,14 +15,14 @@ Many of the lifting-bits tools have support for using the vcpkg binaries written For example: ```bash -curl -LO https://github.com/lifting-bits/cxx-common/releases/latest/download/vcpkg_ubuntu-20.04_llvm-13_amd64.tar.xz -tar -xJf vcpkg_ubuntu-20.04_llvm-13_amd64.tar.xz +curl -LO https://github.com/lifting-bits/cxx-common/releases/latest/download/vcpkg_ubuntu-20.04_llvm-14_amd64.tar.xz +tar -xJf vcpkg_ubuntu-20.04_llvm-14_amd64.tar.xz ``` Will produce a directory, and then you'll have to set the following during your CMake configure command to use these dependencies! ```text --DCMAKE_TOOLCHAIN_FILE="<...>/vcpkg_ubuntu-20.04_llvm-13_amd64/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x64-linux-rel +-DCMAKE_TOOLCHAIN_FILE="<...>/vcpkg_ubuntu-20.04_llvm-14_amd64/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x64-linux-rel ``` Replace `x64-linux-rel` with `x64-osx-rel` if using the macOS pre-built download. @@ -31,10 +31,10 @@ Replace `x64-linux-rel` with `x64-osx-rel` if using the macOS pre-built download If you aren't running a supported operating system, or you want to have dependencies with a build type other than `Release`, you can build everything from source using the `./build_dependencies.sh` script (pass `--help` to see available options). -By default, the script will install the dependencies listed in [`dependencies.txt`](./dependencies.txt), which doesn't include an LLVM version, so passing an `llvm-13` string as an argument will actually be passed to [`vcpkg install`](https://github.com/microsoft/vcpkg/blob/master/docs/examples/installing-and-using-packages.md#install). Any other strings not matching the script's own options are also passed to the `vcpkg install` command. Furthermore, without specifying any other build script options, vcpkg determine determine the best triplet for your operating system, which means building _both_ `Debug` and `Release` build types (see the [vcpkg triplet docs](https://github.com/microsoft/vcpkg/blob/master/docs/users/triplets.md) for more info). +By default, the script will install the dependencies listed in [`dependencies.txt`](./dependencies.txt), which doesn't include an LLVM version, so passing an `llvm-14` string as an argument will actually be passed to [`vcpkg install`](https://github.com/microsoft/vcpkg/blob/master/docs/examples/installing-and-using-packages.md#install). Any other strings not matching the script's own options are also passed to the `vcpkg install` command. Furthermore, without specifying any other build script options, vcpkg determine determine the best triplet for your operating system, which means building _both_ `Debug` and `Release` build types (see the [vcpkg triplet docs](https://github.com/microsoft/vcpkg/blob/master/docs/users/triplets.md) for more info). ```bash -./build_dependencies.sh llvm-13 +./build_dependencies.sh llvm-14 ``` Note that vcpkg will use binary caching to store built dependency packages (usually at `~/.cache/vcpkg` or manually set with environment variable `VCPKG_DEFAULT_BINARY_CACHE`) so that upon reinstallation/rebuilding (re-running the script) you likely won't have to rebuild everything from scratch, unless the package itself has been updated, you are using a different vcpkg triplet, your compiler has been changed/update, or any of the vcpkg scripts have changed (updated vcpkg repo). If you'd like to turn off [binary caching](https://github.com/microsoft/vcpkg/blob/master/docs/users/binarycaching.md) (not recommended), then you can either pass `--no-binarycaching` to the build script after the main options listed in or add `-binarycaching` to the `VCPKG_FEATURE_FLAGS` environment variable. @@ -46,25 +46,25 @@ Note that vcpkg will use binary caching to store built dependency packages (usua Passing `--export-dir ` to the `./build_dependencies.sh` script, you can install the chosen dependencies in a separate directory. Otherwise, the built dependencies will be stored within the vcpkg repo directory itself (`vcpkg/installed` relative path if in the root of this repo). Separate export directories are required to keep track of different LLVM versions, since they cannot coexist within the same export (read: installation) directory. ```bash -./build_dependencies.sh --export-dir vcpkg-llvm-13-install llvm-13 +./build_dependencies.sh --export-dir vcpkg-llvm-14-install llvm-14 ``` -will build all of the dependencies listed in `dependencies.txt` _and_ LLVM 13 and install into a local directory named `vcpkg-llvm-13-install`. +will build all of the dependencies listed in `dependencies.txt` _and_ LLVM 14 and install into a local directory named `vcpkg-llvm-14-install`. Furthermore, you are able to install additional dependencies into an existing exported directory created by this script by setting the `--export-dir ` to the same path: ```bash -./build_dependencies.sh --release --export-dir "<...>/vcpkg_ubuntu-20.04_llvm-13_amd64" spdlog +./build_dependencies.sh --release --export-dir "<...>/vcpkg_ubuntu-20.04_llvm-14_amd64" spdlog ``` When reusing the pre-built export directory downloaded from GitHub, you must specify `--release` (see the 'Debug and Release Builds' section below) to build only release binaries. You cannot use dependencies from different triplets. ### Debug and Release Builds -To build both debug and release versions with llvm-13, just run the following +To build both debug and release versions with llvm-14, just run the following ```bash -./build_dependencies.sh llvm-13 +./build_dependencies.sh llvm-14 ``` The script will be verbose about what it is doing and will clone the correct version of vcpkg (found in `vcpkg_info.txt`) and build everything in the `vcpkg` directory in the root of this repo. @@ -83,7 +83,7 @@ $ ./build_dependencies.sh --export-dir example-export-dir If you don't want to compile a debug version of the tools, just pass `--release` to the script. ```bash -$ ./build_dependencies.sh --release llvm-13 +$ ./build_dependencies.sh --release llvm-14 ... [+] Set the following in your CMake configure command to use these dependencies! [+] -DCMAKE_TOOLCHAIN_FILE="/Users/ekilmer/src/cxx-common/vcpkg/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x64-osx-rel -DVCPKG_HOST_TRIPLET=x64-osx-rel @@ -98,7 +98,7 @@ There is experimental support for compiling dependencies with address sanitizer These dependencies can be built with the script by passing `--asan` to the script, and it should work whether building only Release or both Debug and Release: ```bash -./build_dependencies.sh [--release] --asan llvm-13 +./build_dependencies.sh [--release] --asan llvm-14 ``` Just because your dependencies were built with a sanitizer, you'll still need to manually add support for sanitizer usage within your own project. A quick and dirty way involves specifying the extra compilation flags during CMake configure: @@ -163,4 +163,4 @@ This command will do similar things as the above command, except it will `remove This repo is under the Apache-2.0 LICENSE, unless where specified. See below. -The LLVM version port directories (ports/llvm-{13,14}) were initially copied from the upstream [vcpkg](https://github.com/microsoft/vcpkg) repo as a starting point. Eventually, we plan to submit the relevant patches for upstream when we have thoroughly tested these changes. More info can be found in the respective `LICENSE` and `NOTICE` files in those directories. +The LLVM version port directories (ports/llvm-{14,15}) were initially copied from the upstream [vcpkg](https://github.com/microsoft/vcpkg) repo as a starting point. Eventually, we plan to submit the relevant patches for upstream when we have thoroughly tested these changes. More info can be found in the respective `LICENSE` and `NOTICE` files in those directories. diff --git a/ports/llvm-13/0002-fix-install-paths.patch b/ports/llvm-13/0002-fix-install-paths.patch deleted file mode 100644 index 3582bcbf..00000000 --- a/ports/llvm-13/0002-fix-install-paths.patch +++ /dev/null @@ -1,138 +0,0 @@ - clang/cmake/modules/CMakeLists.txt | 4 ++-- - flang/cmake/modules/CMakeLists.txt | 4 ++-- - lld/cmake/modules/CMakeLists.txt | 4 ++-- - llvm/cmake/modules/AddLLVM.cmake | 2 +- - llvm/cmake/modules/CMakeLists.txt | 2 +- - mlir/cmake/modules/CMakeLists.txt | 4 ++-- - polly/cmake/CMakeLists.txt | 4 ++-- - pstl/CMakeLists.txt | 4 ++-- - 8 files changed, 14 insertions(+), 14 deletions(-) - -diff --git a/clang/cmake/modules/CMakeLists.txt b/clang/cmake/modules/CMakeLists.txt -index 561665d58cad..3c73878a4483 100644 ---- a/clang/cmake/modules/CMakeLists.txt -+++ b/clang/cmake/modules/CMakeLists.txt -@@ -3,11 +3,11 @@ include(LLVMDistributionSupport) - # Generate a list of CMake library targets so that other CMake projects can - # link against them. LLVM calls its version of this file LLVMExports.cmake, but - # the usual CMake convention seems to be ${Project}Targets.cmake. --set(CLANG_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/clang) -+set(CLANG_INSTALL_PACKAGE_DIR share/clang) - set(clang_cmake_builddir "${CMAKE_BINARY_DIR}/${CLANG_INSTALL_PACKAGE_DIR}") - - # Keep this in sync with llvm/cmake/CMakeLists.txt! --set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm) -+set(LLVM_INSTALL_PACKAGE_DIR share/llvm) - set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}") - - get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS) -diff --git a/flang/cmake/modules/CMakeLists.txt b/flang/cmake/modules/CMakeLists.txt -index e46498a6bc35..2e922f8ca89d 100644 ---- a/flang/cmake/modules/CMakeLists.txt -+++ b/flang/cmake/modules/CMakeLists.txt -@@ -1,11 +1,11 @@ - # Generate a list of CMake library targets so that other CMake projects can - # link against them. LLVM calls its version of this file LLVMExports.cmake, but - # the usual CMake convention seems to be ${Project}Targets.cmake. --set(FLANG_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/flang) -+set(FLANG_INSTALL_PACKAGE_DIR share/flang) - set(flang_cmake_builddir "${CMAKE_BINARY_DIR}/${FLANG_INSTALL_PACKAGE_DIR}") - - # Keep this in sync with llvm/cmake/CMakeLists.txt! --set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm) -+set(LLVM_INSTALL_PACKAGE_DIR share/llvm) - set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}") - - get_property(FLANG_EXPORTS GLOBAL PROPERTY FLANG_EXPORTS) -diff --git a/lld/cmake/modules/CMakeLists.txt b/lld/cmake/modules/CMakeLists.txt -index 62d03fa901dd..09b0f54ee8c3 100644 ---- a/lld/cmake/modules/CMakeLists.txt -+++ b/lld/cmake/modules/CMakeLists.txt -@@ -1,11 +1,11 @@ - # Generate a list of CMake library targets so that other CMake projects can - # link against them. LLVM calls its version of this file LLVMExports.cmake, but - # the usual CMake convention seems to be ${Project}Targets.cmake. --set(LLD_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/lld) -+set(LLD_INSTALL_PACKAGE_DIR share/lld) - set(lld_cmake_builddir "${CMAKE_BINARY_DIR}/${LLD_INSTALL_PACKAGE_DIR}") - - # Keep this in sync with llvm/cmake/CMakeLists.txt! --set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm) -+set(LLVM_INSTALL_PACKAGE_DIR share/llvm) - set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}") - - get_property(LLD_EXPORTS GLOBAL PROPERTY LLD_EXPORTS) -diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake -index 29e40f45fef8..e9094e9b8eb2 100644 ---- a/llvm/cmake/modules/AddLLVM.cmake -+++ b/llvm/cmake/modules/AddLLVM.cmake -@@ -1033,7 +1033,7 @@ function(process_llvm_pass_plugins) - - ## Part 1: Extension header to be included whenever we need extension - # processing. -- set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm) -+ set(LLVM_INSTALL_PACKAGE_DIR share/llvm) - set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}") - file(WRITE - "${llvm_cmake_builddir}/LLVMConfigExtensions.cmake" -diff --git a/llvm/cmake/modules/CMakeLists.txt b/llvm/cmake/modules/CMakeLists.txt -index 51b6a4fdc284..a818de2e116c 100644 ---- a/llvm/cmake/modules/CMakeLists.txt -+++ b/llvm/cmake/modules/CMakeLists.txt -@@ -1,6 +1,6 @@ - include(LLVMDistributionSupport) - --set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm) -+set(LLVM_INSTALL_PACKAGE_DIR share/llvm) - set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}") - - # First for users who use an installed LLVM, create the LLVMExports.cmake file. -diff --git a/mlir/cmake/modules/CMakeLists.txt b/mlir/cmake/modules/CMakeLists.txt -index 65efc4a14987..7c3213ab0c2b 100644 ---- a/mlir/cmake/modules/CMakeLists.txt -+++ b/mlir/cmake/modules/CMakeLists.txt -@@ -3,11 +3,11 @@ include(LLVMDistributionSupport) - # Generate a list of CMake library targets so that other CMake projects can - # link against them. LLVM calls its version of this file LLVMExports.cmake, but - # the usual CMake convention seems to be ${Project}Targets.cmake. --set(MLIR_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/mlir) -+set(MLIR_INSTALL_PACKAGE_DIR share/mlir) - set(mlir_cmake_builddir "${CMAKE_BINARY_DIR}/${MLIR_INSTALL_PACKAGE_DIR}") - - # Keep this in sync with llvm/cmake/CMakeLists.txt! --set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm) -+set(LLVM_INSTALL_PACKAGE_DIR share/llvm) - set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}") - - get_property(MLIR_EXPORTS GLOBAL PROPERTY MLIR_EXPORTS) -diff --git a/polly/cmake/CMakeLists.txt b/polly/cmake/CMakeLists.txt -index 7cc129ba2e90..9776391cd535 100644 ---- a/polly/cmake/CMakeLists.txt -+++ b/polly/cmake/CMakeLists.txt -@@ -1,7 +1,7 @@ - # Keep this in sync with llvm/cmake/CMakeLists.txt! - --set(LLVM_INSTALL_PACKAGE_DIR "lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm") --set(POLLY_INSTALL_PACKAGE_DIR "lib${LLVM_LIBDIR_SUFFIX}/cmake/polly") -+set(LLVM_INSTALL_PACKAGE_DIR share/llvm) -+set(POLLY_INSTALL_PACKAGE_DIR share/polly) - if (CMAKE_CONFIGURATION_TYPES) - set(POLLY_EXPORTS_FILE_NAME "PollyExports-$>.cmake") - else() -diff --git a/pstl/CMakeLists.txt b/pstl/CMakeLists.txt -index 8bea8843589b..3658c0a4414a 100644 ---- a/pstl/CMakeLists.txt -+++ b/pstl/CMakeLists.txt -@@ -81,10 +81,10 @@ install(TARGETS ParallelSTL - install(EXPORT ParallelSTLTargets - FILE ParallelSTLTargets.cmake - NAMESPACE pstl:: -- DESTINATION lib/cmake/ParallelSTL) -+ DESTINATION share/ParallelSTL) - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfig.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfigVersion.cmake" -- DESTINATION lib/cmake/ParallelSTL) -+ DESTINATION share/ParallelSTL) - install(DIRECTORY include/ - DESTINATION include - PATTERN "*.in" EXCLUDE) diff --git a/ports/llvm-13/0003-fix-openmp-debug.patch b/ports/llvm-13/0003-fix-openmp-debug.patch deleted file mode 100644 index 3eff4fa5..00000000 --- a/ports/llvm-13/0003-fix-openmp-debug.patch +++ /dev/null @@ -1,25 +0,0 @@ - openmp/runtime/src/CMakeLists.txt | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/openmp/runtime/src/CMakeLists.txt b/openmp/runtime/src/CMakeLists.txt -index bdb867e352f7..16a13fa959ea 100644 ---- a/openmp/runtime/src/CMakeLists.txt -+++ b/openmp/runtime/src/CMakeLists.txt -@@ -159,7 +159,7 @@ else() - endif() - - set_target_properties(omp PROPERTIES -- PREFIX "" SUFFIX "" OUTPUT_NAME "${LIBOMP_LIB_FILE}" -+ PREFIX "" SUFFIX "" OUTPUT_NAME "${LIBOMP_LIB_FILE}" DEBUG_POSTFIX "" - LINK_FLAGS "${LIBOMP_CONFIGURED_LDFLAGS}" - LINKER_LANGUAGE ${LIBOMP_LINKER_LANGUAGE} - ) -@@ -236,7 +236,7 @@ if(WIN32) - # Create new import library that is just the previously created one + kmp_import.cpp - add_library(ompimp STATIC ${LIBOMP_GENERATED_IMP_LIB} kmp_import.cpp) - set_target_properties(ompimp PROPERTIES -- PREFIX "" SUFFIX "" OUTPUT_NAME "${LIBOMP_IMP_LIB_FILE}" -+ PREFIX "" SUFFIX "" OUTPUT_NAME "${LIBOMP_IMP_LIB_FILE}" DEBUG_POSTFIX "" - LINKER_LANGUAGE C - ) - add_dependencies(ompimp omp) # ensure generated import library is created first diff --git a/ports/llvm-13/0009-fix-tools-install-path.patch b/ports/llvm-13/0009-fix-tools-install-path.patch deleted file mode 100644 index bfc5c5fc..00000000 --- a/ports/llvm-13/0009-fix-tools-install-path.patch +++ /dev/null @@ -1,184 +0,0 @@ - clang-tools-extra/modularize/CMakeLists.txt | 2 +- - clang/cmake/modules/AddClang.cmake | 2 +- - clang/tools/c-index-test/CMakeLists.txt | 2 +- - clang/tools/clang-format/CMakeLists.txt | 2 +- - clang/tools/scan-build/CMakeLists.txt | 2 +- - clang/tools/scan-view/CMakeLists.txt | 2 +- - clang/utils/hmaptool/CMakeLists.txt | 2 +- - flang/cmake/modules/AddFlang.cmake | 2 +- - flang/tools/f18/CMakeLists.txt | 4 ++-- - flang/tools/flang-driver/CMakeLists.txt | 2 +- - lld/cmake/modules/AddLLD.cmake | 2 +- - lld/tools/lld/CMakeLists.txt | 2 +- - lldb/cmake/modules/AddLLDB.cmake | 2 +- - 13 files changed, 14 insertions(+), 14 deletions(-) - -diff --git a/clang-tools-extra/modularize/CMakeLists.txt b/clang-tools-extra/modularize/CMakeLists.txt -index 4caae81c49b6..8c459c51cc34 100644 ---- a/clang-tools-extra/modularize/CMakeLists.txt -+++ b/clang-tools-extra/modularize/CMakeLists.txt -@@ -23,5 +23,5 @@ clang_target_link_libraries(modularize - ) - - install(TARGETS modularize -- RUNTIME DESTINATION bin -+ RUNTIME DESTINATION tools/llvm - COMPONENT clang-extras) -diff --git a/clang/cmake/modules/AddClang.cmake b/clang/cmake/modules/AddClang.cmake -index 5752f4277444..00b7d21b8fef 100644 ---- a/clang/cmake/modules/AddClang.cmake -+++ b/clang/cmake/modules/AddClang.cmake -@@ -159,7 +159,7 @@ macro(add_clang_tool name) - get_target_export_arg(${name} Clang export_to_clangtargets) - install(TARGETS ${name} - ${export_to_clangtargets} -- RUNTIME DESTINATION bin -+ RUNTIME DESTINATION tools/llvm - COMPONENT ${name}) - - if(NOT LLVM_ENABLE_IDE) -diff --git a/clang/tools/c-index-test/CMakeLists.txt b/clang/tools/c-index-test/CMakeLists.txt -index ceef4b08637c..ce6d7799475b 100644 ---- a/clang/tools/c-index-test/CMakeLists.txt -+++ b/clang/tools/c-index-test/CMakeLists.txt -@@ -54,7 +54,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) - set_property(TARGET c-index-test APPEND PROPERTY INSTALL_RPATH - "@executable_path/../../lib") - else() -- set(INSTALL_DESTINATION bin) -+ set(INSTALL_DESTINATION tools/llvm) - endif() - - install(TARGETS c-index-test -diff --git a/clang/tools/clang-format/CMakeLists.txt b/clang/tools/clang-format/CMakeLists.txt -index 35ecdb11253c..d1b800dfdadc 100644 ---- a/clang/tools/clang-format/CMakeLists.txt -+++ b/clang/tools/clang-format/CMakeLists.txt -@@ -36,5 +36,5 @@ install(PROGRAMS clang-format.py - DESTINATION share/clang - COMPONENT clang-format) - install(PROGRAMS git-clang-format -- DESTINATION bin -+ DESTINATION tools/llvm - COMPONENT clang-format) -diff --git a/clang/tools/scan-build/CMakeLists.txt b/clang/tools/scan-build/CMakeLists.txt -index ec0702d76f18..9a34a09921b1 100644 ---- a/clang/tools/scan-build/CMakeLists.txt -+++ b/clang/tools/scan-build/CMakeLists.txt -@@ -47,7 +47,7 @@ if(CLANG_INSTALL_SCANBUILD) - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile}) - list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile}) - install(PROGRAMS bin/${BinFile} -- DESTINATION bin -+ DESTINATION tools/llvm - COMPONENT scan-build) - endforeach() - -diff --git a/clang/tools/scan-view/CMakeLists.txt b/clang/tools/scan-view/CMakeLists.txt -index eccc6b83195b..232976c0c227 100644 ---- a/clang/tools/scan-view/CMakeLists.txt -+++ b/clang/tools/scan-view/CMakeLists.txt -@@ -20,7 +20,7 @@ if(CLANG_INSTALL_SCANVIEW) - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile}) - list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile}) - install(PROGRAMS bin/${BinFile} -- DESTINATION bin -+ DESTINATION tools/llvm - COMPONENT scan-view) - endforeach() - -diff --git a/clang/utils/hmaptool/CMakeLists.txt b/clang/utils/hmaptool/CMakeLists.txt -index 62f2de0cb15c..38dc821c76de 100644 ---- a/clang/utils/hmaptool/CMakeLists.txt -+++ b/clang/utils/hmaptool/CMakeLists.txt -@@ -10,7 +10,7 @@ add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/${CLANG_HM - - list(APPEND Depends ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/${CLANG_HMAPTOOL}) - install(PROGRAMS ${CLANG_HMAPTOOL} -- DESTINATION bin -+ DESTINATION tools/llvm - COMPONENT hmaptool) - - add_custom_target(hmaptool ALL DEPENDS ${Depends}) -diff --git a/flang/cmake/modules/AddFlang.cmake b/flang/cmake/modules/AddFlang.cmake -index 5da58a59ed12..c019d7fc50a9 100644 ---- a/flang/cmake/modules/AddFlang.cmake -+++ b/flang/cmake/modules/AddFlang.cmake -@@ -108,7 +108,7 @@ macro(add_flang_tool name) - get_target_export_arg(${name} Flang export_to_flangtargets) - install(TARGETS ${name} - ${export_to_flangtargets} -- RUNTIME DESTINATION bin -+ RUNTIME DESTINATION tools/llvm - COMPONENT ${name}) - - if(NOT LLVM_ENABLE_IDE) -diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt -index 239859b5e5b9..12d00f904f8a 100644 ---- a/flang/tools/f18/CMakeLists.txt -+++ b/flang/tools/f18/CMakeLists.txt -@@ -60,7 +60,7 @@ endforeach() - - add_custom_target(module_files ALL DEPENDS ${MODULE_FILES}) - --install(TARGETS f18 DESTINATION bin) -+install(TARGETS f18 DESTINATION tools/llvm) - - set(FLANG_DEFAULT_DRIVER "flang-new") - if (NOT FLANG_BUILD_NEW_DRIVER) -@@ -70,5 +70,5 @@ endif() - # This flang shell script will only work in a POSIX shell. - if (NOT WIN32) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/flang.in ${CMAKE_BINARY_DIR}/bin/flang @ONLY) -- install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/flang DESTINATION bin) -+ install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/flang DESTINATION tools/llvm) - endif() -diff --git a/flang/tools/flang-driver/CMakeLists.txt b/flang/tools/flang-driver/CMakeLists.txt -index 4c7ad220d223..f4206913e76f 100644 ---- a/flang/tools/flang-driver/CMakeLists.txt -+++ b/flang/tools/flang-driver/CMakeLists.txt -@@ -27,4 +27,4 @@ clang_target_link_libraries(flang-new - clangBasic - ) - --install(TARGETS flang-new DESTINATION bin) -+install(TARGETS flang-new DESTINATION tools/llvm) -diff --git a/lld/cmake/modules/AddLLD.cmake b/lld/cmake/modules/AddLLD.cmake -index 9883475d1aa5..48e46586f387 100644 ---- a/lld/cmake/modules/AddLLD.cmake -+++ b/lld/cmake/modules/AddLLD.cmake -@@ -46,7 +46,7 @@ macro(add_lld_tool name) - get_target_export_arg(${name} LLD export_to_lldtargets) - install(TARGETS ${name} - ${export_to_lldtargets} -- RUNTIME DESTINATION bin -+ RUNTIME DESTINATION tools/llvm - COMPONENT ${name}) - - if(NOT CMAKE_CONFIGURATION_TYPES) -diff --git a/lld/tools/lld/CMakeLists.txt b/lld/tools/lld/CMakeLists.txt -index e77b2161a873..b325b934640c 100644 ---- a/lld/tools/lld/CMakeLists.txt -+++ b/lld/tools/lld/CMakeLists.txt -@@ -21,7 +21,7 @@ target_link_libraries(lld - ) - - install(TARGETS lld -- RUNTIME DESTINATION bin) -+ RUNTIME DESTINATION tools/llvm) - - if(NOT LLD_SYMLINKS_TO_CREATE) - set(LLD_SYMLINKS_TO_CREATE -diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake -index 8be214a8509a..4a5d0fa39be3 100644 ---- a/lldb/cmake/modules/AddLLDB.cmake -+++ b/lldb/cmake/modules/AddLLDB.cmake -@@ -187,7 +187,7 @@ function(add_lldb_executable name) - endif() - - if(ARG_GENERATE_INSTALL) -- set(install_dest bin) -+ set(install_dest tools/llvm) - if(ARG_INSTALL_PREFIX) - set(install_dest ${ARG_INSTALL_PREFIX}) - endif() diff --git a/ports/llvm-13/0010-fix-libffi.patch b/ports/llvm-13/0010-fix-libffi.patch deleted file mode 100644 index 93d0cb4d..00000000 --- a/ports/llvm-13/0010-fix-libffi.patch +++ /dev/null @@ -1,16 +0,0 @@ - llvm/cmake/config-ix.cmake | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake -index dd0aaadb47c7..279435b5b27d 100644 ---- a/llvm/cmake/config-ix.cmake -+++ b/llvm/cmake/config-ix.cmake -@@ -343,7 +343,7 @@ if( LLVM_ENABLE_FFI ) - message(FATAL_ERROR "libffi includes are not found.") - endif() - -- find_library(FFI_LIBRARY_PATH ffi PATHS ${FFI_LIBRARY_DIR}) -+ find_library(FFI_LIBRARY_PATH NAMES ffi libffi PATHS ${FFI_LIBRARY_DIR}) - if( NOT FFI_LIBRARY_PATH ) - message(FATAL_ERROR "libffi is not found.") - endif() diff --git a/ports/llvm-13/0011-fix-libxml2.patch b/ports/llvm-13/0011-fix-libxml2.patch deleted file mode 100644 index d3f953f3..00000000 --- a/ports/llvm-13/0011-fix-libxml2.patch +++ /dev/null @@ -1,34 +0,0 @@ - clang/tools/c-index-test/CMakeLists.txt | 6 +----- - lldb/cmake/modules/LLDBConfig.cmake | 2 +- - 2 files changed, 2 insertions(+), 6 deletions(-) - -diff --git a/clang/tools/c-index-test/CMakeLists.txt b/clang/tools/c-index-test/CMakeLists.txt -index ceef4b08637c..40b9e995597f 100644 ---- a/clang/tools/c-index-test/CMakeLists.txt -+++ b/clang/tools/c-index-test/CMakeLists.txt -@@ -40,11 +40,7 @@ set_target_properties(c-index-test - - # If libxml2 is available, make it available for c-index-test. - if (CLANG_HAVE_LIBXML) -- if ((CMAKE_OSX_SYSROOT) AND (EXISTS ${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR})) -- include_directories(SYSTEM ${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR}) -- else() -- include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR}) -- endif() -+ include_directories(SYSTEM ${LIBXML2_INCLUDE_DIRS}) - target_link_libraries(c-index-test PRIVATE ${LIBXML2_LIBRARIES}) - endif() - -diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake -index b62cd7d24438..a8c78ee1bccd 100644 ---- a/lldb/cmake/modules/LLDBConfig.cmake -+++ b/lldb/cmake/modules/LLDBConfig.cmake -@@ -215,7 +215,7 @@ if (LLDB_ENABLE_LZMA) - endif() - - if (LLDB_ENABLE_LIBXML2) -- include_directories(${LIBXML2_INCLUDE_DIR}) -+ include_directories(${LIBXML2_INCLUDE_DIRS}) - endif() - - include_directories(BEFORE diff --git a/ports/llvm-13/0020-fix-FindZ3.cmake.patch b/ports/llvm-13/0020-fix-FindZ3.cmake.patch deleted file mode 100644 index 91afccaa..00000000 --- a/ports/llvm-13/0020-fix-FindZ3.cmake.patch +++ /dev/null @@ -1,70 +0,0 @@ -diff --git a/llvm/cmake/modules/FindZ3.cmake b/llvm/cmake/modules/FindZ3.cmake -index 118b1eac3b32..455bbf28facc 100644 ---- a/llvm/cmake/modules/FindZ3.cmake -+++ b/llvm/cmake/modules/FindZ3.cmake -@@ -1,3 +1,22 @@ -+# Try first to find Z3 using its upstream cmake files (included in newer version) -+# unless the user has provided a hint that would assume skipping the CONFIG -+# option -+if (NOT DEFINED Z3_ROOT AND NOT LLVM_Z3_INSTALL_DIR) -+ find_package(Z3 QUIET CONFIG) -+endif() -+ -+# If we found with CONFIG mode, then set up the compatible variables -+if (Z3_FOUND) -+ set(Z3_VERSION "${Z3_VERSION_STRING}") -+ set(Z3_LIBRARIES z3::libz3) -+ get_property(Z3_INCLUDE_DIR -+ TARGET z3::libz3 PROPERTY -+ INTERFACE_INCLUDE_DIRECTORIES -+ ) -+ find_package_handle_standard_args(Z3 CONFIG_MODE) -+ -+else() -+ - INCLUDE(CheckCXXSourceRuns) - - # Function to check Z3's version -@@ -123,3 +142,5 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(Z3 - VERSION_VAR Z3_VERSION_STRING) - - mark_as_advanced(Z3_INCLUDE_DIR Z3_LIBRARIES) -+ -+endif() -diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt -index 014b4a2caf15..ac121ac0bc14 100644 ---- a/llvm/lib/Support/CMakeLists.txt -+++ b/llvm/lib/Support/CMakeLists.txt -@@ -71,7 +71,11 @@ endif() - - # Link Z3 if the user wants to build it. - if(LLVM_WITH_Z3) -- set(system_libs ${system_libs} ${Z3_LIBRARIES}) -+ if(TARGET "${Z3_LIBRARIES}") -+ set(imported_libs ${imported_libs} "${Z3_LIBRARIES}") -+ else() -+ set(system_libs ${system_libs} ${Z3_LIBRARIES}) -+ endif() - endif() - - # Override the C runtime allocator on Windows and embed it into LLVM tools & libraries -@@ -276,6 +280,19 @@ if(LLVM_ENABLE_ZLIB) - set(llvm_system_libs ${llvm_system_libs} "${zlib_library}") - endif() - -+if(LLVM_WITH_Z3 AND TARGET "${Z3_LIBRARIES}") -+ # CMAKE_BUILD_TYPE is only meaningful to single-configuration generators. -+ if(CMAKE_BUILD_TYPE) -+ string(TOUPPER ${CMAKE_BUILD_TYPE} build_type) -+ get_property(z3_library TARGET "${Z3_LIBRARIES}" PROPERTY LOCATION_${build_type}) -+ endif() -+ if(NOT z3_library) -+ get_property(z3_library TARGET "${Z3_LIBRARIES}" PROPERTY LOCATION) -+ endif() -+ get_library_name("${z3_library}" z3_library) -+ set(llvm_system_libs ${llvm_system_libs} "${z3_library}") -+endif() -+ - if(LLVM_ENABLE_TERMINFO) - get_library_name(${TERMINFO_LIB} terminfo_library) - set(llvm_system_libs ${llvm_system_libs} "${terminfo_library}") diff --git a/ports/llvm-13/0021-fix-find_dependency.patch b/ports/llvm-13/0021-fix-find_dependency.patch deleted file mode 100644 index af7acbfc..00000000 --- a/ports/llvm-13/0021-fix-find_dependency.patch +++ /dev/null @@ -1,28 +0,0 @@ -diff --git a/llvm/cmake/modules/LLVMConfig.cmake.in b/llvm/cmake/modules/LLVMConfig.cmake.in -index 60b56b5152ea..09d78a0a2466 100644 ---- a/llvm/cmake/modules/LLVMConfig.cmake.in -+++ b/llvm/cmake/modules/LLVMConfig.cmake.in -@@ -56,17 +56,21 @@ set(LLVM_ENABLE_THREADS @LLVM_ENABLE_THREADS@) - - set(LLVM_ENABLE_UNWIND_TABLES @LLVM_ENABLE_UNWIND_TABLES@) - -+include(CMakeFindDependencyMacro) - set(LLVM_ENABLE_ZLIB @LLVM_ENABLE_ZLIB@) - if(LLVM_ENABLE_ZLIB) -- find_package(ZLIB) -+ find_dependency(ZLIB) - endif() - - set(LLVM_ENABLE_LIBXML2 @LLVM_ENABLE_LIBXML2@) - if(LLVM_ENABLE_LIBXML2) -- find_package(LibXml2) -+ find_dependency(LibXml2) - endif() - - set(LLVM_WITH_Z3 @LLVM_WITH_Z3@) -+if(LLVM_WITH_Z3) -+ find_dependency(Z3 4.7.1) -+endif() - - set(LLVM_ENABLE_DIA_SDK @LLVM_ENABLE_DIA_SDK@) - diff --git a/ports/llvm-13/0022-llvm-config-bin-path.patch b/ports/llvm-13/0022-llvm-config-bin-path.patch deleted file mode 100644 index ed608df0..00000000 --- a/ports/llvm-13/0022-llvm-config-bin-path.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/llvm/cmake/modules/CMakeLists.txt b/llvm/cmake/modules/CMakeLists.txt -index a818de2e116c..17e8068c68d9 100644 ---- a/llvm/cmake/modules/CMakeLists.txt -+++ b/llvm/cmake/modules/CMakeLists.txt -@@ -115,7 +115,7 @@ set(LLVM_CONFIG_MAIN_INCLUDE_DIR "${LLVM_CONFIG_INCLUDE_DIRS}") - set(LLVM_CONFIG_LIBRARY_DIRS "\${LLVM_INSTALL_PREFIX}/lib\${LLVM_LIBDIR_SUFFIX}") - set(LLVM_CONFIG_CMAKE_DIR "\${LLVM_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}") - set(LLVM_CONFIG_BINARY_DIR "\${LLVM_INSTALL_PREFIX}") --set(LLVM_CONFIG_TOOLS_BINARY_DIR "\${LLVM_INSTALL_PREFIX}/bin") -+set(LLVM_CONFIG_TOOLS_BINARY_DIR "\${LLVM_INSTALL_PREFIX}/tools/llvm") - - # Generate a default location for lit - if (LLVM_INSTALL_UTILS AND LLVM_BUILD_UTILS) diff --git a/ports/llvm-15/0001-Fix-install-paths.patch b/ports/llvm-15/0001-Fix-install-paths.patch new file mode 100644 index 00000000..8e3e2e6e --- /dev/null +++ b/ports/llvm-15/0001-Fix-install-paths.patch @@ -0,0 +1,10 @@ +diff --git a/openmp/tools/Modules/CMakeLists.txt b/openmp/tools/Modules/CMakeLists.txt +index 22d818eea72d..75aacc4468d4 100644 +--- a/openmp/tools/Modules/CMakeLists.txt ++++ b/openmp/tools/Modules/CMakeLists.txt +@@ -12,4 +12,4 @@ + + + install(FILES "FindOpenMPTarget.cmake" +- DESTINATION "${OPENMP_INSTALL_LIBDIR}/cmake/openmp") ++ DESTINATION "share/openmp") diff --git a/ports/llvm-13/0004-fix-dr-1734.patch b/ports/llvm-15/0002-Fix-DR-1734.patch similarity index 83% rename from ports/llvm-13/0004-fix-dr-1734.patch rename to ports/llvm-15/0002-Fix-DR-1734.patch index e8bd159b..3a2f4a28 100644 --- a/ports/llvm-13/0004-fix-dr-1734.patch +++ b/ports/llvm-15/0002-Fix-DR-1734.patch @@ -2,7 +2,7 @@ 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/Support/type_traits.h b/llvm/include/llvm/Support/type_traits.h -index 7b7d5d991f3f..332864c1907e 100644 +index 7b7d5d991f3f..469b681deea3 100644 --- a/llvm/include/llvm/Support/type_traits.h +++ b/llvm/include/llvm/Support/type_traits.h @@ -176,7 +176,8 @@ class is_trivially_copyable { @@ -10,7 +10,7 @@ index 7b7d5d991f3f..332864c1907e 100644 (has_deleted_copy_constructor || has_trivial_copy_constructor); -#ifdef HAVE_STD_IS_TRIVIALLY_COPYABLE -+ // due to DR 1734, a type can be std::is_trivially_copyable but not llvm::is_trivially_copyable ++// due to DR 1734, a type can be std::is_trivially_copyable but not llvm::is_trivially_copyable +#if 0 static_assert(value == std::is_trivially_copyable::value, "inconsistent behavior between llvm:: and std:: implementation of is_trivially_copyable"); diff --git a/ports/llvm-13/0005-fix-tools-path.patch b/ports/llvm-15/0003-Fix-tools-path.patch similarity index 87% rename from ports/llvm-13/0005-fix-tools-path.patch rename to ports/llvm-15/0003-Fix-tools-path.patch index 06fc8fc2..66fec67d 100644 --- a/ports/llvm-13/0005-fix-tools-path.patch +++ b/ports/llvm-15/0003-Fix-tools-path.patch @@ -2,10 +2,10 @@ 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/tools/llvm-config/llvm-config.cpp b/llvm/tools/llvm-config/llvm-config.cpp -index 1a2f04552d13..9370c5e28206 100644 +index 2c6c55f89d38..f2b581559991 100644 --- a/llvm/tools/llvm-config/llvm-config.cpp +++ b/llvm/tools/llvm-config/llvm-config.cpp -@@ -305,7 +305,7 @@ int main(int argc, char **argv) { +@@ -307,7 +307,7 @@ int main(int argc, char **argv) { // bin dir). sys::fs::make_absolute(CurrentPath); CurrentExecPrefix = diff --git a/ports/llvm-13/0007-fix-compiler-rt-install-path.patch b/ports/llvm-15/0004-Fix-compiler-rt-install-path.patch similarity index 77% rename from ports/llvm-13/0007-fix-compiler-rt-install-path.patch rename to ports/llvm-15/0004-Fix-compiler-rt-install-path.patch index 6a585cd4..b08c1215 100644 --- a/ports/llvm-13/0007-fix-compiler-rt-install-path.patch +++ b/ports/llvm-15/0004-Fix-compiler-rt-install-path.patch @@ -4,23 +4,23 @@ 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt -index 8131f6005dc2..9afef2e5a4e7 100644 +index 6e2060991b92..94ced7feda9b 100644 --- a/clang/lib/Headers/CMakeLists.txt +++ b/clang/lib/Headers/CMakeLists.txt -@@ -222,7 +222,7 @@ set_target_properties(clang-resource-headers PROPERTIES - FOLDER "Misc" - RUNTIME_OUTPUT_DIRECTORY "${output_dir}") +@@ -420,7 +420,7 @@ add_header_target("openmp-resource-headers" ${openmp_wrapper_files}) + add_header_target("windows-resource-headers" ${windows_only_files}) + add_header_target("utility-resource-headers" ${utility_files}) -set(header_install_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include) +set(header_install_dir tools/llvm/lib/clang/${CLANG_VERSION}/include) - install( - FILES ${files} ${generated_files} + ############################################################# + # Install rules for the catch-all clang-resource-headers target diff --git a/clang/runtime/CMakeLists.txt b/clang/runtime/CMakeLists.txt -index 61b1c60bf590..c20a5a326f15 100644 +index 9f4633bc85b1..6d7b70ee0dea 100644 --- a/clang/runtime/CMakeLists.txt +++ b/clang/runtime/CMakeLists.txt -@@ -82,7 +82,7 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS ${COMPILER_RT_SRC_ROOT}/) +@@ -84,7 +84,7 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS ${COMPILER_RT_SRC_ROOT}/) -DLLVM_LIT_ARGS=${LLVM_LIT_ARGS} -DCOMPILER_RT_OUTPUT_DIR=${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION} -DCOMPILER_RT_EXEC_OUTPUT_DIR=${LLVM_RUNTIME_OUTPUT_INTDIR} @@ -30,10 +30,10 @@ index 61b1c60bf590..c20a5a326f15 100644 -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX} diff --git a/compiler-rt/cmake/base-config-ix.cmake b/compiler-rt/cmake/base-config-ix.cmake -index c11342e68813..61bb52135c43 100644 +index 8a6219568b3f..f9c9f6478280 100644 --- a/compiler-rt/cmake/base-config-ix.cmake +++ b/compiler-rt/cmake/base-config-ix.cmake -@@ -42,7 +42,7 @@ if (LLVM_TREE_AVAILABLE) +@@ -45,7 +45,7 @@ if (LLVM_TREE_AVAILABLE) # Setup the paths where compiler-rt runtimes and headers should be stored. set(COMPILER_RT_OUTPUT_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}) set(COMPILER_RT_EXEC_OUTPUT_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) diff --git a/ports/llvm-15/0005-Fix-tools-install-path.patch b/ports/llvm-15/0005-Fix-tools-install-path.patch new file mode 100644 index 00000000..22bd804f --- /dev/null +++ b/ports/llvm-15/0005-Fix-tools-install-path.patch @@ -0,0 +1,207 @@ + clang-tools-extra/clang-tidy/tool/CMakeLists.txt | 2 +- + clang-tools-extra/modularize/CMakeLists.txt | 2 +- + clang/cmake/modules/AddClang.cmake | 2 +- + clang/tools/c-index-test/CMakeLists.txt | 2 +- + clang/tools/clang-format/CMakeLists.txt | 2 +- + clang/tools/clang-linker-wrapper/CMakeLists.txt | 2 +- + clang/tools/clang-nvlink-wrapper/CMakeLists.txt | 2 +- + clang/tools/scan-build-py/CMakeLists.txt | 4 ++-- + clang/tools/scan-build/CMakeLists.txt | 2 +- + clang/tools/scan-view/CMakeLists.txt | 2 +- + flang/cmake/modules/AddFlang.cmake | 2 +- + flang/tools/f18/CMakeLists.txt | 2 +- + flang/tools/flang-driver/CMakeLists.txt | 2 +- + lld/cmake/modules/AddLLD.cmake | 2 +- + lldb/cmake/modules/AddLLDB.cmake | 2 +- + 15 files changed, 16 insertions(+), 16 deletions(-) + +diff --git a/clang-tools-extra/clang-tidy/tool/CMakeLists.txt b/clang-tools-extra/clang-tidy/tool/CMakeLists.txt +index 3ce552872015..e09b917ae5f8 100644 +--- a/clang-tools-extra/clang-tidy/tool/CMakeLists.txt ++++ b/clang-tools-extra/clang-tidy/tool/CMakeLists.txt +@@ -64,6 +64,6 @@ install(PROGRAMS clang-tidy-diff.py + DESTINATION "${CMAKE_INSTALL_DATADIR}/clang" + COMPONENT clang-tidy) + install(PROGRAMS run-clang-tidy.py +- DESTINATION "${CMAKE_INSTALL_BINDIR}" ++ DESTINATION "${LLVM_TOOLS_INSTALL_DIR}" + COMPONENT clang-tidy + RENAME run-clang-tidy) +diff --git a/clang-tools-extra/modularize/CMakeLists.txt b/clang-tools-extra/modularize/CMakeLists.txt +index fb17e353c39f..4b409e47446a 100644 +--- a/clang-tools-extra/modularize/CMakeLists.txt ++++ b/clang-tools-extra/modularize/CMakeLists.txt +@@ -23,5 +23,5 @@ clang_target_link_libraries(modularize + ) + + install(TARGETS modularize +- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ++ RUNTIME DESTINATION "${LLVM_TOOLS_INSTALL_DIR}" + COMPONENT clang-extras) +diff --git a/clang/cmake/modules/AddClang.cmake b/clang/cmake/modules/AddClang.cmake +index 21ac332e4f5f..1aaf785bdc99 100644 +--- a/clang/cmake/modules/AddClang.cmake ++++ b/clang/cmake/modules/AddClang.cmake +@@ -166,7 +166,7 @@ macro(add_clang_tool name) + get_target_export_arg(${name} Clang export_to_clangtargets) + install(TARGETS ${name} + ${export_to_clangtargets} +- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ++ RUNTIME DESTINATION "${LLVM_TOOLS_INSTALL_DIR}" + COMPONENT ${name}) + + if(NOT LLVM_ENABLE_IDE) +diff --git a/clang/tools/c-index-test/CMakeLists.txt b/clang/tools/c-index-test/CMakeLists.txt +index 0ae1b4e55244..e8a34e136194 100644 +--- a/clang/tools/c-index-test/CMakeLists.txt ++++ b/clang/tools/c-index-test/CMakeLists.txt +@@ -49,7 +49,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) + set_property(TARGET c-index-test APPEND PROPERTY INSTALL_RPATH + "@executable_path/../../lib") + else() +- set(INSTALL_DESTINATION "${CMAKE_INSTALL_BINDIR}") ++ set(INSTALL_DESTINATION "${LLVM_TOOLS_INSTALL_DIR}") + endif() + + install(TARGETS c-index-test +diff --git a/clang/tools/clang-format/CMakeLists.txt b/clang/tools/clang-format/CMakeLists.txt +index bbdef93b576b..8744e414da0a 100644 +--- a/clang/tools/clang-format/CMakeLists.txt ++++ b/clang/tools/clang-format/CMakeLists.txt +@@ -36,5 +36,5 @@ install(PROGRAMS clang-format.py + DESTINATION "${CMAKE_INSTALL_DATADIR}/clang" + COMPONENT clang-format) + install(PROGRAMS git-clang-format +- DESTINATION "${CMAKE_INSTALL_BINDIR}" ++ DESTINATION "${LLVM_TOOLS_INSTALL_DIR}" + COMPONENT clang-format) +diff --git a/clang/tools/clang-linker-wrapper/CMakeLists.txt b/clang/tools/clang-linker-wrapper/CMakeLists.txt +index 88c19cad7b53..b50c9ff90586 100644 +--- a/clang/tools/clang-linker-wrapper/CMakeLists.txt ++++ b/clang/tools/clang-linker-wrapper/CMakeLists.txt +@@ -44,4 +44,4 @@ target_link_libraries(clang-linker-wrapper + ${CLANG_LINKER_WRAPPER_LIB_DEPS} + ) + +-install(TARGETS clang-linker-wrapper RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") ++install(TARGETS clang-linker-wrapper RUNTIME DESTINATION "${LLVM_TOOLS_INSTALL_DIR}") +diff --git a/clang/tools/clang-nvlink-wrapper/CMakeLists.txt b/clang/tools/clang-nvlink-wrapper/CMakeLists.txt +index 2c979e509795..f22b801fe19a 100644 +--- a/clang/tools/clang-nvlink-wrapper/CMakeLists.txt ++++ b/clang/tools/clang-nvlink-wrapper/CMakeLists.txt +@@ -22,4 +22,4 @@ target_link_libraries(clang-nvlink-wrapper + ${CLANG_NVLINK_WRAPPER_LIB_DEPS} + ) + +-install(TARGETS clang-nvlink-wrapper RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") ++install(TARGETS clang-nvlink-wrapper RUNTIME DESTINATION "${LLVM_TOOLS_INSTALL_DIR}") +diff --git a/clang/tools/scan-build-py/CMakeLists.txt b/clang/tools/scan-build-py/CMakeLists.txt +index 061dc7ef4dd9..91499600693b 100644 +--- a/clang/tools/scan-build-py/CMakeLists.txt ++++ b/clang/tools/scan-build-py/CMakeLists.txt +@@ -43,7 +43,7 @@ foreach(BinFile ${BinFiles}) + ${CMAKE_BINARY_DIR}/bin/scan-build-py + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/scan-build) + install (PROGRAMS "bin/scan-build" +- DESTINATION "${CMAKE_INSTALL_BINDIR}" ++ DESTINATION "${LLVM_TOOLS_INSTALL_DIR}" + RENAME scan-build-py + COMPONENT scan-build-py) + list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/scan-build-py) +@@ -56,7 +56,7 @@ foreach(BinFile ${BinFiles}) + ${CMAKE_BINARY_DIR}/bin/ + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile}) + install(PROGRAMS bin/${BinFile} +- DESTINATION "${CMAKE_INSTALL_BINDIR}" ++ DESTINATION "${LLVM_TOOLS_INSTALL_DIR}" + COMPONENT scan-build-py) + list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile}) + endif() +diff --git a/clang/tools/scan-build/CMakeLists.txt b/clang/tools/scan-build/CMakeLists.txt +index ef687b0e90a1..a52af70443c3 100644 +--- a/clang/tools/scan-build/CMakeLists.txt ++++ b/clang/tools/scan-build/CMakeLists.txt +@@ -47,7 +47,7 @@ if(CLANG_INSTALL_SCANBUILD) + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile}) + list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile}) + install(PROGRAMS bin/${BinFile} +- DESTINATION "${CMAKE_INSTALL_BINDIR}" ++ DESTINATION "${LLVM_TOOLS_INSTALL_DIR}" + COMPONENT scan-build) + endforeach() + +diff --git a/clang/tools/scan-view/CMakeLists.txt b/clang/tools/scan-view/CMakeLists.txt +index 07aec76ee66f..ca6a3380ad0c 100644 +--- a/clang/tools/scan-view/CMakeLists.txt ++++ b/clang/tools/scan-view/CMakeLists.txt +@@ -20,7 +20,7 @@ if(CLANG_INSTALL_SCANVIEW) + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${BinFile}) + list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${BinFile}) + install(PROGRAMS bin/${BinFile} +- DESTINATION "${CMAKE_INSTALL_BINDIR}" ++ DESTINATION "${LLVM_TOOLS_INSTALL_DIR}" + COMPONENT scan-view) + endforeach() + +diff --git a/flang/cmake/modules/AddFlang.cmake b/flang/cmake/modules/AddFlang.cmake +index d516ca31b51f..4a0d4ce80168 100644 +--- a/flang/cmake/modules/AddFlang.cmake ++++ b/flang/cmake/modules/AddFlang.cmake +@@ -110,7 +110,7 @@ macro(add_flang_tool name) + get_target_export_arg(${name} Flang export_to_flangtargets) + install(TARGETS ${name} + ${export_to_flangtargets} +- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ++ RUNTIME DESTINATION "${LLVM_TOOLS_INSTALL_DIR}" + COMPONENT ${name}) + + if(NOT LLVM_ENABLE_IDE) +diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt +index dd0898730e2e..d01c2f8076e3 100644 +--- a/flang/tools/f18/CMakeLists.txt ++++ b/flang/tools/f18/CMakeLists.txt +@@ -56,7 +56,7 @@ if (NOT WIN32) + @ONLY + ) + add_custom_target(flang-to-external-fc ALL DEPENDS ${CMAKE_BINARY_DIR}/bin/flang-to-external-fc) +- install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/flang-to-external-fc DESTINATION "${CMAKE_INSTALL_BINDIR}") ++ install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/flang-to-external-fc DESTINATION "${LLVM_TOOLS_INSTALL_DIR}") + endif() + + # TODO Move this to a more suitable location +diff --git a/flang/tools/flang-driver/CMakeLists.txt b/flang/tools/flang-driver/CMakeLists.txt +index 94c8ce6d58f1..466d41c58b1d 100644 +--- a/flang/tools/flang-driver/CMakeLists.txt ++++ b/flang/tools/flang-driver/CMakeLists.txt +@@ -42,4 +42,4 @@ if(FLANG_PLUGIN_SUPPORT) + export_executable_symbols_for_plugins(flang-new) + endif() + +-install(TARGETS flang-new DESTINATION "${CMAKE_INSTALL_BINDIR}") ++install(TARGETS flang-new DESTINATION "${LLVM_TOOLS_INSTALL_DIR}") +diff --git a/lld/cmake/modules/AddLLD.cmake b/lld/cmake/modules/AddLLD.cmake +index d3924f7243d4..f328b62ad8c8 100644 +--- a/lld/cmake/modules/AddLLD.cmake ++++ b/lld/cmake/modules/AddLLD.cmake +@@ -47,7 +47,7 @@ macro(add_lld_tool name) + get_target_export_arg(${name} LLD export_to_lldtargets) + install(TARGETS ${name} + ${export_to_lldtargets} +- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ++ RUNTIME DESTINATION "${LLVM_TOOLS_INSTALL_DIR}" + COMPONENT ${name}) + + if(NOT CMAKE_CONFIGURATION_TYPES) +diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake +index 3291a7c808e1..9fe9b9a7940d 100644 +--- a/lldb/cmake/modules/AddLLDB.cmake ++++ b/lldb/cmake/modules/AddLLDB.cmake +@@ -189,7 +189,7 @@ function(add_lldb_executable name) + endif() + + if(ARG_GENERATE_INSTALL) +- set(install_dest bin) ++ set(install_dest "${LLVM_TOOLS_INSTALL_DIR}") + if(ARG_INSTALL_PREFIX) + set(install_dest ${ARG_INSTALL_PREFIX}) + endif() diff --git a/ports/llvm-15/0006-Fix-libffi.patch b/ports/llvm-15/0006-Fix-libffi.patch new file mode 100644 index 00000000..3859b81f --- /dev/null +++ b/ports/llvm-15/0006-Fix-libffi.patch @@ -0,0 +1,16 @@ + llvm/cmake/modules/FindFFI.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/llvm/cmake/modules/FindFFI.cmake b/llvm/cmake/modules/FindFFI.cmake +index b0d859af8959..a756d0c8fdb0 100644 +--- a/llvm/cmake/modules/FindFFI.cmake ++++ b/llvm/cmake/modules/FindFFI.cmake +@@ -34,7 +34,7 @@ else() + endif() + endif() + +-find_library(FFI_LIBRARIES ffi PATHS ${FFI_LIBRARY_DIR}) ++find_library(FFI_LIBRARIES ffi libffi PATHS ${FFI_LIBRARY_DIR}) + + if(FFI_LIBRARIES) + include(CMakePushCheckState) diff --git a/ports/llvm-15/0007-Fix-install-bolt.patch b/ports/llvm-15/0007-Fix-install-bolt.patch new file mode 100644 index 00000000..361f58e7 --- /dev/null +++ b/ports/llvm-15/0007-Fix-install-bolt.patch @@ -0,0 +1,21 @@ + bolt/tools/driver/CMakeLists.txt | 7 ------- + 1 file changed, 7 deletions(-) + +diff --git a/bolt/tools/driver/CMakeLists.txt b/bolt/tools/driver/CMakeLists.txt +index e56be15dbcff..85b078e2e761 100644 +--- a/bolt/tools/driver/CMakeLists.txt ++++ b/bolt/tools/driver/CMakeLists.txt +@@ -35,13 +35,6 @@ set(BOLT_DEPENDS + ) + + add_custom_target(bolt DEPENDS ${BOLT_DEPENDS}) +-install(PROGRAMS +- ${CMAKE_BINARY_DIR}/bin/llvm-bolt +- ${CMAKE_BINARY_DIR}/bin/perf2bolt +- ${CMAKE_BINARY_DIR}/bin/llvm-boltdiff +- DESTINATION ${CMAKE_INSTALL_BINDIR} +- COMPONENT bolt +- ) + add_llvm_install_targets(install-bolt DEPENDS bolt COMPONENT bolt) + set_target_properties(bolt PROPERTIES FOLDER "BOLT") + set_target_properties(install-bolt PROPERTIES FOLDER "BOLT") diff --git a/ports/llvm-15/0020-fix-FindZ3.cmake.patch b/ports/llvm-15/0020-fix-FindZ3.cmake.patch new file mode 100644 index 00000000..a24a2d75 --- /dev/null +++ b/ports/llvm-15/0020-fix-FindZ3.cmake.patch @@ -0,0 +1,33 @@ +diff --git a/llvm/cmake/modules/FindZ3.cmake b/llvm/cmake/modules/FindZ3.cmake +index 118b1eac3b32..455bbf28facc 100644 +--- a/llvm/cmake/modules/FindZ3.cmake ++++ b/llvm/cmake/modules/FindZ3.cmake +@@ -1,3 +1,22 @@ ++# Try first to find Z3 using its upstream cmake files (included in newer version) ++# unless the user has provided a hint that would assume skipping the CONFIG ++# option ++if (NOT DEFINED Z3_ROOT AND NOT LLVM_Z3_INSTALL_DIR) ++ find_package(Z3 QUIET CONFIG) ++endif() ++ ++# If we found with CONFIG mode, then set up the compatible variables ++if (Z3_FOUND) ++ set(Z3_VERSION "${Z3_VERSION_STRING}") ++ set(Z3_LIBRARIES z3::libz3) ++ get_property(Z3_INCLUDE_DIR ++ TARGET z3::libz3 PROPERTY ++ INTERFACE_INCLUDE_DIRECTORIES ++ ) ++ find_package_handle_standard_args(Z3 CONFIG_MODE) ++ ++else() ++ + INCLUDE(CheckCXXSourceRuns) + + # Function to check Z3's version +@@ -123,3 +142,5 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(Z3 + VERSION_VAR Z3_VERSION_STRING) + + mark_as_advanced(Z3_INCLUDE_DIR Z3_LIBRARIES) ++ ++endif() diff --git a/ports/llvm-15/0021-fix-find_dependency.patch b/ports/llvm-15/0021-fix-find_dependency.patch new file mode 100644 index 00000000..6e912f61 --- /dev/null +++ b/ports/llvm-15/0021-fix-find_dependency.patch @@ -0,0 +1,54 @@ +diff --git a/llvm/cmake/modules/LLVMConfig.cmake.in b/llvm/cmake/modules/LLVMConfig.cmake.in +index fbf28d36bedf..a9a5b83852b5 100644 +--- a/llvm/cmake/modules/LLVMConfig.cmake.in ++++ b/llvm/cmake/modules/LLVMConfig.cmake.in +@@ -51,16 +51,18 @@ set(LLVM_ENABLE_ASSERTIONS @LLVM_ENABLE_ASSERTIONS@) + + set(LLVM_ENABLE_EH @LLVM_ENABLE_EH@) + ++include(CMakeFindDependencyMacro) ++ + set(LLVM_ENABLE_FFI @LLVM_ENABLE_FFI@) + if(LLVM_ENABLE_FFI) +- find_package(FFI) ++ find_dependency(FFI) + endif() + + set(LLVM_ENABLE_RTTI @LLVM_ENABLE_RTTI@) + + set(LLVM_ENABLE_TERMINFO @LLVM_ENABLE_TERMINFO@) + if(LLVM_ENABLE_TERMINFO) +- find_package(Terminfo) ++ find_dependency(Terminfo) + endif() + + set(LLVM_ENABLE_THREADS @LLVM_ENABLE_THREADS@) +@@ -69,22 +71,23 @@ set(LLVM_ENABLE_UNWIND_TABLES @LLVM_ENABLE_UNWIND_TABLES@) + + set(LLVM_ENABLE_ZLIB @LLVM_ENABLE_ZLIB@) + if(LLVM_ENABLE_ZLIB) +- set(ZLIB_ROOT @ZLIB_ROOT@) +- find_package(ZLIB) ++ find_dependency(ZLIB) + endif() + + set(LLVM_ENABLE_ZSTD @LLVM_ENABLE_ZSTD@) + if(LLVM_ENABLE_ZSTD) +- set(zstd_ROOT @zstd_ROOT@) +- find_package(zstd) ++ find_dependency(zstd) + endif() + + set(LLVM_ENABLE_LIBXML2 @LLVM_ENABLE_LIBXML2@) + if(LLVM_ENABLE_LIBXML2) +- find_package(LibXml2) ++ find_dependency(LibXml2) + endif() + + set(LLVM_WITH_Z3 @LLVM_WITH_Z3@) ++if(LLVM_WITH_Z3) ++ find_dependency(Z3 4.7.1) ++endif() + + set(LLVM_ENABLE_DIA_SDK @LLVM_ENABLE_DIA_SDK@) + diff --git a/ports/llvm-13/0023-clang-sys-include-dir-path.patch b/ports/llvm-15/0023-clang-sys-include-dir-path.patch similarity index 100% rename from ports/llvm-13/0023-clang-sys-include-dir-path.patch rename to ports/llvm-15/0023-clang-sys-include-dir-path.patch diff --git a/ports/llvm-13/0024-remove-elf_relocation-checks.patch b/ports/llvm-15/0024-remove-elf_relocation-checks.patch similarity index 77% rename from ports/llvm-13/0024-remove-elf_relocation-checks.patch rename to ports/llvm-15/0024-remove-elf_relocation-checks.patch index 9039c434..204f34dd 100644 --- a/ports/llvm-13/0024-remove-elf_relocation-checks.patch +++ b/ports/llvm-15/0024-remove-elf_relocation-checks.patch @@ -1,12 +1,12 @@ diff --git a/llvm/include/llvm/ExecutionEngine/RuntimeDyld.h b/llvm/include/llvm/ExecutionEngine/RuntimeDyld.h -index 128c9967a596..9dc2f6cf7f98 100644 +index c434b45077a3..a4ccfd28fa65 100644 --- a/llvm/include/llvm/ExecutionEngine/RuntimeDyld.h +++ b/llvm/include/llvm/ExecutionEngine/RuntimeDyld.h @@ -57,6 +57,10 @@ class RuntimeDyldImpl; class RuntimeDyld { public: -+ ++ + // Should there be a hard failure on a relocation or just soft failure? + static bool ShouldFailOnRelocationErrors; + @@ -14,10 +14,10 @@ index 128c9967a596..9dc2f6cf7f98 100644 // Any relocations already associated with the symbol will be re-resolved. void reassignSectionAddress(unsigned SectionID, uint64_t Addr); diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp -index 687fd839805f..2e9e1a2794ac 100644 +index 3f38d26869d4..ccf0d531f0d5 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp -@@ -1446,4 +1446,6 @@ void jitLinkForORC( +@@ -1479,4 +1479,6 @@ void jitLinkForORC( std::move(O), std::move(Info)); } @@ -25,7 +25,7 @@ index 687fd839805f..2e9e1a2794ac 100644 + } // end namespace llvm diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp -index efe0b9cd61cd..4f29726b2112 100644 +index f92618afdff6..777efb3445e5 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp @@ -21,6 +21,7 @@ @@ -45,7 +45,7 @@ index efe0b9cd61cd..4f29726b2112 100644 + llvm::raw_string_ostream ss(message); + ss << "Relocation type not implemented yet: " << ty << "!\n"; + if (RuntimeDyld::ShouldFailOnRelocationErrors) { -+ report_fatal_error(message); ++ report_fatal_error(message.c_str()); + } else { + dbgs() << message; + } @@ -63,7 +63,7 @@ index efe0b9cd61cd..4f29726b2112 100644 break; case ELF::R_X86_64_NONE: break; -@@ -371,7 +383,7 @@ void RuntimeDyldELF::resolveX86Relocation(const SectionEntry &Section, +@@ -397,7 +409,7 @@ void RuntimeDyldELF::resolveX86Relocation(const SectionEntry &Section, default: // There are other relocation types, but it appears these are the // only ones currently used by the LLVM ELF object writer @@ -72,16 +72,16 @@ index efe0b9cd61cd..4f29726b2112 100644 break; } } -@@ -394,7 +406,7 @@ void RuntimeDyldELF::resolveAArch64Relocation(const SectionEntry &Section, +@@ -420,7 +432,7 @@ void RuntimeDyldELF::resolveAArch64Relocation(const SectionEntry &Section, switch (Type) { default: - report_fatal_error("Relocation type not implemented yet!"); + report_reallocation_error(Type); break; - case ELF::R_AARCH64_ABS16: { - uint64_t Result = Value + Addend; -@@ -779,7 +791,7 @@ void RuntimeDyldELF::resolvePPC32Relocation(const SectionEntry &Section, + case ELF::R_AARCH64_NONE: + break; +@@ -807,7 +819,7 @@ void RuntimeDyldELF::resolvePPC32Relocation(const SectionEntry &Section, uint8_t *LocalAddress = Section.getAddressWithOffset(Offset); switch (Type) { default: @@ -90,7 +90,7 @@ index efe0b9cd61cd..4f29726b2112 100644 break; case ELF::R_PPC_ADDR16_LO: writeInt16BE(LocalAddress, applyPPClo(Value + Addend)); -@@ -799,7 +811,7 @@ void RuntimeDyldELF::resolvePPC64Relocation(const SectionEntry &Section, +@@ -827,7 +839,7 @@ void RuntimeDyldELF::resolvePPC64Relocation(const SectionEntry &Section, uint8_t *LocalAddress = Section.getAddressWithOffset(Offset); switch (Type) { default: @@ -99,7 +99,7 @@ index efe0b9cd61cd..4f29726b2112 100644 break; case ELF::R_PPC64_ADDR16: writeInt16BE(LocalAddress, applyPPClo(Value + Addend)); -@@ -893,7 +905,7 @@ void RuntimeDyldELF::resolveSystemZRelocation(const SectionEntry &Section, +@@ -921,7 +933,7 @@ void RuntimeDyldELF::resolveSystemZRelocation(const SectionEntry &Section, uint8_t *LocalAddress = Section.getAddressWithOffset(Offset); switch (Type) { default: @@ -108,7 +108,7 @@ index efe0b9cd61cd..4f29726b2112 100644 break; case ELF::R_390_PC16DBL: case ELF::R_390_PLT16DBL: { -@@ -948,7 +960,7 @@ void RuntimeDyldELF::resolveBPFRelocation(const SectionEntry &Section, +@@ -976,7 +988,7 @@ void RuntimeDyldELF::resolveBPFRelocation(const SectionEntry &Section, switch (Type) { default: @@ -117,15 +117,3 @@ index efe0b9cd61cd..4f29726b2112 100644 break; case ELF::R_BPF_NONE: case ELF::R_BPF_64_64: -diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h -index 31892b7466e6..4a2cc70f0e96 100644 ---- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h -+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h -@@ -162,6 +162,7 @@ private: - bool relocationNeedsStub(const RelocationRef &R) const override; - - public: -+ - RuntimeDyldELF(RuntimeDyld::MemoryManager &MemMgr, - JITSymbolResolver &Resolver); - ~RuntimeDyldELF() override; diff --git a/ports/llvm-15/0025-PASTA-patches.patch b/ports/llvm-15/0025-PASTA-patches.patch new file mode 100644 index 00000000..be22c67d --- /dev/null +++ b/ports/llvm-15/0025-PASTA-patches.patch @@ -0,0 +1,1475 @@ +From 3817b8dcea37c64c61f3608d6cbe1758adf2979e Mon Sep 17 00:00:00 2001 +From: Peter Goodman +Date: Thu, 4 Aug 2022 16:12:06 -0400 +Subject: [PATCH] PASTA patches + +--- + clang/include/clang/Lex/PPCallbacks.h | 118 ++++++++++++ + clang/include/clang/Lex/Preprocessor.h | 47 +++-- + clang/include/clang/Lex/TokenLexer.h | 5 +- + clang/lib/Lex/PPDirectives.cpp | 129 ++++++++----- + clang/lib/Lex/PPExpressions.cpp | 28 +++ + clang/lib/Lex/PPLexerChange.cpp | 38 ++++ + clang/lib/Lex/PPMacroExpansion.cpp | 240 ++++++++++++++++++++++++- + clang/lib/Lex/Pragma.cpp | 52 ++++++ + clang/lib/Lex/Preprocessor.cpp | 43 ++++- + clang/lib/Lex/TokenLexer.cpp | 2 + + clang/lib/Parse/ParseTemplate.cpp | 7 + + 11 files changed, 631 insertions(+), 78 deletions(-) + +diff --git a/clang/include/clang/Lex/PPCallbacks.h b/clang/include/clang/Lex/PPCallbacks.h +index 76a74f20c..89de5bd2d 100644 +--- a/clang/include/clang/Lex/PPCallbacks.h ++++ b/clang/include/clang/Lex/PPCallbacks.h +@@ -40,6 +40,117 @@ public: + EnterFile, ExitFile, SystemHeaderPragma, RenameFile + }; + ++ // PASTA PATCH: Add in an event that lets us get better visibility into the ++ // behavior of the preprocessor, as things are happening. ++#define LLVM_CLANG_HAS_PASTA_EVENTS 20220727L ++ enum EventKind { ++ // Tell us just after one of the lexers has lexed a token. ++ // ++ // `Tok` is the token generated from one of the underlying lexers. ++ // `Data` is zero or it is a raw source location for where the lexer was ++ // invoked. ++ TokenFromLexer, ++ TokenFromTokenLexer, ++ TokenFromCachingLexer, ++ TokenFromAfterModuleImportLexer, ++ ++ // Tell the listener that the parser has split a token. This happens in C++ ++ // code for templates, e.g. `constant>>0`, where the `>>>` is first ++ // treated as one token, but then where the parser realizes that it is ++ // really `constant> > 0`. ++ BeginSplitToken, ++ EndSplitToken, ++ ++ // Tell the listener that we've just lexed the hash token that should start ++ // off a directive. ++ // ++ // `Tok` is the `#`. ++ BeginDirective, ++ ++ // Ends with an `EndDirective`. ++ // ++ // `Tok` is the `#`. ++ BeginSkippedArea, ++ ++ // Tell the listener that we're in a named directive, e.g. `if` or `define`. ++ // ++ // `Tok` is the `#`. ++ // `Data` is a `Token *` of the token lexed after the `#`. ++ SetNamedDirective, ++ ++ // Tell the listener that we're in an unnamed directive, e.g. GNU line ++ // numbers, such as `# 1`. ++ // ++ // `Tok` is the `#`. ++ // `Data` is a `const Token *` of the token lexed after the `#`. ++ SetUnnamedDirective, ++ ++ // End a directive. ++ // ++ // `Tok` is the `tok::eod` token. ++ EndDirective, ++ ++ // We thought something was a directive, but it wasn't, e.g. due to us ++ // parsing a .S file. ++ EndNonDirective, ++ ++ // `Tok` is the name of the macro being expanded. ++ // `Data` is the `MacroInfo *`. For built-in macros, this may be `nullptr`. ++ BeginMacroExpansion, ++ SwitchToExpansion, ++ CancelExpansion, // E.g. `_Pragma` in a macro parameter. ++ EndMacroExpansion, ++ ++ // `Tok` is the name of the macro being expanded. ++ // `Data` is a `MacroInfo *`. ++ BeginMacroCallArgumentList, ++ ++ // `Tok` is the token that terminated the argument list, i.e. a `)`. ++ // `Data` is a `MacroArgs *`. For built-in macros, this may be `nullptr`. ++ EndMacroCallArgumentList, ++ ++ // `Tok` is the token just before the first token of the argument, e.g. ++ // `(` or `,`. ++ // `Data` is a `Token *` of the macro name. ++ BeginMacroCallArgument, ++ ++ // `Tok` is the token just before the first token of the argument. ++ // `Data` is a `Token *` just after the last token of the argument, e.g. a ++ // `)` or a `,`. ++ EndMacroCallArgument, ++ ++ // `Tok` is the token just before the first token of the variadic arguments, ++ // e.g. a `(` or a `,`. ++ // `Data` is a `Token *` of the macro name. ++ BeginVariadicCallArgumentList, ++ ++ // `Tok` is the token just before the first token of the variadic arguments ++ // `Data` is a `Token *` just after the last token of the arguments, e.g. a ++ // `)` or a `,`. ++ EndVariadicCallArgumentList, ++ ++ // `Tok` is the token which begins the substitution. ++ // `Data` is `nullptr`. ++ BeginSubstitution, ++ ++ // `Tok` is the token (previously visible via another event) which we want ++ // to say begins the substitution. ++ // `Data` is `nullptr`. ++ BeginDelayedSubstitution, ++ ++ // `Tok` is the last token before the substituted tokens will begin being ++ // outputted. ++ // `Data` is a `Token *` of the first token of the substitution. ++ SwitchToSubstitution, ++ ++ // `Tok` is the last substituted token. ++ // `Data` is a `Token *` of the first token of the substitution. ++ EndSubstitution, ++ }; ++ ++ // PASTA PATCH: ++ virtual void Event(const Token &Tok, EventKind Kind, uintptr_t Data) {} ++ + /// Callback invoked whenever a source file is entered or exited. + /// + /// \param Loc Indicates the new location. +@@ -430,6 +541,13 @@ public: + + ~PPChainedCallbacks() override; + ++ ++ // PASTA PATCH: Interpose on preprocessor events. ++ void Event(const Token &Tok, EventKind Kind, uintptr_t Data) override { ++ First->Event(Tok, Kind, Data); ++ Second->Event(Tok, Kind, Data); ++ } ++ + void FileChanged(SourceLocation Loc, FileChangeReason Reason, + SrcMgr::CharacteristicKind FileType, + FileID PrevFID) override { +diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h +index e567f6391..728b49ead 100644 +--- a/clang/include/clang/Lex/Preprocessor.h ++++ b/clang/include/clang/Lex/Preprocessor.h +@@ -566,6 +566,9 @@ private: + /// encountered (e.g. a file is \#included, etc). + std::unique_ptr Callbacks; + ++ // PASTA PATCH: Add post-lex action. ++ std::function PostLexAction; ++ + struct MacroExpandsInfo { + Token Tok; + MacroDefinition MD; +@@ -1374,8 +1377,8 @@ public: + + /// Process directives while skipping until the through header or + /// #pragma hdrstop is found. +- void HandleSkippedDirectiveWhileUsingPCH(Token &Result, +- SourceLocation HashLoc); ++ void HandleSkippedDirectiveWhileUsingPCH(Token &Result, // PASTA PATCH ++ const Token &SavedHash); // PASTA PATCH + + /// Enter the specified FileID as the main source file, + /// which implicitly adds the builtin defines etc. +@@ -2108,15 +2111,7 @@ private: + CurPPLexer = nullptr; + } + +- void PopIncludeMacroStack() { +- CurLexer = std::move(IncludeMacroStack.back().TheLexer); +- CurPPLexer = IncludeMacroStack.back().ThePPLexer; +- CurTokenLexer = std::move(IncludeMacroStack.back().TheTokenLexer); +- CurDirLookup = IncludeMacroStack.back().TheDirLookup; +- CurLexerSubmodule = IncludeMacroStack.back().TheSubmodule; +- CurLexerKind = IncludeMacroStack.back().CurLexerKind; +- IncludeMacroStack.pop_back(); +- } ++ void PopIncludeMacroStack(); // PASTA PATCH + + void PropagateLineStartLeadingSpaceInfo(Token &Result); + +@@ -2173,7 +2168,7 @@ private: + /// \p FoundElse is false, then \#else directives are ok, if not, then we have + /// already seen one so a \#else directive is a duplicate. When this returns, + /// the caller can lex the first valid token. +- void SkipExcludedConditionalBlock(SourceLocation HashTokenLoc, ++ void SkipExcludedConditionalBlock(const Token &HashToken, // PASTA PATCH + SourceLocation IfTokenLoc, + bool FoundNonSkipPortion, bool FoundElse, + SourceLocation ElseLoc = SourceLocation()); +@@ -2227,7 +2222,7 @@ private: + /// After reading "MACRO(", this method is invoked to read all of the formal + /// arguments specified for the macro invocation. Returns null on error. + MacroArgs *ReadMacroCallArgumentList(Token &MacroName, MacroInfo *MI, +- SourceLocation &MacroEnd); ++ Token &MacroEndTok); // PASTA PATCH + + /// If an identifier token is read that is to be expanded + /// as a builtin macro, handle it and return the next token as 'Tok'. +@@ -2294,12 +2289,13 @@ private: + /// Handle*Directive - implement the various preprocessor directives. These + /// should side-effect the current preprocessor object so that the next call + /// to Lex() will return the appropriate token next. +- void HandleLineDirective(); +- void HandleDigitDirective(Token &Tok); +- void HandleUserDiagnosticDirective(Token &Tok, bool isWarning); +- void HandleIdentSCCSDirective(Token &Tok); +- void HandleMacroPublicDirective(Token &Tok); +- void HandleMacroPrivateDirective(); ++ void HandleLineDirective(const Token &SavedHash); // PASTA PATCH ++ void HandleDigitDirective(const Token &SavedHash, Token &Tok); // PASTA PATCH ++ void HandleUserDiagnosticDirective(const Token &SavedHash, Token &Tok, // PASTA PATCH ++ bool isWarning); // PASTA PATCH ++ void HandleIdentSCCSDirective(const Token &SavedHash, Token &Tok); // PASTA PATCH ++ void HandleMacroPublicDirective(const Token &SavedHash, Token &Tok); // PASTA PATCH ++ void HandleMacroPrivateDirective(const Token &SavedHash); // PASTA PATCH + + /// An additional notification that can be produced by a header inclusion or + /// import to tell the parser what happened. +@@ -2330,7 +2326,7 @@ private: + ModuleMap::KnownHeader &SuggestedModule, bool isAngled); + + // File inclusion. +- void HandleIncludeDirective(SourceLocation HashLoc, Token &Tok, ++ void HandleIncludeDirective(const Token &SavedHash, Token &Tok, // PASTA PATCH + const DirectoryLookup *LookupFrom = nullptr, + const FileEntry *LookupFromFile = nullptr); + ImportAction +@@ -2338,9 +2334,9 @@ private: + Token &FilenameTok, SourceLocation EndLoc, + const DirectoryLookup *LookupFrom = nullptr, + const FileEntry *LookupFromFile = nullptr); +- void HandleIncludeNextDirective(SourceLocation HashLoc, Token &Tok); +- void HandleIncludeMacrosDirective(SourceLocation HashLoc, Token &Tok); +- void HandleImportDirective(SourceLocation HashLoc, Token &Tok); ++ void HandleIncludeNextDirective(const Token &SavedHash, Token &Tok); // PASTA PATCH ++ void HandleIncludeMacrosDirective(const Token &SavedHash, Token &Tok); // PASTA PATCH ++ void HandleImportDirective(const Token &SavedHash, Token &Tok); // PASTA PATCH + void HandleMicrosoftImportDirective(Token &Tok); + + public: +@@ -2407,8 +2403,9 @@ private: + void replayPreambleConditionalStack(); + + // Macro handling. +- void HandleDefineDirective(Token &Tok, bool ImmediatelyAfterHeaderGuard); +- void HandleUndefDirective(); ++ void HandleDefineDirective(const Token &SavedHash, Token &Tok, // PASTA PATCH ++ bool ImmediatelyAfterHeaderGuard); // PASTA PATCH ++ void HandleUndefDirective(const Token &SavedHash); // PASTA PATCH + + // Conditional Inclusion. + void HandleIfdefDirective(Token &Result, const Token &HashToken, +diff --git a/clang/include/clang/Lex/TokenLexer.h b/clang/include/clang/Lex/TokenLexer.h +index 4d229ae61..35fae6c58 100644 +--- a/clang/include/clang/Lex/TokenLexer.h ++++ b/clang/include/clang/Lex/TokenLexer.h +@@ -13,7 +13,7 @@ + #ifndef LLVM_CLANG_LEX_TOKENLEXER_H + #define LLVM_CLANG_LEX_TOKENLEXER_H + +-#include "clang/Basic/SourceLocation.h" ++#include "clang/Lex/Token.h" // PASTA PATCH + #include "llvm/ADT/ArrayRef.h" + + namespace clang { +@@ -40,6 +40,9 @@ class TokenLexer { + /// The current preprocessor object we are expanding for. + Preprocessor &PP; + ++ // PASTA PATCH: The name token of the macro. ++ Token MacroNameTok; ++ + /// This is the pointer to an array of tokens that the macro is + /// defined to, with arguments expanded for function-like macros. If this is + /// a token stream, these are the tokens we are returning. This points into +diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp +index f3aefdd22..87514f87c 100644 +--- a/clang/lib/Lex/PPDirectives.cpp ++++ b/clang/lib/Lex/PPDirectives.cpp +@@ -441,7 +441,7 @@ Optional Preprocessor::getSkippedRangeForExcludedConditionalBlock( + /// If ElseOk is true, then \#else directives are ok, if not, then we have + /// already seen one so a \#else directive is a duplicate. When this returns, + /// the caller can lex the first valid token. +-void Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc, ++void Preprocessor::SkipExcludedConditionalBlock(const Token &HashToken, // PASTA PATCH + SourceLocation IfTokenLoc, + bool FoundNonSkipPortion, + bool FoundElse, +@@ -455,6 +455,12 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc, + CurPPLexer->pushConditionalLevel(IfTokenLoc, /*isSkipping*/ false, + FoundNonSkipPortion, FoundElse); + ++ // PASTA PATCH ++ SourceLocation HashTokenLoc = HashToken.getLocation(); ++ if (Callbacks) { ++ Callbacks->Event(HashToken, PPCallbacks::BeginSkippedArea, 0); ++ } ++ + // Enter raw mode to disable identifier lookup (and thus macro expansion), + // disabling warnings, etc. + CurPPLexer->LexingRawMode = true; +@@ -974,16 +980,16 @@ private: + /// #define (to warn about macros that don't match the PCH) + /// #pragma (to check for pragma hdrstop). + /// All other directives are completely discarded. +-void Preprocessor::HandleSkippedDirectiveWhileUsingPCH(Token &Result, +- SourceLocation HashLoc) { ++void Preprocessor::HandleSkippedDirectiveWhileUsingPCH( // PASTA PATCH ++ Token &Result, const Token &SavedHash) { // PASTA PATCH + if (const IdentifierInfo *II = Result.getIdentifierInfo()) { + if (II->getPPKeywordID() == tok::pp_define) { +- return HandleDefineDirective(Result, +- /*ImmediatelyAfterHeaderGuard=*/false); ++ return HandleDefineDirective(SavedHash, Result, // PASTA PATCH ++ /*ImmediatelyAfterHeaderGuard=*/false); // PASTA PATCH + } + if (SkippingUntilPCHThroughHeader && + II->getPPKeywordID() == tok::pp_include) { +- return HandleIncludeDirective(HashLoc, Result); ++ return HandleIncludeDirective(SavedHash, Result); // PASTA PATCH + } + if (SkippingUntilPragmaHdrStop && II->getPPKeywordID() == tok::pp_pragma) { + Lex(Result); +@@ -1022,10 +1028,36 @@ void Preprocessor::HandleDirective(Token &Result) { + // Save the '#' token in case we need to return it later. + Token SavedHash = Result; + ++ // PASTA PATCH: Tell us when we're about to start a directive. ++ if (Callbacks) { ++ Callbacks->Event(SavedHash, PPCallbacks::BeginDirective, 0); ++ } ++ + // Read the next token, the directive flavor. This isn't expanded due to + // C99 6.10.3p8. + LexUnexpandedToken(Result); + ++ // PASTA PATCH: Tell us when we're about to start a directive. ++ if (Callbacks) { ++ switch (Result.getKind()) { ++ case tok::identifier: ++ case tok::raw_identifier: ++ case tok::kw_if: ++ case tok::kw_else: ++ Callbacks->Event(SavedHash, PPCallbacks::SetNamedDirective, ++ reinterpret_cast(&Result)); ++ break; ++ case tok::eod: ++ case tok::code_completion: ++ case tok::numeric_constant: ++ case tok::string_literal: ++ default: ++ Callbacks->Event(SavedHash, PPCallbacks::SetUnnamedDirective, ++ reinterpret_cast(&Result)); ++ break; ++ } ++ } ++ + // C99 6.10.3p11: Is this preprocessor directive in macro invocation? e.g.: + // #define A(x) #x + // A(abc +@@ -1059,7 +1091,7 @@ void Preprocessor::HandleDirective(Token &Result) { + ResetMacroExpansionHelper helper(this); + + if (SkippingUntilPCHThroughHeader || SkippingUntilPragmaHdrStop) +- return HandleSkippedDirectiveWhileUsingPCH(Result, SavedHash.getLocation()); ++ return HandleSkippedDirectiveWhileUsingPCH(Result, SavedHash); // PASTA PATCH + + switch (Result.getKind()) { + case tok::eod: +@@ -1073,7 +1105,7 @@ void Preprocessor::HandleDirective(Token &Result) { + case tok::numeric_constant: // # 7 GNU line marker directive. + if (getLangOpts().AsmPreprocessor) + break; // # 4 is not a preprocessor directive in .S files. +- return HandleDigitDirective(Result); ++ return HandleDigitDirective(SavedHash, Result); // PASTA PATCH + default: + IdentifierInfo *II = Result.getIdentifierInfo(); + if (!II) break; // Not an identifier. +@@ -1103,24 +1135,25 @@ void Preprocessor::HandleDirective(Token &Result) { + // C99 6.10.2 - Source File Inclusion. + case tok::pp_include: + // Handle #include. +- return HandleIncludeDirective(SavedHash.getLocation(), Result); ++ return HandleIncludeDirective(SavedHash, Result); // PASTA PATCH + case tok::pp___include_macros: + // Handle -imacros. +- return HandleIncludeMacrosDirective(SavedHash.getLocation(), Result); ++ return HandleIncludeMacrosDirective(SavedHash, Result); // PASTA PATCH + + // C99 6.10.3 - Macro Replacement. + case tok::pp_define: +- return HandleDefineDirective(Result, ImmediatelyAfterTopLevelIfndef); ++ return HandleDefineDirective(SavedHash, Result, // PASTA PATCH ++ ImmediatelyAfterTopLevelIfndef); // PASTA PATCH + case tok::pp_undef: +- return HandleUndefDirective(); ++ return HandleUndefDirective(SavedHash); // PASTA PATCH + + // C99 6.10.4 - Line Control. + case tok::pp_line: +- return HandleLineDirective(); ++ return HandleLineDirective(SavedHash); // PASTA PATCH + + // C99 6.10.5 - Error Directive. + case tok::pp_error: +- return HandleUserDiagnosticDirective(Result, false); ++ return HandleUserDiagnosticDirective(SavedHash, Result, false); // PASTA PATCH + + // C99 6.10.6 - Pragma Directive. + case tok::pp_pragma: +@@ -1128,17 +1161,17 @@ void Preprocessor::HandleDirective(Token &Result) { + + // GNU Extensions. + case tok::pp_import: +- return HandleImportDirective(SavedHash.getLocation(), Result); ++ return HandleImportDirective(SavedHash, Result); // PASTA PATCH + case tok::pp_include_next: +- return HandleIncludeNextDirective(SavedHash.getLocation(), Result); ++ return HandleIncludeNextDirective(SavedHash, Result); // PASTA PATCH + + case tok::pp_warning: + Diag(Result, diag::ext_pp_warning_directive); +- return HandleUserDiagnosticDirective(Result, true); ++ return HandleUserDiagnosticDirective(SavedHash, Result, true); // PASTA PATCH + case tok::pp_ident: +- return HandleIdentSCCSDirective(Result); ++ return HandleIdentSCCSDirective(SavedHash, Result); // PASTA PATCH + case tok::pp_sccs: +- return HandleIdentSCCSDirective(Result); ++ return HandleIdentSCCSDirective(SavedHash, Result); // PASTA PATCH + case tok::pp_assert: + //isExtension = true; // FIXME: implement #assert + break; +@@ -1148,12 +1181,12 @@ void Preprocessor::HandleDirective(Token &Result) { + + case tok::pp___public_macro: + if (getLangOpts().Modules || getLangOpts().ModulesLocalVisibility) +- return HandleMacroPublicDirective(Result); ++ return HandleMacroPublicDirective(SavedHash, Result); // PASTA PATCH + break; + + case tok::pp___private_macro: + if (getLangOpts().Modules || getLangOpts().ModulesLocalVisibility) +- return HandleMacroPrivateDirective(); ++ return HandleMacroPrivateDirective(SavedHash); // PASTA PATCH + break; + } + break; +@@ -1164,6 +1197,11 @@ void Preprocessor::HandleDirective(Token &Result) { + // various pseudo-ops. Just return the # token and push back the following + // token to be lexed next time. + if (getLangOpts().AsmPreprocessor) { ++ // PASTA PATCH: Get visibility on end of macro directives. ++ if (Callbacks) { ++ Callbacks->Event(SavedHash, PPCallbacks::EndNonDirective, 0); ++ } ++ + auto Toks = std::make_unique(2); + // Return the # and the token after it. + Toks[0] = SavedHash; +@@ -1251,7 +1289,7 @@ static bool GetLineValue(Token &DigitTok, unsigned &Val, + /// # line digit-sequence + /// # line digit-sequence "s-char-sequence" + /// \endverbatim +-void Preprocessor::HandleLineDirective() { ++void Preprocessor::HandleLineDirective(const Token &SavedHash) { // PASTA PATCH + // Read the line # and string argument. Per C99 6.10.4p5, these tokens are + // expanded. + Token DigitTok; +@@ -1413,7 +1451,8 @@ static bool ReadLineMarkerFlags(bool &IsFileEntry, bool &IsFileExit, + /// # 42 "file" ('1' | '2')? + /// # 42 "file" ('1' | '2')? '3' '4'? + /// +-void Preprocessor::HandleDigitDirective(Token &DigitTok) { ++void Preprocessor::HandleDigitDirective( // PASTA PATCH ++ const Token &SavedHash, Token &DigitTok) { // PASTA PATCH + // Validate the number and convert it to an unsigned. GNU does not have a + // line # limit other than it fit in 32-bits. + unsigned LineNo; +@@ -1485,8 +1524,8 @@ void Preprocessor::HandleDigitDirective(Token &DigitTok) { + + /// HandleUserDiagnosticDirective - Handle a #warning or #error directive. + /// +-void Preprocessor::HandleUserDiagnosticDirective(Token &Tok, +- bool isWarning) { ++void Preprocessor::HandleUserDiagnosticDirective(const Token &SavedHash, // PASTA PATCH ++ Token &Tok, bool isWarning) { // PASTA PATCH + // Read the rest of the line raw. We do this because we don't want macros + // to be expanded and we don't require that the tokens be valid preprocessing + // tokens. For example, this is allowed: "#warning ` 'foo". GCC does +@@ -1507,7 +1546,8 @@ void Preprocessor::HandleUserDiagnosticDirective(Token &Tok, + + /// HandleIdentSCCSDirective - Handle a #ident/#sccs directive. + /// +-void Preprocessor::HandleIdentSCCSDirective(Token &Tok) { ++void Preprocessor::HandleIdentSCCSDirective(const Token &SavedHash, // PASTA PATCH ++ Token &Tok) { // PASTA PATCH + // Yes, this directive is an extension. + Diag(Tok, diag::ext_pp_ident_directive); + +@@ -1542,7 +1582,8 @@ void Preprocessor::HandleIdentSCCSDirective(Token &Tok) { + } + + /// Handle a #public directive. +-void Preprocessor::HandleMacroPublicDirective(Token &Tok) { ++void Preprocessor::HandleMacroPublicDirective(const Token &SavedHash, // PASTA PATCH ++ Token &Tok) { // PASTA PATCH + Token MacroNameTok; + ReadMacroName(MacroNameTok, MU_Undef); + +@@ -1569,7 +1610,7 @@ void Preprocessor::HandleMacroPublicDirective(Token &Tok) { + } + + /// Handle a #private directive. +-void Preprocessor::HandleMacroPrivateDirective() { ++void Preprocessor::HandleMacroPrivateDirective(const Token &SavedHash) { // PASTA PATCH + Token MacroNameTok; + ReadMacroName(MacroNameTok, MU_Undef); + +@@ -1783,10 +1824,11 @@ bool Preprocessor::checkModuleIsAvailable(const LangOptions &LangOpts, + /// routine with functionality shared between \#include, \#include_next and + /// \#import. LookupFrom is set when this is a \#include_next directive, it + /// specifies the file to start searching from. +-void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc, ++void Preprocessor::HandleIncludeDirective(const Token &SavedHash, // PASTA PATCH + Token &IncludeTok, + const DirectoryLookup *LookupFrom, + const FileEntry *LookupFromFile) { ++ SourceLocation HashLoc = SavedHash.getLocation(); // PASTA PATCH + Token FilenameTok; + if (LexHeaderName(FilenameTok)) + return; +@@ -2393,7 +2435,7 @@ Preprocessor::ImportAction Preprocessor::HandleHeaderIncludeOrImport( + + /// HandleIncludeNextDirective - Implements \#include_next. + /// +-void Preprocessor::HandleIncludeNextDirective(SourceLocation HashLoc, ++void Preprocessor::HandleIncludeNextDirective(const Token &SavedHash, // PASTA PATCH + Token &IncludeNextTok) { + Diag(IncludeNextTok, diag::ext_pp_include_next_directive); + +@@ -2426,7 +2468,7 @@ void Preprocessor::HandleIncludeNextDirective(SourceLocation HashLoc, + ++Lookup; + } + +- return HandleIncludeDirective(HashLoc, IncludeNextTok, Lookup, ++ return HandleIncludeDirective(SavedHash, IncludeNextTok, Lookup, + LookupFromFile); + } + +@@ -2446,21 +2488,21 @@ void Preprocessor::HandleMicrosoftImportDirective(Token &Tok) { + + /// HandleImportDirective - Implements \#import. + /// +-void Preprocessor::HandleImportDirective(SourceLocation HashLoc, +- Token &ImportTok) { ++void Preprocessor::HandleImportDirective(const Token &SavedHash, // PASTA PATCH ++ Token &ImportTok) { // PASTA PATCH + if (!LangOpts.ObjC) { // #import is standard for ObjC. + if (LangOpts.MSVCCompat) + return HandleMicrosoftImportDirective(ImportTok); + Diag(ImportTok, diag::ext_pp_import_directive); + } +- return HandleIncludeDirective(HashLoc, ImportTok); ++ return HandleIncludeDirective(SavedHash, ImportTok); // PASTA PATCH + } + + /// HandleIncludeMacrosDirective - The -imacros command line option turns into a + /// pseudo directive in the predefines buffer. This handles it by sucking all + /// tokens through the preprocessor and discarding them (only keeping the side + /// effects on the preprocessor). +-void Preprocessor::HandleIncludeMacrosDirective(SourceLocation HashLoc, ++void Preprocessor::HandleIncludeMacrosDirective(const Token &SavedHash, // PASTA PATCH + Token &IncludeMacrosTok) { + // This directive should only occur in the predefines buffer. If not, emit an + // error and reject it. +@@ -2474,7 +2516,7 @@ void Preprocessor::HandleIncludeMacrosDirective(SourceLocation HashLoc, + + // Treat this as a normal #include for checking purposes. If this is + // successful, it will push a new lexer onto the include stack. +- HandleIncludeDirective(HashLoc, IncludeMacrosTok); ++ HandleIncludeDirective(SavedHash, IncludeMacrosTok); // PASTA PATCH + + Token TmpTok; + do { +@@ -2860,7 +2902,8 @@ MacroInfo *Preprocessor::ReadOptionalMacroParameterListAndBody( + /// HandleDefineDirective - Implements \#define. This consumes the entire macro + /// line then lets the caller lex the next real token. + void Preprocessor::HandleDefineDirective( +- Token &DefineTok, const bool ImmediatelyAfterHeaderGuard) { ++ const Token &SavedHash, Token &DefineTok, // PASTA PATCH ++ const bool ImmediatelyAfterHeaderGuard) { // PASTA PATCH + ++NumDefined; + + Token MacroNameTok; +@@ -3014,7 +3057,7 @@ void Preprocessor::HandleDefineDirective( + + /// HandleUndefDirective - Implements \#undef. + /// +-void Preprocessor::HandleUndefDirective() { ++void Preprocessor::HandleUndefDirective(const Token &SavedHash) { // PASTA PATCH + ++NumUndefined; + + Token MacroNameTok; +@@ -3078,7 +3121,7 @@ void Preprocessor::HandleIfdefDirective(Token &Result, + if (MacroNameTok.is(tok::eod)) { + // Skip code until we get to #endif. This helps with recovery by not + // emitting an error when the #endif is reached. +- SkipExcludedConditionalBlock(HashToken.getLocation(), ++ SkipExcludedConditionalBlock(HashToken, // PASTA PATCH + DirectiveTok.getLocation(), + /*Foundnonskip*/ false, /*FoundElse*/ false); + return; +@@ -3133,7 +3176,7 @@ void Preprocessor::HandleIfdefDirective(Token &Result, + /*foundelse*/false); + } else { + // No, skip the contents of this block. +- SkipExcludedConditionalBlock(HashToken.getLocation(), ++ SkipExcludedConditionalBlock(HashToken, // PASTA PATCH + DirectiveTok.getLocation(), + /*Foundnonskip*/ false, + /*FoundElse*/ false); +@@ -3186,7 +3229,7 @@ void Preprocessor::HandleIfDirective(Token &IfToken, + /*foundnonskip*/true, /*foundelse*/false); + } else { + // No, skip the contents of this block. +- SkipExcludedConditionalBlock(HashToken.getLocation(), IfToken.getLocation(), ++ SkipExcludedConditionalBlock(HashToken, IfToken.getLocation(), // PASTA PATCH + /*Foundnonskip*/ false, + /*FoundElse*/ false); + } +@@ -3254,7 +3297,7 @@ void Preprocessor::HandleElseDirective(Token &Result, const Token &HashToken) { + } + + // Finally, skip the rest of the contents of this block. +- SkipExcludedConditionalBlock(HashToken.getLocation(), CI.IfLoc, ++ SkipExcludedConditionalBlock(HashToken, CI.IfLoc, // PASTA PATCH + /*Foundnonskip*/ true, + /*FoundElse*/ true, Result.getLocation()); + } +@@ -3318,6 +3361,6 @@ void Preprocessor::HandleElifFamilyDirective(Token &ElifToken, + + // Finally, skip the rest of the contents of this block. + SkipExcludedConditionalBlock( +- HashToken.getLocation(), CI.IfLoc, /*Foundnonskip*/ true, ++ HashToken, CI.IfLoc, /*Foundnonskip*/ true, // PASTA PATCH + /*FoundElse*/ CI.FoundElse, ElifToken.getLocation()); + } +diff --git a/clang/lib/Lex/PPExpressions.cpp b/clang/lib/Lex/PPExpressions.cpp +index 424cccfdb..d1ee58ce8 100644 +--- a/clang/lib/Lex/PPExpressions.cpp ++++ b/clang/lib/Lex/PPExpressions.cpp +@@ -101,6 +101,32 @@ struct DefinedTracker { + /// EvaluateDefined - Process a 'defined(sym)' expression. + static bool EvaluateDefined(PPValue &Result, Token &PeekTok, DefinedTracker &DT, + bool ValueLive, Preprocessor &PP) { ++ // PASTA PATCH ++ PPCallbacks *Callbacks = PP.getPPCallbacks(); ++ Token SavedStart = PeekTok; ++ if (Callbacks) { ++ Callbacks->Event(SavedStart, PPCallbacks::BeginDelayedSubstitution, 0); ++ } ++ auto Expand = [&] (void) { ++ if (Callbacks) { ++ Token ResultTok; ++ ResultTok.startToken(); ++ ResultTok.setKind(tok::numeric_constant); ++ const char *ResultStr = Result.Val.getExtValue() ? "1" : "0"; ++ PP.CreateString(ResultStr, ResultTok, SavedStart.getLocation(), ++ PeekTok.getEndLoc()); ++ ++ Callbacks->Event(PeekTok, PPCallbacks::SwitchToSubstitution, ++ reinterpret_cast(&SavedStart)); ++ ++ Callbacks->Event(ResultTok, PPCallbacks::TokenFromTokenLexer, ++ SavedStart.getLocation().getRawEncoding()); ++ ++ Callbacks->Event(SavedStart, PPCallbacks::EndSubstitution, ++ reinterpret_cast(&SavedStart)); ++ } ++ }; ++ + SourceLocation beginLoc(PeekTok.getLocation()); + Result.setBegin(beginLoc); + +@@ -154,12 +180,14 @@ static bool EvaluateDefined(PPValue &Result, Token &PeekTok, DefinedTracker &DT, + PP.Diag(LParenLoc, diag::note_matching) << tok::l_paren; + return true; + } ++ Expand(); // PASTA PATCH + // Consume the ). + PP.LexNonComment(PeekTok); + Result.setEnd(PeekTok.getLocation()); + } else { + // Consume identifier. + Result.setEnd(PeekTok.getLocation()); ++ Expand(); // PASTA PATCH + PP.LexNonComment(PeekTok); + } + +diff --git a/clang/lib/Lex/PPLexerChange.cpp b/clang/lib/Lex/PPLexerChange.cpp +index f8b0a2c5f..f2d7b3d5a 100644 +--- a/clang/lib/Lex/PPLexerChange.cpp ++++ b/clang/lib/Lex/PPLexerChange.cpp +@@ -30,6 +30,36 @@ using namespace clang; + // Miscellaneous Methods. + //===----------------------------------------------------------------------===// + ++void Preprocessor::PopIncludeMacroStack() { ++ ++ // PASTA PATCH: Tell us about the end of macro expansions. ++ if (Callbacks && CurTokenLexer && CurTokenLexer->Macro) { ++ Callbacks->Event(CurTokenLexer->MacroNameTok, ++ PPCallbacks::EndMacroExpansion, ++ reinterpret_cast(CurTokenLexer->Macro)); ++ } ++ ++ // PASTA PATCH: Make us aware of the end of `_Pragma` handling. ++ if (Callbacks && CurPPLexer && CurLexer.get() == CurPPLexer && ++ CurLexer->isPragmaLexer()) { ++ Token PragmaTok; ++ PragmaTok.setKind(tok::raw_identifier); ++ PragmaTok.setLocation(SourceMgr.getExpansionLoc(CurLexer->getFileLoc())); ++ PragmaTok.setLength(7u); ++ PragmaTok.setRawIdentifierData( ++ SourceMgr.getCharacterData(PragmaTok.getLocation(), nullptr)); ++ Callbacks->Event(PragmaTok, PPCallbacks::EndMacroExpansion, 0); ++ } ++ ++ CurLexer = std::move(IncludeMacroStack.back().TheLexer); ++ CurPPLexer = IncludeMacroStack.back().ThePPLexer; ++ CurTokenLexer = std::move(IncludeMacroStack.back().TheTokenLexer); ++ CurDirLookup = IncludeMacroStack.back().TheDirLookup; ++ CurLexerSubmodule = IncludeMacroStack.back().TheSubmodule; ++ CurLexerKind = IncludeMacroStack.back().CurLexerKind; ++ IncludeMacroStack.pop_back(); ++} ++ + /// isInPrimaryFile - Return true if we're in the top-level file, not in a + /// \#include. This looks through macro expansions and active _Pragma lexers. + bool Preprocessor::isInPrimaryFile() const { +@@ -592,6 +622,14 @@ bool Preprocessor::HandleEndOfTokenLexer(Token &Result) { + assert(CurTokenLexer && !CurPPLexer && + "Ending a macro when currently in a #include file!"); + ++ // PASTA PATCH: Tell us about the end of macro expansions. ++ if (CurTokenLexer && CurTokenLexer->Macro) { ++ Callbacks->Event(CurTokenLexer->MacroNameTok, ++ PPCallbacks::EndMacroExpansion, ++ reinterpret_cast(CurTokenLexer->Macro)); ++ CurTokenLexer->Macro = nullptr; ++ } ++ + if (!MacroExpandingLexersStack.empty() && + MacroExpandingLexersStack.back().first == CurTokenLexer.get()) + removeCachedMacroExpandedTokensOfLastLexer(); +diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp +index f6c95a8b6..9597676c3 100644 +--- a/clang/lib/Lex/PPMacroExpansion.cpp ++++ b/clang/lib/Lex/PPMacroExpansion.cpp +@@ -472,6 +472,13 @@ bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier, + + MacroInfo *MI = M.getMacroInfo(); + ++ // PASTA PATCH: Visibility into macro expansion. ++ Token SavedIdentifier = Identifier; ++ if (Callbacks) { ++ Callbacks->Event(SavedIdentifier, PPCallbacks::BeginMacroExpansion, ++ reinterpret_cast(MI)); ++ } ++ + // If this is a macro expansion in the "#if !defined(x)" line for the file, + // then the macro could expand to different things in other contexts, we need + // to disable the optimization in this case. +@@ -482,6 +489,7 @@ bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier, + if (Callbacks) + Callbacks->MacroExpands(Identifier, M, Identifier.getLocation(), + /*Args=*/nullptr); ++ + ExpandBuiltinMacro(Identifier); + return true; + } +@@ -503,7 +511,22 @@ bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier, + InMacroArgs = true; + ArgMacro = &Identifier; + +- Args = ReadMacroCallArgumentList(Identifier, MI, ExpansionEnd); ++ // PASTA PATCH: Visibility into macro expansion. ++ if (Callbacks) { ++ Callbacks->Event(SavedIdentifier, PPCallbacks::BeginMacroCallArgumentList, ++ reinterpret_cast(MI)); ++ } ++ ++ // PASTA PATCH: Visibility to last token in argument list. ++ Token ExpansionEndTok; ++ Args = ReadMacroCallArgumentList(Identifier, MI, ExpansionEndTok); ++ ExpansionEnd = ExpansionEndTok.getLocation(); ++ ++ // PASTA PATCH: Visibility into macro expansion. ++ if (Callbacks) { ++ Callbacks->Event(ExpansionEndTok, PPCallbacks::EndMacroCallArgumentList, ++ reinterpret_cast(Args)); ++ } + + // Finished parsing args. + InMacroArgs = false; +@@ -562,7 +585,7 @@ bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier, + + // If this macro expands to no tokens, don't bother to push it onto the + // expansion stack, only to take it right back off. +- if (MI->getNumTokens() == 0) { ++ if (false && MI->getNumTokens() == 0) { // PASTA PATCH + // No need for arg info. + if (Args) Args->destroy(*this); + +@@ -572,7 +595,7 @@ bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier, + PropagateLineStartLeadingSpaceInfo(Identifier); + ++NumFastMacroExpanded; + return false; +- } else if (MI->getNumTokens() == 1 && ++ } else if (false && MI->getNumTokens() == 1 && // PASTA PATCH + isTrivialSingleTokenExpansion(MI, Identifier.getIdentifierInfo(), + *this)) { + // Otherwise, if this macro expands into a single trivially-expanded +@@ -620,6 +643,12 @@ bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier, + return true; + } + ++ // PASTA PATCH: Switch state to now start expanding. ++ if (Callbacks) { ++ Callbacks->Event(SavedIdentifier, PPCallbacks::SwitchToExpansion, ++ reinterpret_cast(MI)); ++ } ++ + // Start expanding the macro. + EnterMacro(Identifier, ExpansionEnd, MI, Args); + return false; +@@ -759,14 +788,11 @@ static bool GenerateNewArgTokens(Preprocessor &PP, + /// error. + MacroArgs *Preprocessor::ReadMacroCallArgumentList(Token &MacroName, + MacroInfo *MI, +- SourceLocation &MacroEnd) { ++ Token &Tok) { + // The number of fixed arguments to parse. + unsigned NumFixedArgsLeft = MI->getNumParams(); + bool isVariadic = MI->isVariadic(); + +- // Outer loop, while there are more arguments, keep reading them. +- Token Tok; +- + // Read arguments as unexpanded tokens. This avoids issues, e.g., where + // an argument value in a macro could expand to ',' or '(' or ')'. + LexUnexpandedToken(Tok); +@@ -778,6 +804,7 @@ MacroArgs *Preprocessor::ReadMacroCallArgumentList(Token &MacroName, + SmallVector ArgTokens; + bool ContainsCodeCompletionTok = false; + bool FoundElidedComma = false; ++ bool InVariadicSection = false; // PASTA PATCH + + SourceLocation TooManyArgsLoc; + +@@ -792,6 +819,20 @@ MacroArgs *Preprocessor::ReadMacroCallArgumentList(Token &MacroName, + size_t ArgTokenStart = ArgTokens.size(); + SourceLocation ArgStartLoc = Tok.getLocation(); + ++ // PASTA PATCH: Visibility into macro expansion. ++ Token ArgStartTok = Tok; ++ if (Callbacks) { ++ if (isVariadic && !NumFixedArgsLeft) { ++ Callbacks->Event(ArgStartTok, PPCallbacks::BeginVariadicCallArgumentList, ++ reinterpret_cast(&MacroName)); ++ InVariadicSection = true; ++ } ++ if (NumFixedArgsLeft) { ++ Callbacks->Event(ArgStartTok, PPCallbacks::BeginMacroCallArgument, ++ reinterpret_cast(&MacroName)); ++ } ++ } ++ + // C99 6.10.3p11: Keep track of the number of l_parens we have seen. Note + // that we already consumed the first one. + unsigned NumParens = 0; +@@ -816,9 +857,10 @@ MacroArgs *Preprocessor::ReadMacroCallArgumentList(Token &MacroName, + EnterTokenStream(std::move(Toks), 1, true, /*IsReinject*/ false); + break; + } else if (Tok.is(tok::r_paren)) { ++ + // If we found the ) token, the macro arg list is done. + if (NumParens-- == 0) { +- MacroEnd = Tok.getLocation(); ++ // MacroEnd = Tok.getLocation(); // PASTA PATCH + if (!ArgTokens.empty() && + ArgTokens.back().commaAfterElided()) { + FoundElidedComma = true; +@@ -846,6 +888,23 @@ MacroArgs *Preprocessor::ReadMacroCallArgumentList(Token &MacroName, + break; + if (NumFixedArgsLeft > 1) + break; ++ ++ // PASTA PATCH: Visibility into variadic macro expansion. ++ if (Callbacks) { ++ Callbacks->Event(ArgStartTok, PPCallbacks::EndMacroCallArgument, ++ reinterpret_cast(&Tok)); ++ ArgStartTok = Tok; ++ ++ if (!InVariadicSection) { ++ Callbacks->Event( ++ ArgStartTok, PPCallbacks::BeginVariadicCallArgumentList, ++ reinterpret_cast(&MacroName)); ++ InVariadicSection = true; ++ } ++ ++ Callbacks->Event(ArgStartTok, PPCallbacks::BeginMacroCallArgument, ++ reinterpret_cast(&MacroName)); ++ } + } + } else if (Tok.is(tok::comment) && !KeepMacroComments) { + // If this is a comment token in the argument list and we're just in +@@ -874,6 +933,16 @@ MacroArgs *Preprocessor::ReadMacroCallArgumentList(Token &MacroName, + ArgTokens.push_back(Tok); + } + ++ // PASTA PATCH: ++ if (Callbacks) { ++ Callbacks->Event(ArgStartTok, PPCallbacks::EndMacroCallArgument, ++ reinterpret_cast(&Tok)); ++ if (InVariadicSection) { ++ Callbacks->Event(ArgStartTok, PPCallbacks::EndVariadicCallArgumentList, ++ reinterpret_cast(&Tok)); ++ } ++ } ++ + // If this was an empty argument list foo(), don't add this as an empty + // argument. + if (ArgTokens.empty() && Tok.getKind() == tok::r_paren) +@@ -1161,6 +1230,17 @@ static bool EvaluateHasIncludeCommon(Token &Tok, + IdentifierInfo *II, Preprocessor &PP, + const DirectoryLookup *LookupFrom, + const FileEntry *LookupFromFile) { ++ // PASTA PATCH: Visibility into macro expansion. ++ PPCallbacks *Callbacks = PP.getPPCallbacks(); ++ Token SavedIdentifier = Tok; ++ SavedIdentifier.setIdentifierInfo(II); ++ MacroDefinition MD = PP.getMacroDefinition(II); ++ MacroInfo *MI = MD.getMacroInfo(); ++ if (Callbacks) { ++ Callbacks->Event(SavedIdentifier, PPCallbacks::BeginMacroCallArgumentList, ++ reinterpret_cast(MI)); ++ } ++ + // Save the location of the current token. If a '(' is later found, use + // that location. If not, use the end of this location instead. + SourceLocation LParenLoc = Tok.getLocation(); +@@ -1180,6 +1260,8 @@ static bool EvaluateHasIncludeCommon(Token &Tok, + return false; + } while (Tok.getKind() == tok::comment); + ++ Token LParenTok = Tok; // PASTA PATCH ++ + // Ensure we have a '('. + if (Tok.isNot(tok::l_paren)) { + // No '(', use end of last token. +@@ -1190,6 +1272,10 @@ static bool EvaluateHasIncludeCommon(Token &Tok, + if (Tok.isNot(tok::header_name)) + return false; + } else { ++ if (Callbacks) { ++ Callbacks->Event(LParenTok, PPCallbacks::BeginMacroCallArgument, ++ reinterpret_cast(&SavedIdentifier)); ++ } + // Save '(' location for possible missing ')' message. + LParenLoc = Tok.getLocation(); + if (PP.LexHeaderName(Tok)) +@@ -1221,6 +1307,16 @@ static bool EvaluateHasIncludeCommon(Token &Tok, + return false; + } + ++ // PASTA PATCH ++ if (Callbacks) { ++ Callbacks->Event(LParenTok, PPCallbacks::EndMacroCallArgument, ++ reinterpret_cast(&Tok)); ++ Callbacks->Event(LParenTok, PPCallbacks::EndMacroCallArgumentList, ++ 0); ++ Callbacks->Event(SavedIdentifier, PPCallbacks::SwitchToExpansion, ++ reinterpret_cast(MI)); ++ } ++ + bool isAngled = PP.GetIncludeFilenameSpelling(Tok.getLocation(), Filename); + // If GetIncludeFilenameSpelling set the start ptr to null, there was an + // error. +@@ -1293,9 +1389,27 @@ static void EvaluateFeatureLikeBuiltinMacro(llvm::raw_svector_ostream& OS, + llvm::function_ref< + int(Token &Tok, + bool &HasLexedNextTok)> Op) { ++ ++ // PASTA PATCH: Visibility into macro expansion. ++ PPCallbacks *Callbacks = PP.getPPCallbacks(); ++ Token SavedIdentifier = Tok; ++ SavedIdentifier.setIdentifierInfo(II); ++ MacroDefinition MD = PP.getMacroDefinition(II); ++ MacroInfo *MI = MD.getMacroInfo(); ++ if (Callbacks) { ++ Callbacks->Event(SavedIdentifier, PPCallbacks::BeginMacroCallArgumentList, ++ reinterpret_cast(MI)); ++ } ++ + // Parse the initial '('. + PP.LexUnexpandedToken(Tok); + if (Tok.isNot(tok::l_paren)) { ++ ++ // PASTA PATCH ++ if (Callbacks) { ++ Callbacks->Event(Tok, PPCallbacks::EndMacroCallArgumentList, 0); ++ } ++ + PP.Diag(Tok.getLocation(), diag::err_pp_expected_after) << II + << tok::l_paren; + +@@ -1307,6 +1421,22 @@ static void EvaluateFeatureLikeBuiltinMacro(llvm::raw_svector_ostream& OS, + return; + } + ++ // PASTA PATCH ++ Token ArgBeginTok = Tok; ++ if (Callbacks) { ++ Callbacks->Event(ArgBeginTok, PPCallbacks::BeginMacroCallArgument, ++ reinterpret_cast(&SavedIdentifier)); ++ } ++ bool DoneDone = false; ++ auto Done = [&] (void) { ++ if (!DoneDone && Callbacks) { ++ DoneDone = true; ++ Callbacks->Event(ArgBeginTok, PPCallbacks::EndMacroCallArgument, ++ reinterpret_cast(&Tok)); ++ Callbacks->Event(Tok, PPCallbacks::EndMacroCallArgumentList, 0); ++ } ++ }; ++ + unsigned ParenDepth = 1; + SourceLocation LParenLoc = Tok.getLocation(); + llvm::Optional Result; +@@ -1327,6 +1457,7 @@ already_lexed: + // Don't provide even a dummy value if the eod or eof marker is + // reached. Simply provide a diagnostic. + PP.Diag(Tok.getLocation(), diag::err_unterm_macro_invoc); ++ Done(); // PASTA PATCH + return; + + case tok::comma: +@@ -1334,6 +1465,13 @@ already_lexed: + PP.Diag(Tok.getLocation(), diag::err_too_many_args_in_macro_invoc); + SuppressDiagnostic = true; + } ++ if (Callbacks) { ++ Callbacks->Event(ArgBeginTok, PPCallbacks::EndMacroCallArgument, ++ reinterpret_cast(&Tok)); ++ ArgBeginTok = Tok; ++ Callbacks->Event(ArgBeginTok, PPCallbacks::BeginMacroCallArgument, ++ reinterpret_cast(&SavedIdentifier)); ++ } + continue; + + case tok::l_paren: +@@ -1363,6 +1501,7 @@ already_lexed: + if (!SuppressDiagnostic) + PP.Diag(Tok.getLocation(), diag::err_too_few_args_in_macro_invoc); + } ++ Done(); // PASTA PATCH + Tok.setKind(tok::numeric_constant); + return; + +@@ -1371,6 +1510,13 @@ already_lexed: + if (Result.hasValue()) + break; + ++ // PASTA PATCH ++ Done(); ++ if (Callbacks) { ++ Callbacks->Event(SavedIdentifier, PPCallbacks::SwitchToExpansion, ++ reinterpret_cast(MI)); ++ } ++ + bool HasLexedNextToken = false; + Result = Op(Tok, HasLexedNextToken); + ResultTok = Tok; +@@ -1393,6 +1539,8 @@ already_lexed: + SuppressDiagnostic = true; + } + } ++ ++ Done(); // PASTA PATCH + } + + /// Helper function to return the IdentifierInfo structure of a Token +@@ -1458,6 +1606,38 @@ static bool isTargetEnvironment(const TargetInfo &TI, + return TI.getTriple().getEnvironment() == Env.getEnvironment(); + } + ++// PASTA PATCH: Tell us about the end of macro expansions. We have to add ++// this as a post-lex action, so that we can observe what is actually lexed ++// into `Identifier`. ++struct DeferExpansionEnd { ++ std::function &PostLexAction; ++ PPCallbacks * const Callbacks; ++ Token Identifier; ++ MacroInfo * const MI; ++ ++ DeferExpansionEnd(std::function &PostLexAction_, ++ PPCallbacks *Callbacks_, Token Identifier_, MacroInfo *MI_) ++ : PostLexAction(PostLexAction_), ++ Callbacks(Callbacks_), ++ Identifier(std::move(Identifier_)), ++ MI(MI_) {} ++ ++ ~DeferExpansionEnd(void) { ++ if (Callbacks) { ++ auto CB = Callbacks; ++ auto Ident = std::move(Identifier); ++ auto Info = MI; ++ PostLexAction = [CB, Ident, Info, ++ PrevPostLexAction = std::move(PostLexAction)] ++ (const Token &Tok) { ++ CB->Event(Ident, PPCallbacks::EndMacroExpansion, ++ reinterpret_cast(Info)); ++ PrevPostLexAction(Tok); ++ }; ++ } ++ } ++}; ++ + /// ExpandBuiltinMacro - If an identifier token is read that is to be expanded + /// as a builtin macro, handle it and return the next token as 'Tok'. + void Preprocessor::ExpandBuiltinMacro(Token &Tok) { +@@ -1483,7 +1663,22 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { + bool IsAtStartOfLine = Tok.isAtStartOfLine(); + bool HasLeadingSpace = Tok.hasLeadingSpace(); + ++ // PASTA PATCH: ++ Token SavedIdentifier = Tok; ++ SavedIdentifier.setIdentifierInfo(II); ++ MacroDefinition MD = getMacroDefinition(II); ++ MacroInfo *MI = MD.getMacroInfo(); ++ DeferExpansionEnd NotifyMacroEnd(PostLexAction, Callbacks.get(), ++ SavedIdentifier, MI); ++ auto SwitchToExpansion = [&] (void) { ++ if (Callbacks) { ++ Callbacks->Event(SavedIdentifier, PPCallbacks::SwitchToExpansion, ++ reinterpret_cast(MI)); ++ } ++ }; ++ + if (II == Ident__LINE__) { ++ SwitchToExpansion(); // PASTA PATCH + // C99 6.10.8: "__LINE__: The presumed line number (within the current + // source file) of the current source line (an integer constant)". This can + // be affected by #line. +@@ -1506,6 +1701,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { + Tok.setKind(tok::numeric_constant); + } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__ || + II == Ident__FILE_NAME__) { ++ SwitchToExpansion(); // PASTA PATCH + // C99 6.10.8: "__FILE__: The presumed name of the current source file (a + // character string literal)". This can be affected by #line. + PresumedLoc PLoc = SourceMgr.getPresumedLoc(Tok.getLocation()); +@@ -1545,6 +1741,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { + } + Tok.setKind(tok::string_literal); + } else if (II == Ident__DATE__) { ++ SwitchToExpansion(); // PASTA PATCH + Diag(Tok.getLocation(), diag::warn_pp_date_time); + if (!DATELoc.isValid()) + ComputeDATE_TIME(DATELoc, TIMELoc, *this); +@@ -1555,6 +1752,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { + Tok.getLength())); + return; + } else if (II == Ident__TIME__) { ++ SwitchToExpansion(); // PASTA PATCH + Diag(Tok.getLocation(), diag::warn_pp_date_time); + if (!TIMELoc.isValid()) + ComputeDATE_TIME(DATELoc, TIMELoc, *this); +@@ -1565,6 +1763,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { + Tok.getLength())); + return; + } else if (II == Ident__INCLUDE_LEVEL__) { ++ SwitchToExpansion(); // PASTA PATCH + // Compute the presumed include depth of this token. This can be affected + // by GNU line markers. + unsigned Depth = 0; +@@ -1580,6 +1779,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { + OS << Depth; + Tok.setKind(tok::numeric_constant); + } else if (II == Ident__TIMESTAMP__) { ++ SwitchToExpansion(); // PASTA PATCH + Diag(Tok.getLocation(), diag::warn_pp_date_time); + // MSVC, ICC, GCC, VisualAge C++ extension. The generated string should be + // of the form "Ddd Mmm dd hh::mm::ss yyyy", which is returned by asctime. +@@ -1604,6 +1804,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { + OS << '"' << StringRef(Result).drop_back() << '"'; + Tok.setKind(tok::string_literal); + } else if (II == Ident__COUNTER__) { ++ SwitchToExpansion(); // PASTA PATCH + // __COUNTER__ expands to a simple numeric value. + OS << CounterValue++; + Tok.setKind(tok::numeric_constant); +@@ -1785,6 +1986,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { + (II->getName() == getLangOpts().CurrentModule); + }); + } else if (II == Ident__MODULE__) { ++ SwitchToExpansion(); // PASTA PATCH + // The current module as an identifier. + OS << getLangOpts().CurrentModule; + IdentifierInfo *ModuleII = getIdentifierInfo(getLangOpts().CurrentModule); +@@ -1793,6 +1995,12 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { + } else if (II == Ident__identifier) { + SourceLocation Loc = Tok.getLocation(); + ++ // PASTA PATCH ++ if (Callbacks) { ++ Callbacks->Event(SavedIdentifier, PPCallbacks::BeginMacroCallArgumentList, ++ 0); ++ } ++ + // We're expecting '__identifier' '(' identifier ')'. Try to recover + // if the parens are missing. + LexNonComment(Tok); +@@ -1806,6 +2014,13 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { + return; + } + ++ // PASTA PATCH ++ Token LParenTok = Tok; ++ if (Callbacks) { ++ Callbacks->Event(LParenTok, PPCallbacks::BeginMacroCallArgument, ++ reinterpret_cast(&SavedIdentifier)); ++ } ++ + SourceLocation LParenLoc = Tok.getLocation(); + LexNonComment(Tok); + +@@ -1834,6 +2049,15 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { + << Tok.getKind() << tok::r_paren; + Diag(LParenLoc, diag::note_matching) << tok::l_paren; + } ++ ++ // PASTA PATCH ++ if (Callbacks) { ++ Callbacks->Event(LParenTok, PPCallbacks::EndMacroCallArgument, ++ reinterpret_cast(&Tok)); ++ Callbacks->Event(Tok, PPCallbacks::EndMacroCallArgumentList, 0); ++ } ++ SwitchToExpansion(); // PASTA PATCH ++ + return; + } else if (II == Ident__is_target_arch) { + EvaluateFeatureLikeBuiltinMacro( +diff --git a/clang/lib/Lex/Pragma.cpp b/clang/lib/Lex/Pragma.cpp +index eb7e7cbc4..83cf8d37b 100644 +--- a/clang/lib/Lex/Pragma.cpp ++++ b/clang/lib/Lex/Pragma.cpp +@@ -209,10 +209,29 @@ void Preprocessor::Handle_Pragma(Token &Tok) { + // In Case #2, we check the syntax now, but then put the tokens back into the + // token stream for later consumption. + ++ // PASTA PATCH ++ // If we're expanding a macro argument, then skip the eager checking done ++ // for case 2, and let it happen later. ++ Token SavedIdentifier = Tok; ++ MacroDefinition MD = getMacroDefinition(Tok.getIdentifierInfo()); ++ MacroInfo *MI = MD.getMacroInfo(); ++ if (InMacroArgPreExpansion) { ++ if (Callbacks) { ++ Callbacks->Event(SavedIdentifier, PPCallbacks::CancelExpansion, ++ reinterpret_cast(MI)); ++ } ++ return; ++ } ++ if (Callbacks) { ++ Callbacks->Event(SavedIdentifier, PPCallbacks::BeginMacroCallArgumentList, ++ reinterpret_cast(MI)); ++ } ++ + TokenCollector Toks = {*this, InMacroArgPreExpansion, {}, Tok}; + + // Remember the pragma token location. + SourceLocation PragmaLoc = Tok.getLocation(); ++ SourceLocation PragmaEndLoc = Tok.getEndLoc(); // PASTA PATCH + + // Read the '('. + Toks.lex(); +@@ -221,6 +240,13 @@ void Preprocessor::Handle_Pragma(Token &Tok) { + return; + } + ++ // PASTA PATCH ++ Token LParenTok = Tok; ++ if (Callbacks) { ++ Callbacks->Event(LParenTok, PPCallbacks::BeginMacroCallArgument, ++ reinterpret_cast(&SavedIdentifier)); ++ } ++ + // Read the '"..."'. + Toks.lex(); + if (!tok::isStringLiteral(Tok.getKind())) { +@@ -256,6 +282,32 @@ void Preprocessor::Handle_Pragma(Token &Tok) { + return; + } + ++ // PASTA PATCH: Go and simulate the directive events that would have happened ++ // if this had been an actual `#pragma` directive. ++ Token HashTok; ++ Token PragmaDirectiveTok; ++ if (Callbacks) { ++ Callbacks->Event(LParenTok, PPCallbacks::EndMacroCallArgument, ++ reinterpret_cast(&Tok)); ++ Callbacks->Event(LParenTok, PPCallbacks::EndMacroCallArgumentList, 0); ++ Callbacks->Event(SavedIdentifier, PPCallbacks::SwitchToExpansion, ++ reinterpret_cast(MI)); ++ ++ HashTok.startToken(); ++ HashTok.setKind(tok::hash); ++ HashTok.setLocation(PragmaLoc); ++ HashTok.setLength(1u); ++ Callbacks->Event(HashTok, PPCallbacks::BeginDirective, 0); ++ ++ PragmaDirectiveTok.startToken(); ++ PragmaDirectiveTok.setKind(tok::raw_identifier); ++ CreateString("pragma", PragmaDirectiveTok, PragmaLoc.getLocWithOffset(1), ++ PragmaEndLoc); ++ Callbacks->Event(PragmaDirectiveTok, PPCallbacks::TokenFromLexer, 0); ++ Callbacks->Event(HashTok, PPCallbacks::SetNamedDirective, ++ reinterpret_cast(&PragmaDirectiveTok)); ++ } ++ + // If we're expanding a macro argument, put the tokens back. + if (InMacroArgPreExpansion) { + Toks.revert(); +diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp +index 3c338a2b8..4b3d153de 100644 +--- a/clang/lib/Lex/Preprocessor.cpp ++++ b/clang/lib/Lex/Preprocessor.cpp +@@ -92,6 +92,7 @@ Preprocessor::Preprocessor(std::shared_ptr PPOpts, + Identifiers(IILookup), PragmaHandlers(new PragmaNamespace(StringRef())), + TUKind(TUKind), SkipMainFilePreamble(0, true), + CurSubmoduleState(&NullSubmoduleState) { ++ PostLexAction = [] (const Token &) {}; + OwnsHeaderSearch = OwnsHeaders; + + // Default to discarding comments. +@@ -669,9 +670,17 @@ void Preprocessor::replayPreambleConditionalStack() { + "CurPPLexer is null when calling replayPreambleConditionalStack."); + CurPPLexer->setConditionalLevels(PreambleConditionalStack.getStack()); + PreambleConditionalStack.doneReplaying(); ++ ++ // PASTA PATCH ++ Token HashToken; ++ HashToken.startToken(); ++ HashToken.setKind(tok::hash); ++ HashToken.setLocation(PreambleConditionalStack.SkipInfo->HashTokenLoc); ++ HashToken.setLength(1u); ++ + if (PreambleConditionalStack.reachedEOFWhileSkipping()) + SkipExcludedConditionalBlock( +- PreambleConditionalStack.SkipInfo->HashTokenLoc, ++ HashToken, // PASTA PATCH + PreambleConditionalStack.SkipInfo->IfTokenLoc, + PreambleConditionalStack.SkipInfo->FoundNonSkipPortion, + PreambleConditionalStack.SkipInfo->FoundElse, +@@ -887,24 +896,56 @@ bool Preprocessor::HandleIdentifier(Token &Identifier) { + void Preprocessor::Lex(Token &Result) { + ++LexLevel; + ++ auto InputRawLoc = Result.getLocation().getRawEncoding(); // PASTA PATCH ++ + // We loop here until a lex function returns a token; this avoids recursion. + bool ReturnedToken; + do { + switch (CurLexerKind) { + case CLK_Lexer: + ReturnedToken = CurLexer->Lex(Result); ++ ++ // PASTA PATCH: Visibility into all tokens. ++ if (ReturnedToken && Callbacks) { ++ Callbacks->Event(Result, PPCallbacks::TokenFromLexer, InputRawLoc); ++ } + break; + case CLK_TokenLexer: + ReturnedToken = CurTokenLexer->Lex(Result); ++ ++ // PASTA PATCH: Visibility into all tokens. ++ if (ReturnedToken && Callbacks) { ++ Callbacks->Event(Result, PPCallbacks::TokenFromTokenLexer, InputRawLoc); ++ } + break; + case CLK_CachingLexer: + CachingLex(Result); + ReturnedToken = true; ++ ++ // PASTA PATCH: Visibility into all tokens. ++ if (ReturnedToken && Callbacks) { ++ Callbacks->Event(Result, PPCallbacks::TokenFromCachingLexer, ++ InputRawLoc); ++ } + break; + case CLK_LexAfterModuleImport: + ReturnedToken = LexAfterModuleImport(Result); ++ ++ // PASTA PATCH: Visibility into all tokens. ++ if (ReturnedToken && Callbacks) { ++ Callbacks->Event(Result, PPCallbacks::TokenFromAfterModuleImportLexer, ++ InputRawLoc); ++ } + break; + } ++ ++ if (ReturnedToken && Callbacks && Result.is(tok::eod)) { ++ Callbacks->Event(Result, PPCallbacks::EndDirective, 0); ++ } ++ ++ // PASTA PATCH ++ PostLexAction(Result); ++ PostLexAction = [] (const Token &) {}; + } while (!ReturnedToken); + + if (Result.is(tok::unknown) && TheModuleLoader.HadFatalFailure) +diff --git a/clang/lib/Lex/TokenLexer.cpp b/clang/lib/Lex/TokenLexer.cpp +index e71a65f03..b08397d84 100644 +--- a/clang/lib/Lex/TokenLexer.cpp ++++ b/clang/lib/Lex/TokenLexer.cpp +@@ -41,6 +41,8 @@ void TokenLexer::Init(Token &Tok, SourceLocation ELEnd, MacroInfo *MI, + // associated with it. + destroy(); + ++ MacroNameTok = Tok; ++ + Macro = MI; + ActualArgs = Actuals; + CurTokenIdx = 0; +diff --git a/clang/lib/Parse/ParseTemplate.cpp b/clang/lib/Parse/ParseTemplate.cpp +index f875e3bf4..a6dfcd05a 100644 +--- a/clang/lib/Parse/ParseTemplate.cpp ++++ b/clang/lib/Parse/ParseTemplate.cpp +@@ -1199,6 +1199,13 @@ bool Parser::ParseGreaterThanInTemplateList(SourceLocation LAngleLoc, + AfterGreaterLoc = PP.SplitToken(AfterGreaterLoc, Tok.getLength()); + Tok.setLocation(AfterGreaterLoc); + ++ // PASTA PATCH: We want to observe when tokens are split up so that we can ++ // have this reflected in PASTA's token lists. ++ if (PPCallbacks *Callbacks = PP.getPPCallbacks()) { ++ Callbacks->Event(Greater, PPCallbacks::BeginSplitToken, 0); ++ Callbacks->Event(Tok, PPCallbacks::EndSplitToken, 0); ++ } ++ + // Update the token cache to match what we just did if necessary. + if (CachingTokens) { + // If the previous cached token is being merged, delete it. +-- +2.37.1 + diff --git a/ports/llvm-15/0026-fix-prefix-path-calc.patch b/ports/llvm-15/0026-fix-prefix-path-calc.patch new file mode 100644 index 00000000..20af3578 --- /dev/null +++ b/ports/llvm-15/0026-fix-prefix-path-calc.patch @@ -0,0 +1,13 @@ +diff --git a/cmake/Modules/FindPrefixFromConfig.cmake b/cmake/Modules/FindPrefixFromConfig.cmake +index 22211e4b72f2..c83e99c21556 100644 +--- a/cmake/Modules/FindPrefixFromConfig.cmake ++++ b/cmake/Modules/FindPrefixFromConfig.cmake +@@ -39,7 +39,7 @@ function(find_prefix_from_config out_var prefix_var path_to_leave) + # install prefix, and avoid hard-coding any absolute paths. + set(config_code + "# Compute the installation prefix from this LLVMConfig.cmake file location." +- "get_filename_component(${prefix_var} \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)") ++ "get_filename_component(${prefix_var} \"\${CMAKE_CURRENT_LIST_DIR}\" PATH)") + # Construct the proper number of get_filename_component(... PATH) + # calls to compute the installation prefix. + string(REGEX REPLACE "/" ";" _count "${path_to_leave}") diff --git a/ports/llvm-13/clang_usage b/ports/llvm-15/clang_usage similarity index 100% rename from ports/llvm-13/clang_usage rename to ports/llvm-15/clang_usage diff --git a/ports/llvm-13/flang_usage b/ports/llvm-15/flang_usage similarity index 100% rename from ports/llvm-13/flang_usage rename to ports/llvm-15/flang_usage diff --git a/ports/llvm-13/lld_usage b/ports/llvm-15/lld_usage similarity index 100% rename from ports/llvm-13/lld_usage rename to ports/llvm-15/lld_usage diff --git a/ports/llvm-13/llvm_usage b/ports/llvm-15/llvm_usage similarity index 100% rename from ports/llvm-13/llvm_usage rename to ports/llvm-15/llvm_usage diff --git a/ports/llvm-13/mlir_usage b/ports/llvm-15/mlir_usage similarity index 100% rename from ports/llvm-13/mlir_usage rename to ports/llvm-15/mlir_usage diff --git a/ports/llvm-13/portfile.cmake b/ports/llvm-15/portfile.cmake similarity index 66% rename from ports/llvm-13/portfile.cmake rename to ports/llvm-15/portfile.cmake index d0ced172..68666c65 100644 --- a/ports/llvm-13/portfile.cmake +++ b/ports/llvm-15/portfile.cmake @@ -1,4 +1,4 @@ -set(LLVM_VERSION "13.0.1") +set(LLVM_VERSION "15.0.1") vcpkg_check_linkage(ONLY_STATIC_LIBRARY) @@ -6,22 +6,22 @@ vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO llvm/llvm-project REF llvmorg-${LLVM_VERSION} - SHA512 9a8cb5d11964ba88b7624f19ec861fb28701f23956ea3c92f6ac644332d5f41fde97bd8933dd3ee70ed378058c252fa3a3887c8d1af90d219970c2b27691166f + SHA512 d518de4860bd953c4728f00cb52aba37e1e8c2a0825b0a6cc046494f2ad4d1e1d07d36524c2aca87c7f27a5c07c21cdcf18ac73a03c2eed813ca46d24f31f445 HEAD_REF main PATCHES - 0002-fix-install-paths.patch - 0003-fix-openmp-debug.patch - 0004-fix-dr-1734.patch - 0005-fix-tools-path.patch - 0007-fix-compiler-rt-install-path.patch - 0009-fix-tools-install-path.patch - 0010-fix-libffi.patch - 0011-fix-libxml2.patch + 0001-Fix-install-paths.patch # This patch fixes paths in ClangConfig.cmake, LLVMConfig.cmake, LLDConfig.cmake etc. + 0002-Fix-DR-1734.patch + 0003-Fix-tools-path.patch + 0004-Fix-compiler-rt-install-path.patch + 0005-Fix-tools-install-path.patch + 0006-Fix-libffi.patch + 0007-Fix-install-bolt.patch 0020-fix-FindZ3.cmake.patch 0021-fix-find_dependency.patch - 0022-llvm-config-bin-path.patch 0023-clang-sys-include-dir-path.patch 0024-remove-elf_relocation-checks.patch + # 0025-PASTA-patches.patch + 0026-fix-prefix-path-calc.patch ) string(REPLACE "." ";" VERSION_LIST ${LLVM_VERSION}) @@ -45,11 +45,15 @@ vcpkg_check_features( enable-ffi LLVM_ENABLE_FFI enable-terminfo LLVM_ENABLE_TERMINFO enable-threads LLVM_ENABLE_THREADS + enable-ios COMPILER_RT_ENABLE_IOS enable-eh LLVM_ENABLE_EH enable-bindings LLVM_ENABLE_BINDINGS enable-z3 LLVM_ENABLE_Z3_SOLVER ) +vcpkg_cmake_get_vars(cmake_vars_file) +include("${cmake_vars_file}") + # Linking with gold is better than /bin/ld # Linking with lld is better than gold # MacOS just has LLD, so only set explicit linker on Linux @@ -122,13 +126,16 @@ elseif("disable-assertions" IN_LIST FEATURES) endif() # LLVM_ABI_BREAKING_CHECKS can be WITH_ASSERTS (default), FORCE_ON or FORCE_OFF. -# By default abi-breaking checks are enabled if assertions are enabled. +# By default in LLVM, abi-breaking checks are enabled if assertions are enabled. +# however, this breaks linking with the debug versions, since the option is +# baked into the header files; thus, we always turn off LLVM_ABI_BREAKING_CHECKS +# unless the user asks for it if("enable-abi-breaking-checks" IN_LIST FEATURES) # Force enable abi-breaking checks. list(APPEND FEATURE_OPTIONS -DLLVM_ABI_BREAKING_CHECKS=FORCE_ON ) -elseif("disable-abi-breaking-checks" IN_LIST FEATURES) +else() # Force disable abi-breaking checks. list(APPEND FEATURE_OPTIONS -DLLVM_ABI_BREAKING_CHECKS=FORCE_OFF @@ -136,6 +143,9 @@ elseif("disable-abi-breaking-checks" IN_LIST FEATURES) endif() set(LLVM_ENABLE_PROJECTS) +if("bolt" IN_LIST FEATURES) + list(APPEND LLVM_ENABLE_PROJECTS "bolt") +endif() if("clang" IN_LIST FEATURES OR "clang-tools-extra" IN_LIST FEATURES) list(APPEND LLVM_ENABLE_PROJECTS "clang") if("disable-clang-static-analyzer" IN_LIST FEATURES) @@ -146,12 +156,7 @@ if("clang" IN_LIST FEATURES OR "clang-tools-extra" IN_LIST FEATURES) -DCLANG_ENABLE_STATIC_ANALYZER=OFF ) endif() - if(VCPKG_TARGET_IS_WINDOWS) - list(APPEND FEATURE_OPTIONS - # Disable dl library on Windows - -DDL_LIBRARY_PATH:FILEPATH= - ) - elseif(VCPKG_TARGET_IS_OSX) + if(VCPKG_TARGET_IS_OSX) list(APPEND FEATURE_OPTIONS -DDEFAULT_SYSROOT:FILEPATH=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -DLLVM_CREATE_XCODE_TOOLCHAIN=ON @@ -170,9 +175,8 @@ if("compiler-rt" IN_LIST FEATURES) list(APPEND LLVM_ENABLE_PROJECTS "compiler-rt") endif() if("flang" IN_LIST FEATURES) - # Disable Flang on Windows (see http://lists.llvm.org/pipermail/flang-dev/2020-July/000448.html). - if(VCPKG_TARGET_IS_WINDOWS) - message(FATAL_ERROR "Building Flang with MSVC is not supported. Disable it until issues are fixed.") + if(VCPKG_DETECTED_CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") + message(FATAL_ERROR "Building Flang with MSVC is not supported on x86. Disable it until issues are fixed.") endif() list(APPEND LLVM_ENABLE_PROJECTS "flang") list(APPEND FEATURE_OPTIONS @@ -183,71 +187,55 @@ endif() if("libclc" IN_LIST FEATURES) list(APPEND LLVM_ENABLE_PROJECTS "libclc") endif() -if("libcxx" IN_LIST FEATURES) - list(APPEND LLVM_ENABLE_PROJECTS "libcxx") - list(APPEND FEATURE_OPTIONS - -DLIBCXX_ENABLE_STATIC=YES - -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=YES - -DLIBCXX_ENABLE_FILESYSTEM=YES - -DLIBCXX_INCLUDE_BENCHMARKS=NO - ) - if(VCPKG_TARGET_IS_LINUX) - list(APPEND FEATURE_OPTIONS - # Broken on Linux when set to YES - # Error on installing shared debug lib - -DLIBCXX_ENABLE_SHARED=NO - ) - else() - list(APPEND FEATURE_OPTIONS - -DLIBCXX_ENABLE_SHARED=YES - ) - endif() - list(APPEND LLVM_ENABLE_PROJECTS "libcxx") -endif() -if("libcxxabi" IN_LIST FEATURES) - list(APPEND LLVM_ENABLE_PROJECTS "libcxxabi") -endif() -if("libunwind" IN_LIST FEATURES) - list(APPEND LLVM_ENABLE_PROJECTS "libunwind") -endif() if("lld" IN_LIST FEATURES) list(APPEND LLVM_ENABLE_PROJECTS "lld") endif() if("lldb" IN_LIST FEATURES) list(APPEND LLVM_ENABLE_PROJECTS "lldb") + list(APPEND FEATURE_OPTIONS + -DLLDB_ENABLE_CURSES=OFF + ) endif() if("mlir" IN_LIST FEATURES) list(APPEND LLVM_ENABLE_PROJECTS "mlir") endif() if("openmp" IN_LIST FEATURES) - # Disable OpenMP on Windows (see https://bugs.llvm.org/show_bug.cgi?id=45074). - if(VCPKG_TARGET_IS_WINDOWS) - message(FATAL_ERROR "Building OpenMP with MSVC is not supported. Disable it until issues are fixed.") - endif() list(APPEND LLVM_ENABLE_PROJECTS "openmp") # Perl is required for the OpenMP run-time vcpkg_find_acquire_program(PERL) get_filename_component(PERL_PATH ${PERL} DIRECTORY) vcpkg_add_to_path(${PERL_PATH}) - if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - list(APPEND FEATURE_OPTIONS - -DLIBOMP_DEFAULT_LIB_NAME=libompd - ) - endif() -endif() -if("parallel-libs" IN_LIST FEATURES) - list(APPEND LLVM_ENABLE_PROJECTS "parallel-libs") + # Skip post-build check + set(VCPKG_POLICY_SKIP_DUMPBIN_CHECKS enabled) endif() if("polly" IN_LIST FEATURES) list(APPEND LLVM_ENABLE_PROJECTS "polly") endif() if("pstl" IN_LIST FEATURES) - if(VCPKG_TARGET_IS_WINDOWS) + if(VCPKG_DETECTED_CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") message(FATAL_ERROR "Building pstl with MSVC is not supported. Disable it until issues are fixed.") endif() list(APPEND LLVM_ENABLE_PROJECTS "pstl") endif() +set(LLVM_ENABLE_RUNTIMES) +if("libcxx" IN_LIST FEATURES) + if(VCPKG_DETECTED_CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + message(FATAL_ERROR "Building libcxx with MSVC is not supported, as cl doesn't support the #include_next extension.") + endif() + list(APPEND LLVM_ENABLE_RUNTIMES "libcxx") +endif() +if("libcxxabi" IN_LIST FEATURES) + if(VCPKG_DETECTED_CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + message(FATAL_ERROR "Building libcxxabi with MSVC is not supported. Disable it until issues are fixed.") + endif() + list(APPEND LLVM_ENABLE_RUNTIMES "libcxxabi") +endif() +if("libunwind" IN_LIST FEATURES) + list(APPEND LLVM_ENABLE_RUNTIMES "libunwind") +endif() + +# this is for normal targets set(known_llvm_targets AArch64 AMDGPU @@ -263,6 +251,7 @@ set(known_llvm_targets RISCV Sparc SystemZ + VE WebAssembly X86 XCore @@ -276,92 +265,94 @@ foreach(llvm_target IN LISTS known_llvm_targets) endif() endforeach() +# this is for experimental targets +set(known_llvm_experimental_targets + SPRIV +) + +set(LLVM_EXPERIMENTAL_TARGETS_TO_BUILD "") +foreach(llvm_target IN LISTS known_llvm_experimental_targets) + string(TOLOWER "target-${llvm_target}" feature_name) + if(feature_name IN_LIST FEATURES) + list(APPEND LLVM_EXPERIMENTAL_TARGETS_TO_BUILD "${llvm_target}") + endif() +endforeach() + vcpkg_find_acquire_program(PYTHON3) get_filename_component(PYTHON3_DIR ${PYTHON3} DIRECTORY) vcpkg_add_to_path(${PYTHON3_DIR}) -if(NOT VCPKG_TARGET_ARCHITECTURE STREQUAL "${VCPKG_DETECTED_CMAKE_SYSTEM_PROCESSOR}") - # TODO: support more targets and OS - if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64") - if(VCPKG_TARGET_IS_OSX) - list(APPEND CROSS_OPTIONS -DLLVM_HOST_TRIPLE=arm64-apple-darwin20.3.0) - list(APPEND CROSS_OPTIONS -DLLVM_DEFAULT_TARGET_TRIPLE=arm64-apple-darwin20.3.0) - elseif(VCPKG_TARGET_IS_WINDOWS) - list(APPEND CROSS_OPTIONS -DLLVM_HOST_TRIPLE=arm64-pc-win32) - list(APPEND CROSS_OPTIONS -DLLVM_DEFAULT_TARGET_TRIPLE=arm64-pc-win32) - - # Remove if PR #16111 is merged - list(APPEND CROSS_OPTIONS -DCMAKE_CROSSCOMPILING=ON) - list(APPEND CROSS_OPTIONS -DCMAKE_SYSTEM_PROCESSOR:STRING=ARM64) - list(APPEND CROSS_OPTIONS -DCMAKE_SYSTEM_NAME:STRING=Windows) - endif() - list(APPEND CROSS_OPTIONS -DLLVM_TARGET_ARCH=AArch64) - elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") - if(VCPKG_TARGET_IS_OSX) - list(APPEND CROSS_OPTIONS -DLLVM_HOST_TRIPLE=x86_64-apple-darwin20.3.0) - list(APPEND CROSS_OPTIONS -DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-apple-darwin20.3.0) - endif() - list(APPEND CROSS_OPTIONS -DLLVM_TARGET_ARCH=X86) - endif() -endif() +set(LLVM_LINK_JOBS 2) vcpkg_cmake_configure( SOURCE_PATH ${SOURCE_PATH}/llvm - PREFER_NINJA OPTIONS ${FEATURE_OPTIONS} - ${CROSS_OPTIONS} -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_BUILD_EXAMPLES=OFF -DLLVM_INCLUDE_DOCS=OFF -DLLVM_BUILD_DOCS=OFF -DLLVM_INCLUDE_TESTS=OFF -DLLVM_BUILD_TESTS=OFF - # Disable linking to Windows PDB analysis library (hard-coded path in LLVMExports.cmake) - -DLLVM_ENABLE_DIA_SDK=OFF + -DLLVM_INCLUDE_BENCHMARKS=OFF + -DLLVM_BUILD_BENCHMARKS=OFF # Force TableGen to be built with optimization. This will significantly improve build time. -DLLVM_OPTIMIZED_TABLEGEN=ON "-DLLVM_ENABLE_PROJECTS=${LLVM_ENABLE_PROJECTS}" + "-DLLVM_ENABLE_RUNTIMES=${LLVM_ENABLE_RUNTIMES}" "-DLLVM_TARGETS_TO_BUILD=${LLVM_TARGETS_TO_BUILD}" + "-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=${LLVM_EXPERIMENTAL_TARGETS_TO_BUILD}" -DPACKAGE_VERSION=${LLVM_VERSION} # Limit the maximum number of concurrent link jobs to 1. This should fix low amount of memory issue for link. - -DLLVM_PARALLEL_LINK_JOBS=2 - # Disable build LLVM-C.dll (Windows only) due to doesn't compile with CMAKE_DEBUG_POSTFIX - -DLLVM_BUILD_LLVM_C_DYLIB=OFF - # Path for binary subdirectory (defaults to 'bin') - -DLLVM_TOOLS_INSTALL_DIR=tools/llvm - OPTIONS_DEBUG - -DCMAKE_DEBUG_POSTFIX=d + "-DLLVM_PARALLEL_LINK_JOBS=${LLVM_LINK_JOBS}" + -DCMAKE_INSTALL_PACKAGEDIR:STRING=share + -DLLVM_TOOLS_INSTALL_DIR:STRING=tools/llvm + -DCLANG_TOOLS_INSTALL_DIR:STRING=tools/llvm + -DMLIR_TOOLS_INSTALL_DIR:STRING=tools/llvm ) vcpkg_cmake_install(ADD_BIN_TO_PATH) +# 'package_name' should be the case of the package used in CMake 'find_package' +# 'FEATURE_NAME' should be the name of the vcpkg port feature function(llvm_cmake_package_config_fixup package_name) cmake_parse_arguments("arg" "DO_NOT_DELETE_PARENT_CONFIG_PATH" "FEATURE_NAME" "" ${ARGN}) + string(TOUPPER "${package_name}" upper_package) + string(TOLOWER "${package_name}" lower_package) if(NOT DEFINED arg_FEATURE_NAME) - set(arg_FEATURE_NAME ${package_name}) + set(arg_FEATURE_NAME ${lower_package}) endif() - if("${arg_FEATURE_NAME}" STREQUAL "${PORT}" OR "${arg_FEATURE_NAME}" IN_LIST FEATURES) + if("${lower_package}" STREQUAL "llvm" OR "${arg_FEATURE_NAME}" IN_LIST FEATURES) set(args) - list(APPEND args PACKAGE_NAME "${package_name}") + # Maintains case even if package_name name is case-sensitive + list(APPEND args PACKAGE_NAME "${lower_package}") + list(APPEND args TOOLS_PATH "tools/llvm") if(arg_DO_NOT_DELETE_PARENT_CONFIG_PATH) list(APPEND args "DO_NOT_DELETE_PARENT_CONFIG_PATH") endif() vcpkg_cmake_config_fixup(${args}) - file(INSTALL "${SOURCE_PATH}/${package_name}/LICENSE.TXT" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${package_name}" RENAME copyright) - if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${package_name}_usage") - file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/${package_name}_usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${package_name}" RENAME usage) + file(INSTALL "${SOURCE_PATH}/${lower_package}/LICENSE.TXT" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${lower_package}" RENAME copyright) + + # Remove last parent directory + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/${lower_package}/${package_name}Config.cmake" "get_filename_component(${upper_package}_INSTALL_PREFIX \"\${${upper_package}_INSTALL_PREFIX}\" PATH)\n\n" "\n") + + if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${lower_package}_usage") + file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/${lower_package}_usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${lower_package}" RENAME usage) endif() endif() endfunction() -llvm_cmake_package_config_fixup("clang" DO_NOT_DELETE_PARENT_CONFIG_PATH) -llvm_cmake_package_config_fixup("flang" DO_NOT_DELETE_PARENT_CONFIG_PATH) -llvm_cmake_package_config_fixup("lld" DO_NOT_DELETE_PARENT_CONFIG_PATH) -llvm_cmake_package_config_fixup("mlir" DO_NOT_DELETE_PARENT_CONFIG_PATH) -llvm_cmake_package_config_fixup("polly" DO_NOT_DELETE_PARENT_CONFIG_PATH) +llvm_cmake_package_config_fixup("Clang" DO_NOT_DELETE_PARENT_CONFIG_PATH) +llvm_cmake_package_config_fixup("Flang" DO_NOT_DELETE_PARENT_CONFIG_PATH) +llvm_cmake_package_config_fixup("LLD" DO_NOT_DELETE_PARENT_CONFIG_PATH) +llvm_cmake_package_config_fixup("MLIR" DO_NOT_DELETE_PARENT_CONFIG_PATH) +llvm_cmake_package_config_fixup("OpenMP" DO_NOT_DELETE_PARENT_CONFIG_PATH) +llvm_cmake_package_config_fixup("Polly" DO_NOT_DELETE_PARENT_CONFIG_PATH) llvm_cmake_package_config_fixup("ParallelSTL" FEATURE_NAME "pstl" DO_NOT_DELETE_PARENT_CONFIG_PATH) -llvm_cmake_package_config_fixup("llvm") +llvm_cmake_package_config_fixup("LLVM") + +# Needed because we are doing versioned ports +file(INSTALL "${SOURCE_PATH}/llvm/LICENSE.TXT" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) set(empty_dirs) @@ -396,12 +387,20 @@ endif() vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/llvm) if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") - file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) - file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share) - file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/tools) + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/tools" + "${CURRENT_PACKAGES_DIR}/debug/include" + "${CURRENT_PACKAGES_DIR}/debug/share" + "${CURRENT_PACKAGES_DIR}/debug/lib/clang" + ) +endif() + +if("mlir" IN_LIST FEATURES) + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/mlir/MLIRConfig.cmake" "set(MLIR_MAIN_SRC_DIR \"${SOURCE_PATH}/mlir\")" "") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/mlir/MLIRConfig.cmake" "${CURRENT_BUILDTREES_DIR}" "\${MLIR_INCLUDE_DIRS}") endif() # LLVM still generates a few DLLs in the static build: +# * LLVM-C.dll # * libclang.dll # * LTO.dll # * Remarks.dll diff --git a/ports/llvm-13/vcpkg.json b/ports/llvm-15/vcpkg.json similarity index 84% rename from ports/llvm-13/vcpkg.json rename to ports/llvm-15/vcpkg.json index c975e6c1..639f8b0c 100644 --- a/ports/llvm-13/vcpkg.json +++ b/ports/llvm-15/vcpkg.json @@ -1,9 +1,9 @@ { - "name": "llvm-13", - "version": "13.0.1", - "port-version": 6, + "name": "llvm-15", + "version": "15.0.1", "description": "The LLVM Compiler Infrastructure.", "homepage": "https://llvm.org", + "license": "Apache-2.0", "supports": "!uwp & !(arm & windows)", "dependencies": [ { @@ -13,6 +13,10 @@ { "name": "vcpkg-cmake-config", "host": true + }, + { + "name": "vcpkg-cmake-get-vars", + "host": true } ], "default-features": [ @@ -25,11 +29,23 @@ "utils" ], "features": { + "bolt": { + "description": "BOLT is a post-link optimizer developed to speed up large applications.", + "dependencies": [ + { + "name": "llvm-15", + "default-features": false, + "features": [ + "tools" + ] + } + ] + }, "clang": { "description": "Include C Language Family Front-end.", "dependencies": [ { - "name": "llvm-13", + "name": "llvm-15", "default-features": false, "features": [ "compiler-rt", @@ -48,10 +64,9 @@ "description": "Build with default options.", "dependencies": [ { - "name": "llvm-13", + "name": "llvm-15", "default-features": false, "features": [ - "disable-abi-breaking-checks", "enable-assertions", "enable-bindings", "enable-eh", @@ -66,7 +81,7 @@ "description": "Build with cxx-common target set", "dependencies": [ { - "name": "llvm-13", + "name": "llvm-15", "default-features": false, "features": [ "target-aarch64", @@ -83,7 +98,7 @@ "description": "Build with platform-specific default targets.", "dependencies": [ { - "name": "llvm-13", + "name": "llvm-15", "default-features": false, "features": [ "target-aarch64" @@ -91,7 +106,7 @@ "platform": "arm64" }, { - "name": "llvm-13", + "name": "llvm-15", "default-features": false, "features": [ "target-x86" @@ -99,7 +114,7 @@ "platform": "x86 | x64" }, { - "name": "llvm-13", + "name": "llvm-15", "default-features": false, "features": [ "target-arm" @@ -107,7 +122,7 @@ "platform": "arm & !arm64" }, { - "name": "llvm-13", + "name": "llvm-15", "default-features": false, "features": [ "target-all" @@ -116,9 +131,6 @@ } ] }, - "disable-abi-breaking-checks": { - "description": "Build LLVM with LLVM_ABI_BREAKING_CHECKS=FORCE_OFF." - }, "disable-assertions": { "description": "Build LLVM without assertions." }, @@ -138,7 +150,7 @@ "description": "Build LLVM with exception handler.", "dependencies": [ { - "name": "llvm-13", + "name": "llvm-15", "default-features": false, "features": [ "enable-rtti" @@ -152,6 +164,12 @@ "libffi" ] }, + "enable-ios": { + "description": "Build compiler-rt for iOS SDK.", + "dependencies": [ + "target-arm" + ] + }, "enable-libxml2": { "description": "Build with LibXml2.", "dependencies": [ @@ -178,7 +196,7 @@ "dependencies": [ "z3", { - "name": "llvm-13", + "name": "llvm-15", "default-features": false, "features": [ "clang" @@ -190,7 +208,7 @@ "description": "Include Fortran front end.", "dependencies": [ { - "name": "llvm-13", + "name": "llvm-15", "default-features": false, "features": [ "clang", @@ -207,7 +225,7 @@ "description": "Include libcxx library.", "dependencies": [ { - "name": "llvm-13", + "name": "llvm-15", "default-features": false, "features": [ "libcxxabi" @@ -225,7 +243,7 @@ "description": "Include LLVM linker.", "dependencies": [ { - "name": "llvm-13", + "name": "llvm-15", "default-features": false, "features": [ "tools" @@ -237,7 +255,7 @@ "description": "Include LLVM debugger.", "dependencies": [ { - "name": "llvm-13", + "name": "llvm-15", "default-features": false, "features": [ "tools" @@ -249,7 +267,7 @@ "description": "Include MLIR (Multi-Level IR Compiler Framework) project.", "dependencies": [ { - "name": "llvm-13", + "name": "llvm-15", "default-features": false, "features": [ "tools" @@ -261,7 +279,7 @@ "description": "Include LLVM OpenMP libraries.", "dependencies": [ { - "name": "llvm-13", + "name": "llvm-15", "default-features": false, "features": [ "utils" @@ -269,14 +287,12 @@ } ] }, - "parallel-libs": { - "description": "Include parallel-libs project." - }, "polly": { "description": "Include Polly (Polyhedral optimizations for LLVM) project.", "dependencies": [ + "target-ve", { - "name": "llvm-13", + "name": "llvm-15", "default-features": false, "features": [ "tools", @@ -295,7 +311,7 @@ "description": "Build with all backends.", "dependencies": [ { - "name": "llvm-13", + "name": "llvm-15", "default-features": false, "features": [ "target-aarch64", @@ -311,7 +327,9 @@ "target-powerpc", "target-riscv", "target-sparc", + "target-spirv", "target-systemz", + "target-ve", "target-webassembly", "target-x86", "target-xcore" @@ -355,9 +373,15 @@ "target-sparc": { "description": "Build with Sparc backend." }, + "target-spirv": { + "description": "Build with Spriv backend." + }, "target-systemz": { "description": "Build with SystemZ backend." }, + "target-ve": { + "description": "Build with VE backend." + }, "target-webassembly": { "description": "Build with WebAssembly backend." }, @@ -368,7 +392,16 @@ "description": "Build with XCore backend." }, "tools": { - "description": "Build LLVM tools." + "description": "Build LLVM tools.", + "dependencies": [ + { + "name": "llvm-15", + "default-features": false, + "features": [ + "enable-threads" + ] + } + ] }, "utils": { "description": "Build LLVM utils."