diff --git a/.config/tsaoptions.json b/.config/tsaoptions.json new file mode 100644 index 00000000000000..179942118a9eae --- /dev/null +++ b/.config/tsaoptions.json @@ -0,0 +1,10 @@ +{ + "instanceUrl": "https://devdiv.visualstudio.com/", + "template": "TFSDEVDIV", + "projectName": "DEVDIV", + "areaPath": "DevDiv\\mono", + "iterationPath": "DevDiv", + "notificationAliases": [ "runtimerepo-infra@microsoft.com" ], + "repositoryName": "llvm-project", + "codebaseName": "llvm-project" +} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 20c4f52cd37860..8d4c0484aec605 100644 --- a/.gitignore +++ b/.gitignore @@ -70,3 +70,7 @@ pythonenv* /clang/utils/analyzer/projects/*/RefScanBuildResults # automodapi puts generated documentation files here. /lldb/docs/python_api/ + +/artifacts +/.dotnet +/.packages diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 00000000000000..3014b766801b9d --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,5 @@ + + + + + diff --git a/Directory.Build.targets b/Directory.Build.targets new file mode 100644 index 00000000000000..177d64c47ad118 --- /dev/null +++ b/Directory.Build.targets @@ -0,0 +1,4 @@ + + + + diff --git a/NuGet.config b/NuGet.config new file mode 100644 index 00000000000000..6082e261d277ec --- /dev/null +++ b/NuGet.config @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + diff --git a/bolt/utils/docker/Dockerfile b/bolt/utils/docker/Dockerfile deleted file mode 100644 index 722a07e46f9e43..00000000000000 --- a/bolt/utils/docker/Dockerfile +++ /dev/null @@ -1,31 +0,0 @@ -FROM ubuntu:20.04 AS builder - -ARG DEBIAN_FRONTEND=noninteractive -ENV TZ=UTC - -RUN apt-get update && \ - apt-get install -y --no-install-recommends ca-certificates git \ - build-essential cmake ninja-build python3 libjemalloc-dev \ - python3-psutil && \ - rm -rf /var/lib/apt/lists - -WORKDIR /home/bolt - -RUN git clone --depth 1 https://github.com/llvm/llvm-project - -RUN mkdir build && \ - cd build && \ - cmake -G Ninja ../llvm-project/llvm \ - -DLLVM_ENABLE_PROJECTS="bolt;clang;lld" \ - -DLLVM_TARGETS_TO_BUILD="X86;AArch64" \ - -DCMAKE_BUILD_TYPE=Release \ - -DLLVM_ENABLE_ASSERTIONS=ON \ - -DCMAKE_EXE_LINKER_FLAGS="-Wl,--push-state -Wl,-whole-archive -ljemalloc_pic -Wl,--pop-state -lpthread -lstdc++ -lm -ldl" \ - -DCMAKE_INSTALL_PREFIX=/home/bolt/install && \ - ninja check-bolt && \ - ninja install-llvm-bolt install-perf2bolt install-merge-fdata \ - install-llvm-boltdiff install-bolt_rt - -FROM ubuntu:20.04 - -COPY --from=builder /home/bolt/install /usr/local diff --git a/build.cmd b/build.cmd new file mode 100644 index 00000000000000..1ba69afd9cc779 --- /dev/null +++ b/build.cmd @@ -0,0 +1,8 @@ +@echo off +setlocal + +set _args=%* +if "%~1"=="-?" set _args=-help + +powershell -ExecutionPolicy ByPass -NoProfile -File "%~dp0eng\build.ps1" %_args% +exit /b %ERRORLEVEL% diff --git a/build.sh b/build.sh new file mode 100755 index 00000000000000..da2ba1a158ec1b --- /dev/null +++ b/build.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +source="${BASH_SOURCE[0]}" + +function is_cygwin_or_mingw() +{ + case $(uname -s) in + CYGWIN*) return 0;; + MINGW*) return 0;; + *) return 1;; + esac +} + +# resolve $SOURCE until the file is no longer a symlink +while [[ -h $source ]]; do + scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + + # if $source was a relative symlink, we need to resolve it relative to the path where the + # symlink file was located + [[ $source != /* ]] && source="$scriptroot/$source" +done + +scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + +if is_cygwin_or_mingw; then + # if bash shell running on Windows (not WSL), + # pass control to powershell build script. + scriptroot=$(cygpath -d "$scriptroot") + powershell -c "$scriptroot\\build.cmd" $@ +else + "$scriptroot/eng/build.sh" $@ +fi diff --git a/clang/cmake/modules/AddClang.cmake b/clang/cmake/modules/AddClang.cmake index 75b0080f671564..7bc852d50b9f42 100644 --- a/clang/cmake/modules/AddClang.cmake +++ b/clang/cmake/modules/AddClang.cmake @@ -177,6 +177,56 @@ macro(add_clang_tool name) DEPENDS ${name} COMPONENT ${name}) endif() + + if(APPLE) + if(LLVM_EXTERNALIZE_DEBUGINFO_INSTALL) + if(LLVM_EXTERNALIZE_DEBUGINFO_EXTENSION) + set(file_ext ${LLVM_EXTERNALIZE_DEBUGINFO_EXTENSION}) + elseif(LLVM_EXTERNALIZE_DEBUGINFO_FLATTEN) + set(file_ext dwarf) + else() + set(file_ext dSYM) + endif() + set(output_name "$.${file_ext}") + if(LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR) + set(output_path "${LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR}/${output_name}") + else() + set(output_path "${output_name}") + endif() + get_filename_component(debuginfo_absolute_path ${output_path} REALPATH BASE_DIR $) + install(FILES ${debuginfo_absolute_path} DESTINATION bin OPTIONAL COMPONENT ${name}) + endif() + elseif(WIN32) + if(LLVM_EXTERNALIZE_DEBUGINFO_INSTALL) + install(FILES $ DESTINATION bin OPTIONAL COMPONENT ${name}) + endif() + else() + if(LLVM_EXTERNALIZE_DEBUGINFO_INSTALL) + if(LLVM_EXTERNALIZE_DEBUGINFO_EXTENSION) + set(file_ext ${LLVM_EXTERNALIZE_DEBUGINFO_EXTENSION}) + else() + set(file_ext debug) + endif() + + set(output_name "$.${file_ext}") + + if(LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR) + set(output_path "${LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR}/${output_name}") + # If an output dir is specified, it must be manually mkdir'd on Linux, + # as that directory needs to exist before we can pipe to a file in it. + add_custom_command(TARGET ${name} POST_BUILD + WORKING_DIRECTORY ${LLVM_RUNTIME_OUTPUT_INTDIR} + COMMAND ${CMAKE_COMMAND} -E make_directory ${LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR} + ) + else() + set(output_path "${output_name}") + endif() + + get_filename_component(debuginfo_absolute_path ${output_path} REALPATH BASE_DIR $) + install(FILES ${debuginfo_absolute_path} DESTINATION bin OPTIONAL COMPONENT ${name}) + endif() + endif() + set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name}) endif() endif() diff --git a/clang/tools/clang-fuzzer/Dockerfile b/clang/tools/clang-fuzzer/Dockerfile deleted file mode 100644 index 1ddf82954e219f..00000000000000 --- a/clang/tools/clang-fuzzer/Dockerfile +++ /dev/null @@ -1,41 +0,0 @@ -#===- llvm/tools/clang/tools/clang-fuzzer ---------------------------------===// -# -# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# -#===----------------------------------------------------------------------===// -# Produces an image that builds clang-proto-fuzzer -FROM ubuntu:16.04 -RUN apt-get update -y -RUN apt-get install -y autoconf automake libtool curl make g++ unzip wget git \ - binutils liblzma-dev libz-dev python-all cmake ninja-build subversion \ - pkg-config docbook2x - -WORKDIR /root - -# Get protobuf -RUN wget -qO- https://github.com/google/protobuf/releases/download/v3.3.0/protobuf-cpp-3.3.0.tar.gz | tar zxf - -RUN cd protobuf-3.3.0 && ./autogen.sh && ./configure && make -j $(nproc) && make check -j $(nproc) && make install && ldconfig -# Get LLVM -RUN svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm -RUN cd llvm/tools && svn co http://llvm.org/svn/llvm-project/cfe/trunk clang -r $(cd ../ && svn info | grep Revision | awk '{print $2}') -RUN cd llvm/projects && svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt -r $(cd ../ && svn info | grep Revision | awk '{print $2}') -# Build plain LLVM (stage 0) -RUN mkdir build0 && cd build0 && cmake -GNinja -DCMAKE_BUILD_TYPE=Release ../llvm && ninja -# Configure instrumented LLVM (stage 1) -RUN mkdir build1 && cd build1 && cmake -GNinja -DCMAKE_BUILD_TYPE=Release ../llvm \ - -DLLVM_ENABLE_ASSERTIONS=ON \ - -DCMAKE_C_COMPILER=`pwd`/../build0/bin/clang \ - -DCMAKE_CXX_COMPILER=`pwd`/../build0/bin/clang++ \ - -DLLVM_USE_SANITIZE_COVERAGE=YES \ - -DLLVM_USE_SANITIZER=Address -DCLANG_ENABLE_PROTO_FUZZER=ON -# Build the fuzzers -RUN cd build1 && ninja clang-fuzzer -RUN cd build1 && ninja clang-objc-fuzzer -RUN cd build1 && ninja clang-proto-fuzzer -RUN cd build1 && ninja clang-proto-to-cxx -RUN cd build1 && ninja clang-loop-proto-to-cxx -RUN cd build1 && ninja clang-loop-proto-to-llvm -RUN cd build1 && ninja clang-loop-proto-fuzzer -RUN cd build1 && ninja clang-llvm-proto-fuzzer diff --git a/clang/utils/analyzer/Dockerfile b/clang/utils/analyzer/Dockerfile deleted file mode 100644 index cc73ed973b8116..00000000000000 --- a/clang/utils/analyzer/Dockerfile +++ /dev/null @@ -1,74 +0,0 @@ -FROM ubuntu:bionic - -RUN apt-get update && apt-get install -y \ - apt-transport-https \ - ca-certificates \ - gnupg \ - software-properties-common \ - wget - -# newer CMake is required by LLVM -RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null -RUN apt-add-repository -y 'deb https://apt.kitware.com/ubuntu/ bionic main' - -# test system dependencies -RUN apt-get update && apt-get install -y \ - git=1:2.17.1* \ - gettext=0.19.8.1* \ - python3=3.6.7-1~18.04 \ - python3-pip=9.0.1-2.3* \ - cmake=3.20.5* \ - cmake-data=3.20.5* \ - ninja-build=1.8.2-1 - -# box2d dependencies -RUN apt-get install -y \ - libx11-dev=2:1.6.4-3* \ - libxrandr-dev=2:1.5.1-1 \ - libxinerama-dev=2:1.1.3-1 \ - libxcursor-dev=1:1.1.15-1 \ - libxi-dev=2:1.7.9-1 - -# symengine dependencies -RUN apt-get install -y \ - libgmp10=2:6.1.2+dfsg-2ubuntu0.1 \ - libgmp-dev=2:6.1.2+dfsg-2ubuntu0.1 - -# simbody dependencies -RUN apt-get install -y \ - liblapack-dev=3.7.1-4* - -# drogon dependencies -RUN apt-get install -y \ - libjsonrpccpp-dev=0.7.0-1* \ - uuid-dev=2.31.1-0.4* - -# tmux dependencies -RUN apt-get install -y \ - autotools-dev=20180224.1 \ - automake=1:1.15.1-3* \ - libncurses5-dev=6.1-1* \ - libevent-dev=2.1.8* \ - pkg-config=0.29.1-0* \ - flex=2.6.4-6 \ - bison=2:3.0.4.* - -RUN apt-get install -y \ - libjpeg-dev - -RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1 - -VOLUME /analyzer -VOLUME /projects -VOLUME /llvm-project -VOLUME /build -VOLUME /scripts - -ENV PATH="/analyzer/bin:${PATH}" - -ADD entrypoint.py /entrypoint.py - -ADD requirements.txt /requirements.txt -RUN pip3 install -r /requirements.txt - -ENTRYPOINT ["python", "/entrypoint.py"] diff --git a/dir.common.props b/dir.common.props new file mode 100644 index 00000000000000..1f372d78db6abe --- /dev/null +++ b/dir.common.props @@ -0,0 +1,85 @@ + + + + + $(__BuildArch) + x64 + x64 + + $(__BuildType) + Debug + Debug + Release + Checked + + $(__BuildOS) + Windows_NT + Linux + OSX + + + <__BuildOS>$(BuildOS) + <__BuildArch>$(BuildArch) + + $(BuildType) + $(BuildArch) + + $(BuildOS).$(BuildArch).$(BuildType) + + + + + + + <__ProjectDir Condition="'$(__ProjectDir)'==''">$(MSBuildThisFileDirectory) + $(__ProjectDir)\ + $(ProjectDir)\..\..\ + $(MSBuildThisFileDirectory) + + $(RootRepoDir)artifacts\obj\llvm\$(MSBuildProjectName)\ + + $(__SourceDir)\ + $(ProjectDir)src\ + + $(__RootBinDir)\ + $(RootRepoDir)artifacts\ + + $(__BinDir)\ + $(RootBinDir)bin\llvm\$(PlatformConfigPathPart)\ + + <_LLVMSourceDir Condition="'$(_LLVMSourceDir)'==''">$(MSBuildThisFileDirectory)/llvm + <_LLVMBuildDir Condition="'$(_LLVMBuildDir)'==''">$(MSBuildThisFileDirectory)/artifacts/obj/BuildRoot-$(TargetArchitecture) + <_LLVMInstallDir Condition="'$(_LLVMInstallDir)'==''">$(MSBuildThisFileDirectory)/artifacts/obj/InstallRoot-$(TargetArchitecture) + + <_LibCxxSourceDir Condition="'$(_LibCxxSourceDir)'==''">$(MSBuildThisFileDirectory)/runtimes + <_LibCxxBuildDir Condition="'$(_LibCxxBuildDir)'==''">$(MSBuildThisFileDirectory)/artifacts/obj/libcxx/BuildRoot-$(TargetArchitecture) + <_LibCxxInstallDir Condition="'$(_LibCxxInstallDir)'==''">$(MSBuildThisFileDirectory)/artifacts/obj/libcxx/InstallRoot-$(TargetArchitecture) + + + + + + 1.0.0 + $([System.IO.File]::ReadAllText('$(_LLVMBuildDir)\version.txt')) + $(LLVMVersion) + + + false + $(PackageVersion) + + preview8 + + + + + true + true + true + true + true + + true + + + + diff --git a/eng/Build.props b/eng/Build.props new file mode 100644 index 00000000000000..a884f3c0863de0 --- /dev/null +++ b/eng/Build.props @@ -0,0 +1,6 @@ + + + + + + diff --git a/eng/Publishing.props b/eng/Publishing.props new file mode 100644 index 00000000000000..10bc8c8684de37 --- /dev/null +++ b/eng/Publishing.props @@ -0,0 +1,6 @@ + + + + 3 + + diff --git a/eng/Tools.props b/eng/Tools.props new file mode 100644 index 00000000000000..112543dc80edb0 --- /dev/null +++ b/eng/Tools.props @@ -0,0 +1,11 @@ + + + false + + + + + + + + diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml new file mode 100644 index 00000000000000..fbbbef46ac5064 --- /dev/null +++ b/eng/Version.Details.xml @@ -0,0 +1,19 @@ + + + + + + + https://github.com/dotnet/arcade + 1aff4eb33aa7cbf26ccd9fc43c17cb609a14dad4 + + + https://github.com/dotnet/arcade + 1aff4eb33aa7cbf26ccd9fc43c17cb609a14dad4 + + + https://github.com/dotnet/arcade + 1aff4eb33aa7cbf26ccd9fc43c17cb609a14dad4 + + + diff --git a/eng/Versions.props b/eng/Versions.props new file mode 100644 index 00000000000000..e23b9b51cf2603 --- /dev/null +++ b/eng/Versions.props @@ -0,0 +1,11 @@ + + + + 1.0.0 + alpha + 1 + + + 8.0.0-beta.23262.5 + + diff --git a/eng/azure-pipelines-codeql.yml b/eng/azure-pipelines-codeql.yml new file mode 100644 index 00000000000000..c9d18b9a1a0611 --- /dev/null +++ b/eng/azure-pipelines-codeql.yml @@ -0,0 +1,117 @@ +trigger: + none + +schedules: + - cron: 0 12 * * 1 + displayName: Weekly Monday CodeQL/Semmle run + branches: + include: + - dotnet/main + - dotnet/release/* + always: true + +variables: + - template: /eng/common-variables.yml + - template: /eng/common/templates/variables/pool-providers.yml + - name: Codeql.Enabled + value: True + - name: Codeql.Cadence + value: 0 + - name: Codeql.TSAEnabled + value: True + - name: Codeql.BuildIdentifier + value: $(System.JobDisplayName) + +stages: +- stage: Build + jobs: + - template: /eng/common/templates/jobs/jobs.yml + parameters: + jobs: + + ############ LINUX BUILD ############ + - job: Build_Linux + displayName: Linux + timeoutInMinutes: 600 + variables: + - _BuildConfig: Release + strategy: + matrix: + x64: + assetManifestOS: linux + assetManifestPlatform: x64 + imagename: mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-cross-amd64 + rootfs: /crossrootfs/x64 + ClangTargetArg: /p:ClangTarget=x86_64-linux-gnu + ClangBinDirArg: /p:ClangBinDir=/usr/local/bin + archflag: --arch x64 + pool: + ${{ if eq(variables['System.TeamProject'], 'public') }}: + name: $(DncEngPublicBuildPool) + demands: ImageOverride -equals build.ubuntu.2204.amd64.open + ${{ if eq(variables['System.TeamProject'], 'internal') }}: + name: $(DncEngInternalBuildPool) + demands: ImageOverride -equals build.ubuntu.2204.amd64 + container: + image: $(imagename) + steps: + - bash: | + set -ex + git clean -ffdx + git reset --hard HEAD + displayName: 'Clean up working directory' + + - task: CodeQL3000Init@0 + displayName: Initialize CodeQL (manually-injected) + + - bash: | + ./build.sh --ci --restore --build --pack $(archflag) --configuration $(_BuildConfig) $(_InternalBuildArgs) $(ClangBinDirArg) $(ClangTargetArg) + displayName: 'Build and package' + env: + ROOTFS_DIR: $(rootfs) + + - task: CodeQL3000Finalize@0 + displayName: Finalize CodeQL (manually-injected) + + ############ WINDOWS BUILD ############ + - job: Build_Windows + displayName: Windows + timeoutInMinutes: 600 + strategy: + matrix: + # Release + x64_release: + _BuildConfig: Release + assetManifestOS: win + assetManifestPlatform: x64 + LLVMTableGenArg: /p:LLVMTableGenPath=$(Build.SourcesDirectory)\artifacts\obj\BuildRoot-x64\bin\llvm-tblgen.exe + ClangTableGenArg: /p:ClangTableGenPath=$(Build.SourcesDirectory)\artifacts\obj\BuildRoot-x64\bin\clang-tblgen.exe + archflag: -arch x64 + pool: + ${{ if eq(variables['System.TeamProject'], 'public') }}: + name: $(DncEngPublicBuildPool) + demands: ImageOverride -equals windows.vs2022.amd64.open + ${{ if eq(variables['System.TeamProject'], 'internal') }}: + name: $(DncEngInternalBuildPool) + demands: ImageOverride -equals windows.vs2022.amd64 + steps: + - checkout: self + clean: true + fetchDepth: 2 + + - script: | + git clean -ffdx + git reset --hard HEAD + displayName: 'Clean up working directory' + + - task: CodeQL3000Init@0 + displayName: Initialize CodeQL (manually-injected) + + - powershell: eng\build.ps1 -ci -restore -build -arch x64 -configuration $(_BuildConfig) $(_InternalBuildArgs) /p:BuildLLVMTableGenOnly=true + displayName: 'Build host llvm-tblgen for cross-compiling' + + - powershell: eng\build.ps1 -ci -restore -build -pack $(archflag) -configuration $(_BuildConfig) $(_InternalBuildArgs) $(LLVMTableGenArg) $(ClangTableGenArg) + displayName: 'Build and package' + + - task: CodeQL3000Finalize@0 + displayName: Finalize CodeQL (manually-injected) diff --git a/eng/azure-pipelines.yml b/eng/azure-pipelines.yml new file mode 100644 index 00000000000000..1d9971238d48eb --- /dev/null +++ b/eng/azure-pipelines.yml @@ -0,0 +1,245 @@ +trigger: + batch: true + branches: + include: + - dotnet/main* + - dotnet/release/* + +pr: + branches: + include: + - dotnet/main* + - dotnet/release/* + +variables: +- template: /eng/common-variables.yml +- template: /eng/common/templates/variables/pool-providers.yml +# disable CodeQL here, we have a separate pipeline for it +- name: Codeql.Enabled + value: false + +stages: +- stage: build + displayName: Build + jobs: + - template: /eng/common/templates/jobs/jobs.yml + parameters: + enablePublishBuildArtifacts: true + enablePublishBuildAssets: true + enablePublishUsingPipelines: true + jobs: + + ############ LINUX BUILD ############ + - job: Build_Linux + displayName: Linux + timeoutInMinutes: 600 + variables: + - _BuildConfig: Release + strategy: + matrix: + x64: + assetManifestOS: linux + assetManifestPlatform: x64 + imagename: mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-cross-amd64 + rootfs: /crossrootfs/x64 + ClangTargetArg: /p:ClangTarget=x86_64-linux-gnu + ClangBinDirArg: /p:ClangBinDir=/usr/local/bin + archflag: --arch x64 + arm64: + assetManifestOS: linux + assetManifestPlatform: arm64 + imagename: mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-cross-arm64 + rootfs: /crossrootfs/arm64 + ClangTargetArg: /p:ClangTarget=aarch64-linux-gnu + ClangBinDirArg: /p:ClangBinDir=/usr/local/bin + archflag: --arch arm64 + arm: + assetManifestOS: linux + assetManifestPlatform: arm + imagename: mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-cross-arm + rootfs: /crossrootfs/arm + ClangTargetArg: /p:ClangTarget=arm-linux-gnueabihf + ClangBinDirArg: /p:ClangBinDir=/usr/local/bin + archflag: --arch arm + pool: + ${{ if eq(variables['System.TeamProject'], 'public') }}: + name: $(DncEngPublicBuildPool) + demands: ImageOverride -equals build.ubuntu.2204.amd64.open + ${{ if eq(variables['System.TeamProject'], 'internal') }}: + name: $(DncEngInternalBuildPool) + demands: ImageOverride -equals build.ubuntu.2204.amd64 + container: + image: $(imagename) + steps: + - bash: | + set -ex + git clean -ffdx + git reset --hard HEAD + displayName: 'Clean up working directory' + + - bash: | + ./build.sh --ci --restore --build --pack $(archflag) --configuration $(_BuildConfig) $(_InternalBuildArgs) $(ClangBinDirArg) $(ClangTargetArg) + displayName: 'Build and package' + env: + ROOTFS_DIR: $(rootfs) + + - bash: | + ./eng/common/build.sh --ci --restore --publish --configuration $(_BuildConfig) $(_InternalBuildArgs) /p:AssetManifestOS=$(assetManifestOS) /p:PlatformName=$(assetManifestPlatform) --projects $(Build.SourcesDirectory)/llvm.proj + displayName: Publish packages + condition: and(succeeded(), ne(variables['System.TeamProject'], 'public'), ne(variables['Build.Reason'], 'PullRequest')) + + ############ LINUX MUSL BUILD ############ + - job: Build_Linux_musl + displayName: Linux_musl + timeoutInMinutes: 600 + variables: + - _BuildConfig: Release + strategy: + matrix: + x64: + assetManifestOS: linux-musl + assetManifestPlatform: x64 + imagename: mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-cross-amd64-alpine + rootfs: /crossrootfs/x64 + ClangTargetArg: /p:ClangTarget=x86_64-alpine-linux-musl + ClangBinDirArg: /p:ClangBinDir=/usr/local/bin + archflag: --arch x64 + arm64: + assetManifestOS: linux-musl + assetManifestPlatform: arm64 + imagename: mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-cross-arm64-alpine + rootfs: /crossrootfs/arm64 + ClangTargetArg: /p:ClangTarget=aarch64-alpine-linux-musl + ClangBinDirArg: /p:ClangBinDir=/usr/local/bin + archflag: --arch arm64 + pool: + ${{ if eq(variables['System.TeamProject'], 'public') }}: + name: $(DncEngPublicBuildPool) + demands: ImageOverride -equals build.ubuntu.2204.amd64.open + ${{ if eq(variables['System.TeamProject'], 'internal') }}: + name: $(DncEngInternalBuildPool) + demands: ImageOverride -equals build.ubuntu.2204.amd64 + container: + image: $(imagename) + steps: + - bash: | + set -ex + git clean -ffdx + git reset --hard HEAD + displayName: 'Clean up working directory' + + - bash: | + ./build.sh --ci --restore --build --pack $(archflag) --configuration $(_BuildConfig) $(_InternalBuildArgs) /p:OutputRid=linux-musl-$(assetManifestPlatform) $(ClangBinDirArg) $(ClangTargetArg) + displayName: 'Build and package' + env: + ROOTFS_DIR: $(rootfs) + + - bash: | + ./eng/common/build.sh --ci --restore --publish --configuration $(_BuildConfig) $(_InternalBuildArgs) /p:AssetManifestOS=$(assetManifestOS) /p:PlatformName=$(assetManifestPlatform) --projects $(Build.SourcesDirectory)/llvm.proj + displayName: Publish packages + condition: and(succeeded(), ne(variables['System.TeamProject'], 'public'), ne(variables['Build.Reason'], 'PullRequest')) + + ############ MACOS BUILD ############ + - job: Build_macOS + displayName: macOS + timeoutInMinutes: 600 + variables: + - _BuildConfig: Release + strategy: + matrix: + x64: + assetManifestOS: osx + assetManifestPlatform: x64 + clangTargetArg: /p:ClangTarget=x86_64-apple-darwin + archflag: --arch x64 + arm64: + assetManifestOS: osx + assetManifestPlatform: arm64 + clangTargetArg: /p:ClangTarget=aarch64-apple-darwin + archflag: --arch arm64 + pool: + vmImage: macos-11 + steps: + - bash: | + set -ex + git clean -ffdx + git reset --hard HEAD + displayName: 'Clean up working directory' + + - bash: | + ./build.sh --ci --restore --build --pack $(archflag) --configuration $(_BuildConfig) $(ClangTargetArg) $(_InternalBuildArgs) + displayName: 'Build and package' + + - bash: | + ./eng/common/build.sh --ci --restore --publish --configuration $(_BuildConfig) $(_InternalBuildArgs) /p:AssetManifestOS=$(assetManifestOS) /p:PlatformName=$(assetManifestPlatform) --projects $(Build.SourcesDirectory)/llvm.proj + displayName: Publish packages + condition: and(succeeded(), ne(variables['System.TeamProject'], 'public'), ne(variables['Build.Reason'], 'PullRequest')) + + ############ WINDOWS BUILD ############ + - job: Build_Windows + displayName: Windows + timeoutInMinutes: 600 + strategy: + matrix: + # Release + x64_release: + _BuildConfig: Release + assetManifestOS: win + assetManifestPlatform: x64 + LLVMTableGenArg: /p:NativeTablegenDir=$(Build.SourcesDirectory)\artifacts\obj\BuildRoot-x64\bin + archflag: -arch x64 + arm64_release: + _BuildConfig: Release + assetManifestOS: win + assetManifestPlatform: arm64 + LLVMTableGenArg: /p:NativeTablegenDir=$(Build.SourcesDirectory)\artifacts\obj\BuildRoot-x64\bin + archflag: -arch arm64 + # Debug + x64_debug: + _BuildConfig: Debug + assetManifestOS: win + assetManifestPlatform: x64 + LLVMTableGenArg: /p:NativeTablegenDir=$(Build.SourcesDirectory)\artifacts\obj\BuildRoot-x64\bin + archflag: -arch x64 + arm64_debug: + _BuildConfig: Debug + assetManifestOS: win + assetManifestPlatform: arm64 + LLVMTableGenArg: /p:NativeTablegenDir=$(Build.SourcesDirectory)\artifacts\obj\BuildRoot-x64\bin + archflag: -arch arm64 + pool: + ${{ if eq(variables['System.TeamProject'], 'public') }}: + name: $(DncEngPublicBuildPool) + demands: ImageOverride -equals windows.vs2022.amd64.open + ${{ if eq(variables['System.TeamProject'], 'internal') }}: + name: $(DncEngInternalBuildPool) + demands: ImageOverride -equals windows.vs2022.amd64 + steps: + - checkout: self + clean: true + fetchDepth: 2 + + - script: | + git clean -ffdx + git reset --hard HEAD + displayName: 'Clean up working directory' + + - powershell: eng\build.ps1 -ci -restore -build -arch x64 -configuration $(_BuildConfig) $(_InternalBuildArgs) /p:BuildLLVMTableGenOnly=true + displayName: 'Build host llvm-tblgen for cross-compiling' + + - powershell: eng\build.ps1 -ci -restore -build -pack $(archflag) -configuration $(_BuildConfig) $(_InternalBuildArgs) $(LLVMTableGenArg) + displayName: 'Build and package' + + - powershell: eng\common\build.ps1 -ci -restore -publish -configuration $(_BuildConfig) $(_InternalBuildArgs) /p:AssetManifestOS=$(_BuildConfig)-$(assetManifestOS) /p:PlatformName=$(assetManifestPlatform) -projects $(Build.SourcesDirectory)\llvm.proj + displayName: Publish packages + condition: and(succeeded(), ne(variables['System.TeamProject'], 'public'), ne(variables['Build.Reason'], 'PullRequest')) + +############ POST BUILD ARCADE LOGIC ############ +- ${{ if and(ne(variables['System.TeamProject'], 'public'), ne(variables['Build.Reason'], 'PullRequest')) }}: + - template: /eng/common/templates/post-build/post-build.yml + parameters: + publishingInfraVersion: 3 + enableSourceLinkValidation: false + enableSigningValidation: false + enableSymbolValidation: false + enableNugetValidation: true diff --git a/eng/build.ps1 b/eng/build.ps1 new file mode 100644 index 00000000000000..bc12cebbdcbd15 --- /dev/null +++ b/eng/build.ps1 @@ -0,0 +1,132 @@ +[CmdletBinding(PositionalBinding=$false)] +Param( + [switch][Alias('h')]$help, + [switch][Alias('b')]$build, + [switch][Alias('t')]$test, + [switch]$buildtests, + [string][Alias('c')]$configuration = "Debug", + [string][Alias('f')]$framework, + [string]$vs, + [string]$os, + [switch]$allconfigurations, + [switch]$coverage, + [string]$testscope, + [string]$arch, + [string]$runtimeConfiguration, + [string]$librariesConfiguration, + [Parameter(ValueFromRemainingArguments=$true)][String[]]$properties +) + +function Get-Help() { + Write-Host "Common settings:" + Write-Host " -os Build operating system: Windows_NT or Unix" + Write-Host " -arch Build platform: x86, x64, arm or arm64" + Write-Host " -configuration Build configuration: Debug or Release (short: -c)" + Write-Host " -verbosity MSBuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic] (short: -v)" + Write-Host " -binaryLog Output binary log (short: -bl)" + Write-Host " -help Print help and exit (short: -h)" + Write-Host "" + + Write-Host "Actions (defaults to -restore -build):" + Write-Host " -restore Restore dependencies (short: -r)" + Write-Host " -build Build all source projects (short: -b)" + Write-Host " -buildtests Build all test projects" + Write-Host " -rebuild Rebuild all source projects" + Write-Host " -test Run all unit tests (short: -t)" + Write-Host " -pack Package build outputs into NuGet packages" + Write-Host " -sign Sign build outputs" + Write-Host " -publish Publish artifacts (e.g. symbols)" + Write-Host " -clean Clean the solution" + Write-Host "" + + Write-Host "Libraries settings:" + Write-Host " -vs Open the solution with VS for Test Explorer support. Path or solution name (ie -vs Microsoft.CSharp)" + Write-Host " -framework Build framework: netcoreapp5.0 or net472 (short: -f)" + Write-Host " -coverage Collect code coverage when testing" + Write-Host " -testscope Scope tests, allowed values: innerloop, outerloop, all" + Write-Host " -allconfigurations Build packages for all build configurations" + Write-Host "" + + Write-Host "Command-line arguments not listed above are passed thru to msbuild." + Write-Host "The above arguments can be shortened as much as to be unambiguous (e.g. -con for configuration, -t for test, etc.)." +} + +if ($help -or (($null -ne $properties) -and ($properties.Contains('/help') -or $properties.Contains('/?')))) { + Get-Help + exit 0 +} + +# VS Test Explorer support for libraries +if ($vs) { + . $PSScriptRoot\common\tools.ps1 + + # Microsoft.DotNet.CoreSetup.sln is special - hosting tests are currently meant to run on the + # bootstrapped .NET Core, not on the live-built runtime. + if ([System.IO.Path]::GetFileName($vs) -ieq "Microsoft.DotNet.CoreSetup.sln") { + if (-Not (Test-Path $vs)) { + $vs = Join-Path "$PSScriptRoot\..\src\installer" $vs + } + + # This tells .NET Core to use the bootstrapped runtime to run the tests + $env:DOTNET_ROOT=InitializeDotNetCli -install:$false + } + else { + if (-Not (Test-Path $vs)) { + $vs = Join-Path "$PSScriptRoot\..\src\libraries" $vs | Join-Path -ChildPath "$vs.sln" + } + + $archTestHost = if ($arch) { $arch } else { "x64" } + + # This tells .NET Core to use the same dotnet.exe that build scripts use + $env:DOTNET_ROOT="$PSScriptRoot\..\artifacts\bin\testhost\netcoreapp5.0-Windows_NT-$configuration-$archTestHost"; + $env:DEVPATH="$PSScriptRoot\..\artifacts\bin\testhost\net472-Windows_NT-$configuration-$archTestHost"; + } + + # This tells MSBuild to load the SDK from the directory of the bootstrapped SDK + $env:DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR=InitializeDotNetCli -install:$false + + # This tells .NET Core not to go looking for .NET Core in other places + $env:DOTNET_MULTILEVEL_LOOKUP=0; + + # Put our local dotnet.exe on PATH first so Visual Studio knows which one to use + $env:PATH=($env:DOTNET_ROOT + ";" + $env:PATH); + + # Launch Visual Studio with the locally defined environment variables + ."$vs" + + exit 0 +} + +# Check if an action is passed in +$actions = "r","restore","b","build","buildtests","rebuild","t","test","pack","sign","publish","clean" +$actionPassedIn = @(Compare-Object -ReferenceObject @($PSBoundParameters.Keys) -DifferenceObject $actions -ExcludeDifferent -IncludeEqual).Length -ne 0 +if ($null -ne $properties -and $actionPassedIn -ne $true) { + $actionPassedIn = @(Compare-Object -ReferenceObject $properties -DifferenceObject $actions.ForEach({ "-" + $_ }) -ExcludeDifferent -IncludeEqual).Length -ne 0 +} + +if (!$actionPassedIn) { + $arguments = "-restore -build" +} + +$possibleDirToBuild = if($properties.Length -gt 0) { $properties[0]; } else { $null } + +foreach ($argument in $PSBoundParameters.Keys) +{ + switch($argument) + { + "build" { $arguments += " -build" } + "buildtests" { if ($build -eq $true) { $arguments += " /p:BuildTests=true" } else { $arguments += " -build /p:BuildTests=only" } } + "test" { $arguments += " -test" } + "configuration" { $configuration = (Get-Culture).TextInfo.ToTitleCase($($PSBoundParameters[$argument])); $arguments += " /p:ConfigurationGroup=$configuration -configuration $configuration" } + "runtimeConfiguration" { $arguments += " /p:RuntimeConfiguration=$((Get-Culture).TextInfo.ToTitleCase($($PSBoundParameters[$argument])))" } + "framework" { $arguments += " /p:BuildTargetFramework=$($PSBoundParameters[$argument].ToLowerInvariant())" } + "os" { $arguments += " /p:OSGroup=$($PSBoundParameters[$argument])" } + "allconfigurations" { $arguments += " /p:BuildAllConfigurations=true" } + "arch" { $arguments += " /p:ArchGroup=$($PSBoundParameters[$argument]) /p:TargetArchitecture=$($PSBoundParameters[$argument])" } + "properties" { $arguments += " " + $properties } + default { $arguments += " /p:$argument=$($PSBoundParameters[$argument])" } + } +} + +Invoke-Expression "& `"$PSScriptRoot/common/build.ps1`" $arguments" +exit $lastExitCode diff --git a/eng/build.sh b/eng/build.sh new file mode 100755 index 00000000000000..becb2067421838 --- /dev/null +++ b/eng/build.sh @@ -0,0 +1,170 @@ +#!/usr/bin/env bash + +set -ue + +source="${BASH_SOURCE[0]}" + +# resolve $source until the file is no longer a symlink +while [[ -h "$source" ]]; do + scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + # if $source was a relative symlink, we need to resolve it relative to the path where the + # symlink file was located + [[ $source != /* ]] && source="$scriptroot/$source" +done +scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + +usage() +{ + echo "Common settings:" + echo " --os Build operating system: Windows_NT or Unix" + echo " --arch Build platform: x86, x64, arm or arm64" + echo " --configuration Build configuration: Debug or Release (short: -c)" + echo " --verbosity MSBuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic] (short: -v)" + echo " --binaryLog Output binary log (short: -bl)" + echo " --cross Optional argument to signify cross compilation" + echo " --help Print help and exit (short: -h)" + echo "" + + echo "Actions (defaults to --restore --build):" + echo " --restore Restore dependencies (short: -r)" + echo " --build Build all source projects (short: -b)" + echo " --buildtests Build all test projects" + echo " --rebuild Rebuild all source projects" + echo " --test Run all unit tests (short: -t)" + echo " --pack Package build outputs into NuGet packages" + echo " --sign Sign build outputs" + echo " --publish Publish artifacts (e.g. symbols)" + echo " --clean Clean the solution" + echo "" + + echo "Libraries settings:" + echo " --framework Build framework: netcoreapp or net472 (short: -f)" + echo " --coverage Collect code coverage when testing" + echo " --testscope Test scope, allowed values: innerloop, outerloop, all" + echo " --allconfigurations Build packages for all build configurations" + echo "" + + echo "Native build settings:" + echo " --clang Optional argument to build using clang in PATH (default)" + echo " --clangx.y Optional argument to build using clang version x.y" + echo " --cmakeargs User-settable additional arguments passed to CMake." + echo " --gcc Optional argument to build using gcc in PATH (default)" + echo " --gccx.y Optional argument to build using gcc version x.y" + + echo "Command line arguments starting with '/p:' are passed through to MSBuild." + echo "Arguments can also be passed in with a single hyphen." +} + +arguments='' +cmakeargs='' +extraargs='' +build=false +buildtests=false +checkedPossibleDirectoryToBuild=false + +# Check if an action is passed in +declare -a actions=("r" "restore" "b" "build" "buildtests" "rebuild" "t" "test" "pack" "sign" "publish" "clean") +actInt=($(comm -12 <(printf '%s\n' "${actions[@]/#/-}" | sort) <(printf '%s\n' "${@/#--/-}" | sort))) + +while [[ $# > 0 ]]; do + opt="$(echo "${1/#--/-}" | awk '{print tolower($0)}')" + case "$opt" in + -help|-h) + usage + exit 0 + ;; + -arch) + arguments="$arguments /p:ArchGroup=$2 /p:TargetArchitecture=$2" + shift 2 + ;; + -configuration|-c) + val="$(tr '[:lower:]' '[:upper:]' <<< ${2:0:1})${2:1}" + arguments="$arguments /p:ConfigurationGroup=$val -configuration $val" + shift 2 + ;; + -framework|-f) + val="$(echo "$2" | awk '{print tolower($0)}')" + arguments="$arguments /p:BuildTargetFramework=$val" + shift 2 + ;; + -os) + arguments="$arguments /p:OSGroup=$2" + shift 2 + ;; + -allconfigurations) + arguments="$arguments /p:BuildAllConfigurations=true" + shift 1 + ;; + -build) + build=true + arguments="$arguments -build" + shift 1 + ;; + -buildtests) + buildtests=true + shift 1 + ;; + -testscope) + arguments="$arguments /p:TestScope=$2" + shift 2 + ;; + -coverage) + arguments="$arguments /p:Coverage=true" + shift 1 + ;; + -stripsymbols) + arguments="$arguments /p:BuildNativeStripSymbols=true" + shift 1 + ;; + -runtimeconfiguration) + val="$(tr '[:lower:]' '[:upper:]' <<< ${2:0:1})${2:1}" + arguments="$arguments /p:RuntimeConfiguration=$val" + shift 2 + ;; + -librariesconfiguration) + arguments="$arguments /p:LibrariesConfiguration=$2" + shift 2 + ;; + -cross) + arguments="$arguments /p:CrossBuild=True" + shift 1 + ;; + -clang*) + arguments="$arguments /p:Compiler=$opt" + shift 1 + ;; + -cmakeargs) + cmakeargs="${cmakeargs} ${opt} $2" + shift 2 + ;; + -gcc*) + arguments="$arguments /p:Compiler=$opt" + shift 1 + ;; + *) + ea=$1 + + extraargs="$extraargs $ea" + shift 1 + ;; + esac +done + +if [[ "$buildtests" == true ]]; then + if [[ "$build" == true ]]; then + arguments="$arguments /p:BuildTests=true" + else + arguments="$arguments -build /p:BuildTests=only" + fi +fi + +if [ ${#actInt[@]} -eq 0 ]; then + arguments="-restore -build $arguments" +fi + +# URL-encode space (%20) to avoid quoting issues until the msbuild call in /eng/common/tools.sh. +# In *proj files (XML docs), URL-encoded string are rendered in their decoded form. +cmakeargs="${cmakeargs// /%20}" +arguments="$arguments /p:CMakeArgs=\"$cmakeargs\" $extraargs" +"$scriptroot/common/build.sh" $arguments diff --git a/eng/common-variables.yml b/eng/common-variables.yml new file mode 100644 index 00000000000000..1901c728e063e9 --- /dev/null +++ b/eng/common-variables.yml @@ -0,0 +1,40 @@ + +variables: + # Cannot use key:value syntax in root defined variables + - name: _TeamName + value: DotNetCore + - name: _DotNetArtifactsCategory + value: .NETCore + - name: _DotNetValidationArtifactsCategory + value: .NETCore + - name: HelixApiAccessToken + value: '' + - name: _RunAsPublic + value: True + - name: _RunAsInternal + value: False + - name: _InternalBuildArgs + value: '' + + - ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: + - name: _RunAsPublic + value: False + - name: _RunAsInternal + value: True + - name: _SignType + value: real + # DotNet-Blob-Feed provides: dotnetfeed-storage-access-key-1 + # Publish-Build-Assets provides: MaestroAccessToken, BotAccount-dotnet-maestro-bot-PAT + # DotNet-HelixApi-Access provides: HelixApiAccessToken + - group: DotNet-Blob-Feed + - group: Publish-Build-Assets + - group: DotNet-VSTS-Bot + - group: DotNet-HelixApi-Access + - name: _InternalBuildArgs + value: /p:DotNetSignType=$(_SignType) /p:TeamName=$(_TeamName) + /p:DotNetPublishBlobFeedKey=$(dotnetfeed-storage-access-key-1) + /p:DotNetPublishBlobFeedUrl=https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json + /p:DotNetPublishToBlobFeed=true + /p:DotNetPublishUsingPipelines=true + /p:DotNetArtifactsCategory=$(_DotNetArtifactsCategory) + /p:OfficialBuildId=$(BUILD.BUILDNUMBER) diff --git a/eng/common/BuildConfiguration/build-configuration.json b/eng/common/BuildConfiguration/build-configuration.json new file mode 100644 index 00000000000000..3d1cc89894c94b --- /dev/null +++ b/eng/common/BuildConfiguration/build-configuration.json @@ -0,0 +1,4 @@ +{ + "RetryCountLimit": 1, + "RetryByAnyError": false +} diff --git a/eng/common/CIBuild.cmd b/eng/common/CIBuild.cmd new file mode 100644 index 00000000000000..56c2f25ac22ffa --- /dev/null +++ b/eng/common/CIBuild.cmd @@ -0,0 +1,2 @@ +@echo off +powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0Build.ps1""" -restore -build -test -sign -pack -publish -ci %*" \ No newline at end of file diff --git a/eng/common/PSScriptAnalyzerSettings.psd1 b/eng/common/PSScriptAnalyzerSettings.psd1 new file mode 100644 index 00000000000000..4c1ea7c98ea4d1 --- /dev/null +++ b/eng/common/PSScriptAnalyzerSettings.psd1 @@ -0,0 +1,11 @@ +@{ + IncludeRules=@('PSAvoidUsingCmdletAliases', + 'PSAvoidUsingWMICmdlet', + 'PSAvoidUsingPositionalParameters', + 'PSAvoidUsingInvokeExpression', + 'PSUseDeclaredVarsMoreThanAssignments', + 'PSUseCmdletCorrectly', + 'PSStandardDSCFunctionsInResource', + 'PSUseIdenticalMandatoryParametersForDSC', + 'PSUseIdenticalParametersForDSC') +} \ No newline at end of file diff --git a/eng/common/README.md b/eng/common/README.md new file mode 100644 index 00000000000000..ff49c371527a03 --- /dev/null +++ b/eng/common/README.md @@ -0,0 +1,28 @@ +# Don't touch this folder + + uuuuuuuuuuuuuuuuuuuu + u" uuuuuuuuuuuuuuuuuu "u + u" u$$$$$$$$$$$$$$$$$$$$u "u + u" u$$$$$$$$$$$$$$$$$$$$$$$$u "u + u" u$$$$$$$$$$$$$$$$$$$$$$$$$$$$u "u + u" u$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$u "u + u" u$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$u "u + $ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $ + $ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $ + $ $$$" ... "$... ...$" ... "$$$ ... "$$$ $ + $ $$$u `"$$$$$$$ $$$ $$$$$ $$ $$$ $$$ $ + $ $$$$$$uu "$$$$ $$$ $$$$$ $$ """ u$$$ $ + $ $$$""$$$ $$$$ $$$u "$$$" u$$ $$$$$$$$ $ + $ $$$$....,$$$$$..$$$$$....,$$$$..$$$$$$$$ $ + $ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $ + "u "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" u" + "u "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" u" + "u "$$$$$$$$$$$$$$$$$$$$$$$$$$$$" u" + "u "$$$$$$$$$$$$$$$$$$$$$$$$" u" + "u "$$$$$$$$$$$$$$$$$$$$" u" + "u """""""""""""""""" u" + """""""""""""""""""" + +!!! Changes made in this directory are subject to being overwritten by automation !!! + +The files in this directory are shared by all Arcade repos and managed by automation. If you need to make changes to these files, open an issue or submit a pull request to https://github.com/dotnet/arcade first. diff --git a/eng/common/SetupNugetSources.ps1 b/eng/common/SetupNugetSources.ps1 new file mode 100644 index 00000000000000..6e99723945183e --- /dev/null +++ b/eng/common/SetupNugetSources.ps1 @@ -0,0 +1,167 @@ +# This file is a temporary workaround for internal builds to be able to restore from private AzDO feeds. +# This file should be removed as part of this issue: https://github.com/dotnet/arcade/issues/4080 +# +# What the script does is iterate over all package sources in the pointed NuGet.config and add a credential entry +# under for each Maestro managed private feed. Two additional credential +# entries are also added for the two private static internal feeds: dotnet3-internal and dotnet3-internal-transport. +# +# This script needs to be called in every job that will restore packages and which the base repo has +# private AzDO feeds in the NuGet.config. +# +# See example YAML call for this script below. Note the use of the variable `$(dn-bot-dnceng-artifact-feeds-rw)` +# from the AzureDevOps-Artifact-Feeds-Pats variable group. +# +# Any disabledPackageSources entries which start with "darc-int" will be re-enabled as part of this script executing +# +# - task: PowerShell@2 +# displayName: Setup Private Feeds Credentials +# condition: eq(variables['Agent.OS'], 'Windows_NT') +# inputs: +# filePath: $(Build.SourcesDirectory)/eng/common/SetupNugetSources.ps1 +# arguments: -ConfigFile $(Build.SourcesDirectory)/NuGet.config -Password $Env:Token +# env: +# Token: $(dn-bot-dnceng-artifact-feeds-rw) + +[CmdletBinding()] +param ( + [Parameter(Mandatory = $true)][string]$ConfigFile, + [Parameter(Mandatory = $true)][string]$Password +) + +$ErrorActionPreference = "Stop" +Set-StrictMode -Version 2.0 +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + +. $PSScriptRoot\tools.ps1 + +# Add source entry to PackageSources +function AddPackageSource($sources, $SourceName, $SourceEndPoint, $creds, $Username, $Password) { + $packageSource = $sources.SelectSingleNode("add[@key='$SourceName']") + + if ($packageSource -eq $null) + { + $packageSource = $doc.CreateElement("add") + $packageSource.SetAttribute("key", $SourceName) + $packageSource.SetAttribute("value", $SourceEndPoint) + $sources.AppendChild($packageSource) | Out-Null + } + else { + Write-Host "Package source $SourceName already present." + } + + AddCredential -Creds $creds -Source $SourceName -Username $Username -Password $Password +} + +# Add a credential node for the specified source +function AddCredential($creds, $source, $username, $password) { + # Looks for credential configuration for the given SourceName. Create it if none is found. + $sourceElement = $creds.SelectSingleNode($Source) + if ($sourceElement -eq $null) + { + $sourceElement = $doc.CreateElement($Source) + $creds.AppendChild($sourceElement) | Out-Null + } + + # Add the node to the credential if none is found. + $usernameElement = $sourceElement.SelectSingleNode("add[@key='Username']") + if ($usernameElement -eq $null) + { + $usernameElement = $doc.CreateElement("add") + $usernameElement.SetAttribute("key", "Username") + $sourceElement.AppendChild($usernameElement) | Out-Null + } + $usernameElement.SetAttribute("value", $Username) + + # Add the to the credential if none is found. + # Add it as a clear text because there is no support for encrypted ones in non-windows .Net SDKs. + # -> https://github.com/NuGet/Home/issues/5526 + $passwordElement = $sourceElement.SelectSingleNode("add[@key='ClearTextPassword']") + if ($passwordElement -eq $null) + { + $passwordElement = $doc.CreateElement("add") + $passwordElement.SetAttribute("key", "ClearTextPassword") + $sourceElement.AppendChild($passwordElement) | Out-Null + } + $passwordElement.SetAttribute("value", $Password) +} + +function InsertMaestroPrivateFeedCredentials($Sources, $Creds, $Username, $Password) { + $maestroPrivateSources = $Sources.SelectNodes("add[contains(@key,'darc-int')]") + + Write-Host "Inserting credentials for $($maestroPrivateSources.Count) Maestro's private feeds." + + ForEach ($PackageSource in $maestroPrivateSources) { + Write-Host "`tInserting credential for Maestro's feed:" $PackageSource.Key + AddCredential -Creds $creds -Source $PackageSource.Key -Username $Username -Password $Password + } +} + +function EnablePrivatePackageSources($DisabledPackageSources) { + $maestroPrivateSources = $DisabledPackageSources.SelectNodes("add[contains(@key,'darc-int')]") + ForEach ($DisabledPackageSource in $maestroPrivateSources) { + Write-Host "`tEnsuring private source '$($DisabledPackageSource.key)' is enabled by deleting it from disabledPackageSource" + # Due to https://github.com/NuGet/Home/issues/10291, we must actually remove the disabled entries + $DisabledPackageSources.RemoveChild($DisabledPackageSource) + } +} + +if (!(Test-Path $ConfigFile -PathType Leaf)) { + Write-PipelineTelemetryError -Category 'Build' -Message "Eng/common/SetupNugetSources.ps1 returned a non-zero exit code. Couldn't find the NuGet config file: $ConfigFile" + ExitWithExitCode 1 +} + +if (!$Password) { + Write-PipelineTelemetryError -Category 'Build' -Message 'Eng/common/SetupNugetSources.ps1 returned a non-zero exit code. Please supply a valid PAT' + ExitWithExitCode 1 +} + +# Load NuGet.config +$doc = New-Object System.Xml.XmlDocument +$filename = (Get-Item $ConfigFile).FullName +$doc.Load($filename) + +# Get reference to or create one if none exist already +$sources = $doc.DocumentElement.SelectSingleNode("packageSources") +if ($sources -eq $null) { + $sources = $doc.CreateElement("packageSources") + $doc.DocumentElement.AppendChild($sources) | Out-Null +} + +# Looks for a node. Create it if none is found. +$creds = $doc.DocumentElement.SelectSingleNode("packageSourceCredentials") +if ($creds -eq $null) { + $creds = $doc.CreateElement("packageSourceCredentials") + $doc.DocumentElement.AppendChild($creds) | Out-Null +} + +# Check for disabledPackageSources; we'll enable any darc-int ones we find there +$disabledSources = $doc.DocumentElement.SelectSingleNode("disabledPackageSources") +if ($disabledSources -ne $null) { + Write-Host "Checking for any darc-int disabled package sources in the disabledPackageSources node" + EnablePrivatePackageSources -DisabledPackageSources $disabledSources +} + +$userName = "dn-bot" + +# Insert credential nodes for Maestro's private feeds +InsertMaestroPrivateFeedCredentials -Sources $sources -Creds $creds -Username $userName -Password $Password + +# 3.1 uses a different feed url format so it's handled differently here +$dotnet31Source = $sources.SelectSingleNode("add[@key='dotnet3.1']") +if ($dotnet31Source -ne $null) { + AddPackageSource -Sources $sources -SourceName "dotnet3.1-internal" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3.1-internal/nuget/v2" -Creds $creds -Username $userName -Password $Password + AddPackageSource -Sources $sources -SourceName "dotnet3.1-internal-transport" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3.1-internal-transport/nuget/v2" -Creds $creds -Username $userName -Password $Password +} + +$dotnetVersions = @('5','6','7') + +foreach ($dotnetVersion in $dotnetVersions) { + $feedPrefix = "dotnet" + $dotnetVersion; + $dotnetSource = $sources.SelectSingleNode("add[@key='$feedPrefix']") + if ($dotnetSource -ne $null) { + AddPackageSource -Sources $sources -SourceName "$feedPrefix-internal" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/internal/_packaging/$feedPrefix-internal/nuget/v2" -Creds $creds -Username $userName -Password $Password + AddPackageSource -Sources $sources -SourceName "$feedPrefix-internal-transport" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/internal/_packaging/$feedPrefix-internal-transport/nuget/v2" -Creds $creds -Username $userName -Password $Password + } +} + +$doc.Save($filename) diff --git a/eng/common/SetupNugetSources.sh b/eng/common/SetupNugetSources.sh new file mode 100644 index 00000000000000..8af7d899db1212 --- /dev/null +++ b/eng/common/SetupNugetSources.sh @@ -0,0 +1,171 @@ +#!/usr/bin/env bash + +# This file is a temporary workaround for internal builds to be able to restore from private AzDO feeds. +# This file should be removed as part of this issue: https://github.com/dotnet/arcade/issues/4080 +# +# What the script does is iterate over all package sources in the pointed NuGet.config and add a credential entry +# under for each Maestro's managed private feed. Two additional credential +# entries are also added for the two private static internal feeds: dotnet3-internal and dotnet3-internal-transport. +# +# This script needs to be called in every job that will restore packages and which the base repo has +# private AzDO feeds in the NuGet.config. +# +# See example YAML call for this script below. Note the use of the variable `$(dn-bot-dnceng-artifact-feeds-rw)` +# from the AzureDevOps-Artifact-Feeds-Pats variable group. +# +# Any disabledPackageSources entries which start with "darc-int" will be re-enabled as part of this script executing. +# +# - task: Bash@3 +# displayName: Setup Private Feeds Credentials +# inputs: +# filePath: $(Build.SourcesDirectory)/eng/common/SetupNugetSources.sh +# arguments: $(Build.SourcesDirectory)/NuGet.config $Token +# condition: ne(variables['Agent.OS'], 'Windows_NT') +# env: +# Token: $(dn-bot-dnceng-artifact-feeds-rw) + +ConfigFile=$1 +CredToken=$2 +NL='\n' +TB=' ' + +source="${BASH_SOURCE[0]}" + +# resolve $source until the file is no longer a symlink +while [[ -h "$source" ]]; do + scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + # if $source was a relative symlink, we need to resolve it relative to the path where the + # symlink file was located + [[ $source != /* ]] && source="$scriptroot/$source" +done +scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + +. "$scriptroot/tools.sh" + +if [ ! -f "$ConfigFile" ]; then + Write-PipelineTelemetryError -Category 'Build' "Error: Eng/common/SetupNugetSources.sh returned a non-zero exit code. Couldn't find the NuGet config file: $ConfigFile" + ExitWithExitCode 1 +fi + +if [ -z "$CredToken" ]; then + Write-PipelineTelemetryError -category 'Build' "Error: Eng/common/SetupNugetSources.sh returned a non-zero exit code. Please supply a valid PAT" + ExitWithExitCode 1 +fi + +if [[ `uname -s` == "Darwin" ]]; then + NL=$'\\\n' + TB='' +fi + +# Ensure there is a ... section. +grep -i "" $ConfigFile +if [ "$?" != "0" ]; then + echo "Adding ... section." + ConfigNodeHeader="" + PackageSourcesTemplate="${TB}${NL}${TB}" + + sed -i.bak "s|$ConfigNodeHeader|$ConfigNodeHeader${NL}$PackageSourcesTemplate|" $ConfigFile +fi + +# Ensure there is a ... section. +grep -i "" $ConfigFile +if [ "$?" != "0" ]; then + echo "Adding ... section." + + PackageSourcesNodeFooter="" + PackageSourceCredentialsTemplate="${TB}${NL}${TB}" + + sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourcesNodeFooter${NL}$PackageSourceCredentialsTemplate|" $ConfigFile +fi + +PackageSources=() + +# Ensure dotnet3.1-internal and dotnet3.1-internal-transport are in the packageSources if the public dotnet3.1 feeds are present +grep -i "" + + sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourceTemplate${NL}$PackageSourcesNodeFooter|" $ConfigFile + fi + PackageSources+=('dotnet3.1-internal') + + grep -i "" $ConfigFile + if [ "$?" != "0" ]; then + echo "Adding dotnet3.1-internal-transport to the packageSources." + PackageSourcesNodeFooter="" + PackageSourceTemplate="${TB}" + + sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourceTemplate${NL}$PackageSourcesNodeFooter|" $ConfigFile + fi + PackageSources+=('dotnet3.1-internal-transport') +fi + +DotNetVersions=('5' '6' '7') + +for DotNetVersion in ${DotNetVersions[@]} ; do + FeedPrefix="dotnet${DotNetVersion}"; + grep -i "" + + sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourceTemplate${NL}$PackageSourcesNodeFooter|" $ConfigFile + fi + PackageSources+=("$FeedPrefix-internal") + + grep -i "" $ConfigFile + if [ "$?" != "0" ]; then + echo "Adding $FeedPrefix-internal-transport to the packageSources." + PackageSourcesNodeFooter="" + PackageSourceTemplate="${TB}" + + sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourceTemplate${NL}$PackageSourcesNodeFooter|" $ConfigFile + fi + PackageSources+=("$FeedPrefix-internal-transport") + fi +done + +# I want things split line by line +PrevIFS=$IFS +IFS=$'\n' +PackageSources+="$IFS" +PackageSources+=$(grep -oh '"darc-int-[^"]*"' $ConfigFile | tr -d '"') +IFS=$PrevIFS + +for FeedName in ${PackageSources[@]} ; do + # Check if there is no existing credential for this FeedName + grep -i "<$FeedName>" $ConfigFile + if [ "$?" != "0" ]; then + echo "Adding credentials for $FeedName." + + PackageSourceCredentialsNodeFooter="" + NewCredential="${TB}${TB}<$FeedName>${NL}${NL}${NL}" + + sed -i.bak "s|$PackageSourceCredentialsNodeFooter|$NewCredential${NL}$PackageSourceCredentialsNodeFooter|" $ConfigFile + fi +done + +# Re-enable any entries in disabledPackageSources where the feed name contains darc-int +grep -i "" $ConfigFile +if [ "$?" == "0" ]; then + DisabledDarcIntSources=() + echo "Re-enabling any disabled \"darc-int\" package sources in $ConfigFile" + DisabledDarcIntSources+=$(grep -oh '"darc-int-[^"]*" value="true"' $ConfigFile | tr -d '"') + for DisabledSourceName in ${DisabledDarcIntSources[@]} ; do + if [[ $DisabledSourceName == darc-int* ]] + then + OldDisableValue="" + NewDisableValue="" + sed -i.bak "s|$OldDisableValue|$NewDisableValue|" $ConfigFile + echo "Neutralized disablePackageSources entry for '$DisabledSourceName'" + fi + done +fi diff --git a/eng/common/build.ps1 b/eng/common/build.ps1 new file mode 100644 index 00000000000000..33a6f2d0e24811 --- /dev/null +++ b/eng/common/build.ps1 @@ -0,0 +1,166 @@ +[CmdletBinding(PositionalBinding=$false)] +Param( + [string][Alias('c')]$configuration = "Debug", + [string]$platform = $null, + [string] $projects, + [string][Alias('v')]$verbosity = "minimal", + [string] $msbuildEngine = $null, + [bool] $warnAsError = $true, + [bool] $nodeReuse = $true, + [switch][Alias('r')]$restore, + [switch] $deployDeps, + [switch][Alias('b')]$build, + [switch] $rebuild, + [switch] $deploy, + [switch][Alias('t')]$test, + [switch] $integrationTest, + [switch] $performanceTest, + [switch] $sign, + [switch] $pack, + [switch] $publish, + [switch] $clean, + [switch][Alias('bl')]$binaryLog, + [switch][Alias('nobl')]$excludeCIBinarylog, + [switch] $ci, + [switch] $prepareMachine, + [string] $runtimeSourceFeed = '', + [string] $runtimeSourceFeedKey = '', + [switch] $excludePrereleaseVS, + [switch] $nativeToolsOnMachine, + [switch] $help, + [Parameter(ValueFromRemainingArguments=$true)][String[]]$properties +) + +# Unset 'Platform' environment variable to avoid unwanted collision in InstallDotNetCore.targets file +# some computer has this env var defined (e.g. Some HP) +if($env:Platform) { + $env:Platform="" +} +function Print-Usage() { + Write-Host "Common settings:" + Write-Host " -configuration Build configuration: 'Debug' or 'Release' (short: -c)" + Write-Host " -platform Platform configuration: 'x86', 'x64' or any valid Platform value to pass to msbuild" + Write-Host " -verbosity Msbuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic] (short: -v)" + Write-Host " -binaryLog Output binary log (short: -bl)" + Write-Host " -help Print help and exit" + Write-Host "" + + Write-Host "Actions:" + Write-Host " -restore Restore dependencies (short: -r)" + Write-Host " -build Build solution (short: -b)" + Write-Host " -rebuild Rebuild solution" + Write-Host " -deploy Deploy built VSIXes" + Write-Host " -deployDeps Deploy dependencies (e.g. VSIXes for integration tests)" + Write-Host " -test Run all unit tests in the solution (short: -t)" + Write-Host " -integrationTest Run all integration tests in the solution" + Write-Host " -performanceTest Run all performance tests in the solution" + Write-Host " -pack Package build outputs into NuGet packages and Willow components" + Write-Host " -sign Sign build outputs" + Write-Host " -publish Publish artifacts (e.g. symbols)" + Write-Host " -clean Clean the solution" + Write-Host "" + + Write-Host "Advanced settings:" + Write-Host " -projects Semi-colon delimited list of sln/proj's to build. Globbing is supported (*.sln)" + Write-Host " -ci Set when running on CI server" + Write-Host " -excludeCIBinarylog Don't output binary log (short: -nobl)" + Write-Host " -prepareMachine Prepare machine for CI run, clean up processes after build" + Write-Host " -warnAsError Sets warnaserror msbuild parameter ('true' or 'false')" + Write-Host " -msbuildEngine Msbuild engine to use to run build ('dotnet', 'vs', or unspecified)." + Write-Host " -excludePrereleaseVS Set to exclude build engines in prerelease versions of Visual Studio" + Write-Host " -nativeToolsOnMachine Sets the native tools on machine environment variable (indicating that the script should use native tools on machine)" + Write-Host "" + + Write-Host "Command line arguments not listed above are passed thru to msbuild." + Write-Host "The above arguments can be shortened as much as to be unambiguous (e.g. -co for configuration, -t for test, etc.)." +} + +. $PSScriptRoot\tools.ps1 + +function InitializeCustomToolset { + if (-not $restore) { + return + } + + $script = Join-Path $EngRoot 'restore-toolset.ps1' + + if (Test-Path $script) { + . $script + } +} + +function Build { + $toolsetBuildProj = InitializeToolset + InitializeCustomToolset + + $bl = if ($binaryLog) { '/bl:' + (Join-Path $LogDir 'Build.binlog') } else { '' } + $platformArg = if ($platform) { "/p:Platform=$platform" } else { '' } + + if ($projects) { + # Re-assign properties to a new variable because PowerShell doesn't let us append properties directly for unclear reasons. + # Explicitly set the type as string[] because otherwise PowerShell would make this char[] if $properties is empty. + [string[]] $msbuildArgs = $properties + + # Resolve relative project paths into full paths + $projects = ($projects.Split(';').ForEach({Resolve-Path $_}) -join ';') + + $msbuildArgs += "/p:Projects=$projects" + $properties = $msbuildArgs + } + + MSBuild $toolsetBuildProj ` + $bl ` + $platformArg ` + /p:Configuration=$configuration ` + /p:RepoRoot=$RepoRoot ` + /p:Restore=$restore ` + /p:DeployDeps=$deployDeps ` + /p:Build=$build ` + /p:Rebuild=$rebuild ` + /p:Deploy=$deploy ` + /p:Test=$test ` + /p:Pack=$pack ` + /p:IntegrationTest=$integrationTest ` + /p:PerformanceTest=$performanceTest ` + /p:Sign=$sign ` + /p:Publish=$publish ` + @properties +} + +try { + if ($clean) { + if (Test-Path $ArtifactsDir) { + Remove-Item -Recurse -Force $ArtifactsDir + Write-Host 'Artifacts directory deleted.' + } + exit 0 + } + + if ($help -or (($null -ne $properties) -and ($properties.Contains('/help') -or $properties.Contains('/?')))) { + Print-Usage + exit 0 + } + + if ($ci) { + if (-not $excludeCIBinarylog) { + $binaryLog = $true + } + $nodeReuse = $false + } + + if ($nativeToolsOnMachine) { + $env:NativeToolsOnMachine = $true + } + if ($restore) { + InitializeNativeTools + } + + Build +} +catch { + Write-Host $_.ScriptStackTrace + Write-PipelineTelemetryError -Category 'InitializeToolset' -Message $_ + ExitWithExitCode 1 +} + +ExitWithExitCode 0 diff --git a/eng/common/build.sh b/eng/common/build.sh new file mode 100755 index 00000000000000..50af40cdd2ce60 --- /dev/null +++ b/eng/common/build.sh @@ -0,0 +1,247 @@ +#!/usr/bin/env bash + +# Stop script if unbound variable found (use ${var:-} if intentional) +set -u + +# Stop script if command returns non-zero exit code. +# Prevents hidden errors caused by missing error code propagation. +set -e + +usage() +{ + echo "Common settings:" + echo " --configuration Build configuration: 'Debug' or 'Release' (short: -c)" + echo " --verbosity Msbuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic] (short: -v)" + echo " --binaryLog Create MSBuild binary log (short: -bl)" + echo " --help Print help and exit (short: -h)" + echo "" + + echo "Actions:" + echo " --restore Restore dependencies (short: -r)" + echo " --build Build solution (short: -b)" + echo " --sourceBuild Source-build the solution (short: -sb)" + echo " Will additionally trigger the following actions: --restore, --build, --pack" + echo " If --configuration is not set explicitly, will also set it to 'Release'" + echo " --rebuild Rebuild solution" + echo " --test Run all unit tests in the solution (short: -t)" + echo " --integrationTest Run all integration tests in the solution" + echo " --performanceTest Run all performance tests in the solution" + echo " --pack Package build outputs into NuGet packages and Willow components" + echo " --sign Sign build outputs" + echo " --publish Publish artifacts (e.g. symbols)" + echo " --clean Clean the solution" + echo "" + + echo "Advanced settings:" + echo " --projects Project or solution file(s) to build" + echo " --ci Set when running on CI server" + echo " --excludeCIBinarylog Don't output binary log (short: -nobl)" + echo " --prepareMachine Prepare machine for CI run, clean up processes after build" + echo " --nodeReuse Sets nodereuse msbuild parameter ('true' or 'false')" + echo " --warnAsError Sets warnaserror msbuild parameter ('true' or 'false')" + echo "" + echo "Command line arguments not listed above are passed thru to msbuild." + echo "Arguments can also be passed in with a single hyphen." +} + +source="${BASH_SOURCE[0]}" + +# resolve $source until the file is no longer a symlink +while [[ -h "$source" ]]; do + scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + # if $source was a relative symlink, we need to resolve it relative to the path where the + # symlink file was located + [[ $source != /* ]] && source="$scriptroot/$source" +done +scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + +restore=false +build=false +source_build=false +rebuild=false +test=false +integration_test=false +performance_test=false +pack=false +publish=false +sign=false +public=false +ci=false +clean=false + +warn_as_error=true +node_reuse=true +binary_log=false +exclude_ci_binary_log=false +pipelines_log=false + +projects='' +configuration='' +prepare_machine=false +verbosity='minimal' +runtime_source_feed='' +runtime_source_feed_key='' + +properties='' +while [[ $# > 0 ]]; do + opt="$(echo "${1/#--/-}" | tr "[:upper:]" "[:lower:]")" + case "$opt" in + -help|-h) + usage + exit 0 + ;; + -clean) + clean=true + ;; + -configuration|-c) + configuration=$2 + shift + ;; + -verbosity|-v) + verbosity=$2 + shift + ;; + -binarylog|-bl) + binary_log=true + ;; + -excludeCIBinarylog|-nobl) + exclude_ci_binary_log=true + ;; + -pipelineslog|-pl) + pipelines_log=true + ;; + -restore|-r) + restore=true + ;; + -build|-b) + build=true + ;; + -rebuild) + rebuild=true + ;; + -pack) + pack=true + ;; + -sourcebuild|-sb) + build=true + source_build=true + restore=true + pack=true + ;; + -test|-t) + test=true + ;; + -integrationtest) + integration_test=true + ;; + -performancetest) + performance_test=true + ;; + -sign) + sign=true + ;; + -publish) + publish=true + ;; + -preparemachine) + prepare_machine=true + ;; + -projects) + projects=$2 + shift + ;; + -ci) + ci=true + ;; + -warnaserror) + warn_as_error=$2 + shift + ;; + -nodereuse) + node_reuse=$2 + shift + ;; + -runtimesourcefeed) + runtime_source_feed=$2 + shift + ;; + -runtimesourcefeedkey) + runtime_source_feed_key=$2 + shift + ;; + *) + properties="$properties $1" + ;; + esac + + shift +done + +if [[ -z "$configuration" ]]; then + if [[ "$source_build" = true ]]; then configuration="Release"; else configuration="Debug"; fi +fi + +if [[ "$ci" == true ]]; then + pipelines_log=true + node_reuse=false + if [[ "$exclude_ci_binary_log" == false ]]; then + binary_log=true + fi +fi + +. "$scriptroot/tools.sh" + +function InitializeCustomToolset { + local script="$eng_root/restore-toolset.sh" + + if [[ -a "$script" ]]; then + . "$script" + fi +} + +function Build { + InitializeToolset + InitializeCustomToolset + + if [[ ! -z "$projects" ]]; then + properties="$properties /p:Projects=$projects" + fi + + local bl="" + if [[ "$binary_log" == true ]]; then + bl="/bl:\"$log_dir/Build.binlog\"" + fi + + MSBuild $_InitializeToolset \ + $bl \ + /p:Configuration=$configuration \ + /p:RepoRoot="$repo_root" \ + /p:Restore=$restore \ + /p:Build=$build \ + /p:ArcadeBuildFromSource=$source_build \ + /p:Rebuild=$rebuild \ + /p:Test=$test \ + /p:Pack=$pack \ + /p:IntegrationTest=$integration_test \ + /p:PerformanceTest=$performance_test \ + /p:Sign=$sign \ + /p:Publish=$publish \ + $properties + + ExitWithExitCode 0 +} + +if [[ "$clean" == true ]]; then + if [ -d "$artifacts_dir" ]; then + rm -rf $artifacts_dir + echo "Artifacts directory deleted." + fi + exit 0 +fi + +if [[ "$restore" == true ]]; then + InitializeNativeTools +fi + +Build diff --git a/eng/common/cibuild.sh b/eng/common/cibuild.sh new file mode 100755 index 00000000000000..1a02c0dec8fd7b --- /dev/null +++ b/eng/common/cibuild.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +source="${BASH_SOURCE[0]}" + +# resolve $SOURCE until the file is no longer a symlink +while [[ -h $source ]]; do + scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + + # if $source was a relative symlink, we need to resolve it relative to the path where + # the symlink file was located + [[ $source != /* ]] && source="$scriptroot/$source" +done +scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + +. "$scriptroot/build.sh" --restore --build --test --pack --publish --ci $@ \ No newline at end of file diff --git a/eng/common/cross/arm/sources.list.bionic b/eng/common/cross/arm/sources.list.bionic new file mode 100644 index 00000000000000..2109557409576d --- /dev/null +++ b/eng/common/cross/arm/sources.list.bionic @@ -0,0 +1,11 @@ +deb http://ports.ubuntu.com/ubuntu-ports/ bionic main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ bionic-backports main restricted +deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-backports main restricted + +deb http://ports.ubuntu.com/ubuntu-ports/ bionic-security main restricted universe multiverse +deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-security main restricted universe multiverse diff --git a/eng/common/cross/arm/sources.list.focal b/eng/common/cross/arm/sources.list.focal new file mode 100644 index 00000000000000..4de2600c17478c --- /dev/null +++ b/eng/common/cross/arm/sources.list.focal @@ -0,0 +1,11 @@ +deb http://ports.ubuntu.com/ubuntu-ports/ focal main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ focal main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ focal-updates main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ focal-updates main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ focal-backports main restricted +deb-src http://ports.ubuntu.com/ubuntu-ports/ focal-backports main restricted + +deb http://ports.ubuntu.com/ubuntu-ports/ focal-security main restricted universe multiverse +deb-src http://ports.ubuntu.com/ubuntu-ports/ focal-security main restricted universe multiverse diff --git a/eng/common/cross/arm/sources.list.jammy b/eng/common/cross/arm/sources.list.jammy new file mode 100644 index 00000000000000..6bb0453029cc47 --- /dev/null +++ b/eng/common/cross/arm/sources.list.jammy @@ -0,0 +1,11 @@ +deb http://ports.ubuntu.com/ubuntu-ports/ jammy main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted +deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted + +deb http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse +deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse diff --git a/eng/common/cross/arm/sources.list.jessie b/eng/common/cross/arm/sources.list.jessie new file mode 100644 index 00000000000000..4d142ac9b1089e --- /dev/null +++ b/eng/common/cross/arm/sources.list.jessie @@ -0,0 +1,3 @@ +# Debian (sid) # UNSTABLE +deb http://ftp.debian.org/debian/ sid main contrib non-free +deb-src http://ftp.debian.org/debian/ sid main contrib non-free diff --git a/eng/common/cross/arm/sources.list.xenial b/eng/common/cross/arm/sources.list.xenial new file mode 100644 index 00000000000000..56fbb36a59f62e --- /dev/null +++ b/eng/common/cross/arm/sources.list.xenial @@ -0,0 +1,11 @@ +deb http://ports.ubuntu.com/ubuntu-ports/ xenial main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ xenial-updates main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-updates main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ xenial-backports main restricted +deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-backports main restricted + +deb http://ports.ubuntu.com/ubuntu-ports/ xenial-security main restricted universe multiverse +deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-security main restricted universe multiverse diff --git a/eng/common/cross/arm/sources.list.zesty b/eng/common/cross/arm/sources.list.zesty new file mode 100644 index 00000000000000..ea2c14a7874736 --- /dev/null +++ b/eng/common/cross/arm/sources.list.zesty @@ -0,0 +1,11 @@ +deb http://ports.ubuntu.com/ubuntu-ports/ zesty main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ zesty main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ zesty-updates main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ zesty-updates main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ zesty-backports main restricted +deb-src http://ports.ubuntu.com/ubuntu-ports/ zesty-backports main restricted + +deb http://ports.ubuntu.com/ubuntu-ports/ zesty-security main restricted universe multiverse +deb-src http://ports.ubuntu.com/ubuntu-ports/ zesty-security main restricted universe multiverse diff --git a/eng/common/cross/arm/tizen/tizen.patch b/eng/common/cross/arm/tizen/tizen.patch new file mode 100644 index 00000000000000..fb12ade7250ae9 --- /dev/null +++ b/eng/common/cross/arm/tizen/tizen.patch @@ -0,0 +1,9 @@ +diff -u -r a/usr/lib/libc.so b/usr/lib/libc.so +--- a/usr/lib/libc.so 2016-12-30 23:00:08.284951863 +0900 ++++ b/usr/lib/libc.so 2016-12-30 23:00:32.140951815 +0900 +@@ -2,4 +2,4 @@ + Use the shared library, but some functions are only in + the static library, so try that secondarily. */ + OUTPUT_FORMAT(elf32-littlearm) +-GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a AS_NEEDED ( /lib/ld-linux-armhf.so.3 ) ) ++GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld-linux-armhf.so.3 ) ) diff --git a/eng/common/cross/arm64/sources.list.bionic b/eng/common/cross/arm64/sources.list.bionic new file mode 100644 index 00000000000000..2109557409576d --- /dev/null +++ b/eng/common/cross/arm64/sources.list.bionic @@ -0,0 +1,11 @@ +deb http://ports.ubuntu.com/ubuntu-ports/ bionic main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ bionic-backports main restricted +deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-backports main restricted + +deb http://ports.ubuntu.com/ubuntu-ports/ bionic-security main restricted universe multiverse +deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-security main restricted universe multiverse diff --git a/eng/common/cross/arm64/sources.list.buster b/eng/common/cross/arm64/sources.list.buster new file mode 100644 index 00000000000000..7194ac64a9602f --- /dev/null +++ b/eng/common/cross/arm64/sources.list.buster @@ -0,0 +1,11 @@ +deb http://deb.debian.org/debian buster main +deb-src http://deb.debian.org/debian buster main + +deb http://deb.debian.org/debian-security/ buster/updates main +deb-src http://deb.debian.org/debian-security/ buster/updates main + +deb http://deb.debian.org/debian buster-updates main +deb-src http://deb.debian.org/debian buster-updates main + +deb http://deb.debian.org/debian buster-backports main contrib non-free +deb-src http://deb.debian.org/debian buster-backports main contrib non-free diff --git a/eng/common/cross/arm64/sources.list.focal b/eng/common/cross/arm64/sources.list.focal new file mode 100644 index 00000000000000..4de2600c17478c --- /dev/null +++ b/eng/common/cross/arm64/sources.list.focal @@ -0,0 +1,11 @@ +deb http://ports.ubuntu.com/ubuntu-ports/ focal main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ focal main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ focal-updates main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ focal-updates main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ focal-backports main restricted +deb-src http://ports.ubuntu.com/ubuntu-ports/ focal-backports main restricted + +deb http://ports.ubuntu.com/ubuntu-ports/ focal-security main restricted universe multiverse +deb-src http://ports.ubuntu.com/ubuntu-ports/ focal-security main restricted universe multiverse diff --git a/eng/common/cross/arm64/sources.list.jammy b/eng/common/cross/arm64/sources.list.jammy new file mode 100644 index 00000000000000..6bb0453029cc47 --- /dev/null +++ b/eng/common/cross/arm64/sources.list.jammy @@ -0,0 +1,11 @@ +deb http://ports.ubuntu.com/ubuntu-ports/ jammy main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted +deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted + +deb http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse +deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse diff --git a/eng/common/cross/arm64/sources.list.stretch b/eng/common/cross/arm64/sources.list.stretch new file mode 100644 index 00000000000000..0e1215774368a0 --- /dev/null +++ b/eng/common/cross/arm64/sources.list.stretch @@ -0,0 +1,12 @@ +deb http://deb.debian.org/debian stretch main +deb-src http://deb.debian.org/debian stretch main + +deb http://deb.debian.org/debian-security/ stretch/updates main +deb-src http://deb.debian.org/debian-security/ stretch/updates main + +deb http://deb.debian.org/debian stretch-updates main +deb-src http://deb.debian.org/debian stretch-updates main + +deb http://deb.debian.org/debian stretch-backports main contrib non-free +deb-src http://deb.debian.org/debian stretch-backports main contrib non-free + diff --git a/eng/common/cross/arm64/sources.list.xenial b/eng/common/cross/arm64/sources.list.xenial new file mode 100644 index 00000000000000..56fbb36a59f62e --- /dev/null +++ b/eng/common/cross/arm64/sources.list.xenial @@ -0,0 +1,11 @@ +deb http://ports.ubuntu.com/ubuntu-ports/ xenial main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ xenial-updates main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-updates main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ xenial-backports main restricted +deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-backports main restricted + +deb http://ports.ubuntu.com/ubuntu-ports/ xenial-security main restricted universe multiverse +deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-security main restricted universe multiverse diff --git a/eng/common/cross/arm64/sources.list.zesty b/eng/common/cross/arm64/sources.list.zesty new file mode 100644 index 00000000000000..ea2c14a7874736 --- /dev/null +++ b/eng/common/cross/arm64/sources.list.zesty @@ -0,0 +1,11 @@ +deb http://ports.ubuntu.com/ubuntu-ports/ zesty main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ zesty main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ zesty-updates main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ zesty-updates main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ zesty-backports main restricted +deb-src http://ports.ubuntu.com/ubuntu-ports/ zesty-backports main restricted + +deb http://ports.ubuntu.com/ubuntu-ports/ zesty-security main restricted universe multiverse +deb-src http://ports.ubuntu.com/ubuntu-ports/ zesty-security main restricted universe multiverse diff --git a/eng/common/cross/arm64/tizen/tizen.patch b/eng/common/cross/arm64/tizen/tizen.patch new file mode 100644 index 00000000000000..af7c8be0590684 --- /dev/null +++ b/eng/common/cross/arm64/tizen/tizen.patch @@ -0,0 +1,9 @@ +diff -u -r a/usr/lib/libc.so b/usr/lib/libc.so +--- a/usr/lib64/libc.so 2016-12-30 23:00:08.284951863 +0900 ++++ b/usr/lib64/libc.so 2016-12-30 23:00:32.140951815 +0900 +@@ -2,4 +2,4 @@ + Use the shared library, but some functions are only in + the static library, so try that secondarily. */ + OUTPUT_FORMAT(elf64-littleaarch64) +-GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a AS_NEEDED ( /lib/ld-linux-aarch64.so.1 ) ) ++GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld-linux-aarch64.so.1 ) ) diff --git a/eng/common/cross/armel/armel.jessie.patch b/eng/common/cross/armel/armel.jessie.patch new file mode 100644 index 00000000000000..2d2615619351fc --- /dev/null +++ b/eng/common/cross/armel/armel.jessie.patch @@ -0,0 +1,43 @@ +diff -u -r a/usr/include/urcu/uatomic/generic.h b/usr/include/urcu/uatomic/generic.h +--- a/usr/include/urcu/uatomic/generic.h 2014-10-22 15:00:58.000000000 -0700 ++++ b/usr/include/urcu/uatomic/generic.h 2020-10-30 21:38:28.550000000 -0700 +@@ -69,10 +69,10 @@ + #endif + #ifdef UATOMIC_HAS_ATOMIC_SHORT + case 2: +- return __sync_val_compare_and_swap_2(addr, old, _new); ++ return __sync_val_compare_and_swap_2((uint16_t*) addr, old, _new); + #endif + case 4: +- return __sync_val_compare_and_swap_4(addr, old, _new); ++ return __sync_val_compare_and_swap_4((uint32_t*) addr, old, _new); + #if (CAA_BITS_PER_LONG == 64) + case 8: + return __sync_val_compare_and_swap_8(addr, old, _new); +@@ -109,7 +109,7 @@ + return; + #endif + case 4: +- __sync_and_and_fetch_4(addr, val); ++ __sync_and_and_fetch_4((uint32_t*) addr, val); + return; + #if (CAA_BITS_PER_LONG == 64) + case 8: +@@ -148,7 +148,7 @@ + return; + #endif + case 4: +- __sync_or_and_fetch_4(addr, val); ++ __sync_or_and_fetch_4((uint32_t*) addr, val); + return; + #if (CAA_BITS_PER_LONG == 64) + case 8: +@@ -187,7 +187,7 @@ + return __sync_add_and_fetch_2(addr, val); + #endif + case 4: +- return __sync_add_and_fetch_4(addr, val); ++ return __sync_add_and_fetch_4((uint32_t*) addr, val); + #if (CAA_BITS_PER_LONG == 64) + case 8: + return __sync_add_and_fetch_8(addr, val); diff --git a/eng/common/cross/armel/sources.list.jessie b/eng/common/cross/armel/sources.list.jessie new file mode 100644 index 00000000000000..3d9c3059d8970c --- /dev/null +++ b/eng/common/cross/armel/sources.list.jessie @@ -0,0 +1,3 @@ +# Debian (jessie) # Stable +deb http://ftp.debian.org/debian/ jessie main contrib non-free +deb-src http://ftp.debian.org/debian/ jessie main contrib non-free diff --git a/eng/common/cross/armel/tizen/tizen.patch b/eng/common/cross/armel/tizen/tizen.patch new file mode 100644 index 00000000000000..ca7c7c1ff751fe --- /dev/null +++ b/eng/common/cross/armel/tizen/tizen.patch @@ -0,0 +1,9 @@ +diff -u -r a/usr/lib/libc.so b/usr/lib/libc.so +--- a/usr/lib/libc.so 2016-12-30 23:00:08.284951863 +0900 ++++ b/usr/lib/libc.so 2016-12-30 23:00:32.140951815 +0900 +@@ -2,4 +2,4 @@ + Use the shared library, but some functions are only in + the static library, so try that secondarily. */ + OUTPUT_FORMAT(elf32-littlearm) +-GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a AS_NEEDED ( /lib/ld-linux.so.3 ) ) ++GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld-linux.so.3 ) ) diff --git a/eng/common/cross/armv6/sources.list.buster b/eng/common/cross/armv6/sources.list.buster new file mode 100644 index 00000000000000..f27fc4fb346b6c --- /dev/null +++ b/eng/common/cross/armv6/sources.list.buster @@ -0,0 +1,2 @@ +deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi +deb-src http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi diff --git a/eng/common/cross/build-android-rootfs.sh b/eng/common/cross/build-android-rootfs.sh new file mode 100755 index 00000000000000..f163fb9dae9665 --- /dev/null +++ b/eng/common/cross/build-android-rootfs.sh @@ -0,0 +1,131 @@ +#!/usr/bin/env bash +set -e +__NDK_Version=r21 + +usage() +{ + echo "Creates a toolchain and sysroot used for cross-compiling for Android." + echo. + echo "Usage: $0 [BuildArch] [ApiLevel]" + echo. + echo "BuildArch is the target architecture of Android. Currently only arm64 is supported." + echo "ApiLevel is the target Android API level. API levels usually match to Android releases. See https://source.android.com/source/build-numbers.html" + echo. + echo "By default, the toolchain and sysroot will be generated in cross/android-rootfs/toolchain/[BuildArch]. You can change this behavior" + echo "by setting the TOOLCHAIN_DIR environment variable" + echo. + echo "By default, the NDK will be downloaded into the cross/android-rootfs/android-ndk-$__NDK_Version directory. If you already have an NDK installation," + echo "you can set the NDK_DIR environment variable to have this script use that installation of the NDK." + echo "By default, this script will generate a file, android_platform, in the root of the ROOTFS_DIR directory that contains the RID for the supported and tested Android build: android.28-arm64. This file is to replace '/etc/os-release', which is not available for Android." + exit 1 +} + +__ApiLevel=28 # The minimum platform for arm64 is API level 21 but the minimum version that support glob(3) is 28. See $ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/glob.h +__BuildArch=arm64 +__AndroidArch=aarch64 +__AndroidToolchain=aarch64-linux-android + +for i in "$@" + do + lowerI="$(echo $i | tr "[:upper:]" "[:lower:]")" + case $lowerI in + -?|-h|--help) + usage + exit 1 + ;; + arm64) + __BuildArch=arm64 + __AndroidArch=aarch64 + __AndroidToolchain=aarch64-linux-android + ;; + arm) + __BuildArch=arm + __AndroidArch=arm + __AndroidToolchain=arm-linux-androideabi + ;; + *[0-9]) + __ApiLevel=$i + ;; + *) + __UnprocessedBuildArgs="$__UnprocessedBuildArgs $i" + ;; + esac +done + +# Obtain the location of the bash script to figure out where the root of the repo is. +__ScriptBaseDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +__CrossDir="$__ScriptBaseDir/../../../.tools/android-rootfs" + +if [[ ! -f "$__CrossDir" ]]; then + mkdir -p "$__CrossDir" +fi + +# Resolve absolute path to avoid `../` in build logs +__CrossDir="$( cd "$__CrossDir" && pwd )" + +__NDK_Dir="$__CrossDir/android-ndk-$__NDK_Version" +__lldb_Dir="$__CrossDir/lldb" +__ToolchainDir="$__CrossDir/android-ndk-$__NDK_Version" + +if [[ -n "$TOOLCHAIN_DIR" ]]; then + __ToolchainDir=$TOOLCHAIN_DIR +fi + +if [[ -n "$NDK_DIR" ]]; then + __NDK_Dir=$NDK_DIR +fi + +echo "Target API level: $__ApiLevel" +echo "Target architecture: $__BuildArch" +echo "NDK location: $__NDK_Dir" +echo "Target Toolchain location: $__ToolchainDir" + +# Download the NDK if required +if [ ! -d $__NDK_Dir ]; then + echo Downloading the NDK into $__NDK_Dir + mkdir -p $__NDK_Dir + wget -q --progress=bar:force:noscroll --show-progress https://dl.google.com/android/repository/android-ndk-$__NDK_Version-linux-x86_64.zip -O $__CrossDir/android-ndk-$__NDK_Version-linux-x86_64.zip + unzip -q $__CrossDir/android-ndk-$__NDK_Version-linux-x86_64.zip -d $__CrossDir +fi + +if [ ! -d $__lldb_Dir ]; then + mkdir -p $__lldb_Dir + echo Downloading LLDB into $__lldb_Dir + wget -q --progress=bar:force:noscroll --show-progress https://dl.google.com/android/repository/lldb-2.3.3614996-linux-x86_64.zip -O $__CrossDir/lldb-2.3.3614996-linux-x86_64.zip + unzip -q $__CrossDir/lldb-2.3.3614996-linux-x86_64.zip -d $__lldb_Dir +fi + +echo "Download dependencies..." +__TmpDir=$__CrossDir/tmp/$__BuildArch/ +mkdir -p "$__TmpDir" + +# combined dependencies for coreclr, installer and libraries +__AndroidPackages="libicu" +__AndroidPackages+=" libandroid-glob" +__AndroidPackages+=" liblzma" +__AndroidPackages+=" krb5" +__AndroidPackages+=" openssl" + +for path in $(wget -qO- https://packages.termux.dev/termux-main-21/dists/stable/main/binary-$__AndroidArch/Packages |\ + grep -A15 "Package: \(${__AndroidPackages// /\\|}\)" | grep -v "static\|tool" | grep Filename); do + + if [[ "$path" != "Filename:" ]]; then + echo "Working on: $path" + wget -qO- https://packages.termux.dev/termux-main-21/$path | dpkg -x - "$__TmpDir" + fi +done + +cp -R "$__TmpDir/data/data/com.termux/files/usr/"* "$__ToolchainDir/sysroot/usr/" + +# Generate platform file for build.sh script to assign to __DistroRid +echo "Generating platform file..." +echo "RID=android.${__ApiLevel}-${__BuildArch}" > $__ToolchainDir/sysroot/android_platform + +echo "Now to build coreclr, libraries and installers; run:" +echo ROOTFS_DIR=\$\(realpath $__ToolchainDir/sysroot\) ./build.sh --cross --arch $__BuildArch \ + --subsetCategory coreclr +echo ROOTFS_DIR=\$\(realpath $__ToolchainDir/sysroot\) ./build.sh --cross --arch $__BuildArch \ + --subsetCategory libraries +echo ROOTFS_DIR=\$\(realpath $__ToolchainDir/sysroot\) ./build.sh --cross --arch $__BuildArch \ + --subsetCategory installer diff --git a/eng/common/cross/build-rootfs.sh b/eng/common/cross/build-rootfs.sh new file mode 100755 index 00000000000000..9caf9b021dbdd3 --- /dev/null +++ b/eng/common/cross/build-rootfs.sh @@ -0,0 +1,648 @@ +#!/usr/bin/env bash + +set -e + +usage() +{ + echo "Usage: $0 [BuildArch] [CodeName] [lldbx.y] [llvmx[.y]] [--skipunmount] --rootfsdir ]" + echo "BuildArch can be: arm(default), arm64, armel, armv6, ppc64le, riscv64, s390x, x64, x86" + echo "CodeName - optional, Code name for Linux, can be: xenial(default), zesty, bionic, alpine" + echo " for alpine can be specified with version: alpineX.YY or alpineedge" + echo " for FreeBSD can be: freebsd12, freebsd13" + echo " for illumos can be: illumos" + echo " for Haiku can be: haiku." + echo "lldbx.y - optional, LLDB version, can be: lldb3.9(default), lldb4.0, lldb5.0, lldb6.0 no-lldb. Ignored for alpine and FreeBSD" + echo "llvmx[.y] - optional, LLVM version for LLVM related packages." + echo "--skipunmount - optional, will skip the unmount of rootfs folder." + echo "--skipsigcheck - optional, will skip package signature checks (allowing untrusted packages)." + echo "--use-mirror - optional, use mirror URL to fetch resources, when available." + echo "--jobs N - optional, restrict to N jobs." + exit 1 +} + +__CodeName=xenial +__CrossDir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +__BuildArch=arm +__AlpineArch=armv7 +__FreeBSDArch=arm +__FreeBSDMachineArch=armv7 +__IllumosArch=arm7 +__HaikuArch=arm +__QEMUArch=arm +__UbuntuArch=armhf +__UbuntuRepo="http://ports.ubuntu.com/" +__LLDB_Package="liblldb-3.9-dev" +__SkipUnmount=0 + +# base development support +__UbuntuPackages="build-essential" + +__AlpinePackages="alpine-base" +__AlpinePackages+=" build-base" +__AlpinePackages+=" linux-headers" +__AlpinePackages+=" lldb-dev" +__AlpinePackages+=" python3" +__AlpinePackages+=" libedit" + +# symlinks fixer +__UbuntuPackages+=" symlinks" + +# runtime dependencies +__UbuntuPackages+=" libicu-dev" +__UbuntuPackages+=" liblttng-ust-dev" +__UbuntuPackages+=" libunwind8-dev" +__UbuntuPackages+=" libnuma-dev" + +__AlpinePackages+=" gettext-dev" +__AlpinePackages+=" icu-dev" +__AlpinePackages+=" libunwind-dev" +__AlpinePackages+=" lttng-ust-dev" +__AlpinePackages+=" compiler-rt" +__AlpinePackages+=" numactl-dev" + +# runtime libraries' dependencies +__UbuntuPackages+=" libcurl4-openssl-dev" +__UbuntuPackages+=" libkrb5-dev" +__UbuntuPackages+=" libssl-dev" +__UbuntuPackages+=" zlib1g-dev" + +__AlpinePackages+=" curl-dev" +__AlpinePackages+=" krb5-dev" +__AlpinePackages+=" openssl-dev" +__AlpinePackages+=" zlib-dev" + +__FreeBSDBase="12.4-RELEASE" +__FreeBSDPkg="1.17.0" +__FreeBSDABI="12" +__FreeBSDPackages="libunwind" +__FreeBSDPackages+=" icu" +__FreeBSDPackages+=" libinotify" +__FreeBSDPackages+=" openssl" +__FreeBSDPackages+=" krb5" +__FreeBSDPackages+=" terminfo-db" + +__IllumosPackages="icu" +__IllumosPackages+=" mit-krb5" +__IllumosPackages+=" openssl" +__IllumosPackages+=" zlib" + +__HaikuPackages="gcc_syslibs" +__HaikuPackages+=" gcc_syslibs_devel" +__HaikuPackages+=" gmp" +__HaikuPackages+=" gmp_devel" +__HaikuPackages+=" icu66" +__HaikuPackages+=" icu66_devel" +__HaikuPackages+=" krb5" +__HaikuPackages+=" krb5_devel" +__HaikuPackages+=" libiconv" +__HaikuPackages+=" libiconv_devel" +__HaikuPackages+=" llvm12_libunwind" +__HaikuPackages+=" llvm12_libunwind_devel" +__HaikuPackages+=" mpfr" +__HaikuPackages+=" mpfr_devel" +__HaikuPackages+=" openssl" +__HaikuPackages+=" openssl_devel" +__HaikuPackages+=" zlib" +__HaikuPackages+=" zlib_devel" + +# ML.NET dependencies +__UbuntuPackages+=" libomp5" +__UbuntuPackages+=" libomp-dev" + +# Taken from https://github.com/alpinelinux/alpine-chroot-install/blob/6d08f12a8a70dd9b9dc7d997c88aa7789cc03c42/alpine-chroot-install#L85-L133 +__AlpineKeys=' +4a6a0840:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1yHJxQgsHQREclQu4Ohe\nqxTxd1tHcNnvnQTu/UrTky8wWvgXT+jpveroeWWnzmsYlDI93eLI2ORakxb3gA2O\nQ0Ry4ws8vhaxLQGC74uQR5+/yYrLuTKydFzuPaS1dK19qJPXB8GMdmFOijnXX4SA\njixuHLe1WW7kZVtjL7nufvpXkWBGjsfrvskdNA/5MfxAeBbqPgaq0QMEfxMAn6/R\nL5kNepi/Vr4S39Xvf2DzWkTLEK8pcnjNkt9/aafhWqFVW7m3HCAII6h/qlQNQKSo\nGuH34Q8GsFG30izUENV9avY7hSLq7nggsvknlNBZtFUcmGoQrtx3FmyYsIC8/R+B\nywIDAQAB +5243ef4b:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvNijDxJ8kloskKQpJdx+\nmTMVFFUGDoDCbulnhZMJoKNkSuZOzBoFC94omYPtxnIcBdWBGnrm6ncbKRlR+6oy\nDO0W7c44uHKCFGFqBhDasdI4RCYP+fcIX/lyMh6MLbOxqS22TwSLhCVjTyJeeH7K\naA7vqk+QSsF4TGbYzQDDpg7+6aAcNzg6InNePaywA6hbT0JXbxnDWsB+2/LLSF2G\nmnhJlJrWB1WGjkz23ONIWk85W4S0XB/ewDefd4Ly/zyIciastA7Zqnh7p3Ody6Q0\nsS2MJzo7p3os1smGjUF158s6m/JbVh4DN6YIsxwl2OjDOz9R0OycfJSDaBVIGZzg\ncQIDAQAB +524d27bb:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAr8s1q88XpuJWLCZALdKj\nlN8wg2ePB2T9aIcaxryYE/Jkmtu+ZQ5zKq6BT3y/udt5jAsMrhHTwroOjIsF9DeG\ne8Y3vjz+Hh4L8a7hZDaw8jy3CPag47L7nsZFwQOIo2Cl1SnzUc6/owoyjRU7ab0p\niWG5HK8IfiybRbZxnEbNAfT4R53hyI6z5FhyXGS2Ld8zCoU/R4E1P0CUuXKEN4p0\n64dyeUoOLXEWHjgKiU1mElIQj3k/IF02W89gDj285YgwqA49deLUM7QOd53QLnx+\nxrIrPv3A+eyXMFgexNwCKQU9ZdmWa00MjjHlegSGK8Y2NPnRoXhzqSP9T9i2HiXL\nVQIDAQAB +5261cecb:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwlzMkl7b5PBdfMzGdCT0\ncGloRr5xGgVmsdq5EtJvFkFAiN8Ac9MCFy/vAFmS8/7ZaGOXoCDWbYVLTLOO2qtX\nyHRl+7fJVh2N6qrDDFPmdgCi8NaE+3rITWXGrrQ1spJ0B6HIzTDNEjRKnD4xyg4j\ng01FMcJTU6E+V2JBY45CKN9dWr1JDM/nei/Pf0byBJlMp/mSSfjodykmz4Oe13xB\nCa1WTwgFykKYthoLGYrmo+LKIGpMoeEbY1kuUe04UiDe47l6Oggwnl+8XD1MeRWY\nsWgj8sF4dTcSfCMavK4zHRFFQbGp/YFJ/Ww6U9lA3Vq0wyEI6MCMQnoSMFwrbgZw\nwwIDAQAB +58199dcc:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3v8/ye/V/t5xf4JiXLXa\nhWFRozsnmn3hobON20GdmkrzKzO/eUqPOKTpg2GtvBhK30fu5oY5uN2ORiv2Y2ht\neLiZ9HVz3XP8Fm9frha60B7KNu66FO5P2o3i+E+DWTPqqPcCG6t4Znk2BypILcit\nwiPKTsgbBQR2qo/cO01eLLdt6oOzAaF94NH0656kvRewdo6HG4urbO46tCAizvCR\nCA7KGFMyad8WdKkTjxh8YLDLoOCtoZmXmQAiwfRe9pKXRH/XXGop8SYptLqyVVQ+\ntegOD9wRs2tOlgcLx4F/uMzHN7uoho6okBPiifRX+Pf38Vx+ozXh056tjmdZkCaV\naQIDAQAB +58cbb476:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoSPnuAGKtRIS5fEgYPXD\n8pSGvKAmIv3A08LBViDUe+YwhilSHbYXUEAcSH1KZvOo1WT1x2FNEPBEFEFU1Eyc\n+qGzbA03UFgBNvArurHQ5Z/GngGqE7IarSQFSoqewYRtFSfp+TL9CUNBvM0rT7vz\n2eMu3/wWG+CBmb92lkmyWwC1WSWFKO3x8w+Br2IFWvAZqHRt8oiG5QtYvcZL6jym\nY8T6sgdDlj+Y+wWaLHs9Fc+7vBuyK9C4O1ORdMPW15qVSl4Lc2Wu1QVwRiKnmA+c\nDsH/m7kDNRHM7TjWnuj+nrBOKAHzYquiu5iB3Qmx+0gwnrSVf27Arc3ozUmmJbLj\nzQIDAQAB +58e4f17d:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvBxJN9ErBgdRcPr5g4hV\nqyUSGZEKuvQliq2Z9SRHLh2J43+EdB6A+yzVvLnzcHVpBJ+BZ9RV30EM9guck9sh\nr+bryZcRHyjG2wiIEoduxF2a8KeWeQH7QlpwGhuobo1+gA8L0AGImiA6UP3LOirl\nI0G2+iaKZowME8/tydww4jx5vG132JCOScMjTalRsYZYJcjFbebQQolpqRaGB4iG\nWqhytWQGWuKiB1A22wjmIYf3t96l1Mp+FmM2URPxD1gk/BIBnX7ew+2gWppXOK9j\n1BJpo0/HaX5XoZ/uMqISAAtgHZAqq+g3IUPouxTphgYQRTRYpz2COw3NF43VYQrR\nbQIDAQAB +60ac2099:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwR4uJVtJOnOFGchnMW5Y\nj5/waBdG1u5BTMlH+iQMcV5+VgWhmpZHJCBz3ocD+0IGk2I68S5TDOHec/GSC0lv\n6R9o6F7h429GmgPgVKQsc8mPTPtbjJMuLLs4xKc+viCplXc0Nc0ZoHmCH4da6fCV\ntdpHQjVe6F9zjdquZ4RjV6R6JTiN9v924dGMAkbW/xXmamtz51FzondKC52Gh8Mo\n/oA0/T0KsCMCi7tb4QNQUYrf+Xcha9uus4ww1kWNZyfXJB87a2kORLiWMfs2IBBJ\nTmZ2Fnk0JnHDb8Oknxd9PvJPT0mvyT8DA+KIAPqNvOjUXP4bnjEHJcoCP9S5HkGC\nIQIDAQAB +6165ee59:MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAutQkua2CAig4VFSJ7v54\nALyu/J1WB3oni7qwCZD3veURw7HxpNAj9hR+S5N/pNeZgubQvJWyaPuQDm7PTs1+\ntFGiYNfAsiibX6Rv0wci3M+z2XEVAeR9Vzg6v4qoofDyoTbovn2LztaNEjTkB+oK\ntlvpNhg1zhou0jDVYFniEXvzjckxswHVb8cT0OMTKHALyLPrPOJzVtM9C1ew2Nnc\n3848xLiApMu3NBk0JqfcS3Bo5Y2b1FRVBvdt+2gFoKZix1MnZdAEZ8xQzL/a0YS5\nHd0wj5+EEKHfOd3A75uPa/WQmA+o0cBFfrzm69QDcSJSwGpzWrD1ScH3AK8nWvoj\nv7e9gukK/9yl1b4fQQ00vttwJPSgm9EnfPHLAtgXkRloI27H6/PuLoNvSAMQwuCD\nhQRlyGLPBETKkHeodfLoULjhDi1K2gKJTMhtbnUcAA7nEphkMhPWkBpgFdrH+5z4\nLxy+3ek0cqcI7K68EtrffU8jtUj9LFTUC8dERaIBs7NgQ/LfDbDfGh9g6qVj1hZl\nk9aaIPTm/xsi8v3u+0qaq7KzIBc9s59JOoA8TlpOaYdVgSQhHHLBaahOuAigH+VI\nisbC9vmqsThF2QdDtQt37keuqoda2E6sL7PUvIyVXDRfwX7uMDjlzTxHTymvq2Ck\nhtBqojBnThmjJQFgZXocHG8CAwEAAQ== +61666e3f:MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAlEyxkHggKCXC2Wf5Mzx4\nnZLFZvU2bgcA3exfNPO/g1YunKfQY+Jg4fr6tJUUTZ3XZUrhmLNWvpvSwDS19ZmC\nIXOu0+V94aNgnhMsk9rr59I8qcbsQGIBoHzuAl8NzZCgdbEXkiY90w1skUw8J57z\nqCsMBydAueMXuWqF5nGtYbi5vHwK42PffpiZ7G5Kjwn8nYMW5IZdL6ZnMEVJUWC9\nI4waeKg0yskczYDmZUEAtrn3laX9677ToCpiKrvmZYjlGl0BaGp3cxggP2xaDbUq\nqfFxWNgvUAb3pXD09JM6Mt6HSIJaFc9vQbrKB9KT515y763j5CC2KUsilszKi3mB\nHYe5PoebdjS7D1Oh+tRqfegU2IImzSwW3iwA7PJvefFuc/kNIijfS/gH/cAqAK6z\nbhdOtE/zc7TtqW2Wn5Y03jIZdtm12CxSxwgtCF1NPyEWyIxAQUX9ACb3M0FAZ61n\nfpPrvwTaIIxxZ01L3IzPLpbc44x/DhJIEU+iDt6IMTrHOphD9MCG4631eIdB0H1b\n6zbNX1CXTsafqHRFV9XmYYIeOMggmd90s3xIbEujA6HKNP/gwzO6CDJ+nHFDEqoF\nSkxRdTkEqjTjVKieURW7Swv7zpfu5PrsrrkyGnsRrBJJzXlm2FOOxnbI2iSL1B5F\nrO5kbUxFeZUIDq+7Yv4kLWcCAwEAAQ== +616a9724:MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAnC+bR4bHf/L6QdU4puhQ\ngl1MHePszRC38bzvVFDUJsmCaMCL2suCs2A2yxAgGb9pu9AJYLAmxQC4mM3jNqhg\n/E7yuaBbek3O02zN/ctvflJ250wZCy+z0ZGIp1ak6pu1j14IwHokl9j36zNfGtfv\nADVOcdpWITFFlPqwq1qt/H3UsKVmtiF3BNWWTeUEQwKvlU8ymxgS99yn0+4OPyNT\nL3EUeS+NQJtDS01unau0t7LnjUXn+XIneWny8bIYOQCuVR6s/gpIGuhBaUqwaJOw\n7jkJZYF2Ij7uPb4b5/R3vX2FfxxqEHqssFSg8FFUNTZz3qNZs0CRVyfA972g9WkJ\nhPfn31pQYil4QGRibCMIeU27YAEjXoqfJKEPh4UWMQsQLrEfdGfb8VgwrPbniGfU\nL3jKJR3VAafL9330iawzVQDlIlwGl6u77gEXMl9K0pfazunYhAp+BMP+9ot5ckK+\nosmrqj11qMESsAj083GeFdfV3pXEIwUytaB0AKEht9DbqUfiE/oeZ/LAXgySMtVC\nsbC4ESmgVeY2xSBIJdDyUap7FR49GGrw0W49NUv9gRgQtGGaNVQQO9oGL2PBC41P\niWF9GLoX30HIz1P8PF/cZvicSSPkQf2Z6TV+t0ebdGNS5DjapdnCrq8m9Z0pyKsQ\nuxAL2a7zX8l5i1CZh1ycUGsCAwEAAQ== +616abc23:MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0MfCDrhODRCIxR9Dep1s\neXafh5CE5BrF4WbCgCsevyPIdvTeyIaW4vmO3bbG4VzhogDZju+R3IQYFuhoXP5v\nY+zYJGnwrgz3r5wYAvPnLEs1+dtDKYOgJXQj+wLJBW1mzRDL8FoRXOe5iRmn1EFS\nwZ1DoUvyu7/J5r0itKicZp3QKED6YoilXed+1vnS4Sk0mzN4smuMR9eO1mMCqNp9\n9KTfRDHTbakIHwasECCXCp50uXdoW6ig/xUAFanpm9LtK6jctNDbXDhQmgvAaLXZ\nLvFqoaYJ/CvWkyYCgL6qxvMvVmPoRv7OPcyni4xR/WgWa0MSaEWjgPx3+yj9fiMA\n1S02pFWFDOr5OUF/O4YhFJvUCOtVsUPPfA/Lj6faL0h5QI9mQhy5Zb9TTaS9jB6p\nLw7u0dJlrjFedk8KTJdFCcaGYHP6kNPnOxMylcB/5WcztXZVQD5WpCicGNBxCGMm\nW64SgrV7M07gQfL/32QLsdqPUf0i8hoVD8wfQ3EpbQzv6Fk1Cn90bZqZafg8XWGY\nwddhkXk7egrr23Djv37V2okjzdqoyLBYBxMz63qQzFoAVv5VoY2NDTbXYUYytOvG\nGJ1afYDRVWrExCech1mX5ZVUB1br6WM+psFLJFoBFl6mDmiYt0vMYBddKISsvwLl\nIJQkzDwtXzT2cSjoj3T5QekCAwEAAQ== +616ac3bc:MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAvaaoSLab+IluixwKV5Od\n0gib2YurjPatGIbn5Ov2DLUFYiebj2oJINXJSwUOO+4WcuHFEqiL/1rya+k5hLZt\nhnPL1tn6QD4rESznvGSasRCQNT2vS/oyZbTYJRyAtFkEYLlq0t3S3xBxxHWuvIf0\nqVxVNYpQWyM3N9RIeYBR/euXKJXileSHk/uq1I5wTC0XBIHWcthczGN0m9wBEiWS\n0m3cnPk4q0Ea8mUJ91Rqob19qETz6VbSPYYpZk3qOycjKosuwcuzoMpwU8KRiMFd\n5LHtX0Hx85ghGsWDVtS0c0+aJa4lOMGvJCAOvDfqvODv7gKlCXUpgumGpLdTmaZ8\n1RwqspAe3IqBcdKTqRD4m2mSg23nVx2FAY3cjFvZQtfooT7q1ItRV5RgH6FhQSl7\n+6YIMJ1Bf8AAlLdRLpg+doOUGcEn+pkDiHFgI8ylH1LKyFKw+eXaAml/7DaWZk1d\ndqggwhXOhc/UUZFQuQQ8A8zpA13PcbC05XxN2hyP93tCEtyynMLVPtrRwDnHxFKa\nqKzs3rMDXPSXRn3ZZTdKH3069ApkEjQdpcwUh+EmJ1Ve/5cdtzT6kKWCjKBFZP/s\n91MlRrX2BTRdHaU5QJkUheUtakwxuHrdah2F94lRmsnQlpPr2YseJu6sIE+Dnx4M\nCfhdVbQL2w54R645nlnohu8CAwEAAQ== +616adfeb:MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAq0BFD1D4lIxQcsqEpQzU\npNCYM3aP1V/fxxVdT4DWvSI53JHTwHQamKdMWtEXetWVbP5zSROniYKFXd/xrD9X\n0jiGHey3lEtylXRIPxe5s+wXoCmNLcJVnvTcDtwx/ne2NLHxp76lyc25At+6RgE6\nADjLVuoD7M4IFDkAsd8UQ8zM0Dww9SylIk/wgV3ZkifecvgUQRagrNUdUjR56EBZ\nraQrev4hhzOgwelT0kXCu3snbUuNY/lU53CoTzfBJ5UfEJ5pMw1ij6X0r5S9IVsy\nKLWH1hiO0NzU2c8ViUYCly4Fe9xMTFc6u2dy/dxf6FwERfGzETQxqZvSfrRX+GLj\n/QZAXiPg5178hT/m0Y3z5IGenIC/80Z9NCi+byF1WuJlzKjDcF/TU72zk0+PNM/H\nKuppf3JT4DyjiVzNC5YoWJT2QRMS9KLP5iKCSThwVceEEg5HfhQBRT9M6KIcFLSs\nmFjx9kNEEmc1E8hl5IR3+3Ry8G5/bTIIruz14jgeY9u5jhL8Vyyvo41jgt9sLHR1\n/J1TxKfkgksYev7PoX6/ZzJ1ksWKZY5NFoDXTNYUgzFUTOoEaOg3BAQKadb3Qbbq\nXIrxmPBdgrn9QI7NCgfnAY3Tb4EEjs3ON/BNyEhUENcXOH6I1NbcuBQ7g9P73kE4\nVORdoc8MdJ5eoKBpO8Ww8HECAwEAAQ== +616ae350:MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAyduVzi1mWm+lYo2Tqt/0\nXkCIWrDNP1QBMVPrE0/ZlU2bCGSoo2Z9FHQKz/mTyMRlhNqTfhJ5qU3U9XlyGOPJ\npiM+b91g26pnpXJ2Q2kOypSgOMOPA4cQ42PkHBEqhuzssfj9t7x47ppS94bboh46\nxLSDRff/NAbtwTpvhStV3URYkxFG++cKGGa5MPXBrxIp+iZf9GnuxVdST5PGiVGP\nODL/b69sPJQNbJHVquqUTOh5Ry8uuD2WZuXfKf7/C0jC/ie9m2+0CttNu9tMciGM\nEyKG1/Xhk5iIWO43m4SrrT2WkFlcZ1z2JSf9Pjm4C2+HovYpihwwdM/OdP8Xmsnr\nDzVB4YvQiW+IHBjStHVuyiZWc+JsgEPJzisNY0Wyc/kNyNtqVKpX6dRhMLanLmy+\nf53cCSI05KPQAcGj6tdL+D60uKDkt+FsDa0BTAobZ31OsFVid0vCXtsbplNhW1IF\nHwsGXBTVcfXg44RLyL8Lk/2dQxDHNHzAUslJXzPxaHBLmt++2COa2EI1iWlvtznk\nOk9WP8SOAIj+xdqoiHcC4j72BOVVgiITIJNHrbppZCq6qPR+fgXmXa+sDcGh30m6\n9Wpbr28kLMSHiENCWTdsFij+NQTd5S47H7XTROHnalYDuF1RpS+DpQidT5tUimaT\nJZDr++FjKrnnijbyNF8b98UCAwEAAQ== +616db30d:MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAnpUpyWDWjlUk3smlWeA0\nlIMW+oJ38t92CRLHH3IqRhyECBRW0d0aRGtq7TY8PmxjjvBZrxTNDpJT6KUk4LRm\na6A6IuAI7QnNK8SJqM0DLzlpygd7GJf8ZL9SoHSH+gFsYF67Cpooz/YDqWrlN7Vw\ntO00s0B+eXy+PCXYU7VSfuWFGK8TGEv6HfGMALLjhqMManyvfp8hz3ubN1rK3c8C\nUS/ilRh1qckdbtPvoDPhSbTDmfU1g/EfRSIEXBrIMLg9ka/XB9PvWRrekrppnQzP\nhP9YE3x/wbFc5QqQWiRCYyQl/rgIMOXvIxhkfe8H5n1Et4VAorkpEAXdsfN8KSVv\nLSMazVlLp9GYq5SUpqYX3KnxdWBgN7BJoZ4sltsTpHQ/34SXWfu3UmyUveWj7wp0\nx9hwsPirVI00EEea9AbP7NM2rAyu6ukcm4m6ATd2DZJIViq2es6m60AE6SMCmrQF\nwmk4H/kdQgeAELVfGOm2VyJ3z69fQuywz7xu27S6zTKi05Qlnohxol4wVb6OB7qG\nLPRtK9ObgzRo/OPumyXqlzAi/Yvyd1ZQk8labZps3e16bQp8+pVPiumWioMFJDWV\nGZjCmyMSU8V6MB6njbgLHoyg2LCukCAeSjbPGGGYhnKLm1AKSoJh3IpZuqcKCk5C\n8CM1S15HxV78s9dFntEqIokCAwEAAQ== +' +__Keyring= +__SkipSigCheck=0 +__UseMirror=0 + +__UnprocessedBuildArgs= +while :; do + if [[ "$#" -le 0 ]]; then + break + fi + + lowerI="$(echo "$1" | tr "[:upper:]" "[:lower:]")" + case $lowerI in + -\?|-h|--help) + usage + exit 1 + ;; + arm) + __BuildArch=arm + __UbuntuArch=armhf + __AlpineArch=armv7 + __QEMUArch=arm + ;; + arm64) + __BuildArch=arm64 + __UbuntuArch=arm64 + __AlpineArch=aarch64 + __QEMUArch=aarch64 + __FreeBSDArch=arm64 + __FreeBSDMachineArch=aarch64 + ;; + armel) + __BuildArch=armel + __UbuntuArch=armel + __UbuntuRepo="http://ftp.debian.org/debian/" + __CodeName=jessie + ;; + armv6) + __BuildArch=armv6 + __UbuntuArch=armhf + __QEMUArch=arm + __UbuntuRepo="http://raspbian.raspberrypi.org/raspbian/" + __CodeName=buster + __LLDB_Package="liblldb-6.0-dev" + + if [[ -e "/usr/share/keyrings/raspbian-archive-keyring.gpg" ]]; then + __Keyring="--keyring /usr/share/keyrings/raspbian-archive-keyring.gpg" + fi + ;; + riscv64) + __BuildArch=riscv64 + __AlpineArch=riscv64 + __AlpinePackages="${__AlpinePackages// lldb-dev/}" + __QEMUArch=riscv64 + __UbuntuArch=riscv64 + __UbuntuRepo="http://deb.debian.org/debian-ports" + __UbuntuPackages="${__UbuntuPackages// libunwind8-dev/}" + unset __LLDB_Package + + if [[ -e "/usr/share/keyrings/debian-ports-archive-keyring.gpg" ]]; then + __Keyring="--keyring /usr/share/keyrings/debian-ports-archive-keyring.gpg --include=debian-ports-archive-keyring" + fi + ;; + ppc64le) + __BuildArch=ppc64le + __AlpineArch=ppc64le + __QEMUArch=ppc64le + __UbuntuArch=ppc64el + __UbuntuRepo="http://ports.ubuntu.com/ubuntu-ports/" + __UbuntuPackages="${__UbuntuPackages// libunwind8-dev/}" + __UbuntuPackages="${__UbuntuPackages// libomp-dev/}" + __UbuntuPackages="${__UbuntuPackages// libomp5/}" + unset __LLDB_Package + ;; + s390x) + __BuildArch=s390x + __AlpineArch=s390x + __QEMUArch=s390x + __UbuntuArch=s390x + __UbuntuRepo="http://ports.ubuntu.com/ubuntu-ports/" + __UbuntuPackages="${__UbuntuPackages// libunwind8-dev/}" + __UbuntuPackages="${__UbuntuPackages// libomp-dev/}" + __UbuntuPackages="${__UbuntuPackages// libomp5/}" + unset __LLDB_Package + ;; + x64) + __BuildArch=x64 + __AlpineArch=x86_64 + __UbuntuArch=amd64 + __FreeBSDArch=amd64 + __FreeBSDMachineArch=amd64 + __illumosArch=x86_64 + __HaikuArch=x86_64 + __UbuntuRepo="http://archive.ubuntu.com/ubuntu/" + ;; + x86) + __BuildArch=x86 + __UbuntuArch=i386 + __AlpineArch=x86 + __UbuntuRepo="http://archive.ubuntu.com/ubuntu/" + ;; + lldb*) + version="${lowerI/lldb/}" + parts=(${version//./ }) + + # for versions > 6.0, lldb has dropped the minor version + if [[ "${parts[0]}" -gt 6 ]]; then + version="${parts[0]}" + fi + + __LLDB_Package="liblldb-${version}-dev" + ;; + no-lldb) + unset __LLDB_Package + ;; + llvm*) + version="${lowerI/llvm/}" + parts=(${version//./ }) + __LLVM_MajorVersion="${parts[0]}" + __LLVM_MinorVersion="${parts[1]}" + + # for versions > 6.0, llvm has dropped the minor version + if [[ -z "$__LLVM_MinorVersion" && "$__LLVM_MajorVersion" -le 6 ]]; then + __LLVM_MinorVersion=0; + fi + ;; + xenial) # Ubuntu 16.04 + if [[ "$__CodeName" != "jessie" ]]; then + __CodeName=xenial + fi + ;; + zesty) # Ubuntu 17.04 + if [[ "$__CodeName" != "jessie" ]]; then + __CodeName=zesty + fi + ;; + bionic) # Ubuntu 18.04 + if [[ "$__CodeName" != "jessie" ]]; then + __CodeName=bionic + fi + ;; + focal) # Ubuntu 20.04 + if [[ "$__CodeName" != "jessie" ]]; then + __CodeName=focal + fi + ;; + jammy) # Ubuntu 22.04 + if [[ "$__CodeName" != "jessie" ]]; then + __CodeName=jammy + fi + ;; + jessie) # Debian 8 + __CodeName=jessie + + if [[ -z "$__UbuntuRepo" ]]; then + __UbuntuRepo="http://ftp.debian.org/debian/" + fi + ;; + stretch) # Debian 9 + __CodeName=stretch + __LLDB_Package="liblldb-6.0-dev" + + if [[ -z "$__UbuntuRepo" ]]; then + __UbuntuRepo="http://ftp.debian.org/debian/" + fi + ;; + buster) # Debian 10 + __CodeName=buster + __LLDB_Package="liblldb-6.0-dev" + + if [[ -z "$__UbuntuRepo" ]]; then + __UbuntuRepo="http://ftp.debian.org/debian/" + fi + ;; + bullseye) # Debian 11 + __CodeName=bullseye + + if [[ -z "$__UbuntuRepo" ]]; then + __UbuntuRepo="http://ftp.debian.org/debian/" + fi + ;; + sid) # Debian sid + __CodeName=sid + + if [[ -z "$__UbuntuRepo" ]]; then + __UbuntuRepo="http://ftp.debian.org/debian/" + fi + ;; + tizen) + __CodeName= + __UbuntuRepo= + __Tizen=tizen + ;; + alpine*) + __CodeName=alpine + __UbuntuRepo= + version="${lowerI/alpine/}" + + if [[ "$version" == "edge" ]]; then + __AlpineVersion=edge + else + parts=(${version//./ }) + __AlpineMajorVersion="${parts[0]}" + __AlpineMinoVersion="${parts[1]}" + __AlpineVersion="$__AlpineMajorVersion.$__AlpineMinoVersion" + fi + ;; + freebsd12) + __CodeName=freebsd + __SkipUnmount=1 + ;; + freebsd13) + __CodeName=freebsd + __FreeBSDBase="13.2-RELEASE" + __FreeBSDABI="13" + __SkipUnmount=1 + ;; + illumos) + __CodeName=illumos + __SkipUnmount=1 + ;; + haiku) + __CodeName=haiku + __SkipUnmount=1 + ;; + --skipunmount) + __SkipUnmount=1 + ;; + --skipsigcheck) + __SkipSigCheck=1 + ;; + --rootfsdir|-rootfsdir) + shift + __RootfsDir="$1" + ;; + --use-mirror) + __UseMirror=1 + ;; + --use-jobs) + shift + MAXJOBS=$1 + ;; + *) + __UnprocessedBuildArgs="$__UnprocessedBuildArgs $1" + ;; + esac + + shift +done + +case "$__AlpineVersion" in + 3.14) __AlpinePackages+=" llvm11-libs" ;; + 3.15) __AlpinePackages+=" llvm12-libs" ;; + 3.16) __AlpinePackages+=" llvm13-libs" ;; + 3.17) __AlpinePackages+=" llvm15-libs" ;; + edge) __AlpineLlvmLibsLookup=1 ;; + *) + if [[ "$__AlpineArch" =~ s390x|ppc64le ]]; then + __AlpineVersion=3.15 # minimum version that supports lldb-dev + __AlpinePackages+=" llvm12-libs" + elif [[ "$__AlpineArch" == "x86" ]]; then + __AlpineVersion=3.17 # minimum version that supports lldb-dev + __AlpinePackages+=" llvm15-libs" + elif [[ "$__AlpineArch" == "riscv64" ]]; then + __AlpineLlvmLibsLookup=1 + __AlpineVersion=edge # minimum version with APKINDEX.tar.gz (packages archive) + else + __AlpineVersion=3.13 # 3.13 to maximize compatibility + __AlpinePackages+=" llvm10-libs" + + if [[ "$__AlpineArch" == "armv7" ]]; then + __AlpinePackages="${__AlpinePackages//numactl-dev/}" + fi + fi +esac + +if [[ "$__AlpineVersion" =~ 3\.1[345] ]]; then + # compiler-rt--static was merged in compiler-rt package in alpine 3.16 + # for older versions, we need compiler-rt--static, so replace the name + __AlpinePackages="${__AlpinePackages/compiler-rt/compiler-rt-static}" +fi + +if [[ "$__BuildArch" == "armel" ]]; then + __LLDB_Package="lldb-3.5-dev" +fi + +if [[ "$__CodeName" == "xenial" && "$__UbuntuArch" == "armhf" ]]; then + # libnuma-dev is not available on armhf for xenial + __UbuntuPackages="${__UbuntuPackages//libnuma-dev/}" +fi + +__UbuntuPackages+=" ${__LLDB_Package:-}" + +if [[ -n "$__LLVM_MajorVersion" ]]; then + __UbuntuPackages+=" libclang-common-${__LLVM_MajorVersion}${__LLVM_MinorVersion:+.$__LLVM_MinorVersion}-dev" +fi + +if [[ -z "$__RootfsDir" && -n "$ROOTFS_DIR" ]]; then + __RootfsDir="$ROOTFS_DIR" +fi + +if [[ -z "$__RootfsDir" ]]; then + __RootfsDir="$__CrossDir/../../../.tools/rootfs/$__BuildArch" +fi + +if [[ -d "$__RootfsDir" ]]; then + if [[ "$__SkipUnmount" == "0" ]]; then + umount "$__RootfsDir"/* || true + fi + rm -rf "$__RootfsDir" +fi + +mkdir -p "$__RootfsDir" +__RootfsDir="$( cd "$__RootfsDir" && pwd )" + +if [[ "$__CodeName" == "alpine" ]]; then + __ApkToolsVersion=2.12.11 + __ApkToolsSHA512SUM=53e57b49230da07ef44ee0765b9592580308c407a8d4da7125550957bb72cb59638e04f8892a18b584451c8d841d1c7cb0f0ab680cc323a3015776affaa3be33 + __ApkToolsDir="$(mktemp -d)" + __ApkKeysDir="$(mktemp -d)" + + wget "https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic//v$__ApkToolsVersion/x86_64/apk.static" -P "$__ApkToolsDir" + echo "$__ApkToolsSHA512SUM $__ApkToolsDir/apk.static" | sha512sum -c + chmod +x "$__ApkToolsDir/apk.static" + + if [[ -f "/usr/bin/qemu-$__QEMUArch-static" ]]; then + mkdir -p "$__RootfsDir"/usr/bin + cp -v "/usr/bin/qemu-$__QEMUArch-static" "$__RootfsDir/usr/bin" + fi + + if [[ "$__AlpineVersion" == "edge" ]]; then + version=edge + else + version="v$__AlpineVersion" + fi + + for line in $__AlpineKeys; do + id="${line%%:*}" + content="${line#*:}" + + echo -e "-----BEGIN PUBLIC KEY-----\n$content\n-----END PUBLIC KEY-----" > "$__ApkKeysDir/alpine-devel@lists.alpinelinux.org-$id.rsa.pub" + done + + if [[ "$__SkipSigCheck" == "1" ]]; then + __ApkSignatureArg="--allow-untrusted" + else + __ApkSignatureArg="--keys-dir $__ApkKeysDir" + fi + + # initialize DB + "$__ApkToolsDir/apk.static" \ + -X "http://dl-cdn.alpinelinux.org/alpine/$version/main" \ + -X "http://dl-cdn.alpinelinux.org/alpine/$version/community" \ + -U $__ApkSignatureArg --root "$__RootfsDir" --arch "$__AlpineArch" --initdb add + + if [[ "$__AlpineLlvmLibsLookup" == 1 ]]; then + __AlpinePackages+=" $("$__ApkToolsDir/apk.static" \ + -X "http://dl-cdn.alpinelinux.org/alpine/$version/main" \ + -X "http://dl-cdn.alpinelinux.org/alpine/$version/community" \ + -U $__ApkSignatureArg --root "$__RootfsDir" --arch "$__AlpineArch" \ + search 'llvm*-libs' | sort | tail -1 | sed 's/-[^-]*//2g')" + fi + + # install all packages in one go + "$__ApkToolsDir/apk.static" \ + -X "http://dl-cdn.alpinelinux.org/alpine/$version/main" \ + -X "http://dl-cdn.alpinelinux.org/alpine/$version/community" \ + -U $__ApkSignatureArg --root "$__RootfsDir" --arch "$__AlpineArch" \ + add $__AlpinePackages + + rm -r "$__ApkToolsDir" +elif [[ "$__CodeName" == "freebsd" ]]; then + mkdir -p "$__RootfsDir"/usr/local/etc + JOBS=${MAXJOBS:="$(getconf _NPROCESSORS_ONLN)"} + wget -O - "https://download.freebsd.org/ftp/releases/${__FreeBSDArch}/${__FreeBSDMachineArch}/${__FreeBSDBase}/base.txz" | tar -C "$__RootfsDir" -Jxf - ./lib ./usr/lib ./usr/libdata ./usr/include ./usr/share/keys ./etc ./bin/freebsd-version + echo "ABI = \"FreeBSD:${__FreeBSDABI}:${__FreeBSDMachineArch}\"; FINGERPRINTS = \"${__RootfsDir}/usr/share/keys\"; REPOS_DIR = [\"${__RootfsDir}/etc/pkg\"]; REPO_AUTOUPDATE = NO; RUN_SCRIPTS = NO;" > "${__RootfsDir}"/usr/local/etc/pkg.conf + echo "FreeBSD: { url: \"pkg+http://pkg.FreeBSD.org/\${ABI}/quarterly\", mirror_type: \"srv\", signature_type: \"fingerprints\", fingerprints: \"${__RootfsDir}/usr/share/keys/pkg\", enabled: yes }" > "${__RootfsDir}"/etc/pkg/FreeBSD.conf + mkdir -p "$__RootfsDir"/tmp + # get and build package manager + wget -O - "https://github.com/freebsd/pkg/archive/${__FreeBSDPkg}.tar.gz" | tar -C "$__RootfsDir"/tmp -zxf - + cd "$__RootfsDir/tmp/pkg-${__FreeBSDPkg}" + # needed for install to succeed + mkdir -p "$__RootfsDir"/host/etc + ./autogen.sh && ./configure --prefix="$__RootfsDir"/host && make -j "$JOBS" && make install + rm -rf "$__RootfsDir/tmp/pkg-${__FreeBSDPkg}" + # install packages we need. + INSTALL_AS_USER=$(whoami) "$__RootfsDir"/host/sbin/pkg -r "$__RootfsDir" -C "$__RootfsDir"/usr/local/etc/pkg.conf update + INSTALL_AS_USER=$(whoami) "$__RootfsDir"/host/sbin/pkg -r "$__RootfsDir" -C "$__RootfsDir"/usr/local/etc/pkg.conf install --yes $__FreeBSDPackages +elif [[ "$__CodeName" == "illumos" ]]; then + mkdir "$__RootfsDir/tmp" + pushd "$__RootfsDir/tmp" + JOBS=${MAXJOBS:="$(getconf _NPROCESSORS_ONLN)"} + echo "Downloading sysroot." + wget -O - https://github.com/illumos/sysroot/releases/download/20181213-de6af22ae73b-v1/illumos-sysroot-i386-20181213-de6af22ae73b-v1.tar.gz | tar -C "$__RootfsDir" -xzf - + echo "Building binutils. Please wait.." + wget -O - https://ftp.gnu.org/gnu/binutils/binutils-2.33.1.tar.bz2 | tar -xjf - + mkdir build-binutils && cd build-binutils + ../binutils-2.33.1/configure --prefix="$__RootfsDir" --target="${__illumosArch}-sun-solaris2.10" --program-prefix="${__illumosArch}-illumos-" --with-sysroot="$__RootfsDir" + make -j "$JOBS" && make install && cd .. + echo "Building gcc. Please wait.." + wget -O - https://ftp.gnu.org/gnu/gcc/gcc-8.4.0/gcc-8.4.0.tar.xz | tar -xJf - + CFLAGS="-fPIC" + CXXFLAGS="-fPIC" + CXXFLAGS_FOR_TARGET="-fPIC" + CFLAGS_FOR_TARGET="-fPIC" + export CFLAGS CXXFLAGS CXXFLAGS_FOR_TARGET CFLAGS_FOR_TARGET + mkdir build-gcc && cd build-gcc + ../gcc-8.4.0/configure --prefix="$__RootfsDir" --target="${__illumosArch}-sun-solaris2.10" --program-prefix="${__illumosArch}-illumos-" --with-sysroot="$__RootfsDir" --with-gnu-as \ + --with-gnu-ld --disable-nls --disable-libgomp --disable-libquadmath --disable-libssp --disable-libvtv --disable-libcilkrts --disable-libada --disable-libsanitizer \ + --disable-libquadmath-support --disable-shared --enable-tls + make -j "$JOBS" && make install && cd .. + BaseUrl=https://pkgsrc.smartos.org + if [[ "$__UseMirror" == 1 ]]; then + BaseUrl=https://pkgsrc.smartos.skylime.net + fi + BaseUrl="$BaseUrl/packages/SmartOS/trunk/${__illumosArch}/All" + echo "Downloading manifest" + wget "$BaseUrl" + echo "Downloading dependencies." + read -ra array <<<"$__IllumosPackages" + for package in "${array[@]}"; do + echo "Installing '$package'" + # find last occurrence of package in listing and extract its name + package="$(sed -En '/.*href="('"$package"'-[0-9].*).tgz".*/h;$!d;g;s//\1/p' All)" + echo "Resolved name '$package'" + wget "$BaseUrl"/"$package".tgz + ar -x "$package".tgz + tar --skip-old-files -xzf "$package".tmp.tg* -C "$__RootfsDir" 2>/dev/null + done + echo "Cleaning up temporary files." + popd + rm -rf "$__RootfsDir"/{tmp,+*} + mkdir -p "$__RootfsDir"/usr/include/net + mkdir -p "$__RootfsDir"/usr/include/netpacket + wget -P "$__RootfsDir"/usr/include/net https://raw.githubusercontent.com/illumos/illumos-gate/master/usr/src/uts/common/io/bpf/net/bpf.h + wget -P "$__RootfsDir"/usr/include/net https://raw.githubusercontent.com/illumos/illumos-gate/master/usr/src/uts/common/io/bpf/net/dlt.h + wget -P "$__RootfsDir"/usr/include/netpacket https://raw.githubusercontent.com/illumos/illumos-gate/master/usr/src/uts/common/inet/sockmods/netpacket/packet.h + wget -P "$__RootfsDir"/usr/include/sys https://raw.githubusercontent.com/illumos/illumos-gate/master/usr/src/uts/common/sys/sdt.h +elif [[ "$__CodeName" == "haiku" ]]; then + JOBS=${MAXJOBS:="$(getconf _NPROCESSORS_ONLN)"} + + echo "Building Haiku sysroot for $__HaikuArch" + mkdir -p "$__RootfsDir/tmp" + pushd "$__RootfsDir/tmp" + + mkdir "$__RootfsDir/tmp/download" + + echo "Downloading Haiku package tool" + git clone https://github.com/haiku/haiku-toolchains-ubuntu --depth 1 $__RootfsDir/tmp/script + wget -O "$__RootfsDir/tmp/download/hosttools.zip" $($__RootfsDir/tmp/script/fetch.sh --hosttools) + unzip -o "$__RootfsDir/tmp/download/hosttools.zip" -d "$__RootfsDir/tmp/bin" + + DepotBaseUrl="https://depot.haiku-os.org/__api/v2/pkg/get-pkg" + HpkgBaseUrl="https://eu.hpkg.haiku-os.org/haiku/master/$__HaikuArch/current" + + # Download Haiku packages + echo "Downloading Haiku packages" + read -ra array <<<"$__HaikuPackages" + for package in "${array[@]}"; do + echo "Downloading $package..." + # API documented here: https://github.com/haiku/haikudepotserver/blob/master/haikudepotserver-api2/src/main/resources/api2/pkg.yaml#L60 + # The schema here: https://github.com/haiku/haikudepotserver/blob/master/haikudepotserver-api2/src/main/resources/api2/pkg.yaml#L598 + hpkgDownloadUrl="$(wget -qO- --post-data='{"name":"'"$package"'","repositorySourceCode":"haikuports_'$__HaikuArch'","versionType":"LATEST","naturalLanguageCode":"en"}' \ + --header='Content-Type:application/json' "$DepotBaseUrl" | jq -r '.result.versions[].hpkgDownloadURL')" + wget -P "$__RootfsDir/tmp/download" "$hpkgDownloadUrl" + done + for package in haiku haiku_devel; do + echo "Downloading $package..." + hpkgVersion="$(wget -qO- $HpkgBaseUrl | sed -n 's/^.*version: "\([^"]*\)".*$/\1/p')" + wget -P "$__RootfsDir/tmp/download" "$HpkgBaseUrl/packages/$package-$hpkgVersion-1-$__HaikuArch.hpkg" + done + + # Set up the sysroot + echo "Setting up sysroot and extracting required packages" + mkdir -p "$__RootfsDir/boot/system" + for file in "$__RootfsDir/tmp/download/"*.hpkg; do + echo "Extracting $file..." + LD_LIBRARY_PATH="$__RootfsDir/tmp/bin" "$__RootfsDir/tmp/bin/package" extract -C "$__RootfsDir/boot/system" "$file" + done + + # Download buildtools + echo "Downloading Haiku buildtools" + wget -O "$__RootfsDir/tmp/download/buildtools.zip" $($__RootfsDir/tmp/script/fetch.sh --buildtools --arch=$__HaikuArch) + unzip -o "$__RootfsDir/tmp/download/buildtools.zip" -d "$__RootfsDir" + + # Cleaning up temporary files + echo "Cleaning up temporary files" + popd + rm -rf "$__RootfsDir/tmp" +elif [[ -n "$__CodeName" ]]; then + + if [[ "$__SkipSigCheck" == "0" ]]; then + __Keyring="$__Keyring --force-check-gpg" + fi + + debootstrap "--variant=minbase" $__Keyring --arch "$__UbuntuArch" "$__CodeName" "$__RootfsDir" "$__UbuntuRepo" + cp "$__CrossDir/$__BuildArch/sources.list.$__CodeName" "$__RootfsDir/etc/apt/sources.list" + chroot "$__RootfsDir" apt-get update + chroot "$__RootfsDir" apt-get -f -y install + chroot "$__RootfsDir" apt-get -y install $__UbuntuPackages + chroot "$__RootfsDir" symlinks -cr /usr + chroot "$__RootfsDir" apt-get clean + + if [[ "$__SkipUnmount" == "0" ]]; then + umount "$__RootfsDir"/* || true + fi + + if [[ "$__BuildArch" == "armel" && "$__CodeName" == "jessie" ]]; then + pushd "$__RootfsDir" + patch -p1 < "$__CrossDir/$__BuildArch/armel.jessie.patch" + popd + fi +elif [[ "$__Tizen" == "tizen" ]]; then + ROOTFS_DIR="$__RootfsDir" "$__CrossDir/tizen-build-rootfs.sh" "$__BuildArch" +else + echo "Unsupported target platform." + usage; + exit 1 +fi diff --git a/eng/common/cross/ppc64le/sources.list.bionic b/eng/common/cross/ppc64le/sources.list.bionic new file mode 100644 index 00000000000000..2109557409576d --- /dev/null +++ b/eng/common/cross/ppc64le/sources.list.bionic @@ -0,0 +1,11 @@ +deb http://ports.ubuntu.com/ubuntu-ports/ bionic main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ bionic-backports main restricted +deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-backports main restricted + +deb http://ports.ubuntu.com/ubuntu-ports/ bionic-security main restricted universe multiverse +deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-security main restricted universe multiverse diff --git a/eng/common/cross/riscv64/sources.list.sid b/eng/common/cross/riscv64/sources.list.sid new file mode 100644 index 00000000000000..65f730d224caa6 --- /dev/null +++ b/eng/common/cross/riscv64/sources.list.sid @@ -0,0 +1 @@ +deb http://deb.debian.org/debian-ports sid main diff --git a/eng/common/cross/s390x/sources.list.bionic b/eng/common/cross/s390x/sources.list.bionic new file mode 100644 index 00000000000000..2109557409576d --- /dev/null +++ b/eng/common/cross/s390x/sources.list.bionic @@ -0,0 +1,11 @@ +deb http://ports.ubuntu.com/ubuntu-ports/ bionic main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main restricted universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main restricted universe + +deb http://ports.ubuntu.com/ubuntu-ports/ bionic-backports main restricted +deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-backports main restricted + +deb http://ports.ubuntu.com/ubuntu-ports/ bionic-security main restricted universe multiverse +deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-security main restricted universe multiverse diff --git a/eng/common/cross/tizen-build-rootfs.sh b/eng/common/cross/tizen-build-rootfs.sh new file mode 100644 index 00000000000000..ac84173d44fc30 --- /dev/null +++ b/eng/common/cross/tizen-build-rootfs.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash +set -e + +ARCH=$1 +LINK_ARCH=$ARCH + +case "$ARCH" in + arm) + TIZEN_ARCH="armv7hl" + ;; + armel) + TIZEN_ARCH="armv7l" + LINK_ARCH="arm" + ;; + arm64) + TIZEN_ARCH="aarch64" + ;; + x86) + TIZEN_ARCH="i686" + ;; + x64) + TIZEN_ARCH="x86_64" + LINK_ARCH="x86" + ;; + *) + echo "Unsupported architecture for tizen: $ARCH" + exit 1 +esac + +__CrossDir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +__TIZEN_CROSSDIR="$__CrossDir/${ARCH}/tizen" + +if [[ -z "$ROOTFS_DIR" ]]; then + echo "ROOTFS_DIR is not defined." + exit 1; +fi + +TIZEN_TMP_DIR=$ROOTFS_DIR/tizen_tmp +mkdir -p $TIZEN_TMP_DIR + +# Download files +echo ">>Start downloading files" +VERBOSE=1 $__CrossDir/tizen-fetch.sh $TIZEN_TMP_DIR $TIZEN_ARCH +echo "<>Start constructing Tizen rootfs" +TIZEN_RPM_FILES=`ls $TIZEN_TMP_DIR/*.rpm` +cd $ROOTFS_DIR +for f in $TIZEN_RPM_FILES; do + rpm2cpio $f | cpio -idm --quiet +done +echo "<>Start configuring Tizen rootfs" +ln -sfn asm-${LINK_ARCH} ./usr/include/asm +patch -p1 < $__TIZEN_CROSSDIR/tizen.patch +echo "</dev/null; then + VERBOSE=0 +fi + +Log() +{ + if [ $VERBOSE -ge $1 ]; then + echo ${@:2} + fi +} + +Inform() +{ + Log 1 -e "\x1B[0;34m$@\x1B[m" +} + +Debug() +{ + Log 2 -e "\x1B[0;32m$@\x1B[m" +} + +Error() +{ + >&2 Log 0 -e "\x1B[0;31m$@\x1B[m" +} + +Fetch() +{ + URL=$1 + FILE=$2 + PROGRESS=$3 + if [ $VERBOSE -ge 1 ] && [ $PROGRESS ]; then + CURL_OPT="--progress-bar" + else + CURL_OPT="--silent" + fi + curl $CURL_OPT $URL > $FILE +} + +hash curl 2> /dev/null || { Error "Require 'curl' Aborting."; exit 1; } +hash xmllint 2> /dev/null || { Error "Require 'xmllint' Aborting."; exit 1; } +hash sha256sum 2> /dev/null || { Error "Require 'sha256sum' Aborting."; exit 1; } + +TMPDIR=$1 +if [ ! -d $TMPDIR ]; then + TMPDIR=./tizen_tmp + Debug "Create temporary directory : $TMPDIR" + mkdir -p $TMPDIR +fi + +TIZEN_ARCH=$2 + +TIZEN_URL=http://download.tizen.org/snapshots/TIZEN/Tizen +BUILD_XML=build.xml +REPOMD_XML=repomd.xml +PRIMARY_XML=primary.xml +TARGET_URL="http://__not_initialized" + +Xpath_get() +{ + XPATH_RESULT='' + XPATH=$1 + XML_FILE=$2 + RESULT=$(xmllint --xpath $XPATH $XML_FILE) + if [[ -z ${RESULT// } ]]; then + Error "Can not find target from $XML_FILE" + Debug "Xpath = $XPATH" + exit 1 + fi + XPATH_RESULT=$RESULT +} + +fetch_tizen_pkgs_init() +{ + TARGET=$1 + PROFILE=$2 + Debug "Initialize TARGET=$TARGET, PROFILE=$PROFILE" + + TMP_PKG_DIR=$TMPDIR/tizen_${PROFILE}_pkgs + if [ -d $TMP_PKG_DIR ]; then rm -rf $TMP_PKG_DIR; fi + mkdir -p $TMP_PKG_DIR + + PKG_URL=$TIZEN_URL/$PROFILE/latest + + BUILD_XML_URL=$PKG_URL/$BUILD_XML + TMP_BUILD=$TMP_PKG_DIR/$BUILD_XML + TMP_REPOMD=$TMP_PKG_DIR/$REPOMD_XML + TMP_PRIMARY=$TMP_PKG_DIR/$PRIMARY_XML + TMP_PRIMARYGZ=${TMP_PRIMARY}.gz + + Fetch $BUILD_XML_URL $TMP_BUILD + + Debug "fetch $BUILD_XML_URL to $TMP_BUILD" + + TARGET_XPATH="//build/buildtargets/buildtarget[@name=\"$TARGET\"]/repo[@type=\"binary\"]/text()" + Xpath_get $TARGET_XPATH $TMP_BUILD + TARGET_PATH=$XPATH_RESULT + TARGET_URL=$PKG_URL/$TARGET_PATH + + REPOMD_URL=$TARGET_URL/repodata/repomd.xml + PRIMARY_XPATH='string(//*[local-name()="data"][@type="primary"]/*[local-name()="location"]/@href)' + + Fetch $REPOMD_URL $TMP_REPOMD + + Debug "fetch $REPOMD_URL to $TMP_REPOMD" + + Xpath_get $PRIMARY_XPATH $TMP_REPOMD + PRIMARY_XML_PATH=$XPATH_RESULT + PRIMARY_URL=$TARGET_URL/$PRIMARY_XML_PATH + + Fetch $PRIMARY_URL $TMP_PRIMARYGZ + + Debug "fetch $PRIMARY_URL to $TMP_PRIMARYGZ" + + gunzip $TMP_PRIMARYGZ + + Debug "unzip $TMP_PRIMARYGZ to $TMP_PRIMARY" +} + +fetch_tizen_pkgs() +{ + ARCH=$1 + PACKAGE_XPATH_TPL='string(//*[local-name()="metadata"]/*[local-name()="package"][*[local-name()="name"][text()="_PKG_"]][*[local-name()="arch"][text()="_ARCH_"]]/*[local-name()="location"]/@href)' + + PACKAGE_CHECKSUM_XPATH_TPL='string(//*[local-name()="metadata"]/*[local-name()="package"][*[local-name()="name"][text()="_PKG_"]][*[local-name()="arch"][text()="_ARCH_"]]/*[local-name()="checksum"]/text())' + + for pkg in ${@:2} + do + Inform "Fetching... $pkg" + XPATH=${PACKAGE_XPATH_TPL/_PKG_/$pkg} + XPATH=${XPATH/_ARCH_/$ARCH} + Xpath_get $XPATH $TMP_PRIMARY + PKG_PATH=$XPATH_RESULT + + XPATH=${PACKAGE_CHECKSUM_XPATH_TPL/_PKG_/$pkg} + XPATH=${XPATH/_ARCH_/$ARCH} + Xpath_get $XPATH $TMP_PRIMARY + CHECKSUM=$XPATH_RESULT + + PKG_URL=$TARGET_URL/$PKG_PATH + PKG_FILE=$(basename $PKG_PATH) + PKG_PATH=$TMPDIR/$PKG_FILE + + Debug "Download $PKG_URL to $PKG_PATH" + Fetch $PKG_URL $PKG_PATH true + + echo "$CHECKSUM $PKG_PATH" | sha256sum -c - > /dev/null + if [ $? -ne 0 ]; then + Error "Fail to fetch $PKG_URL to $PKG_PATH" + Debug "Checksum = $CHECKSUM" + exit 1 + fi + done +} + +Inform "Initialize ${TIZEN_ARCH} base" +fetch_tizen_pkgs_init standard Tizen-Base +Inform "fetch common packages" +fetch_tizen_pkgs ${TIZEN_ARCH} gcc gcc-devel-static glibc glibc-devel libicu libicu-devel libatomic linux-glibc-devel keyutils keyutils-devel libkeyutils +Inform "fetch coreclr packages" +fetch_tizen_pkgs ${TIZEN_ARCH} lldb lldb-devel libgcc libstdc++ libstdc++-devel libunwind libunwind-devel lttng-ust-devel lttng-ust userspace-rcu-devel userspace-rcu +Inform "fetch corefx packages" +fetch_tizen_pkgs ${TIZEN_ARCH} libcom_err libcom_err-devel zlib zlib-devel libopenssl11 libopenssl1.1-devel krb5 krb5-devel + +Inform "Initialize standard unified" +fetch_tizen_pkgs_init standard Tizen-Unified +Inform "fetch corefx packages" +fetch_tizen_pkgs ${TIZEN_ARCH} gssdp gssdp-devel tizen-release + diff --git a/eng/common/cross/toolchain.cmake b/eng/common/cross/toolchain.cmake new file mode 100644 index 00000000000000..a88d643c8a765e --- /dev/null +++ b/eng/common/cross/toolchain.cmake @@ -0,0 +1,377 @@ +set(CROSS_ROOTFS $ENV{ROOTFS_DIR}) + +# reset platform variables (e.g. cmake 3.25 sets LINUX=1) +unset(LINUX) +unset(FREEBSD) +unset(ILLUMOS) +unset(ANDROID) +unset(TIZEN) +unset(HAIKU) + +set(TARGET_ARCH_NAME $ENV{TARGET_BUILD_ARCH}) +if(EXISTS ${CROSS_ROOTFS}/bin/freebsd-version) + set(CMAKE_SYSTEM_NAME FreeBSD) + set(FREEBSD 1) +elseif(EXISTS ${CROSS_ROOTFS}/usr/platform/i86pc) + set(CMAKE_SYSTEM_NAME SunOS) + set(ILLUMOS 1) +elseif(EXISTS ${CROSS_ROOTFS}/boot/system/develop/headers/config/HaikuConfig.h) + set(CMAKE_SYSTEM_NAME Haiku) + set(HAIKU 1) +else() + set(CMAKE_SYSTEM_NAME Linux) + set(LINUX 1) +endif() +set(CMAKE_SYSTEM_VERSION 1) + +if(EXISTS ${CROSS_ROOTFS}/etc/tizen-release) + set(TIZEN 1) +elseif(EXISTS ${CROSS_ROOTFS}/android_platform) + set(ANDROID 1) +endif() + +if(TARGET_ARCH_NAME STREQUAL "arm") + set(CMAKE_SYSTEM_PROCESSOR armv7l) + if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv7-alpine-linux-musleabihf) + set(TOOLCHAIN "armv7-alpine-linux-musleabihf") + elseif(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv6-alpine-linux-musleabihf) + set(TOOLCHAIN "armv6-alpine-linux-musleabihf") + else() + set(TOOLCHAIN "arm-linux-gnueabihf") + endif() + if(TIZEN) + set(TIZEN_TOOLCHAIN "armv7hl-tizen-linux-gnueabihf/9.2.0") + endif() +elseif(TARGET_ARCH_NAME STREQUAL "arm64") + set(CMAKE_SYSTEM_PROCESSOR aarch64) + if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/aarch64-alpine-linux-musl) + set(TOOLCHAIN "aarch64-alpine-linux-musl") + elseif(LINUX) + set(TOOLCHAIN "aarch64-linux-gnu") + if(TIZEN) + set(TIZEN_TOOLCHAIN "aarch64-tizen-linux-gnu/9.2.0") + endif() + elseif(FREEBSD) + set(triple "aarch64-unknown-freebsd12") + endif() +elseif(TARGET_ARCH_NAME STREQUAL "armel") + set(CMAKE_SYSTEM_PROCESSOR armv7l) + set(TOOLCHAIN "arm-linux-gnueabi") + if(TIZEN) + set(TIZEN_TOOLCHAIN "armv7l-tizen-linux-gnueabi/9.2.0") + endif() +elseif(TARGET_ARCH_NAME STREQUAL "armv6") + set(CMAKE_SYSTEM_PROCESSOR armv6l) + if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv6-alpine-linux-musleabihf) + set(TOOLCHAIN "armv6-alpine-linux-musleabihf") + else() + set(TOOLCHAIN "arm-linux-gnueabihf") + endif() +elseif(TARGET_ARCH_NAME STREQUAL "ppc64le") + set(CMAKE_SYSTEM_PROCESSOR ppc64le) + if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/powerpc64le-alpine-linux-musl) + set(TOOLCHAIN "powerpc64le-alpine-linux-musl") + else() + set(TOOLCHAIN "powerpc64le-linux-gnu") + endif() +elseif(TARGET_ARCH_NAME STREQUAL "riscv64") + set(CMAKE_SYSTEM_PROCESSOR riscv64) + if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/riscv64-alpine-linux-musl) + set(TOOLCHAIN "riscv64-alpine-linux-musl") + else() + set(TOOLCHAIN "riscv64-linux-gnu") + endif() +elseif(TARGET_ARCH_NAME STREQUAL "s390x") + set(CMAKE_SYSTEM_PROCESSOR s390x) + if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/s390x-alpine-linux-musl) + set(TOOLCHAIN "s390x-alpine-linux-musl") + else() + set(TOOLCHAIN "s390x-linux-gnu") + endif() +elseif(TARGET_ARCH_NAME STREQUAL "x64") + set(CMAKE_SYSTEM_PROCESSOR x86_64) + if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/x86_64-alpine-linux-musl) + set(TOOLCHAIN "x86_64-alpine-linux-musl") + elseif(LINUX) + set(TOOLCHAIN "x86_64-linux-gnu") + if(TIZEN) + set(TIZEN_TOOLCHAIN "x86_64-tizen-linux-gnu/9.2.0") + endif() + elseif(FREEBSD) + set(triple "x86_64-unknown-freebsd12") + elseif(ILLUMOS) + set(TOOLCHAIN "x86_64-illumos") + elseif(HAIKU) + set(TOOLCHAIN "x86_64-unknown-haiku") + endif() +elseif(TARGET_ARCH_NAME STREQUAL "x86") + set(CMAKE_SYSTEM_PROCESSOR i686) + if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/i586-alpine-linux-musl) + set(TOOLCHAIN "i586-alpine-linux-musl") + else() + set(TOOLCHAIN "i686-linux-gnu") + endif() + if(TIZEN) + set(TIZEN_TOOLCHAIN "i586-tizen-linux-gnu/9.2.0") + endif() +else() + message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only arm, arm64, armel, armv6, ppc64le, riscv64, s390x, x64 and x86 are supported!") +endif() + +if(DEFINED ENV{TOOLCHAIN}) + set(TOOLCHAIN $ENV{TOOLCHAIN}) +endif() + +# Specify include paths +if(TIZEN) + if(TARGET_ARCH_NAME STREQUAL "arm") + include_directories(SYSTEM ${CROSS_ROOTFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}/include/c++/) + include_directories(SYSTEM ${CROSS_ROOTFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}/include/c++/armv7hl-tizen-linux-gnueabihf) + endif() + if(TARGET_ARCH_NAME STREQUAL "armel") + include_directories(SYSTEM ${CROSS_ROOTFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}/include/c++/) + include_directories(SYSTEM ${CROSS_ROOTFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}/include/c++/armv7l-tizen-linux-gnueabi) + endif() + if(TARGET_ARCH_NAME STREQUAL "arm64") + include_directories(SYSTEM ${CROSS_ROOTFS}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}/include/c++/) + include_directories(SYSTEM ${CROSS_ROOTFS}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}/include/c++/aarch64-tizen-linux-gnu) + endif() + if(TARGET_ARCH_NAME STREQUAL "x86") + include_directories(SYSTEM ${CROSS_ROOTFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}/include/c++/) + include_directories(SYSTEM ${CROSS_ROOTFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}/include/c++/i586-tizen-linux-gnu) + endif() + if(TARGET_ARCH_NAME STREQUAL "x64") + include_directories(SYSTEM ${CROSS_ROOTFS}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}/include/c++/) + include_directories(SYSTEM ${CROSS_ROOTFS}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}/include/c++/x86_64-tizen-linux-gnu) + endif() +endif() + +if(ANDROID) + if(TARGET_ARCH_NAME STREQUAL "arm") + set(ANDROID_ABI armeabi-v7a) + elseif(TARGET_ARCH_NAME STREQUAL "arm64") + set(ANDROID_ABI arm64-v8a) + endif() + + # extract platform number required by the NDK's toolchain + file(READ "${CROSS_ROOTFS}/android_platform" RID_FILE_CONTENTS) + string(REPLACE "RID=" "" ANDROID_RID "${RID_FILE_CONTENTS}") + string(REGEX REPLACE ".*\\.([0-9]+)-.*" "\\1" ANDROID_PLATFORM "${ANDROID_RID}") + + set(ANDROID_TOOLCHAIN clang) + set(FEATURE_EVENT_TRACE 0) # disable event trace as there is no lttng-ust package in termux repository + set(CMAKE_SYSTEM_LIBRARY_PATH "${CROSS_ROOTFS}/usr/lib") + set(CMAKE_SYSTEM_INCLUDE_PATH "${CROSS_ROOTFS}/usr/include") + + # include official NDK toolchain script + include(${CROSS_ROOTFS}/../build/cmake/android.toolchain.cmake) +elseif(FREEBSD) + # we cross-compile by instructing clang + set(CMAKE_C_COMPILER_TARGET ${triple}) + set(CMAKE_CXX_COMPILER_TARGET ${triple}) + set(CMAKE_ASM_COMPILER_TARGET ${triple}) + set(CMAKE_SYSROOT "${CROSS_ROOTFS}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=lld") + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fuse-ld=lld") +elseif(ILLUMOS) + set(CMAKE_SYSROOT "${CROSS_ROOTFS}") + + include_directories(SYSTEM ${CROSS_ROOTFS}/include) + + set(TOOLSET_PREFIX ${TOOLCHAIN}-) + function(locate_toolchain_exec exec var) + string(TOUPPER ${exec} EXEC_UPPERCASE) + if(NOT "$ENV{CLR_${EXEC_UPPERCASE}}" STREQUAL "") + set(${var} "$ENV{CLR_${EXEC_UPPERCASE}}" PARENT_SCOPE) + return() + endif() + + find_program(EXEC_LOCATION_${exec} + NAMES + "${TOOLSET_PREFIX}${exec}${CLR_CMAKE_COMPILER_FILE_NAME_VERSION}" + "${TOOLSET_PREFIX}${exec}") + + if (EXEC_LOCATION_${exec} STREQUAL "EXEC_LOCATION_${exec}-NOTFOUND") + message(FATAL_ERROR "Unable to find toolchain executable. Name: ${exec}, Prefix: ${TOOLSET_PREFIX}.") + endif() + set(${var} ${EXEC_LOCATION_${exec}} PARENT_SCOPE) + endfunction() + + set(CMAKE_SYSTEM_PREFIX_PATH "${CROSS_ROOTFS}") + + locate_toolchain_exec(gcc CMAKE_C_COMPILER) + locate_toolchain_exec(g++ CMAKE_CXX_COMPILER) + + set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} -lssp") + set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lssp") +elseif(HAIKU) + set(CMAKE_SYSROOT "${CROSS_ROOTFS}") + + set(TOOLSET_PREFIX ${TOOLCHAIN}-) + function(locate_toolchain_exec exec var) + string(TOUPPER ${exec} EXEC_UPPERCASE) + if(NOT "$ENV{CLR_${EXEC_UPPERCASE}}" STREQUAL "") + set(${var} "$ENV{CLR_${EXEC_UPPERCASE}}" PARENT_SCOPE) + return() + endif() + + find_program(EXEC_LOCATION_${exec} + PATHS "${CROSS_ROOTFS}/cross-tools-x86_64/bin" + NAMES + "${TOOLSET_PREFIX}${exec}${CLR_CMAKE_COMPILER_FILE_NAME_VERSION}" + "${TOOLSET_PREFIX}${exec}") + + if (EXEC_LOCATION_${exec} STREQUAL "EXEC_LOCATION_${exec}-NOTFOUND") + message(FATAL_ERROR "Unable to find toolchain executable. Name: ${exec}, Prefix: ${TOOLSET_PREFIX}.") + endif() + set(${var} ${EXEC_LOCATION_${exec}} PARENT_SCOPE) + endfunction() + + set(CMAKE_SYSTEM_PREFIX_PATH "${CROSS_ROOTFS}") + + locate_toolchain_exec(gcc CMAKE_C_COMPILER) + locate_toolchain_exec(g++ CMAKE_CXX_COMPILER) + + set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} -lssp") + set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lssp") + + # let CMake set up the correct search paths + include(Platform/Haiku) +else() + set(CMAKE_SYSROOT "${CROSS_ROOTFS}") + + set(CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN "${CROSS_ROOTFS}/usr") + set(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN "${CROSS_ROOTFS}/usr") + set(CMAKE_ASM_COMPILER_EXTERNAL_TOOLCHAIN "${CROSS_ROOTFS}/usr") +endif() + +# Specify link flags + +function(add_toolchain_linker_flag Flag) + set(Config "${ARGV1}") + set(CONFIG_SUFFIX "") + if (NOT Config STREQUAL "") + set(CONFIG_SUFFIX "_${Config}") + endif() + set("CMAKE_EXE_LINKER_FLAGS${CONFIG_SUFFIX}_INIT" "${CMAKE_EXE_LINKER_FLAGS${CONFIG_SUFFIX}_INIT} ${Flag}" PARENT_SCOPE) + set("CMAKE_SHARED_LINKER_FLAGS${CONFIG_SUFFIX}_INIT" "${CMAKE_SHARED_LINKER_FLAGS${CONFIG_SUFFIX}_INIT} ${Flag}" PARENT_SCOPE) +endfunction() + +if(LINUX) + add_toolchain_linker_flag("-Wl,--rpath-link=${CROSS_ROOTFS}/lib/${TOOLCHAIN}") + add_toolchain_linker_flag("-Wl,--rpath-link=${CROSS_ROOTFS}/usr/lib/${TOOLCHAIN}") +endif() + +if(TARGET_ARCH_NAME MATCHES "^(arm|armel)$") + if(TIZEN) + add_toolchain_linker_flag("-B${CROSS_ROOTFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}") + add_toolchain_linker_flag("-L${CROSS_ROOTFS}/lib") + add_toolchain_linker_flag("-L${CROSS_ROOTFS}/usr/lib") + add_toolchain_linker_flag("-L${CROSS_ROOTFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}") + endif() +elseif(TARGET_ARCH_NAME MATCHES "^(arm64|x64)$") + if(TIZEN) + add_toolchain_linker_flag("-B${CROSS_ROOTFS}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}") + add_toolchain_linker_flag("-L${CROSS_ROOTFS}/lib64") + add_toolchain_linker_flag("-L${CROSS_ROOTFS}/usr/lib64") + add_toolchain_linker_flag("-L${CROSS_ROOTFS}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}") + + add_toolchain_linker_flag("-Wl,--rpath-link=${CROSS_ROOTFS}/lib64") + add_toolchain_linker_flag("-Wl,--rpath-link=${CROSS_ROOTFS}/usr/lib64") + add_toolchain_linker_flag("-Wl,--rpath-link=${CROSS_ROOTFS}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}") + endif() +elseif(TARGET_ARCH_NAME STREQUAL "x86") + if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/i586-alpine-linux-musl) + add_toolchain_linker_flag("--target=${TOOLCHAIN}") + add_toolchain_linker_flag("-Wl,--rpath-link=${CROSS_ROOTFS}/usr/lib/gcc/${TOOLCHAIN}") + endif() + add_toolchain_linker_flag(-m32) + if(TIZEN) + add_toolchain_linker_flag("-B${CROSS_ROOTFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}") + add_toolchain_linker_flag("-L${CROSS_ROOTFS}/lib") + add_toolchain_linker_flag("-L${CROSS_ROOTFS}/usr/lib") + add_toolchain_linker_flag("-L${CROSS_ROOTFS}/usr/lib/gcc/${TIZEN_TOOLCHAIN}") + endif() +elseif(ILLUMOS) + add_toolchain_linker_flag("-L${CROSS_ROOTFS}/lib/amd64") + add_toolchain_linker_flag("-L${CROSS_ROOTFS}/usr/amd64/lib") +elseif(HAIKU) + add_toolchain_linker_flag("-lnetwork") + add_toolchain_linker_flag("-lroot") +endif() + +# Specify compile options + +if((TARGET_ARCH_NAME MATCHES "^(arm|arm64|armel|armv6|ppc64le|riscv64|s390x|x64|x86)$" AND NOT ANDROID AND NOT FREEBSD) OR ILLUMOS OR HAIKU) + set(CMAKE_C_COMPILER_TARGET ${TOOLCHAIN}) + set(CMAKE_CXX_COMPILER_TARGET ${TOOLCHAIN}) + set(CMAKE_ASM_COMPILER_TARGET ${TOOLCHAIN}) +endif() + +if(TARGET_ARCH_NAME MATCHES "^(arm|armel)$") + add_compile_options(-mthumb) + if (NOT DEFINED CLR_ARM_FPU_TYPE) + set (CLR_ARM_FPU_TYPE vfpv3) + endif (NOT DEFINED CLR_ARM_FPU_TYPE) + + add_compile_options (-mfpu=${CLR_ARM_FPU_TYPE}) + if (NOT DEFINED CLR_ARM_FPU_CAPABILITY) + set (CLR_ARM_FPU_CAPABILITY 0x7) + endif (NOT DEFINED CLR_ARM_FPU_CAPABILITY) + + add_definitions (-DCLR_ARM_FPU_CAPABILITY=${CLR_ARM_FPU_CAPABILITY}) + + # persist variables across multiple try_compile passes + list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CLR_ARM_FPU_TYPE CLR_ARM_FPU_CAPABILITY) + + if(TARGET_ARCH_NAME STREQUAL "armel") + add_compile_options(-mfloat-abi=softfp) + endif() +elseif(TARGET_ARCH_NAME STREQUAL "x86") + if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/i586-alpine-linux-musl) + add_compile_options(--target=${TOOLCHAIN}) + endif() + add_compile_options(-m32) + add_compile_options(-Wno-error=unused-command-line-argument) +endif() + +if(TIZEN) + if(TARGET_ARCH_NAME MATCHES "^(arm|armel|arm64|x86)$") + add_compile_options(-Wno-deprecated-declarations) # compile-time option + add_compile_options(-D__extern_always_inline=inline) # compile-time option + endif() +endif() + +# Set LLDB include and library paths for builds that need lldb. +if(TARGET_ARCH_NAME MATCHES "^(arm|armel|x86)$") + if(TARGET_ARCH_NAME STREQUAL "x86") + set(LLVM_CROSS_DIR "$ENV{LLVM_CROSS_HOME}") + else() # arm/armel case + set(LLVM_CROSS_DIR "$ENV{LLVM_ARM_HOME}") + endif() + if(LLVM_CROSS_DIR) + set(WITH_LLDB_LIBS "${LLVM_CROSS_DIR}/lib/" CACHE STRING "") + set(WITH_LLDB_INCLUDES "${LLVM_CROSS_DIR}/include" CACHE STRING "") + set(LLDB_H "${WITH_LLDB_INCLUDES}" CACHE STRING "") + set(LLDB "${LLVM_CROSS_DIR}/lib/liblldb.so" CACHE STRING "") + else() + if(TARGET_ARCH_NAME STREQUAL "x86") + set(WITH_LLDB_LIBS "${CROSS_ROOTFS}/usr/lib/i386-linux-gnu" CACHE STRING "") + set(CHECK_LLVM_DIR "${CROSS_ROOTFS}/usr/lib/llvm-3.8/include") + if(EXISTS "${CHECK_LLVM_DIR}" AND IS_DIRECTORY "${CHECK_LLVM_DIR}") + set(WITH_LLDB_INCLUDES "${CHECK_LLVM_DIR}") + else() + set(WITH_LLDB_INCLUDES "${CROSS_ROOTFS}/usr/lib/llvm-3.6/include") + endif() + else() # arm/armel case + set(WITH_LLDB_LIBS "${CROSS_ROOTFS}/usr/lib/${TOOLCHAIN}" CACHE STRING "") + set(WITH_LLDB_INCLUDES "${CROSS_ROOTFS}/usr/lib/llvm-3.6/include" CACHE STRING "") + endif() + endif() +endif() + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) diff --git a/eng/common/cross/x64/sources.list.bionic b/eng/common/cross/x64/sources.list.bionic new file mode 100644 index 00000000000000..a71ccadcffaf89 --- /dev/null +++ b/eng/common/cross/x64/sources.list.bionic @@ -0,0 +1,11 @@ +deb http://archive.ubuntu.com/ubuntu/ bionic main restricted universe +deb-src http://archive.ubuntu.com/ubuntu/ bionic main restricted universe + +deb http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe +deb-src http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe + +deb http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted +deb-src http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted + +deb http://archive.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse +deb-src http://archive.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse diff --git a/eng/common/cross/x64/sources.list.xenial b/eng/common/cross/x64/sources.list.xenial new file mode 100644 index 00000000000000..ad9c5a0144ef05 --- /dev/null +++ b/eng/common/cross/x64/sources.list.xenial @@ -0,0 +1,11 @@ +deb http://archive.ubuntu.com/ubuntu/ xenial main restricted universe +deb-src http://archive.ubuntu.com/ubuntu/ xenial main restricted universe + +deb http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe +deb-src http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe + +deb http://archive.ubuntu.com/ubuntu/ xenial-backports main restricted +deb-src http://archive.ubuntu.com/ubuntu/ xenial-backports main restricted + +deb http://archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse +deb-src http://archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse diff --git a/eng/common/cross/x64/tizen/tizen.patch b/eng/common/cross/x64/tizen/tizen.patch new file mode 100644 index 00000000000000..56fbc881095b38 --- /dev/null +++ b/eng/common/cross/x64/tizen/tizen.patch @@ -0,0 +1,9 @@ +diff -u -r a/usr/lib64/libc.so b/usr/lib64/libc.so +--- a/usr/lib64/libc.so 2016-12-30 23:00:08.284951863 +0900 ++++ b/usr/lib64/libc.so 2016-12-30 23:00:32.140951815 +0900 +@@ -2,4 +2,4 @@ + Use the shared library, but some functions are only in + the static library, so try that secondarily. */ + OUTPUT_FORMAT(elf64-x86-64) +-GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a AS_NEEDED ( /lib64/ld-linux-x86-64.so.2 ) ) ++GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld-linux-x86-64.so.2 ) ) diff --git a/eng/common/cross/x86/sources.list.bionic b/eng/common/cross/x86/sources.list.bionic new file mode 100644 index 00000000000000..a71ccadcffaf89 --- /dev/null +++ b/eng/common/cross/x86/sources.list.bionic @@ -0,0 +1,11 @@ +deb http://archive.ubuntu.com/ubuntu/ bionic main restricted universe +deb-src http://archive.ubuntu.com/ubuntu/ bionic main restricted universe + +deb http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe +deb-src http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe + +deb http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted +deb-src http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted + +deb http://archive.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse +deb-src http://archive.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse diff --git a/eng/common/cross/x86/sources.list.focal b/eng/common/cross/x86/sources.list.focal new file mode 100644 index 00000000000000..99d5731330e79d --- /dev/null +++ b/eng/common/cross/x86/sources.list.focal @@ -0,0 +1,11 @@ +deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe +deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted universe + +deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe +deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe + +deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted +deb-src http://archive.ubuntu.com/ubuntu/ focal-backports main restricted + +deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse +deb-src http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse diff --git a/eng/common/cross/x86/sources.list.jammy b/eng/common/cross/x86/sources.list.jammy new file mode 100644 index 00000000000000..af1c1feaeac1bd --- /dev/null +++ b/eng/common/cross/x86/sources.list.jammy @@ -0,0 +1,11 @@ +deb http://archive.ubuntu.com/ubuntu/ jammy main restricted universe +deb-src http://archive.ubuntu.com/ubuntu/ jammy main restricted universe + +deb http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted universe +deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted universe + +deb http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted +deb-src http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted + +deb http://archive.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse +deb-src http://archive.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse diff --git a/eng/common/cross/x86/sources.list.xenial b/eng/common/cross/x86/sources.list.xenial new file mode 100644 index 00000000000000..ad9c5a0144ef05 --- /dev/null +++ b/eng/common/cross/x86/sources.list.xenial @@ -0,0 +1,11 @@ +deb http://archive.ubuntu.com/ubuntu/ xenial main restricted universe +deb-src http://archive.ubuntu.com/ubuntu/ xenial main restricted universe + +deb http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe +deb-src http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe + +deb http://archive.ubuntu.com/ubuntu/ xenial-backports main restricted +deb-src http://archive.ubuntu.com/ubuntu/ xenial-backports main restricted + +deb http://archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse +deb-src http://archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse diff --git a/eng/common/cross/x86/tizen/tizen.patch b/eng/common/cross/x86/tizen/tizen.patch new file mode 100644 index 00000000000000..f4fe8838ad6687 --- /dev/null +++ b/eng/common/cross/x86/tizen/tizen.patch @@ -0,0 +1,9 @@ +diff -u -r a/usr/lib/libc.so b/usr/lib/libc.so +--- a/usr/lib/libc.so 2016-12-30 23:00:08.284951863 +0900 ++++ b/usr/lib/libc.so 2016-12-30 23:00:32.140951815 +0900 +@@ -2,4 +2,4 @@ + Use the shared library, but some functions are only in + the static library, so try that secondarily. */ + OUTPUT_FORMAT(elf32-i386) +-GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a AS_NEEDED ( /lib/ld-linux.so.2 ) ) ++GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld-linux.so.2 ) ) diff --git a/eng/common/darc-init.ps1 b/eng/common/darc-init.ps1 new file mode 100644 index 00000000000000..435e7641341b16 --- /dev/null +++ b/eng/common/darc-init.ps1 @@ -0,0 +1,47 @@ +param ( + $darcVersion = $null, + $versionEndpoint = 'https://maestro-prod.westus2.cloudapp.azure.com/api/assets/darc-version?api-version=2019-01-16', + $verbosity = 'minimal', + $toolpath = $null +) + +. $PSScriptRoot\tools.ps1 + +function InstallDarcCli ($darcVersion, $toolpath) { + $darcCliPackageName = 'microsoft.dotnet.darc' + + $dotnetRoot = InitializeDotNetCli -install:$true + $dotnet = "$dotnetRoot\dotnet.exe" + $toolList = & "$dotnet" tool list -g + + if ($toolList -like "*$darcCliPackageName*") { + & "$dotnet" tool uninstall $darcCliPackageName -g + } + + # If the user didn't explicitly specify the darc version, + # query the Maestro API for the correct version of darc to install. + if (-not $darcVersion) { + $darcVersion = $(Invoke-WebRequest -Uri $versionEndpoint -UseBasicParsing).Content + } + + $arcadeServicesSource = 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json' + + Write-Host "Installing Darc CLI version $darcVersion..." + Write-Host 'You may need to restart your command window if this is the first dotnet tool you have installed.' + if (-not $toolpath) { + Write-Host "'$dotnet' tool install $darcCliPackageName --version $darcVersion --add-source '$arcadeServicesSource' -v $verbosity -g" + & "$dotnet" tool install $darcCliPackageName --version $darcVersion --add-source "$arcadeServicesSource" -v $verbosity -g + }else { + Write-Host "'$dotnet' tool install $darcCliPackageName --version $darcVersion --add-source '$arcadeServicesSource' -v $verbosity --tool-path '$toolpath'" + & "$dotnet" tool install $darcCliPackageName --version $darcVersion --add-source "$arcadeServicesSource" -v $verbosity --tool-path "$toolpath" + } +} + +try { + InstallDarcCli $darcVersion $toolpath +} +catch { + Write-Host $_.ScriptStackTrace + Write-PipelineTelemetryError -Category 'Darc' -Message $_ + ExitWithExitCode 1 +} \ No newline at end of file diff --git a/eng/common/darc-init.sh b/eng/common/darc-init.sh new file mode 100755 index 00000000000000..84c1d0cc2e75ac --- /dev/null +++ b/eng/common/darc-init.sh @@ -0,0 +1,82 @@ +#!/usr/bin/env bash + +source="${BASH_SOURCE[0]}" +darcVersion='' +versionEndpoint='https://maestro-prod.westus2.cloudapp.azure.com/api/assets/darc-version?api-version=2019-01-16' +verbosity='minimal' + +while [[ $# > 0 ]]; do + opt="$(echo "$1" | tr "[:upper:]" "[:lower:]")" + case "$opt" in + --darcversion) + darcVersion=$2 + shift + ;; + --versionendpoint) + versionEndpoint=$2 + shift + ;; + --verbosity) + verbosity=$2 + shift + ;; + --toolpath) + toolpath=$2 + shift + ;; + *) + echo "Invalid argument: $1" + usage + exit 1 + ;; + esac + + shift +done + +# resolve $source until the file is no longer a symlink +while [[ -h "$source" ]]; do + scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + # if $source was a relative symlink, we need to resolve it relative to the path where the + # symlink file was located + [[ $source != /* ]] && source="$scriptroot/$source" +done +scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + +. "$scriptroot/tools.sh" + +if [ -z "$darcVersion" ]; then + darcVersion=$(curl -X GET "$versionEndpoint" -H "accept: text/plain") +fi + +function InstallDarcCli { + local darc_cli_package_name="microsoft.dotnet.darc" + + InitializeDotNetCli true + local dotnet_root=$_InitializeDotNetCli + + if [ -z "$toolpath" ]; then + local tool_list=$($dotnet_root/dotnet tool list -g) + if [[ $tool_list = *$darc_cli_package_name* ]]; then + echo $($dotnet_root/dotnet tool uninstall $darc_cli_package_name -g) + fi + else + local tool_list=$($dotnet_root/dotnet tool list --tool-path "$toolpath") + if [[ $tool_list = *$darc_cli_package_name* ]]; then + echo $($dotnet_root/dotnet tool uninstall $darc_cli_package_name --tool-path "$toolpath") + fi + fi + + local arcadeServicesSource="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" + + echo "Installing Darc CLI version $darcVersion..." + echo "You may need to restart your command shell if this is the first dotnet tool you have installed." + if [ -z "$toolpath" ]; then + echo $($dotnet_root/dotnet tool install $darc_cli_package_name --version $darcVersion --add-source "$arcadeServicesSource" -v $verbosity -g) + else + echo $($dotnet_root/dotnet tool install $darc_cli_package_name --version $darcVersion --add-source "$arcadeServicesSource" -v $verbosity --tool-path "$toolpath") + fi +} + +InstallDarcCli diff --git a/eng/common/dotnet-install.cmd b/eng/common/dotnet-install.cmd new file mode 100644 index 00000000000000..b1c2642e76f725 --- /dev/null +++ b/eng/common/dotnet-install.cmd @@ -0,0 +1,2 @@ +@echo off +powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0dotnet-install.ps1""" %*" \ No newline at end of file diff --git a/eng/common/dotnet-install.ps1 b/eng/common/dotnet-install.ps1 new file mode 100644 index 00000000000000..811f0f717f736a --- /dev/null +++ b/eng/common/dotnet-install.ps1 @@ -0,0 +1,28 @@ +[CmdletBinding(PositionalBinding=$false)] +Param( + [string] $verbosity = 'minimal', + [string] $architecture = '', + [string] $version = 'Latest', + [string] $runtime = 'dotnet', + [string] $RuntimeSourceFeed = '', + [string] $RuntimeSourceFeedKey = '' +) + +. $PSScriptRoot\tools.ps1 + +$dotnetRoot = Join-Path $RepoRoot '.dotnet' + +$installdir = $dotnetRoot +try { + if ($architecture -and $architecture.Trim() -eq 'x86') { + $installdir = Join-Path $installdir 'x86' + } + InstallDotNet $installdir $version $architecture $runtime $true -RuntimeSourceFeed $RuntimeSourceFeed -RuntimeSourceFeedKey $RuntimeSourceFeedKey +} +catch { + Write-Host $_.ScriptStackTrace + Write-PipelineTelemetryError -Category 'InitializeToolset' -Message $_ + ExitWithExitCode 1 +} + +ExitWithExitCode 0 diff --git a/eng/common/dotnet-install.sh b/eng/common/dotnet-install.sh new file mode 100755 index 00000000000000..abd045a3247f02 --- /dev/null +++ b/eng/common/dotnet-install.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash + +source="${BASH_SOURCE[0]}" +# resolve $source until the file is no longer a symlink +while [[ -h "$source" ]]; do + scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + # if $source was a relative symlink, we need to resolve it relative to the path where the + # symlink file was located + [[ $source != /* ]] && source="$scriptroot/$source" +done +scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + +. "$scriptroot/tools.sh" + +version='Latest' +architecture='' +runtime='dotnet' +runtimeSourceFeed='' +runtimeSourceFeedKey='' +while [[ $# > 0 ]]; do + opt="$(echo "$1" | tr "[:upper:]" "[:lower:]")" + case "$opt" in + -version|-v) + shift + version="$1" + ;; + -architecture|-a) + shift + architecture="$1" + ;; + -runtime|-r) + shift + runtime="$1" + ;; + -runtimesourcefeed) + shift + runtimeSourceFeed="$1" + ;; + -runtimesourcefeedkey) + shift + runtimeSourceFeedKey="$1" + ;; + *) + Write-PipelineTelemetryError -Category 'Build' -Message "Invalid argument: $1" + exit 1 + ;; + esac + shift +done + +# Use uname to determine what the CPU is, see https://en.wikipedia.org/wiki/Uname#Examples +cpuname=$(uname -m) +case $cpuname in + arm64|aarch64) + buildarch=arm64 + ;; + loongarch64) + buildarch=loongarch64 + ;; + amd64|x86_64) + buildarch=x64 + ;; + armv*l) + buildarch=arm + ;; + i[3-6]86) + buildarch=x86 + ;; + *) + echo "Unknown CPU $cpuname detected, treating it as x64" + buildarch=x64 + ;; +esac + +dotnetRoot="${repo_root}.dotnet" +if [[ $architecture != "" ]] && [[ $architecture != $buildarch ]]; then + dotnetRoot="$dotnetRoot/$architecture" +fi + +InstallDotNet $dotnetRoot $version "$architecture" $runtime true $runtimeSourceFeed $runtimeSourceFeedKey || { + local exit_code=$? + Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "dotnet-install.sh failed (exit code '$exit_code')." >&2 + ExitWithExitCode $exit_code +} + +ExitWithExitCode 0 diff --git a/eng/common/enable-cross-org-publishing.ps1 b/eng/common/enable-cross-org-publishing.ps1 new file mode 100644 index 00000000000000..da09da4f1fc445 --- /dev/null +++ b/eng/common/enable-cross-org-publishing.ps1 @@ -0,0 +1,13 @@ +param( + [string] $token +) + + +. $PSScriptRoot\pipeline-logging-functions.ps1 + +# Write-PipelineSetVariable will no-op if a variable named $ci is not defined +# Since this script is only ever called in AzDO builds, just universally set it +$ci = $true + +Write-PipelineSetVariable -Name 'VSS_NUGET_ACCESSTOKEN' -Value $token -IsMultiJobVariable $false +Write-PipelineSetVariable -Name 'VSS_NUGET_URI_PREFIXES' -Value 'https://dnceng.pkgs.visualstudio.com/;https://pkgs.dev.azure.com/dnceng/;https://devdiv.pkgs.visualstudio.com/;https://pkgs.dev.azure.com/devdiv/' -IsMultiJobVariable $false diff --git a/eng/common/generate-locproject.ps1 b/eng/common/generate-locproject.ps1 new file mode 100644 index 00000000000000..524aaa57f2b742 --- /dev/null +++ b/eng/common/generate-locproject.ps1 @@ -0,0 +1,189 @@ +Param( + [Parameter(Mandatory=$true)][string] $SourcesDirectory, # Directory where source files live; if using a Localize directory it should live in here + [string] $LanguageSet = 'VS_Main_Languages', # Language set to be used in the LocProject.json + [switch] $UseCheckedInLocProjectJson, # When set, generates a LocProject.json and compares it to one that already exists in the repo; otherwise just generates one + [switch] $CreateNeutralXlfs # Creates neutral xlf files. Only set to false when running locally +) + +# Generates LocProject.json files for the OneLocBuild task. OneLocBuildTask is described here: +# https://ceapex.visualstudio.com/CEINTL/_wiki/wikis/CEINTL.wiki/107/Localization-with-OneLocBuild-Task + +Set-StrictMode -Version 2.0 +$ErrorActionPreference = "Stop" +. $PSScriptRoot\pipeline-logging-functions.ps1 + +$exclusionsFilePath = "$SourcesDirectory\eng\Localize\LocExclusions.json" +$exclusions = @{ Exclusions = @() } +if (Test-Path -Path $exclusionsFilePath) +{ + $exclusions = Get-Content "$exclusionsFilePath" | ConvertFrom-Json +} + +Push-Location "$SourcesDirectory" # push location for Resolve-Path -Relative to work + +# Template files +$jsonFiles = @() +$jsonTemplateFiles = Get-ChildItem -Recurse -Path "$SourcesDirectory" | Where-Object { $_.FullName -Match "\.template\.config\\localize\\.+\.en\.json" } # .NET templating pattern +$jsonTemplateFiles | ForEach-Object { + $null = $_.Name -Match "(.+)\.[\w-]+\.json" # matches '[filename].[langcode].json + + $destinationFile = "$($_.Directory.FullName)\$($Matches.1).json" + $jsonFiles += Copy-Item "$($_.FullName)" -Destination $destinationFile -PassThru +} + +$jsonWinformsTemplateFiles = Get-ChildItem -Recurse -Path "$SourcesDirectory" | Where-Object { $_.FullName -Match "en\\strings\.json" } # current winforms pattern + +$wxlFiles = Get-ChildItem -Recurse -Path "$SourcesDirectory" | Where-Object { $_.FullName -Match "\\.+\.wxl" -And -Not( $_.Directory.Name -Match "\d{4}" ) } # localized files live in four digit lang ID directories; this excludes them +if (-not $wxlFiles) { + $wxlEnFiles = Get-ChildItem -Recurse -Path "$SourcesDirectory" | Where-Object { $_.FullName -Match "\\1033\\.+\.wxl" } # pick up en files (1033 = en) specifically so we can copy them to use as the neutral xlf files + if ($wxlEnFiles) { + $wxlFiles = @() + $wxlEnFiles | ForEach-Object { + $destinationFile = "$($_.Directory.Parent.FullName)\$($_.Name)" + $wxlFiles += Copy-Item "$($_.FullName)" -Destination $destinationFile -PassThru + } + } +} + +$macosHtmlEnFiles = Get-ChildItem -Recurse -Path "$SourcesDirectory" | Where-Object { $_.FullName -Match "en\.lproj\\.+\.html$" } # add installer HTML files +$macosHtmlFiles = @() +if ($macosHtmlEnFiles) { + $macosHtmlEnFiles | ForEach-Object { + $destinationFile = "$($_.Directory.Parent.FullName)\$($_.Name)" + $macosHtmlFiles += Copy-Item "$($_.FullName)" -Destination $destinationFile -PassThru + } +} + +$xlfFiles = @() + +$allXlfFiles = Get-ChildItem -Recurse -Path "$SourcesDirectory\*\*.xlf" +$langXlfFiles = @() +if ($allXlfFiles) { + $null = $allXlfFiles[0].FullName -Match "\.([\w-]+)\.xlf" # matches '[langcode].xlf' + $firstLangCode = $Matches.1 + $langXlfFiles = Get-ChildItem -Recurse -Path "$SourcesDirectory\*\*.$firstLangCode.xlf" +} +$langXlfFiles | ForEach-Object { + $null = $_.Name -Match "(.+)\.[\w-]+\.xlf" # matches '[filename].[langcode].xlf + + $destinationFile = "$($_.Directory.FullName)\$($Matches.1).xlf" + $xlfFiles += Copy-Item "$($_.FullName)" -Destination $destinationFile -PassThru +} + +$locFiles = $jsonFiles + $jsonWinformsTemplateFiles + $xlfFiles + +$locJson = @{ + Projects = @( + @{ + LanguageSet = $LanguageSet + LocItems = @( + $locFiles | ForEach-Object { + $outputPath = "$(($_.DirectoryName | Resolve-Path -Relative) + "\")" + $continue = $true + foreach ($exclusion in $exclusions.Exclusions) { + if ($_.FullName.Contains($exclusion)) + { + $continue = $false + } + } + $sourceFile = ($_.FullName | Resolve-Path -Relative) + if (!$CreateNeutralXlfs -and $_.Extension -eq '.xlf') { + Remove-Item -Path $sourceFile + } + if ($continue) + { + if ($_.Directory.Name -eq 'en' -and $_.Extension -eq '.json') { + return @{ + SourceFile = $sourceFile + CopyOption = "LangIDOnPath" + OutputPath = "$($_.Directory.Parent.FullName | Resolve-Path -Relative)\" + } + } else { + return @{ + SourceFile = $sourceFile + CopyOption = "LangIDOnName" + OutputPath = $outputPath + } + } + } + } + ) + }, + @{ + LanguageSet = $LanguageSet + CloneLanguageSet = "WiX_CloneLanguages" + LssFiles = @( "wxl_loc.lss" ) + LocItems = @( + $wxlFiles | ForEach-Object { + $outputPath = "$($_.Directory.FullName | Resolve-Path -Relative)\" + $continue = $true + foreach ($exclusion in $exclusions.Exclusions) { + if ($_.FullName.Contains($exclusion)) { + $continue = $false + } + } + $sourceFile = ($_.FullName | Resolve-Path -Relative) + if ($continue) + { + return @{ + SourceFile = $sourceFile + CopyOption = "LangIDOnPath" + OutputPath = $outputPath + } + } + } + ) + }, + @{ + LanguageSet = $LanguageSet + CloneLanguageSet = "VS_macOS_CloneLanguages" + LssFiles = @( ".\eng\common\loc\P22DotNetHtmlLocalization.lss" ) + LocItems = @( + $macosHtmlFiles | ForEach-Object { + $outputPath = "$($_.Directory.FullName | Resolve-Path -Relative)\" + $continue = $true + foreach ($exclusion in $exclusions.Exclusions) { + if ($_.FullName.Contains($exclusion)) { + $continue = $false + } + } + $sourceFile = ($_.FullName | Resolve-Path -Relative) + $lciFile = $sourceFile + ".lci" + if ($continue) { + $result = @{ + SourceFile = $sourceFile + CopyOption = "LangIDOnPath" + OutputPath = $outputPath + } + if (Test-Path $lciFile -PathType Leaf) { + $result["LciFile"] = $lciFile + } + return $result + } + } + ) + } + ) +} + +$json = ConvertTo-Json $locJson -Depth 5 +Write-Host "LocProject.json generated:`n`n$json`n`n" +Pop-Location + +if (!$UseCheckedInLocProjectJson) { + New-Item "$SourcesDirectory\eng\Localize\LocProject.json" -Force # Need this to make sure the Localize directory is created + Set-Content "$SourcesDirectory\eng\Localize\LocProject.json" $json +} +else { + New-Item "$SourcesDirectory\eng\Localize\LocProject-generated.json" -Force # Need this to make sure the Localize directory is created + Set-Content "$SourcesDirectory\eng\Localize\LocProject-generated.json" $json + + if ((Get-FileHash "$SourcesDirectory\eng\Localize\LocProject-generated.json").Hash -ne (Get-FileHash "$SourcesDirectory\eng\Localize\LocProject.json").Hash) { + Write-PipelineTelemetryError -Category "OneLocBuild" -Message "Existing LocProject.json differs from generated LocProject.json. Download LocProject-generated.json and compare them." + + exit 1 + } + else { + Write-Host "Generated LocProject.json and current LocProject.json are identical." + } +} diff --git a/eng/common/generate-sbom-prep.ps1 b/eng/common/generate-sbom-prep.ps1 new file mode 100644 index 00000000000000..3e5c1c74a1c50d --- /dev/null +++ b/eng/common/generate-sbom-prep.ps1 @@ -0,0 +1,21 @@ +Param( + [Parameter(Mandatory=$true)][string] $ManifestDirPath # Manifest directory where sbom will be placed +) + +. $PSScriptRoot\pipeline-logging-functions.ps1 + +Write-Host "Creating dir $ManifestDirPath" +# create directory for sbom manifest to be placed +if (!(Test-Path -path $ManifestDirPath)) +{ + New-Item -ItemType Directory -path $ManifestDirPath + Write-Host "Successfully created directory $ManifestDirPath" +} +else{ + Write-PipelineTelemetryError -category 'Build' "Unable to create sbom folder." +} + +Write-Host "Updating artifact name" +$artifact_name = "${env:SYSTEM_STAGENAME}_${env:AGENT_JOBNAME}_SBOM" -replace '["/:<>\\|?@*"() ]', '_' +Write-Host "Artifact name $artifact_name" +Write-Host "##vso[task.setvariable variable=ARTIFACT_NAME]$artifact_name" diff --git a/eng/common/generate-sbom-prep.sh b/eng/common/generate-sbom-prep.sh new file mode 100644 index 00000000000000..d5c76dc827b496 --- /dev/null +++ b/eng/common/generate-sbom-prep.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +source="${BASH_SOURCE[0]}" + +# resolve $SOURCE until the file is no longer a symlink +while [[ -h $source ]]; do + scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + + # if $source was a relative symlink, we need to resolve it relative to the path where the + # symlink file was located + [[ $source != /* ]] && source="$scriptroot/$source" +done +scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" +. $scriptroot/pipeline-logging-functions.sh + +manifest_dir=$1 + +if [ ! -d "$manifest_dir" ] ; then + mkdir -p "$manifest_dir" + echo "Sbom directory created." $manifest_dir +else + Write-PipelineTelemetryError -category 'Build' "Unable to create sbom folder." +fi + +artifact_name=$SYSTEM_STAGENAME"_"$AGENT_JOBNAME"_SBOM" +echo "Artifact name before : "$artifact_name +# replace all special characters with _, some builds use special characters like : in Agent.Jobname, that is not a permissible name while uploading artifacts. +safe_artifact_name="${artifact_name//["/:<>\\|?@*$" ]/_}" +echo "Artifact name after : "$safe_artifact_name +export ARTIFACT_NAME=$safe_artifact_name +echo "##vso[task.setvariable variable=ARTIFACT_NAME]$safe_artifact_name" + +exit 0 diff --git a/eng/common/helixpublish.proj b/eng/common/helixpublish.proj new file mode 100644 index 00000000000000..d7f185856e7912 --- /dev/null +++ b/eng/common/helixpublish.proj @@ -0,0 +1,26 @@ + + + + msbuild + + + + + %(Identity) + + + + + + $(WorkItemDirectory) + $(WorkItemCommand) + $(WorkItemTimeout) + + + + + + + + + diff --git a/eng/common/init-tools-native.cmd b/eng/common/init-tools-native.cmd new file mode 100644 index 00000000000000..438cd548c452cc --- /dev/null +++ b/eng/common/init-tools-native.cmd @@ -0,0 +1,3 @@ +@echo off +powershell -NoProfile -NoLogo -ExecutionPolicy ByPass -command "& """%~dp0init-tools-native.ps1""" %*" +exit /b %ErrorLevel% \ No newline at end of file diff --git a/eng/common/init-tools-native.ps1 b/eng/common/init-tools-native.ps1 new file mode 100644 index 00000000000000..27ccdb9ecc9516 --- /dev/null +++ b/eng/common/init-tools-native.ps1 @@ -0,0 +1,203 @@ +<# +.SYNOPSIS +Entry point script for installing native tools + +.DESCRIPTION +Reads $RepoRoot\global.json file to determine native assets to install +and executes installers for those tools + +.PARAMETER BaseUri +Base file directory or Url from which to acquire tool archives + +.PARAMETER InstallDirectory +Directory to install native toolset. This is a command-line override for the default +Install directory precedence order: +- InstallDirectory command-line override +- NETCOREENG_INSTALL_DIRECTORY environment variable +- (default) %USERPROFILE%/.netcoreeng/native + +.PARAMETER Clean +Switch specifying to not install anything, but cleanup native asset folders + +.PARAMETER Force +Clean and then install tools + +.PARAMETER DownloadRetries +Total number of retry attempts + +.PARAMETER RetryWaitTimeInSeconds +Wait time between retry attempts in seconds + +.PARAMETER GlobalJsonFile +File path to global.json file + +.PARAMETER PathPromotion +Optional switch to enable either promote native tools specified in the global.json to the path (in Azure Pipelines) +or break the build if a native tool is not found on the path (on a local dev machine) + +.NOTES +#> +[CmdletBinding(PositionalBinding=$false)] +Param ( + [string] $BaseUri = 'https://netcorenativeassets.blob.core.windows.net/resource-packages/external', + [string] $InstallDirectory, + [switch] $Clean = $False, + [switch] $Force = $False, + [int] $DownloadRetries = 5, + [int] $RetryWaitTimeInSeconds = 30, + [string] $GlobalJsonFile, + [switch] $PathPromotion +) + +if (!$GlobalJsonFile) { + $GlobalJsonFile = Join-Path (Get-Item $PSScriptRoot).Parent.Parent.FullName 'global.json' +} + +Set-StrictMode -version 2.0 +$ErrorActionPreference='Stop' + +. $PSScriptRoot\pipeline-logging-functions.ps1 +Import-Module -Name (Join-Path $PSScriptRoot 'native\CommonLibrary.psm1') + +try { + # Define verbose switch if undefined + $Verbose = $VerbosePreference -Eq 'Continue' + + $EngCommonBaseDir = Join-Path $PSScriptRoot 'native\' + $NativeBaseDir = $InstallDirectory + if (!$NativeBaseDir) { + $NativeBaseDir = CommonLibrary\Get-NativeInstallDirectory + } + $Env:CommonLibrary_NativeInstallDir = $NativeBaseDir + $InstallBin = Join-Path $NativeBaseDir 'bin' + $InstallerPath = Join-Path $EngCommonBaseDir 'install-tool.ps1' + + # Process tools list + Write-Host "Processing $GlobalJsonFile" + If (-Not (Test-Path $GlobalJsonFile)) { + Write-Host "Unable to find '$GlobalJsonFile'" + exit 0 + } + $NativeTools = Get-Content($GlobalJsonFile) -Raw | + ConvertFrom-Json | + Select-Object -Expand 'native-tools' -ErrorAction SilentlyContinue + if ($NativeTools) { + if ($PathPromotion -eq $True) { + $ArcadeToolsDirectory = "$env:SYSTEMDRIVE\arcade-tools" + if (Test-Path $ArcadeToolsDirectory) { # if this directory exists, we should use native tools on machine + $NativeTools.PSObject.Properties | ForEach-Object { + $ToolName = $_.Name + $ToolVersion = $_.Value + $InstalledTools = @{} + + if ((Get-Command "$ToolName" -ErrorAction SilentlyContinue) -eq $null) { + if ($ToolVersion -eq "latest") { + $ToolVersion = "" + } + $ToolDirectories = (Get-ChildItem -Path "$ArcadeToolsDirectory" -Filter "$ToolName-$ToolVersion*" | Sort-Object -Descending) + if ($ToolDirectories -eq $null) { + Write-Error "Unable to find directory for $ToolName $ToolVersion; please make sure the tool is installed on this image." + exit 1 + } + $ToolDirectory = $ToolDirectories[0] + $BinPathFile = "$($ToolDirectory.FullName)\binpath.txt" + if (-not (Test-Path -Path "$BinPathFile")) { + Write-Error "Unable to find binpath.txt in '$($ToolDirectory.FullName)' ($ToolName $ToolVersion); artifact is either installed incorrectly or is not a bootstrappable tool." + exit 1 + } + $BinPath = Get-Content "$BinPathFile" + $ToolPath = Convert-Path -Path $BinPath + Write-Host "Adding $ToolName to the path ($ToolPath)..." + Write-Host "##vso[task.prependpath]$ToolPath" + $env:PATH = "$ToolPath;$env:PATH" + $InstalledTools += @{ $ToolName = $ToolDirectory.FullName } + } + } + return $InstalledTools + } else { + $NativeTools.PSObject.Properties | ForEach-Object { + $ToolName = $_.Name + $ToolVersion = $_.Value + + if ((Get-Command "$ToolName" -ErrorAction SilentlyContinue) -eq $null) { + Write-PipelineTelemetryError -Category 'NativeToolsBootstrap' -Message "$ToolName not found on path. Please install $ToolName $ToolVersion before proceeding." + Write-PipelineTelemetryError -Category 'NativeToolsBootstrap' -Message "If this is running on a build machine, the arcade-tools directory was not found, which means there's an error with the image." + } + } + exit 0 + } + } else { + $NativeTools.PSObject.Properties | ForEach-Object { + $ToolName = $_.Name + $ToolVersion = $_.Value + $LocalInstallerArguments = @{ ToolName = "$ToolName" } + $LocalInstallerArguments += @{ InstallPath = "$InstallBin" } + $LocalInstallerArguments += @{ BaseUri = "$BaseUri" } + $LocalInstallerArguments += @{ CommonLibraryDirectory = "$EngCommonBaseDir" } + $LocalInstallerArguments += @{ Version = "$ToolVersion" } + + if ($Verbose) { + $LocalInstallerArguments += @{ Verbose = $True } + } + if (Get-Variable 'Force' -ErrorAction 'SilentlyContinue') { + if($Force) { + $LocalInstallerArguments += @{ Force = $True } + } + } + if ($Clean) { + $LocalInstallerArguments += @{ Clean = $True } + } + + Write-Verbose "Installing $ToolName version $ToolVersion" + Write-Verbose "Executing '$InstallerPath $($LocalInstallerArguments.Keys.ForEach({"-$_ '$($LocalInstallerArguments.$_)'"}) -join ' ')'" + & $InstallerPath @LocalInstallerArguments + if ($LASTEXITCODE -Ne "0") { + $errMsg = "$ToolName installation failed" + if ((Get-Variable 'DoNotAbortNativeToolsInstallationOnFailure' -ErrorAction 'SilentlyContinue') -and $DoNotAbortNativeToolsInstallationOnFailure) { + $showNativeToolsWarning = $true + if ((Get-Variable 'DoNotDisplayNativeToolsInstallationWarnings' -ErrorAction 'SilentlyContinue') -and $DoNotDisplayNativeToolsInstallationWarnings) { + $showNativeToolsWarning = $false + } + if ($showNativeToolsWarning) { + Write-Warning $errMsg + } + $toolInstallationFailure = $true + } else { + # We cannot change this to Write-PipelineTelemetryError because of https://github.com/dotnet/arcade/issues/4482 + Write-Host $errMsg + exit 1 + } + } + } + + if ((Get-Variable 'toolInstallationFailure' -ErrorAction 'SilentlyContinue') -and $toolInstallationFailure) { + # We cannot change this to Write-PipelineTelemetryError because of https://github.com/dotnet/arcade/issues/4482 + Write-Host 'Native tools bootstrap failed' + exit 1 + } + } + } + else { + Write-Host 'No native tools defined in global.json' + exit 0 + } + + if ($Clean) { + exit 0 + } + if (Test-Path $InstallBin) { + Write-Host 'Native tools are available from ' (Convert-Path -Path $InstallBin) + Write-Host "##vso[task.prependpath]$(Convert-Path -Path $InstallBin)" + return $InstallBin + } + elseif (-not ($PathPromotion)) { + Write-PipelineTelemetryError -Category 'NativeToolsBootstrap' -Message 'Native tools install directory does not exist, installation failed' + exit 1 + } + exit 0 +} +catch { + Write-Host $_.ScriptStackTrace + Write-PipelineTelemetryError -Category 'NativeToolsBootstrap' -Message $_ + ExitWithExitCode 1 +} diff --git a/eng/common/init-tools-native.sh b/eng/common/init-tools-native.sh new file mode 100755 index 00000000000000..3e6a8d6acf2f57 --- /dev/null +++ b/eng/common/init-tools-native.sh @@ -0,0 +1,238 @@ +#!/usr/bin/env bash + +source="${BASH_SOURCE[0]}" +scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + +base_uri='https://netcorenativeassets.blob.core.windows.net/resource-packages/external' +install_directory='' +clean=false +force=false +download_retries=5 +retry_wait_time_seconds=30 +global_json_file="$(dirname "$(dirname "${scriptroot}")")/global.json" +declare -a native_assets + +. $scriptroot/pipeline-logging-functions.sh +. $scriptroot/native/common-library.sh + +while (($# > 0)); do + lowerI="$(echo $1 | tr "[:upper:]" "[:lower:]")" + case $lowerI in + --baseuri) + base_uri=$2 + shift 2 + ;; + --installdirectory) + install_directory=$2 + shift 2 + ;; + --clean) + clean=true + shift 1 + ;; + --force) + force=true + shift 1 + ;; + --donotabortonfailure) + donotabortonfailure=true + shift 1 + ;; + --donotdisplaywarnings) + donotdisplaywarnings=true + shift 1 + ;; + --downloadretries) + download_retries=$2 + shift 2 + ;; + --retrywaittimeseconds) + retry_wait_time_seconds=$2 + shift 2 + ;; + --help) + echo "Common settings:" + echo " --installdirectory Directory to install native toolset." + echo " This is a command-line override for the default" + echo " Install directory precedence order:" + echo " - InstallDirectory command-line override" + echo " - NETCOREENG_INSTALL_DIRECTORY environment variable" + echo " - (default) %USERPROFILE%/.netcoreeng/native" + echo "" + echo " --clean Switch specifying not to install anything, but cleanup native asset folders" + echo " --donotabortonfailure Switch specifiying whether to abort native tools installation on failure" + echo " --donotdisplaywarnings Switch specifiying whether to display warnings during native tools installation on failure" + echo " --force Clean and then install tools" + echo " --help Print help and exit" + echo "" + echo "Advanced settings:" + echo " --baseuri Base URI for where to download native tools from" + echo " --downloadretries Number of times a download should be attempted" + echo " --retrywaittimeseconds Wait time between download attempts" + echo "" + exit 0 + ;; + esac +done + +function ReadGlobalJsonNativeTools { + # happy path: we have a proper JSON parsing tool `jq(1)` in PATH! + if command -v jq &> /dev/null; then + + # jq: read each key/value pair under "native-tools" entry and emit: + # KEY="" VALUE="" + # followed by a null byte. + # + # bash: read line with null byte delimeter and push to array (for later `eval`uation). + + while IFS= read -rd '' line; do + native_assets+=("$line") + done < <(jq -r '. | + select(has("native-tools")) | + ."native-tools" | + keys[] as $k | + @sh "KEY=\($k) VALUE=\(.[$k])\u0000"' "$global_json_file") + + return + fi + + # Warning: falling back to manually parsing JSON, which is not recommended. + + # Following routine matches the output and escaping logic of jq(1)'s @sh formatter used above. + # It has been tested with several weird strings with escaped characters in entries (key and value) + # and results were compared with the output of jq(1) in binary representation using xxd(1); + # just before the assignment to 'native_assets' array (above and below). + + # try to capture the section under "native-tools". + if [[ ! "$(cat "$global_json_file")" =~ \"native-tools\"[[:space:]\:\{]*([^\}]+) ]]; then + return + fi + + section="${BASH_REMATCH[1]}" + + parseStarted=0 + possibleEnd=0 + escaping=0 + escaped=0 + isKey=1 + + for (( i=0; i<${#section}; i++ )); do + char="${section:$i:1}" + if ! ((parseStarted)) && [[ "$char" =~ [[:space:],:] ]]; then continue; fi + + if ! ((escaping)) && [[ "$char" == "\\" ]]; then + escaping=1 + elif ((escaping)) && ! ((escaped)); then + escaped=1 + fi + + if ! ((parseStarted)) && [[ "$char" == "\"" ]]; then + parseStarted=1 + possibleEnd=0 + elif [[ "$char" == "'" ]]; then + token="$token'\\\''" + possibleEnd=0 + elif ((escaping)) || [[ "$char" != "\"" ]]; then + token="$token$char" + possibleEnd=1 + fi + + if ((possibleEnd)) && ! ((escaping)) && [[ "$char" == "\"" ]]; then + # Use printf to unescape token to match jq(1)'s @sh formatting rules. + # do not use 'token="$(printf "$token")"' syntax, as $() eats the trailing linefeed. + printf -v token "'$token'" + + if ((isKey)); then + KEY="$token" + isKey=0 + else + line="KEY=$KEY VALUE=$token" + native_assets+=("$line") + isKey=1 + fi + + # reset for next token + parseStarted=0 + token= + elif ((escaping)) && ((escaped)); then + escaping=0 + escaped=0 + fi + done +} + +native_base_dir=$install_directory +if [[ -z $install_directory ]]; then + native_base_dir=$(GetNativeInstallDirectory) +fi + +install_bin="${native_base_dir}/bin" +installed_any=false + +ReadGlobalJsonNativeTools + +if [[ ${#native_assets[@]} -eq 0 ]]; then + echo "No native tools defined in global.json" + exit 0; +else + native_installer_dir="$scriptroot/native" + for index in "${!native_assets[@]}"; do + eval "${native_assets["$index"]}" + + installer_path="$native_installer_dir/install-$KEY.sh" + installer_command="$installer_path" + installer_command+=" --baseuri $base_uri" + installer_command+=" --installpath $install_bin" + installer_command+=" --version $VALUE" + echo $installer_command + + if [[ $force = true ]]; then + installer_command+=" --force" + fi + + if [[ $clean = true ]]; then + installer_command+=" --clean" + fi + + if [[ -a $installer_path ]]; then + $installer_command + if [[ $? != 0 ]]; then + if [[ $donotabortonfailure = true ]]; then + if [[ $donotdisplaywarnings != true ]]; then + Write-PipelineTelemetryError -category 'NativeToolsBootstrap' "Execution Failed" + fi + else + Write-PipelineTelemetryError -category 'NativeToolsBootstrap' "Execution Failed" + exit 1 + fi + else + $installed_any = true + fi + else + if [[ $donotabortonfailure == true ]]; then + if [[ $donotdisplaywarnings != true ]]; then + Write-PipelineTelemetryError -category 'NativeToolsBootstrap' "Execution Failed: no install script" + fi + else + Write-PipelineTelemetryError -category 'NativeToolsBootstrap' "Execution Failed: no install script" + exit 1 + fi + fi + done +fi + +if [[ $clean = true ]]; then + exit 0 +fi + +if [[ -d $install_bin ]]; then + echo "Native tools are available from $install_bin" + echo "##vso[task.prependpath]$install_bin" +else + if [[ $installed_any = true ]]; then + Write-PipelineTelemetryError -category 'NativeToolsBootstrap' "Native tools install directory does not exist, installation failed" + exit 1 + fi +fi + +exit 0 diff --git a/eng/common/internal-feed-operations.ps1 b/eng/common/internal-feed-operations.ps1 new file mode 100644 index 00000000000000..92b77347d9904e --- /dev/null +++ b/eng/common/internal-feed-operations.ps1 @@ -0,0 +1,132 @@ +param( + [Parameter(Mandatory=$true)][string] $Operation, + [string] $AuthToken, + [string] $CommitSha, + [string] $RepoName, + [switch] $IsFeedPrivate +) + +$ErrorActionPreference = 'Stop' +Set-StrictMode -Version 2.0 +. $PSScriptRoot\tools.ps1 + +# Sets VSS_NUGET_EXTERNAL_FEED_ENDPOINTS based on the "darc-int-*" feeds defined in NuGet.config. This is needed +# in build agents by CredProvider to authenticate the restore requests to internal feeds as specified in +# https://github.com/microsoft/artifacts-credprovider/blob/0f53327cd12fd893d8627d7b08a2171bf5852a41/README.md#environment-variables. This should ONLY be called from identified +# internal builds +function SetupCredProvider { + param( + [string] $AuthToken + ) + + # Install the Cred Provider NuGet plugin + Write-Host 'Setting up Cred Provider NuGet plugin in the agent...' + Write-Host "Getting 'installcredprovider.ps1' from 'https://github.com/microsoft/artifacts-credprovider'..." + + $url = 'https://raw.githubusercontent.com/microsoft/artifacts-credprovider/master/helpers/installcredprovider.ps1' + + Write-Host "Writing the contents of 'installcredprovider.ps1' locally..." + Invoke-WebRequest $url -OutFile installcredprovider.ps1 + + Write-Host 'Installing plugin...' + .\installcredprovider.ps1 -Force + + Write-Host "Deleting local copy of 'installcredprovider.ps1'..." + Remove-Item .\installcredprovider.ps1 + + if (-Not("$env:USERPROFILE\.nuget\plugins\netcore")) { + Write-PipelineTelemetryError -Category 'Arcade' -Message 'CredProvider plugin was not installed correctly!' + ExitWithExitCode 1 + } + else { + Write-Host 'CredProvider plugin was installed correctly!' + } + + # Then, we set the 'VSS_NUGET_EXTERNAL_FEED_ENDPOINTS' environment variable to restore from the stable + # feeds successfully + + $nugetConfigPath = Join-Path $RepoRoot "NuGet.config" + + if (-Not (Test-Path -Path $nugetConfigPath)) { + Write-PipelineTelemetryError -Category 'Build' -Message 'NuGet.config file not found in repo root!' + ExitWithExitCode 1 + } + + $endpoints = New-Object System.Collections.ArrayList + $nugetConfigPackageSources = Select-Xml -Path $nugetConfigPath -XPath "//packageSources/add[contains(@key, 'darc-int-')]/@value" | foreach{$_.Node.Value} + + if (($nugetConfigPackageSources | Measure-Object).Count -gt 0 ) { + foreach ($stableRestoreResource in $nugetConfigPackageSources) { + $trimmedResource = ([string]$stableRestoreResource).Trim() + [void]$endpoints.Add(@{endpoint="$trimmedResource"; password="$AuthToken"}) + } + } + + if (($endpoints | Measure-Object).Count -gt 0) { + $endpointCredentials = @{endpointCredentials=$endpoints} | ConvertTo-Json -Compress + + # Create the environment variables the AzDo way + Write-LoggingCommand -Area 'task' -Event 'setvariable' -Data $endpointCredentials -Properties @{ + 'variable' = 'VSS_NUGET_EXTERNAL_FEED_ENDPOINTS' + 'issecret' = 'false' + } + + # We don't want sessions cached since we will be updating the endpoints quite frequently + Write-LoggingCommand -Area 'task' -Event 'setvariable' -Data 'False' -Properties @{ + 'variable' = 'NUGET_CREDENTIALPROVIDER_SESSIONTOKENCACHE_ENABLED' + 'issecret' = 'false' + } + } + else + { + Write-Host 'No internal endpoints found in NuGet.config' + } +} + +#Workaround for https://github.com/microsoft/msbuild/issues/4430 +function InstallDotNetSdkAndRestoreArcade { + $dotnetTempDir = Join-Path $RepoRoot "dotnet" + $dotnetSdkVersion="2.1.507" # After experimentation we know this version works when restoring the SDK (compared to 3.0.*) + $dotnet = "$dotnetTempDir\dotnet.exe" + $restoreProjPath = "$PSScriptRoot\restore.proj" + + Write-Host "Installing dotnet SDK version $dotnetSdkVersion to restore Arcade SDK..." + InstallDotNetSdk "$dotnetTempDir" "$dotnetSdkVersion" + + '' | Out-File "$restoreProjPath" + + & $dotnet restore $restoreProjPath + + Write-Host 'Arcade SDK restored!' + + if (Test-Path -Path $restoreProjPath) { + Remove-Item $restoreProjPath + } + + if (Test-Path -Path $dotnetTempDir) { + Remove-Item $dotnetTempDir -Recurse + } +} + +try { + Push-Location $PSScriptRoot + + if ($Operation -like 'setup') { + SetupCredProvider $AuthToken + } + elseif ($Operation -like 'install-restore') { + InstallDotNetSdkAndRestoreArcade + } + else { + Write-PipelineTelemetryError -Category 'Arcade' -Message "Unknown operation '$Operation'!" + ExitWithExitCode 1 + } +} +catch { + Write-Host $_.ScriptStackTrace + Write-PipelineTelemetryError -Category 'Arcade' -Message $_ + ExitWithExitCode 1 +} +finally { + Pop-Location +} diff --git a/eng/common/internal-feed-operations.sh b/eng/common/internal-feed-operations.sh new file mode 100755 index 00000000000000..9378223ba0955b --- /dev/null +++ b/eng/common/internal-feed-operations.sh @@ -0,0 +1,141 @@ +#!/usr/bin/env bash + +set -e + +# Sets VSS_NUGET_EXTERNAL_FEED_ENDPOINTS based on the "darc-int-*" feeds defined in NuGet.config. This is needed +# in build agents by CredProvider to authenticate the restore requests to internal feeds as specified in +# https://github.com/microsoft/artifacts-credprovider/blob/0f53327cd12fd893d8627d7b08a2171bf5852a41/README.md#environment-variables. +# This should ONLY be called from identified internal builds +function SetupCredProvider { + local authToken=$1 + + # Install the Cred Provider NuGet plugin + echo "Setting up Cred Provider NuGet plugin in the agent..."... + echo "Getting 'installcredprovider.ps1' from 'https://github.com/microsoft/artifacts-credprovider'..." + + local url="https://raw.githubusercontent.com/microsoft/artifacts-credprovider/master/helpers/installcredprovider.sh" + + echo "Writing the contents of 'installcredprovider.ps1' locally..." + local installcredproviderPath="installcredprovider.sh" + if command -v curl > /dev/null; then + curl $url > "$installcredproviderPath" + else + wget -q -O "$installcredproviderPath" "$url" + fi + + echo "Installing plugin..." + . "$installcredproviderPath" + + echo "Deleting local copy of 'installcredprovider.sh'..." + rm installcredprovider.sh + + if [ ! -d "$HOME/.nuget/plugins" ]; then + Write-PipelineTelemetryError -category 'Build' 'CredProvider plugin was not installed correctly!' + ExitWithExitCode 1 + else + echo "CredProvider plugin was installed correctly!" + fi + + # Then, we set the 'VSS_NUGET_EXTERNAL_FEED_ENDPOINTS' environment variable to restore from the stable + # feeds successfully + + local nugetConfigPath="{$repo_root}NuGet.config" + + if [ ! "$nugetConfigPath" ]; then + Write-PipelineTelemetryError -category 'Build' "NuGet.config file not found in repo's root!" + ExitWithExitCode 1 + fi + + local endpoints='[' + local nugetConfigPackageValues=`cat "$nugetConfigPath" | grep "key=\"darc-int-"` + local pattern="value=\"(.*)\"" + + for value in $nugetConfigPackageValues + do + if [[ $value =~ $pattern ]]; then + local endpoint="${BASH_REMATCH[1]}" + endpoints+="{\"endpoint\": \"$endpoint\", \"password\": \"$authToken\"}," + fi + done + + endpoints=${endpoints%?} + endpoints+=']' + + if [ ${#endpoints} -gt 2 ]; then + local endpointCredentials="{\"endpointCredentials\": "$endpoints"}" + + echo "##vso[task.setvariable variable=VSS_NUGET_EXTERNAL_FEED_ENDPOINTS]$endpointCredentials" + echo "##vso[task.setvariable variable=NUGET_CREDENTIALPROVIDER_SESSIONTOKENCACHE_ENABLED]False" + else + echo "No internal endpoints found in NuGet.config" + fi +} + +# Workaround for https://github.com/microsoft/msbuild/issues/4430 +function InstallDotNetSdkAndRestoreArcade { + local dotnetTempDir="$repo_root/dotnet" + local dotnetSdkVersion="2.1.507" # After experimentation we know this version works when restoring the SDK (compared to 3.0.*) + local restoreProjPath="$repo_root/eng/common/restore.proj" + + echo "Installing dotnet SDK version $dotnetSdkVersion to restore Arcade SDK..." + echo "" > "$restoreProjPath" + + InstallDotNetSdk "$dotnetTempDir" "$dotnetSdkVersion" + + local res=`$dotnetTempDir/dotnet restore $restoreProjPath` + echo "Arcade SDK restored!" + + # Cleanup + if [ "$restoreProjPath" ]; then + rm "$restoreProjPath" + fi + + if [ "$dotnetTempDir" ]; then + rm -r $dotnetTempDir + fi +} + +source="${BASH_SOURCE[0]}" +operation='' +authToken='' +repoName='' + +while [[ $# > 0 ]]; do + opt="$(echo "$1" | tr "[:upper:]" "[:lower:]")" + case "$opt" in + --operation) + operation=$2 + shift + ;; + --authtoken) + authToken=$2 + shift + ;; + *) + echo "Invalid argument: $1" + usage + exit 1 + ;; + esac + + shift +done + +while [[ -h "$source" ]]; do + scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + # if $source was a relative symlink, we need to resolve it relative to the path where the + # symlink file was located + [[ $source != /* ]] && source="$scriptroot/$source" +done +scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + +. "$scriptroot/tools.sh" + +if [ "$operation" = "setup" ]; then + SetupCredProvider $authToken +elif [ "$operation" = "install-restore" ]; then + InstallDotNetSdkAndRestoreArcade +else + echo "Unknown operation '$operation'!" +fi diff --git a/eng/common/internal/Directory.Build.props b/eng/common/internal/Directory.Build.props new file mode 100644 index 00000000000000..dbf99d82a5c2ec --- /dev/null +++ b/eng/common/internal/Directory.Build.props @@ -0,0 +1,4 @@ + + + + diff --git a/eng/common/internal/NuGet.config b/eng/common/internal/NuGet.config new file mode 100644 index 00000000000000..19d3d311b166f5 --- /dev/null +++ b/eng/common/internal/NuGet.config @@ -0,0 +1,7 @@ + + + + + + + diff --git a/eng/common/internal/Tools.csproj b/eng/common/internal/Tools.csproj new file mode 100644 index 00000000000000..7f5ce6d6081338 --- /dev/null +++ b/eng/common/internal/Tools.csproj @@ -0,0 +1,30 @@ + + + + net472 + false + false + + + + + + + + + + + + + + https://devdiv.pkgs.visualstudio.com/_packaging/dotnet-core-internal-tooling/nuget/v3/index.json; + + + $(RestoreSources); + https://devdiv.pkgs.visualstudio.com/_packaging/VS/nuget/v3/index.json; + + + + + + diff --git a/eng/common/loc/P22DotNetHtmlLocalization.lss b/eng/common/loc/P22DotNetHtmlLocalization.lss new file mode 100644 index 00000000000000..6661fed566e49b Binary files /dev/null and b/eng/common/loc/P22DotNetHtmlLocalization.lss differ diff --git a/eng/common/msbuild.ps1 b/eng/common/msbuild.ps1 new file mode 100644 index 00000000000000..f041e5ddd95892 --- /dev/null +++ b/eng/common/msbuild.ps1 @@ -0,0 +1,28 @@ +[CmdletBinding(PositionalBinding=$false)] +Param( + [string] $verbosity = 'minimal', + [bool] $warnAsError = $true, + [bool] $nodeReuse = $true, + [switch] $ci, + [switch] $prepareMachine, + [switch] $excludePrereleaseVS, + [string] $msbuildEngine = $null, + [Parameter(ValueFromRemainingArguments=$true)][String[]]$extraArgs +) + +. $PSScriptRoot\tools.ps1 + +try { + if ($ci) { + $nodeReuse = $false + } + + MSBuild @extraArgs +} +catch { + Write-Host $_.ScriptStackTrace + Write-PipelineTelemetryError -Category 'Build' -Message $_ + ExitWithExitCode 1 +} + +ExitWithExitCode 0 \ No newline at end of file diff --git a/eng/common/msbuild.sh b/eng/common/msbuild.sh new file mode 100755 index 00000000000000..20d3dad5435200 --- /dev/null +++ b/eng/common/msbuild.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +source="${BASH_SOURCE[0]}" + +# resolve $source until the file is no longer a symlink +while [[ -h "$source" ]]; do + scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + # if $source was a relative symlink, we need to resolve it relative to the path where the + # symlink file was located + [[ $source != /* ]] && source="$scriptroot/$source" +done +scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + +verbosity='minimal' +warn_as_error=true +node_reuse=true +prepare_machine=false +extra_args='' + +while (($# > 0)); do + lowerI="$(echo $1 | tr "[:upper:]" "[:lower:]")" + case $lowerI in + --verbosity) + verbosity=$2 + shift 2 + ;; + --warnaserror) + warn_as_error=$2 + shift 2 + ;; + --nodereuse) + node_reuse=$2 + shift 2 + ;; + --ci) + ci=true + shift 1 + ;; + --preparemachine) + prepare_machine=true + shift 1 + ;; + *) + extra_args="$extra_args $1" + shift 1 + ;; + esac +done + +. "$scriptroot/tools.sh" + +if [[ "$ci" == true ]]; then + node_reuse=false +fi + +MSBuild $extra_args +ExitWithExitCode 0 diff --git a/eng/common/native/CommonLibrary.psm1 b/eng/common/native/CommonLibrary.psm1 new file mode 100644 index 00000000000000..ca38268c44d832 --- /dev/null +++ b/eng/common/native/CommonLibrary.psm1 @@ -0,0 +1,400 @@ +<# +.SYNOPSIS +Helper module to install an archive to a directory + +.DESCRIPTION +Helper module to download and extract an archive to a specified directory + +.PARAMETER Uri +Uri of artifact to download + +.PARAMETER InstallDirectory +Directory to extract artifact contents to + +.PARAMETER Force +Force download / extraction if file or contents already exist. Default = False + +.PARAMETER DownloadRetries +Total number of retry attempts. Default = 5 + +.PARAMETER RetryWaitTimeInSeconds +Wait time between retry attempts in seconds. Default = 30 + +.NOTES +Returns False if download or extraction fail, True otherwise +#> +function DownloadAndExtract { + [CmdletBinding(PositionalBinding=$false)] + Param ( + [Parameter(Mandatory=$True)] + [string] $Uri, + [Parameter(Mandatory=$True)] + [string] $InstallDirectory, + [switch] $Force = $False, + [int] $DownloadRetries = 5, + [int] $RetryWaitTimeInSeconds = 30 + ) + # Define verbose switch if undefined + $Verbose = $VerbosePreference -Eq "Continue" + + $TempToolPath = CommonLibrary\Get-TempPathFilename -Path $Uri + + # Download native tool + $DownloadStatus = CommonLibrary\Get-File -Uri $Uri ` + -Path $TempToolPath ` + -DownloadRetries $DownloadRetries ` + -RetryWaitTimeInSeconds $RetryWaitTimeInSeconds ` + -Force:$Force ` + -Verbose:$Verbose + + if ($DownloadStatus -Eq $False) { + Write-Error "Download failed from $Uri" + return $False + } + + # Extract native tool + $UnzipStatus = CommonLibrary\Expand-Zip -ZipPath $TempToolPath ` + -OutputDirectory $InstallDirectory ` + -Force:$Force ` + -Verbose:$Verbose + + if ($UnzipStatus -Eq $False) { + # Retry Download one more time with Force=true + $DownloadRetryStatus = CommonLibrary\Get-File -Uri $Uri ` + -Path $TempToolPath ` + -DownloadRetries 1 ` + -RetryWaitTimeInSeconds $RetryWaitTimeInSeconds ` + -Force:$True ` + -Verbose:$Verbose + + if ($DownloadRetryStatus -Eq $False) { + Write-Error "Last attempt of download failed as well" + return $False + } + + # Retry unzip again one more time with Force=true + $UnzipRetryStatus = CommonLibrary\Expand-Zip -ZipPath $TempToolPath ` + -OutputDirectory $InstallDirectory ` + -Force:$True ` + -Verbose:$Verbose + if ($UnzipRetryStatus -Eq $False) + { + Write-Error "Last attempt of unzip failed as well" + # Clean up partial zips and extracts + if (Test-Path $TempToolPath) { + Remove-Item $TempToolPath -Force + } + if (Test-Path $InstallDirectory) { + Remove-Item $InstallDirectory -Force -Recurse + } + return $False + } + } + + return $True +} + +<# +.SYNOPSIS +Download a file, retry on failure + +.DESCRIPTION +Download specified file and retry if attempt fails + +.PARAMETER Uri +Uri of file to download. If Uri is a local path, the file will be copied instead of downloaded + +.PARAMETER Path +Path to download or copy uri file to + +.PARAMETER Force +Overwrite existing file if present. Default = False + +.PARAMETER DownloadRetries +Total number of retry attempts. Default = 5 + +.PARAMETER RetryWaitTimeInSeconds +Wait time between retry attempts in seconds Default = 30 + +#> +function Get-File { + [CmdletBinding(PositionalBinding=$false)] + Param ( + [Parameter(Mandatory=$True)] + [string] $Uri, + [Parameter(Mandatory=$True)] + [string] $Path, + [int] $DownloadRetries = 5, + [int] $RetryWaitTimeInSeconds = 30, + [switch] $Force = $False + ) + $Attempt = 0 + + if ($Force) { + if (Test-Path $Path) { + Remove-Item $Path -Force + } + } + if (Test-Path $Path) { + Write-Host "File '$Path' already exists, skipping download" + return $True + } + + $DownloadDirectory = Split-Path -ErrorAction Ignore -Path "$Path" -Parent + if (-Not (Test-Path $DownloadDirectory)) { + New-Item -path $DownloadDirectory -force -itemType "Directory" | Out-Null + } + + $TempPath = "$Path.tmp" + if (Test-Path -IsValid -Path $Uri) { + Write-Verbose "'$Uri' is a file path, copying temporarily to '$TempPath'" + Copy-Item -Path $Uri -Destination $TempPath + Write-Verbose "Moving temporary file to '$Path'" + Move-Item -Path $TempPath -Destination $Path + return $? + } + else { + Write-Verbose "Downloading $Uri" + # Don't display the console progress UI - it's a huge perf hit + $ProgressPreference = 'SilentlyContinue' + while($Attempt -Lt $DownloadRetries) + { + try { + Invoke-WebRequest -UseBasicParsing -Uri $Uri -OutFile $TempPath + Write-Verbose "Downloaded to temporary location '$TempPath'" + Move-Item -Path $TempPath -Destination $Path + Write-Verbose "Moved temporary file to '$Path'" + return $True + } + catch { + $Attempt++ + if ($Attempt -Lt $DownloadRetries) { + $AttemptsLeft = $DownloadRetries - $Attempt + Write-Warning "Download failed, $AttemptsLeft attempts remaining, will retry in $RetryWaitTimeInSeconds seconds" + Start-Sleep -Seconds $RetryWaitTimeInSeconds + } + else { + Write-Error $_ + Write-Error $_.Exception + } + } + } + } + + return $False +} + +<# +.SYNOPSIS +Generate a shim for a native tool + +.DESCRIPTION +Creates a wrapper script (shim) that passes arguments forward to native tool assembly + +.PARAMETER ShimName +The name of the shim + +.PARAMETER ShimDirectory +The directory where shims are stored + +.PARAMETER ToolFilePath +Path to file that shim forwards to + +.PARAMETER Force +Replace shim if already present. Default = False + +.NOTES +Returns $True if generating shim succeeds, $False otherwise +#> +function New-ScriptShim { + [CmdletBinding(PositionalBinding=$false)] + Param ( + [Parameter(Mandatory=$True)] + [string] $ShimName, + [Parameter(Mandatory=$True)] + [string] $ShimDirectory, + [Parameter(Mandatory=$True)] + [string] $ToolFilePath, + [Parameter(Mandatory=$True)] + [string] $BaseUri, + [switch] $Force + ) + try { + Write-Verbose "Generating '$ShimName' shim" + + if (-Not (Test-Path $ToolFilePath)){ + Write-Error "Specified tool file path '$ToolFilePath' does not exist" + return $False + } + + # WinShimmer is a small .NET Framework program that creates .exe shims to bootstrapped programs + # Many of the checks for installed programs expect a .exe extension for Windows tools, rather + # than a .bat or .cmd file. + # Source: https://github.com/dotnet/arcade/tree/master/src/WinShimmer + if (-Not (Test-Path "$ShimDirectory\WinShimmer\winshimmer.exe")) { + $InstallStatus = DownloadAndExtract -Uri "$BaseUri/windows/winshimmer/WinShimmer.zip" ` + -InstallDirectory $ShimDirectory\WinShimmer ` + -Force:$Force ` + -DownloadRetries 2 ` + -RetryWaitTimeInSeconds 5 ` + -Verbose:$Verbose + } + + if ((Test-Path (Join-Path $ShimDirectory "$ShimName.exe"))) { + Write-Host "$ShimName.exe already exists; replacing..." + Remove-Item (Join-Path $ShimDirectory "$ShimName.exe") + } + + & "$ShimDirectory\WinShimmer\winshimmer.exe" $ShimName $ToolFilePath $ShimDirectory + return $True + } + catch { + Write-Host $_ + Write-Host $_.Exception + return $False + } +} + +<# +.SYNOPSIS +Returns the machine architecture of the host machine + +.NOTES +Returns 'x64' on 64 bit machines + Returns 'x86' on 32 bit machines +#> +function Get-MachineArchitecture { + $ProcessorArchitecture = $Env:PROCESSOR_ARCHITECTURE + $ProcessorArchitectureW6432 = $Env:PROCESSOR_ARCHITEW6432 + if($ProcessorArchitecture -Eq "X86") + { + if(($ProcessorArchitectureW6432 -Eq "") -Or + ($ProcessorArchitectureW6432 -Eq "X86")) { + return "x86" + } + $ProcessorArchitecture = $ProcessorArchitectureW6432 + } + if (($ProcessorArchitecture -Eq "AMD64") -Or + ($ProcessorArchitecture -Eq "IA64") -Or + ($ProcessorArchitecture -Eq "ARM64") -Or + ($ProcessorArchitecture -Eq "LOONGARCH64")) { + return "x64" + } + return "x86" +} + +<# +.SYNOPSIS +Get the name of a temporary folder under the native install directory +#> +function Get-TempDirectory { + return Join-Path (Get-NativeInstallDirectory) "temp/" +} + +function Get-TempPathFilename { + [CmdletBinding(PositionalBinding=$false)] + Param ( + [Parameter(Mandatory=$True)] + [string] $Path + ) + $TempDir = CommonLibrary\Get-TempDirectory + $TempFilename = Split-Path $Path -leaf + $TempPath = Join-Path $TempDir $TempFilename + return $TempPath +} + +<# +.SYNOPSIS +Returns the base directory to use for native tool installation + +.NOTES +Returns the value of the NETCOREENG_INSTALL_DIRECTORY if that environment variable +is set, or otherwise returns an install directory under the %USERPROFILE% +#> +function Get-NativeInstallDirectory { + $InstallDir = $Env:NETCOREENG_INSTALL_DIRECTORY + if (!$InstallDir) { + $InstallDir = Join-Path $Env:USERPROFILE ".netcoreeng/native/" + } + return $InstallDir +} + +<# +.SYNOPSIS +Unzip an archive + +.DESCRIPTION +Powershell module to unzip an archive to a specified directory + +.PARAMETER ZipPath (Required) +Path to archive to unzip + +.PARAMETER OutputDirectory (Required) +Output directory for archive contents + +.PARAMETER Force +Overwrite output directory contents if they already exist + +.NOTES +- Returns True and does not perform an extraction if output directory already exists but Overwrite is not True. +- Returns True if unzip operation is successful +- Returns False if Overwrite is True and it is unable to remove contents of OutputDirectory +- Returns False if unable to extract zip archive +#> +function Expand-Zip { + [CmdletBinding(PositionalBinding=$false)] + Param ( + [Parameter(Mandatory=$True)] + [string] $ZipPath, + [Parameter(Mandatory=$True)] + [string] $OutputDirectory, + [switch] $Force + ) + + Write-Verbose "Extracting '$ZipPath' to '$OutputDirectory'" + try { + if ((Test-Path $OutputDirectory) -And (-Not $Force)) { + Write-Host "Directory '$OutputDirectory' already exists, skipping extract" + return $True + } + if (Test-Path $OutputDirectory) { + Write-Verbose "'Force' is 'True', but '$OutputDirectory' exists, removing directory" + Remove-Item $OutputDirectory -Force -Recurse + if ($? -Eq $False) { + Write-Error "Unable to remove '$OutputDirectory'" + return $False + } + } + + $TempOutputDirectory = Join-Path "$(Split-Path -Parent $OutputDirectory)" "$(Split-Path -Leaf $OutputDirectory).tmp" + if (Test-Path $TempOutputDirectory) { + Remove-Item $TempOutputDirectory -Force -Recurse + } + New-Item -Path $TempOutputDirectory -Force -ItemType "Directory" | Out-Null + + Add-Type -assembly "system.io.compression.filesystem" + [io.compression.zipfile]::ExtractToDirectory("$ZipPath", "$TempOutputDirectory") + if ($? -Eq $False) { + Write-Error "Unable to extract '$ZipPath'" + return $False + } + + Move-Item -Path $TempOutputDirectory -Destination $OutputDirectory + } + catch { + Write-Host $_ + Write-Host $_.Exception + + return $False + } + return $True +} + +export-modulemember -function DownloadAndExtract +export-modulemember -function Expand-Zip +export-modulemember -function Get-File +export-modulemember -function Get-MachineArchitecture +export-modulemember -function Get-NativeInstallDirectory +export-modulemember -function Get-TempDirectory +export-modulemember -function Get-TempPathFilename +export-modulemember -function New-ScriptShim diff --git a/eng/common/native/common-library.sh b/eng/common/native/common-library.sh new file mode 100755 index 00000000000000..080c2c283ae468 --- /dev/null +++ b/eng/common/native/common-library.sh @@ -0,0 +1,172 @@ +#!/usr/bin/env bash + +function GetNativeInstallDirectory { + local install_dir + + if [[ -z $NETCOREENG_INSTALL_DIRECTORY ]]; then + install_dir=$HOME/.netcoreeng/native/ + else + install_dir=$NETCOREENG_INSTALL_DIRECTORY + fi + + echo $install_dir + return 0 +} + +function GetTempDirectory { + + echo $(GetNativeInstallDirectory)temp/ + return 0 +} + +function ExpandZip { + local zip_path=$1 + local output_directory=$2 + local force=${3:-false} + + echo "Extracting $zip_path to $output_directory" + if [[ -d $output_directory ]] && [[ $force = false ]]; then + echo "Directory '$output_directory' already exists, skipping extract" + return 0 + fi + + if [[ -d $output_directory ]]; then + echo "'Force flag enabled, but '$output_directory' exists. Removing directory" + rm -rf $output_directory + if [[ $? != 0 ]]; then + Write-PipelineTelemetryError -category 'NativeToolsBootstrap' "Unable to remove '$output_directory'" + return 1 + fi + fi + + echo "Creating directory: '$output_directory'" + mkdir -p $output_directory + + echo "Extracting archive" + tar -xf $zip_path -C $output_directory + if [[ $? != 0 ]]; then + Write-PipelineTelemetryError -category 'NativeToolsBootstrap' "Unable to extract '$zip_path'" + return 1 + fi + + return 0 +} + +function GetCurrentOS { + local unameOut="$(uname -s)" + case $unameOut in + Linux*) echo "Linux";; + Darwin*) echo "MacOS";; + esac + return 0 +} + +function GetFile { + local uri=$1 + local path=$2 + local force=${3:-false} + local download_retries=${4:-5} + local retry_wait_time_seconds=${5:-30} + + if [[ -f $path ]]; then + if [[ $force = false ]]; then + echo "File '$path' already exists. Skipping download" + return 0 + else + rm -rf $path + fi + fi + + if [[ -f $uri ]]; then + echo "'$uri' is a file path, copying file to '$path'" + cp $uri $path + return $? + fi + + echo "Downloading $uri" + # Use curl if available, otherwise use wget + if command -v curl > /dev/null; then + curl "$uri" -sSL --retry $download_retries --retry-delay $retry_wait_time_seconds --create-dirs -o "$path" --fail + else + wget -q -O "$path" "$uri" --tries="$download_retries" + fi + + return $? +} + +function GetTempPathFileName { + local path=$1 + + local temp_dir=$(GetTempDirectory) + local temp_file_name=$(basename $path) + echo $temp_dir$temp_file_name + return 0 +} + +function DownloadAndExtract { + local uri=$1 + local installDir=$2 + local force=${3:-false} + local download_retries=${4:-5} + local retry_wait_time_seconds=${5:-30} + + local temp_tool_path=$(GetTempPathFileName $uri) + + echo "downloading to: $temp_tool_path" + + # Download file + GetFile "$uri" "$temp_tool_path" $force $download_retries $retry_wait_time_seconds + if [[ $? != 0 ]]; then + Write-PipelineTelemetryError -category 'NativeToolsBootstrap' "Failed to download '$uri' to '$temp_tool_path'." + return 1 + fi + + # Extract File + echo "extracting from $temp_tool_path to $installDir" + ExpandZip "$temp_tool_path" "$installDir" $force $download_retries $retry_wait_time_seconds + if [[ $? != 0 ]]; then + Write-PipelineTelemetryError -category 'NativeToolsBootstrap' "Failed to extract '$temp_tool_path' to '$installDir'." + return 1 + fi + + return 0 +} + +function NewScriptShim { + local shimpath=$1 + local tool_file_path=$2 + local force=${3:-false} + + echo "Generating '$shimpath' shim" + if [[ -f $shimpath ]]; then + if [[ $force = false ]]; then + echo "File '$shimpath' already exists." >&2 + return 1 + else + rm -rf $shimpath + fi + fi + + if [[ ! -f $tool_file_path ]]; then + # try to see if the path is lower cased + tool_file_path="$(echo $tool_file_path | tr "[:upper:]" "[:lower:]")" + if [[ ! -f $tool_file_path ]]; then + Write-PipelineTelemetryError -category 'NativeToolsBootstrap' "Specified tool file path:'$tool_file_path' does not exist" + return 1 + fi + fi + + local shim_contents=$'#!/usr/bin/env bash\n' + shim_contents+="SHIMARGS="$'$1\n' + shim_contents+="$tool_file_path"$' $SHIMARGS\n' + + # Write shim file + echo "$shim_contents" > $shimpath + + chmod +x $shimpath + + echo "Finished generating shim '$shimpath'" + + return $? +} + diff --git a/eng/common/native/init-compiler.sh b/eng/common/native/init-compiler.sh new file mode 100644 index 00000000000000..517401b688bf76 --- /dev/null +++ b/eng/common/native/init-compiler.sh @@ -0,0 +1,137 @@ +#!/bin/sh +# +# This file detects the C/C++ compiler and exports it to the CC/CXX environment variables +# +# NOTE: some scripts source this file and rely on stdout being empty, make sure to not output anything here! + +if [ -z "$build_arch" ] || [ -z "$compiler" ]; then + echo "Usage..." + echo "build_arch= compiler= init-compiler.sh" + echo "Specify the target architecture." + echo "Specify the name of compiler (clang or gcc)." + exit 1 +fi + +case "$compiler" in + clang*|-clang*|--clang*) + # clangx.y or clang-x.y + version="$(echo "$compiler" | tr -d '[:alpha:]-=')" + majorVersion="${version%%.*}" + [ -z "${version##*.*}" ] && minorVersion="${version#*.}" + + if [ -z "$minorVersion" ] && [ -n "$majorVersion" ] && [ "$majorVersion" -le 6 ]; then + minorVersion=0; + fi + compiler=clang + ;; + + gcc*|-gcc*|--gcc*) + # gccx.y or gcc-x.y + version="$(echo "$compiler" | tr -d '[:alpha:]-=')" + majorVersion="${version%%.*}" + [ -z "${version##*.*}" ] && minorVersion="${version#*.}" + compiler=gcc + ;; +esac + +cxxCompiler="$compiler++" + +# clear the existing CC and CXX from environment +CC= +CXX= +LDFLAGS= + +if [ "$compiler" = "gcc" ]; then cxxCompiler="g++"; fi + +check_version_exists() { + desired_version=-1 + + # Set up the environment to be used for building with the desired compiler. + if command -v "$compiler-$1.$2" > /dev/null; then + desired_version="-$1.$2" + elif command -v "$compiler$1$2" > /dev/null; then + desired_version="$1$2" + elif command -v "$compiler-$1$2" > /dev/null; then + desired_version="-$1$2" + fi + + echo "$desired_version" +} + +if [ -z "$CLR_CC" ]; then + + # Set default versions + if [ -z "$majorVersion" ]; then + # note: gcc (all versions) and clang versions higher than 6 do not have minor version in file name, if it is zero. + if [ "$compiler" = "clang" ]; then versions="16 15 14 13 12 11 10 9 8 7 6.0 5.0 4.0 3.9 3.8 3.7 3.6 3.5" + elif [ "$compiler" = "gcc" ]; then versions="13 12 11 10 9 8 7 6 5 4.9"; fi + + for version in $versions; do + _major="${version%%.*}" + [ -z "${version##*.*}" ] && _minor="${version#*.}" + desired_version="$(check_version_exists "$_major" "$_minor")" + if [ "$desired_version" != "-1" ]; then majorVersion="$_major"; break; fi + done + + if [ -z "$majorVersion" ]; then + if command -v "$compiler" > /dev/null; then + if [ "$(uname)" != "Darwin" ]; then + echo "Warning: Specific version of $compiler not found, falling back to use the one in PATH." + fi + CC="$(command -v "$compiler")" + CXX="$(command -v "$cxxCompiler")" + else + echo "No usable version of $compiler found." + exit 1 + fi + else + if [ "$compiler" = "clang" ] && [ "$majorVersion" -lt 5 ]; then + if [ "$build_arch" = "arm" ] || [ "$build_arch" = "armel" ]; then + if command -v "$compiler" > /dev/null; then + echo "Warning: Found clang version $majorVersion which is not supported on arm/armel architectures, falling back to use clang from PATH." + CC="$(command -v "$compiler")" + CXX="$(command -v "$cxxCompiler")" + else + echo "Found clang version $majorVersion which is not supported on arm/armel architectures, and there is no clang in PATH." + exit 1 + fi + fi + fi + fi + else + desired_version="$(check_version_exists "$majorVersion" "$minorVersion")" + if [ "$desired_version" = "-1" ]; then + echo "Could not find specific version of $compiler: $majorVersion $minorVersion." + exit 1 + fi + fi + + if [ -z "$CC" ]; then + CC="$(command -v "$compiler$desired_version")" + CXX="$(command -v "$cxxCompiler$desired_version")" + if [ -z "$CXX" ]; then CXX="$(command -v "$cxxCompiler")"; fi + fi +else + if [ ! -f "$CLR_CC" ]; then + echo "CLR_CC is set but path '$CLR_CC' does not exist" + exit 1 + fi + CC="$CLR_CC" + CXX="$CLR_CXX" +fi + +if [ -z "$CC" ]; then + echo "Unable to find $compiler." + exit 1 +fi + +# Only lld version >= 9 can be considered stable. lld doesn't support s390x. +if [ "$compiler" = "clang" ] && [ -n "$majorVersion" ] && [ "$majorVersion" -ge 9 ] && [ "$build_arch" != "s390x" ]; then + if "$CC" -fuse-ld=lld -Wl,--version >/dev/null 2>&1; then + LDFLAGS="-fuse-ld=lld" + fi +fi + +SCAN_BUILD_COMMAND="$(command -v "scan-build$desired_version")" + +export CC CXX LDFLAGS SCAN_BUILD_COMMAND diff --git a/eng/common/native/install-cmake-test.sh b/eng/common/native/install-cmake-test.sh new file mode 100755 index 00000000000000..8a5e7cf0db5a92 --- /dev/null +++ b/eng/common/native/install-cmake-test.sh @@ -0,0 +1,117 @@ +#!/usr/bin/env bash + +source="${BASH_SOURCE[0]}" +scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + +. $scriptroot/common-library.sh + +base_uri= +install_path= +version= +clean=false +force=false +download_retries=5 +retry_wait_time_seconds=30 + +while (($# > 0)); do + lowerI="$(echo $1 | tr "[:upper:]" "[:lower:]")" + case $lowerI in + --baseuri) + base_uri=$2 + shift 2 + ;; + --installpath) + install_path=$2 + shift 2 + ;; + --version) + version=$2 + shift 2 + ;; + --clean) + clean=true + shift 1 + ;; + --force) + force=true + shift 1 + ;; + --downloadretries) + download_retries=$2 + shift 2 + ;; + --retrywaittimeseconds) + retry_wait_time_seconds=$2 + shift 2 + ;; + --help) + echo "Common settings:" + echo " --baseuri Base file directory or Url wrom which to acquire tool archives" + echo " --installpath Base directory to install native tool to" + echo " --clean Don't install the tool, just clean up the current install of the tool" + echo " --force Force install of tools even if they previously exist" + echo " --help Print help and exit" + echo "" + echo "Advanced settings:" + echo " --downloadretries Total number of retry attempts" + echo " --retrywaittimeseconds Wait time between retry attempts in seconds" + echo "" + exit 0 + ;; + esac +done + +tool_name="cmake-test" +tool_os=$(GetCurrentOS) +tool_folder="$(echo $tool_os | tr "[:upper:]" "[:lower:]")" +tool_arch="x86_64" +tool_name_moniker="$tool_name-$version-$tool_os-$tool_arch" +tool_install_directory="$install_path/$tool_name/$version" +tool_file_path="$tool_install_directory/$tool_name_moniker/bin/$tool_name" +shim_path="$install_path/$tool_name.sh" +uri="${base_uri}/$tool_folder/$tool_name/$tool_name_moniker.tar.gz" + +# Clean up tool and installers +if [[ $clean = true ]]; then + echo "Cleaning $tool_install_directory" + if [[ -d $tool_install_directory ]]; then + rm -rf $tool_install_directory + fi + + echo "Cleaning $shim_path" + if [[ -f $shim_path ]]; then + rm -rf $shim_path + fi + + tool_temp_path=$(GetTempPathFileName $uri) + echo "Cleaning $tool_temp_path" + if [[ -f $tool_temp_path ]]; then + rm -rf $tool_temp_path + fi + + exit 0 +fi + +# Install tool +if [[ -f $tool_file_path ]] && [[ $force = false ]]; then + echo "$tool_name ($version) already exists, skipping install" + exit 0 +fi + +DownloadAndExtract $uri $tool_install_directory $force $download_retries $retry_wait_time_seconds + +if [[ $? != 0 ]]; then + Write-PipelineTelemetryError -category 'NativeToolsBootstrap' 'Installation failed' + exit 1 +fi + +# Generate Shim +# Always rewrite shims so that we are referencing the expected version +NewScriptShim $shim_path $tool_file_path true + +if [[ $? != 0 ]]; then + Write-PipelineTelemetryError -category 'NativeToolsBootstrap' 'Shim generation failed' + exit 1 +fi + +exit 0 diff --git a/eng/common/native/install-cmake.sh b/eng/common/native/install-cmake.sh new file mode 100755 index 00000000000000..de496beebc5acf --- /dev/null +++ b/eng/common/native/install-cmake.sh @@ -0,0 +1,117 @@ +#!/usr/bin/env bash + +source="${BASH_SOURCE[0]}" +scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + +. $scriptroot/common-library.sh + +base_uri= +install_path= +version= +clean=false +force=false +download_retries=5 +retry_wait_time_seconds=30 + +while (($# > 0)); do + lowerI="$(echo $1 | tr "[:upper:]" "[:lower:]")" + case $lowerI in + --baseuri) + base_uri=$2 + shift 2 + ;; + --installpath) + install_path=$2 + shift 2 + ;; + --version) + version=$2 + shift 2 + ;; + --clean) + clean=true + shift 1 + ;; + --force) + force=true + shift 1 + ;; + --downloadretries) + download_retries=$2 + shift 2 + ;; + --retrywaittimeseconds) + retry_wait_time_seconds=$2 + shift 2 + ;; + --help) + echo "Common settings:" + echo " --baseuri Base file directory or Url wrom which to acquire tool archives" + echo " --installpath Base directory to install native tool to" + echo " --clean Don't install the tool, just clean up the current install of the tool" + echo " --force Force install of tools even if they previously exist" + echo " --help Print help and exit" + echo "" + echo "Advanced settings:" + echo " --downloadretries Total number of retry attempts" + echo " --retrywaittimeseconds Wait time between retry attempts in seconds" + echo "" + exit 0 + ;; + esac +done + +tool_name="cmake" +tool_os=$(GetCurrentOS) +tool_folder="$(echo $tool_os | tr "[:upper:]" "[:lower:]")" +tool_arch="x86_64" +tool_name_moniker="$tool_name-$version-$tool_os-$tool_arch" +tool_install_directory="$install_path/$tool_name/$version" +tool_file_path="$tool_install_directory/$tool_name_moniker/bin/$tool_name" +shim_path="$install_path/$tool_name.sh" +uri="${base_uri}/$tool_folder/$tool_name/$tool_name_moniker.tar.gz" + +# Clean up tool and installers +if [[ $clean = true ]]; then + echo "Cleaning $tool_install_directory" + if [[ -d $tool_install_directory ]]; then + rm -rf $tool_install_directory + fi + + echo "Cleaning $shim_path" + if [[ -f $shim_path ]]; then + rm -rf $shim_path + fi + + tool_temp_path=$(GetTempPathFileName $uri) + echo "Cleaning $tool_temp_path" + if [[ -f $tool_temp_path ]]; then + rm -rf $tool_temp_path + fi + + exit 0 +fi + +# Install tool +if [[ -f $tool_file_path ]] && [[ $force = false ]]; then + echo "$tool_name ($version) already exists, skipping install" + exit 0 +fi + +DownloadAndExtract $uri $tool_install_directory $force $download_retries $retry_wait_time_seconds + +if [[ $? != 0 ]]; then + Write-PipelineTelemetryError -category 'NativeToolsBootstrap' 'Installation failed' + exit 1 +fi + +# Generate Shim +# Always rewrite shims so that we are referencing the expected version +NewScriptShim $shim_path $tool_file_path true + +if [[ $? != 0 ]]; then + Write-PipelineTelemetryError -category 'NativeToolsBootstrap' 'Shim generation failed' + exit 1 +fi + +exit 0 diff --git a/eng/common/native/install-tool.ps1 b/eng/common/native/install-tool.ps1 new file mode 100644 index 00000000000000..78f2d84a4e4b11 --- /dev/null +++ b/eng/common/native/install-tool.ps1 @@ -0,0 +1,132 @@ +<# +.SYNOPSIS +Install native tool + +.DESCRIPTION +Install cmake native tool from Azure blob storage + +.PARAMETER InstallPath +Base directory to install native tool to + +.PARAMETER BaseUri +Base file directory or Url from which to acquire tool archives + +.PARAMETER CommonLibraryDirectory +Path to folder containing common library modules + +.PARAMETER Force +Force install of tools even if they previously exist + +.PARAMETER Clean +Don't install the tool, just clean up the current install of the tool + +.PARAMETER DownloadRetries +Total number of retry attempts + +.PARAMETER RetryWaitTimeInSeconds +Wait time between retry attempts in seconds + +.NOTES +Returns 0 if install succeeds, 1 otherwise +#> +[CmdletBinding(PositionalBinding=$false)] +Param ( + [Parameter(Mandatory=$True)] + [string] $ToolName, + [Parameter(Mandatory=$True)] + [string] $InstallPath, + [Parameter(Mandatory=$True)] + [string] $BaseUri, + [Parameter(Mandatory=$True)] + [string] $Version, + [string] $CommonLibraryDirectory = $PSScriptRoot, + [switch] $Force = $False, + [switch] $Clean = $False, + [int] $DownloadRetries = 5, + [int] $RetryWaitTimeInSeconds = 30 +) + +. $PSScriptRoot\..\pipeline-logging-functions.ps1 + +# Import common library modules +Import-Module -Name (Join-Path $CommonLibraryDirectory "CommonLibrary.psm1") + +try { + # Define verbose switch if undefined + $Verbose = $VerbosePreference -Eq "Continue" + + $Arch = CommonLibrary\Get-MachineArchitecture + $ToolOs = "win64" + if($Arch -Eq "x32") { + $ToolOs = "win32" + } + $ToolNameMoniker = "$ToolName-$Version-$ToolOs-$Arch" + $ToolInstallDirectory = Join-Path $InstallPath "$ToolName\$Version\" + $Uri = "$BaseUri/windows/$ToolName/$ToolNameMoniker.zip" + $ShimPath = Join-Path $InstallPath "$ToolName.exe" + + if ($Clean) { + Write-Host "Cleaning $ToolInstallDirectory" + if (Test-Path $ToolInstallDirectory) { + Remove-Item $ToolInstallDirectory -Force -Recurse + } + Write-Host "Cleaning $ShimPath" + if (Test-Path $ShimPath) { + Remove-Item $ShimPath -Force + } + $ToolTempPath = CommonLibrary\Get-TempPathFilename -Path $Uri + Write-Host "Cleaning $ToolTempPath" + if (Test-Path $ToolTempPath) { + Remove-Item $ToolTempPath -Force + } + exit 0 + } + + # Install tool + if ((Test-Path $ToolInstallDirectory) -And (-Not $Force)) { + Write-Verbose "$ToolName ($Version) already exists, skipping install" + } + else { + $InstallStatus = CommonLibrary\DownloadAndExtract -Uri $Uri ` + -InstallDirectory $ToolInstallDirectory ` + -Force:$Force ` + -DownloadRetries $DownloadRetries ` + -RetryWaitTimeInSeconds $RetryWaitTimeInSeconds ` + -Verbose:$Verbose + + if ($InstallStatus -Eq $False) { + Write-PipelineTelemetryError "Installation failed" -Category "NativeToolsetBootstrapping" + exit 1 + } + } + + $ToolFilePath = Get-ChildItem $ToolInstallDirectory -Recurse -Filter "$ToolName.exe" | % { $_.FullName } + if (@($ToolFilePath).Length -Gt 1) { + Write-Error "There are multiple copies of $ToolName in $($ToolInstallDirectory): `n$(@($ToolFilePath | out-string))" + exit 1 + } elseif (@($ToolFilePath).Length -Lt 1) { + Write-Host "$ToolName was not found in $ToolInstallDirectory." + exit 1 + } + + # Generate shim + # Always rewrite shims so that we are referencing the expected version + $GenerateShimStatus = CommonLibrary\New-ScriptShim -ShimName $ToolName ` + -ShimDirectory $InstallPath ` + -ToolFilePath "$ToolFilePath" ` + -BaseUri $BaseUri ` + -Force:$Force ` + -Verbose:$Verbose + + if ($GenerateShimStatus -Eq $False) { + Write-PipelineTelemetryError "Generate shim failed" -Category "NativeToolsetBootstrapping" + return 1 + } + + exit 0 +} +catch { + Write-Host $_.ScriptStackTrace + Write-PipelineTelemetryError -Category "NativeToolsetBootstrapping" -Message $_ + exit 1 +} diff --git a/eng/common/pipeline-logging-functions.ps1 b/eng/common/pipeline-logging-functions.ps1 new file mode 100644 index 00000000000000..8e422c561e4bdb --- /dev/null +++ b/eng/common/pipeline-logging-functions.ps1 @@ -0,0 +1,260 @@ +# Source for this file was taken from https://github.com/microsoft/azure-pipelines-task-lib/blob/11c9439d4af17e6475d9fe058e6b2e03914d17e6/powershell/VstsTaskSdk/LoggingCommandFunctions.ps1 and modified. + +# NOTE: You should not be calling these method directly as they are likely to change. Instead you should be calling the Write-Pipeline* functions defined in tools.ps1 + +$script:loggingCommandPrefix = '##vso[' +$script:loggingCommandEscapeMappings = @( # TODO: WHAT ABOUT "="? WHAT ABOUT "%"? + New-Object psobject -Property @{ Token = ';' ; Replacement = '%3B' } + New-Object psobject -Property @{ Token = "`r" ; Replacement = '%0D' } + New-Object psobject -Property @{ Token = "`n" ; Replacement = '%0A' } + New-Object psobject -Property @{ Token = "]" ; Replacement = '%5D' } +) +# TODO: BUG: Escape % ??? +# TODO: Add test to verify don't need to escape "=". + +# Specify "-Force" to force pipeline formatted output even if "$ci" is false or not set +function Write-PipelineTelemetryError { + [CmdletBinding()] + param( + [Parameter(Mandatory = $true)] + [string]$Category, + [Parameter(Mandatory = $true)] + [string]$Message, + [Parameter(Mandatory = $false)] + [string]$Type = 'error', + [string]$ErrCode, + [string]$SourcePath, + [string]$LineNumber, + [string]$ColumnNumber, + [switch]$AsOutput, + [switch]$Force) + + $PSBoundParameters.Remove('Category') | Out-Null + + if ($Force -Or ((Test-Path variable:ci) -And $ci)) { + $Message = "(NETCORE_ENGINEERING_TELEMETRY=$Category) $Message" + } + $PSBoundParameters.Remove('Message') | Out-Null + $PSBoundParameters.Add('Message', $Message) + Write-PipelineTaskError @PSBoundParameters +} + +# Specify "-Force" to force pipeline formatted output even if "$ci" is false or not set +function Write-PipelineTaskError { + [CmdletBinding()] + param( + [Parameter(Mandatory = $true)] + [string]$Message, + [Parameter(Mandatory = $false)] + [string]$Type = 'error', + [string]$ErrCode, + [string]$SourcePath, + [string]$LineNumber, + [string]$ColumnNumber, + [switch]$AsOutput, + [switch]$Force + ) + + if (!$Force -And (-Not (Test-Path variable:ci) -Or !$ci)) { + if ($Type -eq 'error') { + Write-Host $Message -ForegroundColor Red + return + } + elseif ($Type -eq 'warning') { + Write-Host $Message -ForegroundColor Yellow + return + } + } + + if (($Type -ne 'error') -and ($Type -ne 'warning')) { + Write-Host $Message + return + } + $PSBoundParameters.Remove('Force') | Out-Null + if (-not $PSBoundParameters.ContainsKey('Type')) { + $PSBoundParameters.Add('Type', 'error') + } + Write-LogIssue @PSBoundParameters +} + +function Write-PipelineSetVariable { + [CmdletBinding()] + param( + [Parameter(Mandatory = $true)] + [string]$Name, + [string]$Value, + [switch]$Secret, + [switch]$AsOutput, + [bool]$IsMultiJobVariable = $true) + + if ((Test-Path variable:ci) -And $ci) { + Write-LoggingCommand -Area 'task' -Event 'setvariable' -Data $Value -Properties @{ + 'variable' = $Name + 'isSecret' = $Secret + 'isOutput' = $IsMultiJobVariable + } -AsOutput:$AsOutput + } +} + +function Write-PipelinePrependPath { + [CmdletBinding()] + param( + [Parameter(Mandatory = $true)] + [string]$Path, + [switch]$AsOutput) + + if ((Test-Path variable:ci) -And $ci) { + Write-LoggingCommand -Area 'task' -Event 'prependpath' -Data $Path -AsOutput:$AsOutput + } +} + +function Write-PipelineSetResult { + [CmdletBinding()] + param( + [ValidateSet("Succeeded", "SucceededWithIssues", "Failed", "Cancelled", "Skipped")] + [Parameter(Mandatory = $true)] + [string]$Result, + [string]$Message) + if ((Test-Path variable:ci) -And $ci) { + Write-LoggingCommand -Area 'task' -Event 'complete' -Data $Message -Properties @{ + 'result' = $Result + } + } +} + +<######################################## +# Private functions. +########################################> +function Format-LoggingCommandData { + [CmdletBinding()] + param([string]$Value, [switch]$Reverse) + + if (!$Value) { + return '' + } + + if (!$Reverse) { + foreach ($mapping in $script:loggingCommandEscapeMappings) { + $Value = $Value.Replace($mapping.Token, $mapping.Replacement) + } + } + else { + for ($i = $script:loggingCommandEscapeMappings.Length - 1 ; $i -ge 0 ; $i--) { + $mapping = $script:loggingCommandEscapeMappings[$i] + $Value = $Value.Replace($mapping.Replacement, $mapping.Token) + } + } + + return $Value +} + +function Format-LoggingCommand { + [CmdletBinding()] + param( + [Parameter(Mandatory = $true)] + [string]$Area, + [Parameter(Mandatory = $true)] + [string]$Event, + [string]$Data, + [hashtable]$Properties) + + # Append the preamble. + [System.Text.StringBuilder]$sb = New-Object -TypeName System.Text.StringBuilder + $null = $sb.Append($script:loggingCommandPrefix).Append($Area).Append('.').Append($Event) + + # Append the properties. + if ($Properties) { + $first = $true + foreach ($key in $Properties.Keys) { + [string]$value = Format-LoggingCommandData $Properties[$key] + if ($value) { + if ($first) { + $null = $sb.Append(' ') + $first = $false + } + else { + $null = $sb.Append(';') + } + + $null = $sb.Append("$key=$value") + } + } + } + + # Append the tail and output the value. + $Data = Format-LoggingCommandData $Data + $sb.Append(']').Append($Data).ToString() +} + +function Write-LoggingCommand { + [CmdletBinding(DefaultParameterSetName = 'Parameters')] + param( + [Parameter(Mandatory = $true, ParameterSetName = 'Parameters')] + [string]$Area, + [Parameter(Mandatory = $true, ParameterSetName = 'Parameters')] + [string]$Event, + [Parameter(ParameterSetName = 'Parameters')] + [string]$Data, + [Parameter(ParameterSetName = 'Parameters')] + [hashtable]$Properties, + [Parameter(Mandatory = $true, ParameterSetName = 'Object')] + $Command, + [switch]$AsOutput) + + if ($PSCmdlet.ParameterSetName -eq 'Object') { + Write-LoggingCommand -Area $Command.Area -Event $Command.Event -Data $Command.Data -Properties $Command.Properties -AsOutput:$AsOutput + return + } + + $command = Format-LoggingCommand -Area $Area -Event $Event -Data $Data -Properties $Properties + if ($AsOutput) { + $command + } + else { + Write-Host $command + } +} + +function Write-LogIssue { + [CmdletBinding()] + param( + [ValidateSet('warning', 'error')] + [Parameter(Mandatory = $true)] + [string]$Type, + [string]$Message, + [string]$ErrCode, + [string]$SourcePath, + [string]$LineNumber, + [string]$ColumnNumber, + [switch]$AsOutput) + + $command = Format-LoggingCommand -Area 'task' -Event 'logissue' -Data $Message -Properties @{ + 'type' = $Type + 'code' = $ErrCode + 'sourcepath' = $SourcePath + 'linenumber' = $LineNumber + 'columnnumber' = $ColumnNumber + } + if ($AsOutput) { + return $command + } + + if ($Type -eq 'error') { + $foregroundColor = $host.PrivateData.ErrorForegroundColor + $backgroundColor = $host.PrivateData.ErrorBackgroundColor + if ($foregroundColor -isnot [System.ConsoleColor] -or $backgroundColor -isnot [System.ConsoleColor]) { + $foregroundColor = [System.ConsoleColor]::Red + $backgroundColor = [System.ConsoleColor]::Black + } + } + else { + $foregroundColor = $host.PrivateData.WarningForegroundColor + $backgroundColor = $host.PrivateData.WarningBackgroundColor + if ($foregroundColor -isnot [System.ConsoleColor] -or $backgroundColor -isnot [System.ConsoleColor]) { + $foregroundColor = [System.ConsoleColor]::Yellow + $backgroundColor = [System.ConsoleColor]::Black + } + } + + Write-Host $command -ForegroundColor $foregroundColor -BackgroundColor $backgroundColor +} diff --git a/eng/common/pipeline-logging-functions.sh b/eng/common/pipeline-logging-functions.sh new file mode 100755 index 00000000000000..6a0b2255e91186 --- /dev/null +++ b/eng/common/pipeline-logging-functions.sh @@ -0,0 +1,206 @@ +#!/usr/bin/env bash + +function Write-PipelineTelemetryError { + local telemetry_category='' + local force=false + local function_args=() + local message='' + while [[ $# -gt 0 ]]; do + opt="$(echo "${1/#--/-}" | tr "[:upper:]" "[:lower:]")" + case "$opt" in + -category|-c) + telemetry_category=$2 + shift + ;; + -force|-f) + force=true + ;; + -*) + function_args+=("$1 $2") + shift + ;; + *) + message=$* + ;; + esac + shift + done + + if [[ $force != true ]] && [[ "$ci" != true ]]; then + echo "$message" >&2 + return + fi + + if [[ $force == true ]]; then + function_args+=("-force") + fi + message="(NETCORE_ENGINEERING_TELEMETRY=$telemetry_category) $message" + function_args+=("$message") + Write-PipelineTaskError ${function_args[@]} +} + +function Write-PipelineTaskError { + local message_type="error" + local sourcepath='' + local linenumber='' + local columnnumber='' + local error_code='' + local force=false + + while [[ $# -gt 0 ]]; do + opt="$(echo "${1/#--/-}" | tr "[:upper:]" "[:lower:]")" + case "$opt" in + -type|-t) + message_type=$2 + shift + ;; + -sourcepath|-s) + sourcepath=$2 + shift + ;; + -linenumber|-ln) + linenumber=$2 + shift + ;; + -columnnumber|-cn) + columnnumber=$2 + shift + ;; + -errcode|-e) + error_code=$2 + shift + ;; + -force|-f) + force=true + ;; + *) + break + ;; + esac + + shift + done + + if [[ $force != true ]] && [[ "$ci" != true ]]; then + echo "$@" >&2 + return + fi + + local message="##vso[task.logissue" + + message="$message type=$message_type" + + if [ -n "$sourcepath" ]; then + message="$message;sourcepath=$sourcepath" + fi + + if [ -n "$linenumber" ]; then + message="$message;linenumber=$linenumber" + fi + + if [ -n "$columnnumber" ]; then + message="$message;columnnumber=$columnnumber" + fi + + if [ -n "$error_code" ]; then + message="$message;code=$error_code" + fi + + message="$message]$*" + echo "$message" +} + +function Write-PipelineSetVariable { + if [[ "$ci" != true ]]; then + return + fi + + local name='' + local value='' + local secret=false + local as_output=false + local is_multi_job_variable=true + + while [[ $# -gt 0 ]]; do + opt="$(echo "${1/#--/-}" | tr "[:upper:]" "[:lower:]")" + case "$opt" in + -name|-n) + name=$2 + shift + ;; + -value|-v) + value=$2 + shift + ;; + -secret|-s) + secret=true + ;; + -as_output|-a) + as_output=true + ;; + -is_multi_job_variable|-i) + is_multi_job_variable=$2 + shift + ;; + esac + shift + done + + value=${value/;/%3B} + value=${value/\\r/%0D} + value=${value/\\n/%0A} + value=${value/]/%5D} + + local message="##vso[task.setvariable variable=$name;isSecret=$secret;isOutput=$is_multi_job_variable]$value" + + if [[ "$as_output" == true ]]; then + $message + else + echo "$message" + fi +} + +function Write-PipelinePrependPath { + local prepend_path='' + + while [[ $# -gt 0 ]]; do + opt="$(echo "${1/#--/-}" | tr "[:upper:]" "[:lower:]")" + case "$opt" in + -path|-p) + prepend_path=$2 + shift + ;; + esac + shift + done + + export PATH="$prepend_path:$PATH" + + if [[ "$ci" == true ]]; then + echo "##vso[task.prependpath]$prepend_path" + fi +} + +function Write-PipelineSetResult { + local result='' + local message='' + + while [[ $# -gt 0 ]]; do + opt="$(echo "${1/#--/-}" | tr "[:upper:]" "[:lower:]")" + case "$opt" in + -result|-r) + result=$2 + shift + ;; + -message|-m) + message=$2 + shift + ;; + esac + shift + done + + if [[ "$ci" == true ]]; then + echo "##vso[task.complete result=$result;]$message" + fi +} diff --git a/eng/common/post-build/add-build-to-channel.ps1 b/eng/common/post-build/add-build-to-channel.ps1 new file mode 100644 index 00000000000000..de2d957922a653 --- /dev/null +++ b/eng/common/post-build/add-build-to-channel.ps1 @@ -0,0 +1,48 @@ +param( + [Parameter(Mandatory=$true)][int] $BuildId, + [Parameter(Mandatory=$true)][int] $ChannelId, + [Parameter(Mandatory=$true)][string] $MaestroApiAccessToken, + [Parameter(Mandatory=$false)][string] $MaestroApiEndPoint = 'https://maestro-prod.westus2.cloudapp.azure.com', + [Parameter(Mandatory=$false)][string] $MaestroApiVersion = '2019-01-16' +) + +try { + . $PSScriptRoot\post-build-utils.ps1 + + # Check that the channel we are going to promote the build to exist + $channelInfo = Get-MaestroChannel -ChannelId $ChannelId + + if (!$channelInfo) { + Write-PipelineTelemetryCategory -Category 'PromoteBuild' -Message "Channel with BAR ID $ChannelId was not found in BAR!" + ExitWithExitCode 1 + } + + # Get info about which channel(s) the build has already been promoted to + $buildInfo = Get-MaestroBuild -BuildId $BuildId + + if (!$buildInfo) { + Write-PipelineTelemetryError -Category 'PromoteBuild' -Message "Build with BAR ID $BuildId was not found in BAR!" + ExitWithExitCode 1 + } + + # Find whether the build is already assigned to the channel or not + if ($buildInfo.channels) { + foreach ($channel in $buildInfo.channels) { + if ($channel.Id -eq $ChannelId) { + Write-Host "The build with BAR ID $BuildId is already on channel $ChannelId!" + ExitWithExitCode 0 + } + } + } + + Write-Host "Promoting build '$BuildId' to channel '$ChannelId'." + + Assign-BuildToChannel -BuildId $BuildId -ChannelId $ChannelId + + Write-Host 'done.' +} +catch { + Write-Host $_ + Write-PipelineTelemetryError -Category 'PromoteBuild' -Message "There was an error while trying to promote build '$BuildId' to channel '$ChannelId'" + ExitWithExitCode 1 +} diff --git a/eng/common/post-build/check-channel-consistency.ps1 b/eng/common/post-build/check-channel-consistency.ps1 new file mode 100644 index 00000000000000..63f3464c986a71 --- /dev/null +++ b/eng/common/post-build/check-channel-consistency.ps1 @@ -0,0 +1,40 @@ +param( + [Parameter(Mandatory=$true)][string] $PromoteToChannels, # List of channels that the build should be promoted to + [Parameter(Mandatory=$true)][array] $AvailableChannelIds # List of channel IDs available in the YAML implementation +) + +try { + . $PSScriptRoot\post-build-utils.ps1 + + if ($PromoteToChannels -eq "") { + Write-PipelineTaskError -Type 'warning' -Message "This build won't publish assets as it's not configured to any Maestro channel. If that wasn't intended use Darc to configure a default channel using add-default-channel for this branch or to promote it to a channel using add-build-to-channel. See https://github.com/dotnet/arcade/blob/master/Documentation/Darc.md#assigning-an-individual-build-to-a-channel for more info." + ExitWithExitCode 0 + } + + # Check that every channel that Maestro told to promote the build to + # is available in YAML + $PromoteToChannelsIds = $PromoteToChannels -split "\D" | Where-Object { $_ } + + $hasErrors = $false + + foreach ($id in $PromoteToChannelsIds) { + if (($id -ne 0) -and ($id -notin $AvailableChannelIds)) { + Write-PipelineTaskError -Message "Channel $id is not present in the post-build YAML configuration! This is an error scenario. Please contact @dnceng." + $hasErrors = $true + } + } + + # The `Write-PipelineTaskError` doesn't error the script and we might report several errors + # in the previous lines. The check below makes sure that we return an error state from the + # script if we reported any validation error + if ($hasErrors) { + ExitWithExitCode 1 + } + + Write-Host 'done.' +} +catch { + Write-Host $_ + Write-PipelineTelemetryError -Category 'CheckChannelConsistency' -Message "There was an error while trying to check consistency of Maestro default channels for the build and post-build YAML configuration." + ExitWithExitCode 1 +} diff --git a/eng/common/post-build/nuget-validation.ps1 b/eng/common/post-build/nuget-validation.ps1 new file mode 100644 index 00000000000000..dab3534ab53893 --- /dev/null +++ b/eng/common/post-build/nuget-validation.ps1 @@ -0,0 +1,24 @@ +# This script validates NuGet package metadata information using this +# tool: https://github.com/NuGet/NuGetGallery/tree/jver-verify/src/VerifyMicrosoftPackage + +param( + [Parameter(Mandatory=$true)][string] $PackagesPath, # Path to where the packages to be validated are + [Parameter(Mandatory=$true)][string] $ToolDestinationPath # Where the validation tool should be downloaded to +) + +try { + . $PSScriptRoot\post-build-utils.ps1 + + $url = 'https://raw.githubusercontent.com/NuGet/NuGetGallery/3e25ad135146676bcab0050a516939d9958bfa5d/src/VerifyMicrosoftPackage/verify.ps1' + + New-Item -ItemType 'directory' -Path ${ToolDestinationPath} -Force + + Invoke-WebRequest $url -OutFile ${ToolDestinationPath}\verify.ps1 + + & ${ToolDestinationPath}\verify.ps1 ${PackagesPath}\*.nupkg +} +catch { + Write-Host $_.ScriptStackTrace + Write-PipelineTelemetryError -Category 'NuGetValidation' -Message $_ + ExitWithExitCode 1 +} diff --git a/eng/common/post-build/post-build-utils.ps1 b/eng/common/post-build/post-build-utils.ps1 new file mode 100644 index 00000000000000..534f6988d5b7fd --- /dev/null +++ b/eng/common/post-build/post-build-utils.ps1 @@ -0,0 +1,91 @@ +# Most of the functions in this file require the variables `MaestroApiEndPoint`, +# `MaestroApiVersion` and `MaestroApiAccessToken` to be globally available. + +$ErrorActionPreference = 'Stop' +Set-StrictMode -Version 2.0 + +# `tools.ps1` checks $ci to perform some actions. Since the post-build +# scripts don't necessarily execute in the same agent that run the +# build.ps1/sh script this variable isn't automatically set. +$ci = $true +$disableConfigureToolsetImport = $true +. $PSScriptRoot\..\tools.ps1 + +function Create-MaestroApiRequestHeaders([string]$ContentType = 'application/json') { + Validate-MaestroVars + + $headers = New-Object 'System.Collections.Generic.Dictionary[[String],[String]]' + $headers.Add('Accept', $ContentType) + $headers.Add('Authorization',"Bearer $MaestroApiAccessToken") + return $headers +} + +function Get-MaestroChannel([int]$ChannelId) { + Validate-MaestroVars + + $apiHeaders = Create-MaestroApiRequestHeaders + $apiEndpoint = "$MaestroApiEndPoint/api/channels/${ChannelId}?api-version=$MaestroApiVersion" + + $result = try { Invoke-WebRequest -Method Get -Uri $apiEndpoint -Headers $apiHeaders | ConvertFrom-Json } catch { Write-Host "Error: $_" } + return $result +} + +function Get-MaestroBuild([int]$BuildId) { + Validate-MaestroVars + + $apiHeaders = Create-MaestroApiRequestHeaders -AuthToken $MaestroApiAccessToken + $apiEndpoint = "$MaestroApiEndPoint/api/builds/${BuildId}?api-version=$MaestroApiVersion" + + $result = try { return Invoke-WebRequest -Method Get -Uri $apiEndpoint -Headers $apiHeaders | ConvertFrom-Json } catch { Write-Host "Error: $_" } + return $result +} + +function Get-MaestroSubscriptions([string]$SourceRepository, [int]$ChannelId) { + Validate-MaestroVars + + $SourceRepository = [System.Web.HttpUtility]::UrlEncode($SourceRepository) + $apiHeaders = Create-MaestroApiRequestHeaders -AuthToken $MaestroApiAccessToken + $apiEndpoint = "$MaestroApiEndPoint/api/subscriptions?sourceRepository=$SourceRepository&channelId=$ChannelId&api-version=$MaestroApiVersion" + + $result = try { Invoke-WebRequest -Method Get -Uri $apiEndpoint -Headers $apiHeaders | ConvertFrom-Json } catch { Write-Host "Error: $_" } + return $result +} + +function Assign-BuildToChannel([int]$BuildId, [int]$ChannelId) { + Validate-MaestroVars + + $apiHeaders = Create-MaestroApiRequestHeaders -AuthToken $MaestroApiAccessToken + $apiEndpoint = "$MaestroApiEndPoint/api/channels/${ChannelId}/builds/${BuildId}?api-version=$MaestroApiVersion" + Invoke-WebRequest -Method Post -Uri $apiEndpoint -Headers $apiHeaders | Out-Null +} + +function Trigger-Subscription([string]$SubscriptionId) { + Validate-MaestroVars + + $apiHeaders = Create-MaestroApiRequestHeaders -AuthToken $MaestroApiAccessToken + $apiEndpoint = "$MaestroApiEndPoint/api/subscriptions/$SubscriptionId/trigger?api-version=$MaestroApiVersion" + Invoke-WebRequest -Uri $apiEndpoint -Headers $apiHeaders -Method Post | Out-Null +} + +function Validate-MaestroVars { + try { + Get-Variable MaestroApiEndPoint | Out-Null + Get-Variable MaestroApiVersion | Out-Null + Get-Variable MaestroApiAccessToken | Out-Null + + if (!($MaestroApiEndPoint -Match '^http[s]?://maestro-(int|prod).westus2.cloudapp.azure.com$')) { + Write-PipelineTelemetryError -Category 'MaestroVars' -Message "MaestroApiEndPoint is not a valid Maestro URL. '$MaestroApiEndPoint'" + ExitWithExitCode 1 + } + + if (!($MaestroApiVersion -Match '^[0-9]{4}-[0-9]{2}-[0-9]{2}$')) { + Write-PipelineTelemetryError -Category 'MaestroVars' -Message "MaestroApiVersion does not match a version string in the format yyyy-MM-DD. '$MaestroApiVersion'" + ExitWithExitCode 1 + } + } + catch { + Write-PipelineTelemetryError -Category 'MaestroVars' -Message 'Error: Variables `MaestroApiEndPoint`, `MaestroApiVersion` and `MaestroApiAccessToken` are required while using this script.' + Write-Host $_ + ExitWithExitCode 1 + } +} diff --git a/eng/common/post-build/publish-using-darc.ps1 b/eng/common/post-build/publish-using-darc.ps1 new file mode 100644 index 00000000000000..8508397d77640e --- /dev/null +++ b/eng/common/post-build/publish-using-darc.ps1 @@ -0,0 +1,54 @@ +param( + [Parameter(Mandatory=$true)][int] $BuildId, + [Parameter(Mandatory=$true)][int] $PublishingInfraVersion, + [Parameter(Mandatory=$true)][string] $AzdoToken, + [Parameter(Mandatory=$true)][string] $MaestroToken, + [Parameter(Mandatory=$false)][string] $MaestroApiEndPoint = 'https://maestro-prod.westus2.cloudapp.azure.com', + [Parameter(Mandatory=$true)][string] $WaitPublishingFinish, + [Parameter(Mandatory=$false)][string] $ArtifactsPublishingAdditionalParameters, + [Parameter(Mandatory=$false)][string] $SymbolPublishingAdditionalParameters +) + +try { + . $PSScriptRoot\post-build-utils.ps1 + + $darc = Get-Darc + + $optionalParams = [System.Collections.ArrayList]::new() + + if ("" -ne $ArtifactsPublishingAdditionalParameters) { + $optionalParams.Add("--artifact-publishing-parameters") | Out-Null + $optionalParams.Add($ArtifactsPublishingAdditionalParameters) | Out-Null + } + + if ("" -ne $SymbolPublishingAdditionalParameters) { + $optionalParams.Add("--symbol-publishing-parameters") | Out-Null + $optionalParams.Add($SymbolPublishingAdditionalParameters) | Out-Null + } + + if ("false" -eq $WaitPublishingFinish) { + $optionalParams.Add("--no-wait") | Out-Null + } + + & $darc add-build-to-channel ` + --id $buildId ` + --publishing-infra-version $PublishingInfraVersion ` + --default-channels ` + --source-branch main ` + --azdev-pat $AzdoToken ` + --bar-uri $MaestroApiEndPoint ` + --password $MaestroToken ` + @optionalParams + + if ($LastExitCode -ne 0) { + Write-Host "Problems using Darc to promote build ${buildId} to default channels. Stopping execution..." + exit 1 + } + + Write-Host 'done.' +} +catch { + Write-Host $_ + Write-PipelineTelemetryError -Category 'PromoteBuild' -Message "There was an error while trying to publish build '$BuildId' to default channels." + ExitWithExitCode 1 +} diff --git a/eng/common/post-build/sourcelink-validation.ps1 b/eng/common/post-build/sourcelink-validation.ps1 new file mode 100644 index 00000000000000..4011d324e7391c --- /dev/null +++ b/eng/common/post-build/sourcelink-validation.ps1 @@ -0,0 +1,319 @@ +param( + [Parameter(Mandatory=$true)][string] $InputPath, # Full path to directory where Symbols.NuGet packages to be checked are stored + [Parameter(Mandatory=$true)][string] $ExtractPath, # Full path to directory where the packages will be extracted during validation + [Parameter(Mandatory=$false)][string] $GHRepoName, # GitHub name of the repo including the Org. E.g., dotnet/arcade + [Parameter(Mandatory=$false)][string] $GHCommit, # GitHub commit SHA used to build the packages + [Parameter(Mandatory=$true)][string] $SourcelinkCliVersion # Version of SourceLink CLI to use +) + +. $PSScriptRoot\post-build-utils.ps1 + +# Cache/HashMap (File -> Exist flag) used to consult whether a file exist +# in the repository at a specific commit point. This is populated by inserting +# all files present in the repo at a specific commit point. +$global:RepoFiles = @{} + +# Maximum number of jobs to run in parallel +$MaxParallelJobs = 16 + +$MaxRetries = 5 +$RetryWaitTimeInSeconds = 30 + +# Wait time between check for system load +$SecondsBetweenLoadChecks = 10 + +if (!$InputPath -or !(Test-Path $InputPath)){ + Write-Host "No files to validate." + ExitWithExitCode 0 +} + +$ValidatePackage = { + param( + [string] $PackagePath # Full path to a Symbols.NuGet package + ) + + . $using:PSScriptRoot\..\tools.ps1 + + # Ensure input file exist + if (!(Test-Path $PackagePath)) { + Write-Host "Input file does not exist: $PackagePath" + return [pscustomobject]@{ + result = 1 + packagePath = $PackagePath + } + } + + # Extensions for which we'll look for SourceLink information + # For now we'll only care about Portable & Embedded PDBs + $RelevantExtensions = @('.dll', '.exe', '.pdb') + + Write-Host -NoNewLine 'Validating ' ([System.IO.Path]::GetFileName($PackagePath)) '...' + + $PackageId = [System.IO.Path]::GetFileNameWithoutExtension($PackagePath) + $ExtractPath = Join-Path -Path $using:ExtractPath -ChildPath $PackageId + $FailedFiles = 0 + + Add-Type -AssemblyName System.IO.Compression.FileSystem + + [System.IO.Directory]::CreateDirectory($ExtractPath) | Out-Null + + try { + $zip = [System.IO.Compression.ZipFile]::OpenRead($PackagePath) + + $zip.Entries | + Where-Object {$RelevantExtensions -contains [System.IO.Path]::GetExtension($_.Name)} | + ForEach-Object { + $FileName = $_.FullName + $Extension = [System.IO.Path]::GetExtension($_.Name) + $FakeName = -Join((New-Guid), $Extension) + $TargetFile = Join-Path -Path $ExtractPath -ChildPath $FakeName + + # We ignore resource DLLs + if ($FileName.EndsWith('.resources.dll')) { + return [pscustomobject]@{ + result = 0 + packagePath = $PackagePath + } + } + + [System.IO.Compression.ZipFileExtensions]::ExtractToFile($_, $TargetFile, $true) + + $ValidateFile = { + param( + [string] $FullPath, # Full path to the module that has to be checked + [string] $RealPath, + [ref] $FailedFiles + ) + + $sourcelinkExe = "$env:USERPROFILE\.dotnet\tools" + $sourcelinkExe = Resolve-Path "$sourcelinkExe\sourcelink.exe" + $SourceLinkInfos = & $sourcelinkExe print-urls $FullPath | Out-String + + if ($LASTEXITCODE -eq 0 -and -not ([string]::IsNullOrEmpty($SourceLinkInfos))) { + $NumFailedLinks = 0 + + # We only care about Http addresses + $Matches = (Select-String '(http[s]?)(:\/\/)([^\s,]+)' -Input $SourceLinkInfos -AllMatches).Matches + + if ($Matches.Count -ne 0) { + $Matches.Value | + ForEach-Object { + $Link = $_ + $CommitUrl = "https://raw.githubusercontent.com/${using:GHRepoName}/${using:GHCommit}/" + + $FilePath = $Link.Replace($CommitUrl, "") + $Status = 200 + $Cache = $using:RepoFiles + + $attempts = 0 + + while ($attempts -lt $using:MaxRetries) { + if ( !($Cache.ContainsKey($FilePath)) ) { + try { + $Uri = $Link -as [System.URI] + + if ($Link -match "submodules") { + # Skip submodule links until sourcelink properly handles submodules + $Status = 200 + } + elseif ($Uri.AbsoluteURI -ne $null -and ($Uri.Host -match 'github' -or $Uri.Host -match 'githubusercontent')) { + # Only GitHub links are valid + $Status = (Invoke-WebRequest -Uri $Link -UseBasicParsing -Method HEAD -TimeoutSec 5).StatusCode + } + else { + # If it's not a github link, we want to break out of the loop and not retry. + $Status = 0 + $attempts = $using:MaxRetries + } + } + catch { + Write-Host $_ + $Status = 0 + } + } + + if ($Status -ne 200) { + $attempts++ + + if ($attempts -lt $using:MaxRetries) + { + $attemptsLeft = $using:MaxRetries - $attempts + Write-Warning "Download failed, $attemptsLeft attempts remaining, will retry in $using:RetryWaitTimeInSeconds seconds" + Start-Sleep -Seconds $using:RetryWaitTimeInSeconds + } + else { + if ($NumFailedLinks -eq 0) { + if ($FailedFiles.Value -eq 0) { + Write-Host + } + + Write-Host "`tFile $RealPath has broken links:" + } + + Write-Host "`t`tFailed to retrieve $Link" + + $NumFailedLinks++ + } + } + else { + break + } + } + } + } + + if ($NumFailedLinks -ne 0) { + $FailedFiles.value++ + $global:LASTEXITCODE = 1 + } + } + } + + &$ValidateFile $TargetFile $FileName ([ref]$FailedFiles) + } + } + catch { + Write-Host $_ + } + finally { + $zip.Dispose() + } + + if ($FailedFiles -eq 0) { + Write-Host 'Passed.' + return [pscustomobject]@{ + result = 0 + packagePath = $PackagePath + } + } + else { + Write-PipelineTelemetryError -Category 'SourceLink' -Message "$PackagePath has broken SourceLink links." + return [pscustomobject]@{ + result = 1 + packagePath = $PackagePath + } + } +} + +function CheckJobResult( + $result, + $packagePath, + [ref]$ValidationFailures, + [switch]$logErrors) { + if ($result -ne '0') { + if ($logErrors) { + Write-PipelineTelemetryError -Category 'SourceLink' -Message "$packagePath has broken SourceLink links." + } + $ValidationFailures.Value++ + } +} + +function ValidateSourceLinkLinks { + if ($GHRepoName -ne '' -and !($GHRepoName -Match '^[^\s\/]+/[^\s\/]+$')) { + if (!($GHRepoName -Match '^[^\s-]+-[^\s]+$')) { + Write-PipelineTelemetryError -Category 'SourceLink' -Message "GHRepoName should be in the format / or -. '$GHRepoName'" + ExitWithExitCode 1 + } + else { + $GHRepoName = $GHRepoName -replace '^([^\s-]+)-([^\s]+)$', '$1/$2'; + } + } + + if ($GHCommit -ne '' -and !($GHCommit -Match '^[0-9a-fA-F]{40}$')) { + Write-PipelineTelemetryError -Category 'SourceLink' -Message "GHCommit should be a 40 chars hexadecimal string. '$GHCommit'" + ExitWithExitCode 1 + } + + if ($GHRepoName -ne '' -and $GHCommit -ne '') { + $RepoTreeURL = -Join('http://api.github.com/repos/', $GHRepoName, '/git/trees/', $GHCommit, '?recursive=1') + $CodeExtensions = @('.cs', '.vb', '.fs', '.fsi', '.fsx', '.fsscript') + + try { + # Retrieve the list of files in the repo at that particular commit point and store them in the RepoFiles hash + $Data = Invoke-WebRequest $RepoTreeURL -UseBasicParsing | ConvertFrom-Json | Select-Object -ExpandProperty tree + + foreach ($file in $Data) { + $Extension = [System.IO.Path]::GetExtension($file.path) + + if ($CodeExtensions.Contains($Extension)) { + $RepoFiles[$file.path] = 1 + } + } + } + catch { + Write-Host "Problems downloading the list of files from the repo. Url used: $RepoTreeURL . Execution will proceed without caching." + } + } + elseif ($GHRepoName -ne '' -or $GHCommit -ne '') { + Write-Host 'For using the http caching mechanism both GHRepoName and GHCommit should be informed.' + } + + if (Test-Path $ExtractPath) { + Remove-Item $ExtractPath -Force -Recurse -ErrorAction SilentlyContinue + } + + $ValidationFailures = 0 + + # Process each NuGet package in parallel + Get-ChildItem "$InputPath\*.symbols.nupkg" | + ForEach-Object { + Write-Host "Starting $($_.FullName)" + Start-Job -ScriptBlock $ValidatePackage -ArgumentList $_.FullName | Out-Null + $NumJobs = @(Get-Job -State 'Running').Count + + while ($NumJobs -ge $MaxParallelJobs) { + Write-Host "There are $NumJobs validation jobs running right now. Waiting $SecondsBetweenLoadChecks seconds to check again." + sleep $SecondsBetweenLoadChecks + $NumJobs = @(Get-Job -State 'Running').Count + } + + foreach ($Job in @(Get-Job -State 'Completed')) { + $jobResult = Wait-Job -Id $Job.Id | Receive-Job + CheckJobResult $jobResult.result $jobResult.packagePath ([ref]$ValidationFailures) -LogErrors + Remove-Job -Id $Job.Id + } + } + + foreach ($Job in @(Get-Job)) { + $jobResult = Wait-Job -Id $Job.Id | Receive-Job + CheckJobResult $jobResult.result $jobResult.packagePath ([ref]$ValidationFailures) + Remove-Job -Id $Job.Id + } + if ($ValidationFailures -gt 0) { + Write-PipelineTelemetryError -Category 'SourceLink' -Message "$ValidationFailures package(s) failed validation." + ExitWithExitCode 1 + } +} + +function InstallSourcelinkCli { + $sourcelinkCliPackageName = 'sourcelink' + + $dotnetRoot = InitializeDotNetCli -install:$true + $dotnet = "$dotnetRoot\dotnet.exe" + $toolList = & "$dotnet" tool list --global + + if (($toolList -like "*$sourcelinkCliPackageName*") -and ($toolList -like "*$sourcelinkCliVersion*")) { + Write-Host "SourceLink CLI version $sourcelinkCliVersion is already installed." + } + else { + Write-Host "Installing SourceLink CLI version $sourcelinkCliVersion..." + Write-Host 'You may need to restart your command window if this is the first dotnet tool you have installed.' + & "$dotnet" tool install $sourcelinkCliPackageName --version $sourcelinkCliVersion --verbosity "minimal" --global + } +} + +try { + InstallSourcelinkCli + + foreach ($Job in @(Get-Job)) { + Remove-Job -Id $Job.Id + } + + ValidateSourceLinkLinks +} +catch { + Write-Host $_.Exception + Write-Host $_.ScriptStackTrace + Write-PipelineTelemetryError -Category 'SourceLink' -Message $_ + ExitWithExitCode 1 +} diff --git a/eng/common/post-build/symbols-validation.ps1 b/eng/common/post-build/symbols-validation.ps1 new file mode 100644 index 00000000000000..cd2181bafa057d --- /dev/null +++ b/eng/common/post-build/symbols-validation.ps1 @@ -0,0 +1,339 @@ +param( + [Parameter(Mandatory = $true)][string] $InputPath, # Full path to directory where NuGet packages to be checked are stored + [Parameter(Mandatory = $true)][string] $ExtractPath, # Full path to directory where the packages will be extracted during validation + [Parameter(Mandatory = $true)][string] $DotnetSymbolVersion, # Version of dotnet symbol to use + [Parameter(Mandatory = $false)][switch] $CheckForWindowsPdbs, # If we should check for the existence of windows pdbs in addition to portable PDBs + [Parameter(Mandatory = $false)][switch] $ContinueOnError, # If we should keep checking symbols after an error + [Parameter(Mandatory = $false)][switch] $Clean, # Clean extracted symbols directory after checking symbols + [Parameter(Mandatory = $false)][string] $SymbolExclusionFile # Exclude the symbols in the file from publishing to symbol server +) + +. $PSScriptRoot\..\tools.ps1 +# Maximum number of jobs to run in parallel +$MaxParallelJobs = 16 + +# Max number of retries +$MaxRetry = 5 + +# Wait time between check for system load +$SecondsBetweenLoadChecks = 10 + +# Set error codes +Set-Variable -Name "ERROR_BADEXTRACT" -Option Constant -Value -1 +Set-Variable -Name "ERROR_FILEDOESNOTEXIST" -Option Constant -Value -2 + +$WindowsPdbVerificationParam = "" +if ($CheckForWindowsPdbs) { + $WindowsPdbVerificationParam = "--windows-pdbs" +} + +$ExclusionSet = New-Object System.Collections.Generic.HashSet[string]; + +if (!$InputPath -or !(Test-Path $InputPath)){ + Write-Host "No symbols to validate." + ExitWithExitCode 0 +} + +#Check if the path exists +if ($SymbolExclusionFile -and (Test-Path $SymbolExclusionFile)){ + [string[]]$Exclusions = Get-Content "$SymbolExclusionFile" + $Exclusions | foreach { if($_ -and $_.Trim()){$ExclusionSet.Add($_)} } +} +else{ + Write-Host "Symbol Exclusion file does not exists. No symbols to exclude." +} + +$CountMissingSymbols = { + param( + [string] $PackagePath, # Path to a NuGet package + [string] $WindowsPdbVerificationParam # If we should check for the existence of windows pdbs in addition to portable PDBs + ) + + Add-Type -AssemblyName System.IO.Compression.FileSystem + + Write-Host "Validating $PackagePath " + + # Ensure input file exist + if (!(Test-Path $PackagePath)) { + Write-PipelineTaskError "Input file does not exist: $PackagePath" + return [pscustomobject]@{ + result = $using:ERROR_FILEDOESNOTEXIST + packagePath = $PackagePath + } + } + + # Extensions for which we'll look for symbols + $RelevantExtensions = @('.dll', '.exe', '.so', '.dylib') + + # How many files are missing symbol information + $MissingSymbols = 0 + + $PackageId = [System.IO.Path]::GetFileNameWithoutExtension($PackagePath) + $PackageGuid = New-Guid + $ExtractPath = Join-Path -Path $using:ExtractPath -ChildPath $PackageGuid + $SymbolsPath = Join-Path -Path $ExtractPath -ChildPath 'Symbols' + + try { + [System.IO.Compression.ZipFile]::ExtractToDirectory($PackagePath, $ExtractPath) + } + catch { + Write-Host "Something went wrong extracting $PackagePath" + Write-Host $_ + return [pscustomobject]@{ + result = $using:ERROR_BADEXTRACT + packagePath = $PackagePath + } + } + + Get-ChildItem -Recurse $ExtractPath | + Where-Object { $RelevantExtensions -contains $_.Extension } | + ForEach-Object { + $FileName = $_.FullName + if ($FileName -Match '\\ref\\') { + Write-Host "`t Ignoring reference assembly file " $FileName + return + } + + $FirstMatchingSymbolDescriptionOrDefault = { + param( + [string] $FullPath, # Full path to the module that has to be checked + [string] $TargetServerParam, # Parameter to pass to `Symbol Tool` indicating the server to lookup for symbols + [string] $WindowsPdbVerificationParam, # Parameter to pass to potential check for windows-pdbs. + [string] $SymbolsPath + ) + + $FileName = [System.IO.Path]::GetFileName($FullPath) + $Extension = [System.IO.Path]::GetExtension($FullPath) + + # Those below are potential symbol files that the `dotnet symbol` might + # return. Which one will be returned depend on the type of file we are + # checking and which type of file was uploaded. + + # The file itself is returned + $SymbolPath = $SymbolsPath + '\' + $FileName + + # PDB file for the module + $PdbPath = $SymbolPath.Replace($Extension, '.pdb') + + # PDB file for R2R module (created by crossgen) + $NGenPdb = $SymbolPath.Replace($Extension, '.ni.pdb') + + # DBG file for a .so library + $SODbg = $SymbolPath.Replace($Extension, '.so.dbg') + + # DWARF file for a .dylib + $DylibDwarf = $SymbolPath.Replace($Extension, '.dylib.dwarf') + + $dotnetSymbolExe = "$env:USERPROFILE\.dotnet\tools" + $dotnetSymbolExe = Resolve-Path "$dotnetSymbolExe\dotnet-symbol.exe" + + $totalRetries = 0 + + while ($totalRetries -lt $using:MaxRetry) { + + # Save the output and get diagnostic output + $output = & $dotnetSymbolExe --symbols --modules $WindowsPdbVerificationParam $TargetServerParam $FullPath -o $SymbolsPath --diagnostics | Out-String + + if ((Test-Path $PdbPath) -and (Test-path $SymbolPath)) { + return 'Module and PDB for Module' + } + elseif ((Test-Path $NGenPdb) -and (Test-Path $PdbPath) -and (Test-Path $SymbolPath)) { + return 'Dll, PDB and NGen PDB' + } + elseif ((Test-Path $SODbg) -and (Test-Path $SymbolPath)) { + return 'So and DBG for SO' + } + elseif ((Test-Path $DylibDwarf) -and (Test-Path $SymbolPath)) { + return 'Dylib and Dwarf for Dylib' + } + elseif (Test-Path $SymbolPath) { + return 'Module' + } + else + { + $totalRetries++ + } + } + + return $null + } + + $FileRelativePath = $FileName.Replace("$ExtractPath\", "") + if (($($using:ExclusionSet) -ne $null) -and ($($using:ExclusionSet).Contains($FileRelativePath) -or ($($using:ExclusionSet).Contains($FileRelativePath.Replace("\", "/"))))){ + Write-Host "Skipping $FileName from symbol validation" + } + + else { + $FileGuid = New-Guid + $ExpandedSymbolsPath = Join-Path -Path $SymbolsPath -ChildPath $FileGuid + + $SymbolsOnMSDL = & $FirstMatchingSymbolDescriptionOrDefault ` + -FullPath $FileName ` + -TargetServerParam '--microsoft-symbol-server' ` + -SymbolsPath "$ExpandedSymbolsPath-msdl" ` + -WindowsPdbVerificationParam $WindowsPdbVerificationParam + $SymbolsOnSymWeb = & $FirstMatchingSymbolDescriptionOrDefault ` + -FullPath $FileName ` + -TargetServerParam '--internal-server' ` + -SymbolsPath "$ExpandedSymbolsPath-symweb" ` + -WindowsPdbVerificationParam $WindowsPdbVerificationParam + + Write-Host -NoNewLine "`t Checking file " $FileName "... " + + if ($SymbolsOnMSDL -ne $null -and $SymbolsOnSymWeb -ne $null) { + Write-Host "Symbols found on MSDL ($SymbolsOnMSDL) and SymWeb ($SymbolsOnSymWeb)" + } + else { + $MissingSymbols++ + + if ($SymbolsOnMSDL -eq $null -and $SymbolsOnSymWeb -eq $null) { + Write-Host 'No symbols found on MSDL or SymWeb!' + } + else { + if ($SymbolsOnMSDL -eq $null) { + Write-Host 'No symbols found on MSDL!' + } + else { + Write-Host 'No symbols found on SymWeb!' + } + } + } + } + } + + if ($using:Clean) { + Remove-Item $ExtractPath -Recurse -Force + } + + Pop-Location + + return [pscustomobject]@{ + result = $MissingSymbols + packagePath = $PackagePath + } +} + +function CheckJobResult( + $result, + $packagePath, + [ref]$DupedSymbols, + [ref]$TotalFailures) { + if ($result -eq $ERROR_BADEXTRACT) { + Write-PipelineTelemetryError -Category 'CheckSymbols' -Message "$packagePath has duplicated symbol files" + $DupedSymbols.Value++ + } + elseif ($result -eq $ERROR_FILEDOESNOTEXIST) { + Write-PipelineTelemetryError -Category 'CheckSymbols' -Message "$packagePath does not exist" + $TotalFailures.Value++ + } + elseif ($result -gt '0') { + Write-PipelineTelemetryError -Category 'CheckSymbols' -Message "Missing symbols for $result modules in the package $packagePath" + $TotalFailures.Value++ + } + else { + Write-Host "All symbols verified for package $packagePath" + } +} + +function CheckSymbolsAvailable { + if (Test-Path $ExtractPath) { + Remove-Item $ExtractPath -Force -Recurse -ErrorAction SilentlyContinue + } + + $TotalPackages = 0 + $TotalFailures = 0 + $DupedSymbols = 0 + + Get-ChildItem "$InputPath\*.nupkg" | + ForEach-Object { + $FileName = $_.Name + $FullName = $_.FullName + + # These packages from Arcade-Services include some native libraries that + # our current symbol uploader can't handle. Below is a workaround until + # we get issue: https://github.com/dotnet/arcade/issues/2457 sorted. + if ($FileName -Match 'Microsoft\.DotNet\.Darc\.') { + Write-Host "Ignoring Arcade-services file: $FileName" + Write-Host + return + } + elseif ($FileName -Match 'Microsoft\.DotNet\.Maestro\.Tasks\.') { + Write-Host "Ignoring Arcade-services file: $FileName" + Write-Host + return + } + + $TotalPackages++ + + Start-Job -ScriptBlock $CountMissingSymbols -ArgumentList @($FullName,$WindowsPdbVerificationParam) | Out-Null + + $NumJobs = @(Get-Job -State 'Running').Count + + while ($NumJobs -ge $MaxParallelJobs) { + Write-Host "There are $NumJobs validation jobs running right now. Waiting $SecondsBetweenLoadChecks seconds to check again." + sleep $SecondsBetweenLoadChecks + $NumJobs = @(Get-Job -State 'Running').Count + } + + foreach ($Job in @(Get-Job -State 'Completed')) { + $jobResult = Wait-Job -Id $Job.Id | Receive-Job + CheckJobResult $jobResult.result $jobResult.packagePath ([ref]$DupedSymbols) ([ref]$TotalFailures) + Remove-Job -Id $Job.Id + } + Write-Host + } + + foreach ($Job in @(Get-Job)) { + $jobResult = Wait-Job -Id $Job.Id | Receive-Job + CheckJobResult $jobResult.result $jobResult.packagePath ([ref]$DupedSymbols) ([ref]$TotalFailures) + } + + if ($TotalFailures -gt 0 -or $DupedSymbols -gt 0) { + if ($TotalFailures -gt 0) { + Write-PipelineTelemetryError -Category 'CheckSymbols' -Message "Symbols missing for $TotalFailures/$TotalPackages packages" + } + + if ($DupedSymbols -gt 0) { + Write-PipelineTelemetryError -Category 'CheckSymbols' -Message "$DupedSymbols/$TotalPackages packages had duplicated symbol files and could not be extracted" + } + + ExitWithExitCode 1 + } + else { + Write-Host "All symbols validated!" + } +} + +function InstallDotnetSymbol { + $dotnetSymbolPackageName = 'dotnet-symbol' + + $dotnetRoot = InitializeDotNetCli -install:$true + $dotnet = "$dotnetRoot\dotnet.exe" + $toolList = & "$dotnet" tool list --global + + if (($toolList -like "*$dotnetSymbolPackageName*") -and ($toolList -like "*$dotnetSymbolVersion*")) { + Write-Host "dotnet-symbol version $dotnetSymbolVersion is already installed." + } + else { + Write-Host "Installing dotnet-symbol version $dotnetSymbolVersion..." + Write-Host 'You may need to restart your command window if this is the first dotnet tool you have installed.' + & "$dotnet" tool install $dotnetSymbolPackageName --version $dotnetSymbolVersion --verbosity "minimal" --global + } +} + +try { + . $PSScriptRoot\post-build-utils.ps1 + + InstallDotnetSymbol + + foreach ($Job in @(Get-Job)) { + Remove-Job -Id $Job.Id + } + + CheckSymbolsAvailable +} +catch { + Write-Host $_.ScriptStackTrace + Write-PipelineTelemetryError -Category 'CheckSymbols' -Message $_ + ExitWithExitCode 1 +} diff --git a/eng/common/post-build/trigger-subscriptions.ps1 b/eng/common/post-build/trigger-subscriptions.ps1 new file mode 100644 index 00000000000000..55dea518ac5850 --- /dev/null +++ b/eng/common/post-build/trigger-subscriptions.ps1 @@ -0,0 +1,64 @@ +param( + [Parameter(Mandatory=$true)][string] $SourceRepo, + [Parameter(Mandatory=$true)][int] $ChannelId, + [Parameter(Mandatory=$true)][string] $MaestroApiAccessToken, + [Parameter(Mandatory=$false)][string] $MaestroApiEndPoint = 'https://maestro-prod.westus2.cloudapp.azure.com', + [Parameter(Mandatory=$false)][string] $MaestroApiVersion = '2019-01-16' +) + +try { + . $PSScriptRoot\post-build-utils.ps1 + + # Get all the $SourceRepo subscriptions + $normalizedSourceRepo = $SourceRepo.Replace('dnceng@', '') + $subscriptions = Get-MaestroSubscriptions -SourceRepository $normalizedSourceRepo -ChannelId $ChannelId + + if (!$subscriptions) { + Write-PipelineTelemetryError -Category 'TriggerSubscriptions' -Message "No subscriptions found for source repo '$normalizedSourceRepo' in channel '$ChannelId'" + ExitWithExitCode 0 + } + + $subscriptionsToTrigger = New-Object System.Collections.Generic.List[string] + $failedTriggeredSubscription = $false + + # Get all enabled subscriptions that need dependency flow on 'everyBuild' + foreach ($subscription in $subscriptions) { + if ($subscription.enabled -and $subscription.policy.updateFrequency -like 'everyBuild' -and $subscription.channel.id -eq $ChannelId) { + Write-Host "Should trigger this subscription: ${$subscription.id}" + [void]$subscriptionsToTrigger.Add($subscription.id) + } + } + + foreach ($subscriptionToTrigger in $subscriptionsToTrigger) { + try { + Write-Host "Triggering subscription '$subscriptionToTrigger'." + + Trigger-Subscription -SubscriptionId $subscriptionToTrigger + + Write-Host 'done.' + } + catch + { + Write-Host "There was an error while triggering subscription '$subscriptionToTrigger'" + Write-Host $_ + Write-Host $_.ScriptStackTrace + $failedTriggeredSubscription = $true + } + } + + if ($subscriptionsToTrigger.Count -eq 0) { + Write-Host "No subscription matched source repo '$normalizedSourceRepo' and channel ID '$ChannelId'." + } + elseif ($failedTriggeredSubscription) { + Write-PipelineTelemetryError -Category 'TriggerSubscriptions' -Message 'At least one subscription failed to be triggered...' + ExitWithExitCode 1 + } + else { + Write-Host 'All subscriptions were triggered successfully!' + } +} +catch { + Write-Host $_.ScriptStackTrace + Write-PipelineTelemetryError -Category 'TriggerSubscriptions' -Message $_ + ExitWithExitCode 1 +} diff --git a/eng/common/retain-build.ps1 b/eng/common/retain-build.ps1 new file mode 100644 index 00000000000000..e7ba975adeb6b1 --- /dev/null +++ b/eng/common/retain-build.ps1 @@ -0,0 +1,45 @@ + +Param( +[Parameter(Mandatory=$true)][int] $buildId, +[Parameter(Mandatory=$true)][string] $azdoOrgUri, +[Parameter(Mandatory=$true)][string] $azdoProject, +[Parameter(Mandatory=$true)][string] $token +) + +$ErrorActionPreference = 'Stop' +Set-StrictMode -Version 2.0 + +function Get-AzDOHeaders( + [string] $token) +{ + $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":${token}")) + $headers = @{"Authorization"="Basic $base64AuthInfo"} + return $headers +} + +function Update-BuildRetention( + [string] $azdoOrgUri, + [string] $azdoProject, + [int] $buildId, + [string] $token) +{ + $headers = Get-AzDOHeaders -token $token + $requestBody = "{ + `"keepForever`": `"true`" + }" + + $requestUri = "${azdoOrgUri}/${azdoProject}/_apis/build/builds/${buildId}?api-version=6.0" + write-Host "Attempting to retain build using the following URI: ${requestUri} ..." + + try { + Invoke-RestMethod -Uri $requestUri -Method Patch -Body $requestBody -Header $headers -contentType "application/json" + Write-Host "Updated retention settings for build ${buildId}." + } + catch { + Write-Error "Failed to update retention settings for build: $_.Exception.Response.StatusDescription" + exit 1 + } +} + +Update-BuildRetention -azdoOrgUri $azdoOrgUri -azdoProject $azdoProject -buildId $buildId -token $token +exit 0 diff --git a/eng/common/sdk-task.ps1 b/eng/common/sdk-task.ps1 new file mode 100644 index 00000000000000..e10a5968797463 --- /dev/null +++ b/eng/common/sdk-task.ps1 @@ -0,0 +1,97 @@ +[CmdletBinding(PositionalBinding=$false)] +Param( + [string] $configuration = 'Debug', + [string] $task, + [string] $verbosity = 'minimal', + [string] $msbuildEngine = $null, + [switch] $restore, + [switch] $prepareMachine, + [switch] $help, + [Parameter(ValueFromRemainingArguments=$true)][String[]]$properties +) + +$ci = $true +$binaryLog = $true +$warnAsError = $true + +. $PSScriptRoot\tools.ps1 + +function Print-Usage() { + Write-Host "Common settings:" + Write-Host " -task Name of Arcade task (name of a project in SdkTasks directory of the Arcade SDK package)" + Write-Host " -restore Restore dependencies" + Write-Host " -verbosity Msbuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]" + Write-Host " -help Print help and exit" + Write-Host "" + + Write-Host "Advanced settings:" + Write-Host " -prepareMachine Prepare machine for CI run" + Write-Host " -msbuildEngine Msbuild engine to use to run build ('dotnet', 'vs', or unspecified)." + Write-Host "" + Write-Host "Command line arguments not listed above are passed thru to msbuild." +} + +function Build([string]$target) { + $logSuffix = if ($target -eq 'Execute') { '' } else { ".$target" } + $log = Join-Path $LogDir "$task$logSuffix.binlog" + $outputPath = Join-Path $ToolsetDir "$task\" + + MSBuild $taskProject ` + /bl:$log ` + /t:$target ` + /p:Configuration=$configuration ` + /p:RepoRoot=$RepoRoot ` + /p:BaseIntermediateOutputPath=$outputPath ` + /v:$verbosity ` + @properties +} + +try { + if ($help -or (($null -ne $properties) -and ($properties.Contains('/help') -or $properties.Contains('/?')))) { + Print-Usage + exit 0 + } + + if ($task -eq "") { + Write-PipelineTelemetryError -Category 'Build' -Message "Missing required parameter '-task '" + Print-Usage + ExitWithExitCode 1 + } + + if( $msbuildEngine -eq "vs") { + # Ensure desktop MSBuild is available for sdk tasks. + if( -not ($GlobalJson.tools.PSObject.Properties.Name -contains "vs" )) { + $GlobalJson.tools | Add-Member -Name "vs" -Value (ConvertFrom-Json "{ `"version`": `"16.5`" }") -MemberType NoteProperty + } + if( -not ($GlobalJson.tools.PSObject.Properties.Name -match "xcopy-msbuild" )) { + $GlobalJson.tools | Add-Member -Name "xcopy-msbuild" -Value "17.4.1" -MemberType NoteProperty + } + if ($GlobalJson.tools."xcopy-msbuild".Trim() -ine "none") { + $xcopyMSBuildToolsFolder = InitializeXCopyMSBuild $GlobalJson.tools."xcopy-msbuild" -install $true + } + if ($xcopyMSBuildToolsFolder -eq $null) { + throw 'Unable to get xcopy downloadable version of msbuild' + } + + $global:_MSBuildExe = "$($xcopyMSBuildToolsFolder)\MSBuild\Current\Bin\MSBuild.exe" + } + + $taskProject = GetSdkTaskProject $task + if (!(Test-Path $taskProject)) { + Write-PipelineTelemetryError -Category 'Build' -Message "Unknown task: $task" + ExitWithExitCode 1 + } + + if ($restore) { + Build 'Restore' + } + + Build 'Execute' +} +catch { + Write-Host $_.ScriptStackTrace + Write-PipelineTelemetryError -Category 'Build' -Message $_ + ExitWithExitCode 1 +} + +ExitWithExitCode 0 diff --git a/eng/common/sdl/NuGet.config b/eng/common/sdl/NuGet.config new file mode 100644 index 00000000000000..3849bdb3cf51e8 --- /dev/null +++ b/eng/common/sdl/NuGet.config @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/eng/common/sdl/configure-sdl-tool.ps1 b/eng/common/sdl/configure-sdl-tool.ps1 new file mode 100644 index 00000000000000..bdbf49e6c71de8 --- /dev/null +++ b/eng/common/sdl/configure-sdl-tool.ps1 @@ -0,0 +1,116 @@ +Param( + [string] $GuardianCliLocation, + [string] $WorkingDirectory, + [string] $TargetDirectory, + [string] $GdnFolder, + # The list of Guardian tools to configure. For each object in the array: + # - If the item is a [hashtable], it must contain these entries: + # - Name = The tool name as Guardian knows it. + # - Scenario = (Optional) Scenario-specific name for this configuration entry. It must be unique + # among all tool entries with the same Name. + # - Args = (Optional) Array of Guardian tool configuration args, like '@("Target > C:\temp")' + # - If the item is a [string] $v, it is treated as '@{ Name="$v" }' + [object[]] $ToolsList, + [string] $GuardianLoggerLevel='Standard', + # Optional: Additional params to add to any tool using CredScan. + [string[]] $CrScanAdditionalRunConfigParams, + # Optional: Additional params to add to any tool using PoliCheck. + [string[]] $PoliCheckAdditionalRunConfigParams, + # Optional: Additional params to add to any tool using CodeQL/Semmle. + [string[]] $CodeQLAdditionalRunConfigParams +) + +$ErrorActionPreference = 'Stop' +Set-StrictMode -Version 2.0 +$disableConfigureToolsetImport = $true +$global:LASTEXITCODE = 0 + +try { + # `tools.ps1` checks $ci to perform some actions. Since the SDL + # scripts don't necessarily execute in the same agent that run the + # build.ps1/sh script this variable isn't automatically set. + $ci = $true + . $PSScriptRoot\..\tools.ps1 + + # Normalize tools list: all in [hashtable] form with defined values for each key. + $ToolsList = $ToolsList | + ForEach-Object { + if ($_ -is [string]) { + $_ = @{ Name = $_ } + } + + if (-not ($_['Scenario'])) { $_.Scenario = "" } + if (-not ($_['Args'])) { $_.Args = @() } + $_ + } + + Write-Host "List of tools to configure:" + $ToolsList | ForEach-Object { $_ | Out-String | Write-Host } + + # We store config files in the r directory of .gdn + $gdnConfigPath = Join-Path $GdnFolder 'r' + $ValidPath = Test-Path $GuardianCliLocation + + if ($ValidPath -eq $False) + { + Write-PipelineTelemetryError -Force -Category 'Sdl' -Message "Invalid Guardian CLI Location." + ExitWithExitCode 1 + } + + foreach ($tool in $ToolsList) { + # Put together the name and scenario to make a unique key. + $toolConfigName = $tool.Name + if ($tool.Scenario) { + $toolConfigName += "_" + $tool.Scenario + } + + Write-Host "=== Configuring $toolConfigName..." + + $gdnConfigFile = Join-Path $gdnConfigPath "$toolConfigName-configure.gdnconfig" + + # For some tools, add default and automatic args. + if ($tool.Name -eq 'credscan') { + if ($targetDirectory) { + $tool.Args += "`"TargetDirectory < $TargetDirectory`"" + } + $tool.Args += "`"OutputType < pre`"" + $tool.Args += $CrScanAdditionalRunConfigParams + } elseif ($tool.Name -eq 'policheck') { + if ($targetDirectory) { + $tool.Args += "`"Target < $TargetDirectory`"" + } + $tool.Args += $PoliCheckAdditionalRunConfigParams + } elseif ($tool.Name -eq 'semmle' -or $tool.Name -eq 'codeql') { + if ($targetDirectory) { + $tool.Args += "`"SourceCodeDirectory < $TargetDirectory`"" + } + $tool.Args += $CodeQLAdditionalRunConfigParams + } + + # Create variable pointing to the args array directly so we can use splat syntax later. + $toolArgs = $tool.Args + + # Configure the tool. If args array is provided or the current tool has some default arguments + # defined, add "--args" and splat each element on the end. Arg format is "{Arg id} < {Value}", + # one per parameter. Doc page for "guardian configure": + # https://dev.azure.com/securitytools/SecurityIntegration/_wiki/wikis/Guardian/1395/configure + Exec-BlockVerbosely { + & $GuardianCliLocation configure ` + --working-directory $WorkingDirectory ` + --tool $tool.Name ` + --output-path $gdnConfigFile ` + --logger-level $GuardianLoggerLevel ` + --noninteractive ` + --force ` + $(if ($toolArgs) { "--args" }) @toolArgs + Exit-IfNZEC "Sdl" + } + + Write-Host "Created '$toolConfigName' configuration file: $gdnConfigFile" + } +} +catch { + Write-Host $_.ScriptStackTrace + Write-PipelineTelemetryError -Force -Category 'Sdl' -Message $_ + ExitWithExitCode 1 +} diff --git a/eng/common/sdl/execute-all-sdl-tools.ps1 b/eng/common/sdl/execute-all-sdl-tools.ps1 new file mode 100644 index 00000000000000..4797e012c7d2f7 --- /dev/null +++ b/eng/common/sdl/execute-all-sdl-tools.ps1 @@ -0,0 +1,165 @@ +Param( + [string] $GuardianPackageName, # Required: the name of guardian CLI package (not needed if GuardianCliLocation is specified) + [string] $NugetPackageDirectory, # Required: directory where NuGet packages are installed (not needed if GuardianCliLocation is specified) + [string] $GuardianCliLocation, # Optional: Direct location of Guardian CLI executable if GuardianPackageName & NugetPackageDirectory are not specified + [string] $Repository=$env:BUILD_REPOSITORY_NAME, # Required: the name of the repository (e.g. dotnet/arcade) + [string] $BranchName=$env:BUILD_SOURCEBRANCH, # Optional: name of branch or version of gdn settings; defaults to master + [string] $SourceDirectory=$env:BUILD_SOURCESDIRECTORY, # Required: the directory where source files are located + [string] $ArtifactsDirectory = (Join-Path $env:BUILD_ARTIFACTSTAGINGDIRECTORY ('artifacts')), # Required: the directory where build artifacts are located + [string] $AzureDevOpsAccessToken, # Required: access token for dnceng; should be provided via KeyVault + + # Optional: list of SDL tools to run on source code. See 'configure-sdl-tool.ps1' for tools list + # format. + [object[]] $SourceToolsList, + # Optional: list of SDL tools to run on built artifacts. See 'configure-sdl-tool.ps1' for tools + # list format. + [object[]] $ArtifactToolsList, + # Optional: list of SDL tools to run without automatically specifying a target directory. See + # 'configure-sdl-tool.ps1' for tools list format. + [object[]] $CustomToolsList, + + [bool] $TsaPublish=$False, # Optional: true will publish results to TSA; only set to true after onboarding to TSA; TSA is the automated framework used to upload test results as bugs. + [string] $TsaBranchName=$env:BUILD_SOURCEBRANCH, # Optional: required for TSA publish; defaults to $(Build.SourceBranchName); TSA is the automated framework used to upload test results as bugs. + [string] $TsaRepositoryName=$env:BUILD_REPOSITORY_NAME, # Optional: TSA repository name; will be generated automatically if not submitted; TSA is the automated framework used to upload test results as bugs. + [string] $BuildNumber=$env:BUILD_BUILDNUMBER, # Optional: required for TSA publish; defaults to $(Build.BuildNumber) + [bool] $UpdateBaseline=$False, # Optional: if true, will update the baseline in the repository; should only be run after fixing any issues which need to be fixed + [bool] $TsaOnboard=$False, # Optional: if true, will onboard the repository to TSA; should only be run once; TSA is the automated framework used to upload test results as bugs. + [string] $TsaInstanceUrl, # Optional: only needed if TsaOnboard or TsaPublish is true; the instance-url registered with TSA; TSA is the automated framework used to upload test results as bugs. + [string] $TsaCodebaseName, # Optional: only needed if TsaOnboard or TsaPublish is true; the name of the codebase registered with TSA; TSA is the automated framework used to upload test results as bugs. + [string] $TsaProjectName, # Optional: only needed if TsaOnboard or TsaPublish is true; the name of the project registered with TSA; TSA is the automated framework used to upload test results as bugs. + [string] $TsaNotificationEmail, # Optional: only needed if TsaOnboard is true; the email(s) which will receive notifications of TSA bug filings (e.g. alias@microsoft.com); TSA is the automated framework used to upload test results as bugs. + [string] $TsaCodebaseAdmin, # Optional: only needed if TsaOnboard is true; the aliases which are admins of the TSA codebase (e.g. DOMAIN\alias); TSA is the automated framework used to upload test results as bugs. + [string] $TsaBugAreaPath, # Optional: only needed if TsaOnboard is true; the area path where TSA will file bugs in AzDO; TSA is the automated framework used to upload test results as bugs. + [string] $TsaIterationPath, # Optional: only needed if TsaOnboard is true; the iteration path where TSA will file bugs in AzDO; TSA is the automated framework used to upload test results as bugs. + [string] $GuardianLoggerLevel='Standard', # Optional: the logger level for the Guardian CLI; options are Trace, Verbose, Standard, Warning, and Error + [string[]] $CrScanAdditionalRunConfigParams, # Optional: Additional Params to custom build a CredScan run config in the format @("xyz:abc","sdf:1") + [string[]] $PoliCheckAdditionalRunConfigParams, # Optional: Additional Params to custom build a Policheck run config in the format @("xyz:abc","sdf:1") + [string[]] $CodeQLAdditionalRunConfigParams, # Optional: Additional Params to custom build a Semmle/CodeQL run config in the format @("xyz < abc","sdf < 1") + [bool] $BreakOnFailure=$False # Optional: Fail the build if there were errors during the run +) + +try { + $ErrorActionPreference = 'Stop' + Set-StrictMode -Version 2.0 + $disableConfigureToolsetImport = $true + $global:LASTEXITCODE = 0 + + # `tools.ps1` checks $ci to perform some actions. Since the SDL + # scripts don't necessarily execute in the same agent that run the + # build.ps1/sh script this variable isn't automatically set. + $ci = $true + . $PSScriptRoot\..\tools.ps1 + + #Replace repo names to the format of org/repo + if (!($Repository.contains('/'))) { + $RepoName = $Repository -replace '(.*?)-(.*)', '$1/$2'; + } + else{ + $RepoName = $Repository; + } + + if ($GuardianPackageName) { + $guardianCliLocation = Join-Path $NugetPackageDirectory (Join-Path $GuardianPackageName (Join-Path 'tools' 'guardian.cmd')) + } else { + $guardianCliLocation = $GuardianCliLocation + } + + $workingDirectory = (Split-Path $SourceDirectory -Parent) + $ValidPath = Test-Path $guardianCliLocation + + if ($ValidPath -eq $False) + { + Write-PipelineTelemetryError -Force -Category 'Sdl' -Message 'Invalid Guardian CLI Location.' + ExitWithExitCode 1 + } + + Exec-BlockVerbosely { + & $(Join-Path $PSScriptRoot 'init-sdl.ps1') -GuardianCliLocation $guardianCliLocation -Repository $RepoName -BranchName $BranchName -WorkingDirectory $workingDirectory -AzureDevOpsAccessToken $AzureDevOpsAccessToken -GuardianLoggerLevel $GuardianLoggerLevel + } + $gdnFolder = Join-Path $workingDirectory '.gdn' + + if ($TsaOnboard) { + if ($TsaCodebaseName -and $TsaNotificationEmail -and $TsaCodebaseAdmin -and $TsaBugAreaPath) { + Exec-BlockVerbosely { + & $guardianCliLocation tsa-onboard --codebase-name "$TsaCodebaseName" --notification-alias "$TsaNotificationEmail" --codebase-admin "$TsaCodebaseAdmin" --instance-url "$TsaInstanceUrl" --project-name "$TsaProjectName" --area-path "$TsaBugAreaPath" --iteration-path "$TsaIterationPath" --working-directory $workingDirectory --logger-level $GuardianLoggerLevel + } + if ($LASTEXITCODE -ne 0) { + Write-PipelineTelemetryError -Force -Category 'Sdl' -Message "Guardian tsa-onboard failed with exit code $LASTEXITCODE." + ExitWithExitCode $LASTEXITCODE + } + } else { + Write-PipelineTelemetryError -Force -Category 'Sdl' -Message 'Could not onboard to TSA -- not all required values ($TsaCodebaseName, $TsaNotificationEmail, $TsaCodebaseAdmin, $TsaBugAreaPath) were specified.' + ExitWithExitCode 1 + } + } + + # Configure a list of tools with a default target directory. Populates the ".gdn/r" directory. + function Configure-ToolsList([object[]] $tools, [string] $targetDirectory) { + if ($tools -and $tools.Count -gt 0) { + Exec-BlockVerbosely { + & $(Join-Path $PSScriptRoot 'configure-sdl-tool.ps1') ` + -GuardianCliLocation $guardianCliLocation ` + -WorkingDirectory $workingDirectory ` + -TargetDirectory $targetDirectory ` + -GdnFolder $gdnFolder ` + -ToolsList $tools ` + -AzureDevOpsAccessToken $AzureDevOpsAccessToken ` + -GuardianLoggerLevel $GuardianLoggerLevel ` + -CrScanAdditionalRunConfigParams $CrScanAdditionalRunConfigParams ` + -PoliCheckAdditionalRunConfigParams $PoliCheckAdditionalRunConfigParams ` + -CodeQLAdditionalRunConfigParams $CodeQLAdditionalRunConfigParams + if ($BreakOnFailure) { + Exit-IfNZEC "Sdl" + } + } + } + } + + # Configure Artifact and Source tools with default Target directories. + Configure-ToolsList $ArtifactToolsList $ArtifactsDirectory + Configure-ToolsList $SourceToolsList $SourceDirectory + # Configure custom tools with no default Target directory. + Configure-ToolsList $CustomToolsList $null + + # At this point, all tools are configured in the ".gdn" directory. Run them all in a single call. + # (If we used "run" multiple times, each run would overwrite data from earlier runs.) + Exec-BlockVerbosely { + & $(Join-Path $PSScriptRoot 'run-sdl.ps1') ` + -GuardianCliLocation $guardianCliLocation ` + -WorkingDirectory $SourceDirectory ` + -UpdateBaseline $UpdateBaseline ` + -GdnFolder $gdnFolder + } + + if ($TsaPublish) { + if ($TsaBranchName -and $BuildNumber) { + if (-not $TsaRepositoryName) { + $TsaRepositoryName = "$($Repository)-$($BranchName)" + } + Exec-BlockVerbosely { + & $guardianCliLocation tsa-publish --all-tools --repository-name "$TsaRepositoryName" --branch-name "$TsaBranchName" --build-number "$BuildNumber" --onboard $True --codebase-name "$TsaCodebaseName" --notification-alias "$TsaNotificationEmail" --codebase-admin "$TsaCodebaseAdmin" --instance-url "$TsaInstanceUrl" --project-name "$TsaProjectName" --area-path "$TsaBugAreaPath" --iteration-path "$TsaIterationPath" --working-directory $workingDirectory --logger-level $GuardianLoggerLevel + } + if ($LASTEXITCODE -ne 0) { + Write-PipelineTelemetryError -Force -Category 'Sdl' -Message "Guardian tsa-publish failed with exit code $LASTEXITCODE." + ExitWithExitCode $LASTEXITCODE + } + } else { + Write-PipelineTelemetryError -Force -Category 'Sdl' -Message 'Could not publish to TSA -- not all required values ($TsaBranchName, $BuildNumber) were specified.' + ExitWithExitCode 1 + } + } + + if ($BreakOnFailure) { + Write-Host "Failing the build in case of breaking results..." + Exec-BlockVerbosely { + & $guardianCliLocation break --working-directory $workingDirectory --logger-level $GuardianLoggerLevel + } + } else { + Write-Host "Letting the build pass even if there were breaking results..." + } +} +catch { + Write-Host $_.ScriptStackTrace + Write-PipelineTelemetryError -Force -Category 'Sdl' -Message $_ + exit 1 +} diff --git a/eng/common/sdl/extract-artifact-archives.ps1 b/eng/common/sdl/extract-artifact-archives.ps1 new file mode 100644 index 00000000000000..68da4fbf257171 --- /dev/null +++ b/eng/common/sdl/extract-artifact-archives.ps1 @@ -0,0 +1,63 @@ +# This script looks for each archive file in a directory and extracts it into the target directory. +# For example, the file "$InputPath/bin.tar.gz" extracts to "$ExtractPath/bin.tar.gz.extracted/**". +# Uses the "tar" utility added to Windows 10 / Windows 2019 that supports tar.gz and zip. +param( + # Full path to directory where archives are stored. + [Parameter(Mandatory=$true)][string] $InputPath, + # Full path to directory to extract archives into. May be the same as $InputPath. + [Parameter(Mandatory=$true)][string] $ExtractPath +) + +$ErrorActionPreference = 'Stop' +Set-StrictMode -Version 2.0 + +$disableConfigureToolsetImport = $true + +try { + # `tools.ps1` checks $ci to perform some actions. Since the SDL + # scripts don't necessarily execute in the same agent that run the + # build.ps1/sh script this variable isn't automatically set. + $ci = $true + . $PSScriptRoot\..\tools.ps1 + + Measure-Command { + $jobs = @() + + # Find archive files for non-Windows and Windows builds. + $archiveFiles = @( + Get-ChildItem (Join-Path $InputPath "*.tar.gz") + Get-ChildItem (Join-Path $InputPath "*.zip") + ) + + foreach ($targzFile in $archiveFiles) { + $jobs += Start-Job -ScriptBlock { + $file = $using:targzFile + $fileName = [System.IO.Path]::GetFileName($file) + $extractDir = Join-Path $using:ExtractPath "$fileName.extracted" + + New-Item $extractDir -ItemType Directory -Force | Out-Null + + Write-Host "Extracting '$file' to '$extractDir'..." + + # Pipe errors to stdout to prevent PowerShell detecting them and quitting the job early. + # This type of quit skips the catch, so we wouldn't be able to tell which file triggered the + # error. Save output so it can be stored in the exception string along with context. + $output = tar -xf $file -C $extractDir 2>&1 + # Handle NZEC manually rather than using Exit-IfNZEC: we are in a background job, so we + # don't have access to the outer scope. + if ($LASTEXITCODE -ne 0) { + throw "Error extracting '$file': non-zero exit code ($LASTEXITCODE). Output: '$output'" + } + + Write-Host "Extracted to $extractDir" + } + } + + Receive-Job $jobs -Wait + } +} +catch { + Write-Host $_ + Write-PipelineTelemetryError -Force -Category 'Sdl' -Message $_ + ExitWithExitCode 1 +} diff --git a/eng/common/sdl/extract-artifact-packages.ps1 b/eng/common/sdl/extract-artifact-packages.ps1 new file mode 100644 index 00000000000000..7f28d9c59ec69c --- /dev/null +++ b/eng/common/sdl/extract-artifact-packages.ps1 @@ -0,0 +1,80 @@ +param( + [Parameter(Mandatory=$true)][string] $InputPath, # Full path to directory where artifact packages are stored + [Parameter(Mandatory=$true)][string] $ExtractPath # Full path to directory where the packages will be extracted +) + +$ErrorActionPreference = 'Stop' +Set-StrictMode -Version 2.0 + +$disableConfigureToolsetImport = $true + +function ExtractArtifacts { + if (!(Test-Path $InputPath)) { + Write-Host "Input Path does not exist: $InputPath" + ExitWithExitCode 0 + } + $Jobs = @() + Get-ChildItem "$InputPath\*.nupkg" | + ForEach-Object { + $Jobs += Start-Job -ScriptBlock $ExtractPackage -ArgumentList $_.FullName + } + + foreach ($Job in $Jobs) { + Wait-Job -Id $Job.Id | Receive-Job + } +} + +try { + # `tools.ps1` checks $ci to perform some actions. Since the SDL + # scripts don't necessarily execute in the same agent that run the + # build.ps1/sh script this variable isn't automatically set. + $ci = $true + . $PSScriptRoot\..\tools.ps1 + + $ExtractPackage = { + param( + [string] $PackagePath # Full path to a NuGet package + ) + + if (!(Test-Path $PackagePath)) { + Write-PipelineTelemetryError -Category 'Build' -Message "Input file does not exist: $PackagePath" + ExitWithExitCode 1 + } + + $RelevantExtensions = @('.dll', '.exe', '.pdb') + Write-Host -NoNewLine 'Extracting ' ([System.IO.Path]::GetFileName($PackagePath)) '...' + + $PackageId = [System.IO.Path]::GetFileNameWithoutExtension($PackagePath) + $ExtractPath = Join-Path -Path $using:ExtractPath -ChildPath $PackageId + + Add-Type -AssemblyName System.IO.Compression.FileSystem + + [System.IO.Directory]::CreateDirectory($ExtractPath); + + try { + $zip = [System.IO.Compression.ZipFile]::OpenRead($PackagePath) + + $zip.Entries | + Where-Object {$RelevantExtensions -contains [System.IO.Path]::GetExtension($_.Name)} | + ForEach-Object { + $TargetFile = Join-Path -Path $ExtractPath -ChildPath $_.Name + + [System.IO.Compression.ZipFileExtensions]::ExtractToFile($_, $TargetFile, $true) + } + } + catch { + Write-Host $_ + Write-PipelineTelemetryError -Force -Category 'Sdl' -Message $_ + ExitWithExitCode 1 + } + finally { + $zip.Dispose() + } + } + Measure-Command { ExtractArtifacts } +} +catch { + Write-Host $_ + Write-PipelineTelemetryError -Force -Category 'Sdl' -Message $_ + ExitWithExitCode 1 +} diff --git a/eng/common/sdl/init-sdl.ps1 b/eng/common/sdl/init-sdl.ps1 new file mode 100644 index 00000000000000..3ac1d92b37006f --- /dev/null +++ b/eng/common/sdl/init-sdl.ps1 @@ -0,0 +1,55 @@ +Param( + [string] $GuardianCliLocation, + [string] $Repository, + [string] $BranchName='master', + [string] $WorkingDirectory, + [string] $AzureDevOpsAccessToken, + [string] $GuardianLoggerLevel='Standard' +) + +$ErrorActionPreference = 'Stop' +Set-StrictMode -Version 2.0 +$disableConfigureToolsetImport = $true +$global:LASTEXITCODE = 0 + +# `tools.ps1` checks $ci to perform some actions. Since the SDL +# scripts don't necessarily execute in the same agent that run the +# build.ps1/sh script this variable isn't automatically set. +$ci = $true +. $PSScriptRoot\..\tools.ps1 + +# Don't display the console progress UI - it's a huge perf hit +$ProgressPreference = 'SilentlyContinue' + +# Construct basic auth from AzDO access token; construct URI to the repository's gdn folder stored in that repository; construct location of zip file +$encodedPat = [Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$AzureDevOpsAccessToken")) +$escapedRepository = [Uri]::EscapeDataString("/$Repository/$BranchName/.gdn") +$uri = "https://dev.azure.com/dnceng/internal/_apis/git/repositories/sdl-tool-cfg/Items?path=$escapedRepository&versionDescriptor[versionOptions]=0&`$format=zip&api-version=5.0" +$zipFile = "$WorkingDirectory/gdn.zip" + +Add-Type -AssemblyName System.IO.Compression.FileSystem +$gdnFolder = (Join-Path $WorkingDirectory '.gdn') + +try { + # if the folder does not exist, we'll do a guardian init and push it to the remote repository + Write-Host 'Initializing Guardian...' + Write-Host "$GuardianCliLocation init --working-directory $WorkingDirectory --logger-level $GuardianLoggerLevel" + & $GuardianCliLocation init --working-directory $WorkingDirectory --logger-level $GuardianLoggerLevel + if ($LASTEXITCODE -ne 0) { + Write-PipelineTelemetryError -Force -Category 'Build' -Message "Guardian init failed with exit code $LASTEXITCODE." + ExitWithExitCode $LASTEXITCODE + } + # We create the mainbaseline so it can be edited later + Write-Host "$GuardianCliLocation baseline --working-directory $WorkingDirectory --name mainbaseline" + & $GuardianCliLocation baseline --working-directory $WorkingDirectory --name mainbaseline + if ($LASTEXITCODE -ne 0) { + Write-PipelineTelemetryError -Force -Category 'Build' -Message "Guardian baseline failed with exit code $LASTEXITCODE." + ExitWithExitCode $LASTEXITCODE + } + ExitWithExitCode 0 +} +catch { + Write-Host $_.ScriptStackTrace + Write-PipelineTelemetryError -Force -Category 'Sdl' -Message $_ + ExitWithExitCode 1 +} diff --git a/eng/common/sdl/packages.config b/eng/common/sdl/packages.config new file mode 100644 index 00000000000000..4585cfd6bba1ed --- /dev/null +++ b/eng/common/sdl/packages.config @@ -0,0 +1,4 @@ + + + + diff --git a/eng/common/sdl/run-sdl.ps1 b/eng/common/sdl/run-sdl.ps1 new file mode 100644 index 00000000000000..2eac8c78f103d1 --- /dev/null +++ b/eng/common/sdl/run-sdl.ps1 @@ -0,0 +1,49 @@ +Param( + [string] $GuardianCliLocation, + [string] $WorkingDirectory, + [string] $GdnFolder, + [string] $UpdateBaseline, + [string] $GuardianLoggerLevel='Standard' +) + +$ErrorActionPreference = 'Stop' +Set-StrictMode -Version 2.0 +$disableConfigureToolsetImport = $true +$global:LASTEXITCODE = 0 + +try { + # `tools.ps1` checks $ci to perform some actions. Since the SDL + # scripts don't necessarily execute in the same agent that run the + # build.ps1/sh script this variable isn't automatically set. + $ci = $true + . $PSScriptRoot\..\tools.ps1 + + # We store config files in the r directory of .gdn + $gdnConfigPath = Join-Path $GdnFolder 'r' + $ValidPath = Test-Path $GuardianCliLocation + + if ($ValidPath -eq $False) + { + Write-PipelineTelemetryError -Force -Category 'Sdl' -Message "Invalid Guardian CLI Location." + ExitWithExitCode 1 + } + + $gdnConfigFiles = Get-ChildItem $gdnConfigPath -Recurse -Include '*.gdnconfig' + Write-Host "Discovered Guardian config files:" + $gdnConfigFiles | Out-String | Write-Host + + Exec-BlockVerbosely { + & $GuardianCliLocation run ` + --working-directory $WorkingDirectory ` + --baseline mainbaseline ` + --update-baseline $UpdateBaseline ` + --logger-level $GuardianLoggerLevel ` + --config @gdnConfigFiles + Exit-IfNZEC "Sdl" + } +} +catch { + Write-Host $_.ScriptStackTrace + Write-PipelineTelemetryError -Force -Category 'Sdl' -Message $_ + ExitWithExitCode 1 +} diff --git a/eng/common/sdl/sdl.ps1 b/eng/common/sdl/sdl.ps1 new file mode 100644 index 00000000000000..648c5068d7d60f --- /dev/null +++ b/eng/common/sdl/sdl.ps1 @@ -0,0 +1,38 @@ + +function Install-Gdn { + param( + [Parameter(Mandatory=$true)] + [string]$Path, + + # If omitted, install the latest version of Guardian, otherwise install that specific version. + [string]$Version + ) + + $ErrorActionPreference = 'Stop' + Set-StrictMode -Version 2.0 + $disableConfigureToolsetImport = $true + $global:LASTEXITCODE = 0 + + # `tools.ps1` checks $ci to perform some actions. Since the SDL + # scripts don't necessarily execute in the same agent that run the + # build.ps1/sh script this variable isn't automatically set. + $ci = $true + . $PSScriptRoot\..\tools.ps1 + + $argumentList = @("install", "Microsoft.Guardian.Cli", "-Source https://securitytools.pkgs.visualstudio.com/_packaging/Guardian/nuget/v3/index.json", "-OutputDirectory $Path", "-NonInteractive", "-NoCache") + + if ($Version) { + $argumentList += "-Version $Version" + } + + Start-Process nuget -Verbose -ArgumentList $argumentList -NoNewWindow -Wait + + $gdnCliPath = Get-ChildItem -Filter guardian.cmd -Recurse -Path $Path + + if (!$gdnCliPath) + { + Write-PipelineTelemetryError -Category 'Sdl' -Message 'Failure installing Guardian' + } + + return $gdnCliPath.FullName +} \ No newline at end of file diff --git a/eng/common/templates/job/execute-sdl.yml b/eng/common/templates/job/execute-sdl.yml new file mode 100644 index 00000000000000..7aabaa18017bf6 --- /dev/null +++ b/eng/common/templates/job/execute-sdl.yml @@ -0,0 +1,134 @@ +parameters: + enable: 'false' # Whether the SDL validation job should execute or not + overrideParameters: '' # Optional: to override values for parameters. + additionalParameters: '' # Optional: parameters that need user specific values eg: '-SourceToolsList @("abc","def") -ArtifactToolsList @("ghi","jkl")' + # Optional: if specified, restore and use this version of Guardian instead of the default. + overrideGuardianVersion: '' + # Optional: if true, publish the '.gdn' folder as a pipeline artifact. This can help with in-depth + # diagnosis of problems with specific tool configurations. + publishGuardianDirectoryToPipeline: false + # The script to run to execute all SDL tools. Use this if you want to use a script to define SDL + # parameters rather than relying on YAML. It may be better to use a local script, because you can + # reproduce results locally without piecing together a command based on the YAML. + executeAllSdlToolsScript: 'eng/common/sdl/execute-all-sdl-tools.ps1' + # There is some sort of bug (has been reported) in Azure DevOps where if this parameter is named + # 'continueOnError', the parameter value is not correctly picked up. + # This can also be remedied by the caller (post-build.yml) if it does not use a nested parameter + sdlContinueOnError: false # optional: determines whether to continue the build if the step errors; + # optional: determines if build artifacts should be downloaded. + downloadArtifacts: true + # optional: determines if this job should search the directory of downloaded artifacts for + # 'tar.gz' and 'zip' archive files and extract them before running SDL validation tasks. + extractArchiveArtifacts: false + dependsOn: '' # Optional: dependencies of the job + artifactNames: '' # Optional: patterns supplied to DownloadBuildArtifacts + # Usage: + # artifactNames: + # - 'BlobArtifacts' + # - 'Artifacts_Windows_NT_Release' + # Optional: download a list of pipeline artifacts. 'downloadArtifacts' controls build artifacts, + # not pipeline artifacts, so doesn't affect the use of this parameter. + pipelineArtifactNames: [] + +jobs: +- job: Run_SDL + dependsOn: ${{ parameters.dependsOn }} + displayName: Run SDL tool + condition: and(succeededOrFailed(), eq( ${{ parameters.enable }}, 'true')) + variables: + - group: DotNet-VSTS-Bot + - name: AzDOProjectName + value: ${{ parameters.AzDOProjectName }} + - name: AzDOPipelineId + value: ${{ parameters.AzDOPipelineId }} + - name: AzDOBuildId + value: ${{ parameters.AzDOBuildId }} + - template: /eng/common/templates/variables/sdl-variables.yml + - name: GuardianVersion + value: ${{ coalesce(parameters.overrideGuardianVersion, '$(DefaultGuardianVersion)') }} + - template: /eng/common/templates/variables/pool-providers.yml + pool: + # We don't use the collection uri here because it might vary (.visualstudio.com vs. dev.azure.com) + ${{ if eq(variables['System.TeamProject'], 'DevDiv') }}: + name: VSEngSS-MicroBuild2022-1ES + demands: Cmd + # If it's not devdiv, it's dnceng + ${{ if ne(variables['System.TeamProject'], 'DevDiv') }}: + name: $(DncEngInternalBuildPool) + demands: ImageOverride -equals windows.vs2019.amd64 + steps: + - checkout: self + clean: true + + # If the template caller didn't provide an AzDO parameter, set them all up as Maestro vars. + - ${{ if not(and(parameters.AzDOProjectName, parameters.AzDOPipelineId, parameters.AzDOBuildId)) }}: + - template: /eng/common/templates/post-build/setup-maestro-vars.yml + + - ${{ if ne(parameters.downloadArtifacts, 'false')}}: + - ${{ if ne(parameters.artifactNames, '') }}: + - ${{ each artifactName in parameters.artifactNames }}: + - task: DownloadBuildArtifacts@0 + displayName: Download Build Artifacts + inputs: + buildType: specific + buildVersionToDownload: specific + project: $(AzDOProjectName) + pipeline: $(AzDOPipelineId) + buildId: $(AzDOBuildId) + artifactName: ${{ artifactName }} + downloadPath: $(Build.ArtifactStagingDirectory)\artifacts + checkDownloadedFiles: true + - ${{ if eq(parameters.artifactNames, '') }}: + - task: DownloadBuildArtifacts@0 + displayName: Download Build Artifacts + inputs: + buildType: specific + buildVersionToDownload: specific + project: $(AzDOProjectName) + pipeline: $(AzDOPipelineId) + buildId: $(AzDOBuildId) + downloadType: specific files + itemPattern: "**" + downloadPath: $(Build.ArtifactStagingDirectory)\artifacts + checkDownloadedFiles: true + + - ${{ each artifactName in parameters.pipelineArtifactNames }}: + - task: DownloadPipelineArtifact@2 + displayName: Download Pipeline Artifacts + inputs: + buildType: specific + buildVersionToDownload: specific + project: $(AzDOProjectName) + pipeline: $(AzDOPipelineId) + buildId: $(AzDOBuildId) + artifactName: ${{ artifactName }} + downloadPath: $(Build.ArtifactStagingDirectory)\artifacts + checkDownloadedFiles: true + + - powershell: eng/common/sdl/extract-artifact-packages.ps1 + -InputPath $(Build.ArtifactStagingDirectory)\artifacts\BlobArtifacts + -ExtractPath $(Build.ArtifactStagingDirectory)\artifacts\BlobArtifacts + displayName: Extract Blob Artifacts + continueOnError: ${{ parameters.sdlContinueOnError }} + + - powershell: eng/common/sdl/extract-artifact-packages.ps1 + -InputPath $(Build.ArtifactStagingDirectory)\artifacts\PackageArtifacts + -ExtractPath $(Build.ArtifactStagingDirectory)\artifacts\PackageArtifacts + displayName: Extract Package Artifacts + continueOnError: ${{ parameters.sdlContinueOnError }} + + - ${{ if ne(parameters.extractArchiveArtifacts, 'false') }}: + - powershell: eng/common/sdl/extract-artifact-archives.ps1 + -InputPath $(Build.ArtifactStagingDirectory)\artifacts + -ExtractPath $(Build.ArtifactStagingDirectory)\artifacts + displayName: Extract Archive Artifacts + continueOnError: ${{ parameters.sdlContinueOnError }} + + - template: /eng/common/templates/steps/execute-sdl.yml + parameters: + overrideGuardianVersion: ${{ parameters.overrideGuardianVersion }} + executeAllSdlToolsScript: ${{ parameters.executeAllSdlToolsScript }} + overrideParameters: ${{ parameters.overrideParameters }} + additionalParameters: ${{ parameters.additionalParameters }} + publishGuardianDirectoryToPipeline: ${{ parameters.publishGuardianDirectoryToPipeline }} + sdlContinueOnError: ${{ parameters.sdlContinueOnError }} diff --git a/eng/common/templates/job/job.yml b/eng/common/templates/job/job.yml new file mode 100644 index 00000000000000..44ad26abf54ba2 --- /dev/null +++ b/eng/common/templates/job/job.yml @@ -0,0 +1,251 @@ +# Internal resources (telemetry, microbuild) can only be accessed from non-public projects, +# and some (Microbuild) should only be applied to non-PR cases for internal builds. + +parameters: +# Job schema parameters - https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=vsts&tabs=schema#job + cancelTimeoutInMinutes: '' + condition: '' + container: '' + continueOnError: false + dependsOn: '' + displayName: '' + pool: '' + steps: [] + strategy: '' + timeoutInMinutes: '' + variables: [] + workspace: '' + +# Job base template specific parameters + # See schema documentation - https://github.com/dotnet/arcade/blob/master/Documentation/AzureDevOps/TemplateSchema.md + artifacts: '' + enableMicrobuild: false + enablePublishBuildArtifacts: false + enablePublishBuildAssets: false + enablePublishTestResults: false + enablePublishUsingPipelines: false + enableBuildRetry: false + disableComponentGovernance: '' + componentGovernanceIgnoreDirectories: '' + mergeTestResults: false + testRunTitle: '' + testResultsFormat: '' + name: '' + preSteps: [] + runAsPublic: false +# Sbom related params + enableSbom: true + PackageVersion: 7.0.0 + BuildDropPath: '$(Build.SourcesDirectory)/artifacts' + +jobs: +- job: ${{ parameters.name }} + + ${{ if ne(parameters.cancelTimeoutInMinutes, '') }}: + cancelTimeoutInMinutes: ${{ parameters.cancelTimeoutInMinutes }} + + ${{ if ne(parameters.condition, '') }}: + condition: ${{ parameters.condition }} + + ${{ if ne(parameters.container, '') }}: + container: ${{ parameters.container }} + + ${{ if ne(parameters.continueOnError, '') }}: + continueOnError: ${{ parameters.continueOnError }} + + ${{ if ne(parameters.dependsOn, '') }}: + dependsOn: ${{ parameters.dependsOn }} + + ${{ if ne(parameters.displayName, '') }}: + displayName: ${{ parameters.displayName }} + + ${{ if ne(parameters.pool, '') }}: + pool: ${{ parameters.pool }} + + ${{ if ne(parameters.strategy, '') }}: + strategy: ${{ parameters.strategy }} + + ${{ if ne(parameters.timeoutInMinutes, '') }}: + timeoutInMinutes: ${{ parameters.timeoutInMinutes }} + + variables: + - ${{ if ne(parameters.enableTelemetry, 'false') }}: + - name: DOTNET_CLI_TELEMETRY_PROFILE + value: '$(Build.Repository.Uri)' + - ${{ if eq(parameters.enableRichCodeNavigation, 'true') }}: + - name: EnableRichCodeNavigation + value: 'true' + - ${{ each variable in parameters.variables }}: + # handle name-value variable syntax + # example: + # - name: [key] + # value: [value] + - ${{ if ne(variable.name, '') }}: + - name: ${{ variable.name }} + value: ${{ variable.value }} + + # handle variable groups + - ${{ if ne(variable.group, '') }}: + - group: ${{ variable.group }} + + # handle template variable syntax + # example: + # - template: path/to/template.yml + # parameters: + # [key]: [value] + - ${{ if ne(variable.template, '') }}: + - template: ${{ variable.template }} + ${{ if ne(variable.parameters, '') }}: + parameters: ${{ variable.parameters }} + + # handle key-value variable syntax. + # example: + # - [key]: [value] + - ${{ if and(eq(variable.name, ''), eq(variable.group, ''), eq(variable.template, '')) }}: + - ${{ each pair in variable }}: + - name: ${{ pair.key }} + value: ${{ pair.value }} + + # DotNet-HelixApi-Access provides 'HelixApiAccessToken' for internal builds + - ${{ if and(eq(parameters.enableTelemetry, 'true'), eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: + - group: DotNet-HelixApi-Access + + ${{ if ne(parameters.workspace, '') }}: + workspace: ${{ parameters.workspace }} + + steps: + - ${{ if ne(parameters.preSteps, '') }}: + - ${{ each preStep in parameters.preSteps }}: + - ${{ preStep }} + + - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: + - ${{ if eq(parameters.enableMicrobuild, 'true') }}: + - task: MicroBuildSigningPlugin@3 + displayName: Install MicroBuild plugin + inputs: + signType: $(_SignType) + zipSources: false + feedSource: https://dnceng.pkgs.visualstudio.com/_packaging/MicroBuildToolset/nuget/v3/index.json + env: + TeamName: $(_TeamName) + continueOnError: ${{ parameters.continueOnError }} + condition: and(succeeded(), in(variables['_SignType'], 'real', 'test'), eq(variables['Agent.Os'], 'Windows_NT')) + + - ${{ if and(eq(parameters.runAsPublic, 'false'), eq(variables['System.TeamProject'], 'internal')) }}: + - task: NuGetAuthenticate@0 + + - ${{ if and(ne(parameters.artifacts.download, 'false'), ne(parameters.artifacts.download, '')) }}: + - task: DownloadPipelineArtifact@2 + inputs: + buildType: current + artifactName: ${{ coalesce(parameters.artifacts.download.name, 'Artifacts_$(Agent.OS)_$(_BuildConfig)') }} + targetPath: ${{ coalesce(parameters.artifacts.download.path, 'artifacts') }} + itemPattern: ${{ coalesce(parameters.artifacts.download.pattern, '**') }} + + - ${{ each step in parameters.steps }}: + - ${{ step }} + + - ${{ if eq(parameters.enableRichCodeNavigation, true) }}: + - task: RichCodeNavIndexer@0 + displayName: RichCodeNav Upload + inputs: + languages: ${{ coalesce(parameters.richCodeNavigationLanguage, 'csharp') }} + environment: ${{ coalesce(parameters.richCodeNavigationEnvironment, 'production') }} + richNavLogOutputDirectory: $(Build.SourcesDirectory)/artifacts/bin + uploadRichNavArtifacts: ${{ coalesce(parameters.richCodeNavigationUploadArtifacts, false) }} + continueOnError: true + + - template: /eng/common/templates/steps/component-governance.yml + parameters: + ${{ if eq(parameters.disableComponentGovernance, '') }}: + ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest'), eq(parameters.runAsPublic, 'false'), or(startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'), startsWith(variables['Build.SourceBranch'], 'refs/heads/dotnet/'), startsWith(variables['Build.SourceBranch'], 'refs/heads/microsoft/'), eq(variables['Build.SourceBranch'], 'refs/heads/main'))) }}: + disableComponentGovernance: false + ${{ else }}: + disableComponentGovernance: true + ${{ else }}: + disableComponentGovernance: ${{ parameters.disableComponentGovernance }} + componentGovernanceIgnoreDirectories: ${{ parameters.componentGovernanceIgnoreDirectories }} + + - ${{ if eq(parameters.enableMicrobuild, 'true') }}: + - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: + - task: MicroBuildCleanup@1 + displayName: Execute Microbuild cleanup tasks + condition: and(always(), in(variables['_SignType'], 'real', 'test'), eq(variables['Agent.Os'], 'Windows_NT')) + continueOnError: ${{ parameters.continueOnError }} + env: + TeamName: $(_TeamName) + + - ${{ if ne(parameters.artifacts.publish, '') }}: + - ${{ if and(ne(parameters.artifacts.publish.artifacts, 'false'), ne(parameters.artifacts.publish.artifacts, '')) }}: + - task: CopyFiles@2 + displayName: Gather binaries for publish to artifacts + inputs: + SourceFolder: 'artifacts/bin' + Contents: '**' + TargetFolder: '$(Build.ArtifactStagingDirectory)/artifacts/bin' + - task: CopyFiles@2 + displayName: Gather packages for publish to artifacts + inputs: + SourceFolder: 'artifacts/packages' + Contents: '**' + TargetFolder: '$(Build.ArtifactStagingDirectory)/artifacts/packages' + - task: PublishBuildArtifacts@1 + displayName: Publish pipeline artifacts + inputs: + PathtoPublish: '$(Build.ArtifactStagingDirectory)/artifacts' + PublishLocation: Container + ArtifactName: ${{ coalesce(parameters.artifacts.publish.artifacts.name , 'Artifacts_$(Agent.Os)_$(_BuildConfig)') }} + continueOnError: true + condition: always() + - ${{ if and(ne(parameters.artifacts.publish.logs, 'false'), ne(parameters.artifacts.publish.logs, '')) }}: + - publish: artifacts/log + artifact: ${{ coalesce(parameters.artifacts.publish.logs.name, 'Logs_Build_$(Agent.Os)_$(_BuildConfig)') }} + displayName: Publish logs + continueOnError: true + condition: always() + + - ${{ if ne(parameters.enablePublishBuildArtifacts, 'false') }}: + - task: PublishBuildArtifacts@1 + displayName: Publish Logs + inputs: + PathtoPublish: '$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)' + PublishLocation: Container + ArtifactName: ${{ coalesce(parameters.enablePublishBuildArtifacts.artifactName, '$(Agent.Os)_$(Agent.JobName)' ) }} + continueOnError: true + condition: always() + + - ${{ if or(and(eq(parameters.enablePublishTestResults, 'true'), eq(parameters.testResultsFormat, '')), eq(parameters.testResultsFormat, 'xunit')) }}: + - task: PublishTestResults@2 + displayName: Publish XUnit Test Results + inputs: + testResultsFormat: 'xUnit' + testResultsFiles: '*.xml' + searchFolder: '$(Build.SourcesDirectory)/artifacts/TestResults/$(_BuildConfig)' + testRunTitle: ${{ coalesce(parameters.testRunTitle, parameters.name, '$(System.JobName)') }}-xunit + mergeTestResults: ${{ parameters.mergeTestResults }} + continueOnError: true + condition: always() + - ${{ if or(and(eq(parameters.enablePublishTestResults, 'true'), eq(parameters.testResultsFormat, '')), eq(parameters.testResultsFormat, 'vstest')) }}: + - task: PublishTestResults@2 + displayName: Publish TRX Test Results + inputs: + testResultsFormat: 'VSTest' + testResultsFiles: '*.trx' + searchFolder: '$(Build.SourcesDirectory)/artifacts/TestResults/$(_BuildConfig)' + testRunTitle: ${{ coalesce(parameters.testRunTitle, parameters.name, '$(System.JobName)') }}-trx + mergeTestResults: ${{ parameters.mergeTestResults }} + continueOnError: true + condition: always() + + - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest'), eq(parameters.enableSbom, 'true')) }}: + - template: /eng/common/templates/steps/generate-sbom.yml + parameters: + PackageVersion: ${{ parameters.packageVersion}} + BuildDropPath: ${{ parameters.buildDropPath }} + IgnoreDirectories: ${{ parameters.componentGovernanceIgnoreDirectories }} + + - ${{ if eq(parameters.enableBuildRetry, 'true') }}: + - publish: $(Build.SourcesDirectory)\eng\common\BuildConfiguration + artifact: BuildConfiguration + displayName: Publish build retry configuration + continueOnError: true diff --git a/eng/common/templates/job/onelocbuild.yml b/eng/common/templates/job/onelocbuild.yml new file mode 100644 index 00000000000000..60ab00c4de3acd --- /dev/null +++ b/eng/common/templates/job/onelocbuild.yml @@ -0,0 +1,109 @@ +parameters: + # Optional: dependencies of the job + dependsOn: '' + + # Optional: A defined YAML pool - https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=vsts&tabs=schema#pool + pool: '' + + CeapexPat: $(dn-bot-ceapex-package-r) # PAT for the loc AzDO instance https://dev.azure.com/ceapex + GithubPat: $(BotAccount-dotnet-bot-repo-PAT) + + SourcesDirectory: $(Build.SourcesDirectory) + CreatePr: true + AutoCompletePr: false + ReusePr: true + UseLfLineEndings: true + UseCheckedInLocProjectJson: false + SkipLocProjectJsonGeneration: false + LanguageSet: VS_Main_Languages + LclSource: lclFilesInRepo + LclPackageId: '' + RepoType: gitHub + GitHubOrg: dotnet + MirrorRepo: '' + MirrorBranch: main + condition: '' + JobNameSuffix: '' + +jobs: +- job: OneLocBuild${{ parameters.JobNameSuffix }} + + dependsOn: ${{ parameters.dependsOn }} + + displayName: OneLocBuild${{ parameters.JobNameSuffix }} + + variables: + - group: OneLocBuildVariables # Contains the CeapexPat and GithubPat + - name: _GenerateLocProjectArguments + value: -SourcesDirectory ${{ parameters.SourcesDirectory }} + -LanguageSet "${{ parameters.LanguageSet }}" + -CreateNeutralXlfs + - ${{ if eq(parameters.UseCheckedInLocProjectJson, 'true') }}: + - name: _GenerateLocProjectArguments + value: ${{ variables._GenerateLocProjectArguments }} -UseCheckedInLocProjectJson + - template: /eng/common/templates/variables/pool-providers.yml + + ${{ if ne(parameters.pool, '') }}: + pool: ${{ parameters.pool }} + ${{ if eq(parameters.pool, '') }}: + pool: + # We don't use the collection uri here because it might vary (.visualstudio.com vs. dev.azure.com) + ${{ if eq(variables['System.TeamProject'], 'DevDiv') }}: + name: VSEngSS-MicroBuild2022-1ES + demands: Cmd + # If it's not devdiv, it's dnceng + ${{ if ne(variables['System.TeamProject'], 'DevDiv') }}: + name: $(DncEngInternalBuildPool) + demands: ImageOverride -equals windows.vs2019.amd64 + + steps: + - ${{ if ne(parameters.SkipLocProjectJsonGeneration, 'true') }}: + - task: Powershell@2 + inputs: + filePath: $(Build.SourcesDirectory)/eng/common/generate-locproject.ps1 + arguments: $(_GenerateLocProjectArguments) + displayName: Generate LocProject.json + condition: ${{ parameters.condition }} + + - task: OneLocBuild@2 + displayName: OneLocBuild + env: + SYSTEM_ACCESSTOKEN: $(System.AccessToken) + inputs: + locProj: eng/Localize/LocProject.json + outDir: $(Build.ArtifactStagingDirectory) + lclSource: ${{ parameters.LclSource }} + lclPackageId: ${{ parameters.LclPackageId }} + isCreatePrSelected: ${{ parameters.CreatePr }} + isAutoCompletePrSelected: ${{ parameters.AutoCompletePr }} + ${{ if eq(parameters.CreatePr, true) }}: + isUseLfLineEndingsSelected: ${{ parameters.UseLfLineEndings }} + ${{ if eq(parameters.RepoType, 'gitHub') }}: + isShouldReusePrSelected: ${{ parameters.ReusePr }} + packageSourceAuth: patAuth + patVariable: ${{ parameters.CeapexPat }} + ${{ if eq(parameters.RepoType, 'gitHub') }}: + repoType: ${{ parameters.RepoType }} + gitHubPatVariable: "${{ parameters.GithubPat }}" + ${{ if ne(parameters.MirrorRepo, '') }}: + isMirrorRepoSelected: true + gitHubOrganization: ${{ parameters.GitHubOrg }} + mirrorRepo: ${{ parameters.MirrorRepo }} + mirrorBranch: ${{ parameters.MirrorBranch }} + condition: ${{ parameters.condition }} + + - task: PublishBuildArtifacts@1 + displayName: Publish Localization Files + inputs: + PathtoPublish: '$(Build.ArtifactStagingDirectory)/loc' + PublishLocation: Container + ArtifactName: Loc + condition: ${{ parameters.condition }} + + - task: PublishBuildArtifacts@1 + displayName: Publish LocProject.json + inputs: + PathtoPublish: '$(Build.SourcesDirectory)/eng/Localize/' + PublishLocation: Container + ArtifactName: Loc + condition: ${{ parameters.condition }} \ No newline at end of file diff --git a/eng/common/templates/job/publish-build-assets.yml b/eng/common/templates/job/publish-build-assets.yml new file mode 100644 index 00000000000000..42017109f374d6 --- /dev/null +++ b/eng/common/templates/job/publish-build-assets.yml @@ -0,0 +1,151 @@ +parameters: + configuration: 'Debug' + + # Optional: condition for the job to run + condition: '' + + # Optional: 'true' if future jobs should run even if this job fails + continueOnError: false + + # Optional: dependencies of the job + dependsOn: '' + + # Optional: Include PublishBuildArtifacts task + enablePublishBuildArtifacts: false + + # Optional: A defined YAML pool - https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=vsts&tabs=schema#pool + pool: {} + + # Optional: should run as a public build even in the internal project + # if 'true', the build won't run any of the internal only steps, even if it is running in non-public projects. + runAsPublic: false + + # Optional: whether the build's artifacts will be published using release pipelines or direct feed publishing + publishUsingPipelines: false + + # Optional: whether the build's artifacts will be published using release pipelines or direct feed publishing + publishAssetsImmediately: false + + artifactsPublishingAdditionalParameters: '' + + signingValidationAdditionalParameters: '' + +jobs: +- job: Asset_Registry_Publish + + dependsOn: ${{ parameters.dependsOn }} + timeoutInMinutes: 150 + + ${{ if eq(parameters.publishAssetsImmediately, 'true') }}: + displayName: Publish Assets + ${{ else }}: + displayName: Publish to Build Asset Registry + + variables: + - template: /eng/common/templates/variables/pool-providers.yml + - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: + - group: Publish-Build-Assets + - group: AzureDevOps-Artifact-Feeds-Pats + - name: runCodesignValidationInjection + value: false + - ${{ if eq(parameters.publishAssetsImmediately, 'true') }}: + - template: /eng/common/templates/post-build/common-variables.yml + + pool: + # We don't use the collection uri here because it might vary (.visualstudio.com vs. dev.azure.com) + ${{ if eq(variables['System.TeamProject'], 'DevDiv') }}: + name: VSEngSS-MicroBuild2022-1ES + demands: Cmd + # If it's not devdiv, it's dnceng + ${{ if ne(variables['System.TeamProject'], 'DevDiv') }}: + name: $(DncEngInternalBuildPool) + demands: ImageOverride -equals windows.vs2019.amd64 + + steps: + - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: + - task: DownloadBuildArtifacts@0 + displayName: Download artifact + inputs: + artifactName: AssetManifests + downloadPath: '$(Build.StagingDirectory)/Download' + checkDownloadedFiles: true + condition: ${{ parameters.condition }} + continueOnError: ${{ parameters.continueOnError }} + + - task: NuGetAuthenticate@0 + + - task: PowerShell@2 + displayName: Publish Build Assets + inputs: + filePath: eng\common\sdk-task.ps1 + arguments: -task PublishBuildAssets -restore -msbuildEngine dotnet + /p:ManifestsPath='$(Build.StagingDirectory)/Download/AssetManifests' + /p:BuildAssetRegistryToken=$(MaestroAccessToken) + /p:MaestroApiEndpoint=https://maestro-prod.westus2.cloudapp.azure.com + /p:PublishUsingPipelines=${{ parameters.publishUsingPipelines }} + /p:OfficialBuildId=$(Build.BuildNumber) + condition: ${{ parameters.condition }} + continueOnError: ${{ parameters.continueOnError }} + + - task: powershell@2 + displayName: Create ReleaseConfigs Artifact + inputs: + targetType: inline + script: | + Add-Content -Path "$(Build.StagingDirectory)/ReleaseConfigs.txt" -Value $(BARBuildId) + Add-Content -Path "$(Build.StagingDirectory)/ReleaseConfigs.txt" -Value "$(DefaultChannels)" + Add-Content -Path "$(Build.StagingDirectory)/ReleaseConfigs.txt" -Value $(IsStableBuild) + + - task: PublishBuildArtifacts@1 + displayName: Publish ReleaseConfigs Artifact + inputs: + PathtoPublish: '$(Build.StagingDirectory)/ReleaseConfigs.txt' + PublishLocation: Container + ArtifactName: ReleaseConfigs + + - task: powershell@2 + displayName: Check if SymbolPublishingExclusionsFile.txt exists + inputs: + targetType: inline + script: | + $symbolExclusionfile = "$(Build.SourcesDirectory)/eng/SymbolPublishingExclusionsFile.txt" + if(Test-Path -Path $symbolExclusionfile) + { + Write-Host "SymbolExclusionFile exists" + Write-Host "##vso[task.setvariable variable=SymbolExclusionFile]true" + } + else{ + Write-Host "Symbols Exclusion file does not exists" + Write-Host "##vso[task.setvariable variable=SymbolExclusionFile]false" + } + + - task: PublishBuildArtifacts@1 + displayName: Publish SymbolPublishingExclusionsFile Artifact + condition: eq(variables['SymbolExclusionFile'], 'true') + inputs: + PathtoPublish: '$(Build.SourcesDirectory)/eng/SymbolPublishingExclusionsFile.txt' + PublishLocation: Container + ArtifactName: ReleaseConfigs + + - ${{ if eq(parameters.publishAssetsImmediately, 'true') }}: + - template: /eng/common/templates/post-build/setup-maestro-vars.yml + parameters: + BARBuildId: ${{ parameters.BARBuildId }} + PromoteToChannelIds: ${{ parameters.PromoteToChannelIds }} + + - task: PowerShell@2 + displayName: Publish Using Darc + inputs: + filePath: $(Build.SourcesDirectory)/eng/common/post-build/publish-using-darc.ps1 + arguments: -BuildId $(BARBuildId) + -PublishingInfraVersion 3 + -AzdoToken '$(publishing-dnceng-devdiv-code-r-build-re)' + -MaestroToken '$(MaestroApiAccessToken)' + -WaitPublishingFinish true + -ArtifactsPublishingAdditionalParameters '${{ parameters.artifactsPublishingAdditionalParameters }}' + -SymbolPublishingAdditionalParameters '${{ parameters.symbolPublishingAdditionalParameters }}' + + - ${{ if eq(parameters.enablePublishBuildArtifacts, 'true') }}: + - template: /eng/common/templates/steps/publish-logs.yml + parameters: + JobLabel: 'Publish_Artifacts_Logs' diff --git a/eng/common/templates/job/source-build.yml b/eng/common/templates/job/source-build.yml new file mode 100644 index 00000000000000..8a3deef2b72746 --- /dev/null +++ b/eng/common/templates/job/source-build.yml @@ -0,0 +1,66 @@ +parameters: + # This template adds arcade-powered source-build to CI. The template produces a server job with a + # default ID 'Source_Build_Complete' to put in a dependency list if necessary. + + # Specifies the prefix for source-build jobs added to pipeline. Use this if disambiguation needed. + jobNamePrefix: 'Source_Build' + + # Defines the platform on which to run the job. By default, a linux-x64 machine, suitable for + # managed-only repositories. This is an object with these properties: + # + # name: '' + # The name of the job. This is included in the job ID. + # targetRID: '' + # The name of the target RID to use, instead of the one auto-detected by Arcade. + # nonPortable: false + # Enables non-portable mode. This means a more specific RID (e.g. fedora.32-x64 rather than + # linux-x64), and compiling against distro-provided packages rather than portable ones. + # skipPublishValidation: false + # Disables publishing validation. By default, a check is performed to ensure no packages are + # published by source-build. + # container: '' + # A container to use. Runs in docker. + # pool: {} + # A pool to use. Runs directly on an agent. + # buildScript: '' + # Specifies the build script to invoke to perform the build in the repo. The default + # './build.sh' should work for typical Arcade repositories, but this is customizable for + # difficult situations. + # jobProperties: {} + # A list of job properties to inject at the top level, for potential extensibility beyond + # container and pool. + platform: {} + +jobs: +- job: ${{ parameters.jobNamePrefix }}_${{ parameters.platform.name }} + displayName: Source-Build (${{ parameters.platform.name }}) + + ${{ each property in parameters.platform.jobProperties }}: + ${{ property.key }}: ${{ property.value }} + + ${{ if ne(parameters.platform.container, '') }}: + container: ${{ parameters.platform.container }} + + ${{ if eq(parameters.platform.pool, '') }}: + # The default VM host AzDO pool. This should be capable of running Docker containers: almost all + # source-build builds run in Docker, including the default managed platform. + # /eng/common/templates/variables/pool-providers.yml can't be used here (some customers declare variables already), so duplicate its logic + pool: + ${{ if eq(variables['System.TeamProject'], 'public') }}: + name: $[replace(replace(eq(contains(coalesce(variables['System.PullRequest.TargetBranch'], variables['Build.SourceBranch'], 'refs/heads/main'), 'release'), 'true'), True, 'NetCore-Svc-Public' ), False, 'NetCore-Public')] + demands: ImageOverride -equals Build.Ubuntu.1804.Amd64.Open + + ${{ if eq(variables['System.TeamProject'], 'internal') }}: + name: $[replace(replace(eq(contains(coalesce(variables['System.PullRequest.TargetBranch'], variables['Build.SourceBranch'], 'refs/heads/main'), 'release'), 'true'), True, 'NetCore1ESPool-Svc-Internal'), False, 'NetCore1ESPool-Internal')] + demands: ImageOverride -equals Build.Ubuntu.1804.Amd64 + + ${{ if ne(parameters.platform.pool, '') }}: + pool: ${{ parameters.platform.pool }} + + workspace: + clean: all + + steps: + - template: /eng/common/templates/steps/source-build.yml + parameters: + platform: ${{ parameters.platform }} diff --git a/eng/common/templates/job/source-index-stage1.yml b/eng/common/templates/job/source-index-stage1.yml new file mode 100644 index 00000000000000..b98202aa02d824 --- /dev/null +++ b/eng/common/templates/job/source-index-stage1.yml @@ -0,0 +1,67 @@ +parameters: + runAsPublic: false + sourceIndexPackageVersion: 1.0.1-20230228.2 + sourceIndexPackageSource: https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json + sourceIndexBuildCommand: powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -Command "eng/common/build.ps1 -restore -build -binarylog -ci" + preSteps: [] + binlogPath: artifacts/log/Debug/Build.binlog + condition: '' + dependsOn: '' + pool: '' + +jobs: +- job: SourceIndexStage1 + dependsOn: ${{ parameters.dependsOn }} + condition: ${{ parameters.condition }} + variables: + - name: SourceIndexPackageVersion + value: ${{ parameters.sourceIndexPackageVersion }} + - name: SourceIndexPackageSource + value: ${{ parameters.sourceIndexPackageSource }} + - name: BinlogPath + value: ${{ parameters.binlogPath }} + - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: + - group: source-dot-net stage1 variables + - template: /eng/common/templates/variables/pool-providers.yml + + ${{ if ne(parameters.pool, '') }}: + pool: ${{ parameters.pool }} + ${{ if eq(parameters.pool, '') }}: + pool: + ${{ if eq(variables['System.TeamProject'], 'public') }}: + name: $(DncEngPublicBuildPool) + demands: ImageOverride -equals windows.vs2019.amd64.open + ${{ if eq(variables['System.TeamProject'], 'internal') }}: + name: $(DncEngInternalBuildPool) + demands: ImageOverride -equals windows.vs2019.amd64 + + steps: + - ${{ each preStep in parameters.preSteps }}: + - ${{ preStep }} + + - task: UseDotNet@2 + displayName: Use .NET Core SDK 6 + inputs: + packageType: sdk + version: 6.0.x + installationPath: $(Agent.TempDirectory)/dotnet + workingDirectory: $(Agent.TempDirectory) + + - script: | + $(Agent.TempDirectory)/dotnet/dotnet tool install BinLogToSln --version $(SourceIndexPackageVersion) --add-source $(SourceIndexPackageSource) --tool-path $(Agent.TempDirectory)/.source-index/tools + $(Agent.TempDirectory)/dotnet/dotnet tool install UploadIndexStage1 --version $(SourceIndexPackageVersion) --add-source $(SourceIndexPackageSource) --tool-path $(Agent.TempDirectory)/.source-index/tools + displayName: Download Tools + # Set working directory to temp directory so 'dotnet' doesn't try to use global.json and use the repo's sdk. + workingDirectory: $(Agent.TempDirectory) + + - script: ${{ parameters.sourceIndexBuildCommand }} + displayName: Build Repository + + - script: $(Agent.TempDirectory)/.source-index/tools/BinLogToSln -i $(BinlogPath) -r $(Build.SourcesDirectory) -n $(Build.Repository.Name) -o .source-index/stage1output + displayName: Process Binlog into indexable sln + + - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: + - script: $(Agent.TempDirectory)/.source-index/tools/UploadIndexStage1 -i .source-index/stage1output -n $(Build.Repository.Name) + displayName: Upload stage1 artifacts to source index + env: + BLOB_CONTAINER_URL: $(source-dot-net-stage1-blob-container-url) diff --git a/eng/common/templates/jobs/codeql-build.yml b/eng/common/templates/jobs/codeql-build.yml new file mode 100644 index 00000000000000..f7dc5ea4aaa63c --- /dev/null +++ b/eng/common/templates/jobs/codeql-build.yml @@ -0,0 +1,31 @@ +parameters: + # See schema documentation in /Documentation/AzureDevOps/TemplateSchema.md + continueOnError: false + # Required: A collection of jobs to run - https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=vsts&tabs=schema#job + jobs: [] + # Optional: if specified, restore and use this version of Guardian instead of the default. + overrideGuardianVersion: '' + +jobs: +- template: /eng/common/templates/jobs/jobs.yml + parameters: + enableMicrobuild: false + enablePublishBuildArtifacts: false + enablePublishTestResults: false + enablePublishBuildAssets: false + enablePublishUsingPipelines: false + enableTelemetry: true + + variables: + - group: Publish-Build-Assets + # The Guardian version specified in 'eng/common/sdl/packages.config'. This value must be kept in + # sync with the packages.config file. + - name: DefaultGuardianVersion + value: 0.109.0 + - name: GuardianPackagesConfigFile + value: $(Build.SourcesDirectory)\eng\common\sdl\packages.config + - name: GuardianVersion + value: ${{ coalesce(parameters.overrideGuardianVersion, '$(DefaultGuardianVersion)') }} + + jobs: ${{ parameters.jobs }} + diff --git a/eng/common/templates/jobs/jobs.yml b/eng/common/templates/jobs/jobs.yml new file mode 100644 index 00000000000000..289bb2396ce83e --- /dev/null +++ b/eng/common/templates/jobs/jobs.yml @@ -0,0 +1,97 @@ +parameters: + # See schema documentation in /Documentation/AzureDevOps/TemplateSchema.md + continueOnError: false + + # Optional: Include PublishBuildArtifacts task + enablePublishBuildArtifacts: false + + # Optional: Enable publishing using release pipelines + enablePublishUsingPipelines: false + + # Optional: Enable running the source-build jobs to build repo from source + enableSourceBuild: false + + # Optional: Parameters for source-build template. + # See /eng/common/templates/jobs/source-build.yml for options + sourceBuildParameters: [] + + graphFileGeneration: + # Optional: Enable generating the graph files at the end of the build + enabled: false + # Optional: Include toolset dependencies in the generated graph files + includeToolset: false + + # Required: A collection of jobs to run - https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=vsts&tabs=schema#job + jobs: [] + + # Optional: Override automatically derived dependsOn value for "publish build assets" job + publishBuildAssetsDependsOn: '' + + # Optional: Publish the assets as soon as the publish to BAR stage is complete, rather doing so in a separate stage. + publishAssetsImmediately: false + + # Optional: If using publishAssetsImmediately and additional parameters are needed, can be used to send along additional parameters (normally sent to post-build.yml) + artifactsPublishingAdditionalParameters: '' + signingValidationAdditionalParameters: '' + + # Optional: should run as a public build even in the internal project + # if 'true', the build won't run any of the internal only steps, even if it is running in non-public projects. + runAsPublic: false + + enableSourceIndex: false + sourceIndexParams: {} + +# Internal resources (telemetry, microbuild) can only be accessed from non-public projects, +# and some (Microbuild) should only be applied to non-PR cases for internal builds. + +jobs: +- ${{ each job in parameters.jobs }}: + - template: ../job/job.yml + parameters: + # pass along parameters + ${{ each parameter in parameters }}: + ${{ if ne(parameter.key, 'jobs') }}: + ${{ parameter.key }}: ${{ parameter.value }} + + # pass along job properties + ${{ each property in job }}: + ${{ if ne(property.key, 'job') }}: + ${{ property.key }}: ${{ property.value }} + + name: ${{ job.job }} + +- ${{ if eq(parameters.enableSourceBuild, true) }}: + - template: /eng/common/templates/jobs/source-build.yml + parameters: + allCompletedJobId: Source_Build_Complete + ${{ each parameter in parameters.sourceBuildParameters }}: + ${{ parameter.key }}: ${{ parameter.value }} + +- ${{ if eq(parameters.enableSourceIndex, 'true') }}: + - template: ../job/source-index-stage1.yml + parameters: + runAsPublic: ${{ parameters.runAsPublic }} + ${{ each parameter in parameters.sourceIndexParams }}: + ${{ parameter.key }}: ${{ parameter.value }} + +- ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: + - ${{ if or(eq(parameters.enablePublishBuildAssets, true), eq(parameters.artifacts.publish.manifests, 'true'), ne(parameters.artifacts.publish.manifests, '')) }}: + - template: ../job/publish-build-assets.yml + parameters: + continueOnError: ${{ parameters.continueOnError }} + dependsOn: + - ${{ if ne(parameters.publishBuildAssetsDependsOn, '') }}: + - ${{ each job in parameters.publishBuildAssetsDependsOn }}: + - ${{ job.job }} + - ${{ if eq(parameters.publishBuildAssetsDependsOn, '') }}: + - ${{ each job in parameters.jobs }}: + - ${{ job.job }} + - ${{ if eq(parameters.enableSourceBuild, true) }}: + - Source_Build_Complete + + runAsPublic: ${{ parameters.runAsPublic }} + publishUsingPipelines: ${{ parameters.enablePublishUsingPipelines }} + publishAssetsImmediately: ${{ parameters.publishAssetsImmediately }} + enablePublishBuildArtifacts: ${{ parameters.enablePublishBuildArtifacts }} + artifactsPublishingAdditionalParameters: ${{ parameters.artifactsPublishingAdditionalParameters }} + signingValidationAdditionalParameters: ${{ parameters.signingValidationAdditionalParameters }} diff --git a/eng/common/templates/jobs/source-build.yml b/eng/common/templates/jobs/source-build.yml new file mode 100644 index 00000000000000..a15b07eb51d9d6 --- /dev/null +++ b/eng/common/templates/jobs/source-build.yml @@ -0,0 +1,46 @@ +parameters: + # This template adds arcade-powered source-build to CI. A job is created for each platform, as + # well as an optional server job that completes when all platform jobs complete. + + # The name of the "join" job for all source-build platforms. If set to empty string, the job is + # not included. Existing repo pipelines can use this job depend on all source-build jobs + # completing without maintaining a separate list of every single job ID: just depend on this one + # server job. By default, not included. Recommended name if used: 'Source_Build_Complete'. + allCompletedJobId: '' + + # See /eng/common/templates/job/source-build.yml + jobNamePrefix: 'Source_Build' + + # This is the default platform provided by Arcade, intended for use by a managed-only repo. + defaultManagedPlatform: + name: 'Managed' + container: 'mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream8' + + # Defines the platforms on which to run build jobs. One job is created for each platform, and the + # object in this array is sent to the job template as 'platform'. If no platforms are specified, + # one job runs on 'defaultManagedPlatform'. + platforms: [] + +jobs: + +- ${{ if ne(parameters.allCompletedJobId, '') }}: + - job: ${{ parameters.allCompletedJobId }} + displayName: Source-Build Complete + pool: server + dependsOn: + - ${{ each platform in parameters.platforms }}: + - ${{ parameters.jobNamePrefix }}_${{ platform.name }} + - ${{ if eq(length(parameters.platforms), 0) }}: + - ${{ parameters.jobNamePrefix }}_${{ parameters.defaultManagedPlatform.name }} + +- ${{ each platform in parameters.platforms }}: + - template: /eng/common/templates/job/source-build.yml + parameters: + jobNamePrefix: ${{ parameters.jobNamePrefix }} + platform: ${{ platform }} + +- ${{ if eq(length(parameters.platforms), 0) }}: + - template: /eng/common/templates/job/source-build.yml + parameters: + jobNamePrefix: ${{ parameters.jobNamePrefix }} + platform: ${{ parameters.defaultManagedPlatform }} diff --git a/eng/common/templates/post-build/common-variables.yml b/eng/common/templates/post-build/common-variables.yml new file mode 100644 index 00000000000000..c24193acfc981f --- /dev/null +++ b/eng/common/templates/post-build/common-variables.yml @@ -0,0 +1,22 @@ +variables: + - group: Publish-Build-Assets + + # Whether the build is internal or not + - name: IsInternalBuild + value: ${{ and(ne(variables['System.TeamProject'], 'public'), contains(variables['Build.SourceBranch'], 'internal')) }} + + # Default Maestro++ API Endpoint and API Version + - name: MaestroApiEndPoint + value: "https://maestro-prod.westus2.cloudapp.azure.com" + - name: MaestroApiAccessToken + value: $(MaestroAccessToken) + - name: MaestroApiVersion + value: "2020-02-20" + + - name: SourceLinkCLIVersion + value: 3.0.0 + - name: SymbolToolVersion + value: 1.0.1 + + - name: runCodesignValidationInjection + value: false diff --git a/eng/common/templates/post-build/post-build.yml b/eng/common/templates/post-build/post-build.yml new file mode 100644 index 00000000000000..ef720f9d781989 --- /dev/null +++ b/eng/common/templates/post-build/post-build.yml @@ -0,0 +1,281 @@ +parameters: + # Which publishing infra should be used. THIS SHOULD MATCH THE VERSION ON THE BUILD MANIFEST. + # Publishing V1 is no longer supported + # Publishing V2 is no longer supported + # Publishing V3 is the default + - name: publishingInfraVersion + displayName: Which version of publishing should be used to promote the build definition? + type: number + default: 3 + values: + - 3 + + - name: BARBuildId + displayName: BAR Build Id + type: number + default: 0 + + - name: PromoteToChannelIds + displayName: Channel to promote BARBuildId to + type: string + default: '' + + - name: enableSourceLinkValidation + displayName: Enable SourceLink validation + type: boolean + default: false + + - name: enableSigningValidation + displayName: Enable signing validation + type: boolean + default: true + + - name: enableSymbolValidation + displayName: Enable symbol validation + type: boolean + default: false + + - name: enableNugetValidation + displayName: Enable NuGet validation + type: boolean + default: true + + - name: publishInstallersAndChecksums + displayName: Publish installers and checksums + type: boolean + default: true + + - name: SDLValidationParameters + type: object + default: + enable: false + publishGdn: false + continueOnError: false + params: '' + artifactNames: '' + downloadArtifacts: true + + # These parameters let the user customize the call to sdk-task.ps1 for publishing + # symbols & general artifacts as well as for signing validation + - name: symbolPublishingAdditionalParameters + displayName: Symbol publishing additional parameters + type: string + default: '' + + - name: artifactsPublishingAdditionalParameters + displayName: Artifact publishing additional parameters + type: string + default: '' + + - name: signingValidationAdditionalParameters + displayName: Signing validation additional parameters + type: string + default: '' + + # Which stages should finish execution before post-build stages start + - name: validateDependsOn + type: object + default: + - build + + - name: publishDependsOn + type: object + default: + - Validate + + # Optional: Call asset publishing rather than running in a separate stage + - name: publishAssetsImmediately + type: boolean + default: false + +stages: +- ${{ if or(eq( parameters.enableNugetValidation, 'true'), eq(parameters.enableSigningValidation, 'true'), eq(parameters.enableSourceLinkValidation, 'true'), eq(parameters.SDLValidationParameters.enable, 'true')) }}: + - stage: Validate + dependsOn: ${{ parameters.validateDependsOn }} + displayName: Validate Build Assets + variables: + - template: common-variables.yml + - template: /eng/common/templates/variables/pool-providers.yml + jobs: + - job: + displayName: NuGet Validation + condition: and(succeededOrFailed(), eq( ${{ parameters.enableNugetValidation }}, 'true')) + pool: + # We don't use the collection uri here because it might vary (.visualstudio.com vs. dev.azure.com) + ${{ if eq(variables['System.TeamProject'], 'DevDiv') }}: + name: VSEngSS-MicroBuild2022-1ES + demands: Cmd + # If it's not devdiv, it's dnceng + ${{ else }}: + name: $(DncEngInternalBuildPool) + demands: ImageOverride -equals windows.vs2019.amd64 + + steps: + - template: setup-maestro-vars.yml + parameters: + BARBuildId: ${{ parameters.BARBuildId }} + PromoteToChannelIds: ${{ parameters.PromoteToChannelIds }} + + - task: DownloadBuildArtifacts@0 + displayName: Download Package Artifacts + inputs: + buildType: specific + buildVersionToDownload: specific + project: $(AzDOProjectName) + pipeline: $(AzDOPipelineId) + buildId: $(AzDOBuildId) + artifactName: PackageArtifacts + checkDownloadedFiles: true + + - task: PowerShell@2 + displayName: Validate + inputs: + filePath: $(Build.SourcesDirectory)/eng/common/post-build/nuget-validation.ps1 + arguments: -PackagesPath $(Build.ArtifactStagingDirectory)/PackageArtifacts/ + -ToolDestinationPath $(Agent.BuildDirectory)/Extract/ + + - job: + displayName: Signing Validation + condition: and( eq( ${{ parameters.enableSigningValidation }}, 'true'), ne( variables['PostBuildSign'], 'true')) + pool: + # We don't use the collection uri here because it might vary (.visualstudio.com vs. dev.azure.com) + ${{ if eq(variables['System.TeamProject'], 'DevDiv') }}: + name: VSEngSS-MicroBuild2022-1ES + demands: Cmd + # If it's not devdiv, it's dnceng + ${{ else }}: + name: $(DncEngInternalBuildPool) + demands: ImageOverride -equals windows.vs2019.amd64 + steps: + - template: setup-maestro-vars.yml + parameters: + BARBuildId: ${{ parameters.BARBuildId }} + PromoteToChannelIds: ${{ parameters.PromoteToChannelIds }} + + - task: DownloadBuildArtifacts@0 + displayName: Download Package Artifacts + inputs: + buildType: specific + buildVersionToDownload: specific + project: $(AzDOProjectName) + pipeline: $(AzDOPipelineId) + buildId: $(AzDOBuildId) + artifactName: PackageArtifacts + checkDownloadedFiles: true + itemPattern: | + ** + !**/Microsoft.SourceBuild.Intermediate.*.nupkg + + # This is necessary whenever we want to publish/restore to an AzDO private feed + # Since sdk-task.ps1 tries to restore packages we need to do this authentication here + # otherwise it'll complain about accessing a private feed. + - task: NuGetAuthenticate@0 + displayName: 'Authenticate to AzDO Feeds' + + # Signing validation will optionally work with the buildmanifest file which is downloaded from + # Azure DevOps above. + - task: PowerShell@2 + displayName: Validate + inputs: + filePath: eng\common\sdk-task.ps1 + arguments: -task SigningValidation -restore -msbuildEngine vs + /p:PackageBasePath='$(Build.ArtifactStagingDirectory)/PackageArtifacts' + /p:SignCheckExclusionsFile='$(Build.SourcesDirectory)/eng/SignCheckExclusionsFile.txt' + ${{ parameters.signingValidationAdditionalParameters }} + + - template: ../steps/publish-logs.yml + parameters: + StageLabel: 'Validation' + JobLabel: 'Signing' + + - job: + displayName: SourceLink Validation + condition: eq( ${{ parameters.enableSourceLinkValidation }}, 'true') + pool: + # We don't use the collection uri here because it might vary (.visualstudio.com vs. dev.azure.com) + ${{ if eq(variables['System.TeamProject'], 'DevDiv') }}: + name: VSEngSS-MicroBuild2022-1ES + demands: Cmd + # If it's not devdiv, it's dnceng + ${{ else }}: + name: $(DncEngInternalBuildPool) + demands: ImageOverride -equals windows.vs2019.amd64 + steps: + - template: setup-maestro-vars.yml + parameters: + BARBuildId: ${{ parameters.BARBuildId }} + PromoteToChannelIds: ${{ parameters.PromoteToChannelIds }} + + - task: DownloadBuildArtifacts@0 + displayName: Download Blob Artifacts + inputs: + buildType: specific + buildVersionToDownload: specific + project: $(AzDOProjectName) + pipeline: $(AzDOPipelineId) + buildId: $(AzDOBuildId) + artifactName: BlobArtifacts + checkDownloadedFiles: true + + - task: PowerShell@2 + displayName: Validate + inputs: + filePath: $(Build.SourcesDirectory)/eng/common/post-build/sourcelink-validation.ps1 + arguments: -InputPath $(Build.ArtifactStagingDirectory)/BlobArtifacts/ + -ExtractPath $(Agent.BuildDirectory)/Extract/ + -GHRepoName $(Build.Repository.Name) + -GHCommit $(Build.SourceVersion) + -SourcelinkCliVersion $(SourceLinkCLIVersion) + continueOnError: true + + - template: /eng/common/templates/job/execute-sdl.yml + parameters: + enable: ${{ parameters.SDLValidationParameters.enable }} + publishGuardianDirectoryToPipeline: ${{ parameters.SDLValidationParameters.publishGdn }} + additionalParameters: ${{ parameters.SDLValidationParameters.params }} + continueOnError: ${{ parameters.SDLValidationParameters.continueOnError }} + artifactNames: ${{ parameters.SDLValidationParameters.artifactNames }} + downloadArtifacts: ${{ parameters.SDLValidationParameters.downloadArtifacts }} + +- ${{ if ne(parameters.publishAssetsImmediately, 'true') }}: + - stage: publish_using_darc + ${{ if or(eq(parameters.enableNugetValidation, 'true'), eq(parameters.enableSigningValidation, 'true'), eq(parameters.enableSourceLinkValidation, 'true'), eq(parameters.SDLValidationParameters.enable, 'true')) }}: + dependsOn: ${{ parameters.publishDependsOn }} + ${{ else }}: + dependsOn: ${{ parameters.validateDependsOn }} + displayName: Publish using Darc + variables: + - template: common-variables.yml + - template: /eng/common/templates/variables/pool-providers.yml + jobs: + - job: + displayName: Publish Using Darc + timeoutInMinutes: 120 + pool: + # We don't use the collection uri here because it might vary (.visualstudio.com vs. dev.azure.com) + ${{ if eq(variables['System.TeamProject'], 'DevDiv') }}: + name: VSEngSS-MicroBuild2022-1ES + demands: Cmd + # If it's not devdiv, it's dnceng + ${{ else }}: + name: $(DncEngInternalBuildPool) + demands: ImageOverride -equals windows.vs2019.amd64 + steps: + - template: setup-maestro-vars.yml + parameters: + BARBuildId: ${{ parameters.BARBuildId }} + PromoteToChannelIds: ${{ parameters.PromoteToChannelIds }} + + - task: NuGetAuthenticate@0 + + - task: PowerShell@2 + displayName: Publish Using Darc + inputs: + filePath: $(Build.SourcesDirectory)/eng/common/post-build/publish-using-darc.ps1 + arguments: -BuildId $(BARBuildId) + -PublishingInfraVersion ${{ parameters.publishingInfraVersion }} + -AzdoToken '$(publishing-dnceng-devdiv-code-r-build-re)' + -MaestroToken '$(MaestroApiAccessToken)' + -WaitPublishingFinish true + -ArtifactsPublishingAdditionalParameters '${{ parameters.artifactsPublishingAdditionalParameters }}' + -SymbolPublishingAdditionalParameters '${{ parameters.symbolPublishingAdditionalParameters }}' diff --git a/eng/common/templates/post-build/setup-maestro-vars.yml b/eng/common/templates/post-build/setup-maestro-vars.yml new file mode 100644 index 00000000000000..0c87f149a4ad77 --- /dev/null +++ b/eng/common/templates/post-build/setup-maestro-vars.yml @@ -0,0 +1,70 @@ +parameters: + BARBuildId: '' + PromoteToChannelIds: '' + +steps: + - ${{ if eq(coalesce(parameters.PromoteToChannelIds, 0), 0) }}: + - task: DownloadBuildArtifacts@0 + displayName: Download Release Configs + inputs: + buildType: current + artifactName: ReleaseConfigs + checkDownloadedFiles: true + + - task: PowerShell@2 + name: setReleaseVars + displayName: Set Release Configs Vars + inputs: + targetType: inline + pwsh: true + script: | + try { + if (!$Env:PromoteToMaestroChannels -or $Env:PromoteToMaestroChannels.Trim() -eq '') { + $Content = Get-Content $(Build.StagingDirectory)/ReleaseConfigs/ReleaseConfigs.txt + + $BarId = $Content | Select -Index 0 + $Channels = $Content | Select -Index 1 + $IsStableBuild = $Content | Select -Index 2 + + $AzureDevOpsProject = $Env:System_TeamProject + $AzureDevOpsBuildDefinitionId = $Env:System_DefinitionId + $AzureDevOpsBuildId = $Env:Build_BuildId + } + else { + $buildApiEndpoint = "${Env:MaestroApiEndPoint}/api/builds/${Env:BARBuildId}?api-version=${Env:MaestroApiVersion}" + + $apiHeaders = New-Object 'System.Collections.Generic.Dictionary[[String],[String]]' + $apiHeaders.Add('Accept', 'application/json') + $apiHeaders.Add('Authorization',"Bearer ${Env:MAESTRO_API_TOKEN}") + + $buildInfo = try { Invoke-WebRequest -Method Get -Uri $buildApiEndpoint -Headers $apiHeaders | ConvertFrom-Json } catch { Write-Host "Error: $_" } + + $BarId = $Env:BARBuildId + $Channels = $Env:PromoteToMaestroChannels -split "," + $Channels = $Channels -join "][" + $Channels = "[$Channels]" + + $IsStableBuild = $buildInfo.stable + $AzureDevOpsProject = $buildInfo.azureDevOpsProject + $AzureDevOpsBuildDefinitionId = $buildInfo.azureDevOpsBuildDefinitionId + $AzureDevOpsBuildId = $buildInfo.azureDevOpsBuildId + } + + Write-Host "##vso[task.setvariable variable=BARBuildId]$BarId" + Write-Host "##vso[task.setvariable variable=TargetChannels]$Channels" + Write-Host "##vso[task.setvariable variable=IsStableBuild]$IsStableBuild" + + Write-Host "##vso[task.setvariable variable=AzDOProjectName]$AzureDevOpsProject" + Write-Host "##vso[task.setvariable variable=AzDOPipelineId]$AzureDevOpsBuildDefinitionId" + Write-Host "##vso[task.setvariable variable=AzDOBuildId]$AzureDevOpsBuildId" + } + catch { + Write-Host $_ + Write-Host $_.Exception + Write-Host $_.ScriptStackTrace + exit 1 + } + env: + MAESTRO_API_TOKEN: $(MaestroApiAccessToken) + BARBuildId: ${{ parameters.BARBuildId }} + PromoteToMaestroChannels: ${{ parameters.PromoteToChannelIds }} diff --git a/eng/common/templates/post-build/trigger-subscription.yml b/eng/common/templates/post-build/trigger-subscription.yml new file mode 100644 index 00000000000000..da669030daf6e9 --- /dev/null +++ b/eng/common/templates/post-build/trigger-subscription.yml @@ -0,0 +1,13 @@ +parameters: + ChannelId: 0 + +steps: +- task: PowerShell@2 + displayName: Triggering subscriptions + inputs: + filePath: $(Build.SourcesDirectory)/eng/common/post-build/trigger-subscriptions.ps1 + arguments: -SourceRepo $(Build.Repository.Uri) + -ChannelId ${{ parameters.ChannelId }} + -MaestroApiAccessToken $(MaestroAccessToken) + -MaestroApiEndPoint $(MaestroApiEndPoint) + -MaestroApiVersion $(MaestroApiVersion) diff --git a/eng/common/templates/steps/add-build-to-channel.yml b/eng/common/templates/steps/add-build-to-channel.yml new file mode 100644 index 00000000000000..f67a210d62f3e5 --- /dev/null +++ b/eng/common/templates/steps/add-build-to-channel.yml @@ -0,0 +1,13 @@ +parameters: + ChannelId: 0 + +steps: +- task: PowerShell@2 + displayName: Add Build to Channel + inputs: + filePath: $(Build.SourcesDirectory)/eng/common/post-build/add-build-to-channel.ps1 + arguments: -BuildId $(BARBuildId) + -ChannelId ${{ parameters.ChannelId }} + -MaestroApiAccessToken $(MaestroApiAccessToken) + -MaestroApiEndPoint $(MaestroApiEndPoint) + -MaestroApiVersion $(MaestroApiVersion) diff --git a/eng/common/templates/steps/build-reason.yml b/eng/common/templates/steps/build-reason.yml new file mode 100644 index 00000000000000..eba58109b52c9d --- /dev/null +++ b/eng/common/templates/steps/build-reason.yml @@ -0,0 +1,12 @@ +# build-reason.yml +# Description: runs steps if build.reason condition is valid. conditions is a string of valid build reasons +# to include steps (',' separated). +parameters: + conditions: '' + steps: [] + +steps: + - ${{ if and( not(startsWith(parameters.conditions, 'not')), contains(parameters.conditions, variables['build.reason'])) }}: + - ${{ parameters.steps }} + - ${{ if and( startsWith(parameters.conditions, 'not'), not(contains(parameters.conditions, variables['build.reason']))) }}: + - ${{ parameters.steps }} diff --git a/eng/common/templates/steps/component-governance.yml b/eng/common/templates/steps/component-governance.yml new file mode 100644 index 00000000000000..0ecec47b0c9177 --- /dev/null +++ b/eng/common/templates/steps/component-governance.yml @@ -0,0 +1,13 @@ +parameters: + disableComponentGovernance: false + componentGovernanceIgnoreDirectories: '' + +steps: +- ${{ if eq(parameters.disableComponentGovernance, 'true') }}: + - script: "echo ##vso[task.setvariable variable=skipComponentGovernanceDetection]true" + displayName: Set skipComponentGovernanceDetection variable +- ${{ if ne(parameters.disableComponentGovernance, 'true') }}: + - task: ComponentGovernanceComponentDetection@0 + continueOnError: true + inputs: + ignoreDirectories: ${{ parameters.componentGovernanceIgnoreDirectories }} \ No newline at end of file diff --git a/eng/common/templates/steps/execute-codeql.yml b/eng/common/templates/steps/execute-codeql.yml new file mode 100644 index 00000000000000..3930b1630214b3 --- /dev/null +++ b/eng/common/templates/steps/execute-codeql.yml @@ -0,0 +1,32 @@ +parameters: + # Language that should be analyzed. Defaults to csharp + language: csharp + # Build Commands + buildCommands: '' + overrideParameters: '' # Optional: to override values for parameters. + additionalParameters: '' # Optional: parameters that need user specific values eg: '-SourceToolsList @("abc","def") -ArtifactToolsList @("ghi","jkl")' + # Optional: if specified, restore and use this version of Guardian instead of the default. + overrideGuardianVersion: '' + # Optional: if true, publish the '.gdn' folder as a pipeline artifact. This can help with in-depth + # diagnosis of problems with specific tool configurations. + publishGuardianDirectoryToPipeline: false + # The script to run to execute all SDL tools. Use this if you want to use a script to define SDL + # parameters rather than relying on YAML. It may be better to use a local script, because you can + # reproduce results locally without piecing together a command based on the YAML. + executeAllSdlToolsScript: 'eng/common/sdl/execute-all-sdl-tools.ps1' + # There is some sort of bug (has been reported) in Azure DevOps where if this parameter is named + # 'continueOnError', the parameter value is not correctly picked up. + # This can also be remedied by the caller (post-build.yml) if it does not use a nested parameter + # optional: determines whether to continue the build if the step errors; + sdlContinueOnError: false + +steps: +- template: /eng/common/templates/steps/execute-sdl.yml + parameters: + overrideGuardianVersion: ${{ parameters.overrideGuardianVersion }} + executeAllSdlToolsScript: ${{ parameters.executeAllSdlToolsScript }} + overrideParameters: ${{ parameters.overrideParameters }} + additionalParameters: '${{ parameters.additionalParameters }} + -CodeQLAdditionalRunConfigParams @("BuildCommands < ${{ parameters.buildCommands }}", "Language < ${{ parameters.language }}")' + publishGuardianDirectoryToPipeline: ${{ parameters.publishGuardianDirectoryToPipeline }} + sdlContinueOnError: ${{ parameters.sdlContinueOnError }} \ No newline at end of file diff --git a/eng/common/templates/steps/execute-sdl.yml b/eng/common/templates/steps/execute-sdl.yml new file mode 100644 index 00000000000000..9dd5709f66dc71 --- /dev/null +++ b/eng/common/templates/steps/execute-sdl.yml @@ -0,0 +1,88 @@ +parameters: + overrideGuardianVersion: '' + executeAllSdlToolsScript: '' + overrideParameters: '' + additionalParameters: '' + publishGuardianDirectoryToPipeline: false + sdlContinueOnError: false + condition: '' + +steps: +- task: NuGetAuthenticate@1 + inputs: + nuGetServiceConnections: GuardianConnect + +- task: NuGetToolInstaller@1 + displayName: 'Install NuGet.exe' + +- ${{ if ne(parameters.overrideGuardianVersion, '') }}: + - pwsh: | + Set-Location -Path $(Build.SourcesDirectory)\eng\common\sdl + . .\sdl.ps1 + $guardianCliLocation = Install-Gdn -Path $(Build.SourcesDirectory)\.artifacts -Version ${{ parameters.overrideGuardianVersion }} + Write-Host "##vso[task.setvariable variable=GuardianCliLocation]$guardianCliLocation" + displayName: Install Guardian (Overridden) + +- ${{ if eq(parameters.overrideGuardianVersion, '') }}: + - pwsh: | + Set-Location -Path $(Build.SourcesDirectory)\eng\common\sdl + . .\sdl.ps1 + $guardianCliLocation = Install-Gdn -Path $(Build.SourcesDirectory)\.artifacts + Write-Host "##vso[task.setvariable variable=GuardianCliLocation]$guardianCliLocation" + displayName: Install Guardian + +- ${{ if ne(parameters.overrideParameters, '') }}: + - powershell: ${{ parameters.executeAllSdlToolsScript }} ${{ parameters.overrideParameters }} + displayName: Execute SDL + continueOnError: ${{ parameters.sdlContinueOnError }} + condition: ${{ parameters.condition }} + +- ${{ if eq(parameters.overrideParameters, '') }}: + - powershell: ${{ parameters.executeAllSdlToolsScript }} + -GuardianCliLocation $(GuardianCliLocation) + -NugetPackageDirectory $(Build.SourcesDirectory)\.packages + -AzureDevOpsAccessToken $(dn-bot-dotnet-build-rw-code-rw) + ${{ parameters.additionalParameters }} + displayName: Execute SDL + continueOnError: ${{ parameters.sdlContinueOnError }} + condition: ${{ parameters.condition }} + +- ${{ if ne(parameters.publishGuardianDirectoryToPipeline, 'false') }}: + # We want to publish the Guardian results and configuration for easy diagnosis. However, the + # '.gdn' dir is a mix of configuration, results, extracted dependencies, and Guardian default + # tooling files. Some of these files are large and aren't useful during an investigation, so + # exclude them by simply deleting them before publishing. (As of writing, there is no documented + # way to selectively exclude a dir from the pipeline artifact publish task.) + - task: DeleteFiles@1 + displayName: Delete Guardian dependencies to avoid uploading + inputs: + SourceFolder: $(Agent.BuildDirectory)/.gdn + Contents: | + c + i + condition: succeededOrFailed() + + - publish: $(Agent.BuildDirectory)/.gdn + artifact: GuardianConfiguration + displayName: Publish GuardianConfiguration + condition: succeededOrFailed() + + # Publish the SARIF files in a container named CodeAnalysisLogs to enable integration + # with the "SARIF SAST Scans Tab" Azure DevOps extension + - task: CopyFiles@2 + displayName: Copy SARIF files + inputs: + flattenFolders: true + sourceFolder: $(Agent.BuildDirectory)/.gdn/rc/ + contents: '**/*.sarif' + targetFolder: $(Build.SourcesDirectory)/CodeAnalysisLogs + condition: succeededOrFailed() + + # Use PublishBuildArtifacts because the SARIF extension only checks this case + # see microsoft/sarif-azuredevops-extension#4 + - task: PublishBuildArtifacts@1 + displayName: Publish SARIF files to CodeAnalysisLogs container + inputs: + pathToPublish: $(Build.SourcesDirectory)/CodeAnalysisLogs + artifactName: CodeAnalysisLogs + condition: succeededOrFailed() \ No newline at end of file diff --git a/eng/common/templates/steps/generate-sbom.yml b/eng/common/templates/steps/generate-sbom.yml new file mode 100644 index 00000000000000..a06373f38fa5d5 --- /dev/null +++ b/eng/common/templates/steps/generate-sbom.yml @@ -0,0 +1,48 @@ +# BuildDropPath - The root folder of the drop directory for which the manifest file will be generated. +# PackageName - The name of the package this SBOM represents. +# PackageVersion - The version of the package this SBOM represents. +# ManifestDirPath - The path of the directory where the generated manifest files will be placed +# IgnoreDirectories - Directories to ignore for SBOM generation. This will be passed through to the CG component detector. + +parameters: + PackageVersion: 7.0.0 + BuildDropPath: '$(Build.SourcesDirectory)/artifacts' + PackageName: '.NET' + ManifestDirPath: $(Build.ArtifactStagingDirectory)/sbom + IgnoreDirectories: '' + sbomContinueOnError: true + +steps: +- task: PowerShell@2 + displayName: Prep for SBOM generation in (Non-linux) + condition: or(eq(variables['Agent.Os'], 'Windows_NT'), eq(variables['Agent.Os'], 'Darwin')) + inputs: + filePath: ./eng/common/generate-sbom-prep.ps1 + arguments: ${{parameters.manifestDirPath}} + +# Chmodding is a workaround for https://github.com/dotnet/arcade/issues/8461 +- script: | + chmod +x ./eng/common/generate-sbom-prep.sh + ./eng/common/generate-sbom-prep.sh ${{parameters.manifestDirPath}} + displayName: Prep for SBOM generation in (Linux) + condition: eq(variables['Agent.Os'], 'Linux') + continueOnError: ${{ parameters.sbomContinueOnError }} + +- task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0 + displayName: 'Generate SBOM manifest' + continueOnError: ${{ parameters.sbomContinueOnError }} + inputs: + PackageName: ${{ parameters.packageName }} + BuildDropPath: ${{ parameters.buildDropPath }} + PackageVersion: ${{ parameters.packageVersion }} + ManifestDirPath: ${{ parameters.manifestDirPath }} + ${{ if ne(parameters.IgnoreDirectories, '') }}: + AdditionalComponentDetectorArgs: '--IgnoreDirectories ${{ parameters.IgnoreDirectories }}' + +- task: PublishPipelineArtifact@1 + displayName: Publish SBOM manifest + continueOnError: ${{parameters.sbomContinueOnError}} + inputs: + targetPath: '${{parameters.manifestDirPath}}' + artifactName: $(ARTIFACT_NAME) + diff --git a/eng/common/templates/steps/publish-logs.yml b/eng/common/templates/steps/publish-logs.yml new file mode 100644 index 00000000000000..88f238f36bfd8d --- /dev/null +++ b/eng/common/templates/steps/publish-logs.yml @@ -0,0 +1,23 @@ +parameters: + StageLabel: '' + JobLabel: '' + +steps: +- task: Powershell@2 + displayName: Prepare Binlogs to Upload + inputs: + targetType: inline + script: | + New-Item -ItemType Directory $(Build.SourcesDirectory)/PostBuildLogs/${{parameters.StageLabel}}/${{parameters.JobLabel}}/ + Move-Item -Path $(Build.SourcesDirectory)/artifacts/log/Debug/* $(Build.SourcesDirectory)/PostBuildLogs/${{parameters.StageLabel}}/${{parameters.JobLabel}}/ + continueOnError: true + condition: always() + +- task: PublishBuildArtifacts@1 + displayName: Publish Logs + inputs: + PathtoPublish: '$(Build.SourcesDirectory)/PostBuildLogs' + PublishLocation: Container + ArtifactName: PostBuildLogs + continueOnError: true + condition: always() diff --git a/eng/common/templates/steps/retain-build.yml b/eng/common/templates/steps/retain-build.yml new file mode 100644 index 00000000000000..83d97a26a01ff9 --- /dev/null +++ b/eng/common/templates/steps/retain-build.yml @@ -0,0 +1,28 @@ +parameters: + # Optional azure devops PAT with build execute permissions for the build's organization, + # only needed if the build that should be retained ran on a different organization than + # the pipeline where this template is executing from + Token: '' + # Optional BuildId to retain, defaults to the current running build + BuildId: '' + # Azure devops Organization URI for the build in the https://dev.azure.com/ format. + # Defaults to the organization the current pipeline is running on + AzdoOrgUri: '$(System.CollectionUri)' + # Azure devops project for the build. Defaults to the project the current pipeline is running on + AzdoProject: '$(System.TeamProject)' + +steps: + - task: powershell@2 + inputs: + targetType: 'filePath' + filePath: eng/common/retain-build.ps1 + pwsh: true + arguments: > + -AzdoOrgUri: ${{parameters.AzdoOrgUri}} + -AzdoProject ${{parameters.AzdoProject}} + -Token ${{coalesce(parameters.Token, '$env:SYSTEM_ACCESSTOKEN') }} + -BuildId ${{coalesce(parameters.BuildId, '$env:BUILD_ID')}} + displayName: Enable permanent build retention + env: + SYSTEM_ACCESSTOKEN: $(System.AccessToken) + BUILD_ID: $(Build.BuildId) \ No newline at end of file diff --git a/eng/common/templates/steps/run-on-unix.yml b/eng/common/templates/steps/run-on-unix.yml new file mode 100644 index 00000000000000..e1733814f65dcc --- /dev/null +++ b/eng/common/templates/steps/run-on-unix.yml @@ -0,0 +1,7 @@ +parameters: + agentOs: '' + steps: [] + +steps: +- ${{ if ne(parameters.agentOs, 'Windows_NT') }}: + - ${{ parameters.steps }} diff --git a/eng/common/templates/steps/run-on-windows.yml b/eng/common/templates/steps/run-on-windows.yml new file mode 100644 index 00000000000000..73e7e9c275a1f1 --- /dev/null +++ b/eng/common/templates/steps/run-on-windows.yml @@ -0,0 +1,7 @@ +parameters: + agentOs: '' + steps: [] + +steps: +- ${{ if eq(parameters.agentOs, 'Windows_NT') }}: + - ${{ parameters.steps }} diff --git a/eng/common/templates/steps/run-script-ifequalelse.yml b/eng/common/templates/steps/run-script-ifequalelse.yml new file mode 100644 index 00000000000000..3d1242f5587c82 --- /dev/null +++ b/eng/common/templates/steps/run-script-ifequalelse.yml @@ -0,0 +1,33 @@ +parameters: + # if parameter1 equals parameter 2, run 'ifScript' command, else run 'elsescript' command + parameter1: '' + parameter2: '' + ifScript: '' + elseScript: '' + + # name of script step + name: Script + + # display name of script step + displayName: If-Equal-Else Script + + # environment + env: {} + + # conditional expression for step execution + condition: '' + +steps: +- ${{ if and(ne(parameters.ifScript, ''), eq(parameters.parameter1, parameters.parameter2)) }}: + - script: ${{ parameters.ifScript }} + name: ${{ parameters.name }} + displayName: ${{ parameters.displayName }} + env: ${{ parameters.env }} + condition: ${{ parameters.condition }} + +- ${{ if and(ne(parameters.elseScript, ''), ne(parameters.parameter1, parameters.parameter2)) }}: + - script: ${{ parameters.elseScript }} + name: ${{ parameters.name }} + displayName: ${{ parameters.displayName }} + env: ${{ parameters.env }} + condition: ${{ parameters.condition }} \ No newline at end of file diff --git a/eng/common/templates/steps/send-to-helix.yml b/eng/common/templates/steps/send-to-helix.yml new file mode 100644 index 00000000000000..3eb7e2d5f840c7 --- /dev/null +++ b/eng/common/templates/steps/send-to-helix.yml @@ -0,0 +1,91 @@ +# Please remember to update the documentation if you make changes to these parameters! +parameters: + HelixSource: 'pr/default' # required -- sources must start with pr/, official/, prodcon/, or agent/ + HelixType: 'tests/default/' # required -- Helix telemetry which identifies what type of data this is; should include "test" for clarity and must end in '/' + HelixBuild: $(Build.BuildNumber) # required -- the build number Helix will use to identify this -- automatically set to the AzDO build number + HelixTargetQueues: '' # required -- semicolon-delimited list of Helix queues to test on; see https://helix.dot.net/ for a list of queues + HelixAccessToken: '' # required -- access token to make Helix API requests; should be provided by the appropriate variable group + HelixConfiguration: '' # optional -- additional property attached to a job + HelixPreCommands: '' # optional -- commands to run before Helix work item execution + HelixPostCommands: '' # optional -- commands to run after Helix work item execution + WorkItemDirectory: '' # optional -- a payload directory to zip up and send to Helix; requires WorkItemCommand; incompatible with XUnitProjects + WorkItemCommand: '' # optional -- a command to execute on the payload; requires WorkItemDirectory; incompatible with XUnitProjects + WorkItemTimeout: '' # optional -- a timeout in TimeSpan.Parse-ready value (e.g. 00:02:00) for the work item command; requires WorkItemDirectory; incompatible with XUnitProjects + CorrelationPayloadDirectory: '' # optional -- a directory to zip up and send to Helix as a correlation payload + XUnitProjects: '' # optional -- semicolon-delimited list of XUnitProjects to parse and send to Helix; requires XUnitRuntimeTargetFramework, XUnitPublishTargetFramework, XUnitRunnerVersion, and IncludeDotNetCli=true + XUnitWorkItemTimeout: '' # optional -- the workitem timeout in seconds for all workitems created from the xUnit projects specified by XUnitProjects + XUnitPublishTargetFramework: '' # optional -- framework to use to publish your xUnit projects + XUnitRuntimeTargetFramework: '' # optional -- framework to use for the xUnit console runner + XUnitRunnerVersion: '' # optional -- version of the xUnit nuget package you wish to use on Helix; required for XUnitProjects + IncludeDotNetCli: false # optional -- true will download a version of the .NET CLI onto the Helix machine as a correlation payload; requires DotNetCliPackageType and DotNetCliVersion + DotNetCliPackageType: '' # optional -- either 'sdk', 'runtime' or 'aspnetcore-runtime'; determines whether the sdk or runtime will be sent to Helix; see https://raw.githubusercontent.com/dotnet/core/main/release-notes/releases-index.json + DotNetCliVersion: '' # optional -- version of the CLI to send to Helix; based on this: https://raw.githubusercontent.com/dotnet/core/main/release-notes/releases-index.json + WaitForWorkItemCompletion: true # optional -- true will make the task wait until work items have been completed and fail the build if work items fail. False is "fire and forget." + IsExternal: false # [DEPRECATED] -- doesn't do anything, jobs are external if HelixAccessToken is empty and Creator is set + HelixBaseUri: 'https://helix.dot.net/' # optional -- sets the Helix API base URI (allows targeting https://helix.int-dot.net ) + Creator: '' # optional -- if the build is external, use this to specify who is sending the job + DisplayNamePrefix: 'Run Tests' # optional -- rename the beginning of the displayName of the steps in AzDO + condition: succeeded() # optional -- condition for step to execute; defaults to succeeded() + continueOnError: false # optional -- determines whether to continue the build if the step errors; defaults to false + +steps: + - powershell: 'powershell "$env:BUILD_SOURCESDIRECTORY\eng\common\msbuild.ps1 $env:BUILD_SOURCESDIRECTORY\eng\common\helixpublish.proj /restore /p:TreatWarningsAsErrors=false /t:Test /bl:$env:BUILD_SOURCESDIRECTORY\artifacts\log\$env:BuildConfig\SendToHelix.binlog"' + displayName: ${{ parameters.DisplayNamePrefix }} (Windows) + env: + BuildConfig: $(_BuildConfig) + HelixSource: ${{ parameters.HelixSource }} + HelixType: ${{ parameters.HelixType }} + HelixBuild: ${{ parameters.HelixBuild }} + HelixConfiguration: ${{ parameters.HelixConfiguration }} + HelixTargetQueues: ${{ parameters.HelixTargetQueues }} + HelixAccessToken: ${{ parameters.HelixAccessToken }} + HelixPreCommands: ${{ parameters.HelixPreCommands }} + HelixPostCommands: ${{ parameters.HelixPostCommands }} + WorkItemDirectory: ${{ parameters.WorkItemDirectory }} + WorkItemCommand: ${{ parameters.WorkItemCommand }} + WorkItemTimeout: ${{ parameters.WorkItemTimeout }} + CorrelationPayloadDirectory: ${{ parameters.CorrelationPayloadDirectory }} + XUnitProjects: ${{ parameters.XUnitProjects }} + XUnitWorkItemTimeout: ${{ parameters.XUnitWorkItemTimeout }} + XUnitPublishTargetFramework: ${{ parameters.XUnitPublishTargetFramework }} + XUnitRuntimeTargetFramework: ${{ parameters.XUnitRuntimeTargetFramework }} + XUnitRunnerVersion: ${{ parameters.XUnitRunnerVersion }} + IncludeDotNetCli: ${{ parameters.IncludeDotNetCli }} + DotNetCliPackageType: ${{ parameters.DotNetCliPackageType }} + DotNetCliVersion: ${{ parameters.DotNetCliVersion }} + WaitForWorkItemCompletion: ${{ parameters.WaitForWorkItemCompletion }} + HelixBaseUri: ${{ parameters.HelixBaseUri }} + Creator: ${{ parameters.Creator }} + SYSTEM_ACCESSTOKEN: $(System.AccessToken) + condition: and(${{ parameters.condition }}, eq(variables['Agent.Os'], 'Windows_NT')) + continueOnError: ${{ parameters.continueOnError }} + - script: $BUILD_SOURCESDIRECTORY/eng/common/msbuild.sh $BUILD_SOURCESDIRECTORY/eng/common/helixpublish.proj /restore /p:TreatWarningsAsErrors=false /t:Test /bl:$BUILD_SOURCESDIRECTORY/artifacts/log/$BuildConfig/SendToHelix.binlog + displayName: ${{ parameters.DisplayNamePrefix }} (Unix) + env: + BuildConfig: $(_BuildConfig) + HelixSource: ${{ parameters.HelixSource }} + HelixType: ${{ parameters.HelixType }} + HelixBuild: ${{ parameters.HelixBuild }} + HelixConfiguration: ${{ parameters.HelixConfiguration }} + HelixTargetQueues: ${{ parameters.HelixTargetQueues }} + HelixAccessToken: ${{ parameters.HelixAccessToken }} + HelixPreCommands: ${{ parameters.HelixPreCommands }} + HelixPostCommands: ${{ parameters.HelixPostCommands }} + WorkItemDirectory: ${{ parameters.WorkItemDirectory }} + WorkItemCommand: ${{ parameters.WorkItemCommand }} + WorkItemTimeout: ${{ parameters.WorkItemTimeout }} + CorrelationPayloadDirectory: ${{ parameters.CorrelationPayloadDirectory }} + XUnitProjects: ${{ parameters.XUnitProjects }} + XUnitWorkItemTimeout: ${{ parameters.XUnitWorkItemTimeout }} + XUnitPublishTargetFramework: ${{ parameters.XUnitPublishTargetFramework }} + XUnitRuntimeTargetFramework: ${{ parameters.XUnitRuntimeTargetFramework }} + XUnitRunnerVersion: ${{ parameters.XUnitRunnerVersion }} + IncludeDotNetCli: ${{ parameters.IncludeDotNetCli }} + DotNetCliPackageType: ${{ parameters.DotNetCliPackageType }} + DotNetCliVersion: ${{ parameters.DotNetCliVersion }} + WaitForWorkItemCompletion: ${{ parameters.WaitForWorkItemCompletion }} + HelixBaseUri: ${{ parameters.HelixBaseUri }} + Creator: ${{ parameters.Creator }} + SYSTEM_ACCESSTOKEN: $(System.AccessToken) + condition: and(${{ parameters.condition }}, ne(variables['Agent.Os'], 'Windows_NT')) + continueOnError: ${{ parameters.continueOnError }} diff --git a/eng/common/templates/steps/source-build.yml b/eng/common/templates/steps/source-build.yml new file mode 100644 index 00000000000000..a97a185a367a92 --- /dev/null +++ b/eng/common/templates/steps/source-build.yml @@ -0,0 +1,114 @@ +parameters: + # This template adds arcade-powered source-build to CI. + + # This is a 'steps' template, and is intended for advanced scenarios where the existing build + # infra has a careful build methodology that must be followed. For example, a repo + # (dotnet/runtime) might choose to clone the GitHub repo only once and store it as a pipeline + # artifact for all subsequent jobs to use, to reduce dependence on a strong network connection to + # GitHub. Using this steps template leaves room for that infra to be included. + + # Defines the platform on which to run the steps. See 'eng/common/templates/job/source-build.yml' + # for details. The entire object is described in the 'job' template for simplicity, even though + # the usage of the properties on this object is split between the 'job' and 'steps' templates. + platform: {} + +steps: +# Build. Keep it self-contained for simple reusability. (No source-build-specific job variables.) +- script: | + set -x + df -h + + # If building on the internal project, the artifact feeds variable may be available (usually only if needed) + # In that case, call the feed setup script to add internal feeds corresponding to public ones. + # In addition, add an msbuild argument to copy the WIP from the repo to the target build location. + # This is because SetupNuGetSources.sh will alter the current NuGet.config file, and we need to preserve those + # changes. + internalRestoreArgs= + if [ '$(dn-bot-dnceng-artifact-feeds-rw)' != '$''(dn-bot-dnceng-artifact-feeds-rw)' ]; then + # Temporarily work around https://github.com/dotnet/arcade/issues/7709 + chmod +x $(Build.SourcesDirectory)/eng/common/SetupNugetSources.sh + $(Build.SourcesDirectory)/eng/common/SetupNugetSources.sh $(Build.SourcesDirectory)/NuGet.config $(dn-bot-dnceng-artifact-feeds-rw) + internalRestoreArgs='/p:CopyWipIntoInnerSourceBuildRepo=true' + + # The 'Copy WIP' feature of source build uses git stash to apply changes from the original repo. + # This only works if there is a username/email configured, which won't be the case in most CI runs. + git config --get user.email + if [ $? -ne 0 ]; then + git config user.email dn-bot@microsoft.com + git config user.name dn-bot + fi + fi + + # If building on the internal project, the internal storage variable may be available (usually only if needed) + # In that case, add variables to allow the download of internal runtimes if the specified versions are not found + # in the default public locations. + internalRuntimeDownloadArgs= + if [ '$(dotnetbuilds-internal-container-read-token-base64)' != '$''(dotnetbuilds-internal-container-read-token-base64)' ]; then + internalRuntimeDownloadArgs='/p:DotNetRuntimeSourceFeed=https://dotnetbuilds.blob.core.windows.net/internal /p:DotNetRuntimeSourceFeedKey=$(dotnetbuilds-internal-container-read-token-base64) --runtimesourcefeed https://dotnetbuilds.blob.core.windows.net/internal --runtimesourcefeedkey $(dotnetbuilds-internal-container-read-token-base64)' + fi + + buildConfig=Release + # Check if AzDO substitutes in a build config from a variable, and use it if so. + if [ '$(_BuildConfig)' != '$''(_BuildConfig)' ]; then + buildConfig='$(_BuildConfig)' + fi + + officialBuildArgs= + if [ '${{ and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}' = 'True' ]; then + officialBuildArgs='/p:DotNetPublishUsingPipelines=true /p:OfficialBuildId=$(BUILD.BUILDNUMBER)' + fi + + targetRidArgs= + if [ '${{ parameters.platform.targetRID }}' != '' ]; then + targetRidArgs='/p:TargetRid=${{ parameters.platform.targetRID }}' + fi + + runtimeOsArgs= + if [ '${{ parameters.platform.runtimeOS }}' != '' ]; then + runtimeOsArgs='/p:RuntimeOS=${{ parameters.platform.runtimeOS }}' + fi + + publishArgs= + if [ '${{ parameters.platform.skipPublishValidation }}' != 'true' ]; then + publishArgs='--publish' + fi + + assetManifestFileName=SourceBuild_RidSpecific.xml + if [ '${{ parameters.platform.name }}' != '' ]; then + assetManifestFileName=SourceBuild_${{ parameters.platform.name }}.xml + fi + + ${{ coalesce(parameters.platform.buildScript, './build.sh') }} --ci \ + --configuration $buildConfig \ + --restore --build --pack $publishArgs -bl \ + $officialBuildArgs \ + $internalRuntimeDownloadArgs \ + $internalRestoreArgs \ + $targetRidArgs \ + $runtimeOsArgs \ + /p:SourceBuildNonPortable=${{ parameters.platform.nonPortable }} \ + /p:ArcadeBuildFromSource=true \ + /p:AssetManifestFileName=$assetManifestFileName + displayName: Build + +# Upload build logs for diagnosis. +- task: CopyFiles@2 + displayName: Prepare BuildLogs staging directory + inputs: + SourceFolder: '$(Build.SourcesDirectory)' + Contents: | + **/*.log + **/*.binlog + artifacts/source-build/self/prebuilt-report/** + TargetFolder: '$(Build.StagingDirectory)/BuildLogs' + CleanTargetFolder: true + continueOnError: true + condition: succeededOrFailed() + +- task: PublishPipelineArtifact@1 + displayName: Publish BuildLogs + inputs: + targetPath: '$(Build.StagingDirectory)/BuildLogs' + artifactName: BuildLogs_SourceBuild_${{ parameters.platform.name }}_Attempt$(System.JobAttempt) + continueOnError: true + condition: succeededOrFailed() diff --git a/eng/common/templates/steps/telemetry-end.yml b/eng/common/templates/steps/telemetry-end.yml new file mode 100644 index 00000000000000..fadc04ca1b9a3e --- /dev/null +++ b/eng/common/templates/steps/telemetry-end.yml @@ -0,0 +1,102 @@ +parameters: + maxRetries: 5 + retryDelay: 10 # in seconds + +steps: +- bash: | + if [ "$AGENT_JOBSTATUS" = "Succeeded" ] || [ "$AGENT_JOBSTATUS" = "PartiallySucceeded" ]; then + errorCount=0 + else + errorCount=1 + fi + warningCount=0 + + curlStatus=1 + retryCount=0 + # retry loop to harden against spotty telemetry connections + # we don't retry successes and 4xx client errors + until [[ $curlStatus -eq 0 || ( $curlStatus -ge 400 && $curlStatus -le 499 ) || $retryCount -ge $MaxRetries ]] + do + if [ $retryCount -gt 0 ]; then + echo "Failed to send telemetry to Helix; waiting $RetryDelay seconds before retrying..." + sleep $RetryDelay + fi + + # create a temporary file for curl output + res=`mktemp` + + curlResult=` + curl --verbose --output $res --write-out "%{http_code}"\ + -H 'Content-Type: application/json' \ + -H "X-Helix-Job-Token: $Helix_JobToken" \ + -H 'Content-Length: 0' \ + -X POST -G "https://helix.dot.net/api/2018-03-14/telemetry/job/build/$Helix_WorkItemId/finish" \ + --data-urlencode "errorCount=$errorCount" \ + --data-urlencode "warningCount=$warningCount"` + curlStatus=$? + + if [ $curlStatus -eq 0 ]; then + if [ $curlResult -gt 299 ] || [ $curlResult -lt 200 ]; then + curlStatus=$curlResult + fi + fi + + let retryCount++ + done + + if [ $curlStatus -ne 0 ]; then + echo "Failed to Send Build Finish information after $retryCount retries" + vstsLogOutput="vso[task.logissue type=error;sourcepath=templates/steps/telemetry-end.yml;code=1;]Failed to Send Build Finish information: $curlStatus" + echo "##$vstsLogOutput" + exit 1 + fi + displayName: Send Unix Build End Telemetry + env: + # defined via VSTS variables in start-job.sh + Helix_JobToken: $(Helix_JobToken) + Helix_WorkItemId: $(Helix_WorkItemId) + MaxRetries: ${{ parameters.maxRetries }} + RetryDelay: ${{ parameters.retryDelay }} + condition: and(always(), ne(variables['Agent.Os'], 'Windows_NT')) +- powershell: | + if (($env:Agent_JobStatus -eq 'Succeeded') -or ($env:Agent_JobStatus -eq 'PartiallySucceeded')) { + $ErrorCount = 0 + } else { + $ErrorCount = 1 + } + $WarningCount = 0 + + # Basic retry loop to harden against server flakiness + $retryCount = 0 + while ($retryCount -lt $env:MaxRetries) { + try { + Invoke-RestMethod -Uri "https://helix.dot.net/api/2018-03-14/telemetry/job/build/$env:Helix_WorkItemId/finish?errorCount=$ErrorCount&warningCount=$WarningCount" -Method Post -ContentType "application/json" -Body "" ` + -Headers @{ 'X-Helix-Job-Token'=$env:Helix_JobToken } + break + } + catch { + $statusCode = $_.Exception.Response.StatusCode.value__ + if ($statusCode -ge 400 -and $statusCode -le 499) { + Write-Host "##vso[task.logissue]error Failed to send telemetry to Helix (status code $statusCode); not retrying (4xx client error)" + Write-Host "##vso[task.logissue]error ", $_.Exception.GetType().FullName, $_.Exception.Message + exit 1 + } + Write-Host "Failed to send telemetry to Helix (status code $statusCode); waiting $env:RetryDelay seconds before retrying..." + $retryCount++ + sleep $env:RetryDelay + continue + } + } + + if ($retryCount -ge $env:MaxRetries) { + Write-Host "##vso[task.logissue]error Failed to send telemetry to Helix after $retryCount retries." + exit 1 + } + displayName: Send Windows Build End Telemetry + env: + # defined via VSTS variables in start-job.ps1 + Helix_JobToken: $(Helix_JobToken) + Helix_WorkItemId: $(Helix_WorkItemId) + MaxRetries: ${{ parameters.maxRetries }} + RetryDelay: ${{ parameters.retryDelay }} + condition: and(always(),eq(variables['Agent.Os'], 'Windows_NT')) diff --git a/eng/common/templates/steps/telemetry-start.yml b/eng/common/templates/steps/telemetry-start.yml new file mode 100644 index 00000000000000..32c01ef0b553b4 --- /dev/null +++ b/eng/common/templates/steps/telemetry-start.yml @@ -0,0 +1,241 @@ +parameters: + helixSource: 'undefined_defaulted_in_telemetry.yml' + helixType: 'undefined_defaulted_in_telemetry.yml' + buildConfig: '' + runAsPublic: false + maxRetries: 5 + retryDelay: 10 # in seconds + +steps: +- ${{ if and(eq(parameters.runAsPublic, 'false'), not(eq(variables['System.TeamProject'], 'public'))) }}: + - task: AzureKeyVault@1 + inputs: + azureSubscription: 'HelixProd_KeyVault' + KeyVaultName: HelixProdKV + SecretsFilter: 'HelixApiAccessToken' + condition: always() +- bash: | + # create a temporary file + jobInfo=`mktemp` + + # write job info content to temporary file + cat > $jobInfo < powershell invocations +# as dot sourcing isn't possible. +function InitializeDotNetCli([bool]$install, [bool]$createSdkLocationFile) { + if (Test-Path variable:global:_DotNetInstallDir) { + return $global:_DotNetInstallDir + } + + # Don't resolve runtime, shared framework, or SDK from other locations to ensure build determinism + $env:DOTNET_MULTILEVEL_LOOKUP=0 + + # Disable first run since we do not need all ASP.NET packages restored. + $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 + + # Disable telemetry on CI. + if ($ci) { + $env:DOTNET_CLI_TELEMETRY_OPTOUT=1 + } + + # Source Build uses DotNetCoreSdkDir variable + if ($env:DotNetCoreSdkDir -ne $null) { + $env:DOTNET_INSTALL_DIR = $env:DotNetCoreSdkDir + } + + # Find the first path on %PATH% that contains the dotnet.exe + if ($useInstalledDotNetCli -and (-not $globalJsonHasRuntimes) -and ($env:DOTNET_INSTALL_DIR -eq $null)) { + $dotnetExecutable = GetExecutableFileName 'dotnet' + $dotnetCmd = Get-Command $dotnetExecutable -ErrorAction SilentlyContinue + + if ($dotnetCmd -ne $null) { + $env:DOTNET_INSTALL_DIR = Split-Path $dotnetCmd.Path -Parent + } + } + + $dotnetSdkVersion = $GlobalJson.tools.dotnet + + # Use dotnet installation specified in DOTNET_INSTALL_DIR if it contains the required SDK version, + # otherwise install the dotnet CLI and SDK to repo local .dotnet directory to avoid potential permission issues. + if ((-not $globalJsonHasRuntimes) -and (-not [string]::IsNullOrEmpty($env:DOTNET_INSTALL_DIR)) -and (Test-Path(Join-Path $env:DOTNET_INSTALL_DIR "sdk\$dotnetSdkVersion"))) { + $dotnetRoot = $env:DOTNET_INSTALL_DIR + } else { + $dotnetRoot = Join-Path $RepoRoot '.dotnet' + + if (-not (Test-Path(Join-Path $dotnetRoot "sdk\$dotnetSdkVersion"))) { + if ($install) { + InstallDotNetSdk $dotnetRoot $dotnetSdkVersion + } else { + Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "Unable to find dotnet with SDK version '$dotnetSdkVersion'" + ExitWithExitCode 1 + } + } + + $env:DOTNET_INSTALL_DIR = $dotnetRoot + } + + # Creates a temporary file under the toolset dir. + # The following code block is protecting against concurrent access so that this function can + # be called in parallel. + if ($createSdkLocationFile) { + do { + $sdkCacheFileTemp = Join-Path $ToolsetDir $([System.IO.Path]::GetRandomFileName()) + } + until (!(Test-Path $sdkCacheFileTemp)) + Set-Content -Path $sdkCacheFileTemp -Value $dotnetRoot + + try { + Move-Item -Force $sdkCacheFileTemp (Join-Path $ToolsetDir 'sdk.txt') + } catch { + # Somebody beat us + Remove-Item -Path $sdkCacheFileTemp + } + } + + # Add dotnet to PATH. This prevents any bare invocation of dotnet in custom + # build steps from using anything other than what we've downloaded. + # It also ensures that VS msbuild will use the downloaded sdk targets. + $env:PATH = "$dotnetRoot;$env:PATH" + + # Make Sure that our bootstrapped dotnet cli is available in future steps of the Azure Pipelines build + Write-PipelinePrependPath -Path $dotnetRoot + + Write-PipelineSetVariable -Name 'DOTNET_MULTILEVEL_LOOKUP' -Value '0' + Write-PipelineSetVariable -Name 'DOTNET_SKIP_FIRST_TIME_EXPERIENCE' -Value '1' + + return $global:_DotNetInstallDir = $dotnetRoot +} + +function Retry($downloadBlock, $maxRetries = 5) { + $retries = 1 + + while($true) { + try { + & $downloadBlock + break + } + catch { + Write-PipelineTelemetryError -Category 'InitializeToolset' -Message $_ + } + + if (++$retries -le $maxRetries) { + $delayInSeconds = [math]::Pow(2, $retries) - 1 # Exponential backoff + Write-Host "Retrying. Waiting for $delayInSeconds seconds before next attempt ($retries of $maxRetries)." + Start-Sleep -Seconds $delayInSeconds + } + else { + Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "Unable to download file in $maxRetries attempts." + break + } + + } +} + +function GetDotNetInstallScript([string] $dotnetRoot) { + $installScript = Join-Path $dotnetRoot 'dotnet-install.ps1' + if (!(Test-Path $installScript)) { + Create-Directory $dotnetRoot + $ProgressPreference = 'SilentlyContinue' # Don't display the console progress UI - it's a huge perf hit + $uri = "https://dotnet.microsoft.com/download/dotnet/scripts/$dotnetInstallScriptVersion/dotnet-install.ps1" + + Retry({ + Write-Host "GET $uri" + Invoke-WebRequest $uri -OutFile $installScript + }) + } + + return $installScript +} + +function InstallDotNetSdk([string] $dotnetRoot, [string] $version, [string] $architecture = '', [switch] $noPath) { + InstallDotNet $dotnetRoot $version $architecture '' $false $runtimeSourceFeed $runtimeSourceFeedKey -noPath:$noPath +} + +function InstallDotNet([string] $dotnetRoot, + [string] $version, + [string] $architecture = '', + [string] $runtime = '', + [bool] $skipNonVersionedFiles = $false, + [string] $runtimeSourceFeed = '', + [string] $runtimeSourceFeedKey = '', + [switch] $noPath) { + + $dotnetVersionLabel = "'sdk v$version'" + + if ($runtime -ne '' -and $runtime -ne 'sdk') { + $runtimePath = $dotnetRoot + $runtimePath = $runtimePath + "\shared" + if ($runtime -eq "dotnet") { $runtimePath = $runtimePath + "\Microsoft.NETCore.App" } + if ($runtime -eq "aspnetcore") { $runtimePath = $runtimePath + "\Microsoft.AspNetCore.App" } + if ($runtime -eq "windowsdesktop") { $runtimePath = $runtimePath + "\Microsoft.WindowsDesktop.App" } + $runtimePath = $runtimePath + "\" + $version + + $dotnetVersionLabel = "runtime toolset '$runtime/$architecture v$version'" + + if (Test-Path $runtimePath) { + Write-Host " Runtime toolset '$runtime/$architecture v$version' already installed." + $installSuccess = $true + Exit + } + } + + $installScript = GetDotNetInstallScript $dotnetRoot + $installParameters = @{ + Version = $version + InstallDir = $dotnetRoot + } + + if ($architecture) { $installParameters.Architecture = $architecture } + if ($runtime) { $installParameters.Runtime = $runtime } + if ($skipNonVersionedFiles) { $installParameters.SkipNonVersionedFiles = $skipNonVersionedFiles } + if ($noPath) { $installParameters.NoPath = $True } + + $variations = @() + $variations += @($installParameters) + + $dotnetBuilds = $installParameters.Clone() + $dotnetbuilds.AzureFeed = "https://dotnetbuilds.azureedge.net/public" + $variations += @($dotnetBuilds) + + if ($runtimeSourceFeed) { + $runtimeSource = $installParameters.Clone() + $runtimeSource.AzureFeed = $runtimeSourceFeed + if ($runtimeSourceFeedKey) { + $decodedBytes = [System.Convert]::FromBase64String($runtimeSourceFeedKey) + $decodedString = [System.Text.Encoding]::UTF8.GetString($decodedBytes) + $runtimeSource.FeedCredential = $decodedString + } + $variations += @($runtimeSource) + } + + $installSuccess = $false + foreach ($variation in $variations) { + if ($variation | Get-Member AzureFeed) { + $location = $variation.AzureFeed + } else { + $location = "public location"; + } + Write-Host " Attempting to install $dotnetVersionLabel from $location." + try { + & $installScript @variation + $installSuccess = $true + break + } + catch { + Write-Host " Failed to install $dotnetVersionLabel from $location." + } + } + if (-not $installSuccess) { + Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "Failed to install $dotnetVersionLabel from any of the specified locations." + ExitWithExitCode 1 + } +} + +# +# Locates Visual Studio MSBuild installation. +# The preference order for MSBuild to use is as follows: +# +# 1. MSBuild from an active VS command prompt +# 2. MSBuild from a compatible VS installation +# 3. MSBuild from the xcopy tool package +# +# Returns full path to msbuild.exe. +# Throws on failure. +# +function InitializeVisualStudioMSBuild([bool]$install, [object]$vsRequirements = $null) { + if (-not (IsWindowsPlatform)) { + throw "Cannot initialize Visual Studio on non-Windows" + } + + if (Test-Path variable:global:_MSBuildExe) { + return $global:_MSBuildExe + } + + # Minimum VS version to require. + $vsMinVersionReqdStr = '16.8' + $vsMinVersionReqd = [Version]::new($vsMinVersionReqdStr) + + # If the version of msbuild is going to be xcopied, + # use this version. Version matches a package here: + # https://dev.azure.com/dnceng/public/_packaging?_a=package&feed=dotnet-eng&package=RoslynTools.MSBuild&protocolType=NuGet&version=17.4.1&view=overview + $defaultXCopyMSBuildVersion = '17.4.1' + + if (!$vsRequirements) { + if (Get-Member -InputObject $GlobalJson.tools -Name 'vs') { + $vsRequirements = $GlobalJson.tools.vs + } + else { + $vsRequirements = New-Object PSObject -Property @{ version = $vsMinVersionReqdStr } + } + } + $vsMinVersionStr = if ($vsRequirements.version) { $vsRequirements.version } else { $vsMinVersionReqdStr } + $vsMinVersion = [Version]::new($vsMinVersionStr) + + # Try msbuild command available in the environment. + if ($env:VSINSTALLDIR -ne $null) { + $msbuildCmd = Get-Command 'msbuild.exe' -ErrorAction SilentlyContinue + if ($msbuildCmd -ne $null) { + # Workaround for https://github.com/dotnet/roslyn/issues/35793 + # Due to this issue $msbuildCmd.Version returns 0.0.0.0 for msbuild.exe 16.2+ + $msbuildVersion = [Version]::new((Get-Item $msbuildCmd.Path).VersionInfo.ProductVersion.Split([char[]]@('-', '+'))[0]) + + if ($msbuildVersion -ge $vsMinVersion) { + return $global:_MSBuildExe = $msbuildCmd.Path + } + + # Report error - the developer environment is initialized with incompatible VS version. + throw "Developer Command Prompt for VS $($env:VisualStudioVersion) is not recent enough. Please upgrade to $vsMinVersionStr or build from a plain CMD window" + } + } + + # Locate Visual Studio installation or download x-copy msbuild. + $vsInfo = LocateVisualStudio $vsRequirements + if ($vsInfo -ne $null) { + # Ensure vsInstallDir has a trailing slash + $vsInstallDir = Join-Path $vsInfo.installationPath "\" + $vsMajorVersion = $vsInfo.installationVersion.Split('.')[0] + + InitializeVisualStudioEnvironmentVariables $vsInstallDir $vsMajorVersion + } else { + + if (Get-Member -InputObject $GlobalJson.tools -Name 'xcopy-msbuild') { + $xcopyMSBuildVersion = $GlobalJson.tools.'xcopy-msbuild' + $vsMajorVersion = $xcopyMSBuildVersion.Split('.')[0] + } else { + #if vs version provided in global.json is incompatible (too low) then use the default version for xcopy msbuild download + if($vsMinVersion -lt $vsMinVersionReqd){ + Write-Host "Using xcopy-msbuild version of $defaultXCopyMSBuildVersion since VS version $vsMinVersionStr provided in global.json is not compatible" + $xcopyMSBuildVersion = $defaultXCopyMSBuildVersion + $vsMajorVersion = $xcopyMSBuildVersion.Split('.')[0] + } + else{ + # If the VS version IS compatible, look for an xcopy msbuild package + # with a version matching VS. + # Note: If this version does not exist, then an explicit version of xcopy msbuild + # can be specified in global.json. This will be required for pre-release versions of msbuild. + $vsMajorVersion = $vsMinVersion.Major + $vsMinorVersion = $vsMinVersion.Minor + $xcopyMSBuildVersion = "$vsMajorVersion.$vsMinorVersion.0" + } + } + + $vsInstallDir = $null + if ($xcopyMSBuildVersion.Trim() -ine "none") { + $vsInstallDir = InitializeXCopyMSBuild $xcopyMSBuildVersion $install + if ($vsInstallDir -eq $null) { + throw "Could not xcopy msbuild. Please check that package 'RoslynTools.MSBuild @ $xcopyMSBuildVersion' exists on feed 'dotnet-eng'." + } + } + if ($vsInstallDir -eq $null) { + throw 'Unable to find Visual Studio that has required version and components installed' + } + } + + $msbuildVersionDir = if ([int]$vsMajorVersion -lt 16) { "$vsMajorVersion.0" } else { "Current" } + + $local:BinFolder = Join-Path $vsInstallDir "MSBuild\$msbuildVersionDir\Bin" + $local:Prefer64bit = if (Get-Member -InputObject $vsRequirements -Name 'Prefer64bit') { $vsRequirements.Prefer64bit } else { $false } + if ($local:Prefer64bit -and (Test-Path(Join-Path $local:BinFolder "amd64"))) { + $global:_MSBuildExe = Join-Path $local:BinFolder "amd64\msbuild.exe" + } else { + $global:_MSBuildExe = Join-Path $local:BinFolder "msbuild.exe" + } + + return $global:_MSBuildExe +} + +function InitializeVisualStudioEnvironmentVariables([string] $vsInstallDir, [string] $vsMajorVersion) { + $env:VSINSTALLDIR = $vsInstallDir + Set-Item "env:VS$($vsMajorVersion)0COMNTOOLS" (Join-Path $vsInstallDir "Common7\Tools\") + + $vsSdkInstallDir = Join-Path $vsInstallDir "VSSDK\" + if (Test-Path $vsSdkInstallDir) { + Set-Item "env:VSSDK$($vsMajorVersion)0Install" $vsSdkInstallDir + $env:VSSDKInstall = $vsSdkInstallDir + } +} + +function InstallXCopyMSBuild([string]$packageVersion) { + return InitializeXCopyMSBuild $packageVersion -install $true +} + +function InitializeXCopyMSBuild([string]$packageVersion, [bool]$install) { + $packageName = 'RoslynTools.MSBuild' + $packageDir = Join-Path $ToolsDir "msbuild\$packageVersion" + $packagePath = Join-Path $packageDir "$packageName.$packageVersion.nupkg" + + if (!(Test-Path $packageDir)) { + if (!$install) { + return $null + } + + Create-Directory $packageDir + + Write-Host "Downloading $packageName $packageVersion" + $ProgressPreference = 'SilentlyContinue' # Don't display the console progress UI - it's a huge perf hit + Retry({ + Invoke-WebRequest "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/flat2/$packageName/$packageVersion/$packageName.$packageVersion.nupkg" -OutFile $packagePath + }) + + Unzip $packagePath $packageDir + } + + return Join-Path $packageDir 'tools' +} + +# +# Locates Visual Studio instance that meets the minimal requirements specified by tools.vs object in global.json. +# +# The following properties of tools.vs are recognized: +# "version": "{major}.{minor}" +# Two part minimal VS version, e.g. "15.9", "16.0", etc. +# "components": ["componentId1", "componentId2", ...] +# Array of ids of workload components that must be available in the VS instance. +# See e.g. https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-enterprise?view=vs-2017 +# +# Returns JSON describing the located VS instance (same format as returned by vswhere), +# or $null if no instance meeting the requirements is found on the machine. +# +function LocateVisualStudio([object]$vsRequirements = $null){ + if (-not (IsWindowsPlatform)) { + throw "Cannot run vswhere on non-Windows platforms." + } + + if (Get-Member -InputObject $GlobalJson.tools -Name 'vswhere') { + $vswhereVersion = $GlobalJson.tools.vswhere + } else { + $vswhereVersion = '2.5.2' + } + + $vsWhereDir = Join-Path $ToolsDir "vswhere\$vswhereVersion" + $vsWhereExe = Join-Path $vsWhereDir 'vswhere.exe' + + if (!(Test-Path $vsWhereExe)) { + Create-Directory $vsWhereDir + Write-Host 'Downloading vswhere' + Retry({ + Invoke-WebRequest "https://netcorenativeassets.blob.core.windows.net/resource-packages/external/windows/vswhere/$vswhereVersion/vswhere.exe" -OutFile $vswhereExe + }) + } + + if (!$vsRequirements) { $vsRequirements = $GlobalJson.tools.vs } + $args = @('-latest', '-format', 'json', '-requires', 'Microsoft.Component.MSBuild', '-products', '*') + + if (!$excludePrereleaseVS) { + $args += '-prerelease' + } + + if (Get-Member -InputObject $vsRequirements -Name 'version') { + $args += '-version' + $args += $vsRequirements.version + } + + if (Get-Member -InputObject $vsRequirements -Name 'components') { + foreach ($component in $vsRequirements.components) { + $args += '-requires' + $args += $component + } + } + + $vsInfo =& $vsWhereExe $args | ConvertFrom-Json + + if ($lastExitCode -ne 0) { + return $null + } + + # use first matching instance + return $vsInfo[0] +} + +function InitializeBuildTool() { + if (Test-Path variable:global:_BuildTool) { + # If the requested msbuild parameters do not match, clear the cached variables. + if($global:_BuildTool.Contains('ExcludePrereleaseVS') -and $global:_BuildTool.ExcludePrereleaseVS -ne $excludePrereleaseVS) { + Remove-Item variable:global:_BuildTool + Remove-Item variable:global:_MSBuildExe + } else { + return $global:_BuildTool + } + } + + if (-not $msbuildEngine) { + $msbuildEngine = GetDefaultMSBuildEngine + } + + # Initialize dotnet cli if listed in 'tools' + $dotnetRoot = $null + if (Get-Member -InputObject $GlobalJson.tools -Name 'dotnet') { + $dotnetRoot = InitializeDotNetCli -install:$restore + } + + if ($msbuildEngine -eq 'dotnet') { + if (!$dotnetRoot) { + Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "/global.json must specify 'tools.dotnet'." + ExitWithExitCode 1 + } + $dotnetPath = Join-Path $dotnetRoot (GetExecutableFileName 'dotnet') + $buildTool = @{ Path = $dotnetPath; Command = 'msbuild'; Tool = 'dotnet'; Framework = 'net8.0' } + } elseif ($msbuildEngine -eq "vs") { + try { + $msbuildPath = InitializeVisualStudioMSBuild -install:$restore + } catch { + Write-PipelineTelemetryError -Category 'InitializeToolset' -Message $_ + ExitWithExitCode 1 + } + + $buildTool = @{ Path = $msbuildPath; Command = ""; Tool = "vs"; Framework = "net472"; ExcludePrereleaseVS = $excludePrereleaseVS } + } else { + Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "Unexpected value of -msbuildEngine: '$msbuildEngine'." + ExitWithExitCode 1 + } + + return $global:_BuildTool = $buildTool +} + +function GetDefaultMSBuildEngine() { + # Presence of tools.vs indicates the repo needs to build using VS msbuild on Windows. + if (Get-Member -InputObject $GlobalJson.tools -Name 'vs') { + return 'vs' + } + + if (Get-Member -InputObject $GlobalJson.tools -Name 'dotnet') { + return 'dotnet' + } + + Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "-msbuildEngine must be specified, or /global.json must specify 'tools.dotnet' or 'tools.vs'." + ExitWithExitCode 1 +} + +function GetNuGetPackageCachePath() { + if ($env:NUGET_PACKAGES -eq $null) { + # Use local cache on CI to ensure deterministic build. + # Avoid using the http cache as workaround for https://github.com/NuGet/Home/issues/3116 + # use global cache in dev builds to avoid cost of downloading packages. + # For directory normalization, see also: https://github.com/NuGet/Home/issues/7968 + if ($useGlobalNuGetCache) { + $env:NUGET_PACKAGES = Join-Path $env:UserProfile '.nuget\packages\' + } else { + $env:NUGET_PACKAGES = Join-Path $RepoRoot '.packages\' + $env:RESTORENOCACHE = $true + } + } + + return $env:NUGET_PACKAGES +} + +# Returns a full path to an Arcade SDK task project file. +function GetSdkTaskProject([string]$taskName) { + return Join-Path (Split-Path (InitializeToolset) -Parent) "SdkTasks\$taskName.proj" +} + +function InitializeNativeTools() { + if (-Not (Test-Path variable:DisableNativeToolsetInstalls) -And (Get-Member -InputObject $GlobalJson -Name "native-tools")) { + $nativeArgs= @{} + if ($ci) { + $nativeArgs = @{ + InstallDirectory = "$ToolsDir" + } + } + if ($env:NativeToolsOnMachine) { + Write-Host "Variable NativeToolsOnMachine detected, enabling native tool path promotion..." + $nativeArgs += @{ PathPromotion = $true } + } + & "$PSScriptRoot/init-tools-native.ps1" @nativeArgs + } +} + +function InitializeToolset() { + if (Test-Path variable:global:_ToolsetBuildProj) { + return $global:_ToolsetBuildProj + } + + $nugetCache = GetNuGetPackageCachePath + + $toolsetVersion = $GlobalJson.'msbuild-sdks'.'Microsoft.DotNet.Arcade.Sdk' + $toolsetLocationFile = Join-Path $ToolsetDir "$toolsetVersion.txt" + + if (Test-Path $toolsetLocationFile) { + $path = Get-Content $toolsetLocationFile -TotalCount 1 + if (Test-Path $path) { + return $global:_ToolsetBuildProj = $path + } + } + + if (-not $restore) { + Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "Toolset version $toolsetVersion has not been restored." + ExitWithExitCode 1 + } + + $buildTool = InitializeBuildTool + + $proj = Join-Path $ToolsetDir 'restore.proj' + $bl = if ($binaryLog) { '/bl:' + (Join-Path $LogDir 'ToolsetRestore.binlog') } else { '' } + + '' | Set-Content $proj + + MSBuild-Core $proj $bl /t:__WriteToolsetLocation /clp:ErrorsOnly`;NoSummary /p:__ToolsetLocationOutputFile=$toolsetLocationFile + + $path = Get-Content $toolsetLocationFile -Encoding UTF8 -TotalCount 1 + if (!(Test-Path $path)) { + throw "Invalid toolset path: $path" + } + + return $global:_ToolsetBuildProj = $path +} + +function ExitWithExitCode([int] $exitCode) { + if ($ci -and $prepareMachine) { + Stop-Processes + } + exit $exitCode +} + +# Check if $LASTEXITCODE is a nonzero exit code (NZEC). If so, print a Azure Pipeline error for +# diagnostics, then exit the script with the $LASTEXITCODE. +function Exit-IfNZEC([string] $category = "General") { + Write-Host "Exit code $LASTEXITCODE" + if ($LASTEXITCODE -ne 0) { + $message = "Last command failed with exit code $LASTEXITCODE." + Write-PipelineTelemetryError -Force -Category $category -Message $message + ExitWithExitCode $LASTEXITCODE + } +} + +function Stop-Processes() { + Write-Host 'Killing running build processes...' + foreach ($processName in $processesToStopOnExit) { + Get-Process -Name $processName -ErrorAction SilentlyContinue | Stop-Process + } +} + +# +# Executes msbuild (or 'dotnet msbuild') with arguments passed to the function. +# The arguments are automatically quoted. +# Terminates the script if the build fails. +# +function MSBuild() { + if ($pipelinesLog) { + $buildTool = InitializeBuildTool + + if ($ci -and $buildTool.Tool -eq 'dotnet') { + $env:NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS = 20 + $env:NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS = 20 + Write-PipelineSetVariable -Name 'NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS' -Value '20' + Write-PipelineSetVariable -Name 'NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS' -Value '20' + } + + Enable-Nuget-EnhancedRetry + + $toolsetBuildProject = InitializeToolset + $basePath = Split-Path -parent $toolsetBuildProject + $possiblePaths = @( + # new scripts need to work with old packages, so we need to look for the old names/versions + (Join-Path $basePath (Join-Path $buildTool.Framework 'Microsoft.DotNet.ArcadeLogging.dll')), + (Join-Path $basePath (Join-Path $buildTool.Framework 'Microsoft.DotNet.Arcade.Sdk.dll')), + (Join-Path $basePath (Join-Path netcoreapp2.1 'Microsoft.DotNet.ArcadeLogging.dll')), + (Join-Path $basePath (Join-Path netcoreapp2.1 'Microsoft.DotNet.Arcade.Sdk.dll')) + (Join-Path $basePath (Join-Path netcoreapp3.1 'Microsoft.DotNet.ArcadeLogging.dll')), + (Join-Path $basePath (Join-Path netcoreapp3.1 'Microsoft.DotNet.Arcade.Sdk.dll')) + (Join-Path $basePath (Join-Path net7.0 'Microsoft.DotNet.ArcadeLogging.dll')), + (Join-Path $basePath (Join-Path net7.0 'Microsoft.DotNet.Arcade.Sdk.dll')) + ) + $selectedPath = $null + foreach ($path in $possiblePaths) { + if (Test-Path $path -PathType Leaf) { + $selectedPath = $path + break + } + } + if (-not $selectedPath) { + Write-PipelineTelemetryError -Category 'Build' -Message 'Unable to find arcade sdk logger assembly.' + ExitWithExitCode 1 + } + $args += "/logger:$selectedPath" + } + + MSBuild-Core @args +} + +# +# Executes msbuild (or 'dotnet msbuild') with arguments passed to the function. +# The arguments are automatically quoted. +# Terminates the script if the build fails. +# +function MSBuild-Core() { + if ($ci) { + if (!$binaryLog -and !$excludeCIBinarylog) { + Write-PipelineTelemetryError -Category 'Build' -Message 'Binary log must be enabled in CI build, or explicitly opted-out from with the -excludeCIBinarylog switch.' + ExitWithExitCode 1 + } + + if ($nodeReuse) { + Write-PipelineTelemetryError -Category 'Build' -Message 'Node reuse must be disabled in CI build.' + ExitWithExitCode 1 + } + } + + Enable-Nuget-EnhancedRetry + + $buildTool = InitializeBuildTool + + $cmdArgs = "$($buildTool.Command) /m /nologo /clp:Summary /v:$verbosity /nr:$nodeReuse /p:ContinuousIntegrationBuild=$ci" + + if ($warnAsError) { + $cmdArgs += ' /warnaserror /p:TreatWarningsAsErrors=true' + } + else { + $cmdArgs += ' /p:TreatWarningsAsErrors=false' + } + + foreach ($arg in $args) { + if ($null -ne $arg -and $arg.Trim() -ne "") { + if ($arg.EndsWith('\')) { + $arg = $arg + "\" + } + $cmdArgs += " `"$arg`"" + } + } + + $env:ARCADE_BUILD_TOOL_COMMAND = "$($buildTool.Path) $cmdArgs" + + $exitCode = Exec-Process $buildTool.Path $cmdArgs + + if ($exitCode -ne 0) { + # We should not Write-PipelineTaskError here because that message shows up in the build summary + # The build already logged an error, that's the reason it failed. Producing an error here only adds noise. + Write-Host "Build failed with exit code $exitCode. Check errors above." -ForegroundColor Red + + $buildLog = GetMSBuildBinaryLogCommandLineArgument $args + if ($null -ne $buildLog) { + Write-Host "See log: $buildLog" -ForegroundColor DarkGray + } + + # When running on Azure Pipelines, override the returned exit code to avoid double logging. + if ($ci -and $env:SYSTEM_TEAMPROJECT -ne $null) { + Write-PipelineSetResult -Result "Failed" -Message "msbuild execution failed." + # Exiting with an exit code causes the azure pipelines task to log yet another "noise" error + # The above Write-PipelineSetResult will cause the task to be marked as failure without adding yet another error + ExitWithExitCode 0 + } else { + ExitWithExitCode $exitCode + } + } +} + +function GetMSBuildBinaryLogCommandLineArgument($arguments) { + foreach ($argument in $arguments) { + if ($argument -ne $null) { + $arg = $argument.Trim() + if ($arg.StartsWith('/bl:', "OrdinalIgnoreCase")) { + return $arg.Substring('/bl:'.Length) + } + + if ($arg.StartsWith('/binaryLogger:', 'OrdinalIgnoreCase')) { + return $arg.Substring('/binaryLogger:'.Length) + } + } + } + + return $null +} + +function GetExecutableFileName($baseName) { + if (IsWindowsPlatform) { + return "$baseName.exe" + } + else { + return $baseName + } +} + +function IsWindowsPlatform() { + return [environment]::OSVersion.Platform -eq [PlatformID]::Win32NT +} + +function Get-Darc($version) { + $darcPath = "$TempDir\darc\$(New-Guid)" + if ($version -ne $null) { + & $PSScriptRoot\darc-init.ps1 -toolpath $darcPath -darcVersion $version | Out-Host + } else { + & $PSScriptRoot\darc-init.ps1 -toolpath $darcPath | Out-Host + } + return "$darcPath\darc.exe" +} + +. $PSScriptRoot\pipeline-logging-functions.ps1 + +$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot '..\..\') +$EngRoot = Resolve-Path (Join-Path $PSScriptRoot '..') +$ArtifactsDir = Join-Path $RepoRoot 'artifacts' +$ToolsetDir = Join-Path $ArtifactsDir 'toolset' +$ToolsDir = Join-Path $RepoRoot '.tools' +$LogDir = Join-Path (Join-Path $ArtifactsDir 'log') $configuration +$TempDir = Join-Path (Join-Path $ArtifactsDir 'tmp') $configuration +$GlobalJson = Get-Content -Raw -Path (Join-Path $RepoRoot 'global.json') | ConvertFrom-Json +# true if global.json contains a "runtimes" section +$globalJsonHasRuntimes = if ($GlobalJson.tools.PSObject.Properties.Name -Match 'runtimes') { $true } else { $false } + +Create-Directory $ToolsetDir +Create-Directory $TempDir +Create-Directory $LogDir + +Write-PipelineSetVariable -Name 'Artifacts' -Value $ArtifactsDir +Write-PipelineSetVariable -Name 'Artifacts.Toolset' -Value $ToolsetDir +Write-PipelineSetVariable -Name 'Artifacts.Log' -Value $LogDir +Write-PipelineSetVariable -Name 'TEMP' -Value $TempDir +Write-PipelineSetVariable -Name 'TMP' -Value $TempDir + +# Import custom tools configuration, if present in the repo. +# Note: Import in global scope so that the script set top-level variables without qualification. +if (!$disableConfigureToolsetImport) { + $configureToolsetScript = Join-Path $EngRoot 'configure-toolset.ps1' + if (Test-Path $configureToolsetScript) { + . $configureToolsetScript + if ((Test-Path variable:failOnConfigureToolsetError) -And $failOnConfigureToolsetError) { + if ((Test-Path variable:LastExitCode) -And ($LastExitCode -ne 0)) { + Write-PipelineTelemetryError -Category 'Build' -Message 'configure-toolset.ps1 returned a non-zero exit code' + ExitWithExitCode $LastExitCode + } + } + } +} + +# +# If $ci flag is set, turn on (and log that we did) special environment variables for improved Nuget client retry logic. +# +function Enable-Nuget-EnhancedRetry() { + if ($ci) { + Write-Host "Setting NUGET enhanced retry environment variables" + $env:NUGET_ENABLE_ENHANCED_HTTP_RETRY = 'true' + $env:NUGET_ENHANCED_MAX_NETWORK_TRY_COUNT = 6 + $env:NUGET_ENHANCED_NETWORK_RETRY_DELAY_MILLISECONDS = 1000 + $env:NUGET_RETRY_HTTP_429 = 'true' + Write-PipelineSetVariable -Name 'NUGET_ENABLE_ENHANCED_HTTP_RETRY' -Value 'true' + Write-PipelineSetVariable -Name 'NUGET_ENHANCED_MAX_NETWORK_TRY_COUNT' -Value '6' + Write-PipelineSetVariable -Name 'NUGET_ENHANCED_NETWORK_RETRY_DELAY_MILLISECONDS' -Value '1000' + Write-PipelineSetVariable -Name 'NUGET_RETRY_HTTP_429' -Value 'true' + } +} diff --git a/eng/common/tools.sh b/eng/common/tools.sh new file mode 100755 index 00000000000000..e8d478943341df --- /dev/null +++ b/eng/common/tools.sh @@ -0,0 +1,587 @@ +#!/usr/bin/env bash + +# Initialize variables if they aren't already defined. + +# CI mode - set to true on CI server for PR validation build or official build. +ci=${ci:-false} + +# Set to true to use the pipelines logger which will enable Azure logging output. +# https://github.com/Microsoft/azure-pipelines-tasks/blob/master/docs/authoring/commands.md +# This flag is meant as a temporary opt-opt for the feature while validate it across +# our consumers. It will be deleted in the future. +if [[ "$ci" == true ]]; then + pipelines_log=${pipelines_log:-true} +else + pipelines_log=${pipelines_log:-false} +fi + +# Build configuration. Common values include 'Debug' and 'Release', but the repository may use other names. +configuration=${configuration:-'Debug'} + +# Set to true to opt out of outputting binary log while running in CI +exclude_ci_binary_log=${exclude_ci_binary_log:-false} + +if [[ "$ci" == true && "$exclude_ci_binary_log" == false ]]; then + binary_log_default=true +else + binary_log_default=false +fi + +# Set to true to output binary log from msbuild. Note that emitting binary log slows down the build. +binary_log=${binary_log:-$binary_log_default} + +# Turns on machine preparation/clean up code that changes the machine state (e.g. kills build processes). +prepare_machine=${prepare_machine:-false} + +# True to restore toolsets and dependencies. +restore=${restore:-true} + +# Adjusts msbuild verbosity level. +verbosity=${verbosity:-'minimal'} + +# Set to true to reuse msbuild nodes. Recommended to not reuse on CI. +if [[ "$ci" == true ]]; then + node_reuse=${node_reuse:-false} +else + node_reuse=${node_reuse:-true} +fi + +# Configures warning treatment in msbuild. +warn_as_error=${warn_as_error:-true} + +# True to attempt using .NET Core already that meets requirements specified in global.json +# installed on the machine instead of downloading one. +use_installed_dotnet_cli=${use_installed_dotnet_cli:-true} + +# Enable repos to use a particular version of the on-line dotnet-install scripts. +# default URL: https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.sh +dotnetInstallScriptVersion=${dotnetInstallScriptVersion:-'v1'} + +# True to use global NuGet cache instead of restoring packages to repository-local directory. +if [[ "$ci" == true ]]; then + use_global_nuget_cache=${use_global_nuget_cache:-false} +else + use_global_nuget_cache=${use_global_nuget_cache:-true} +fi + +# Used when restoring .NET SDK from alternative feeds +runtime_source_feed=${runtime_source_feed:-''} +runtime_source_feed_key=${runtime_source_feed_key:-''} + +# Resolve any symlinks in the given path. +function ResolvePath { + local path=$1 + + while [[ -h $path ]]; do + local dir="$( cd -P "$( dirname "$path" )" && pwd )" + path="$(readlink "$path")" + + # if $path was a relative symlink, we need to resolve it relative to the path where the + # symlink file was located + [[ $path != /* ]] && path="$dir/$path" + done + + # return value + _ResolvePath="$path" +} + +# ReadVersionFromJson [json key] +function ReadGlobalVersion { + local key=$1 + + if command -v jq &> /dev/null; then + _ReadGlobalVersion="$(jq -r ".[] | select(has(\"$key\")) | .\"$key\"" "$global_json_file")" + elif [[ "$(cat "$global_json_file")" =~ \"$key\"[[:space:]\:]*\"([^\"]+) ]]; then + _ReadGlobalVersion=${BASH_REMATCH[1]} + fi + + if [[ -z "$_ReadGlobalVersion" ]]; then + Write-PipelineTelemetryError -category 'Build' "Error: Cannot find \"$key\" in $global_json_file" + ExitWithExitCode 1 + fi +} + +function InitializeDotNetCli { + if [[ -n "${_InitializeDotNetCli:-}" ]]; then + return + fi + + local install=$1 + + # Don't resolve runtime, shared framework, or SDK from other locations to ensure build determinism + export DOTNET_MULTILEVEL_LOOKUP=0 + + # Disable first run since we want to control all package sources + export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 + + # Disable telemetry on CI + if [[ $ci == true ]]; then + export DOTNET_CLI_TELEMETRY_OPTOUT=1 + fi + + # LTTNG is the logging infrastructure used by Core CLR. Need this variable set + # so it doesn't output warnings to the console. + export LTTNG_HOME="$HOME" + + # Source Build uses DotNetCoreSdkDir variable + if [[ -n "${DotNetCoreSdkDir:-}" ]]; then + export DOTNET_INSTALL_DIR="$DotNetCoreSdkDir" + fi + + # Find the first path on $PATH that contains the dotnet.exe + if [[ "$use_installed_dotnet_cli" == true && $global_json_has_runtimes == false && -z "${DOTNET_INSTALL_DIR:-}" ]]; then + local dotnet_path=`command -v dotnet` + if [[ -n "$dotnet_path" ]]; then + ResolvePath "$dotnet_path" + export DOTNET_INSTALL_DIR=`dirname "$_ResolvePath"` + fi + fi + + ReadGlobalVersion "dotnet" + local dotnet_sdk_version=$_ReadGlobalVersion + local dotnet_root="" + + # Use dotnet installation specified in DOTNET_INSTALL_DIR if it contains the required SDK version, + # otherwise install the dotnet CLI and SDK to repo local .dotnet directory to avoid potential permission issues. + if [[ $global_json_has_runtimes == false && -n "${DOTNET_INSTALL_DIR:-}" && -d "$DOTNET_INSTALL_DIR/sdk/$dotnet_sdk_version" ]]; then + dotnet_root="$DOTNET_INSTALL_DIR" + else + dotnet_root="$repo_root/.dotnet" + + export DOTNET_INSTALL_DIR="$dotnet_root" + + if [[ ! -d "$DOTNET_INSTALL_DIR/sdk/$dotnet_sdk_version" ]]; then + if [[ "$install" == true ]]; then + InstallDotNetSdk "$dotnet_root" "$dotnet_sdk_version" + else + Write-PipelineTelemetryError -category 'InitializeToolset' "Unable to find dotnet with SDK version '$dotnet_sdk_version'" + ExitWithExitCode 1 + fi + fi + fi + + # Add dotnet to PATH. This prevents any bare invocation of dotnet in custom + # build steps from using anything other than what we've downloaded. + Write-PipelinePrependPath -path "$dotnet_root" + + Write-PipelineSetVariable -name "DOTNET_MULTILEVEL_LOOKUP" -value "0" + Write-PipelineSetVariable -name "DOTNET_SKIP_FIRST_TIME_EXPERIENCE" -value "1" + + # return value + _InitializeDotNetCli="$dotnet_root" +} + +function InstallDotNetSdk { + local root=$1 + local version=$2 + local architecture="unset" + if [[ $# -ge 3 ]]; then + architecture=$3 + fi + InstallDotNet "$root" "$version" $architecture 'sdk' 'true' $runtime_source_feed $runtime_source_feed_key +} + +function InstallDotNet { + local root=$1 + local version=$2 + local runtime=$4 + + local dotnetVersionLabel="'$runtime v$version'" + if [[ -n "${4:-}" ]] && [ "$4" != 'sdk' ]; then + runtimePath="$root" + runtimePath="$runtimePath/shared" + case "$runtime" in + dotnet) + runtimePath="$runtimePath/Microsoft.NETCore.App" + ;; + aspnetcore) + runtimePath="$runtimePath/Microsoft.AspNetCore.App" + ;; + windowsdesktop) + runtimePath="$runtimePath/Microsoft.WindowsDesktop.App" + ;; + *) + ;; + esac + runtimePath="$runtimePath/$version" + + dotnetVersionLabel="runtime toolset '$runtime/$architecture v$version'" + + if [ -d "$runtimePath" ]; then + echo " Runtime toolset '$runtime/$architecture v$version' already installed." + local installSuccess=1 + return + fi + fi + + GetDotNetInstallScript "$root" + local install_script=$_GetDotNetInstallScript + + local installParameters=(--version $version --install-dir "$root") + + if [[ -n "${3:-}" ]] && [ "$3" != 'unset' ]; then + installParameters+=(--architecture $3) + fi + if [[ -n "${4:-}" ]] && [ "$4" != 'sdk' ]; then + installParameters+=(--runtime $4) + fi + if [[ "$#" -ge "5" ]] && [[ "$5" != 'false' ]]; then + installParameters+=(--skip-non-versioned-files) + fi + + local variations=() # list of variable names with parameter arrays in them + + local public_location=("${installParameters[@]}") + variations+=(public_location) + + local dotnetbuilds=("${installParameters[@]}" --azure-feed "https://dotnetbuilds.azureedge.net/public") + variations+=(dotnetbuilds) + + if [[ -n "${6:-}" ]]; then + variations+=(private_feed) + local private_feed=("${installParameters[@]}" --azure-feed $6) + if [[ -n "${7:-}" ]]; then + # The 'base64' binary on alpine uses '-d' and doesn't support '--decode' + # '-d'. To work around this, do a simple detection and switch the parameter + # accordingly. + decodeArg="--decode" + if base64 --help 2>&1 | grep -q "BusyBox"; then + decodeArg="-d" + fi + decodedFeedKey=`echo $7 | base64 $decodeArg` + private_feed+=(--feed-credential $decodedFeedKey) + fi + fi + + local installSuccess=0 + for variationName in "${variations[@]}"; do + local name="$variationName[@]" + local variation=("${!name}") + echo " Attempting to install $dotnetVersionLabel from $variationName." + bash "$install_script" "${variation[@]}" && installSuccess=1 + if [[ "$installSuccess" -eq 1 ]]; then + break + fi + + echo " Failed to install $dotnetVersionLabel from $variationName." + done + + if [[ "$installSuccess" -eq 0 ]]; then + Write-PipelineTelemetryError -category 'InitializeToolset' "Failed to install $dotnetVersionLabel from any of the specified locations." + ExitWithExitCode 1 + fi +} + +function with_retries { + local maxRetries=5 + local retries=1 + echo "Trying to run '$@' for maximum of $maxRetries attempts." + while [[ $((retries++)) -le $maxRetries ]]; do + "$@" + + if [[ $? == 0 ]]; then + echo "Ran '$@' successfully." + return 0 + fi + + timeout=$((3**$retries-1)) + echo "Failed to execute '$@'. Waiting $timeout seconds before next attempt ($retries out of $maxRetries)." 1>&2 + sleep $timeout + done + + echo "Failed to execute '$@' for $maxRetries times." 1>&2 + + return 1 +} + +function GetDotNetInstallScript { + local root=$1 + local install_script="$root/dotnet-install.sh" + local install_script_url="https://dotnet.microsoft.com/download/dotnet/scripts/$dotnetInstallScriptVersion/dotnet-install.sh" + + if [[ ! -a "$install_script" ]]; then + mkdir -p "$root" + + echo "Downloading '$install_script_url'" + + # Use curl if available, otherwise use wget + if command -v curl > /dev/null; then + # first, try directly, if this fails we will retry with verbose logging + curl "$install_script_url" -sSL --retry 10 --create-dirs -o "$install_script" || { + if command -v openssl &> /dev/null; then + echo "Curl failed; dumping some information about dotnet.microsoft.com for later investigation" + echo | openssl s_client -showcerts -servername dotnet.microsoft.com -connect dotnet.microsoft.com:443 + fi + echo "Will now retry the same URL with verbose logging." + with_retries curl "$install_script_url" -sSL --verbose --retry 10 --create-dirs -o "$install_script" || { + local exit_code=$? + Write-PipelineTelemetryError -category 'InitializeToolset' "Failed to acquire dotnet install script (exit code '$exit_code')." + ExitWithExitCode $exit_code + } + } + else + with_retries wget -v -O "$install_script" "$install_script_url" || { + local exit_code=$? + Write-PipelineTelemetryError -category 'InitializeToolset' "Failed to acquire dotnet install script (exit code '$exit_code')." + ExitWithExitCode $exit_code + } + fi + fi + # return value + _GetDotNetInstallScript="$install_script" +} + +function InitializeBuildTool { + if [[ -n "${_InitializeBuildTool:-}" ]]; then + return + fi + + InitializeDotNetCli $restore + + # return values + _InitializeBuildTool="$_InitializeDotNetCli/dotnet" + _InitializeBuildToolCommand="msbuild" + _InitializeBuildToolFramework="net8.0" +} + +# Set RestoreNoCache as a workaround for https://github.com/NuGet/Home/issues/3116 +function GetNuGetPackageCachePath { + if [[ -z ${NUGET_PACKAGES:-} ]]; then + if [[ "$use_global_nuget_cache" == true ]]; then + export NUGET_PACKAGES="$HOME/.nuget/packages" + else + export NUGET_PACKAGES="$repo_root/.packages" + export RESTORENOCACHE=true + fi + fi + + # return value + _GetNuGetPackageCachePath=$NUGET_PACKAGES +} + +function InitializeNativeTools() { + if [[ -n "${DisableNativeToolsetInstalls:-}" ]]; then + return + fi + if grep -Fq "native-tools" $global_json_file + then + local nativeArgs="" + if [[ "$ci" == true ]]; then + nativeArgs="--installDirectory $tools_dir" + fi + "$_script_dir/init-tools-native.sh" $nativeArgs + fi +} + +function InitializeToolset { + if [[ -n "${_InitializeToolset:-}" ]]; then + return + fi + + GetNuGetPackageCachePath + + ReadGlobalVersion "Microsoft.DotNet.Arcade.Sdk" + + local toolset_version=$_ReadGlobalVersion + local toolset_location_file="$toolset_dir/$toolset_version.txt" + + if [[ -a "$toolset_location_file" ]]; then + local path=`cat "$toolset_location_file"` + if [[ -a "$path" ]]; then + # return value + _InitializeToolset="$path" + return + fi + fi + + if [[ "$restore" != true ]]; then + Write-PipelineTelemetryError -category 'InitializeToolset' "Toolset version $toolset_version has not been restored." + ExitWithExitCode 2 + fi + + local proj="$toolset_dir/restore.proj" + + local bl="" + if [[ "$binary_log" == true ]]; then + bl="/bl:$log_dir/ToolsetRestore.binlog" + fi + + echo '' > "$proj" + MSBuild-Core "$proj" $bl /t:__WriteToolsetLocation /clp:ErrorsOnly\;NoSummary /p:__ToolsetLocationOutputFile="$toolset_location_file" + + local toolset_build_proj=`cat "$toolset_location_file"` + + if [[ ! -a "$toolset_build_proj" ]]; then + Write-PipelineTelemetryError -category 'Build' "Invalid toolset path: $toolset_build_proj" + ExitWithExitCode 3 + fi + + # return value + _InitializeToolset="$toolset_build_proj" +} + +function ExitWithExitCode { + if [[ "$ci" == true && "$prepare_machine" == true ]]; then + StopProcesses + fi + exit $1 +} + +function StopProcesses { + echo "Killing running build processes..." + pkill -9 "dotnet" || true + pkill -9 "vbcscompiler" || true + return 0 +} + +function MSBuild { + local args=$@ + if [[ "$pipelines_log" == true ]]; then + InitializeBuildTool + InitializeToolset + + if [[ "$ci" == true ]]; then + export NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS=20 + export NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS=20 + Write-PipelineSetVariable -name "NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS" -value "20" + Write-PipelineSetVariable -name "NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS" -value "20" + fi + + local toolset_dir="${_InitializeToolset%/*}" + # new scripts need to work with old packages, so we need to look for the old names/versions + local selectedPath= + local possiblePaths=() + possiblePaths+=( "$toolset_dir/$_InitializeBuildToolFramework/Microsoft.DotNet.ArcadeLogging.dll" ) + possiblePaths+=( "$toolset_dir/$_InitializeBuildToolFramework/Microsoft.DotNet.Arcade.Sdk.dll" ) + possiblePaths+=( "$toolset_dir/netcoreapp2.1/Microsoft.DotNet.ArcadeLogging.dll" ) + possiblePaths+=( "$toolset_dir/netcoreapp2.1/Microsoft.DotNet.Arcade.Sdk.dll" ) + possiblePaths+=( "$toolset_dir/netcoreapp3.1/Microsoft.DotNet.ArcadeLogging.dll" ) + possiblePaths+=( "$toolset_dir/netcoreapp3.1/Microsoft.DotNet.Arcade.Sdk.dll" ) + possiblePaths+=( "$toolset_dir/net7.0/Microsoft.DotNet.ArcadeLogging.dll" ) + possiblePaths+=( "$toolset_dir/net7.0/Microsoft.DotNet.Arcade.Sdk.dll" ) + for path in "${possiblePaths[@]}"; do + if [[ -f $path ]]; then + selectedPath=$path + break + fi + done + if [[ -z "$selectedPath" ]]; then + Write-PipelineTelemetryError -category 'Build' "Unable to find arcade sdk logger assembly." + ExitWithExitCode 1 + fi + args+=( "-logger:$selectedPath" ) + fi + + MSBuild-Core ${args[@]} +} + +function MSBuild-Core { + if [[ "$ci" == true ]]; then + if [[ "$binary_log" != true && "$exclude_ci_binary_log" != true ]]; then + Write-PipelineTelemetryError -category 'Build' "Binary log must be enabled in CI build, or explicitly opted-out from with the -noBinaryLog switch." + ExitWithExitCode 1 + fi + + if [[ "$node_reuse" == true ]]; then + Write-PipelineTelemetryError -category 'Build' "Node reuse must be disabled in CI build." + ExitWithExitCode 1 + fi + fi + + InitializeBuildTool + + local warnaserror_switch="" + if [[ $warn_as_error == true ]]; then + warnaserror_switch="/warnaserror" + fi + + function RunBuildTool { + export ARCADE_BUILD_TOOL_COMMAND="$_InitializeBuildTool $@" + + "$_InitializeBuildTool" "$@" || { + local exit_code=$? + # We should not Write-PipelineTaskError here because that message shows up in the build summary + # The build already logged an error, that's the reason it failed. Producing an error here only adds noise. + echo "Build failed with exit code $exit_code. Check errors above." + + # When running on Azure Pipelines, override the returned exit code to avoid double logging. + if [[ "$ci" == "true" && -n ${SYSTEM_TEAMPROJECT:-} ]]; then + Write-PipelineSetResult -result "Failed" -message "msbuild execution failed." + # Exiting with an exit code causes the azure pipelines task to log yet another "noise" error + # The above Write-PipelineSetResult will cause the task to be marked as failure without adding yet another error + ExitWithExitCode 0 + else + ExitWithExitCode $exit_code + fi + } + } + + RunBuildTool "$_InitializeBuildToolCommand" /m /nologo /clp:Summary /v:$verbosity /nr:$node_reuse $warnaserror_switch /p:TreatWarningsAsErrors=$warn_as_error /p:ContinuousIntegrationBuild=$ci "$@" +} + +function GetDarc { + darc_path="$temp_dir/darc" + version="$1" + + if [[ -n "$version" ]]; then + version="--darcversion $version" + fi + + "$eng_root/common/darc-init.sh" --toolpath "$darc_path" $version +} + +ResolvePath "${BASH_SOURCE[0]}" +_script_dir=`dirname "$_ResolvePath"` + +. "$_script_dir/pipeline-logging-functions.sh" + +eng_root=`cd -P "$_script_dir/.." && pwd` +repo_root=`cd -P "$_script_dir/../.." && pwd` +repo_root="${repo_root}/" +artifacts_dir="${repo_root}artifacts" +toolset_dir="$artifacts_dir/toolset" +tools_dir="${repo_root}.tools" +log_dir="$artifacts_dir/log/$configuration" +temp_dir="$artifacts_dir/tmp/$configuration" + +global_json_file="${repo_root}global.json" +# determine if global.json contains a "runtimes" entry +global_json_has_runtimes=false +if command -v jq &> /dev/null; then + if jq -e '.tools | has("runtimes")' "$global_json_file" &> /dev/null; then + global_json_has_runtimes=true + fi +elif [[ "$(cat "$global_json_file")" =~ \"runtimes\"[[:space:]\:]*\{ ]]; then + global_json_has_runtimes=true +fi + +# HOME may not be defined in some scenarios, but it is required by NuGet +if [[ -z $HOME ]]; then + export HOME="${repo_root}artifacts/.home/" + mkdir -p "$HOME" +fi + +mkdir -p "$toolset_dir" +mkdir -p "$temp_dir" +mkdir -p "$log_dir" + +Write-PipelineSetVariable -name "Artifacts" -value "$artifacts_dir" +Write-PipelineSetVariable -name "Artifacts.Toolset" -value "$toolset_dir" +Write-PipelineSetVariable -name "Artifacts.Log" -value "$log_dir" +Write-PipelineSetVariable -name "Temp" -value "$temp_dir" +Write-PipelineSetVariable -name "TMP" -value "$temp_dir" + +# Import custom tools configuration, if present in the repo. +if [ -z "${disable_configure_toolset_import:-}" ]; then + configure_toolset_script="$eng_root/configure-toolset.sh" + if [[ -a "$configure_toolset_script" ]]; then + . "$configure_toolset_script" + fi +fi + +# TODO: https://github.com/dotnet/arcade/issues/1468 +# Temporary workaround to avoid breaking change. +# Remove once repos are updated. +if [[ -n "${useInstalledDotNetCli:-}" ]]; then + use_installed_dotnet_cli="$useInstalledDotNetCli" +fi diff --git a/global.json b/global.json new file mode 100644 index 00000000000000..2448e303afe867 --- /dev/null +++ b/global.json @@ -0,0 +1,10 @@ +{ + "tools": { + "dotnet": "8.0.100-preview.3.23178.7" + }, + "msbuild-sdks": { + "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.23262.5", + "Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23262.5", + "Microsoft.Build.Traversal": "3.4.0" + } +} diff --git a/libc/utils/buildbot/Dockerfile b/libc/utils/buildbot/Dockerfile deleted file mode 100644 index 8c497be6db0cc4..00000000000000 --- a/libc/utils/buildbot/Dockerfile +++ /dev/null @@ -1,36 +0,0 @@ -FROM debian:10 - -# Installing dependencies. -RUN dpkg --add-architecture i386 -RUN apt-get update && apt-get install -y build-essential clang subversion git \ - vim zip libstdc++6:i386 file binutils-dev binutils-gold cmake python-pip \ - ninja-build python3 -RUN python -m pip install buildbot-worker==2.8.4 - -# Temporary dependencies for AOR tests. -RUN apt-get install -y libmpfr-dev libmpc-dev - -# Change linker to gold. -RUN update-alternatives --install "/usr/bin/ld" "ld" "/usr/bin/ld.gold" 20 - -# Create and switch to buildbot user. -RUN useradd buildbot --create-home -USER buildbot - -WORKDIR /home/buildbot - -# Use clang as the compiler. -ENV CC=/usr/bin/clang -ENV CXX=/usr/bin/clang++ - -ENV WORKER_NAME="libc-x86_64-debian" - -# Set up buildbot host and maintainer info. -RUN mkdir -p "${WORKER_NAME}/info/" -RUN bash -c "(uname -a ; \ - gcc --version | head -n1 ; ld --version \ - | head -n1 ; cmake --version | head -n1 ) > ${WORKER_NAME}/info/host" -RUN echo "Paula Toth " > "${WORKER_NAME}/info/admin" - -ADD --chown=buildbot:buildbot run.sh . -ENTRYPOINT ["./run.sh"] diff --git a/libcxx/utils/ci/Dockerfile b/libcxx/utils/ci/Dockerfile deleted file mode 100644 index 178cba41593388..00000000000000 --- a/libcxx/utils/ci/Dockerfile +++ /dev/null @@ -1,300 +0,0 @@ -#===----------------------------------------------------------------------===## -# -# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# -#===----------------------------------------------------------------------===## -# -# This file defines the buildkite and github actions builder images. -# You can build & push both images using: -# -# docker compose build -# docker compose push -# -# Or you can select a single image to build & push using: -# -# docker compose build buildkite-builder -# docker compose push buildkite-builder -# -# The final images can be found at -# -# ghcr.io/libcxx/buildkite-builder -# ghcr.io/libcxx/actions-builder -# ghcr.io/libcxx/android-buildkite-builder -# -# Members of the github.com/libcxx/ organizations have permissions required to push new images. -# -# ===----------------------------------------------------------------------===## -# Running the buildkite image -# ===----------------------------------------------------------------------===## -# -# To start a Buildkite Agent, run it as: -# $ docker run --env-file -it $(docker build -q libcxx/utils/ci) -# -# The environment variables in `` should be the ones necessary -# to run a BuildKite agent: -# -# BUILDKITE_AGENT_TOKEN= -# -# If you're only looking to run the Docker image locally for debugging a -# build bot, see the `run-buildbot-container` script located in this directory. - - -# HACK: We set the base image in the docker-compose file depending on the final target (buildkite vs github actions). -# This means we have a much slower container build, but we can use the same Dockerfile for both targets. -ARG BASE_IMAGE -FROM $BASE_IMAGE AS builder-base - -# Make sure apt-get doesn't try to prompt for stuff like our time zone, etc. -ENV DEBIAN_FRONTEND=noninteractive - -# populated in the docker-compose file -ARG GCC_LATEST_VERSION -ENV GCC_LATEST_VERSION=${GCC_LATEST_VERSION} - -# populated in the docker-compose file -ARG LLVM_HEAD_VERSION -ENV LLVM_HEAD_VERSION=${LLVM_HEAD_VERSION} - -# HACK: The github actions runner image already has sudo and requires its use. The buildkite base image does not. -# Reconcile this. -RUN <, and ToT, which are the ones we support. -# We also install because we need to support the "latest-1" of the -# current LLVM release branch, which is effectively the of the -# tip-of-trunk LLVM. For example, after branching LLVM 14 but before branching -# LLVM 15, we still need to have Clang 12 in this Docker image because the LLVM -# 14 release branch CI uses it. The tip-of-trunk CI will never use Clang 12, -# though. -RUN <> /home/libcxx-builder/.buildkite-agent/buildkite-agent.cfg -EOF - -USER libcxx-builder -WORKDIR /home/libcxx-builder - -ENV PATH="${PATH}:/home/libcxx-builder/.buildkite-agent/bin" - -CMD ["buildkite-agent", "start"] - -# ===----------------------------------------------------------------------===## -# Android Buildkite Builder Image -# ===----------------------------------------------------------------------===## -# -# IMAGE: ghcr.io/libcxx/android-buildkite-builder. -# -FROM buildkite-builder AS android-buildkite-builder - -COPY --from=android-builder-base /opt/android /opt/android -COPY ./vendor/android/container-setup.sh /opt/android/container-setup.sh - -ENV PATH="/opt/android/sdk/platform-tools:${PATH}" - -USER libcxx-builder -WORKDIR /home/libcxx-builder - -# Reset the configuration, we pass the configuration via the environment. -RUN cp /home/libcxx-builder/.buildkite-agent/buildkite-agent.dist.cfg \ - /home/libcxx-builder/.buildkite-agent/buildkite-agent.cfg - -# Modify the Buildkite agent cmdline to do Android setup stuff first. -CMD /opt/android/container-setup.sh && buildkite-agent start - -# ===----------------------------------------------------------------------===## -# Github Actions Builder Image -# ===----------------------------------------------------------------------===## -# -# IMAGE: ghcr.io/libcxx/actions-builder. -# -FROM builder-base AS actions-builder - -# Install 'act' for running github actions locally. This provides an alternative to the run-buildbot script -# while still providing reproducability. -RUN curl -s https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash - -WORKDIR /home/runner -USER runner - - - diff --git a/lld/cmake/modules/AddLLD.cmake b/lld/cmake/modules/AddLLD.cmake index 2ee066b4153519..57f730b8004ab1 100644 --- a/lld/cmake/modules/AddLLD.cmake +++ b/lld/cmake/modules/AddLLD.cmake @@ -64,8 +64,58 @@ macro(add_lld_tool name) DEPENDS ${name} COMPONENT ${name}) endif() - set_property(GLOBAL APPEND PROPERTY LLD_EXPORTS ${name}) + + if(APPLE) + if(LLVM_EXTERNALIZE_DEBUGINFO_INSTALL) + if(LLVM_EXTERNALIZE_DEBUGINFO_EXTENSION) + set(file_ext ${LLVM_EXTERNALIZE_DEBUGINFO_EXTENSION}) + elseif(LLVM_EXTERNALIZE_DEBUGINFO_FLATTEN) + set(file_ext dwarf) + else() + set(file_ext dSYM) + endif() + set(output_name "$.${file_ext}") + if(LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR) + set(output_path "${LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR}/${output_name}") + else() + set(output_path "${output_name}") + endif() + get_filename_component(debuginfo_absolute_path ${output_path} REALPATH BASE_DIR $) + install(FILES ${debuginfo_absolute_path} DESTINATION bin OPTIONAL COMPONENT ${name}) + endif() + elseif(WIN32) + if(LLVM_EXTERNALIZE_DEBUGINFO_INSTALL) + install(FILES $ DESTINATION bin OPTIONAL COMPONENT ${name}) + endif() + else() + if(LLVM_EXTERNALIZE_DEBUGINFO_INSTALL) + if(LLVM_EXTERNALIZE_DEBUGINFO_EXTENSION) + set(file_ext ${LLVM_EXTERNALIZE_DEBUGINFO_EXTENSION}) + else() + set(file_ext debug) + endif() + + set(output_name "$.${file_ext}") + + if(LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR) + set(output_path "${LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR}/${output_name}") + # If an output dir is specified, it must be manually mkdir'd on Linux, + # as that directory needs to exist before we can pipe to a file in it. + add_custom_command(TARGET ${name} POST_BUILD + WORKING_DIRECTORY ${LLVM_RUNTIME_OUTPUT_INTDIR} + COMMAND ${CMAKE_COMMAND} -E make_directory ${LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR} + ) + else() + set(output_path "${output_name}") + endif() + + get_filename_component(debuginfo_absolute_path ${output_path} REALPATH BASE_DIR $) + install(FILES ${debuginfo_absolute_path} DESTINATION bin OPTIONAL COMPONENT ${name}) + endif() + endif() endif() + + set_property(GLOBAL APPEND PROPERTY LLD_EXPORTS ${name}) endif() endmacro() diff --git a/llvm.proj b/llvm.proj new file mode 100644 index 00000000000000..4f7e2c011a7ae0 --- /dev/null +++ b/llvm.proj @@ -0,0 +1,240 @@ + + + + + + Unix Makefiles + Ninja + <_VCVarsScriptName Condition="'$(BuildOS)' == 'Windows_NT'">vcvars64.bat + <_VCVarsScriptName Condition="'$(BuildOS)' == 'Windows_NT' and '$(TargetArchitecture)' == 'arm64'">vcvarsamd64_arm64.bat + <_SetupEnvironment Condition="'$(BuildOS)' == 'Windows_NT'"> + :: VisualStudio includes vswhere.exe that can be used to locate current VisualStudio installation. + set VSWHERE_TOOLS_BIN=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe + set VS_VCINSTALL_DIR= + + :: Try to locate installed VisualStudio VC environment. + if "%VCINSTALLDIR%" == "" if exist "%VSWHERE_TOOLS_BIN%" ( + for /f "tokens=*" %%a in ('"%VSWHERE_TOOLS_BIN%" -latest -prerelease -property installationPath') do ( + set VS_VCINSTALL_DIR=%%a\VC\ + ) + ) + + if NOT "%VCINSTALLDIR%" == "" set VS_VCINSTALL_DIR=%VCINSTALLDIR% + + :: Run VS build environment script. + call "%VS_VCINSTALL_DIR%\Auxiliary\Build\$(_VCVarsScriptName)" + + + <_CMakeConfigureCommand>$(_SetupEnvironment) cmake $(_LLVMSourceDir) -G "$(CMakeGenerator)" @(_LLVMBuildArgs->'%(Identity)',' ') + <_LibCxxConfigureCommand>$(_SetupEnvironment) cmake $(_LibCxxSourceDir) -G "$(CMakeGenerator)" @(_LibCxxBuildArgs->'%(Identity)',' ') + <_BuildSubset Condition="'$(BuildLLVMTableGenOnly)' == 'true'">llvm-tblgen clang-tblgen llvm-config clang-tidy-confusable-chars-gen clang-pseudo-gen + <_BuildSubset Condition="'$(BuildObjWriterOnly)' == 'true'">objwriter llvm-mca llvm-dwarfdump FileCheck + <_BuildCommand Condition="'$(CMakeGenerator)' == 'Unix Makefiles'">$(_SetupEnvironment) make $(_BuildSubset) -j$([System.Environment]::ProcessorCount) + <_BuildCommand Condition="'$(CMakeGenerator)' == 'Ninja'">$(_SetupEnvironment) ninja $(_BuildSubset) + <_CMakeInstallCommand Condition="'$(BuildObjWriterOnly)' == 'true'"> + $(_SetupEnvironment) + + cmake -DCMAKE_INSTALL_DO_STRIP=1 -DCMAKE_INSTALL_PREFIX=$(_LLVMInstallDir) -DCMAKE_INSTALL_COMPONENT=objwriter -P cmake_install.cmake + cmake -DCMAKE_INSTALL_DO_STRIP=1 -DCMAKE_INSTALL_PREFIX=$(_LLVMInstallDir) -DCMAKE_INSTALL_COMPONENT=llvm-mca -P cmake_install.cmake + cmake -DCMAKE_INSTALL_DO_STRIP=1 -DCMAKE_INSTALL_PREFIX=$(_LLVMInstallDir) -DCMAKE_INSTALL_COMPONENT=llvm-dwarfdump -P cmake_install.cmake + cmake -DCMAKE_INSTALL_DO_STRIP=1 -DCMAKE_INSTALL_PREFIX=$(_LLVMInstallDir) -DCMAKE_INSTALL_COMPONENT=FileCheck -P cmake_install.cmake + + <_CMakeInstallCommand Condition="'$(BuildObjWriterOnly)' != 'true'">$(_SetupEnvironment) cmake -DCMAKE_INSTALL_DO_STRIP=1 -DCMAKE_INSTALL_PREFIX=$(_LLVMInstallDir) -P cmake_install.cmake + + + + <_CrossCFlags>--target=$(ClangTarget) + <_CrossCFlags Condition="'$(BuildOS)' == 'Linux'">$(_CrossCFlags) --sysroot=$(ROOTFS_DIR) --gcc-toolchain=$(ROOTFS_DIR)/usr + <_SharedLinkerFlags>$(_CrossCFlags) + <_SharedLinkerFlags Condition="'$(BuildOS)' == 'Linux'">-Wl,--build-id -Wl,-rpath,'%5C%24ORIGIN' -fuse-ld=lld $(_SharedLinkerFlags) + /usr/bin + + + + <_LLVMBuildArgs Condition="'$(TargetArchitecture)' == 'arm64'" Include="-DLLVM_TARGET_ARCH=AARCH64" /> + <_LLVMBuildArgs Condition="'$(TargetArchitecture)' == 'arm'" Include="-DLLVM_TARGET_ARCH=ARM" /> + <_LLVMBuildArgs Condition="'$(TargetArchitecture)' == 'x64'" Include="-DLLVM_TARGET_ARCH=X86_64" /> + <_LLVMBuildArgs Condition="'$(TargetArchitecture)' == 'arm64' and '$(BuildOS)' == 'Windows_NT'" Include="-DLLVM_DEFAULT_TARGET_TRIPLE=aarch64-windows-msvc" /> + <_LLVMBuildArgs Condition="'$(ClangTarget)' != '' and '$(BuildOS)' == 'Linux'" Include="-DLLVM_DEFAULT_TARGET_TRIPLE=$(ClangTarget)" /> + <_LLVMBuildArgs Condition="'$(ClangTarget)' != '' and '$(BuildOS)' == 'Linux'" Include="-DCMAKE_OBJCOPY=$(ClangBinDir)/llvm-objcopy" /> + <_LLVMBuildArgs Condition="'$(ClangTarget)' != '' and '$(BuildOS)' == 'Linux'" Include="-DCMAKE_STRIP=$(ClangBinDir)/llvm-strip" /> + <_LLVMBuildArgs Condition="'$(TargetArchitecture)' == 'x64' and '$(BuildOS)' == 'OSX'" Include="-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-apple-darwin" /> + <_LLVMBuildArgs Condition="'$(TargetArchitecture)' == 'x64' and '$(BuildOS)' == 'OSX'" Include="-DCMAKE_OSX_ARCHITECTURES=x86_64"/> + <_LLVMBuildArgs Condition="'$(TargetArchitecture)' == 'arm64' and '$(BuildOS)' == 'OSX'" Include="-DLLVM_DEFAULT_TARGET_TRIPLE=arm64-apple-darwin" /> + <_LLVMBuildArgs Condition="'$(TargetArchitecture)' == 'arm64' and '$(BuildOS)' == 'OSX'" Include="-DCMAKE_OSX_ARCHITECTURES=arm64"/> + + <_LLVMBuildArgs Condition="'$(TargetArchitecture)' == 'arm64' and '$(BuildOS)' == 'Windows_NT'" Include="-DCMAKE_SYSTEM_NAME=Windows" /> + <_LLVMBuildArgs Condition="'$(BuildOS)' == 'Linux'" Include="-DCMAKE_SYSTEM_NAME=Linux" /> + <_LLVMBuildArgs Condition="'$(BuildOS)' == 'OSX'" Include="-DCMAKE_SYSTEM_NAME=Darwin" /> + <_LLVMBuildArgs Include="-DCMAKE_BUILD_TYPE=Release" /> + <_LLVMBuildArgs Include='-DLEGAL_COPYRIGHT="\xa9 Microsoft Corporation. All rights reserved."' /> + <_LLVMBuildArgs Include="-DLLVM_BUILD_LLVM_C_DYLIB=OFF" /> + <_LLVMBuildArgs Include="-DLLVM_ENABLE_DIA_SDK=OFF" /> + <_LLVMBuildArgs Include="-DLLVM_INCLUDE_TESTS=OFF" /> + <_LLVMBuildArgs Include='-DLLVM_TARGETS_TO_BUILD="X86%3BAArch64%3BARM%3BWebAssembly"' /> + <_LLVMBuildArgs Include='-DLLVM_BUILD_TESTS=OFF' /> + <_LLVMBuildArgs Include='-DLLVM_BUILD_EXAMPLES=OFF' /> + <_LLVMBuildArgs Include='-DLLVM_INCLUDE_EXAMPLES=OFF' /> + <_LLVMBuildArgs Include='-DLLVM_TOOLS_TO_BUILD="llc%3Bllvm-addr2line%3Bllvm-ar%3Bllvm-as%3Bllvm-config%3Bllvm-cxxfilt%3Bllvm-dis%3Bllvm-dwarfdump%3Bllvm-dwp%3Bllvm-mc%3Bllvm-mca%3Bllvm-nm%3Bllvm-objcopy%3Bllvm-objdump%3Bllvm-ranlib%3Bllvm-readobj%3Bllvm-size%3Bllvm-strings%3Bllvm-strip%3Bllvm-symbolizer%3Bobjwriter%3Bopt%3BFileCheck"' /> + <_LLVMBuildArgs Include='-DLLVM_INSTALL_BINUTILS_SYMLINKS=TRUE' /> + <_LLVMBuildArgs Include='-DLLVM_ENABLE_LIBXML2=OFF' /> + <_LLVMBuildArgs Include='-DLLVM_ENABLE_TERMINFO=OFF' /> + <_LLVMBuildArgs Include='-DLLVM_ENABLE_ZSTD=OFF' /> + <_LLVMBuildArgs Include='-DLLVM_EXTERNALIZE_DEBUGINFO=ON' /> + <_LLVMBuildArgs Include='-DLLVM_EXTERNALIZE_DEBUGINFO_INSTALL=ON' /> + <_LLVMBuildArgs Include='-DLLVM_ENABLE_PDB=ON' /> + <_LLVMBuildArgs Condition="'$(BuildOS)' == 'Linux'" Include='-DLLVM_EXTERNALIZE_DEBUGINFO_EXTENSION=dbg' /> + <_LLVMBuildArgs Condition="'$(BuildOS)' == 'OSX'" Include='-DLLVM_EXTERNALIZE_DEBUGINFO_EXTENSION=dwarf -DLLVM_EXTERNALIZE_DEBUGINFO_FLATTEN=ON' /> + <_LLVMBuildArgs Condition="'$(BuildOS)' == 'Windows_NT' and '$(Configuration)' == 'Release'" Include='-DLLVM_USE_CRT_DEBUG=MT' /> + <_LLVMBuildArgs Condition="'$(BuildOS)' == 'Windows_NT' and '$(Configuration)' == 'Release'" Include='-DLLVM_USE_CRT_RELEASE=MT' /> + <_LLVMBuildArgs Condition="'$(BuildOS)' == 'Windows_NT' and '$(Configuration)' == 'Debug'" Include='-DLLVM_USE_CRT_DEBUG=MTd' /> + <_LLVMBuildArgs Condition="'$(BuildOS)' == 'Windows_NT' and '$(Configuration)' == 'Debug'" Include='-DLLVM_USE_CRT_RELEASE=MTd' /> + <_LLVMBuildArgs Condition="'$(BuildOS)' == 'Windows_NT'" Include='-DLLVM_ENABLE_ZLIB=OFF' /> + <_LLVMBuildArgs Condition="'$(BuildOS)' == 'Windows_NT'" Include='-DLLVM_NATIVE_TOOL_DIR=$(NativeTablegenDir)' /> + <_LLVMBuildArgs Include='-DLLVM_ENABLE_PROJECTS="lld%3Bclang%3Bclang-tools-extra"' /> + <_LLVMBuildArgs Include='-DLLVM_BUILD_TOOLS:BOOL=ON' /> + <_LLVMBuildArgs Include='-DLLVM_INSTALL_UTILS:BOOL=ON' /> + <_LLVMBuildArgs Include="-DLLVM_INCLUDE_UTILS:BOOL=ON" /> + <_LLVMBuildArgs Include='-DCLANG_INCLUDE_TESTS=OFF' /> + <_LLVMBuildArgs Include='-DCLANG_ENABLE_ARCMT=OFF' /> + <_LLVMBuildArgs Include='-DLLVM_ENABLE_LIBCXX=ON' /> + <_LLVMBuildArgs Include='-DCLANG_ENABLE_STATIC_ANALYZER=OFF' /> + <_LLVMBuildArgs Condition="'$(BuildOS)' == 'Linux'" Include='-DCMAKE_POSITION_INDEPENDENT_CODE=ON' /> + <_LLVMBuildArgs Condition="'$(BuildOS)' == 'Linux'" Include='-DCROSS_TOOLCHAIN_FLAGS_LLVM_NATIVE="-DCMAKE_C_COMPILER=clang%3B-DCMAKE_CXX_COMPILER=clang++%3B-DCMAKE_ASM_COMPILER=clang%3B-DCMAKE_EXE_LINKER_FLAGS_INIT=-fuse-ld=lld%3B-DCMAKE_SHARED_LINKER_FLAGS_INIT=-fuse-ld=lld"' /> + + + + <_LLVMBuildArgs Include="-DCMAKE_C_COMPILER=clang" /> + <_LLVMBuildArgs Include="-DCMAKE_CXX_COMPILER=clang++" /> + <_LLVMBuildArgs Include="-DCMAKE_ASM_COMPILER=clang" /> + + + + <_LibCxxCFlags>-I$(_LibCxxInstallDir)/include/c++/v1 -L$(_LibCxxInstallDir)/lib -stdlib=libc++ + + + + <_LLVMBuildArgs Include='-DCMAKE_C_FLAGS="-I../llvm/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DNDEBUG -D__NO_CTYPE_INLINE -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS $(_CrossCFlags)"' /> + <_LLVMBuildArgs Include='-DCMAKE_CXX_FLAGS="-I../llvm/include $(_LibCxxCFlags) -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DNDEBUG -D__NO_CTYPE_INLINE -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS $(_CrossCFlags) "' /> + <_LLVMBuildArgs Include='-DCMAKE_ASM_FLAGS="-I../llvm/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DNDEBUG -D__NO_CTYPE_INLINE -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS $(_CrossCFlags) "' /> + <_LLVMBuildArgs Include='-DCMAKE_EXE_LINKER_FLAGS_INIT="$(_SharedLinkerFlags)"' /> + <_LLVMBuildArgs Include='-DCMAKE_SHARED_LINKER_FLAGS_INIT="$(_SharedLinkerFlags)"' /> + <_LLVMBuildArgs Include='-DCMAKE_MODULE_LINKER_FLAGS_INIT="$(_SharedLinkerFlags)"' /> + <_LLVMBuildArgs Condition="'$(BuildOS)' == 'OSX' and '$(TargetArchitecture)' == 'arm64'" Include='-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0' /> + <_LLVMBuildArgs Condition="'$(BuildOS)' == 'OSX' and '$(TargetArchitecture)' == 'x64'" Include='-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13' /> + + + + + + + + + + <_LibCxxBuildArgs Include='-DLLVM_ENABLE_RUNTIMES="libcxx%3Blibcxxabi%3Blibunwind"' /> + <_LibCxxBuildArgs Include="-DCMAKE_C_COMPILER=clang" /> + <_LibCxxBuildArgs Include="-DCMAKE_CXX_COMPILER=clang++" /> + <_LibCxxBuildArgs Include="-DCMAKE_ASM_COMPILER=clang" /> + <_LibCxxBuildArgs Include='-DCMAKE_C_FLAGS="-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DNDEBUG -D__NO_CTYPE_INLINE -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS $(_CrossCFlags)"' /> + <_LibCxxBuildArgs Include='-DCMAKE_CXX_FLAGS="-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DNDEBUG -D__NO_CTYPE_INLINE -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS $(_CrossCFlags)"' /> + <_LibCxxBuildArgs Include='-DCMAKE_ASM_FLAGS="-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DNDEBUG -D__NO_CTYPE_INLINE -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS $(_CrossCFlags)"' /> + <_LibCxxBuildArgs Include='-DCMAKE_EXE_LINKER_FLAGS_INIT="-Wl,--build-id -fuse-ld=lld"' /> + <_LibCxxBuildArgs Include='-DCMAKE_SHARED_LINKER_FLAGS_INIT="-Wl,--build-id -fuse-ld=lld"' /> + <_LibCxxBuildArgs Include='-DCMAKE_MODULE_LINKER_FLAGS_INIT="-Wl,--build-id -fuse-ld=lld"' /> + <_LibCxxBuildArgs Include='-DCMAKE_INSTALL_PREFIX=$(_LibCxxInstallDir)' /> + <_LibCxxBuildArgs Include='-DCMAKE_POSITION_INDEPENDENT_CODE=ON' /> + <_LibCxxBuildArgs Include="-DCMAKE_CXX_COMPILER_TARGET=$(ClangTarget)" /> + <_LibCxxBuildArgs Include="-DLLVM_DEFAULT_TARGET_TRIPLE=$(ClangTarget)" /> + <_LibCxxBuildArgs Condition="$(ClangTarget.ToLowerInvariant().Contains('musl'))" Include="-DLIBCXX_HAS_MUSL_LIBC=ON" /> + + + + + + + + + <_LibCxxUnstripped Include="libc++.so.1.0" /> + <_LibCxxUnstripped Include="libc++abi.so.1.0" /> + <_LibCxxUnstripped Include="libunwind.so.1.0" /> + + + .dbg + + + + + + + + + + + + + + + + + + llvm-$(PackageVersion.Trim())-dotnet + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 6f5647d70d8bc1..601f0dc41433cd 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -19,6 +19,8 @@ include(${LLVM_COMMON_CMAKE_UTILS}/Modules/LLVMVersion.cmake) set_directory_properties(PROPERTIES LLVM_VERSION_MAJOR "${LLVM_VERSION_MAJOR}") +set(MONO_API_VERSION 1600) + if (NOT PACKAGE_VERSION) set(PACKAGE_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX}") @@ -1399,3 +1401,8 @@ endif() if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS) add_subdirectory(utils/llvm-locstats) endif() + +# emit version we consume in Arcade +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/version.txt.in + ${CMAKE_CURRENT_BINARY_DIR}/version.txt) diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index f6fb56eb51e833..25aa408016ac3c 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -405,11 +405,13 @@ endfunction(add_windows_version_resource_file) # Optional version string (defaults to PACKAGE_VERSION) # PRODUCT_NAME # Optional product name string (defaults to "LLVM") +# PRODUCT_LEGAL_COPYRIGHT +# Optional product legal copyright string # ) function(set_windows_version_resource_properties name resource_file) cmake_parse_arguments(ARG "" - "VERSION_MAJOR;VERSION_MINOR;VERSION_PATCHLEVEL;VERSION_STRING;PRODUCT_NAME" + "VERSION_MAJOR;VERSION_MINOR;VERSION_PATCHLEVEL;VERSION_STRING;PRODUCT_NAME;PRODUCT_LEGAL_COPYRIGHT" "" ${ARGN}) @@ -449,6 +451,10 @@ function(set_windows_version_resource_properties name resource_file) set(ARG_PRODUCT_NAME "LLVM") endif() + if (NOT DEFINED ARG_PRODUCT_LEGAL_COPYRIGHT) + set(ARG_PRODUCT_LEGAL_COPYRIGHT ${LEGAL_COPYRIGHT}) + endif() + set_property(SOURCE ${resource_file} PROPERTY COMPILE_FLAGS /nologo) set_property(SOURCE ${resource_file} @@ -460,7 +466,8 @@ function(set_windows_version_resource_properties name resource_file) "RC_FILE_VERSION=\"${ARG_VERSION_STRING}\"" "RC_INTERNAL_NAME=\"${name}\"" "RC_PRODUCT_NAME=\"${ARG_PRODUCT_NAME}\"" - "RC_PRODUCT_VERSION=\"${ARG_VERSION_STRING}\"") + "RC_PRODUCT_VERSION=\"${ARG_VERSION_STRING}\"" + "RC_COPYRIGHT=\"${ARG_PRODUCT_LEGAL_COPYRIGHT}\"") endfunction(set_windows_version_resource_properties) # llvm_add_library(name sources... @@ -972,10 +979,15 @@ endmacro() macro(add_llvm_executable name) cmake_parse_arguments(ARG - "DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH;SUPPORT_PLUGINS" + "DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH;SUPPORT_PLUGINS;DEBUGINFO_INSTALL" "ENTITLEMENTS;BUNDLE_PATH" "" ${ARGN}) + + if(ARG_DEBUGINFO_INSTALL) + set(DEBUGINFO_INSTALL "DEBUGINFO_INSTALL") + endif() + generate_llvm_objects(${name} ${ARG_UNPARSED_ARGUMENTS}) add_windows_version_resource_file(ALL_FILES ${ALL_FILES}) @@ -1046,7 +1058,7 @@ macro(add_llvm_executable name) add_custom_linker_flags(${name}) if(NOT ARG_IGNORE_EXTERNALIZE_DEBUGINFO) - llvm_externalize_debuginfo(${name}) + llvm_externalize_debuginfo(${name} ${DEBUGINFO_INSTALL}) endif() if (LLVM_PTHREAD_LIB) # libpthreads overrides some standard library symbols, so main @@ -1378,7 +1390,10 @@ macro(llvm_add_tool project name) generate_llvm_objects(${name} ${ARGN}) add_custom_target(${name} DEPENDS llvm-driver) else() - add_llvm_executable(${name} ${ARGN}) + if ( (${name} IN_LIST LLVM_TOOLCHAIN_TOOLS OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY) AND LLVM_BUILD_TOOLS ) + set(DEBUGINFO_INSTALL "DEBUGINFO_INSTALL") + endif() + add_llvm_executable(${name} ${DEBUGINFO_INSTALL} ${ARGN}) if ( ${name} IN_LIST LLVM_TOOLCHAIN_TOOLS OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY) if( LLVM_BUILD_TOOLS ) @@ -1411,7 +1426,12 @@ macro(add_llvm_example name) if( NOT LLVM_BUILD_EXAMPLES ) set(EXCLUDE_FROM_ALL ON) endif() - add_llvm_executable(${name} ${ARGN}) + + if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY AND LLVM_INSTALL_UTILS AND LLVM_BUILD_UTILS) + set(DEBUGINFO_INSTALL "DEBUGINFO_INSTALL") + endif() + + add_llvm_executable(${name} ${DEBUGINFO_INSTALL} ${ARGN}) if( LLVM_BUILD_EXAMPLES ) install(TARGETS ${name} RUNTIME DESTINATION "${LLVM_EXAMPLES_INSTALL_DIR}") endif() @@ -1436,7 +1456,11 @@ macro(add_llvm_utility name) set(EXCLUDE_FROM_ALL ON) endif() - add_llvm_executable(${name} DISABLE_LLVM_LINK_LLVM_DYLIB ${ARGN}) + if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY AND LLVM_INSTALL_UTILS AND LLVM_BUILD_UTILS) + set(DEBUGINFO_INSTALL "DEBUGINFO_INSTALL") + endif() + + add_llvm_executable(${name} DISABLE_LLVM_LINK_LLVM_DYLIB ${DEBUGINFO_INSTALL} ${ARGN}) set_target_properties(${name} PROPERTIES FOLDER "Utils") if ( ${name} IN_LIST LLVM_TOOLCHAIN_UTILITIES OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY) if (LLVM_INSTALL_UTILS AND LLVM_BUILD_UTILS) @@ -2278,6 +2302,8 @@ function(llvm_externalize_debuginfo name) return() endif() + cmake_parse_arguments(ARG "DEBUGINFO_INSTALL" "" "" ${ARGN}) + if(NOT LLVM_EXTERNALIZE_DEBUGINFO_SKIP_STRIP) if(APPLE) if(NOT CMAKE_STRIP) @@ -2292,6 +2318,8 @@ function(llvm_externalize_debuginfo name) if(APPLE) if(LLVM_EXTERNALIZE_DEBUGINFO_EXTENSION) set(file_ext ${LLVM_EXTERNALIZE_DEBUGINFO_EXTENSION}) + elseif(LLVM_EXTERNALIZE_DEBUGINFO_FLATTEN) + set(file_ext dwarf) else() set(file_ext dSYM) endif() @@ -2299,9 +2327,16 @@ function(llvm_externalize_debuginfo name) set(output_name "$.${file_ext}") if(LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR) - set(output_path "-o=${LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR}/${output_name}") + set(output_path "${LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR}/${output_name}") else() - set(output_path "-o=${output_name}") + set(output_path "${output_name}") + endif() + set(output_flag "-o=${output_path}") + + if(LLVM_EXTERNALIZE_DEBUGINFO_FLATTEN) + set(flatten_debuginfo "--flat") + else() + set(flatten_debuginfo "") endif() if(CMAKE_CXX_FLAGS MATCHES "-flto" @@ -2315,15 +2350,50 @@ function(llvm_externalize_debuginfo name) set(CMAKE_DSYMUTIL xcrun dsymutil) endif() add_custom_command(TARGET ${name} POST_BUILD - COMMAND ${CMAKE_DSYMUTIL} ${output_path} $ + WORKING_DIRECTORY ${LLVM_RUNTIME_OUTPUT_INTDIR} + COMMAND ${CMAKE_DSYMUTIL} ${flatten_debuginfo} ${output_flag} $ ${strip_command} ) + if(LLVM_EXTERNALIZE_DEBUGINFO_INSTALL AND ARG_DEBUGINFO_INSTALL) + get_filename_component(debuginfo_absolute_path ${output_path} REALPATH BASE_DIR $) + install(FILES ${debuginfo_absolute_path} DESTINATION bin OPTIONAL COMPONENT ${name}) + endif() + elseif(WIN32) + if(LLVM_EXTERNALIZE_DEBUGINFO_INSTALL AND ARG_DEBUGINFO_INSTALL) + install(FILES $ DESTINATION bin OPTIONAL COMPONENT ${name}) + endif() else() + + if(LLVM_EXTERNALIZE_DEBUGINFO_EXTENSION) + set(file_ext ${LLVM_EXTERNALIZE_DEBUGINFO_EXTENSION}) + else() + set(file_ext debug) + endif() + + set(output_name "$.${file_ext}") + + if(LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR) + set(output_path "${LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR}/${output_name}") + # If an output dir is specified, it must be manually mkdir'd on Linux, + # as that directory needs to exist before we can pipe to a file in it. + add_custom_command(TARGET ${name} POST_BUILD + WORKING_DIRECTORY ${LLVM_RUNTIME_OUTPUT_INTDIR} + COMMAND ${CMAKE_COMMAND} -E make_directory ${LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR} + ) + else() + set(output_path "${output_name}") + endif() + add_custom_command(TARGET ${name} POST_BUILD - COMMAND ${CMAKE_OBJCOPY} --only-keep-debug $ $.debug + WORKING_DIRECTORY ${LLVM_RUNTIME_OUTPUT_INTDIR} + COMMAND ${CMAKE_OBJCOPY} --only-keep-debug $ ${output_path} ${strip_command} -R .gnu_debuglink - COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=$.debug $ + COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${output_path} $ ) + if(LLVM_EXTERNALIZE_DEBUGINFO_INSTALL AND ARG_DEBUGINFO_INSTALL) + get_filename_component(debuginfo_absolute_path ${output_path} REALPATH BASE_DIR $) + install(FILES ${debuginfo_absolute_path} DESTINATION bin OPTIONAL COMPONENT ${name}) + endif() endif() endfunction() diff --git a/llvm/cmake/modules/TableGen.cmake b/llvm/cmake/modules/TableGen.cmake index df91598c404f57..470098f063f9ee 100644 --- a/llvm/cmake/modules/TableGen.cmake +++ b/llvm/cmake/modules/TableGen.cmake @@ -177,7 +177,17 @@ macro(add_tablegen target project) set(${target}_OLD_LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS}) set(LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS} TableGen) - add_llvm_executable(${target} DISABLE_LLVM_LINK_LLVM_DYLIB + # CMake doesn't let compilation units depend on their dependent libraries on some generators. + if(NOT CMAKE_GENERATOR MATCHES "Ninja" AND NOT XCODE) + # FIXME: It leaks to user, callee of add_tablegen. + set(LLVM_ENABLE_OBJLIB ON) + endif() + + if ((${project} STREQUAL LLVM OR ${project} STREQUAL MLIR) AND NOT LLVM_INSTALL_TOOLCHAIN_ONLY AND LLVM_BUILD_UTILS) + set(DEBUGINFO_INSTALL "DEBUGINFO_INSTALL") + endif() + + add_llvm_executable(${target} DISABLE_LLVM_LINK_LLVM_DYLIB ${DEBUGINFO_INSTALL} ${ADD_TABLEGEN_UNPARSED_ARGUMENTS}) set(LLVM_LINK_COMPONENTS ${${target}_OLD_LLVM_LINK_COMPONENTS}) diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h index 7cfe4dc4f775fd..e9fd021fa6c650 100644 --- a/llvm/include/llvm-c/Core.h +++ b/llvm/include/llvm-c/Core.h @@ -221,6 +221,7 @@ typedef enum { LLVMPreserveAllCallConv = 15, LLVMSwiftCallConv = 16, LLVMCXXFASTTLSCallConv = 17, + LLVMMono1CallConv = 21, LLVMX86StdcallCallConv = 64, LLVMX86FastcallCallConv = 65, LLVMARMAPCSCallConv = 66, diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h index a2c90c9f42f38f..34cdcd8d9172e0 100644 --- a/llvm/include/llvm/CodeGen/MachineFunction.h +++ b/llvm/include/llvm/CodeGen/MachineFunction.h @@ -407,6 +407,9 @@ class LLVM_EXTERNAL_VISIBILITY MachineFunction { /// \pre Fn, Target, MMI, and FunctionNumber are properly set. void init(); + // Stack slot containing the this pointer for mono compiled functions + int MonoThisSlot; + public: /// Description of the location of a variable whose Address is valid and /// unchanging during function execution. The Address may be: @@ -675,6 +678,9 @@ class LLVM_EXTERNAL_VISIBILITY MachineFunction { PseudoSourceValueManager &getPSVManager() const { return *PSVManager; } + int getMonoThisSlot() const { return MonoThisSlot; } + void setMonoThisSlot(int Slot) { MonoThisSlot = Slot; } + /// Return the DataLayout attached to the Module associated to this MF. const DataLayout &getDataLayout() const; diff --git a/llvm/include/llvm/Config/llvm-config.h.cmake b/llvm/include/llvm/Config/llvm-config.h.cmake index 6605ea60df99e1..19f5dc12fc0e7c 100644 --- a/llvm/include/llvm/Config/llvm-config.h.cmake +++ b/llvm/include/llvm/Config/llvm-config.h.cmake @@ -198,4 +198,7 @@ /* Define if plugins enabled */ #cmakedefine LLVM_ENABLE_PLUGINS +/* Mono api version */ +#cmakedefine MONO_API_VERSION ${MONO_API_VERSION} + #endif diff --git a/llvm/include/llvm/MC/MCObjectStreamer.h b/llvm/include/llvm/MC/MCObjectStreamer.h index e212d546139808..7ef004d631cfed 100644 --- a/llvm/include/llvm/MC/MCObjectStreamer.h +++ b/llvm/include/llvm/MC/MCObjectStreamer.h @@ -138,6 +138,11 @@ class MCObjectStreamer : public MCStreamer { const MCExpr *Value) override; void emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc = SMLoc()) override; + /// \brief EmitValueImpl with additional param, that allows to emit PCRelative + /// MCFixup. + void emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc, + bool isPCRelative); + void emitULEB128Value(const MCExpr *Value) override; void emitSLEB128Value(const MCExpr *Value) override; void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override; diff --git a/llvm/include/llvm/MC/MCStreamer.h b/llvm/include/llvm/MC/MCStreamer.h index 671511ab4b88e3..67df6f78e7c630 100644 --- a/llvm/include/llvm/MC/MCStreamer.h +++ b/llvm/include/llvm/MC/MCStreamer.h @@ -149,6 +149,7 @@ class ARMTargetStreamer : public MCTargetStreamer { virtual void emitPad(int64_t Offset); virtual void emitRegSave(const SmallVectorImpl &RegList, bool isVector); + virtual void emitLsda(const MCSymbol *Symbol); virtual void emitUnwindRaw(int64_t StackOffset, const SmallVectorImpl &Opcodes); @@ -718,6 +719,9 @@ class MCStreamer { /// etc. virtual void emitBytes(StringRef Data); + /// \brief Emit the given \p Instruction data into the current section. + virtual void emitInstructionBytes(StringRef Data); + /// Functionally identical to EmitBytes. When emitting textual assembly, this /// method uses .byte directives instead of .ascii or .asciz for readability. virtual void emitBinaryData(StringRef Data); @@ -1054,6 +1058,7 @@ class MCStreamer { SMLoc Loc = {}); virtual void emitCFIWindowSave(SMLoc Loc = {}); virtual void emitCFINegateRAState(SMLoc Loc = {}); + virtual void emitCFICompactUnwindEncoding(unsigned Encoding); virtual void emitWinCFIStartProc(const MCSymbol *Symbol, SMLoc Loc = SMLoc()); virtual void emitWinCFIEndProc(SMLoc Loc = SMLoc()); diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp index 323f1a6a1b2bd7..fe48a7a9dd6b67 100644 --- a/llvm/lib/CodeGen/MachineFunction.cpp +++ b/llvm/lib/CodeGen/MachineFunction.cpp @@ -247,6 +247,8 @@ void MachineFunction::init() { "Target-incompatible DataLayout attached\n"); PSVManager = std::make_unique(getTarget()); + + MonoThisSlot = -1; } void MachineFunction::initTargetMachineFunctionInfo( diff --git a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp index e01cd8cbf925a2..2623e1f44cd223 100644 --- a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp @@ -172,6 +172,17 @@ void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf, for (int *CatchObjPtr : Iter->second) *CatchObjPtr = FrameIndex; } + + // + // The mono exception handling code needs to location of the 'this' pointer + // to handle stack traces containing generic shared methods. + // To implement this, it saves the this pointer to an alloca which is marked with + // the 'mono.this' custom metadata. We save the stack slot used by this alloca + // in MachineFunction, so the dwarf exception info emission code can use it to + // compute the reg+offset for it, and save it into the LSDA. + // + if (AI->getMetadata("mono.this")) + MF->setMonoThisSlot(StaticAllocaMap[AI]); } else { // FIXME: Overaligned static allocas should be grouped into // a single dynamic allocation instead of using a separate diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp index 490e0a4dd40417..83f6e8a5bdc360 100644 --- a/llvm/lib/MC/MCObjectStreamer.cpp +++ b/llvm/lib/MC/MCObjectStreamer.cpp @@ -246,7 +246,7 @@ void MCObjectStreamer::emitCFISections(bool EH, bool Debug) { } void MCObjectStreamer::emitValueImpl(const MCExpr *Value, unsigned Size, - SMLoc Loc) { + SMLoc Loc, bool isPCRelative) { MCStreamer::emitValueImpl(Value, Size, Loc); MCDataFragment *DF = getOrCreateDataFragment(); flushPendingLabels(DF, DF->getContents().size()); @@ -266,10 +266,15 @@ void MCObjectStreamer::emitValueImpl(const MCExpr *Value, unsigned Size, } DF->getFixups().push_back( MCFixup::create(DF->getContents().size(), Value, - MCFixup::getKindForSize(Size, false), Loc)); + MCFixup::getKindForSize(Size, isPCRelative), Loc)); DF->getContents().resize(DF->getContents().size() + Size, 0); } +void MCObjectStreamer::emitValueImpl(const MCExpr *Value, unsigned Size, + SMLoc Loc) { + emitValueImpl(Value, Size, Loc, false); +} + MCSymbol *MCObjectStreamer::emitCFILabel() { MCSymbol *Label = getContext().createTempSymbol("cfi"); emitLabel(Label); diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp index d0395770ae8b05..807c3da8fabba1 100644 --- a/llvm/lib/MC/MCStreamer.cpp +++ b/llvm/lib/MC/MCStreamer.cpp @@ -125,6 +125,7 @@ void MCStreamer::emitExplicitComments() {} void MCStreamer::generateCompactUnwindEncodings(MCAsmBackend *MAB) { for (auto &FI : DwarfFrameInfos) +// in previous dotnet change if (FI.CompactUnwindEncoding == 0) { FI.CompactUnwindEncoding = (MAB ? MAB->generateCompactUnwindEncoding(&FI, &Context) : 0); } @@ -692,6 +693,14 @@ void MCStreamer::emitCFINegateRAState(SMLoc Loc) { CurFrame->Instructions.push_back(Instruction); } +void MCStreamer::emitCFICompactUnwindEncoding(unsigned Encoding) +{ + MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo(); + if (!CurFrame) + return; + CurFrame->CompactUnwindEncoding = Encoding; +} + void MCStreamer::emitCFIReturnColumn(int64_t Register) { MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo(); if (!CurFrame) @@ -1221,6 +1230,7 @@ void MCStreamer::emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, void MCStreamer::changeSection(MCSection *, const MCExpr *) {} void MCStreamer::emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) {} void MCStreamer::emitBytes(StringRef Data) {} +void MCStreamer::emitInstructionBytes(StringRef Data) { emitBytes(Data); } void MCStreamer::emitBinaryData(StringRef Data) { emitBytes(Data); } void MCStreamer::emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) { visitUsedExpr(*Value); diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp index 30ef3680ae79c9..ef999cf3e3049c 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp @@ -139,6 +139,7 @@ static unsigned getFixupKindNumBytes(unsigned Kind) { case AArch64::fixup_aarch64_pcrel_call26: case FK_Data_4: case FK_SecRel_4: + case FK_PCRel_4: return 4; case FK_Data_8: @@ -349,14 +350,20 @@ static uint64_t adjustFixupValue(const MCFixup &Fixup, const MCValue &Target, case FK_Data_8: case FK_SecRel_2: case FK_SecRel_4: + case FK_PCRel_4: return Value; } } std::optional AArch64AsmBackend::getFixupKind(StringRef Name) const { - if (!TheTriple.isOSBinFormatELF()) - return std::nullopt; + if (!TheTriple.isOSBinFormatELF()) { + return StringSwitch>(Name) + .Case("R_AARCH64_CALL26", (MCFixupKind)AArch64::fixup_aarch64_pcrel_call26) + .Case("R_AARCH64_ADR_PREL_PG_HI21", (MCFixupKind)AArch64::fixup_aarch64_pcrel_adrp_imm21) + .Case("R_AARCH64_ADD_ABS_LO12_NC", (MCFixupKind)AArch64::fixup_aarch64_add_imm12) + .Default(MCAsmBackend::getFixupKind(Name)); + } unsigned Type = llvm::StringSwitch(Name) #define ELF_RELOC(X, Y) .Case(#X, Y) diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp index 6e074b6a63c41d..ba80c855c53101 100644 --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp @@ -135,6 +135,7 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx, return ELF::R_AARCH64_NONE; case FK_Data_2: return R_CLS(PREL16); + case FK_PCRel_4: case FK_Data_4: { return Target.getAccessVariant() == MCSymbolRefExpr::VK_PLT ? R_CLS(PLT32) diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp index 6cd4badb7704b7..1f323bc9fa8bcc 100644 --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp +++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp @@ -469,6 +469,8 @@ unsigned ARMAsmBackend::adjustFixupValue(const MCAssembler &Asm, case FK_Data_2: case FK_Data_4: return Value; + case FK_PCRel_4: + return Value; case FK_SecRel_2: return Value; case FK_SecRel_4: @@ -1012,6 +1014,9 @@ static unsigned getFixupKindNumBytes(unsigned Kind) { case ARM::fixup_le: return 4; + case FK_PCRel_4: + return 4; + case FK_SecRel_2: return 2; case FK_SecRel_4: diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp index de7449a400a741..45d430f1996064 100644 --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp +++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp @@ -121,6 +121,8 @@ unsigned ARMELFObjectWriter::GetRelocTypeInner(const MCValue &Target, case MCSymbolRefExpr::VK_ARM_PREL31: return ELF::R_ARM_PREL31; } + case FK_PCRel_4: + return ELF::R_ARM_REL32; case ARM::fixup_arm_blx: case ARM::fixup_arm_uncondbl: switch (Modifier) { diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp index 1d80af590d16e0..ad1bcad4adfdff 100644 --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp +++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp @@ -83,6 +83,7 @@ class ARMTargetAsmStreamer : public ARMTargetStreamer { void emitPad(int64_t Offset) override; void emitRegSave(const SmallVectorImpl &RegList, bool isVector) override; + void emitLsda(const MCSymbol* Symbol) override; void emitUnwindRaw(int64_t Offset, const SmallVectorImpl &Opcodes) override; @@ -380,6 +381,8 @@ void ARMTargetAsmStreamer::emitARMWinCFICustom(unsigned Opcode) { OS << "\n"; } +void ARMTargetAsmStreamer::emitLsda(const MCSymbol* Symbol) {} + class ARMTargetELFStreamer : public ARMTargetStreamer { private: StringRef CurrentVendor; @@ -405,6 +408,7 @@ class ARMTargetELFStreamer : public ARMTargetStreamer { void emitPad(int64_t Offset) override; void emitRegSave(const SmallVectorImpl &RegList, bool isVector) override; + void emitLsda(const MCSymbol *Symbol) override; void emitUnwindRaw(int64_t Offset, const SmallVectorImpl &Opcodes) override; @@ -472,6 +476,7 @@ class ARMELFStreamer : public MCELFStreamer { void emitMovSP(unsigned Reg, int64_t Offset = 0); void emitPad(int64_t Offset); void emitRegSave(const SmallVectorImpl &RegList, bool isVector); + void emitLsda(const MCSymbol* Symbol); void emitUnwindRaw(int64_t Offset, const SmallVectorImpl &Opcodes); void emitFill(const MCExpr &NumBytes, uint64_t FillValue, SMLoc Loc) override { @@ -551,6 +556,18 @@ class ARMELFStreamer : public MCELFStreamer { MCELFStreamer::emitBytes(Data); } + /// This function is the one used to emit instruction data into the ELF + /// streamer. We override it to add the appropriate mapping symbol if + /// necessary. + void emitInstructionBytes(StringRef Data) override { + if (IsThumb) + EmitThumbMappingSymbol(); + else + EmitARMMappingSymbol(); + + MCELFStreamer::emitBytes(Data); + } + void FlushPendingMappingSymbol() { if (!LastEMSInfo->hasInfo()) return; @@ -736,6 +753,7 @@ class ARMELFStreamer : public MCELFStreamer { bool CantUnwind; SmallVector Opcodes; UnwindOpcodeAssembler UnwindOpAsm; + const MCSymbol *Lsda; }; } // end anonymous namespace @@ -778,6 +796,10 @@ void ARMTargetELFStreamer::emitRegSave(const SmallVectorImpl &RegList, getStreamer().emitRegSave(RegList, isVector); } +void ARMTargetELFStreamer::emitLsda(const MCSymbol *Symbol) { + getStreamer().emitLsda(Symbol); +} + void ARMTargetELFStreamer::emitUnwindRaw(int64_t Offset, const SmallVectorImpl &Opcodes) { getStreamer().emitUnwindRaw(Offset, Opcodes); @@ -1199,6 +1221,7 @@ void ARMELFStreamer::EHReset() { PendingOffset = 0; UsedFP = false; CantUnwind = false; + Lsda = nullptr; Opcodes.clear(); UnwindOpAsm.Reset(); @@ -1301,6 +1324,8 @@ void ARMELFStreamer::FlushUnwindOpcodes(bool NoHandlerData) { } // Finalize the unwind opcode sequence + if (Lsda != nullptr && Opcodes.size() <= 4u) + PersonalityIndex = ARM::EHABI::AEABI_UNWIND_CPP_PR1; UnwindOpAsm.Finalize(PersonalityIndex, Opcodes); // For compact model 0, we have to emit the unwind opcodes in the .ARM.exidx @@ -1345,7 +1370,13 @@ void ARMELFStreamer::FlushUnwindOpcodes(bool NoHandlerData) { // // In case that the .handlerdata directive is not specified by the // programmer, we should emit zero to terminate the handler data. - if (NoHandlerData && !Personality) + if (Lsda != nullptr) { + const MCSymbolRefExpr *LsdaRef = + MCSymbolRefExpr::create(Lsda, + MCSymbolRefExpr::VK_None, + getContext()); + emitValue(LsdaRef, 4); + } else if (NoHandlerData && !Personality) emitInt32(0); } @@ -1459,6 +1490,10 @@ void ARMELFStreamer::emitRegSave(const SmallVectorImpl &RegList, } } +void ARMELFStreamer::emitLsda(const MCSymbol *Symbol) { + Lsda = Symbol; +} + void ARMELFStreamer::emitUnwindRaw(int64_t Offset, const SmallVectorImpl &Opcodes) { FlushPendingOffset(); diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp index 1237e50c22fdce..a869934fdb07a0 100644 --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp +++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp @@ -98,6 +98,7 @@ void ARMTargetStreamer::emitMovSP(unsigned Reg, int64_t Offset) {} void ARMTargetStreamer::emitPad(int64_t Offset) {} void ARMTargetStreamer::emitRegSave(const SmallVectorImpl &RegList, bool isVector) {} +void ARMTargetStreamer::emitLsda(const MCSymbol *Symbol) {} void ARMTargetStreamer::emitUnwindRaw(int64_t StackOffset, const SmallVectorImpl &Opcodes) { } diff --git a/llvm/tools/llvm-config/llvm-config.cpp b/llvm/tools/llvm-config/llvm-config.cpp index d5b76b1bb6c16c..f23b4a8d5c3423 100644 --- a/llvm/tools/llvm-config/llvm-config.cpp +++ b/llvm/tools/llvm-config/llvm-config.cpp @@ -510,7 +510,9 @@ int main(int argc, char **argv) { if (Arg.starts_with("-")) { HasAnyOption = true; if (Arg == "--version") { - OS << PACKAGE_VERSION << '\n'; + OS << PACKAGE_VERSION << "-mono" << '\n'; + } else if (Arg == "--mono-api-version") { + OS << MONO_API_VERSION << '\n'; } else if (Arg == "--prefix") { OS << ActivePrefix << '\n'; } else if (Arg == "--bindir") { diff --git a/llvm/tools/objwriter/CMakeLists.txt b/llvm/tools/objwriter/CMakeLists.txt new file mode 100644 index 00000000000000..fb7a841397217c --- /dev/null +++ b/llvm/tools/objwriter/CMakeLists.txt @@ -0,0 +1,29 @@ +set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/objwriter.exports) + +set(LLVM_LINK_COMPONENTS + AllTargetsDescs + AllTargetsInfos + MC + Support + ) + +if (MSVC AND (LLVM_USE_CRT_RELEASE STREQUAL "MT")) + # Force uCRT to be dynamically linked for Release build + set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib") +endif() + +message(STATUS "ObjWriter configuring with (${CMAKE_BUILD_TYPE}) build type and (${LLVM_DEFAULT_TARGET_TRIPLE}) default target triple") + +add_llvm_library(objwriter SHARED + objwriter.cpp + debugInfo/codeView/codeViewTypeBuilder.cpp + debugInfo/codeView/codeViewTypeBuilder.h + debugInfo/dwarf/dwarfTypeBuilder.cpp + debugInfo/dwarf/dwarfTypeBuilder.h + debugInfo/dwarf/dwarfGen.cpp + debugInfo/dwarf/dwarfGen.h + debugInfo/dwarf/dwarfAbbrev.cpp + debugInfo/dwarf/dwarfAbbrev.h + debugInfo/typeBuilder.h + objwriter.h # Visual Studio generator doesn't include necessary header files into the project automatically +) diff --git a/llvm/tools/objwriter/README.md b/llvm/tools/objwriter/README.md new file mode 100644 index 00000000000000..5a508e9db10f8c --- /dev/null +++ b/llvm/tools/objwriter/README.md @@ -0,0 +1,5 @@ +# Native Object Writer library + +This library exposes C APIs to emit ELF/Mach-O/PE object files. + +The implementation is based on LLVM's assembler APIs - these are APIs intended to be consumed by assembly language compilers and are therefore close to the underlying object file formats. When in doubt, look at how the assemblers (e.g. llvm-ml in the tools directory of LLVM) use these APIs. diff --git a/llvm/tools/objwriter/cfi.h b/llvm/tools/objwriter/cfi.h new file mode 100644 index 00000000000000..56d49c56c21f4d --- /dev/null +++ b/llvm/tools/objwriter/cfi.h @@ -0,0 +1,33 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#ifndef CFI_H_ +#define CFI_H_ + +#define DWARF_REG_ILLEGAL -1 +enum CFI_OPCODE +{ + CFI_ADJUST_CFA_OFFSET, // Offset is adjusted relative to the current one. + CFI_DEF_CFA_REGISTER, // New register is used to compute CFA + CFI_REL_OFFSET, // Register is saved at offset from the current CFA + CFI_DEF_CFA, // Take address from register and add offset to it +}; + +struct CFI_CODE +{ + unsigned char CodeOffset;// Offset from the start of code the frame covers. + unsigned char CfiOpCode; + short DwarfReg; // Dwarf register number. 0~32 for x64. + int Offset; + CFI_CODE(unsigned char codeOffset, unsigned char cfiOpcode, + short dwarfReg, int offset) + : CodeOffset(codeOffset) + , CfiOpCode(cfiOpcode) + , DwarfReg(dwarfReg) + , Offset(offset) + {} +}; +typedef CFI_CODE* PCFI_CODE; + +#endif // CFI_H + diff --git a/llvm/tools/objwriter/cordebuginfo.h b/llvm/tools/objwriter/cordebuginfo.h new file mode 100644 index 00000000000000..5ccecbcb36bf4c --- /dev/null +++ b/llvm/tools/objwriter/cordebuginfo.h @@ -0,0 +1,336 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +// +// Keep in sync with https://github.com/dotnet/runtime/blob/main/src/coreclr/inc/cordebuginfo.h +// + +/**********************************************************************************/ +// DebugInfo types shared by JIT-EE interface and EE-Debugger interface + +class ICorDebugInfo +{ +public: + /*----------------------------- Boundary-info ---------------------------*/ + + enum MappingTypes + { + NO_MAPPING = -1, + PROLOG = -2, + EPILOG = -3, + MAX_MAPPING_VALUE = -3 // Sentinal value. This should be set to the largest magnitude value in the enum + // so that the compression routines know the enum's range. + }; + + enum BoundaryTypes + { + NO_BOUNDARIES = 0x00, // No implicit boundaries + STACK_EMPTY_BOUNDARIES = 0x01, // Boundary whenever the IL evaluation stack is empty + NOP_BOUNDARIES = 0x02, // Before every CEE_NOP instruction + CALL_SITE_BOUNDARIES = 0x04, // Before every CEE_CALL, CEE_CALLVIRT, etc instruction + + // Set of boundaries that debugger should always reasonably ask the JIT for. + DEFAULT_BOUNDARIES = STACK_EMPTY_BOUNDARIES | NOP_BOUNDARIES | CALL_SITE_BOUNDARIES + }; + + // Note that SourceTypes can be OR'd together - it's possible that + // a sequence point will also be a stack_empty point, and/or a call site. + // The debugger will check to see if a boundary offset's source field & + // SEQUENCE_POINT is true to determine if the boundary is a sequence point. + + enum SourceTypes + { + SOURCE_TYPE_INVALID = 0x00, // To indicate that nothing else applies + SEQUENCE_POINT = 0x01, // The debugger asked for it. + STACK_EMPTY = 0x02, // The stack is empty here + CALL_SITE = 0x04, // This is a call site. + NATIVE_END_OFFSET_UNKNOWN = 0x08, // Indicates a epilog endpoint + CALL_INSTRUCTION = 0x10 // The actual instruction of a call. + + }; + + struct OffsetMapping + { + uint32_t nativeOffset; + uint32_t ilOffset; // IL offset or one of the special values in MappingTypes + SourceTypes source; // The debugger needs this so that + // we don't put Edit and Continue breakpoints where + // the stack isn't empty. We can put regular breakpoints + // there, though, so we need a way to discriminate + // between offsets. + }; + + /*------------------------------ Var-info -------------------------------*/ + + // Note: The debugger needs to target register numbers on platforms other than which the debugger itself + // is running. To this end it maintains its own values for REGNUM_SP and REGNUM_AMBIENT_SP across multiple + // platforms. So any change here that may effect these values should be reflected in the definitions + // contained in debug/inc/DbgIPCEvents.h. + enum RegNum + { +#ifdef TARGET_X86 + REGNUM_EAX, + REGNUM_ECX, + REGNUM_EDX, + REGNUM_EBX, + REGNUM_ESP, + REGNUM_EBP, + REGNUM_ESI, + REGNUM_EDI, +#elif TARGET_ARM + REGNUM_R0, + REGNUM_R1, + REGNUM_R2, + REGNUM_R3, + REGNUM_R4, + REGNUM_R5, + REGNUM_R6, + REGNUM_R7, + REGNUM_R8, + REGNUM_R9, + REGNUM_R10, + REGNUM_R11, + REGNUM_R12, + REGNUM_SP, + REGNUM_LR, + REGNUM_PC, +#elif TARGET_ARM64 + REGNUM_X0, + REGNUM_X1, + REGNUM_X2, + REGNUM_X3, + REGNUM_X4, + REGNUM_X5, + REGNUM_X6, + REGNUM_X7, + REGNUM_X8, + REGNUM_X9, + REGNUM_X10, + REGNUM_X11, + REGNUM_X12, + REGNUM_X13, + REGNUM_X14, + REGNUM_X15, + REGNUM_X16, + REGNUM_X17, + REGNUM_X18, + REGNUM_X19, + REGNUM_X20, + REGNUM_X21, + REGNUM_X22, + REGNUM_X23, + REGNUM_X24, + REGNUM_X25, + REGNUM_X26, + REGNUM_X27, + REGNUM_X28, + REGNUM_FP, + REGNUM_LR, + REGNUM_SP, + REGNUM_PC, +#elif TARGET_AMD64 + REGNUM_RAX, + REGNUM_RCX, + REGNUM_RDX, + REGNUM_RBX, + REGNUM_RSP, + REGNUM_RBP, + REGNUM_RSI, + REGNUM_RDI, + REGNUM_R8, + REGNUM_R9, + REGNUM_R10, + REGNUM_R11, + REGNUM_R12, + REGNUM_R13, + REGNUM_R14, + REGNUM_R15, +#else + PORTABILITY_WARNING("Register numbers not defined on this platform") +#endif + REGNUM_COUNT, + REGNUM_AMBIENT_SP, // ambient SP support. Ambient SP is the original SP in the non-BP based frame. + // Ambient SP should not change even if there are push/pop operations in the method. + +#ifdef TARGET_X86 + REGNUM_FP = REGNUM_EBP, + REGNUM_SP = REGNUM_ESP, +#elif TARGET_AMD64 + REGNUM_SP = REGNUM_RSP, +#elif TARGET_ARM +#ifdef REDHAWK + REGNUM_FP = REGNUM_R7, +#else + REGNUM_FP = REGNUM_R11, +#endif //REDHAWK +#elif TARGET_ARM64 + //Nothing to do here. FP is already alloted. +#else + // RegNum values should be properly defined for this platform + REGNUM_FP = 0, + REGNUM_SP = 1, +#endif + + }; + + // VarLoc describes the location of a native variable. Note that currently, VLT_REG_BYREF and VLT_STK_BYREF + // are only used for value types on X64. + + enum VarLocType + { + VLT_REG, // variable is in a register + VLT_REG_BYREF, // address of the variable is in a register + VLT_REG_FP, // variable is in an fp register + VLT_STK, // variable is on the stack (memory addressed relative to the frame-pointer) + VLT_STK_BYREF, // address of the variable is on the stack (memory addressed relative to the frame-pointer) + VLT_REG_REG, // variable lives in two registers + VLT_REG_STK, // variable lives partly in a register and partly on the stack + VLT_STK_REG, // reverse of VLT_REG_STK + VLT_STK2, // variable lives in two slots on the stack + VLT_FPSTK, // variable lives on the floating-point stack + VLT_FIXED_VA, // variable is a fixed argument in a varargs function (relative to VARARGS_HANDLE) + + VLT_COUNT, + VLT_INVALID, + }; + + // VLT_REG/VLT_REG_FP -- Any pointer-sized enregistered value (TYP_INT, TYP_REF, etc) + // eg. EAX + // VLT_REG_BYREF -- the specified register contains the address of the variable + // eg. [EAX] + + struct vlReg + { + RegNum vlrReg; + }; + + // VLT_STK -- Any 32 bit value which is on the stack + // eg. [ESP+0x20], or [EBP-0x28] + // VLT_STK_BYREF -- the specified stack location contains the address of the variable + // eg. mov EAX, [ESP+0x20]; [EAX] + + struct vlStk + { + RegNum vlsBaseReg; + signed vlsOffset; + }; + + // VLT_REG_REG -- TYP_LONG with both uint32_ts enregistred + // eg. RBM_EAXEDX + + struct vlRegReg + { + RegNum vlrrReg1; + RegNum vlrrReg2; + }; + + // VLT_REG_STK -- Partly enregistered TYP_LONG + // eg { LowerDWord=EAX UpperDWord=[ESP+0x8] } + + struct vlRegStk + { + RegNum vlrsReg; + struct + { + RegNum vlrssBaseReg; + signed vlrssOffset; + } vlrsStk; + }; + + // VLT_STK_REG -- Partly enregistered TYP_LONG + // eg { LowerDWord=[ESP+0x8] UpperDWord=EAX } + + struct vlStkReg + { + struct + { + RegNum vlsrsBaseReg; + signed vlsrsOffset; + } vlsrStk; + RegNum vlsrReg; + }; + + // VLT_STK2 -- Any 64 bit value which is on the stack, + // in 2 successive DWords. + // eg 2 DWords at [ESP+0x10] + + struct vlStk2 + { + RegNum vls2BaseReg; + signed vls2Offset; + }; + + // VLT_FPSTK -- enregisterd TYP_DOUBLE (on the FP stack) + // eg. ST(3). Actually it is ST("FPstkHeigth - vpFpStk") + + struct vlFPstk + { + unsigned vlfReg; + }; + + // VLT_FIXED_VA -- fixed argument of a varargs function. + // The argument location depends on the size of the variable + // arguments (...). Inspecting the VARARGS_HANDLE indicates the + // location of the first arg. This argument can then be accessed + // relative to the position of the first arg + + struct vlFixedVarArg + { + unsigned vlfvOffset; + }; + + // VLT_MEMORY + + struct vlMemory + { + void *rpValue; // pointer to the in-process + // location of the value. + }; + + struct VarLoc + { + VarLocType vlType; + + union + { + ICorDebugInfo::vlReg vlReg; + ICorDebugInfo::vlStk vlStk; + ICorDebugInfo::vlRegReg vlRegReg; + ICorDebugInfo::vlRegStk vlRegStk; + ICorDebugInfo::vlStkReg vlStkReg; + ICorDebugInfo::vlStk2 vlStk2; + ICorDebugInfo::vlFPstk vlFPstk; + ICorDebugInfo::vlFixedVarArg vlFixedVarArg; + ICorDebugInfo::vlMemory vlMemory; + }; + }; + + // This is used to report implicit/hidden arguments + + enum + { + VARARGS_HND_ILNUM = -1, // Value for the CORINFO_VARARGS_HANDLE varNumber + RETBUF_ILNUM = -2, // Pointer to the return-buffer + TYPECTXT_ILNUM = -3, // ParamTypeArg for CORINFO_GENERICS_CTXT_FROM_PARAMTYPEARG + + UNKNOWN_ILNUM = -4, // Unknown variable + + MAX_ILNUM = -4 // Sentinal value. This should be set to the largest magnitude value in th enum + // so that the compression routines know the enum's range. + }; + + struct ILVarInfo + { + uint32_t startOffset; + uint32_t endOffset; + uint32_t varNumber; + }; + + struct NativeVarInfo + { + uint32_t startOffset; + uint32_t endOffset; + uint32_t varNumber; + VarLoc loc; + }; +}; diff --git a/llvm/tools/objwriter/cvconst.h b/llvm/tools/objwriter/cvconst.h new file mode 100644 index 00000000000000..3fbbfdd011a2cb --- /dev/null +++ b/llvm/tools/objwriter/cvconst.h @@ -0,0 +1,3729 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +// cvconst.h - codeview constant definitions +//----------------------------------------------------------------- +// +// Copyright Microsoft Corporation. All Rights Reserved. +// +//--------------------------------------------------------------- +#ifndef _CVCONST_H_ +#define _CVCONST_H_ + + + +// Enumeration for function call type + + +typedef enum CV_call_e { + CV_CALL_NEAR_C = 0x00, // near right to left push, caller pops stack + CV_CALL_FAR_C = 0x01, // far right to left push, caller pops stack + CV_CALL_NEAR_PASCAL = 0x02, // near left to right push, callee pops stack + CV_CALL_FAR_PASCAL = 0x03, // far left to right push, callee pops stack + CV_CALL_NEAR_FAST = 0x04, // near left to right push with regs, callee pops stack + CV_CALL_FAR_FAST = 0x05, // far left to right push with regs, callee pops stack + CV_CALL_SKIPPED = 0x06, // skipped (unused) call index + CV_CALL_NEAR_STD = 0x07, // near standard call + CV_CALL_FAR_STD = 0x08, // far standard call + CV_CALL_NEAR_SYS = 0x09, // near sys call + CV_CALL_FAR_SYS = 0x0a, // far sys call + CV_CALL_THISCALL = 0x0b, // this call (this passed in register) + CV_CALL_MIPSCALL = 0x0c, // Mips call + CV_CALL_GENERIC = 0x0d, // Generic call sequence + CV_CALL_ALPHACALL = 0x0e, // Alpha call + CV_CALL_PPCCALL = 0x0f, // PPC call + CV_CALL_SHCALL = 0x10, // Hitachi SuperH call + CV_CALL_ARMCALL = 0x11, // ARM call + CV_CALL_AM33CALL = 0x12, // AM33 call + CV_CALL_TRICALL = 0x13, // TriCore Call + CV_CALL_SH5CALL = 0x14, // Hitachi SuperH-5 call + CV_CALL_M32RCALL = 0x15, // M32R Call + CV_CALL_CLRCALL = 0x16, // clr call + CV_CALL_INLINE = 0x17, // Marker for routines always inlined and thus lacking a convention + CV_CALL_NEAR_VECTOR = 0x18, // near left to right push with regs, callee pops stack + CV_CALL_RESERVED = 0x19 // first unused call enumeration + + // Do NOT add any more machine specific conventions. This is to be used for + // calling conventions in the source only (e.g. __cdecl, __stdcall). +} CV_call_e; + + +// Values for the access protection of class attributes + + +typedef enum CV_access_e { + CV_private = 1, + CV_protected = 2, + CV_public = 3 +} CV_access_e; + +typedef enum THUNK_ORDINAL { + THUNK_ORDINAL_NOTYPE, // standard thunk + THUNK_ORDINAL_ADJUSTOR, // "this" adjustor thunk + THUNK_ORDINAL_VCALL, // virtual call thunk + THUNK_ORDINAL_PCODE, // pcode thunk + THUNK_ORDINAL_LOAD, // thunk which loads the address to jump to + // via unknown means... + + // trampoline thunk ordinals - only for use in Trampoline thunk symbols + THUNK_ORDINAL_TRAMP_INCREMENTAL, + THUNK_ORDINAL_TRAMP_BRANCHISLAND, + +} THUNK_ORDINAL; + + +enum CV_SourceChksum_t { + CHKSUM_TYPE_NONE = 0, // indicates no checksum is available + CHKSUM_TYPE_MD5, + CHKSUM_TYPE_SHA1, + CHKSUM_TYPE_SHA_256, +}; + +// +// DIA enums +// + +enum SymTagEnum +{ + SymTagNull, + SymTagExe, + SymTagCompiland, + SymTagCompilandDetails, + SymTagCompilandEnv, + SymTagFunction, + SymTagBlock, + SymTagData, + SymTagAnnotation, + SymTagLabel, + SymTagPublicSymbol, + SymTagUDT, + SymTagEnum, + SymTagFunctionType, + SymTagPointerType, + SymTagArrayType, + SymTagBaseType, + SymTagTypedef, + SymTagBaseClass, + SymTagFriend, + SymTagFunctionArgType, + SymTagFuncDebugStart, + SymTagFuncDebugEnd, + SymTagUsingNamespace, + SymTagVTableShape, + SymTagVTable, + SymTagCustom, + SymTagThunk, + SymTagCustomType, + SymTagManagedType, + SymTagDimension, + SymTagCallSite, + SymTagInlineSite, + SymTagBaseInterface, + SymTagVectorType, + SymTagMatrixType, + SymTagHLSLType, + SymTagCaller, + SymTagCallee, + SymTagExport, + SymTagHeapAllocationSite, + SymTagCoffGroup, + SymTagMax +}; + +enum LocationType +{ + LocIsNull, + LocIsStatic, + LocIsTLS, + LocIsRegRel, + LocIsThisRel, + LocIsEnregistered, + LocIsBitField, + LocIsSlot, + LocIsIlRel, + LocInMetaData, + LocIsConstant, + LocTypeMax +}; + +enum DataKind +{ + DataIsUnknown, + DataIsLocal, + DataIsStaticLocal, + DataIsParam, + DataIsObjectPtr, + DataIsFileStatic, + DataIsGlobal, + DataIsMember, + DataIsStaticMember, + DataIsConstant +}; + +enum UdtKind +{ + UdtStruct, + UdtClass, + UdtUnion, + UdtInterface +}; + +enum BasicType +{ + btNoType = 0, + btVoid = 1, + btChar = 2, + btWChar = 3, + btInt = 6, + btUInt = 7, + btFloat = 8, + btBCD = 9, + btBool = 10, + btLong = 13, + btULong = 14, + btCurrency = 25, + btDate = 26, + btVariant = 27, + btComplex = 28, + btBit = 29, + btBSTR = 30, + btHresult = 31, + btChar16 = 32, // char16_t + btChar32 = 33, // char32_t +}; + + +// enumeration for type modifier values + +typedef enum CV_modifier_e { + // 0x0000 - 0x01ff - Reserved. + + CV_MOD_INVALID = 0x0000, + + // Standard modifiers. + + CV_MOD_CONST = 0x0001, + CV_MOD_VOLATILE = 0x0002, + CV_MOD_UNALIGNED = 0x0003, + + // 0x0200 - 0x03ff - HLSL modifiers. + + CV_MOD_HLSL_UNIFORM = 0x0200, + CV_MOD_HLSL_LINE = 0x0201, + CV_MOD_HLSL_TRIANGLE = 0x0202, + CV_MOD_HLSL_LINEADJ = 0x0203, + CV_MOD_HLSL_TRIANGLEADJ = 0x0204, + CV_MOD_HLSL_LINEAR = 0x0205, + CV_MOD_HLSL_CENTROID = 0x0206, + CV_MOD_HLSL_CONSTINTERP = 0x0207, + CV_MOD_HLSL_NOPERSPECTIVE = 0x0208, + CV_MOD_HLSL_SAMPLE = 0x0209, + CV_MOD_HLSL_CENTER = 0x020a, + CV_MOD_HLSL_SNORM = 0x020b, + CV_MOD_HLSL_UNORM = 0x020c, + CV_MOD_HLSL_PRECISE = 0x020d, + CV_MOD_HLSL_UAV_GLOBALLY_COHERENT = 0x020e, + + // 0x0400 - 0xffff - Unused. + +} CV_modifier_e; + + +// built-in type kinds + + +typedef enum CV_builtin_e { + + // 0x0000 - 0x01ff - Reserved. + CV_BI_INVALID = 0x0000, + + // 0x0200 - 0x03ff - HLSL types. + + CV_BI_HLSL_INTERFACE_POINTER = 0x0200, + CV_BI_HLSL_TEXTURE1D = 0x0201, + CV_BI_HLSL_TEXTURE1D_ARRAY = 0x0202, + CV_BI_HLSL_TEXTURE2D = 0x0203, + CV_BI_HLSL_TEXTURE2D_ARRAY = 0x0204, + CV_BI_HLSL_TEXTURE3D = 0x0205, + CV_BI_HLSL_TEXTURECUBE = 0x0206, + CV_BI_HLSL_TEXTURECUBE_ARRAY = 0x0207, + CV_BI_HLSL_TEXTURE2DMS = 0x0208, + CV_BI_HLSL_TEXTURE2DMS_ARRAY = 0x0209, + CV_BI_HLSL_SAMPLER = 0x020a, + CV_BI_HLSL_SAMPLERCOMPARISON = 0x020b, + CV_BI_HLSL_BUFFER = 0x020c, + CV_BI_HLSL_POINTSTREAM = 0x020d, + CV_BI_HLSL_LINESTREAM = 0x020e, + CV_BI_HLSL_TRIANGLESTREAM = 0x020f, + CV_BI_HLSL_INPUTPATCH = 0x0210, + CV_BI_HLSL_OUTPUTPATCH = 0x0211, + CV_BI_HLSL_RWTEXTURE1D = 0x0212, + CV_BI_HLSL_RWTEXTURE1D_ARRAY = 0x0213, + CV_BI_HLSL_RWTEXTURE2D = 0x0214, + CV_BI_HLSL_RWTEXTURE2D_ARRAY = 0x0215, + CV_BI_HLSL_RWTEXTURE3D = 0x0216, + CV_BI_HLSL_RWBUFFER = 0x0217, + CV_BI_HLSL_BYTEADDRESS_BUFFER = 0x0218, + CV_BI_HLSL_RWBYTEADDRESS_BUFFER = 0x0219, + CV_BI_HLSL_STRUCTURED_BUFFER = 0x021a, + CV_BI_HLSL_RWSTRUCTURED_BUFFER = 0x021b, + CV_BI_HLSL_APPEND_STRUCTURED_BUFFER = 0x021c, + CV_BI_HLSL_CONSUME_STRUCTURED_BUFFER= 0x021d, + CV_BI_HLSL_MIN8FLOAT = 0x021e, + CV_BI_HLSL_MIN10FLOAT = 0x021f, + CV_BI_HLSL_MIN16FLOAT = 0x0220, + CV_BI_HLSL_MIN12INT = 0x0221, + CV_BI_HLSL_MIN16INT = 0x0222, + CV_BI_HLSL_MIN16UINT = 0x0223, + + // 0x0400 - 0xffff - Unused. + +} CV_builtin_e; + + +// enum describing the compile flag source language + + +typedef enum CV_CFL_LANG { + CV_CFL_C = 0x00, + CV_CFL_CXX = 0x01, + CV_CFL_FORTRAN = 0x02, + CV_CFL_MASM = 0x03, + CV_CFL_PASCAL = 0x04, + CV_CFL_BASIC = 0x05, + CV_CFL_COBOL = 0x06, + CV_CFL_LINK = 0x07, + CV_CFL_CVTRES = 0x08, + CV_CFL_CVTPGD = 0x09, + CV_CFL_CSHARP = 0x0A, // C# + CV_CFL_VB = 0x0B, // Visual Basic + CV_CFL_ILASM = 0x0C, // IL (as in CLR) ASM + CV_CFL_JAVA = 0x0D, + CV_CFL_JSCRIPT = 0x0E, + CV_CFL_MSIL = 0x0F, // Unknown MSIL (LTCG of .NETMODULE) + CV_CFL_HLSL = 0x10, // High Level Shader Language +} CV_CFL_LANG; + + +// enum describing target processor + + +typedef enum CV_CPU_TYPE_e { + CV_CFL_8080 = 0x00, + CV_CFL_8086 = 0x01, + CV_CFL_80286 = 0x02, + CV_CFL_80386 = 0x03, + CV_CFL_80486 = 0x04, + CV_CFL_PENTIUM = 0x05, + CV_CFL_PENTIUMII = 0x06, + CV_CFL_PENTIUMPRO = CV_CFL_PENTIUMII, + CV_CFL_PENTIUMIII = 0x07, + CV_CFL_MIPS = 0x10, + CV_CFL_MIPSR4000 = CV_CFL_MIPS, // don't break current code + CV_CFL_MIPS16 = 0x11, + CV_CFL_MIPS32 = 0x12, + CV_CFL_MIPS64 = 0x13, + CV_CFL_MIPSI = 0x14, + CV_CFL_MIPSII = 0x15, + CV_CFL_MIPSIII = 0x16, + CV_CFL_MIPSIV = 0x17, + CV_CFL_MIPSV = 0x18, + CV_CFL_M68000 = 0x20, + CV_CFL_M68010 = 0x21, + CV_CFL_M68020 = 0x22, + CV_CFL_M68030 = 0x23, + CV_CFL_M68040 = 0x24, + CV_CFL_ALPHA = 0x30, + CV_CFL_ALPHA_21064 = 0x30, + CV_CFL_ALPHA_21164 = 0x31, + CV_CFL_ALPHA_21164A = 0x32, + CV_CFL_ALPHA_21264 = 0x33, + CV_CFL_ALPHA_21364 = 0x34, + CV_CFL_PPC601 = 0x40, + CV_CFL_PPC603 = 0x41, + CV_CFL_PPC604 = 0x42, + CV_CFL_PPC620 = 0x43, + CV_CFL_PPCFP = 0x44, + CV_CFL_PPCBE = 0x45, + CV_CFL_SH3 = 0x50, + CV_CFL_SH3E = 0x51, + CV_CFL_SH3DSP = 0x52, + CV_CFL_SH4 = 0x53, + CV_CFL_SHMEDIA = 0x54, + CV_CFL_ARM3 = 0x60, + CV_CFL_ARM4 = 0x61, + CV_CFL_ARM4T = 0x62, + CV_CFL_ARM5 = 0x63, + CV_CFL_ARM5T = 0x64, + CV_CFL_ARM6 = 0x65, + CV_CFL_ARM_XMAC = 0x66, + CV_CFL_ARM_WMMX = 0x67, + CV_CFL_ARM7 = 0x68, + CV_CFL_OMNI = 0x70, + CV_CFL_IA64 = 0x80, + CV_CFL_IA64_1 = 0x80, + CV_CFL_IA64_2 = 0x81, + CV_CFL_CEE = 0x90, + CV_CFL_AM33 = 0xA0, + CV_CFL_M32R = 0xB0, + CV_CFL_TRICORE = 0xC0, + CV_CFL_X64 = 0xD0, + CV_CFL_AMD64 = CV_CFL_X64, + CV_CFL_EBC = 0xE0, + CV_CFL_THUMB = 0xF0, + CV_CFL_ARMNT = 0xF4, + CV_CFL_ARM64 = 0xF6, + CV_CFL_D3D11_SHADER = 0x100, +} CV_CPU_TYPE_e; + +typedef enum CV_HREG_e { + // Register subset shared by all processor types, + // must not overlap with any of the ranges below, hence the high values + + CV_ALLREG_ERR = 30000, + CV_ALLREG_TEB = 30001, + CV_ALLREG_TIMER = 30002, + CV_ALLREG_EFAD1 = 30003, + CV_ALLREG_EFAD2 = 30004, + CV_ALLREG_EFAD3 = 30005, + CV_ALLREG_VFRAME= 30006, + CV_ALLREG_HANDLE= 30007, + CV_ALLREG_PARAMS= 30008, + CV_ALLREG_LOCALS= 30009, + CV_ALLREG_TID = 30010, + CV_ALLREG_ENV = 30011, + CV_ALLREG_CMDLN = 30012, + + + // Register set for the Intel 80x86 and ix86 processor series + // (plus PCODE registers) + + CV_REG_NONE = 0, + CV_REG_AL = 1, + CV_REG_CL = 2, + CV_REG_DL = 3, + CV_REG_BL = 4, + CV_REG_AH = 5, + CV_REG_CH = 6, + CV_REG_DH = 7, + CV_REG_BH = 8, + CV_REG_AX = 9, + CV_REG_CX = 10, + CV_REG_DX = 11, + CV_REG_BX = 12, + CV_REG_SP = 13, + CV_REG_BP = 14, + CV_REG_SI = 15, + CV_REG_DI = 16, + CV_REG_EAX = 17, + CV_REG_ECX = 18, + CV_REG_EDX = 19, + CV_REG_EBX = 20, + CV_REG_ESP = 21, + CV_REG_EBP = 22, + CV_REG_ESI = 23, + CV_REG_EDI = 24, + CV_REG_ES = 25, + CV_REG_CS = 26, + CV_REG_SS = 27, + CV_REG_DS = 28, + CV_REG_FS = 29, + CV_REG_GS = 30, + CV_REG_IP = 31, + CV_REG_FLAGS = 32, + CV_REG_EIP = 33, + CV_REG_EFLAGS = 34, + CV_REG_TEMP = 40, // PCODE Temp + CV_REG_TEMPH = 41, // PCODE TempH + CV_REG_QUOTE = 42, // PCODE Quote + CV_REG_PCDR3 = 43, // PCODE reserved + CV_REG_PCDR4 = 44, // PCODE reserved + CV_REG_PCDR5 = 45, // PCODE reserved + CV_REG_PCDR6 = 46, // PCODE reserved + CV_REG_PCDR7 = 47, // PCODE reserved + CV_REG_CR0 = 80, // CR0 -- control registers + CV_REG_CR1 = 81, + CV_REG_CR2 = 82, + CV_REG_CR3 = 83, + CV_REG_CR4 = 84, // Pentium + CV_REG_DR0 = 90, // Debug register + CV_REG_DR1 = 91, + CV_REG_DR2 = 92, + CV_REG_DR3 = 93, + CV_REG_DR4 = 94, + CV_REG_DR5 = 95, + CV_REG_DR6 = 96, + CV_REG_DR7 = 97, + CV_REG_GDTR = 110, + CV_REG_GDTL = 111, + CV_REG_IDTR = 112, + CV_REG_IDTL = 113, + CV_REG_LDTR = 114, + CV_REG_TR = 115, + + CV_REG_PSEUDO1 = 116, + CV_REG_PSEUDO2 = 117, + CV_REG_PSEUDO3 = 118, + CV_REG_PSEUDO4 = 119, + CV_REG_PSEUDO5 = 120, + CV_REG_PSEUDO6 = 121, + CV_REG_PSEUDO7 = 122, + CV_REG_PSEUDO8 = 123, + CV_REG_PSEUDO9 = 124, + + CV_REG_ST0 = 128, + CV_REG_ST1 = 129, + CV_REG_ST2 = 130, + CV_REG_ST3 = 131, + CV_REG_ST4 = 132, + CV_REG_ST5 = 133, + CV_REG_ST6 = 134, + CV_REG_ST7 = 135, + CV_REG_CTRL = 136, + CV_REG_STAT = 137, + CV_REG_TAG = 138, + CV_REG_FPIP = 139, + CV_REG_FPCS = 140, + CV_REG_FPDO = 141, + CV_REG_FPDS = 142, + CV_REG_ISEM = 143, + CV_REG_FPEIP = 144, + CV_REG_FPEDO = 145, + + CV_REG_MM0 = 146, + CV_REG_MM1 = 147, + CV_REG_MM2 = 148, + CV_REG_MM3 = 149, + CV_REG_MM4 = 150, + CV_REG_MM5 = 151, + CV_REG_MM6 = 152, + CV_REG_MM7 = 153, + + CV_REG_XMM0 = 154, // KATMAI registers + CV_REG_XMM1 = 155, + CV_REG_XMM2 = 156, + CV_REG_XMM3 = 157, + CV_REG_XMM4 = 158, + CV_REG_XMM5 = 159, + CV_REG_XMM6 = 160, + CV_REG_XMM7 = 161, + + CV_REG_XMM00 = 162, // KATMAI sub-registers + CV_REG_XMM01 = 163, + CV_REG_XMM02 = 164, + CV_REG_XMM03 = 165, + CV_REG_XMM10 = 166, + CV_REG_XMM11 = 167, + CV_REG_XMM12 = 168, + CV_REG_XMM13 = 169, + CV_REG_XMM20 = 170, + CV_REG_XMM21 = 171, + CV_REG_XMM22 = 172, + CV_REG_XMM23 = 173, + CV_REG_XMM30 = 174, + CV_REG_XMM31 = 175, + CV_REG_XMM32 = 176, + CV_REG_XMM33 = 177, + CV_REG_XMM40 = 178, + CV_REG_XMM41 = 179, + CV_REG_XMM42 = 180, + CV_REG_XMM43 = 181, + CV_REG_XMM50 = 182, + CV_REG_XMM51 = 183, + CV_REG_XMM52 = 184, + CV_REG_XMM53 = 185, + CV_REG_XMM60 = 186, + CV_REG_XMM61 = 187, + CV_REG_XMM62 = 188, + CV_REG_XMM63 = 189, + CV_REG_XMM70 = 190, + CV_REG_XMM71 = 191, + CV_REG_XMM72 = 192, + CV_REG_XMM73 = 193, + + CV_REG_XMM0L = 194, + CV_REG_XMM1L = 195, + CV_REG_XMM2L = 196, + CV_REG_XMM3L = 197, + CV_REG_XMM4L = 198, + CV_REG_XMM5L = 199, + CV_REG_XMM6L = 200, + CV_REG_XMM7L = 201, + + CV_REG_XMM0H = 202, + CV_REG_XMM1H = 203, + CV_REG_XMM2H = 204, + CV_REG_XMM3H = 205, + CV_REG_XMM4H = 206, + CV_REG_XMM5H = 207, + CV_REG_XMM6H = 208, + CV_REG_XMM7H = 209, + + CV_REG_MXCSR = 211, // XMM status register + + CV_REG_EDXEAX = 212, // EDX:EAX pair + + CV_REG_EMM0L = 220, // XMM sub-registers (WNI integer) + CV_REG_EMM1L = 221, + CV_REG_EMM2L = 222, + CV_REG_EMM3L = 223, + CV_REG_EMM4L = 224, + CV_REG_EMM5L = 225, + CV_REG_EMM6L = 226, + CV_REG_EMM7L = 227, + + CV_REG_EMM0H = 228, + CV_REG_EMM1H = 229, + CV_REG_EMM2H = 230, + CV_REG_EMM3H = 231, + CV_REG_EMM4H = 232, + CV_REG_EMM5H = 233, + CV_REG_EMM6H = 234, + CV_REG_EMM7H = 235, + + // do not change the order of these regs, first one must be even too + CV_REG_MM00 = 236, + CV_REG_MM01 = 237, + CV_REG_MM10 = 238, + CV_REG_MM11 = 239, + CV_REG_MM20 = 240, + CV_REG_MM21 = 241, + CV_REG_MM30 = 242, + CV_REG_MM31 = 243, + CV_REG_MM40 = 244, + CV_REG_MM41 = 245, + CV_REG_MM50 = 246, + CV_REG_MM51 = 247, + CV_REG_MM60 = 248, + CV_REG_MM61 = 249, + CV_REG_MM70 = 250, + CV_REG_MM71 = 251, + + CV_REG_YMM0 = 252, // AVX registers + CV_REG_YMM1 = 253, + CV_REG_YMM2 = 254, + CV_REG_YMM3 = 255, + CV_REG_YMM4 = 256, + CV_REG_YMM5 = 257, + CV_REG_YMM6 = 258, + CV_REG_YMM7 = 259, + + CV_REG_YMM0H = 260, + CV_REG_YMM1H = 261, + CV_REG_YMM2H = 262, + CV_REG_YMM3H = 263, + CV_REG_YMM4H = 264, + CV_REG_YMM5H = 265, + CV_REG_YMM6H = 266, + CV_REG_YMM7H = 267, + + CV_REG_YMM0I0 = 268, // AVX integer registers + CV_REG_YMM0I1 = 269, + CV_REG_YMM0I2 = 270, + CV_REG_YMM0I3 = 271, + CV_REG_YMM1I0 = 272, + CV_REG_YMM1I1 = 273, + CV_REG_YMM1I2 = 274, + CV_REG_YMM1I3 = 275, + CV_REG_YMM2I0 = 276, + CV_REG_YMM2I1 = 277, + CV_REG_YMM2I2 = 278, + CV_REG_YMM2I3 = 279, + CV_REG_YMM3I0 = 280, + CV_REG_YMM3I1 = 281, + CV_REG_YMM3I2 = 282, + CV_REG_YMM3I3 = 283, + CV_REG_YMM4I0 = 284, + CV_REG_YMM4I1 = 285, + CV_REG_YMM4I2 = 286, + CV_REG_YMM4I3 = 287, + CV_REG_YMM5I0 = 288, + CV_REG_YMM5I1 = 289, + CV_REG_YMM5I2 = 290, + CV_REG_YMM5I3 = 291, + CV_REG_YMM6I0 = 292, + CV_REG_YMM6I1 = 293, + CV_REG_YMM6I2 = 294, + CV_REG_YMM6I3 = 295, + CV_REG_YMM7I0 = 296, + CV_REG_YMM7I1 = 297, + CV_REG_YMM7I2 = 298, + CV_REG_YMM7I3 = 299, + + CV_REG_YMM0F0 = 300, // AVX floating-point single precise registers + CV_REG_YMM0F1 = 301, + CV_REG_YMM0F2 = 302, + CV_REG_YMM0F3 = 303, + CV_REG_YMM0F4 = 304, + CV_REG_YMM0F5 = 305, + CV_REG_YMM0F6 = 306, + CV_REG_YMM0F7 = 307, + CV_REG_YMM1F0 = 308, + CV_REG_YMM1F1 = 309, + CV_REG_YMM1F2 = 310, + CV_REG_YMM1F3 = 311, + CV_REG_YMM1F4 = 312, + CV_REG_YMM1F5 = 313, + CV_REG_YMM1F6 = 314, + CV_REG_YMM1F7 = 315, + CV_REG_YMM2F0 = 316, + CV_REG_YMM2F1 = 317, + CV_REG_YMM2F2 = 318, + CV_REG_YMM2F3 = 319, + CV_REG_YMM2F4 = 320, + CV_REG_YMM2F5 = 321, + CV_REG_YMM2F6 = 322, + CV_REG_YMM2F7 = 323, + CV_REG_YMM3F0 = 324, + CV_REG_YMM3F1 = 325, + CV_REG_YMM3F2 = 326, + CV_REG_YMM3F3 = 327, + CV_REG_YMM3F4 = 328, + CV_REG_YMM3F5 = 329, + CV_REG_YMM3F6 = 330, + CV_REG_YMM3F7 = 331, + CV_REG_YMM4F0 = 332, + CV_REG_YMM4F1 = 333, + CV_REG_YMM4F2 = 334, + CV_REG_YMM4F3 = 335, + CV_REG_YMM4F4 = 336, + CV_REG_YMM4F5 = 337, + CV_REG_YMM4F6 = 338, + CV_REG_YMM4F7 = 339, + CV_REG_YMM5F0 = 340, + CV_REG_YMM5F1 = 341, + CV_REG_YMM5F2 = 342, + CV_REG_YMM5F3 = 343, + CV_REG_YMM5F4 = 344, + CV_REG_YMM5F5 = 345, + CV_REG_YMM5F6 = 346, + CV_REG_YMM5F7 = 347, + CV_REG_YMM6F0 = 348, + CV_REG_YMM6F1 = 349, + CV_REG_YMM6F2 = 350, + CV_REG_YMM6F3 = 351, + CV_REG_YMM6F4 = 352, + CV_REG_YMM6F5 = 353, + CV_REG_YMM6F6 = 354, + CV_REG_YMM6F7 = 355, + CV_REG_YMM7F0 = 356, + CV_REG_YMM7F1 = 357, + CV_REG_YMM7F2 = 358, + CV_REG_YMM7F3 = 359, + CV_REG_YMM7F4 = 360, + CV_REG_YMM7F5 = 361, + CV_REG_YMM7F6 = 362, + CV_REG_YMM7F7 = 363, + + CV_REG_YMM0D0 = 364, // AVX floating-point double precise registers + CV_REG_YMM0D1 = 365, + CV_REG_YMM0D2 = 366, + CV_REG_YMM0D3 = 367, + CV_REG_YMM1D0 = 368, + CV_REG_YMM1D1 = 369, + CV_REG_YMM1D2 = 370, + CV_REG_YMM1D3 = 371, + CV_REG_YMM2D0 = 372, + CV_REG_YMM2D1 = 373, + CV_REG_YMM2D2 = 374, + CV_REG_YMM2D3 = 375, + CV_REG_YMM3D0 = 376, + CV_REG_YMM3D1 = 377, + CV_REG_YMM3D2 = 378, + CV_REG_YMM3D3 = 379, + CV_REG_YMM4D0 = 380, + CV_REG_YMM4D1 = 381, + CV_REG_YMM4D2 = 382, + CV_REG_YMM4D3 = 383, + CV_REG_YMM5D0 = 384, + CV_REG_YMM5D1 = 385, + CV_REG_YMM5D2 = 386, + CV_REG_YMM5D3 = 387, + CV_REG_YMM6D0 = 388, + CV_REG_YMM6D1 = 389, + CV_REG_YMM6D2 = 390, + CV_REG_YMM6D3 = 391, + CV_REG_YMM7D0 = 392, + CV_REG_YMM7D1 = 393, + CV_REG_YMM7D2 = 394, + CV_REG_YMM7D3 = 395, + + CV_REG_BND0 = 396, + CV_REG_BND1 = 397, + CV_REG_BND2 = 398, + CV_REG_BND3 = 399, + + // registers for the 68K processors + + CV_R68_D0 = 0, + CV_R68_D1 = 1, + CV_R68_D2 = 2, + CV_R68_D3 = 3, + CV_R68_D4 = 4, + CV_R68_D5 = 5, + CV_R68_D6 = 6, + CV_R68_D7 = 7, + CV_R68_A0 = 8, + CV_R68_A1 = 9, + CV_R68_A2 = 10, + CV_R68_A3 = 11, + CV_R68_A4 = 12, + CV_R68_A5 = 13, + CV_R68_A6 = 14, + CV_R68_A7 = 15, + CV_R68_CCR = 16, + CV_R68_SR = 17, + CV_R68_USP = 18, + CV_R68_MSP = 19, + CV_R68_SFC = 20, + CV_R68_DFC = 21, + CV_R68_CACR = 22, + CV_R68_VBR = 23, + CV_R68_CAAR = 24, + CV_R68_ISP = 25, + CV_R68_PC = 26, + //reserved 27 + CV_R68_FPCR = 28, + CV_R68_FPSR = 29, + CV_R68_FPIAR = 30, + //reserved 31 + CV_R68_FP0 = 32, + CV_R68_FP1 = 33, + CV_R68_FP2 = 34, + CV_R68_FP3 = 35, + CV_R68_FP4 = 36, + CV_R68_FP5 = 37, + CV_R68_FP6 = 38, + CV_R68_FP7 = 39, + //reserved 40 + CV_R68_MMUSR030 = 41, + CV_R68_MMUSR = 42, + CV_R68_URP = 43, + CV_R68_DTT0 = 44, + CV_R68_DTT1 = 45, + CV_R68_ITT0 = 46, + CV_R68_ITT1 = 47, + //reserved 50 + CV_R68_PSR = 51, + CV_R68_PCSR = 52, + CV_R68_VAL = 53, + CV_R68_CRP = 54, + CV_R68_SRP = 55, + CV_R68_DRP = 56, + CV_R68_TC = 57, + CV_R68_AC = 58, + CV_R68_SCC = 59, + CV_R68_CAL = 60, + CV_R68_TT0 = 61, + CV_R68_TT1 = 62, + //reserved 63 + CV_R68_BAD0 = 64, + CV_R68_BAD1 = 65, + CV_R68_BAD2 = 66, + CV_R68_BAD3 = 67, + CV_R68_BAD4 = 68, + CV_R68_BAD5 = 69, + CV_R68_BAD6 = 70, + CV_R68_BAD7 = 71, + CV_R68_BAC0 = 72, + CV_R68_BAC1 = 73, + CV_R68_BAC2 = 74, + CV_R68_BAC3 = 75, + CV_R68_BAC4 = 76, + CV_R68_BAC5 = 77, + CV_R68_BAC6 = 78, + CV_R68_BAC7 = 79, + + // Register set for the MIPS 4000 + + CV_M4_NOREG = CV_REG_NONE, + + CV_M4_IntZERO = 10, /* CPU REGISTER */ + CV_M4_IntAT = 11, + CV_M4_IntV0 = 12, + CV_M4_IntV1 = 13, + CV_M4_IntA0 = 14, + CV_M4_IntA1 = 15, + CV_M4_IntA2 = 16, + CV_M4_IntA3 = 17, + CV_M4_IntT0 = 18, + CV_M4_IntT1 = 19, + CV_M4_IntT2 = 20, + CV_M4_IntT3 = 21, + CV_M4_IntT4 = 22, + CV_M4_IntT5 = 23, + CV_M4_IntT6 = 24, + CV_M4_IntT7 = 25, + CV_M4_IntS0 = 26, + CV_M4_IntS1 = 27, + CV_M4_IntS2 = 28, + CV_M4_IntS3 = 29, + CV_M4_IntS4 = 30, + CV_M4_IntS5 = 31, + CV_M4_IntS6 = 32, + CV_M4_IntS7 = 33, + CV_M4_IntT8 = 34, + CV_M4_IntT9 = 35, + CV_M4_IntKT0 = 36, + CV_M4_IntKT1 = 37, + CV_M4_IntGP = 38, + CV_M4_IntSP = 39, + CV_M4_IntS8 = 40, + CV_M4_IntRA = 41, + CV_M4_IntLO = 42, + CV_M4_IntHI = 43, + + CV_M4_Fir = 50, + CV_M4_Psr = 51, + + CV_M4_FltF0 = 60, /* Floating point registers */ + CV_M4_FltF1 = 61, + CV_M4_FltF2 = 62, + CV_M4_FltF3 = 63, + CV_M4_FltF4 = 64, + CV_M4_FltF5 = 65, + CV_M4_FltF6 = 66, + CV_M4_FltF7 = 67, + CV_M4_FltF8 = 68, + CV_M4_FltF9 = 69, + CV_M4_FltF10 = 70, + CV_M4_FltF11 = 71, + CV_M4_FltF12 = 72, + CV_M4_FltF13 = 73, + CV_M4_FltF14 = 74, + CV_M4_FltF15 = 75, + CV_M4_FltF16 = 76, + CV_M4_FltF17 = 77, + CV_M4_FltF18 = 78, + CV_M4_FltF19 = 79, + CV_M4_FltF20 = 80, + CV_M4_FltF21 = 81, + CV_M4_FltF22 = 82, + CV_M4_FltF23 = 83, + CV_M4_FltF24 = 84, + CV_M4_FltF25 = 85, + CV_M4_FltF26 = 86, + CV_M4_FltF27 = 87, + CV_M4_FltF28 = 88, + CV_M4_FltF29 = 89, + CV_M4_FltF30 = 90, + CV_M4_FltF31 = 91, + CV_M4_FltFsr = 92, + + + // Register set for the ALPHA AXP + + CV_ALPHA_NOREG = CV_REG_NONE, + + CV_ALPHA_FltF0 = 10, // Floating point registers + CV_ALPHA_FltF1 = 11, + CV_ALPHA_FltF2 = 12, + CV_ALPHA_FltF3 = 13, + CV_ALPHA_FltF4 = 14, + CV_ALPHA_FltF5 = 15, + CV_ALPHA_FltF6 = 16, + CV_ALPHA_FltF7 = 17, + CV_ALPHA_FltF8 = 18, + CV_ALPHA_FltF9 = 19, + CV_ALPHA_FltF10 = 20, + CV_ALPHA_FltF11 = 21, + CV_ALPHA_FltF12 = 22, + CV_ALPHA_FltF13 = 23, + CV_ALPHA_FltF14 = 24, + CV_ALPHA_FltF15 = 25, + CV_ALPHA_FltF16 = 26, + CV_ALPHA_FltF17 = 27, + CV_ALPHA_FltF18 = 28, + CV_ALPHA_FltF19 = 29, + CV_ALPHA_FltF20 = 30, + CV_ALPHA_FltF21 = 31, + CV_ALPHA_FltF22 = 32, + CV_ALPHA_FltF23 = 33, + CV_ALPHA_FltF24 = 34, + CV_ALPHA_FltF25 = 35, + CV_ALPHA_FltF26 = 36, + CV_ALPHA_FltF27 = 37, + CV_ALPHA_FltF28 = 38, + CV_ALPHA_FltF29 = 39, + CV_ALPHA_FltF30 = 40, + CV_ALPHA_FltF31 = 41, + + CV_ALPHA_IntV0 = 42, // Integer registers + CV_ALPHA_IntT0 = 43, + CV_ALPHA_IntT1 = 44, + CV_ALPHA_IntT2 = 45, + CV_ALPHA_IntT3 = 46, + CV_ALPHA_IntT4 = 47, + CV_ALPHA_IntT5 = 48, + CV_ALPHA_IntT6 = 49, + CV_ALPHA_IntT7 = 50, + CV_ALPHA_IntS0 = 51, + CV_ALPHA_IntS1 = 52, + CV_ALPHA_IntS2 = 53, + CV_ALPHA_IntS3 = 54, + CV_ALPHA_IntS4 = 55, + CV_ALPHA_IntS5 = 56, + CV_ALPHA_IntFP = 57, + CV_ALPHA_IntA0 = 58, + CV_ALPHA_IntA1 = 59, + CV_ALPHA_IntA2 = 60, + CV_ALPHA_IntA3 = 61, + CV_ALPHA_IntA4 = 62, + CV_ALPHA_IntA5 = 63, + CV_ALPHA_IntT8 = 64, + CV_ALPHA_IntT9 = 65, + CV_ALPHA_IntT10 = 66, + CV_ALPHA_IntT11 = 67, + CV_ALPHA_IntRA = 68, + CV_ALPHA_IntT12 = 69, + CV_ALPHA_IntAT = 70, + CV_ALPHA_IntGP = 71, + CV_ALPHA_IntSP = 72, + CV_ALPHA_IntZERO = 73, + + + CV_ALPHA_Fpcr = 74, // Control registers + CV_ALPHA_Fir = 75, + CV_ALPHA_Psr = 76, + CV_ALPHA_FltFsr = 77, + CV_ALPHA_SoftFpcr = 78, + + // Register Set for Motorola/IBM PowerPC + + /* + ** PowerPC General Registers ( User Level ) + */ + CV_PPC_GPR0 = 1, + CV_PPC_GPR1 = 2, + CV_PPC_GPR2 = 3, + CV_PPC_GPR3 = 4, + CV_PPC_GPR4 = 5, + CV_PPC_GPR5 = 6, + CV_PPC_GPR6 = 7, + CV_PPC_GPR7 = 8, + CV_PPC_GPR8 = 9, + CV_PPC_GPR9 = 10, + CV_PPC_GPR10 = 11, + CV_PPC_GPR11 = 12, + CV_PPC_GPR12 = 13, + CV_PPC_GPR13 = 14, + CV_PPC_GPR14 = 15, + CV_PPC_GPR15 = 16, + CV_PPC_GPR16 = 17, + CV_PPC_GPR17 = 18, + CV_PPC_GPR18 = 19, + CV_PPC_GPR19 = 20, + CV_PPC_GPR20 = 21, + CV_PPC_GPR21 = 22, + CV_PPC_GPR22 = 23, + CV_PPC_GPR23 = 24, + CV_PPC_GPR24 = 25, + CV_PPC_GPR25 = 26, + CV_PPC_GPR26 = 27, + CV_PPC_GPR27 = 28, + CV_PPC_GPR28 = 29, + CV_PPC_GPR29 = 30, + CV_PPC_GPR30 = 31, + CV_PPC_GPR31 = 32, + + /* + ** PowerPC Condition Register ( User Level ) + */ + CV_PPC_CR = 33, + CV_PPC_CR0 = 34, + CV_PPC_CR1 = 35, + CV_PPC_CR2 = 36, + CV_PPC_CR3 = 37, + CV_PPC_CR4 = 38, + CV_PPC_CR5 = 39, + CV_PPC_CR6 = 40, + CV_PPC_CR7 = 41, + + /* + ** PowerPC Floating Point Registers ( User Level ) + */ + CV_PPC_FPR0 = 42, + CV_PPC_FPR1 = 43, + CV_PPC_FPR2 = 44, + CV_PPC_FPR3 = 45, + CV_PPC_FPR4 = 46, + CV_PPC_FPR5 = 47, + CV_PPC_FPR6 = 48, + CV_PPC_FPR7 = 49, + CV_PPC_FPR8 = 50, + CV_PPC_FPR9 = 51, + CV_PPC_FPR10 = 52, + CV_PPC_FPR11 = 53, + CV_PPC_FPR12 = 54, + CV_PPC_FPR13 = 55, + CV_PPC_FPR14 = 56, + CV_PPC_FPR15 = 57, + CV_PPC_FPR16 = 58, + CV_PPC_FPR17 = 59, + CV_PPC_FPR18 = 60, + CV_PPC_FPR19 = 61, + CV_PPC_FPR20 = 62, + CV_PPC_FPR21 = 63, + CV_PPC_FPR22 = 64, + CV_PPC_FPR23 = 65, + CV_PPC_FPR24 = 66, + CV_PPC_FPR25 = 67, + CV_PPC_FPR26 = 68, + CV_PPC_FPR27 = 69, + CV_PPC_FPR28 = 70, + CV_PPC_FPR29 = 71, + CV_PPC_FPR30 = 72, + CV_PPC_FPR31 = 73, + + /* + ** PowerPC Floating Point Status and Control Register ( User Level ) + */ + CV_PPC_FPSCR = 74, + + /* + ** PowerPC Machine State Register ( Supervisor Level ) + */ + CV_PPC_MSR = 75, + + /* + ** PowerPC Segment Registers ( Supervisor Level ) + */ + CV_PPC_SR0 = 76, + CV_PPC_SR1 = 77, + CV_PPC_SR2 = 78, + CV_PPC_SR3 = 79, + CV_PPC_SR4 = 80, + CV_PPC_SR5 = 81, + CV_PPC_SR6 = 82, + CV_PPC_SR7 = 83, + CV_PPC_SR8 = 84, + CV_PPC_SR9 = 85, + CV_PPC_SR10 = 86, + CV_PPC_SR11 = 87, + CV_PPC_SR12 = 88, + CV_PPC_SR13 = 89, + CV_PPC_SR14 = 90, + CV_PPC_SR15 = 91, + + /* + ** For all of the special purpose registers add 100 to the SPR# that the + ** Motorola/IBM documentation gives with the exception of any imaginary + ** registers. + */ + + /* + ** PowerPC Special Purpose Registers ( User Level ) + */ + CV_PPC_PC = 99, // PC (imaginary register) + + CV_PPC_MQ = 100, // MPC601 + CV_PPC_XER = 101, + CV_PPC_RTCU = 104, // MPC601 + CV_PPC_RTCL = 105, // MPC601 + CV_PPC_LR = 108, + CV_PPC_CTR = 109, + + CV_PPC_COMPARE = 110, // part of XER (internal to the debugger only) + CV_PPC_COUNT = 111, // part of XER (internal to the debugger only) + + /* + ** PowerPC Special Purpose Registers ( Supervisor Level ) + */ + CV_PPC_DSISR = 118, + CV_PPC_DAR = 119, + CV_PPC_DEC = 122, + CV_PPC_SDR1 = 125, + CV_PPC_SRR0 = 126, + CV_PPC_SRR1 = 127, + CV_PPC_SPRG0 = 372, + CV_PPC_SPRG1 = 373, + CV_PPC_SPRG2 = 374, + CV_PPC_SPRG3 = 375, + CV_PPC_ASR = 280, // 64-bit implementations only + CV_PPC_EAR = 382, + CV_PPC_PVR = 287, + CV_PPC_BAT0U = 628, + CV_PPC_BAT0L = 629, + CV_PPC_BAT1U = 630, + CV_PPC_BAT1L = 631, + CV_PPC_BAT2U = 632, + CV_PPC_BAT2L = 633, + CV_PPC_BAT3U = 634, + CV_PPC_BAT3L = 635, + CV_PPC_DBAT0U = 636, + CV_PPC_DBAT0L = 637, + CV_PPC_DBAT1U = 638, + CV_PPC_DBAT1L = 639, + CV_PPC_DBAT2U = 640, + CV_PPC_DBAT2L = 641, + CV_PPC_DBAT3U = 642, + CV_PPC_DBAT3L = 643, + + /* + ** PowerPC Special Purpose Registers Implementation Dependent ( Supervisor Level ) + */ + + /* + ** Doesn't appear that IBM/Motorola has finished defining these. + */ + + CV_PPC_PMR0 = 1044, // MPC620, + CV_PPC_PMR1 = 1045, // MPC620, + CV_PPC_PMR2 = 1046, // MPC620, + CV_PPC_PMR3 = 1047, // MPC620, + CV_PPC_PMR4 = 1048, // MPC620, + CV_PPC_PMR5 = 1049, // MPC620, + CV_PPC_PMR6 = 1050, // MPC620, + CV_PPC_PMR7 = 1051, // MPC620, + CV_PPC_PMR8 = 1052, // MPC620, + CV_PPC_PMR9 = 1053, // MPC620, + CV_PPC_PMR10 = 1054, // MPC620, + CV_PPC_PMR11 = 1055, // MPC620, + CV_PPC_PMR12 = 1056, // MPC620, + CV_PPC_PMR13 = 1057, // MPC620, + CV_PPC_PMR14 = 1058, // MPC620, + CV_PPC_PMR15 = 1059, // MPC620, + + CV_PPC_DMISS = 1076, // MPC603 + CV_PPC_DCMP = 1077, // MPC603 + CV_PPC_HASH1 = 1078, // MPC603 + CV_PPC_HASH2 = 1079, // MPC603 + CV_PPC_IMISS = 1080, // MPC603 + CV_PPC_ICMP = 1081, // MPC603 + CV_PPC_RPA = 1082, // MPC603 + + CV_PPC_HID0 = 1108, // MPC601, MPC603, MPC620 + CV_PPC_HID1 = 1109, // MPC601 + CV_PPC_HID2 = 1110, // MPC601, MPC603, MPC620 ( IABR ) + CV_PPC_HID3 = 1111, // Not Defined + CV_PPC_HID4 = 1112, // Not Defined + CV_PPC_HID5 = 1113, // MPC601, MPC604, MPC620 ( DABR ) + CV_PPC_HID6 = 1114, // Not Defined + CV_PPC_HID7 = 1115, // Not Defined + CV_PPC_HID8 = 1116, // MPC620 ( BUSCSR ) + CV_PPC_HID9 = 1117, // MPC620 ( L2CSR ) + CV_PPC_HID10 = 1118, // Not Defined + CV_PPC_HID11 = 1119, // Not Defined + CV_PPC_HID12 = 1120, // Not Defined + CV_PPC_HID13 = 1121, // MPC604 ( HCR ) + CV_PPC_HID14 = 1122, // Not Defined + CV_PPC_HID15 = 1123, // MPC601, MPC604, MPC620 ( PIR ) + + // + // JAVA VM registers + // + + CV_JAVA_PC = 1, + + // + // Register set for the Hitachi SH3 + // + + CV_SH3_NOREG = CV_REG_NONE, + + CV_SH3_IntR0 = 10, // CPU REGISTER + CV_SH3_IntR1 = 11, + CV_SH3_IntR2 = 12, + CV_SH3_IntR3 = 13, + CV_SH3_IntR4 = 14, + CV_SH3_IntR5 = 15, + CV_SH3_IntR6 = 16, + CV_SH3_IntR7 = 17, + CV_SH3_IntR8 = 18, + CV_SH3_IntR9 = 19, + CV_SH3_IntR10 = 20, + CV_SH3_IntR11 = 21, + CV_SH3_IntR12 = 22, + CV_SH3_IntR13 = 23, + CV_SH3_IntFp = 24, + CV_SH3_IntSp = 25, + CV_SH3_Gbr = 38, + CV_SH3_Pr = 39, + CV_SH3_Mach = 40, + CV_SH3_Macl = 41, + + CV_SH3_Pc = 50, + CV_SH3_Sr = 51, + + CV_SH3_BarA = 60, + CV_SH3_BasrA = 61, + CV_SH3_BamrA = 62, + CV_SH3_BbrA = 63, + CV_SH3_BarB = 64, + CV_SH3_BasrB = 65, + CV_SH3_BamrB = 66, + CV_SH3_BbrB = 67, + CV_SH3_BdrB = 68, + CV_SH3_BdmrB = 69, + CV_SH3_Brcr = 70, + + // + // Additional registers for Hitachi SH processors + // + + CV_SH_Fpscr = 75, // floating point status/control register + CV_SH_Fpul = 76, // floating point communication register + + CV_SH_FpR0 = 80, // Floating point registers + CV_SH_FpR1 = 81, + CV_SH_FpR2 = 82, + CV_SH_FpR3 = 83, + CV_SH_FpR4 = 84, + CV_SH_FpR5 = 85, + CV_SH_FpR6 = 86, + CV_SH_FpR7 = 87, + CV_SH_FpR8 = 88, + CV_SH_FpR9 = 89, + CV_SH_FpR10 = 90, + CV_SH_FpR11 = 91, + CV_SH_FpR12 = 92, + CV_SH_FpR13 = 93, + CV_SH_FpR14 = 94, + CV_SH_FpR15 = 95, + + CV_SH_XFpR0 = 96, + CV_SH_XFpR1 = 97, + CV_SH_XFpR2 = 98, + CV_SH_XFpR3 = 99, + CV_SH_XFpR4 = 100, + CV_SH_XFpR5 = 101, + CV_SH_XFpR6 = 102, + CV_SH_XFpR7 = 103, + CV_SH_XFpR8 = 104, + CV_SH_XFpR9 = 105, + CV_SH_XFpR10 = 106, + CV_SH_XFpR11 = 107, + CV_SH_XFpR12 = 108, + CV_SH_XFpR13 = 109, + CV_SH_XFpR14 = 110, + CV_SH_XFpR15 = 111, + + // + // Register set for the ARM processor. + // + + CV_ARM_NOREG = CV_REG_NONE, + + CV_ARM_R0 = 10, + CV_ARM_R1 = 11, + CV_ARM_R2 = 12, + CV_ARM_R3 = 13, + CV_ARM_R4 = 14, + CV_ARM_R5 = 15, + CV_ARM_R6 = 16, + CV_ARM_R7 = 17, + CV_ARM_R8 = 18, + CV_ARM_R9 = 19, + CV_ARM_R10 = 20, + CV_ARM_R11 = 21, // Frame pointer, if allocated + CV_ARM_R12 = 22, + CV_ARM_SP = 23, // Stack pointer + CV_ARM_LR = 24, // Link Register + CV_ARM_PC = 25, // Program counter + CV_ARM_CPSR = 26, // Current program status register + + CV_ARM_ACC0 = 27, // DSP co-processor 0 40 bit accumulator + + // + // Registers for ARM VFP10 support + // + + CV_ARM_FPSCR = 40, + CV_ARM_FPEXC = 41, + + CV_ARM_FS0 = 50, + CV_ARM_FS1 = 51, + CV_ARM_FS2 = 52, + CV_ARM_FS3 = 53, + CV_ARM_FS4 = 54, + CV_ARM_FS5 = 55, + CV_ARM_FS6 = 56, + CV_ARM_FS7 = 57, + CV_ARM_FS8 = 58, + CV_ARM_FS9 = 59, + CV_ARM_FS10 = 60, + CV_ARM_FS11 = 61, + CV_ARM_FS12 = 62, + CV_ARM_FS13 = 63, + CV_ARM_FS14 = 64, + CV_ARM_FS15 = 65, + CV_ARM_FS16 = 66, + CV_ARM_FS17 = 67, + CV_ARM_FS18 = 68, + CV_ARM_FS19 = 69, + CV_ARM_FS20 = 70, + CV_ARM_FS21 = 71, + CV_ARM_FS22 = 72, + CV_ARM_FS23 = 73, + CV_ARM_FS24 = 74, + CV_ARM_FS25 = 75, + CV_ARM_FS26 = 76, + CV_ARM_FS27 = 77, + CV_ARM_FS28 = 78, + CV_ARM_FS29 = 79, + CV_ARM_FS30 = 80, + CV_ARM_FS31 = 81, + + // + // ARM VFP Floating Point Extra control registers + // + + CV_ARM_FPEXTRA0 = 90, + CV_ARM_FPEXTRA1 = 91, + CV_ARM_FPEXTRA2 = 92, + CV_ARM_FPEXTRA3 = 93, + CV_ARM_FPEXTRA4 = 94, + CV_ARM_FPEXTRA5 = 95, + CV_ARM_FPEXTRA6 = 96, + CV_ARM_FPEXTRA7 = 97, + + // XSCALE Concan co-processor registers + CV_ARM_WR0 = 128, + CV_ARM_WR1 = 129, + CV_ARM_WR2 = 130, + CV_ARM_WR3 = 131, + CV_ARM_WR4 = 132, + CV_ARM_WR5 = 133, + CV_ARM_WR6 = 134, + CV_ARM_WR7 = 135, + CV_ARM_WR8 = 136, + CV_ARM_WR9 = 137, + CV_ARM_WR10 = 138, + CV_ARM_WR11 = 139, + CV_ARM_WR12 = 140, + CV_ARM_WR13 = 141, + CV_ARM_WR14 = 142, + CV_ARM_WR15 = 143, + + // XSCALE Concan co-processor control registers + CV_ARM_WCID = 144, + CV_ARM_WCON = 145, + CV_ARM_WCSSF = 146, + CV_ARM_WCASF = 147, + CV_ARM_WC4 = 148, + CV_ARM_WC5 = 149, + CV_ARM_WC6 = 150, + CV_ARM_WC7 = 151, + CV_ARM_WCGR0 = 152, + CV_ARM_WCGR1 = 153, + CV_ARM_WCGR2 = 154, + CV_ARM_WCGR3 = 155, + CV_ARM_WC12 = 156, + CV_ARM_WC13 = 157, + CV_ARM_WC14 = 158, + CV_ARM_WC15 = 159, + + // + // ARM VFPv3/Neon extended floating Point + // + + CV_ARM_FS32 = 200, + CV_ARM_FS33 = 201, + CV_ARM_FS34 = 202, + CV_ARM_FS35 = 203, + CV_ARM_FS36 = 204, + CV_ARM_FS37 = 205, + CV_ARM_FS38 = 206, + CV_ARM_FS39 = 207, + CV_ARM_FS40 = 208, + CV_ARM_FS41 = 209, + CV_ARM_FS42 = 210, + CV_ARM_FS43 = 211, + CV_ARM_FS44 = 212, + CV_ARM_FS45 = 213, + CV_ARM_FS46 = 214, + CV_ARM_FS47 = 215, + CV_ARM_FS48 = 216, + CV_ARM_FS49 = 217, + CV_ARM_FS50 = 218, + CV_ARM_FS51 = 219, + CV_ARM_FS52 = 220, + CV_ARM_FS53 = 221, + CV_ARM_FS54 = 222, + CV_ARM_FS55 = 223, + CV_ARM_FS56 = 224, + CV_ARM_FS57 = 225, + CV_ARM_FS58 = 226, + CV_ARM_FS59 = 227, + CV_ARM_FS60 = 228, + CV_ARM_FS61 = 229, + CV_ARM_FS62 = 230, + CV_ARM_FS63 = 231, + + // ARM double-precision floating point + + CV_ARM_ND0 = 300, + CV_ARM_ND1 = 301, + CV_ARM_ND2 = 302, + CV_ARM_ND3 = 303, + CV_ARM_ND4 = 304, + CV_ARM_ND5 = 305, + CV_ARM_ND6 = 306, + CV_ARM_ND7 = 307, + CV_ARM_ND8 = 308, + CV_ARM_ND9 = 309, + CV_ARM_ND10 = 310, + CV_ARM_ND11 = 311, + CV_ARM_ND12 = 312, + CV_ARM_ND13 = 313, + CV_ARM_ND14 = 314, + CV_ARM_ND15 = 315, + CV_ARM_ND16 = 316, + CV_ARM_ND17 = 317, + CV_ARM_ND18 = 318, + CV_ARM_ND19 = 319, + CV_ARM_ND20 = 320, + CV_ARM_ND21 = 321, + CV_ARM_ND22 = 322, + CV_ARM_ND23 = 323, + CV_ARM_ND24 = 324, + CV_ARM_ND25 = 325, + CV_ARM_ND26 = 326, + CV_ARM_ND27 = 327, + CV_ARM_ND28 = 328, + CV_ARM_ND29 = 329, + CV_ARM_ND30 = 330, + CV_ARM_ND31 = 331, + + // ARM extended precision floating point + + CV_ARM_NQ0 = 400, + CV_ARM_NQ1 = 401, + CV_ARM_NQ2 = 402, + CV_ARM_NQ3 = 403, + CV_ARM_NQ4 = 404, + CV_ARM_NQ5 = 405, + CV_ARM_NQ6 = 406, + CV_ARM_NQ7 = 407, + CV_ARM_NQ8 = 408, + CV_ARM_NQ9 = 409, + CV_ARM_NQ10 = 410, + CV_ARM_NQ11 = 411, + CV_ARM_NQ12 = 412, + CV_ARM_NQ13 = 413, + CV_ARM_NQ14 = 414, + CV_ARM_NQ15 = 415, + + // + // Register set for ARM64 + // + + CV_ARM64_NOREG = CV_REG_NONE, + + // General purpose 32-bit integer registers + + CV_ARM64_W0 = 10, + CV_ARM64_W1 = 11, + CV_ARM64_W2 = 12, + CV_ARM64_W3 = 13, + CV_ARM64_W4 = 14, + CV_ARM64_W5 = 15, + CV_ARM64_W6 = 16, + CV_ARM64_W7 = 17, + CV_ARM64_W8 = 18, + CV_ARM64_W9 = 19, + CV_ARM64_W10 = 20, + CV_ARM64_W11 = 21, + CV_ARM64_W12 = 22, + CV_ARM64_W13 = 23, + CV_ARM64_W14 = 24, + CV_ARM64_W15 = 25, + CV_ARM64_W16 = 26, + CV_ARM64_W17 = 27, + CV_ARM64_W18 = 28, + CV_ARM64_W19 = 29, + CV_ARM64_W20 = 30, + CV_ARM64_W21 = 31, + CV_ARM64_W22 = 32, + CV_ARM64_W23 = 33, + CV_ARM64_W24 = 34, + CV_ARM64_W25 = 35, + CV_ARM64_W26 = 36, + CV_ARM64_W27 = 37, + CV_ARM64_W28 = 38, + CV_ARM64_W29 = 39, + CV_ARM64_W30 = 40, + CV_ARM64_WZR = 41, + + // General purpose 64-bit integer registers + + CV_ARM64_X0 = 50, + CV_ARM64_X1 = 51, + CV_ARM64_X2 = 52, + CV_ARM64_X3 = 53, + CV_ARM64_X4 = 54, + CV_ARM64_X5 = 55, + CV_ARM64_X6 = 56, + CV_ARM64_X7 = 57, + CV_ARM64_X8 = 58, + CV_ARM64_X9 = 59, + CV_ARM64_X10 = 60, + CV_ARM64_X11 = 61, + CV_ARM64_X12 = 62, + CV_ARM64_X13 = 63, + CV_ARM64_X14 = 64, + CV_ARM64_X15 = 65, + CV_ARM64_IP0 = 66, + CV_ARM64_IP1 = 67, + CV_ARM64_X18 = 68, + CV_ARM64_X19 = 69, + CV_ARM64_X20 = 70, + CV_ARM64_X21 = 71, + CV_ARM64_X22 = 72, + CV_ARM64_X23 = 73, + CV_ARM64_X24 = 74, + CV_ARM64_X25 = 75, + CV_ARM64_X26 = 76, + CV_ARM64_X27 = 77, + CV_ARM64_X28 = 78, + CV_ARM64_FP = 79, + CV_ARM64_LR = 80, + CV_ARM64_SP = 81, + CV_ARM64_ZR = 82, + CV_ARM64_PC = 83, + + // status registers + + CV_ARM64_NZCV = 90, + CV_ARM64_CPSR = 91, + + // 32-bit floating point registers + + CV_ARM64_S0 = 100, + CV_ARM64_S1 = 101, + CV_ARM64_S2 = 102, + CV_ARM64_S3 = 103, + CV_ARM64_S4 = 104, + CV_ARM64_S5 = 105, + CV_ARM64_S6 = 106, + CV_ARM64_S7 = 107, + CV_ARM64_S8 = 108, + CV_ARM64_S9 = 109, + CV_ARM64_S10 = 110, + CV_ARM64_S11 = 111, + CV_ARM64_S12 = 112, + CV_ARM64_S13 = 113, + CV_ARM64_S14 = 114, + CV_ARM64_S15 = 115, + CV_ARM64_S16 = 116, + CV_ARM64_S17 = 117, + CV_ARM64_S18 = 118, + CV_ARM64_S19 = 119, + CV_ARM64_S20 = 120, + CV_ARM64_S21 = 121, + CV_ARM64_S22 = 122, + CV_ARM64_S23 = 123, + CV_ARM64_S24 = 124, + CV_ARM64_S25 = 125, + CV_ARM64_S26 = 126, + CV_ARM64_S27 = 127, + CV_ARM64_S28 = 128, + CV_ARM64_S29 = 129, + CV_ARM64_S30 = 130, + CV_ARM64_S31 = 131, + + // 64-bit floating point registers + + CV_ARM64_D0 = 140, + CV_ARM64_D1 = 141, + CV_ARM64_D2 = 142, + CV_ARM64_D3 = 143, + CV_ARM64_D4 = 144, + CV_ARM64_D5 = 145, + CV_ARM64_D6 = 146, + CV_ARM64_D7 = 147, + CV_ARM64_D8 = 148, + CV_ARM64_D9 = 149, + CV_ARM64_D10 = 150, + CV_ARM64_D11 = 151, + CV_ARM64_D12 = 152, + CV_ARM64_D13 = 153, + CV_ARM64_D14 = 154, + CV_ARM64_D15 = 155, + CV_ARM64_D16 = 156, + CV_ARM64_D17 = 157, + CV_ARM64_D18 = 158, + CV_ARM64_D19 = 159, + CV_ARM64_D20 = 160, + CV_ARM64_D21 = 161, + CV_ARM64_D22 = 162, + CV_ARM64_D23 = 163, + CV_ARM64_D24 = 164, + CV_ARM64_D25 = 165, + CV_ARM64_D26 = 166, + CV_ARM64_D27 = 167, + CV_ARM64_D28 = 168, + CV_ARM64_D29 = 169, + CV_ARM64_D30 = 170, + CV_ARM64_D31 = 171, + + // 128-bit SIMD registers + + CV_ARM64_Q0 = 180, + CV_ARM64_Q1 = 181, + CV_ARM64_Q2 = 182, + CV_ARM64_Q3 = 183, + CV_ARM64_Q4 = 184, + CV_ARM64_Q5 = 185, + CV_ARM64_Q6 = 186, + CV_ARM64_Q7 = 187, + CV_ARM64_Q8 = 188, + CV_ARM64_Q9 = 189, + CV_ARM64_Q10 = 190, + CV_ARM64_Q11 = 191, + CV_ARM64_Q12 = 192, + CV_ARM64_Q13 = 193, + CV_ARM64_Q14 = 194, + CV_ARM64_Q15 = 195, + CV_ARM64_Q16 = 196, + CV_ARM64_Q17 = 197, + CV_ARM64_Q18 = 198, + CV_ARM64_Q19 = 199, + CV_ARM64_Q20 = 200, + CV_ARM64_Q21 = 201, + CV_ARM64_Q22 = 202, + CV_ARM64_Q23 = 203, + CV_ARM64_Q24 = 204, + CV_ARM64_Q25 = 205, + CV_ARM64_Q26 = 206, + CV_ARM64_Q27 = 207, + CV_ARM64_Q28 = 208, + CV_ARM64_Q29 = 209, + CV_ARM64_Q30 = 210, + CV_ARM64_Q31 = 211, + + // Floating point status register + + CV_ARM64_FPSR = 220, + + // + // Register set for Intel IA64 + // + + CV_IA64_NOREG = CV_REG_NONE, + + // Branch Registers + + CV_IA64_Br0 = 512, + CV_IA64_Br1 = 513, + CV_IA64_Br2 = 514, + CV_IA64_Br3 = 515, + CV_IA64_Br4 = 516, + CV_IA64_Br5 = 517, + CV_IA64_Br6 = 518, + CV_IA64_Br7 = 519, + + // Predicate Registers + + CV_IA64_P0 = 704, + CV_IA64_P1 = 705, + CV_IA64_P2 = 706, + CV_IA64_P3 = 707, + CV_IA64_P4 = 708, + CV_IA64_P5 = 709, + CV_IA64_P6 = 710, + CV_IA64_P7 = 711, + CV_IA64_P8 = 712, + CV_IA64_P9 = 713, + CV_IA64_P10 = 714, + CV_IA64_P11 = 715, + CV_IA64_P12 = 716, + CV_IA64_P13 = 717, + CV_IA64_P14 = 718, + CV_IA64_P15 = 719, + CV_IA64_P16 = 720, + CV_IA64_P17 = 721, + CV_IA64_P18 = 722, + CV_IA64_P19 = 723, + CV_IA64_P20 = 724, + CV_IA64_P21 = 725, + CV_IA64_P22 = 726, + CV_IA64_P23 = 727, + CV_IA64_P24 = 728, + CV_IA64_P25 = 729, + CV_IA64_P26 = 730, + CV_IA64_P27 = 731, + CV_IA64_P28 = 732, + CV_IA64_P29 = 733, + CV_IA64_P30 = 734, + CV_IA64_P31 = 735, + CV_IA64_P32 = 736, + CV_IA64_P33 = 737, + CV_IA64_P34 = 738, + CV_IA64_P35 = 739, + CV_IA64_P36 = 740, + CV_IA64_P37 = 741, + CV_IA64_P38 = 742, + CV_IA64_P39 = 743, + CV_IA64_P40 = 744, + CV_IA64_P41 = 745, + CV_IA64_P42 = 746, + CV_IA64_P43 = 747, + CV_IA64_P44 = 748, + CV_IA64_P45 = 749, + CV_IA64_P46 = 750, + CV_IA64_P47 = 751, + CV_IA64_P48 = 752, + CV_IA64_P49 = 753, + CV_IA64_P50 = 754, + CV_IA64_P51 = 755, + CV_IA64_P52 = 756, + CV_IA64_P53 = 757, + CV_IA64_P54 = 758, + CV_IA64_P55 = 759, + CV_IA64_P56 = 760, + CV_IA64_P57 = 761, + CV_IA64_P58 = 762, + CV_IA64_P59 = 763, + CV_IA64_P60 = 764, + CV_IA64_P61 = 765, + CV_IA64_P62 = 766, + CV_IA64_P63 = 767, + + CV_IA64_Preds = 768, + + // Banked General Registers + + CV_IA64_IntH0 = 832, + CV_IA64_IntH1 = 833, + CV_IA64_IntH2 = 834, + CV_IA64_IntH3 = 835, + CV_IA64_IntH4 = 836, + CV_IA64_IntH5 = 837, + CV_IA64_IntH6 = 838, + CV_IA64_IntH7 = 839, + CV_IA64_IntH8 = 840, + CV_IA64_IntH9 = 841, + CV_IA64_IntH10 = 842, + CV_IA64_IntH11 = 843, + CV_IA64_IntH12 = 844, + CV_IA64_IntH13 = 845, + CV_IA64_IntH14 = 846, + CV_IA64_IntH15 = 847, + + // Special Registers + + CV_IA64_Ip = 1016, + CV_IA64_Umask = 1017, + CV_IA64_Cfm = 1018, + CV_IA64_Psr = 1019, + + // Banked General Registers + + CV_IA64_Nats = 1020, + CV_IA64_Nats2 = 1021, + CV_IA64_Nats3 = 1022, + + // General-Purpose Registers + + // Integer registers + CV_IA64_IntR0 = 1024, + CV_IA64_IntR1 = 1025, + CV_IA64_IntR2 = 1026, + CV_IA64_IntR3 = 1027, + CV_IA64_IntR4 = 1028, + CV_IA64_IntR5 = 1029, + CV_IA64_IntR6 = 1030, + CV_IA64_IntR7 = 1031, + CV_IA64_IntR8 = 1032, + CV_IA64_IntR9 = 1033, + CV_IA64_IntR10 = 1034, + CV_IA64_IntR11 = 1035, + CV_IA64_IntR12 = 1036, + CV_IA64_IntR13 = 1037, + CV_IA64_IntR14 = 1038, + CV_IA64_IntR15 = 1039, + CV_IA64_IntR16 = 1040, + CV_IA64_IntR17 = 1041, + CV_IA64_IntR18 = 1042, + CV_IA64_IntR19 = 1043, + CV_IA64_IntR20 = 1044, + CV_IA64_IntR21 = 1045, + CV_IA64_IntR22 = 1046, + CV_IA64_IntR23 = 1047, + CV_IA64_IntR24 = 1048, + CV_IA64_IntR25 = 1049, + CV_IA64_IntR26 = 1050, + CV_IA64_IntR27 = 1051, + CV_IA64_IntR28 = 1052, + CV_IA64_IntR29 = 1053, + CV_IA64_IntR30 = 1054, + CV_IA64_IntR31 = 1055, + + // Register Stack + CV_IA64_IntR32 = 1056, + CV_IA64_IntR33 = 1057, + CV_IA64_IntR34 = 1058, + CV_IA64_IntR35 = 1059, + CV_IA64_IntR36 = 1060, + CV_IA64_IntR37 = 1061, + CV_IA64_IntR38 = 1062, + CV_IA64_IntR39 = 1063, + CV_IA64_IntR40 = 1064, + CV_IA64_IntR41 = 1065, + CV_IA64_IntR42 = 1066, + CV_IA64_IntR43 = 1067, + CV_IA64_IntR44 = 1068, + CV_IA64_IntR45 = 1069, + CV_IA64_IntR46 = 1070, + CV_IA64_IntR47 = 1071, + CV_IA64_IntR48 = 1072, + CV_IA64_IntR49 = 1073, + CV_IA64_IntR50 = 1074, + CV_IA64_IntR51 = 1075, + CV_IA64_IntR52 = 1076, + CV_IA64_IntR53 = 1077, + CV_IA64_IntR54 = 1078, + CV_IA64_IntR55 = 1079, + CV_IA64_IntR56 = 1080, + CV_IA64_IntR57 = 1081, + CV_IA64_IntR58 = 1082, + CV_IA64_IntR59 = 1083, + CV_IA64_IntR60 = 1084, + CV_IA64_IntR61 = 1085, + CV_IA64_IntR62 = 1086, + CV_IA64_IntR63 = 1087, + CV_IA64_IntR64 = 1088, + CV_IA64_IntR65 = 1089, + CV_IA64_IntR66 = 1090, + CV_IA64_IntR67 = 1091, + CV_IA64_IntR68 = 1092, + CV_IA64_IntR69 = 1093, + CV_IA64_IntR70 = 1094, + CV_IA64_IntR71 = 1095, + CV_IA64_IntR72 = 1096, + CV_IA64_IntR73 = 1097, + CV_IA64_IntR74 = 1098, + CV_IA64_IntR75 = 1099, + CV_IA64_IntR76 = 1100, + CV_IA64_IntR77 = 1101, + CV_IA64_IntR78 = 1102, + CV_IA64_IntR79 = 1103, + CV_IA64_IntR80 = 1104, + CV_IA64_IntR81 = 1105, + CV_IA64_IntR82 = 1106, + CV_IA64_IntR83 = 1107, + CV_IA64_IntR84 = 1108, + CV_IA64_IntR85 = 1109, + CV_IA64_IntR86 = 1110, + CV_IA64_IntR87 = 1111, + CV_IA64_IntR88 = 1112, + CV_IA64_IntR89 = 1113, + CV_IA64_IntR90 = 1114, + CV_IA64_IntR91 = 1115, + CV_IA64_IntR92 = 1116, + CV_IA64_IntR93 = 1117, + CV_IA64_IntR94 = 1118, + CV_IA64_IntR95 = 1119, + CV_IA64_IntR96 = 1120, + CV_IA64_IntR97 = 1121, + CV_IA64_IntR98 = 1122, + CV_IA64_IntR99 = 1123, + CV_IA64_IntR100 = 1124, + CV_IA64_IntR101 = 1125, + CV_IA64_IntR102 = 1126, + CV_IA64_IntR103 = 1127, + CV_IA64_IntR104 = 1128, + CV_IA64_IntR105 = 1129, + CV_IA64_IntR106 = 1130, + CV_IA64_IntR107 = 1131, + CV_IA64_IntR108 = 1132, + CV_IA64_IntR109 = 1133, + CV_IA64_IntR110 = 1134, + CV_IA64_IntR111 = 1135, + CV_IA64_IntR112 = 1136, + CV_IA64_IntR113 = 1137, + CV_IA64_IntR114 = 1138, + CV_IA64_IntR115 = 1139, + CV_IA64_IntR116 = 1140, + CV_IA64_IntR117 = 1141, + CV_IA64_IntR118 = 1142, + CV_IA64_IntR119 = 1143, + CV_IA64_IntR120 = 1144, + CV_IA64_IntR121 = 1145, + CV_IA64_IntR122 = 1146, + CV_IA64_IntR123 = 1147, + CV_IA64_IntR124 = 1148, + CV_IA64_IntR125 = 1149, + CV_IA64_IntR126 = 1150, + CV_IA64_IntR127 = 1151, + + // Floating-Point Registers + + // Low Floating Point Registers + CV_IA64_FltF0 = 2048, + CV_IA64_FltF1 = 2049, + CV_IA64_FltF2 = 2050, + CV_IA64_FltF3 = 2051, + CV_IA64_FltF4 = 2052, + CV_IA64_FltF5 = 2053, + CV_IA64_FltF6 = 2054, + CV_IA64_FltF7 = 2055, + CV_IA64_FltF8 = 2056, + CV_IA64_FltF9 = 2057, + CV_IA64_FltF10 = 2058, + CV_IA64_FltF11 = 2059, + CV_IA64_FltF12 = 2060, + CV_IA64_FltF13 = 2061, + CV_IA64_FltF14 = 2062, + CV_IA64_FltF15 = 2063, + CV_IA64_FltF16 = 2064, + CV_IA64_FltF17 = 2065, + CV_IA64_FltF18 = 2066, + CV_IA64_FltF19 = 2067, + CV_IA64_FltF20 = 2068, + CV_IA64_FltF21 = 2069, + CV_IA64_FltF22 = 2070, + CV_IA64_FltF23 = 2071, + CV_IA64_FltF24 = 2072, + CV_IA64_FltF25 = 2073, + CV_IA64_FltF26 = 2074, + CV_IA64_FltF27 = 2075, + CV_IA64_FltF28 = 2076, + CV_IA64_FltF29 = 2077, + CV_IA64_FltF30 = 2078, + CV_IA64_FltF31 = 2079, + + // High Floating Point Registers + CV_IA64_FltF32 = 2080, + CV_IA64_FltF33 = 2081, + CV_IA64_FltF34 = 2082, + CV_IA64_FltF35 = 2083, + CV_IA64_FltF36 = 2084, + CV_IA64_FltF37 = 2085, + CV_IA64_FltF38 = 2086, + CV_IA64_FltF39 = 2087, + CV_IA64_FltF40 = 2088, + CV_IA64_FltF41 = 2089, + CV_IA64_FltF42 = 2090, + CV_IA64_FltF43 = 2091, + CV_IA64_FltF44 = 2092, + CV_IA64_FltF45 = 2093, + CV_IA64_FltF46 = 2094, + CV_IA64_FltF47 = 2095, + CV_IA64_FltF48 = 2096, + CV_IA64_FltF49 = 2097, + CV_IA64_FltF50 = 2098, + CV_IA64_FltF51 = 2099, + CV_IA64_FltF52 = 2100, + CV_IA64_FltF53 = 2101, + CV_IA64_FltF54 = 2102, + CV_IA64_FltF55 = 2103, + CV_IA64_FltF56 = 2104, + CV_IA64_FltF57 = 2105, + CV_IA64_FltF58 = 2106, + CV_IA64_FltF59 = 2107, + CV_IA64_FltF60 = 2108, + CV_IA64_FltF61 = 2109, + CV_IA64_FltF62 = 2110, + CV_IA64_FltF63 = 2111, + CV_IA64_FltF64 = 2112, + CV_IA64_FltF65 = 2113, + CV_IA64_FltF66 = 2114, + CV_IA64_FltF67 = 2115, + CV_IA64_FltF68 = 2116, + CV_IA64_FltF69 = 2117, + CV_IA64_FltF70 = 2118, + CV_IA64_FltF71 = 2119, + CV_IA64_FltF72 = 2120, + CV_IA64_FltF73 = 2121, + CV_IA64_FltF74 = 2122, + CV_IA64_FltF75 = 2123, + CV_IA64_FltF76 = 2124, + CV_IA64_FltF77 = 2125, + CV_IA64_FltF78 = 2126, + CV_IA64_FltF79 = 2127, + CV_IA64_FltF80 = 2128, + CV_IA64_FltF81 = 2129, + CV_IA64_FltF82 = 2130, + CV_IA64_FltF83 = 2131, + CV_IA64_FltF84 = 2132, + CV_IA64_FltF85 = 2133, + CV_IA64_FltF86 = 2134, + CV_IA64_FltF87 = 2135, + CV_IA64_FltF88 = 2136, + CV_IA64_FltF89 = 2137, + CV_IA64_FltF90 = 2138, + CV_IA64_FltF91 = 2139, + CV_IA64_FltF92 = 2140, + CV_IA64_FltF93 = 2141, + CV_IA64_FltF94 = 2142, + CV_IA64_FltF95 = 2143, + CV_IA64_FltF96 = 2144, + CV_IA64_FltF97 = 2145, + CV_IA64_FltF98 = 2146, + CV_IA64_FltF99 = 2147, + CV_IA64_FltF100 = 2148, + CV_IA64_FltF101 = 2149, + CV_IA64_FltF102 = 2150, + CV_IA64_FltF103 = 2151, + CV_IA64_FltF104 = 2152, + CV_IA64_FltF105 = 2153, + CV_IA64_FltF106 = 2154, + CV_IA64_FltF107 = 2155, + CV_IA64_FltF108 = 2156, + CV_IA64_FltF109 = 2157, + CV_IA64_FltF110 = 2158, + CV_IA64_FltF111 = 2159, + CV_IA64_FltF112 = 2160, + CV_IA64_FltF113 = 2161, + CV_IA64_FltF114 = 2162, + CV_IA64_FltF115 = 2163, + CV_IA64_FltF116 = 2164, + CV_IA64_FltF117 = 2165, + CV_IA64_FltF118 = 2166, + CV_IA64_FltF119 = 2167, + CV_IA64_FltF120 = 2168, + CV_IA64_FltF121 = 2169, + CV_IA64_FltF122 = 2170, + CV_IA64_FltF123 = 2171, + CV_IA64_FltF124 = 2172, + CV_IA64_FltF125 = 2173, + CV_IA64_FltF126 = 2174, + CV_IA64_FltF127 = 2175, + + // Application Registers + + CV_IA64_ApKR0 = 3072, + CV_IA64_ApKR1 = 3073, + CV_IA64_ApKR2 = 3074, + CV_IA64_ApKR3 = 3075, + CV_IA64_ApKR4 = 3076, + CV_IA64_ApKR5 = 3077, + CV_IA64_ApKR6 = 3078, + CV_IA64_ApKR7 = 3079, + CV_IA64_AR8 = 3080, + CV_IA64_AR9 = 3081, + CV_IA64_AR10 = 3082, + CV_IA64_AR11 = 3083, + CV_IA64_AR12 = 3084, + CV_IA64_AR13 = 3085, + CV_IA64_AR14 = 3086, + CV_IA64_AR15 = 3087, + CV_IA64_RsRSC = 3088, + CV_IA64_RsBSP = 3089, + CV_IA64_RsBSPSTORE = 3090, + CV_IA64_RsRNAT = 3091, + CV_IA64_AR20 = 3092, + CV_IA64_StFCR = 3093, + CV_IA64_AR22 = 3094, + CV_IA64_AR23 = 3095, + CV_IA64_EFLAG = 3096, + CV_IA64_CSD = 3097, + CV_IA64_SSD = 3098, + CV_IA64_CFLG = 3099, + CV_IA64_StFSR = 3100, + CV_IA64_StFIR = 3101, + CV_IA64_StFDR = 3102, + CV_IA64_AR31 = 3103, + CV_IA64_ApCCV = 3104, + CV_IA64_AR33 = 3105, + CV_IA64_AR34 = 3106, + CV_IA64_AR35 = 3107, + CV_IA64_ApUNAT = 3108, + CV_IA64_AR37 = 3109, + CV_IA64_AR38 = 3110, + CV_IA64_AR39 = 3111, + CV_IA64_StFPSR = 3112, + CV_IA64_AR41 = 3113, + CV_IA64_AR42 = 3114, + CV_IA64_AR43 = 3115, + CV_IA64_ApITC = 3116, + CV_IA64_AR45 = 3117, + CV_IA64_AR46 = 3118, + CV_IA64_AR47 = 3119, + CV_IA64_AR48 = 3120, + CV_IA64_AR49 = 3121, + CV_IA64_AR50 = 3122, + CV_IA64_AR51 = 3123, + CV_IA64_AR52 = 3124, + CV_IA64_AR53 = 3125, + CV_IA64_AR54 = 3126, + CV_IA64_AR55 = 3127, + CV_IA64_AR56 = 3128, + CV_IA64_AR57 = 3129, + CV_IA64_AR58 = 3130, + CV_IA64_AR59 = 3131, + CV_IA64_AR60 = 3132, + CV_IA64_AR61 = 3133, + CV_IA64_AR62 = 3134, + CV_IA64_AR63 = 3135, + CV_IA64_RsPFS = 3136, + CV_IA64_ApLC = 3137, + CV_IA64_ApEC = 3138, + CV_IA64_AR67 = 3139, + CV_IA64_AR68 = 3140, + CV_IA64_AR69 = 3141, + CV_IA64_AR70 = 3142, + CV_IA64_AR71 = 3143, + CV_IA64_AR72 = 3144, + CV_IA64_AR73 = 3145, + CV_IA64_AR74 = 3146, + CV_IA64_AR75 = 3147, + CV_IA64_AR76 = 3148, + CV_IA64_AR77 = 3149, + CV_IA64_AR78 = 3150, + CV_IA64_AR79 = 3151, + CV_IA64_AR80 = 3152, + CV_IA64_AR81 = 3153, + CV_IA64_AR82 = 3154, + CV_IA64_AR83 = 3155, + CV_IA64_AR84 = 3156, + CV_IA64_AR85 = 3157, + CV_IA64_AR86 = 3158, + CV_IA64_AR87 = 3159, + CV_IA64_AR88 = 3160, + CV_IA64_AR89 = 3161, + CV_IA64_AR90 = 3162, + CV_IA64_AR91 = 3163, + CV_IA64_AR92 = 3164, + CV_IA64_AR93 = 3165, + CV_IA64_AR94 = 3166, + CV_IA64_AR95 = 3167, + CV_IA64_AR96 = 3168, + CV_IA64_AR97 = 3169, + CV_IA64_AR98 = 3170, + CV_IA64_AR99 = 3171, + CV_IA64_AR100 = 3172, + CV_IA64_AR101 = 3173, + CV_IA64_AR102 = 3174, + CV_IA64_AR103 = 3175, + CV_IA64_AR104 = 3176, + CV_IA64_AR105 = 3177, + CV_IA64_AR106 = 3178, + CV_IA64_AR107 = 3179, + CV_IA64_AR108 = 3180, + CV_IA64_AR109 = 3181, + CV_IA64_AR110 = 3182, + CV_IA64_AR111 = 3183, + CV_IA64_AR112 = 3184, + CV_IA64_AR113 = 3185, + CV_IA64_AR114 = 3186, + CV_IA64_AR115 = 3187, + CV_IA64_AR116 = 3188, + CV_IA64_AR117 = 3189, + CV_IA64_AR118 = 3190, + CV_IA64_AR119 = 3191, + CV_IA64_AR120 = 3192, + CV_IA64_AR121 = 3193, + CV_IA64_AR122 = 3194, + CV_IA64_AR123 = 3195, + CV_IA64_AR124 = 3196, + CV_IA64_AR125 = 3197, + CV_IA64_AR126 = 3198, + CV_IA64_AR127 = 3199, + + // CPUID Registers + + CV_IA64_CPUID0 = 3328, + CV_IA64_CPUID1 = 3329, + CV_IA64_CPUID2 = 3330, + CV_IA64_CPUID3 = 3331, + CV_IA64_CPUID4 = 3332, + + // Control Registers + + CV_IA64_ApDCR = 4096, + CV_IA64_ApITM = 4097, + CV_IA64_ApIVA = 4098, + CV_IA64_CR3 = 4099, + CV_IA64_CR4 = 4100, + CV_IA64_CR5 = 4101, + CV_IA64_CR6 = 4102, + CV_IA64_CR7 = 4103, + CV_IA64_ApPTA = 4104, + CV_IA64_ApGPTA = 4105, + CV_IA64_CR10 = 4106, + CV_IA64_CR11 = 4107, + CV_IA64_CR12 = 4108, + CV_IA64_CR13 = 4109, + CV_IA64_CR14 = 4110, + CV_IA64_CR15 = 4111, + CV_IA64_StIPSR = 4112, + CV_IA64_StISR = 4113, + CV_IA64_CR18 = 4114, + CV_IA64_StIIP = 4115, + CV_IA64_StIFA = 4116, + CV_IA64_StITIR = 4117, + CV_IA64_StIIPA = 4118, + CV_IA64_StIFS = 4119, + CV_IA64_StIIM = 4120, + CV_IA64_StIHA = 4121, + CV_IA64_CR26 = 4122, + CV_IA64_CR27 = 4123, + CV_IA64_CR28 = 4124, + CV_IA64_CR29 = 4125, + CV_IA64_CR30 = 4126, + CV_IA64_CR31 = 4127, + CV_IA64_CR32 = 4128, + CV_IA64_CR33 = 4129, + CV_IA64_CR34 = 4130, + CV_IA64_CR35 = 4131, + CV_IA64_CR36 = 4132, + CV_IA64_CR37 = 4133, + CV_IA64_CR38 = 4134, + CV_IA64_CR39 = 4135, + CV_IA64_CR40 = 4136, + CV_IA64_CR41 = 4137, + CV_IA64_CR42 = 4138, + CV_IA64_CR43 = 4139, + CV_IA64_CR44 = 4140, + CV_IA64_CR45 = 4141, + CV_IA64_CR46 = 4142, + CV_IA64_CR47 = 4143, + CV_IA64_CR48 = 4144, + CV_IA64_CR49 = 4145, + CV_IA64_CR50 = 4146, + CV_IA64_CR51 = 4147, + CV_IA64_CR52 = 4148, + CV_IA64_CR53 = 4149, + CV_IA64_CR54 = 4150, + CV_IA64_CR55 = 4151, + CV_IA64_CR56 = 4152, + CV_IA64_CR57 = 4153, + CV_IA64_CR58 = 4154, + CV_IA64_CR59 = 4155, + CV_IA64_CR60 = 4156, + CV_IA64_CR61 = 4157, + CV_IA64_CR62 = 4158, + CV_IA64_CR63 = 4159, + CV_IA64_SaLID = 4160, + CV_IA64_SaIVR = 4161, + CV_IA64_SaTPR = 4162, + CV_IA64_SaEOI = 4163, + CV_IA64_SaIRR0 = 4164, + CV_IA64_SaIRR1 = 4165, + CV_IA64_SaIRR2 = 4166, + CV_IA64_SaIRR3 = 4167, + CV_IA64_SaITV = 4168, + CV_IA64_SaPMV = 4169, + CV_IA64_SaCMCV = 4170, + CV_IA64_CR75 = 4171, + CV_IA64_CR76 = 4172, + CV_IA64_CR77 = 4173, + CV_IA64_CR78 = 4174, + CV_IA64_CR79 = 4175, + CV_IA64_SaLRR0 = 4176, + CV_IA64_SaLRR1 = 4177, + CV_IA64_CR82 = 4178, + CV_IA64_CR83 = 4179, + CV_IA64_CR84 = 4180, + CV_IA64_CR85 = 4181, + CV_IA64_CR86 = 4182, + CV_IA64_CR87 = 4183, + CV_IA64_CR88 = 4184, + CV_IA64_CR89 = 4185, + CV_IA64_CR90 = 4186, + CV_IA64_CR91 = 4187, + CV_IA64_CR92 = 4188, + CV_IA64_CR93 = 4189, + CV_IA64_CR94 = 4190, + CV_IA64_CR95 = 4191, + CV_IA64_CR96 = 4192, + CV_IA64_CR97 = 4193, + CV_IA64_CR98 = 4194, + CV_IA64_CR99 = 4195, + CV_IA64_CR100 = 4196, + CV_IA64_CR101 = 4197, + CV_IA64_CR102 = 4198, + CV_IA64_CR103 = 4199, + CV_IA64_CR104 = 4200, + CV_IA64_CR105 = 4201, + CV_IA64_CR106 = 4202, + CV_IA64_CR107 = 4203, + CV_IA64_CR108 = 4204, + CV_IA64_CR109 = 4205, + CV_IA64_CR110 = 4206, + CV_IA64_CR111 = 4207, + CV_IA64_CR112 = 4208, + CV_IA64_CR113 = 4209, + CV_IA64_CR114 = 4210, + CV_IA64_CR115 = 4211, + CV_IA64_CR116 = 4212, + CV_IA64_CR117 = 4213, + CV_IA64_CR118 = 4214, + CV_IA64_CR119 = 4215, + CV_IA64_CR120 = 4216, + CV_IA64_CR121 = 4217, + CV_IA64_CR122 = 4218, + CV_IA64_CR123 = 4219, + CV_IA64_CR124 = 4220, + CV_IA64_CR125 = 4221, + CV_IA64_CR126 = 4222, + CV_IA64_CR127 = 4223, + + // Protection Key Registers + + CV_IA64_Pkr0 = 5120, + CV_IA64_Pkr1 = 5121, + CV_IA64_Pkr2 = 5122, + CV_IA64_Pkr3 = 5123, + CV_IA64_Pkr4 = 5124, + CV_IA64_Pkr5 = 5125, + CV_IA64_Pkr6 = 5126, + CV_IA64_Pkr7 = 5127, + CV_IA64_Pkr8 = 5128, + CV_IA64_Pkr9 = 5129, + CV_IA64_Pkr10 = 5130, + CV_IA64_Pkr11 = 5131, + CV_IA64_Pkr12 = 5132, + CV_IA64_Pkr13 = 5133, + CV_IA64_Pkr14 = 5134, + CV_IA64_Pkr15 = 5135, + + // Region Registers + + CV_IA64_Rr0 = 6144, + CV_IA64_Rr1 = 6145, + CV_IA64_Rr2 = 6146, + CV_IA64_Rr3 = 6147, + CV_IA64_Rr4 = 6148, + CV_IA64_Rr5 = 6149, + CV_IA64_Rr6 = 6150, + CV_IA64_Rr7 = 6151, + + // Performance Monitor Data Registers + + CV_IA64_PFD0 = 7168, + CV_IA64_PFD1 = 7169, + CV_IA64_PFD2 = 7170, + CV_IA64_PFD3 = 7171, + CV_IA64_PFD4 = 7172, + CV_IA64_PFD5 = 7173, + CV_IA64_PFD6 = 7174, + CV_IA64_PFD7 = 7175, + CV_IA64_PFD8 = 7176, + CV_IA64_PFD9 = 7177, + CV_IA64_PFD10 = 7178, + CV_IA64_PFD11 = 7179, + CV_IA64_PFD12 = 7180, + CV_IA64_PFD13 = 7181, + CV_IA64_PFD14 = 7182, + CV_IA64_PFD15 = 7183, + CV_IA64_PFD16 = 7184, + CV_IA64_PFD17 = 7185, + + // Performance Monitor Config Registers + + CV_IA64_PFC0 = 7424, + CV_IA64_PFC1 = 7425, + CV_IA64_PFC2 = 7426, + CV_IA64_PFC3 = 7427, + CV_IA64_PFC4 = 7428, + CV_IA64_PFC5 = 7429, + CV_IA64_PFC6 = 7430, + CV_IA64_PFC7 = 7431, + CV_IA64_PFC8 = 7432, + CV_IA64_PFC9 = 7433, + CV_IA64_PFC10 = 7434, + CV_IA64_PFC11 = 7435, + CV_IA64_PFC12 = 7436, + CV_IA64_PFC13 = 7437, + CV_IA64_PFC14 = 7438, + CV_IA64_PFC15 = 7439, + + // Instruction Translation Registers + + CV_IA64_TrI0 = 8192, + CV_IA64_TrI1 = 8193, + CV_IA64_TrI2 = 8194, + CV_IA64_TrI3 = 8195, + CV_IA64_TrI4 = 8196, + CV_IA64_TrI5 = 8197, + CV_IA64_TrI6 = 8198, + CV_IA64_TrI7 = 8199, + + // Data Translation Registers + + CV_IA64_TrD0 = 8320, + CV_IA64_TrD1 = 8321, + CV_IA64_TrD2 = 8322, + CV_IA64_TrD3 = 8323, + CV_IA64_TrD4 = 8324, + CV_IA64_TrD5 = 8325, + CV_IA64_TrD6 = 8326, + CV_IA64_TrD7 = 8327, + + // Instruction Breakpoint Registers + + CV_IA64_DbI0 = 8448, + CV_IA64_DbI1 = 8449, + CV_IA64_DbI2 = 8450, + CV_IA64_DbI3 = 8451, + CV_IA64_DbI4 = 8452, + CV_IA64_DbI5 = 8453, + CV_IA64_DbI6 = 8454, + CV_IA64_DbI7 = 8455, + + // Data Breakpoint Registers + + CV_IA64_DbD0 = 8576, + CV_IA64_DbD1 = 8577, + CV_IA64_DbD2 = 8578, + CV_IA64_DbD3 = 8579, + CV_IA64_DbD4 = 8580, + CV_IA64_DbD5 = 8581, + CV_IA64_DbD6 = 8582, + CV_IA64_DbD7 = 8583, + + // + // Register set for the TriCore processor. + // + + CV_TRI_NOREG = CV_REG_NONE, + + // General Purpose Data Registers + + CV_TRI_D0 = 10, + CV_TRI_D1 = 11, + CV_TRI_D2 = 12, + CV_TRI_D3 = 13, + CV_TRI_D4 = 14, + CV_TRI_D5 = 15, + CV_TRI_D6 = 16, + CV_TRI_D7 = 17, + CV_TRI_D8 = 18, + CV_TRI_D9 = 19, + CV_TRI_D10 = 20, + CV_TRI_D11 = 21, + CV_TRI_D12 = 22, + CV_TRI_D13 = 23, + CV_TRI_D14 = 24, + CV_TRI_D15 = 25, + + // General Purpose Address Registers + + CV_TRI_A0 = 26, + CV_TRI_A1 = 27, + CV_TRI_A2 = 28, + CV_TRI_A3 = 29, + CV_TRI_A4 = 30, + CV_TRI_A5 = 31, + CV_TRI_A6 = 32, + CV_TRI_A7 = 33, + CV_TRI_A8 = 34, + CV_TRI_A9 = 35, + CV_TRI_A10 = 36, + CV_TRI_A11 = 37, + CV_TRI_A12 = 38, + CV_TRI_A13 = 39, + CV_TRI_A14 = 40, + CV_TRI_A15 = 41, + + // Extended (64-bit) data registers + + CV_TRI_E0 = 42, + CV_TRI_E2 = 43, + CV_TRI_E4 = 44, + CV_TRI_E6 = 45, + CV_TRI_E8 = 46, + CV_TRI_E10 = 47, + CV_TRI_E12 = 48, + CV_TRI_E14 = 49, + + // Extended (64-bit) address registers + + CV_TRI_EA0 = 50, + CV_TRI_EA2 = 51, + CV_TRI_EA4 = 52, + CV_TRI_EA6 = 53, + CV_TRI_EA8 = 54, + CV_TRI_EA10 = 55, + CV_TRI_EA12 = 56, + CV_TRI_EA14 = 57, + + CV_TRI_PSW = 58, + CV_TRI_PCXI = 59, + CV_TRI_PC = 60, + CV_TRI_FCX = 61, + CV_TRI_LCX = 62, + CV_TRI_ISP = 63, + CV_TRI_ICR = 64, + CV_TRI_BIV = 65, + CV_TRI_BTV = 66, + CV_TRI_SYSCON = 67, + CV_TRI_DPRx_0 = 68, + CV_TRI_DPRx_1 = 69, + CV_TRI_DPRx_2 = 70, + CV_TRI_DPRx_3 = 71, + CV_TRI_CPRx_0 = 68, + CV_TRI_CPRx_1 = 69, + CV_TRI_CPRx_2 = 70, + CV_TRI_CPRx_3 = 71, + CV_TRI_DPMx_0 = 68, + CV_TRI_DPMx_1 = 69, + CV_TRI_DPMx_2 = 70, + CV_TRI_DPMx_3 = 71, + CV_TRI_CPMx_0 = 68, + CV_TRI_CPMx_1 = 69, + CV_TRI_CPMx_2 = 70, + CV_TRI_CPMx_3 = 71, + CV_TRI_DBGSSR = 72, + CV_TRI_EXEVT = 73, + CV_TRI_SWEVT = 74, + CV_TRI_CREVT = 75, + CV_TRI_TRnEVT = 76, + CV_TRI_MMUCON = 77, + CV_TRI_ASI = 78, + CV_TRI_TVA = 79, + CV_TRI_TPA = 80, + CV_TRI_TPX = 81, + CV_TRI_TFA = 82, + + // + // Register set for the AM33 and related processors. + // + + CV_AM33_NOREG = CV_REG_NONE, + + // "Extended" (general purpose integer) registers + CV_AM33_E0 = 10, + CV_AM33_E1 = 11, + CV_AM33_E2 = 12, + CV_AM33_E3 = 13, + CV_AM33_E4 = 14, + CV_AM33_E5 = 15, + CV_AM33_E6 = 16, + CV_AM33_E7 = 17, + + // Address registers + CV_AM33_A0 = 20, + CV_AM33_A1 = 21, + CV_AM33_A2 = 22, + CV_AM33_A3 = 23, + + // Integer data registers + CV_AM33_D0 = 30, + CV_AM33_D1 = 31, + CV_AM33_D2 = 32, + CV_AM33_D3 = 33, + + // (Single-precision) floating-point registers + CV_AM33_FS0 = 40, + CV_AM33_FS1 = 41, + CV_AM33_FS2 = 42, + CV_AM33_FS3 = 43, + CV_AM33_FS4 = 44, + CV_AM33_FS5 = 45, + CV_AM33_FS6 = 46, + CV_AM33_FS7 = 47, + CV_AM33_FS8 = 48, + CV_AM33_FS9 = 49, + CV_AM33_FS10 = 50, + CV_AM33_FS11 = 51, + CV_AM33_FS12 = 52, + CV_AM33_FS13 = 53, + CV_AM33_FS14 = 54, + CV_AM33_FS15 = 55, + CV_AM33_FS16 = 56, + CV_AM33_FS17 = 57, + CV_AM33_FS18 = 58, + CV_AM33_FS19 = 59, + CV_AM33_FS20 = 60, + CV_AM33_FS21 = 61, + CV_AM33_FS22 = 62, + CV_AM33_FS23 = 63, + CV_AM33_FS24 = 64, + CV_AM33_FS25 = 65, + CV_AM33_FS26 = 66, + CV_AM33_FS27 = 67, + CV_AM33_FS28 = 68, + CV_AM33_FS29 = 69, + CV_AM33_FS30 = 70, + CV_AM33_FS31 = 71, + + // Special purpose registers + + // Stack pointer + CV_AM33_SP = 80, + + // Program counter + CV_AM33_PC = 81, + + // Multiply-divide/accumulate registers + CV_AM33_MDR = 82, + CV_AM33_MDRQ = 83, + CV_AM33_MCRH = 84, + CV_AM33_MCRL = 85, + CV_AM33_MCVF = 86, + + // CPU status words + CV_AM33_EPSW = 87, + CV_AM33_FPCR = 88, + + // Loop buffer registers + CV_AM33_LIR = 89, + CV_AM33_LAR = 90, + + // + // Register set for the Mitsubishi M32R + // + + CV_M32R_NOREG = CV_REG_NONE, + + CV_M32R_R0 = 10, + CV_M32R_R1 = 11, + CV_M32R_R2 = 12, + CV_M32R_R3 = 13, + CV_M32R_R4 = 14, + CV_M32R_R5 = 15, + CV_M32R_R6 = 16, + CV_M32R_R7 = 17, + CV_M32R_R8 = 18, + CV_M32R_R9 = 19, + CV_M32R_R10 = 20, + CV_M32R_R11 = 21, + CV_M32R_R12 = 22, // Gloabal Pointer, if used + CV_M32R_R13 = 23, // Frame Pointer, if allocated + CV_M32R_R14 = 24, // Link Register + CV_M32R_R15 = 25, // Stack Pointer + CV_M32R_PSW = 26, // Preocessor Status Register + CV_M32R_CBR = 27, // Condition Bit Register + CV_M32R_SPI = 28, // Interrupt Stack Pointer + CV_M32R_SPU = 29, // User Stack Pointer + CV_M32R_SPO = 30, // OS Stack Pointer + CV_M32R_BPC = 31, // Backup Program Counter + CV_M32R_ACHI = 32, // Accumulator High + CV_M32R_ACLO = 33, // Accumulator Low + CV_M32R_PC = 34, // Program Counter + + // + // Register set for the SuperH SHMedia processor including compact + // mode + // + + // Integer - 64 bit general registers + CV_SHMEDIA_NOREG = CV_REG_NONE, + CV_SHMEDIA_R0 = 10, + CV_SHMEDIA_R1 = 11, + CV_SHMEDIA_R2 = 12, + CV_SHMEDIA_R3 = 13, + CV_SHMEDIA_R4 = 14, + CV_SHMEDIA_R5 = 15, + CV_SHMEDIA_R6 = 16, + CV_SHMEDIA_R7 = 17, + CV_SHMEDIA_R8 = 18, + CV_SHMEDIA_R9 = 19, + CV_SHMEDIA_R10 = 20, + CV_SHMEDIA_R11 = 21, + CV_SHMEDIA_R12 = 22, + CV_SHMEDIA_R13 = 23, + CV_SHMEDIA_R14 = 24, + CV_SHMEDIA_R15 = 25, + CV_SHMEDIA_R16 = 26, + CV_SHMEDIA_R17 = 27, + CV_SHMEDIA_R18 = 28, + CV_SHMEDIA_R19 = 29, + CV_SHMEDIA_R20 = 30, + CV_SHMEDIA_R21 = 31, + CV_SHMEDIA_R22 = 32, + CV_SHMEDIA_R23 = 33, + CV_SHMEDIA_R24 = 34, + CV_SHMEDIA_R25 = 35, + CV_SHMEDIA_R26 = 36, + CV_SHMEDIA_R27 = 37, + CV_SHMEDIA_R28 = 38, + CV_SHMEDIA_R29 = 39, + CV_SHMEDIA_R30 = 40, + CV_SHMEDIA_R31 = 41, + CV_SHMEDIA_R32 = 42, + CV_SHMEDIA_R33 = 43, + CV_SHMEDIA_R34 = 44, + CV_SHMEDIA_R35 = 45, + CV_SHMEDIA_R36 = 46, + CV_SHMEDIA_R37 = 47, + CV_SHMEDIA_R38 = 48, + CV_SHMEDIA_R39 = 49, + CV_SHMEDIA_R40 = 50, + CV_SHMEDIA_R41 = 51, + CV_SHMEDIA_R42 = 52, + CV_SHMEDIA_R43 = 53, + CV_SHMEDIA_R44 = 54, + CV_SHMEDIA_R45 = 55, + CV_SHMEDIA_R46 = 56, + CV_SHMEDIA_R47 = 57, + CV_SHMEDIA_R48 = 58, + CV_SHMEDIA_R49 = 59, + CV_SHMEDIA_R50 = 60, + CV_SHMEDIA_R51 = 61, + CV_SHMEDIA_R52 = 62, + CV_SHMEDIA_R53 = 63, + CV_SHMEDIA_R54 = 64, + CV_SHMEDIA_R55 = 65, + CV_SHMEDIA_R56 = 66, + CV_SHMEDIA_R57 = 67, + CV_SHMEDIA_R58 = 68, + CV_SHMEDIA_R59 = 69, + CV_SHMEDIA_R60 = 70, + CV_SHMEDIA_R61 = 71, + CV_SHMEDIA_R62 = 72, + CV_SHMEDIA_R63 = 73, + + // Target Registers - 32 bit + CV_SHMEDIA_TR0 = 74, + CV_SHMEDIA_TR1 = 75, + CV_SHMEDIA_TR2 = 76, + CV_SHMEDIA_TR3 = 77, + CV_SHMEDIA_TR4 = 78, + CV_SHMEDIA_TR5 = 79, + CV_SHMEDIA_TR6 = 80, + CV_SHMEDIA_TR7 = 81, + CV_SHMEDIA_TR8 = 82, // future-proof + CV_SHMEDIA_TR9 = 83, // future-proof + CV_SHMEDIA_TR10 = 84, // future-proof + CV_SHMEDIA_TR11 = 85, // future-proof + CV_SHMEDIA_TR12 = 86, // future-proof + CV_SHMEDIA_TR13 = 87, // future-proof + CV_SHMEDIA_TR14 = 88, // future-proof + CV_SHMEDIA_TR15 = 89, // future-proof + + // Single - 32 bit fp registers + CV_SHMEDIA_FR0 = 128, + CV_SHMEDIA_FR1 = 129, + CV_SHMEDIA_FR2 = 130, + CV_SHMEDIA_FR3 = 131, + CV_SHMEDIA_FR4 = 132, + CV_SHMEDIA_FR5 = 133, + CV_SHMEDIA_FR6 = 134, + CV_SHMEDIA_FR7 = 135, + CV_SHMEDIA_FR8 = 136, + CV_SHMEDIA_FR9 = 137, + CV_SHMEDIA_FR10 = 138, + CV_SHMEDIA_FR11 = 139, + CV_SHMEDIA_FR12 = 140, + CV_SHMEDIA_FR13 = 141, + CV_SHMEDIA_FR14 = 142, + CV_SHMEDIA_FR15 = 143, + CV_SHMEDIA_FR16 = 144, + CV_SHMEDIA_FR17 = 145, + CV_SHMEDIA_FR18 = 146, + CV_SHMEDIA_FR19 = 147, + CV_SHMEDIA_FR20 = 148, + CV_SHMEDIA_FR21 = 149, + CV_SHMEDIA_FR22 = 150, + CV_SHMEDIA_FR23 = 151, + CV_SHMEDIA_FR24 = 152, + CV_SHMEDIA_FR25 = 153, + CV_SHMEDIA_FR26 = 154, + CV_SHMEDIA_FR27 = 155, + CV_SHMEDIA_FR28 = 156, + CV_SHMEDIA_FR29 = 157, + CV_SHMEDIA_FR30 = 158, + CV_SHMEDIA_FR31 = 159, + CV_SHMEDIA_FR32 = 160, + CV_SHMEDIA_FR33 = 161, + CV_SHMEDIA_FR34 = 162, + CV_SHMEDIA_FR35 = 163, + CV_SHMEDIA_FR36 = 164, + CV_SHMEDIA_FR37 = 165, + CV_SHMEDIA_FR38 = 166, + CV_SHMEDIA_FR39 = 167, + CV_SHMEDIA_FR40 = 168, + CV_SHMEDIA_FR41 = 169, + CV_SHMEDIA_FR42 = 170, + CV_SHMEDIA_FR43 = 171, + CV_SHMEDIA_FR44 = 172, + CV_SHMEDIA_FR45 = 173, + CV_SHMEDIA_FR46 = 174, + CV_SHMEDIA_FR47 = 175, + CV_SHMEDIA_FR48 = 176, + CV_SHMEDIA_FR49 = 177, + CV_SHMEDIA_FR50 = 178, + CV_SHMEDIA_FR51 = 179, + CV_SHMEDIA_FR52 = 180, + CV_SHMEDIA_FR53 = 181, + CV_SHMEDIA_FR54 = 182, + CV_SHMEDIA_FR55 = 183, + CV_SHMEDIA_FR56 = 184, + CV_SHMEDIA_FR57 = 185, + CV_SHMEDIA_FR58 = 186, + CV_SHMEDIA_FR59 = 187, + CV_SHMEDIA_FR60 = 188, + CV_SHMEDIA_FR61 = 189, + CV_SHMEDIA_FR62 = 190, + CV_SHMEDIA_FR63 = 191, + + // Double - 64 bit synonyms for 32bit fp register pairs + // subtract 128 to find first base single register + CV_SHMEDIA_DR0 = 256, + CV_SHMEDIA_DR2 = 258, + CV_SHMEDIA_DR4 = 260, + CV_SHMEDIA_DR6 = 262, + CV_SHMEDIA_DR8 = 264, + CV_SHMEDIA_DR10 = 266, + CV_SHMEDIA_DR12 = 268, + CV_SHMEDIA_DR14 = 270, + CV_SHMEDIA_DR16 = 272, + CV_SHMEDIA_DR18 = 274, + CV_SHMEDIA_DR20 = 276, + CV_SHMEDIA_DR22 = 278, + CV_SHMEDIA_DR24 = 280, + CV_SHMEDIA_DR26 = 282, + CV_SHMEDIA_DR28 = 284, + CV_SHMEDIA_DR30 = 286, + CV_SHMEDIA_DR32 = 288, + CV_SHMEDIA_DR34 = 290, + CV_SHMEDIA_DR36 = 292, + CV_SHMEDIA_DR38 = 294, + CV_SHMEDIA_DR40 = 296, + CV_SHMEDIA_DR42 = 298, + CV_SHMEDIA_DR44 = 300, + CV_SHMEDIA_DR46 = 302, + CV_SHMEDIA_DR48 = 304, + CV_SHMEDIA_DR50 = 306, + CV_SHMEDIA_DR52 = 308, + CV_SHMEDIA_DR54 = 310, + CV_SHMEDIA_DR56 = 312, + CV_SHMEDIA_DR58 = 314, + CV_SHMEDIA_DR60 = 316, + CV_SHMEDIA_DR62 = 318, + + // Vector - 128 bit synonyms for 32bit fp register quads + // subtract 384 to find first base single register + CV_SHMEDIA_FV0 = 512, + CV_SHMEDIA_FV4 = 516, + CV_SHMEDIA_FV8 = 520, + CV_SHMEDIA_FV12 = 524, + CV_SHMEDIA_FV16 = 528, + CV_SHMEDIA_FV20 = 532, + CV_SHMEDIA_FV24 = 536, + CV_SHMEDIA_FV28 = 540, + CV_SHMEDIA_FV32 = 544, + CV_SHMEDIA_FV36 = 548, + CV_SHMEDIA_FV40 = 552, + CV_SHMEDIA_FV44 = 556, + CV_SHMEDIA_FV48 = 560, + CV_SHMEDIA_FV52 = 564, + CV_SHMEDIA_FV56 = 568, + CV_SHMEDIA_FV60 = 572, + + // Matrix - 512 bit synonyms for 16 adjacent 32bit fp registers + // subtract 896 to find first base single register + CV_SHMEDIA_MTRX0 = 1024, + CV_SHMEDIA_MTRX16 = 1040, + CV_SHMEDIA_MTRX32 = 1056, + CV_SHMEDIA_MTRX48 = 1072, + + // Control - Implementation defined 64bit control registers + CV_SHMEDIA_CR0 = 2000, + CV_SHMEDIA_CR1 = 2001, + CV_SHMEDIA_CR2 = 2002, + CV_SHMEDIA_CR3 = 2003, + CV_SHMEDIA_CR4 = 2004, + CV_SHMEDIA_CR5 = 2005, + CV_SHMEDIA_CR6 = 2006, + CV_SHMEDIA_CR7 = 2007, + CV_SHMEDIA_CR8 = 2008, + CV_SHMEDIA_CR9 = 2009, + CV_SHMEDIA_CR10 = 2010, + CV_SHMEDIA_CR11 = 2011, + CV_SHMEDIA_CR12 = 2012, + CV_SHMEDIA_CR13 = 2013, + CV_SHMEDIA_CR14 = 2014, + CV_SHMEDIA_CR15 = 2015, + CV_SHMEDIA_CR16 = 2016, + CV_SHMEDIA_CR17 = 2017, + CV_SHMEDIA_CR18 = 2018, + CV_SHMEDIA_CR19 = 2019, + CV_SHMEDIA_CR20 = 2020, + CV_SHMEDIA_CR21 = 2021, + CV_SHMEDIA_CR22 = 2022, + CV_SHMEDIA_CR23 = 2023, + CV_SHMEDIA_CR24 = 2024, + CV_SHMEDIA_CR25 = 2025, + CV_SHMEDIA_CR26 = 2026, + CV_SHMEDIA_CR27 = 2027, + CV_SHMEDIA_CR28 = 2028, + CV_SHMEDIA_CR29 = 2029, + CV_SHMEDIA_CR30 = 2030, + CV_SHMEDIA_CR31 = 2031, + CV_SHMEDIA_CR32 = 2032, + CV_SHMEDIA_CR33 = 2033, + CV_SHMEDIA_CR34 = 2034, + CV_SHMEDIA_CR35 = 2035, + CV_SHMEDIA_CR36 = 2036, + CV_SHMEDIA_CR37 = 2037, + CV_SHMEDIA_CR38 = 2038, + CV_SHMEDIA_CR39 = 2039, + CV_SHMEDIA_CR40 = 2040, + CV_SHMEDIA_CR41 = 2041, + CV_SHMEDIA_CR42 = 2042, + CV_SHMEDIA_CR43 = 2043, + CV_SHMEDIA_CR44 = 2044, + CV_SHMEDIA_CR45 = 2045, + CV_SHMEDIA_CR46 = 2046, + CV_SHMEDIA_CR47 = 2047, + CV_SHMEDIA_CR48 = 2048, + CV_SHMEDIA_CR49 = 2049, + CV_SHMEDIA_CR50 = 2050, + CV_SHMEDIA_CR51 = 2051, + CV_SHMEDIA_CR52 = 2052, + CV_SHMEDIA_CR53 = 2053, + CV_SHMEDIA_CR54 = 2054, + CV_SHMEDIA_CR55 = 2055, + CV_SHMEDIA_CR56 = 2056, + CV_SHMEDIA_CR57 = 2057, + CV_SHMEDIA_CR58 = 2058, + CV_SHMEDIA_CR59 = 2059, + CV_SHMEDIA_CR60 = 2060, + CV_SHMEDIA_CR61 = 2061, + CV_SHMEDIA_CR62 = 2062, + CV_SHMEDIA_CR63 = 2063, + + CV_SHMEDIA_FPSCR = 2064, + + // Compact mode synonyms + CV_SHMEDIA_GBR = CV_SHMEDIA_R16, + CV_SHMEDIA_MACL = 90, // synonym for lower 32bits of media R17 + CV_SHMEDIA_MACH = 91, // synonym for upper 32bits of media R17 + CV_SHMEDIA_PR = CV_SHMEDIA_R18, + CV_SHMEDIA_T = 92, // synonym for lowest bit of media R19 + CV_SHMEDIA_FPUL = CV_SHMEDIA_FR32, + CV_SHMEDIA_PC = 93, + CV_SHMEDIA_SR = CV_SHMEDIA_CR0, + + // + // AMD64 registers + // + + CV_AMD64_AL = 1, + CV_AMD64_CL = 2, + CV_AMD64_DL = 3, + CV_AMD64_BL = 4, + CV_AMD64_AH = 5, + CV_AMD64_CH = 6, + CV_AMD64_DH = 7, + CV_AMD64_BH = 8, + CV_AMD64_AX = 9, + CV_AMD64_CX = 10, + CV_AMD64_DX = 11, + CV_AMD64_BX = 12, + CV_AMD64_SP = 13, + CV_AMD64_BP = 14, + CV_AMD64_SI = 15, + CV_AMD64_DI = 16, + CV_AMD64_EAX = 17, + CV_AMD64_ECX = 18, + CV_AMD64_EDX = 19, + CV_AMD64_EBX = 20, + CV_AMD64_ESP = 21, + CV_AMD64_EBP = 22, + CV_AMD64_ESI = 23, + CV_AMD64_EDI = 24, + CV_AMD64_ES = 25, + CV_AMD64_CS = 26, + CV_AMD64_SS = 27, + CV_AMD64_DS = 28, + CV_AMD64_FS = 29, + CV_AMD64_GS = 30, + CV_AMD64_FLAGS = 32, + CV_AMD64_RIP = 33, + CV_AMD64_EFLAGS = 34, + + // Control registers + CV_AMD64_CR0 = 80, + CV_AMD64_CR1 = 81, + CV_AMD64_CR2 = 82, + CV_AMD64_CR3 = 83, + CV_AMD64_CR4 = 84, + CV_AMD64_CR8 = 88, + + // Debug registers + CV_AMD64_DR0 = 90, + CV_AMD64_DR1 = 91, + CV_AMD64_DR2 = 92, + CV_AMD64_DR3 = 93, + CV_AMD64_DR4 = 94, + CV_AMD64_DR5 = 95, + CV_AMD64_DR6 = 96, + CV_AMD64_DR7 = 97, + CV_AMD64_DR8 = 98, + CV_AMD64_DR9 = 99, + CV_AMD64_DR10 = 100, + CV_AMD64_DR11 = 101, + CV_AMD64_DR12 = 102, + CV_AMD64_DR13 = 103, + CV_AMD64_DR14 = 104, + CV_AMD64_DR15 = 105, + + CV_AMD64_GDTR = 110, + CV_AMD64_GDTL = 111, + CV_AMD64_IDTR = 112, + CV_AMD64_IDTL = 113, + CV_AMD64_LDTR = 114, + CV_AMD64_TR = 115, + + CV_AMD64_ST0 = 128, + CV_AMD64_ST1 = 129, + CV_AMD64_ST2 = 130, + CV_AMD64_ST3 = 131, + CV_AMD64_ST4 = 132, + CV_AMD64_ST5 = 133, + CV_AMD64_ST6 = 134, + CV_AMD64_ST7 = 135, + CV_AMD64_CTRL = 136, + CV_AMD64_STAT = 137, + CV_AMD64_TAG = 138, + CV_AMD64_FPIP = 139, + CV_AMD64_FPCS = 140, + CV_AMD64_FPDO = 141, + CV_AMD64_FPDS = 142, + CV_AMD64_ISEM = 143, + CV_AMD64_FPEIP = 144, + CV_AMD64_FPEDO = 145, + + CV_AMD64_MM0 = 146, + CV_AMD64_MM1 = 147, + CV_AMD64_MM2 = 148, + CV_AMD64_MM3 = 149, + CV_AMD64_MM4 = 150, + CV_AMD64_MM5 = 151, + CV_AMD64_MM6 = 152, + CV_AMD64_MM7 = 153, + + CV_AMD64_XMM0 = 154, // KATMAI registers + CV_AMD64_XMM1 = 155, + CV_AMD64_XMM2 = 156, + CV_AMD64_XMM3 = 157, + CV_AMD64_XMM4 = 158, + CV_AMD64_XMM5 = 159, + CV_AMD64_XMM6 = 160, + CV_AMD64_XMM7 = 161, + + CV_AMD64_XMM0_0 = 162, // KATMAI sub-registers + CV_AMD64_XMM0_1 = 163, + CV_AMD64_XMM0_2 = 164, + CV_AMD64_XMM0_3 = 165, + CV_AMD64_XMM1_0 = 166, + CV_AMD64_XMM1_1 = 167, + CV_AMD64_XMM1_2 = 168, + CV_AMD64_XMM1_3 = 169, + CV_AMD64_XMM2_0 = 170, + CV_AMD64_XMM2_1 = 171, + CV_AMD64_XMM2_2 = 172, + CV_AMD64_XMM2_3 = 173, + CV_AMD64_XMM3_0 = 174, + CV_AMD64_XMM3_1 = 175, + CV_AMD64_XMM3_2 = 176, + CV_AMD64_XMM3_3 = 177, + CV_AMD64_XMM4_0 = 178, + CV_AMD64_XMM4_1 = 179, + CV_AMD64_XMM4_2 = 180, + CV_AMD64_XMM4_3 = 181, + CV_AMD64_XMM5_0 = 182, + CV_AMD64_XMM5_1 = 183, + CV_AMD64_XMM5_2 = 184, + CV_AMD64_XMM5_3 = 185, + CV_AMD64_XMM6_0 = 186, + CV_AMD64_XMM6_1 = 187, + CV_AMD64_XMM6_2 = 188, + CV_AMD64_XMM6_3 = 189, + CV_AMD64_XMM7_0 = 190, + CV_AMD64_XMM7_1 = 191, + CV_AMD64_XMM7_2 = 192, + CV_AMD64_XMM7_3 = 193, + + CV_AMD64_XMM0L = 194, + CV_AMD64_XMM1L = 195, + CV_AMD64_XMM2L = 196, + CV_AMD64_XMM3L = 197, + CV_AMD64_XMM4L = 198, + CV_AMD64_XMM5L = 199, + CV_AMD64_XMM6L = 200, + CV_AMD64_XMM7L = 201, + + CV_AMD64_XMM0H = 202, + CV_AMD64_XMM1H = 203, + CV_AMD64_XMM2H = 204, + CV_AMD64_XMM3H = 205, + CV_AMD64_XMM4H = 206, + CV_AMD64_XMM5H = 207, + CV_AMD64_XMM6H = 208, + CV_AMD64_XMM7H = 209, + + CV_AMD64_MXCSR = 211, // XMM status register + + CV_AMD64_EMM0L = 220, // XMM sub-registers (WNI integer) + CV_AMD64_EMM1L = 221, + CV_AMD64_EMM2L = 222, + CV_AMD64_EMM3L = 223, + CV_AMD64_EMM4L = 224, + CV_AMD64_EMM5L = 225, + CV_AMD64_EMM6L = 226, + CV_AMD64_EMM7L = 227, + + CV_AMD64_EMM0H = 228, + CV_AMD64_EMM1H = 229, + CV_AMD64_EMM2H = 230, + CV_AMD64_EMM3H = 231, + CV_AMD64_EMM4H = 232, + CV_AMD64_EMM5H = 233, + CV_AMD64_EMM6H = 234, + CV_AMD64_EMM7H = 235, + + // do not change the order of these regs, first one must be even too + CV_AMD64_MM00 = 236, + CV_AMD64_MM01 = 237, + CV_AMD64_MM10 = 238, + CV_AMD64_MM11 = 239, + CV_AMD64_MM20 = 240, + CV_AMD64_MM21 = 241, + CV_AMD64_MM30 = 242, + CV_AMD64_MM31 = 243, + CV_AMD64_MM40 = 244, + CV_AMD64_MM41 = 245, + CV_AMD64_MM50 = 246, + CV_AMD64_MM51 = 247, + CV_AMD64_MM60 = 248, + CV_AMD64_MM61 = 249, + CV_AMD64_MM70 = 250, + CV_AMD64_MM71 = 251, + + // Extended KATMAI registers + CV_AMD64_XMM8 = 252, // KATMAI registers + CV_AMD64_XMM9 = 253, + CV_AMD64_XMM10 = 254, + CV_AMD64_XMM11 = 255, + CV_AMD64_XMM12 = 256, + CV_AMD64_XMM13 = 257, + CV_AMD64_XMM14 = 258, + CV_AMD64_XMM15 = 259, + + CV_AMD64_XMM8_0 = 260, // KATMAI sub-registers + CV_AMD64_XMM8_1 = 261, + CV_AMD64_XMM8_2 = 262, + CV_AMD64_XMM8_3 = 263, + CV_AMD64_XMM9_0 = 264, + CV_AMD64_XMM9_1 = 265, + CV_AMD64_XMM9_2 = 266, + CV_AMD64_XMM9_3 = 267, + CV_AMD64_XMM10_0 = 268, + CV_AMD64_XMM10_1 = 269, + CV_AMD64_XMM10_2 = 270, + CV_AMD64_XMM10_3 = 271, + CV_AMD64_XMM11_0 = 272, + CV_AMD64_XMM11_1 = 273, + CV_AMD64_XMM11_2 = 274, + CV_AMD64_XMM11_3 = 275, + CV_AMD64_XMM12_0 = 276, + CV_AMD64_XMM12_1 = 277, + CV_AMD64_XMM12_2 = 278, + CV_AMD64_XMM12_3 = 279, + CV_AMD64_XMM13_0 = 280, + CV_AMD64_XMM13_1 = 281, + CV_AMD64_XMM13_2 = 282, + CV_AMD64_XMM13_3 = 283, + CV_AMD64_XMM14_0 = 284, + CV_AMD64_XMM14_1 = 285, + CV_AMD64_XMM14_2 = 286, + CV_AMD64_XMM14_3 = 287, + CV_AMD64_XMM15_0 = 288, + CV_AMD64_XMM15_1 = 289, + CV_AMD64_XMM15_2 = 290, + CV_AMD64_XMM15_3 = 291, + + CV_AMD64_XMM8L = 292, + CV_AMD64_XMM9L = 293, + CV_AMD64_XMM10L = 294, + CV_AMD64_XMM11L = 295, + CV_AMD64_XMM12L = 296, + CV_AMD64_XMM13L = 297, + CV_AMD64_XMM14L = 298, + CV_AMD64_XMM15L = 299, + + CV_AMD64_XMM8H = 300, + CV_AMD64_XMM9H = 301, + CV_AMD64_XMM10H = 302, + CV_AMD64_XMM11H = 303, + CV_AMD64_XMM12H = 304, + CV_AMD64_XMM13H = 305, + CV_AMD64_XMM14H = 306, + CV_AMD64_XMM15H = 307, + + CV_AMD64_EMM8L = 308, // XMM sub-registers (WNI integer) + CV_AMD64_EMM9L = 309, + CV_AMD64_EMM10L = 310, + CV_AMD64_EMM11L = 311, + CV_AMD64_EMM12L = 312, + CV_AMD64_EMM13L = 313, + CV_AMD64_EMM14L = 314, + CV_AMD64_EMM15L = 315, + + CV_AMD64_EMM8H = 316, + CV_AMD64_EMM9H = 317, + CV_AMD64_EMM10H = 318, + CV_AMD64_EMM11H = 319, + CV_AMD64_EMM12H = 320, + CV_AMD64_EMM13H = 321, + CV_AMD64_EMM14H = 322, + CV_AMD64_EMM15H = 323, + + // Low byte forms of some standard registers + CV_AMD64_SIL = 324, + CV_AMD64_DIL = 325, + CV_AMD64_BPL = 326, + CV_AMD64_SPL = 327, + + // 64-bit regular registers + CV_AMD64_RAX = 328, + CV_AMD64_RBX = 329, + CV_AMD64_RCX = 330, + CV_AMD64_RDX = 331, + CV_AMD64_RSI = 332, + CV_AMD64_RDI = 333, + CV_AMD64_RBP = 334, + CV_AMD64_RSP = 335, + + // 64-bit integer registers with 8-, 16-, and 32-bit forms (B, W, and D) + CV_AMD64_R8 = 336, + CV_AMD64_R9 = 337, + CV_AMD64_R10 = 338, + CV_AMD64_R11 = 339, + CV_AMD64_R12 = 340, + CV_AMD64_R13 = 341, + CV_AMD64_R14 = 342, + CV_AMD64_R15 = 343, + + CV_AMD64_R8B = 344, + CV_AMD64_R9B = 345, + CV_AMD64_R10B = 346, + CV_AMD64_R11B = 347, + CV_AMD64_R12B = 348, + CV_AMD64_R13B = 349, + CV_AMD64_R14B = 350, + CV_AMD64_R15B = 351, + + CV_AMD64_R8W = 352, + CV_AMD64_R9W = 353, + CV_AMD64_R10W = 354, + CV_AMD64_R11W = 355, + CV_AMD64_R12W = 356, + CV_AMD64_R13W = 357, + CV_AMD64_R14W = 358, + CV_AMD64_R15W = 359, + + CV_AMD64_R8D = 360, + CV_AMD64_R9D = 361, + CV_AMD64_R10D = 362, + CV_AMD64_R11D = 363, + CV_AMD64_R12D = 364, + CV_AMD64_R13D = 365, + CV_AMD64_R14D = 366, + CV_AMD64_R15D = 367, + + // AVX registers 256 bits + CV_AMD64_YMM0 = 368, + CV_AMD64_YMM1 = 369, + CV_AMD64_YMM2 = 370, + CV_AMD64_YMM3 = 371, + CV_AMD64_YMM4 = 372, + CV_AMD64_YMM5 = 373, + CV_AMD64_YMM6 = 374, + CV_AMD64_YMM7 = 375, + CV_AMD64_YMM8 = 376, + CV_AMD64_YMM9 = 377, + CV_AMD64_YMM10 = 378, + CV_AMD64_YMM11 = 379, + CV_AMD64_YMM12 = 380, + CV_AMD64_YMM13 = 381, + CV_AMD64_YMM14 = 382, + CV_AMD64_YMM15 = 383, + + // AVX registers upper 128 bits + CV_AMD64_YMM0H = 384, + CV_AMD64_YMM1H = 385, + CV_AMD64_YMM2H = 386, + CV_AMD64_YMM3H = 387, + CV_AMD64_YMM4H = 388, + CV_AMD64_YMM5H = 389, + CV_AMD64_YMM6H = 390, + CV_AMD64_YMM7H = 391, + CV_AMD64_YMM8H = 392, + CV_AMD64_YMM9H = 393, + CV_AMD64_YMM10H = 394, + CV_AMD64_YMM11H = 395, + CV_AMD64_YMM12H = 396, + CV_AMD64_YMM13H = 397, + CV_AMD64_YMM14H = 398, + CV_AMD64_YMM15H = 399, + + //Lower/upper 8 bytes of XMM registers. Unlike CV_AMD64_XMM, these + //values reprsesent the bit patterns of the registers as 64-bit integers, not + //the representation of these registers as a double. + CV_AMD64_XMM0IL = 400, + CV_AMD64_XMM1IL = 401, + CV_AMD64_XMM2IL = 402, + CV_AMD64_XMM3IL = 403, + CV_AMD64_XMM4IL = 404, + CV_AMD64_XMM5IL = 405, + CV_AMD64_XMM6IL = 406, + CV_AMD64_XMM7IL = 407, + CV_AMD64_XMM8IL = 408, + CV_AMD64_XMM9IL = 409, + CV_AMD64_XMM10IL = 410, + CV_AMD64_XMM11IL = 411, + CV_AMD64_XMM12IL = 412, + CV_AMD64_XMM13IL = 413, + CV_AMD64_XMM14IL = 414, + CV_AMD64_XMM15IL = 415, + + CV_AMD64_XMM0IH = 416, + CV_AMD64_XMM1IH = 417, + CV_AMD64_XMM2IH = 418, + CV_AMD64_XMM3IH = 419, + CV_AMD64_XMM4IH = 420, + CV_AMD64_XMM5IH = 421, + CV_AMD64_XMM6IH = 422, + CV_AMD64_XMM7IH = 423, + CV_AMD64_XMM8IH = 424, + CV_AMD64_XMM9IH = 425, + CV_AMD64_XMM10IH = 426, + CV_AMD64_XMM11IH = 427, + CV_AMD64_XMM12IH = 428, + CV_AMD64_XMM13IH = 429, + CV_AMD64_XMM14IH = 430, + CV_AMD64_XMM15IH = 431, + + CV_AMD64_YMM0I0 = 432, // AVX integer registers + CV_AMD64_YMM0I1 = 433, + CV_AMD64_YMM0I2 = 434, + CV_AMD64_YMM0I3 = 435, + CV_AMD64_YMM1I0 = 436, + CV_AMD64_YMM1I1 = 437, + CV_AMD64_YMM1I2 = 438, + CV_AMD64_YMM1I3 = 439, + CV_AMD64_YMM2I0 = 440, + CV_AMD64_YMM2I1 = 441, + CV_AMD64_YMM2I2 = 442, + CV_AMD64_YMM2I3 = 443, + CV_AMD64_YMM3I0 = 444, + CV_AMD64_YMM3I1 = 445, + CV_AMD64_YMM3I2 = 446, + CV_AMD64_YMM3I3 = 447, + CV_AMD64_YMM4I0 = 448, + CV_AMD64_YMM4I1 = 449, + CV_AMD64_YMM4I2 = 450, + CV_AMD64_YMM4I3 = 451, + CV_AMD64_YMM5I0 = 452, + CV_AMD64_YMM5I1 = 453, + CV_AMD64_YMM5I2 = 454, + CV_AMD64_YMM5I3 = 455, + CV_AMD64_YMM6I0 = 456, + CV_AMD64_YMM6I1 = 457, + CV_AMD64_YMM6I2 = 458, + CV_AMD64_YMM6I3 = 459, + CV_AMD64_YMM7I0 = 460, + CV_AMD64_YMM7I1 = 461, + CV_AMD64_YMM7I2 = 462, + CV_AMD64_YMM7I3 = 463, + CV_AMD64_YMM8I0 = 464, + CV_AMD64_YMM8I1 = 465, + CV_AMD64_YMM8I2 = 466, + CV_AMD64_YMM8I3 = 467, + CV_AMD64_YMM9I0 = 468, + CV_AMD64_YMM9I1 = 469, + CV_AMD64_YMM9I2 = 470, + CV_AMD64_YMM9I3 = 471, + CV_AMD64_YMM10I0 = 472, + CV_AMD64_YMM10I1 = 473, + CV_AMD64_YMM10I2 = 474, + CV_AMD64_YMM10I3 = 475, + CV_AMD64_YMM11I0 = 476, + CV_AMD64_YMM11I1 = 477, + CV_AMD64_YMM11I2 = 478, + CV_AMD64_YMM11I3 = 479, + CV_AMD64_YMM12I0 = 480, + CV_AMD64_YMM12I1 = 481, + CV_AMD64_YMM12I2 = 482, + CV_AMD64_YMM12I3 = 483, + CV_AMD64_YMM13I0 = 484, + CV_AMD64_YMM13I1 = 485, + CV_AMD64_YMM13I2 = 486, + CV_AMD64_YMM13I3 = 487, + CV_AMD64_YMM14I0 = 488, + CV_AMD64_YMM14I1 = 489, + CV_AMD64_YMM14I2 = 490, + CV_AMD64_YMM14I3 = 491, + CV_AMD64_YMM15I0 = 492, + CV_AMD64_YMM15I1 = 493, + CV_AMD64_YMM15I2 = 494, + CV_AMD64_YMM15I3 = 495, + + CV_AMD64_YMM0F0 = 496, // AVX floating-point single precise registers + CV_AMD64_YMM0F1 = 497, + CV_AMD64_YMM0F2 = 498, + CV_AMD64_YMM0F3 = 499, + CV_AMD64_YMM0F4 = 500, + CV_AMD64_YMM0F5 = 501, + CV_AMD64_YMM0F6 = 502, + CV_AMD64_YMM0F7 = 503, + CV_AMD64_YMM1F0 = 504, + CV_AMD64_YMM1F1 = 505, + CV_AMD64_YMM1F2 = 506, + CV_AMD64_YMM1F3 = 507, + CV_AMD64_YMM1F4 = 508, + CV_AMD64_YMM1F5 = 509, + CV_AMD64_YMM1F6 = 510, + CV_AMD64_YMM1F7 = 511, + CV_AMD64_YMM2F0 = 512, + CV_AMD64_YMM2F1 = 513, + CV_AMD64_YMM2F2 = 514, + CV_AMD64_YMM2F3 = 515, + CV_AMD64_YMM2F4 = 516, + CV_AMD64_YMM2F5 = 517, + CV_AMD64_YMM2F6 = 518, + CV_AMD64_YMM2F7 = 519, + CV_AMD64_YMM3F0 = 520, + CV_AMD64_YMM3F1 = 521, + CV_AMD64_YMM3F2 = 522, + CV_AMD64_YMM3F3 = 523, + CV_AMD64_YMM3F4 = 524, + CV_AMD64_YMM3F5 = 525, + CV_AMD64_YMM3F6 = 526, + CV_AMD64_YMM3F7 = 527, + CV_AMD64_YMM4F0 = 528, + CV_AMD64_YMM4F1 = 529, + CV_AMD64_YMM4F2 = 530, + CV_AMD64_YMM4F3 = 531, + CV_AMD64_YMM4F4 = 532, + CV_AMD64_YMM4F5 = 533, + CV_AMD64_YMM4F6 = 534, + CV_AMD64_YMM4F7 = 535, + CV_AMD64_YMM5F0 = 536, + CV_AMD64_YMM5F1 = 537, + CV_AMD64_YMM5F2 = 538, + CV_AMD64_YMM5F3 = 539, + CV_AMD64_YMM5F4 = 540, + CV_AMD64_YMM5F5 = 541, + CV_AMD64_YMM5F6 = 542, + CV_AMD64_YMM5F7 = 543, + CV_AMD64_YMM6F0 = 544, + CV_AMD64_YMM6F1 = 545, + CV_AMD64_YMM6F2 = 546, + CV_AMD64_YMM6F3 = 547, + CV_AMD64_YMM6F4 = 548, + CV_AMD64_YMM6F5 = 549, + CV_AMD64_YMM6F6 = 550, + CV_AMD64_YMM6F7 = 551, + CV_AMD64_YMM7F0 = 552, + CV_AMD64_YMM7F1 = 553, + CV_AMD64_YMM7F2 = 554, + CV_AMD64_YMM7F3 = 555, + CV_AMD64_YMM7F4 = 556, + CV_AMD64_YMM7F5 = 557, + CV_AMD64_YMM7F6 = 558, + CV_AMD64_YMM7F7 = 559, + CV_AMD64_YMM8F0 = 560, + CV_AMD64_YMM8F1 = 561, + CV_AMD64_YMM8F2 = 562, + CV_AMD64_YMM8F3 = 563, + CV_AMD64_YMM8F4 = 564, + CV_AMD64_YMM8F5 = 565, + CV_AMD64_YMM8F6 = 566, + CV_AMD64_YMM8F7 = 567, + CV_AMD64_YMM9F0 = 568, + CV_AMD64_YMM9F1 = 569, + CV_AMD64_YMM9F2 = 570, + CV_AMD64_YMM9F3 = 571, + CV_AMD64_YMM9F4 = 572, + CV_AMD64_YMM9F5 = 573, + CV_AMD64_YMM9F6 = 574, + CV_AMD64_YMM9F7 = 575, + CV_AMD64_YMM10F0 = 576, + CV_AMD64_YMM10F1 = 577, + CV_AMD64_YMM10F2 = 578, + CV_AMD64_YMM10F3 = 579, + CV_AMD64_YMM10F4 = 580, + CV_AMD64_YMM10F5 = 581, + CV_AMD64_YMM10F6 = 582, + CV_AMD64_YMM10F7 = 583, + CV_AMD64_YMM11F0 = 584, + CV_AMD64_YMM11F1 = 585, + CV_AMD64_YMM11F2 = 586, + CV_AMD64_YMM11F3 = 587, + CV_AMD64_YMM11F4 = 588, + CV_AMD64_YMM11F5 = 589, + CV_AMD64_YMM11F6 = 590, + CV_AMD64_YMM11F7 = 591, + CV_AMD64_YMM12F0 = 592, + CV_AMD64_YMM12F1 = 593, + CV_AMD64_YMM12F2 = 594, + CV_AMD64_YMM12F3 = 595, + CV_AMD64_YMM12F4 = 596, + CV_AMD64_YMM12F5 = 597, + CV_AMD64_YMM12F6 = 598, + CV_AMD64_YMM12F7 = 599, + CV_AMD64_YMM13F0 = 600, + CV_AMD64_YMM13F1 = 601, + CV_AMD64_YMM13F2 = 602, + CV_AMD64_YMM13F3 = 603, + CV_AMD64_YMM13F4 = 604, + CV_AMD64_YMM13F5 = 605, + CV_AMD64_YMM13F6 = 606, + CV_AMD64_YMM13F7 = 607, + CV_AMD64_YMM14F0 = 608, + CV_AMD64_YMM14F1 = 609, + CV_AMD64_YMM14F2 = 610, + CV_AMD64_YMM14F3 = 611, + CV_AMD64_YMM14F4 = 612, + CV_AMD64_YMM14F5 = 613, + CV_AMD64_YMM14F6 = 614, + CV_AMD64_YMM14F7 = 615, + CV_AMD64_YMM15F0 = 616, + CV_AMD64_YMM15F1 = 617, + CV_AMD64_YMM15F2 = 618, + CV_AMD64_YMM15F3 = 619, + CV_AMD64_YMM15F4 = 620, + CV_AMD64_YMM15F5 = 621, + CV_AMD64_YMM15F6 = 622, + CV_AMD64_YMM15F7 = 623, + + CV_AMD64_YMM0D0 = 624, // AVX floating-point double precise registers + CV_AMD64_YMM0D1 = 625, + CV_AMD64_YMM0D2 = 626, + CV_AMD64_YMM0D3 = 627, + CV_AMD64_YMM1D0 = 628, + CV_AMD64_YMM1D1 = 629, + CV_AMD64_YMM1D2 = 630, + CV_AMD64_YMM1D3 = 631, + CV_AMD64_YMM2D0 = 632, + CV_AMD64_YMM2D1 = 633, + CV_AMD64_YMM2D2 = 634, + CV_AMD64_YMM2D3 = 635, + CV_AMD64_YMM3D0 = 636, + CV_AMD64_YMM3D1 = 637, + CV_AMD64_YMM3D2 = 638, + CV_AMD64_YMM3D3 = 639, + CV_AMD64_YMM4D0 = 640, + CV_AMD64_YMM4D1 = 641, + CV_AMD64_YMM4D2 = 642, + CV_AMD64_YMM4D3 = 643, + CV_AMD64_YMM5D0 = 644, + CV_AMD64_YMM5D1 = 645, + CV_AMD64_YMM5D2 = 646, + CV_AMD64_YMM5D3 = 647, + CV_AMD64_YMM6D0 = 648, + CV_AMD64_YMM6D1 = 649, + CV_AMD64_YMM6D2 = 650, + CV_AMD64_YMM6D3 = 651, + CV_AMD64_YMM7D0 = 652, + CV_AMD64_YMM7D1 = 653, + CV_AMD64_YMM7D2 = 654, + CV_AMD64_YMM7D3 = 655, + CV_AMD64_YMM8D0 = 656, + CV_AMD64_YMM8D1 = 657, + CV_AMD64_YMM8D2 = 658, + CV_AMD64_YMM8D3 = 659, + CV_AMD64_YMM9D0 = 660, + CV_AMD64_YMM9D1 = 661, + CV_AMD64_YMM9D2 = 662, + CV_AMD64_YMM9D3 = 663, + CV_AMD64_YMM10D0 = 664, + CV_AMD64_YMM10D1 = 665, + CV_AMD64_YMM10D2 = 666, + CV_AMD64_YMM10D3 = 667, + CV_AMD64_YMM11D0 = 668, + CV_AMD64_YMM11D1 = 669, + CV_AMD64_YMM11D2 = 670, + CV_AMD64_YMM11D3 = 671, + CV_AMD64_YMM12D0 = 672, + CV_AMD64_YMM12D1 = 673, + CV_AMD64_YMM12D2 = 674, + CV_AMD64_YMM12D3 = 675, + CV_AMD64_YMM13D0 = 676, + CV_AMD64_YMM13D1 = 677, + CV_AMD64_YMM13D2 = 678, + CV_AMD64_YMM13D3 = 679, + CV_AMD64_YMM14D0 = 680, + CV_AMD64_YMM14D1 = 681, + CV_AMD64_YMM14D2 = 682, + CV_AMD64_YMM14D3 = 683, + CV_AMD64_YMM15D0 = 684, + CV_AMD64_YMM15D1 = 685, + CV_AMD64_YMM15D2 = 686, + CV_AMD64_YMM15D3 = 687 + + + // Note: Next set of platform registers need to go into a new enum... + // this one is above 44K now. + +} CV_HREG_e; + +typedef enum CV_HLSLREG_e { + CV_HLSLREG_TEMP = 0, + CV_HLSLREG_INPUT = 1, + CV_HLSLREG_OUTPUT = 2, + CV_HLSLREG_INDEXABLE_TEMP = 3, + CV_HLSLREG_IMMEDIATE32 = 4, + CV_HLSLREG_IMMEDIATE64 = 5, + CV_HLSLREG_SAMPLER = 6, + CV_HLSLREG_RESOURCE = 7, + CV_HLSLREG_CONSTANT_BUFFER = 8, + CV_HLSLREG_IMMEDIATE_CONSTANT_BUFFER = 9, + CV_HLSLREG_LABEL = 10, + CV_HLSLREG_INPUT_PRIMITIVEID = 11, + CV_HLSLREG_OUTPUT_DEPTH = 12, + CV_HLSLREG_NULL = 13, + CV_HLSLREG_RASTERIZER = 14, + CV_HLSLREG_OUTPUT_COVERAGE_MASK = 15, + CV_HLSLREG_STREAM = 16, + CV_HLSLREG_FUNCTION_BODY = 17, + CV_HLSLREG_FUNCTION_TABLE = 18, + CV_HLSLREG_INTERFACE = 19, + CV_HLSLREG_FUNCTION_INPUT = 20, + CV_HLSLREG_FUNCTION_OUTPUT = 21, + CV_HLSLREG_OUTPUT_CONTROL_POINT_ID = 22, + CV_HLSLREG_INPUT_FORK_INSTANCE_ID = 23, + CV_HLSLREG_INPUT_JOIN_INSTANCE_ID = 24, + CV_HLSLREG_INPUT_CONTROL_POINT = 25, + CV_HLSLREG_OUTPUT_CONTROL_POINT = 26, + CV_HLSLREG_INPUT_PATCH_CONSTANT = 27, + CV_HLSLREG_INPUT_DOMAIN_POINT = 28, + CV_HLSLREG_THIS_POINTER = 29, + CV_HLSLREG_UNORDERED_ACCESS_VIEW = 30, + CV_HLSLREG_THREAD_GROUP_SHARED_MEMORY = 31, + CV_HLSLREG_INPUT_THREAD_ID = 32, + CV_HLSLREG_INPUT_THREAD_GROUP_ID = 33, + CV_HLSLREG_INPUT_THREAD_ID_IN_GROUP = 34, + CV_HLSLREG_INPUT_COVERAGE_MASK = 35, + CV_HLSLREG_INPUT_THREAD_ID_IN_GROUP_FLATTENED = 36, + CV_HLSLREG_INPUT_GS_INSTANCE_ID = 37, + CV_HLSLREG_OUTPUT_DEPTH_GREATER_EQUAL = 38, + CV_HLSLREG_OUTPUT_DEPTH_LESS_EQUAL = 39, + CV_HLSLREG_CYCLE_COUNTER = 40, +} CV_HLSLREG_e; + +enum StackFrameTypeEnum +{ + FrameTypeFPO, // Frame pointer omitted, FPO info available + FrameTypeTrap, // Kernel Trap frame + FrameTypeTSS, // Kernel Trap frame + FrameTypeStandard, // Standard EBP stackframe + FrameTypeFrameData, // Frame pointer omitted, FrameData info available + + FrameTypeUnknown = -1, // Frame which does not have any debug info +}; + +enum MemoryTypeEnum +{ + MemTypeCode, // Read only code memory + MemTypeData, // Read only data/stack memory + MemTypeStack, // Read only stack memory + MemTypeCodeOnHeap, // Read only memory for code generated on heap by runtime + + MemTypeAny = -1, +}; + +typedef enum CV_HLSLMemorySpace_e +{ + // HLSL specific memory spaces + + CV_HLSL_MEMSPACE_DATA = 0x00, + CV_HLSL_MEMSPACE_SAMPLER = 0x01, + CV_HLSL_MEMSPACE_RESOURCE = 0x02, + CV_HLSL_MEMSPACE_RWRESOURCE = 0x03, + + CV_HLSL_MEMSPACE_MAX = 0x0F, +} CV_HLSLMemorySpace_e; + +#endif diff --git a/llvm/tools/objwriter/debugInfo/codeView/codeViewTypeBuilder.cpp b/llvm/tools/objwriter/debugInfo/codeView/codeViewTypeBuilder.cpp new file mode 100644 index 00000000000000..a4f34e22573d98 --- /dev/null +++ b/llvm/tools/objwriter/debugInfo/codeView/codeViewTypeBuilder.cpp @@ -0,0 +1,344 @@ +//===---- codeViewTypeBuilder.cpp -------------------------------*- C++ -*-===// +// +// type builder implementation using codeview::TypeTableBuilder +// +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +//===----------------------------------------------------------------------===// + +#include "codeViewTypeBuilder.h" +#include "llvm/BinaryFormat/COFF.h" +#include +#include + +UserDefinedCodeViewTypesBuilder::UserDefinedCodeViewTypesBuilder() + : Allocator(), TypeTable(Allocator) +{ + // We pretend that the MethodTable pointer in System.Object is VTable shape. + // We use the same "Vtable" for all types because the vtable shape debug + // record is not expressive enough to capture our vtable shape (where the + // vtable slots don't start at the beginning of the vtable). + VFTableShapeRecord vfTableShape(TypeRecordKind::VFTableShape); + ClassVTableTypeIndex = TypeTable.writeLeafType(vfTableShape); + + PointerRecord ptrToVfTableShape(ClassVTableTypeIndex, + TargetPointerSize == 8 ? PointerKind::Near64 : PointerKind::Near32, + PointerMode::LValueReference, + PointerOptions::None, + 0); + + VFuncTabTypeIndex = TypeTable.writeLeafType(ptrToVfTableShape); +} + +void UserDefinedCodeViewTypesBuilder::EmitCodeViewMagicVersion() { + Streamer->emitValueToAlignment(Align(4)); + Streamer->AddComment("Debug section magic"); + Streamer->emitIntValue(COFF::DEBUG_SECTION_MAGIC, 4); +} + +ClassOptions UserDefinedCodeViewTypesBuilder::GetCommonClassOptions() { + return ClassOptions(); +} + +void UserDefinedCodeViewTypesBuilder::EmitTypeInformation( + MCSection *TypeSection, + MCSection *StrSection) { + + if (TypeTable.empty()) + return; + + Streamer->switchSection(TypeSection); + EmitCodeViewMagicVersion(); + + TypeTable.ForEachRecord([&](TypeIndex FieldTypeIndex, + CVRecord Record) { + StringRef S(reinterpret_cast(Record.data().data()), Record.data().size()); + Streamer->emitBinaryData(S); + }); +} + +unsigned UserDefinedCodeViewTypesBuilder::GetEnumFieldListType( + uint64 Count, const EnumRecordTypeDescriptor *TypeRecords) { + ContinuationRecordBuilder CRB; + CRB.begin(ContinuationRecordKind::FieldList); +#ifndef NDEBUG + uint64 MaxInt = (unsigned int)-1; + assert(Count <= MaxInt && "There are too many fields inside enum"); +#endif + for (int i = 0; i < (int)Count; ++i) { + EnumRecordTypeDescriptor record = TypeRecords[i]; + EnumeratorRecord ER(MemberAccess::Public, APSInt::getUnsigned(record.Value), + record.Name); + CRB.writeMemberType(ER); + } + return TypeTable.insertRecord(CRB).getIndex(); +} + +unsigned UserDefinedCodeViewTypesBuilder::GetEnumTypeIndex( + const EnumTypeDescriptor &TypeDescriptor, + const EnumRecordTypeDescriptor *TypeRecords) { + + ClassOptions CO = GetCommonClassOptions(); + unsigned FieldListIndex = + GetEnumFieldListType(TypeDescriptor.ElementCount, TypeRecords); + TypeIndex FieldListIndexType = TypeIndex(FieldListIndex); + TypeIndex ElementTypeIndex = TypeIndex(TypeDescriptor.ElementType); + + EnumRecord EnumRecord(TypeDescriptor.ElementCount, CO, FieldListIndexType, + TypeDescriptor.Name, StringRef(), + ElementTypeIndex); + + TypeIndex Type = TypeTable.writeLeafType(EnumRecord); + UserDefinedTypes.push_back(std::make_pair(TypeDescriptor.Name, Type.getIndex())); + return Type.getIndex(); +} + +unsigned UserDefinedCodeViewTypesBuilder::GetClassTypeIndex( + const ClassTypeDescriptor &ClassDescriptor) { + TypeRecordKind Kind = + ClassDescriptor.IsStruct ? TypeRecordKind::Struct : TypeRecordKind::Class; + ClassOptions CO = ClassOptions::ForwardReference | GetCommonClassOptions(); + + ClassRecord CR(Kind, 0, CO, TypeIndex(), TypeIndex(), TypeIndex(), 0, + ClassDescriptor.Name, StringRef()); + TypeIndex FwdDeclTI = TypeTable.writeLeafType(CR); + return FwdDeclTI.getIndex(); +} + +unsigned UserDefinedCodeViewTypesBuilder::GetCompleteClassTypeIndex( + const ClassTypeDescriptor &ClassDescriptor, + const ClassFieldsTypeDescriptior &ClassFieldsDescriptor, + const DataFieldDescriptor *FieldsDescriptors, + const StaticDataFieldDescriptor *StaticsDescriptors) { + + ContinuationRecordBuilder CRB; + CRB.begin(ContinuationRecordKind::FieldList); + + uint16_t memberCount = 0; + if (ClassDescriptor.BaseClassId != 0) { + memberCount++; + AddBaseClass(CRB, ClassDescriptor.BaseClassId); + } + else if (!ClassDescriptor.IsStruct) { + memberCount++; + AddClassVTShape(CRB); + } + + for (int i = 0; i < ClassFieldsDescriptor.FieldsCount; ++i) { + DataFieldDescriptor desc = FieldsDescriptors[i]; + MemberAccess Access = MemberAccess::Public; + TypeIndex MemberBaseType(desc.FieldTypeIndex); + if (desc.Offset == 0xFFFFFFFF) + { + StaticDataMemberRecord SDMR(Access, MemberBaseType, desc.Name); + CRB.writeMemberType(SDMR); + } + else + { + int MemberOffsetInBytes = desc.Offset; + DataMemberRecord DMR(Access, MemberBaseType, MemberOffsetInBytes, + desc.Name); + CRB.writeMemberType(DMR); + } + memberCount++; + } + TypeIndex FieldListIndex = TypeTable.insertRecord(CRB); + TypeRecordKind Kind = + ClassDescriptor.IsStruct ? TypeRecordKind::Struct : TypeRecordKind::Class; + ClassOptions CO = GetCommonClassOptions(); + ClassRecord CR(Kind, memberCount, CO, FieldListIndex, + TypeIndex(), TypeIndex(), ClassFieldsDescriptor.Size, + ClassDescriptor.Name, StringRef()); + TypeIndex ClassIndex = TypeTable.writeLeafType(CR); + + UserDefinedTypes.push_back(std::make_pair(ClassDescriptor.Name, ClassIndex.getIndex())); + + return ClassIndex.getIndex(); +} + +unsigned UserDefinedCodeViewTypesBuilder::GetArrayTypeIndex( + const ClassTypeDescriptor &ClassDescriptor, + const ArrayTypeDescriptor &ArrayDescriptor) { + ContinuationRecordBuilder CRB; + CRB.begin(ContinuationRecordKind::FieldList); + + unsigned Offset = 0; + unsigned FieldsCount = 0; + + assert(ClassDescriptor.BaseClassId != 0); + + AddBaseClass(CRB, ClassDescriptor.BaseClassId); + FieldsCount++; + Offset += TargetPointerSize; + + MemberAccess Access = MemberAccess::Public; + TypeIndex IndexType = TypeIndex(SimpleTypeKind::Int32); + DataMemberRecord CountDMR(Access, IndexType, Offset, "count"); + CRB.writeMemberType(CountDMR); + FieldsCount++; + Offset += TargetPointerSize; + + if (ArrayDescriptor.IsMultiDimensional == 1) { + for (unsigned i = 0; i < ArrayDescriptor.Rank; ++i) { + DataMemberRecord LengthDMR(Access, TypeIndex(SimpleTypeKind::Int32), + Offset, ArrayDimentions.GetLengthName(i)); + CRB.writeMemberType(LengthDMR); + FieldsCount++; + Offset += 4; + } + + for (unsigned i = 0; i < ArrayDescriptor.Rank; ++i) { + DataMemberRecord BoundsDMR(Access, TypeIndex(SimpleTypeKind::Int32), + Offset, ArrayDimentions.GetBoundsName(i)); + CRB.writeMemberType(BoundsDMR); + FieldsCount++; + Offset += 4; + } + } + + TypeIndex ElementTypeIndex = TypeIndex(ArrayDescriptor.ElementType); + ArrayRecord AR(ElementTypeIndex, IndexType, ArrayDescriptor.Size, ""); + TypeIndex ArrayIndex = TypeTable.writeLeafType(AR); + DataMemberRecord ArrayDMR(Access, ArrayIndex, Offset, "values"); + CRB.writeMemberType(ArrayDMR); + FieldsCount++; + + TypeIndex FieldListIndex = TypeTable.insertRecord(CRB); + + assert(ClassDescriptor.IsStruct == false); + TypeRecordKind Kind = TypeRecordKind::Class; + ClassOptions CO = GetCommonClassOptions(); + ClassRecord CR(Kind, FieldsCount, CO, FieldListIndex, TypeIndex(), + TypeIndex(), ArrayDescriptor.Size, ClassDescriptor.Name, + StringRef()); + TypeIndex ClassIndex = TypeTable.writeLeafType(CR); + + UserDefinedTypes.push_back(std::make_pair(ClassDescriptor.Name, ClassIndex.getIndex())); + + return ClassIndex.getIndex(); +} + +unsigned UserDefinedCodeViewTypesBuilder::GetPointerTypeIndex(const PointerTypeDescriptor& PointerDescriptor) +{ + uint32_t elementType = PointerDescriptor.ElementType; + PointerKind pointerKind = PointerDescriptor.Is64Bit ? PointerKind::Near64 : PointerKind::Near32; + PointerMode pointerMode = PointerDescriptor.IsReference ? PointerMode::LValueReference : PointerMode::Pointer; + PointerOptions pointerOptions = PointerDescriptor.IsConst ? PointerOptions::Const : PointerOptions::None; + + PointerRecord PointerToClass(TypeIndex(elementType), pointerKind, pointerMode, pointerOptions, 0); + TypeIndex PointerIndex = TypeTable.writeLeafType(PointerToClass); + return PointerIndex.getIndex(); +} + +unsigned UserDefinedCodeViewTypesBuilder::GetMemberFunctionTypeIndex(const MemberFunctionTypeDescriptor& MemberDescriptor, + uint32_t const *const ArgumentTypes) +{ + std::vector argumentTypes; + argumentTypes.reserve(MemberDescriptor.NumberOfArguments); + for (uint16_t iArgument = 0; iArgument < MemberDescriptor.NumberOfArguments; iArgument++) + { + argumentTypes.emplace_back(ArgumentTypes[iArgument]); + } + + ArgListRecord ArgList(TypeRecordKind::ArgList, argumentTypes); + TypeIndex ArgumentList = TypeTable.writeLeafType(ArgList); + + MemberFunctionRecord MemberFunction(TypeIndex(MemberDescriptor.ReturnType), + TypeIndex(MemberDescriptor.ContainingClass), + TypeIndex(MemberDescriptor.TypeIndexOfThisPointer), + CallingConvention(MemberDescriptor.CallingConvention), + FunctionOptions::None, MemberDescriptor.NumberOfArguments, + ArgumentList, + MemberDescriptor.ThisAdjust); + + TypeIndex MemberFunctionIndex = TypeTable.writeLeafType(MemberFunction); + return MemberFunctionIndex.getIndex(); +} + +unsigned UserDefinedCodeViewTypesBuilder::GetMemberFunctionId(const MemberFunctionIdTypeDescriptor& MemberIdDescriptor) +{ + MemberFuncIdRecord MemberFuncId(TypeIndex(MemberIdDescriptor.MemberFunction), TypeIndex(MemberIdDescriptor.ParentClass), MemberIdDescriptor.Name); + TypeIndex MemberFuncIdIndex = TypeTable.writeLeafType(MemberFuncId); + return MemberFuncIdIndex.getIndex(); +} + +unsigned UserDefinedCodeViewTypesBuilder::GetPrimitiveTypeIndex(PrimitiveTypeFlags Type) { + switch (Type) { + case PrimitiveTypeFlags::Void: + return TypeIndex::Void().getIndex(); + case PrimitiveTypeFlags::Boolean: + return TypeIndex(SimpleTypeKind::Boolean8).getIndex(); + case PrimitiveTypeFlags::Char: + return TypeIndex::WideCharacter().getIndex(); + case PrimitiveTypeFlags::SByte: + return TypeIndex(SimpleTypeKind::SByte).getIndex(); + case PrimitiveTypeFlags::Byte: + return TypeIndex(SimpleTypeKind::Byte).getIndex(); + case PrimitiveTypeFlags::Int16: + return TypeIndex(SimpleTypeKind::Int16).getIndex(); + case PrimitiveTypeFlags::UInt16: + return TypeIndex(SimpleTypeKind::UInt16).getIndex(); + case PrimitiveTypeFlags::Int32: + return TypeIndex::Int32().getIndex(); + case PrimitiveTypeFlags::UInt32: + return TypeIndex::UInt32().getIndex(); + case PrimitiveTypeFlags::Int64: + return TypeIndex::Int64().getIndex(); + case PrimitiveTypeFlags::UInt64: + return TypeIndex::UInt64().getIndex(); + case PrimitiveTypeFlags::Single: + return TypeIndex::Float32().getIndex(); + case PrimitiveTypeFlags::Double: + return TypeIndex::Float64().getIndex(); + case PrimitiveTypeFlags::IntPtr: + case PrimitiveTypeFlags::UIntPtr: + return TargetPointerSize == 4 ? TypeIndex::VoidPointer32().getIndex() : + TypeIndex::VoidPointer64().getIndex(); + default: + assert(false && "Unexpected type"); + return 0; + } +} + +void UserDefinedCodeViewTypesBuilder::AddBaseClass(ContinuationRecordBuilder &CRB, + unsigned BaseClassId) { + MemberAttributes def; + TypeIndex BaseTypeIndex(BaseClassId); + BaseClassRecord BCR(def, BaseTypeIndex, 0); + CRB.writeMemberType(BCR); +} + +void UserDefinedCodeViewTypesBuilder::AddClassVTShape(ContinuationRecordBuilder &CRB) { + VFPtrRecord VfPtr(VFuncTabTypeIndex); + CRB.writeMemberType(VfPtr); +} + +const char *ArrayDimensionsDescriptor::GetLengthName(unsigned index) { + if (Lengths.size() <= index) { + Resize(index + 1); + } + return Lengths[index].c_str(); +} + +const char *ArrayDimensionsDescriptor::GetBoundsName(unsigned index) { + if (Bounds.size() <= index) { + Resize(index); + } + return Bounds[index].c_str(); +} + +void ArrayDimensionsDescriptor::Resize(unsigned NewSize) { + unsigned OldSize = Lengths.size(); + assert(OldSize == Bounds.size()); + Lengths.resize(NewSize); + Bounds.resize(NewSize); + for (unsigned i = OldSize; i < NewSize; ++i) { + std::stringstream ss; + ss << "length" << i; + ss >> Lengths[i]; + ss.clear(); + ss << "bounds" << i; + ss >> Bounds[i]; + } +} diff --git a/llvm/tools/objwriter/debugInfo/codeView/codeViewTypeBuilder.h b/llvm/tools/objwriter/debugInfo/codeView/codeViewTypeBuilder.h new file mode 100644 index 00000000000000..14980fa9963743 --- /dev/null +++ b/llvm/tools/objwriter/debugInfo/codeView/codeViewTypeBuilder.h @@ -0,0 +1,74 @@ +//===---- codeViewTypeBuilder.h ---------------------------------*- C++ -*-===// +// +// type builder is used to convert .Net types into CodeView descriptors. +// +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +//===----------------------------------------------------------------------===// + +#pragma once + +#include "debugInfo/typeBuilder.h" +#include "llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h" +#include "llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h" + +#include + +using namespace llvm::codeview; + +class ArrayDimensionsDescriptor { +public: + const char *GetLengthName(unsigned index); + const char *GetBoundsName(unsigned index); + +private: + void Resize(unsigned NewSize); + + std::vector Lengths; + std::vector Bounds; +}; + +class UserDefinedCodeViewTypesBuilder : public UserDefinedTypesBuilder { +public: + UserDefinedCodeViewTypesBuilder(); + void EmitTypeInformation(MCSection *TypeSection, MCSection *StrSection = nullptr) override; + + unsigned GetEnumTypeIndex(const EnumTypeDescriptor &TypeDescriptor, + const EnumRecordTypeDescriptor *TypeRecords) override; + unsigned GetClassTypeIndex(const ClassTypeDescriptor &ClassDescriptor) override; + unsigned GetCompleteClassTypeIndex( + const ClassTypeDescriptor &ClassDescriptor, + const ClassFieldsTypeDescriptior &ClassFieldsDescriptor, + const DataFieldDescriptor *FieldsDescriptors, + const StaticDataFieldDescriptor *StaticsDescriptors) override; + + unsigned GetArrayTypeIndex(const ClassTypeDescriptor &ClassDescriptor, + const ArrayTypeDescriptor &ArrayDescriptor) override; + + unsigned GetPointerTypeIndex(const PointerTypeDescriptor& PointerDescriptor) override; + + unsigned GetMemberFunctionTypeIndex(const MemberFunctionTypeDescriptor& MemberDescriptor, + uint32_t const *const ArgumentTypes) override; + + unsigned GetMemberFunctionId(const MemberFunctionIdTypeDescriptor& MemberIdDescriptor) override; + + unsigned GetPrimitiveTypeIndex(PrimitiveTypeFlags Type) override; + +private: + void EmitCodeViewMagicVersion(); + ClassOptions GetCommonClassOptions(); + + unsigned GetEnumFieldListType(uint64 Count, + const EnumRecordTypeDescriptor *TypeRecords); + + void AddBaseClass(ContinuationRecordBuilder &CRB, unsigned BaseClassId); + void AddClassVTShape(ContinuationRecordBuilder &CRB); + + BumpPtrAllocator Allocator; + GlobalTypeTableBuilder TypeTable; + + ArrayDimensionsDescriptor ArrayDimentions; + TypeIndex ClassVTableTypeIndex; + TypeIndex VFuncTabTypeIndex; +}; diff --git a/llvm/tools/objwriter/debugInfo/dwarf/dwarfAbbrev.cpp b/llvm/tools/objwriter/debugInfo/dwarf/dwarfAbbrev.cpp new file mode 100644 index 00000000000000..4f3bface4f269c --- /dev/null +++ b/llvm/tools/objwriter/debugInfo/dwarf/dwarfAbbrev.cpp @@ -0,0 +1,330 @@ +//===---- dwarfAbbrev.cpp ---------------------------------------*- C++ -*-===// +// +// dwarf abbreviations implementation +// +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +//===----------------------------------------------------------------------===// + +#include "dwarfAbbrev.h" +#include "llvm/MC/MCContext.h" +#include "llvm/MC/MCObjectFileInfo.h" + +namespace DwarfAbbrev { + +void Dump(MCObjectStreamer *Streamer, uint16_t DwarfVersion, unsigned TargetPointerSize) { + uint16_t DW_FORM_size; + switch (TargetPointerSize) { + case 1: + DW_FORM_size = dwarf::DW_FORM_data1; + break; + case 2: + DW_FORM_size = dwarf::DW_FORM_data2; + break; + case 4: + DW_FORM_size = dwarf::DW_FORM_data4; + break; + case 8: + DW_FORM_size = dwarf::DW_FORM_data8; + break; + default: + assert(false && "Unexpected TargerPointerSize"); + return; + } + + const uint16_t AbbrevTable[] = { + CompileUnit, + dwarf::DW_TAG_compile_unit, dwarf::DW_CHILDREN_yes, + dwarf::DW_AT_producer, dwarf::DW_FORM_strp, + dwarf::DW_AT_language, dwarf::DW_FORM_data2, + dwarf::DW_AT_name, dwarf::DW_FORM_strp, + dwarf::DW_AT_comp_dir, dwarf::DW_FORM_strp, + dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, + dwarf::DW_AT_high_pc, DW_FORM_size, + dwarf::DW_AT_stmt_list, (DwarfVersion >= 4 ? dwarf::DW_FORM_sec_offset : dwarf::DW_FORM_data4), + 0, 0, + + BaseType, + dwarf::DW_TAG_base_type, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_name, dwarf::DW_FORM_strp, + dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, + dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, + 0, 0, + + EnumerationType, + dwarf::DW_TAG_enumeration_type, dwarf::DW_CHILDREN_yes, + dwarf::DW_AT_name, dwarf::DW_FORM_strp, + dwarf::DW_AT_type, dwarf::DW_FORM_ref4, + dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, + 0, 0, + + Enumerator1, + dwarf::DW_TAG_enumerator, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_name, dwarf::DW_FORM_strp, + dwarf::DW_AT_const_value, dwarf::DW_FORM_data1, + 0, 0, + + Enumerator2, + dwarf::DW_TAG_enumerator, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_name, dwarf::DW_FORM_strp, + dwarf::DW_AT_const_value, dwarf::DW_FORM_data2, + 0, 0, + + Enumerator4, + dwarf::DW_TAG_enumerator, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_name, dwarf::DW_FORM_strp, + dwarf::DW_AT_const_value, dwarf::DW_FORM_data4, + 0, 0, + + Enumerator8, + dwarf::DW_TAG_enumerator, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_name, dwarf::DW_FORM_strp, + dwarf::DW_AT_const_value, dwarf::DW_FORM_data8, + 0, 0, + + TypeDef, + dwarf::DW_TAG_typedef, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_name, dwarf::DW_FORM_strp, + dwarf::DW_AT_type, dwarf::DW_FORM_ref4, + 0, 0, + + Subprogram, + dwarf::DW_TAG_subprogram, dwarf::DW_CHILDREN_yes, + dwarf::DW_AT_specification, dwarf::DW_FORM_ref4, + dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, + dwarf::DW_AT_high_pc, DW_FORM_size, + dwarf::DW_AT_frame_base, dwarf::DW_FORM_exprloc, + dwarf::DW_AT_object_pointer, dwarf::DW_FORM_ref4, + 0, 0, + + SubprogramNoChildren, + dwarf::DW_TAG_subprogram, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_specification, dwarf::DW_FORM_ref4, + dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, + dwarf::DW_AT_high_pc, DW_FORM_size, + dwarf::DW_AT_frame_base, dwarf::DW_FORM_exprloc, + dwarf::DW_AT_object_pointer, dwarf::DW_FORM_ref4, + 0, 0, + + SubprogramStatic, + dwarf::DW_TAG_subprogram, dwarf::DW_CHILDREN_yes, + dwarf::DW_AT_specification, dwarf::DW_FORM_ref4, + dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, + dwarf::DW_AT_high_pc, DW_FORM_size, + dwarf::DW_AT_frame_base, dwarf::DW_FORM_exprloc, + 0, 0, + + SubprogramStaticNoChildren, + dwarf::DW_TAG_subprogram, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_specification, dwarf::DW_FORM_ref4, + dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, + dwarf::DW_AT_high_pc, DW_FORM_size, + dwarf::DW_AT_frame_base, dwarf::DW_FORM_exprloc, + 0, 0, + + SubprogramSpec, + dwarf::DW_TAG_subprogram, dwarf::DW_CHILDREN_yes, + dwarf::DW_AT_name, dwarf::DW_FORM_strp, + dwarf::DW_AT_linkage_name, dwarf::DW_FORM_strp, + dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, + dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, + dwarf::DW_AT_type, dwarf::DW_FORM_ref4, + dwarf::DW_AT_external, dwarf::DW_FORM_flag_present, + dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, + dwarf::DW_AT_object_pointer, dwarf::DW_FORM_ref4, + 0, 0, + + SubprogramStaticSpec, + dwarf::DW_TAG_subprogram, dwarf::DW_CHILDREN_yes, + dwarf::DW_AT_name, dwarf::DW_FORM_strp, + dwarf::DW_AT_linkage_name, dwarf::DW_FORM_strp, + dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, + dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, + dwarf::DW_AT_type, dwarf::DW_FORM_ref4, + dwarf::DW_AT_external, dwarf::DW_FORM_flag_present, + dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, + 0, 0, + + SubprogramStaticNoChildrenSpec, + dwarf::DW_TAG_subprogram, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_name, dwarf::DW_FORM_strp, + dwarf::DW_AT_linkage_name, dwarf::DW_FORM_strp, + dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, + dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, + dwarf::DW_AT_type, dwarf::DW_FORM_ref4, + dwarf::DW_AT_external, dwarf::DW_FORM_flag_present, + dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, + 0, 0, + + Variable, + dwarf::DW_TAG_variable, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_name, dwarf::DW_FORM_strp, + dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, + dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, + dwarf::DW_AT_type, dwarf::DW_FORM_ref4, + dwarf::DW_AT_location, dwarf::DW_FORM_exprloc, + 0, 0, + + VariableLoc, + dwarf::DW_TAG_variable, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_name, dwarf::DW_FORM_strp, + dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, + dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, + dwarf::DW_AT_type, dwarf::DW_FORM_ref4, + dwarf::DW_AT_location, dwarf::DW_FORM_sec_offset, + 0, 0, + + VariableStatic, + dwarf::DW_TAG_variable, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_specification, dwarf::DW_FORM_ref4, + dwarf::DW_AT_location, dwarf::DW_FORM_exprloc, + 0, 0, + + FormalParameter, + dwarf::DW_TAG_formal_parameter, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_name, dwarf::DW_FORM_strp, + dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, + dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, + dwarf::DW_AT_type, dwarf::DW_FORM_ref4, + dwarf::DW_AT_location, dwarf::DW_FORM_exprloc, + 0, 0, + + FormalParameterThis, + dwarf::DW_TAG_formal_parameter, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_name, dwarf::DW_FORM_strp, + dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, + dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, + dwarf::DW_AT_type, dwarf::DW_FORM_ref4, + dwarf::DW_AT_location, dwarf::DW_FORM_exprloc, + dwarf::DW_AT_artificial, dwarf::DW_FORM_flag_present, + 0, 0, + + FormalParameterLoc, + dwarf::DW_TAG_formal_parameter, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_name, dwarf::DW_FORM_strp, + dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, + dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, + dwarf::DW_AT_type, dwarf::DW_FORM_ref4, + dwarf::DW_AT_location, dwarf::DW_FORM_sec_offset, + 0, 0, + + FormalParameterThisLoc, + dwarf::DW_TAG_formal_parameter, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_name, dwarf::DW_FORM_strp, + dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, + dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, + dwarf::DW_AT_type, dwarf::DW_FORM_ref4, + dwarf::DW_AT_location, dwarf::DW_FORM_sec_offset, + dwarf::DW_AT_artificial, dwarf::DW_FORM_flag_present, + 0, 0, + + FormalParameterSpec, + dwarf::DW_TAG_formal_parameter, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_type, dwarf::DW_FORM_ref4, + 0, 0, + + FormalParameterThisSpec, + dwarf::DW_TAG_formal_parameter, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_type, dwarf::DW_FORM_ref4, + dwarf::DW_AT_artificial, dwarf::DW_FORM_flag_present, + 0, 0, + + ClassType, + dwarf::DW_TAG_class_type, dwarf::DW_CHILDREN_yes, + dwarf::DW_AT_name, dwarf::DW_FORM_strp, + dwarf::DW_AT_byte_size, dwarf::DW_FORM_data4, + 0, 0, + + ClassTypeNoChildren, + dwarf::DW_TAG_class_type, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_name, dwarf::DW_FORM_strp, + dwarf::DW_AT_byte_size, dwarf::DW_FORM_data4, + 0, 0, + + ClassTypeDecl, + dwarf::DW_TAG_class_type, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_name, dwarf::DW_FORM_strp, + dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, + 0, 0, + + ClassMember, + dwarf::DW_TAG_member, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_name, dwarf::DW_FORM_strp, + dwarf::DW_AT_type, dwarf::DW_FORM_ref4, + dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data4, + 0, 0, + + ClassMemberStatic, + dwarf::DW_TAG_member, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_name, dwarf::DW_FORM_strp, + dwarf::DW_AT_type, dwarf::DW_FORM_ref4, + dwarf::DW_AT_external, dwarf::DW_FORM_flag_present, + dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, + 0, 0, + + PointerType, + dwarf::DW_TAG_pointer_type, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_type, dwarf::DW_FORM_ref4, + dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, + 0, 0, + + ReferenceType, + dwarf::DW_TAG_reference_type, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_type, dwarf::DW_FORM_ref4, + dwarf::DW_AT_byte_size, dwarf::DW_FORM_data1, + 0, 0, + + ArrayType, + dwarf::DW_TAG_array_type, dwarf::DW_CHILDREN_yes, + dwarf::DW_AT_type, dwarf::DW_FORM_ref4, + 0, 0, + + SubrangeType, + dwarf::DW_TAG_subrange_type, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_upper_bound, dwarf::DW_FORM_udata, + 0, 0, + + ClassInheritance, + dwarf::DW_TAG_inheritance, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_type, dwarf::DW_FORM_ref4, + dwarf::DW_AT_data_member_location, dwarf::DW_FORM_data1, + 0, 0, + + LexicalBlock, + dwarf::DW_TAG_lexical_block, dwarf::DW_CHILDREN_yes, + dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, + dwarf::DW_AT_high_pc, DW_FORM_size, + 0, 0, + + TryBlock, + dwarf::DW_TAG_try_block, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, + dwarf::DW_AT_high_pc, DW_FORM_size, + 0, 0, + + CatchBlock, + dwarf::DW_TAG_catch_block, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, + dwarf::DW_AT_high_pc, DW_FORM_size, + 0, 0, + + VoidType, + dwarf::DW_TAG_unspecified_type, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_name, dwarf::DW_FORM_strp, + 0, 0, + + VoidPointerType, + dwarf::DW_TAG_pointer_type, dwarf::DW_CHILDREN_no, + 0, 0, + }; + + MCContext &context = Streamer->getContext(); + Streamer->switchSection(context.getObjectFileInfo()->getDwarfAbbrevSection()); + + for (uint16_t e : AbbrevTable) { + Streamer->emitULEB128IntValue(e); + } +} + +} diff --git a/llvm/tools/objwriter/debugInfo/dwarf/dwarfAbbrev.h b/llvm/tools/objwriter/debugInfo/dwarf/dwarfAbbrev.h new file mode 100644 index 00000000000000..448123c99a92d7 --- /dev/null +++ b/llvm/tools/objwriter/debugInfo/dwarf/dwarfAbbrev.h @@ -0,0 +1,64 @@ +//===---- dwarfAbbrev.h -----------------------------------------*- C++ -*-===// +// +// dwarf abbreviations +// +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +//===----------------------------------------------------------------------===// + +#pragma once + +#include "llvm/BinaryFormat/Dwarf.h" +#include "llvm/MC/MCObjectStreamer.h" + +using namespace llvm; + +namespace DwarfAbbrev { + +enum DwarfAbbrev : uint16_t +{ + CompileUnit = 0x1, + BaseType, + EnumerationType, + Enumerator1, + Enumerator2, + Enumerator4, + Enumerator8, + TypeDef, + Subprogram, + SubprogramNoChildren, + SubprogramStatic, + SubprogramStaticNoChildren, + SubprogramSpec, + SubprogramStaticSpec, + SubprogramStaticNoChildrenSpec, + Variable, + VariableLoc, + VariableStatic, + FormalParameter, + FormalParameterThis, + FormalParameterLoc, + FormalParameterThisLoc, + FormalParameterSpec, + FormalParameterThisSpec, + ClassType, + ClassTypeNoChildren, + ClassTypeDecl, + ClassMember, + ClassMemberStatic, + PointerType, + ReferenceType, + ArrayType, + SubrangeType, + ClassInheritance, + LexicalBlock, + TryBlock, + CatchBlock, + VoidType, + VoidPointerType, +}; + +void Dump(MCObjectStreamer *Streamer, uint16_t DwarfVersion, unsigned TargetPointerSize); + +} diff --git a/llvm/tools/objwriter/debugInfo/dwarf/dwarfGen.cpp b/llvm/tools/objwriter/debugInfo/dwarf/dwarfGen.cpp new file mode 100644 index 00000000000000..a62ffacae7e77a --- /dev/null +++ b/llvm/tools/objwriter/debugInfo/dwarf/dwarfGen.cpp @@ -0,0 +1,1160 @@ +//===---- dwarfGen.cpp ------------------------------------------*- C++ -*-===// +// +// dwarf generator implementation +// +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +//===----------------------------------------------------------------------===// + +#include "dwarfGen.h" +#include "dwarfAbbrev.h" + +#include "llvm/MC/MCContext.h" +#include "llvm/MC/MCAsmInfo.h" +#include "llvm/MC/MCExpr.h" +#include "llvm/MC/MCObjectFileInfo.h" +#include "llvm/MC/MCSymbol.h" +#include "llvm/Support/LEB128.h" + +#ifdef FEATURE_LANGID_CS +#define DW_LANG_MICROSOFT_CSHARP 0x9e57 +#endif + +// Keep sync with ICorDebugInfo::RegNum (cordebuginfo.h) + +enum class RegNumX86 +{ + REGNUM_EAX, + REGNUM_ECX, + REGNUM_EDX, + REGNUM_EBX, + REGNUM_ESP, + REGNUM_EBP, + REGNUM_ESI, + REGNUM_EDI, + REGNUM_COUNT, + REGNUM_FP = REGNUM_EBP, + REGNUM_SP = REGNUM_ESP +}; + +enum class RegNumArm +{ + REGNUM_R0, + REGNUM_R1, + REGNUM_R2, + REGNUM_R3, + REGNUM_R4, + REGNUM_R5, + REGNUM_R6, + REGNUM_R7, + REGNUM_R8, + REGNUM_R9, + REGNUM_R10, + REGNUM_R11, + REGNUM_R12, + REGNUM_SP, + REGNUM_LR, + REGNUM_PC, + REGNUM_COUNT, + REGNUM_FP = REGNUM_R7 +}; + +enum class RegNumArm64 +{ + REGNUM_X0, + REGNUM_X1, + REGNUM_X2, + REGNUM_X3, + REGNUM_X4, + REGNUM_X5, + REGNUM_X6, + REGNUM_X7, + REGNUM_X8, + REGNUM_X9, + REGNUM_X10, + REGNUM_X11, + REGNUM_X12, + REGNUM_X13, + REGNUM_X14, + REGNUM_X15, + REGNUM_X16, + REGNUM_X17, + REGNUM_X18, + REGNUM_X19, + REGNUM_X20, + REGNUM_X21, + REGNUM_X22, + REGNUM_X23, + REGNUM_X24, + REGNUM_X25, + REGNUM_X26, + REGNUM_X27, + REGNUM_X28, + REGNUM_FP, + REGNUM_LR, + REGNUM_SP, + REGNUM_PC, + REGNUM_COUNT +}; + +enum class RegNumAmd64 +{ + REGNUM_RAX, + REGNUM_RCX, + REGNUM_RDX, + REGNUM_RBX, + REGNUM_RSP, + REGNUM_RBP, + REGNUM_RSI, + REGNUM_RDI, + REGNUM_R8, + REGNUM_R9, + REGNUM_R10, + REGNUM_R11, + REGNUM_R12, + REGNUM_R13, + REGNUM_R14, + REGNUM_R15, + REGNUM_COUNT, + REGNUM_SP = REGNUM_RSP, + REGNUM_FP = REGNUM_RBP +}; + +// Helper routines from lib/MC/MCDwarf.cpp +static const MCExpr *forceExpAbs(MCStreamer &OS, const MCExpr* Expr) { + MCContext &Context = OS.getContext(); + assert(!isa(Expr)); + if (Context.getAsmInfo()->hasAggressiveSymbolFolding()) + return Expr; + + MCSymbol *ABS = Context.createTempSymbol(); + OS.emitAssignment(ABS, Expr); + return MCSymbolRefExpr::create(ABS, Context); +} + +static void emitAbsValue(MCStreamer &OS, const MCExpr *Value, unsigned Size) { + const MCExpr *ABS = forceExpAbs(OS, Value); + OS.emitValue(ABS, Size); +} + +static const MCExpr *MakeStartMinusEndExpr(const MCStreamer &MCOS, + const MCSymbol &Start, + const MCSymbol &End, + int IntVal) { + MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None; + const MCExpr *Res = + MCSymbolRefExpr::create(&End, Variant, MCOS.getContext()); + const MCExpr *RHS = + MCSymbolRefExpr::create(&Start, Variant, MCOS.getContext()); + const MCExpr *Res1 = + MCBinaryExpr::create(MCBinaryExpr::Sub, Res, RHS, MCOS.getContext()); + const MCExpr *Res2 = + MCConstantExpr::create(IntVal, MCOS.getContext()); + const MCExpr *Res3 = + MCBinaryExpr::create(MCBinaryExpr::Sub, Res1, Res2, MCOS.getContext()); + return Res3; +} + +static int GetDwarfRegNum(Triple::ArchType ArchType, int RegNum) { + switch (ArchType) { + case Triple::x86: + switch (static_cast(RegNum)) { + case RegNumX86::REGNUM_EAX: return 0; + case RegNumX86::REGNUM_ECX: return 1; + case RegNumX86::REGNUM_EDX: return 2; + case RegNumX86::REGNUM_EBX: return 3; + case RegNumX86::REGNUM_ESP: return 4; + case RegNumX86::REGNUM_EBP: return 5; + case RegNumX86::REGNUM_ESI: return 6; + case RegNumX86::REGNUM_EDI: return 7; + // fp registers + default: + return RegNum - static_cast(RegNumX86::REGNUM_COUNT) + 32; + } + case Triple::arm: // fall through + case Triple::armeb: // fall through + case Triple::thumb: // fall through + case Triple::thumbeb: + switch (static_cast(RegNum)) { + case RegNumArm::REGNUM_R0: return 0; + case RegNumArm::REGNUM_R1: return 1; + case RegNumArm::REGNUM_R2: return 2; + case RegNumArm::REGNUM_R3: return 3; + case RegNumArm::REGNUM_R4: return 4; + case RegNumArm::REGNUM_R5: return 5; + case RegNumArm::REGNUM_R6: return 6; + case RegNumArm::REGNUM_R7: return 7; + case RegNumArm::REGNUM_R8: return 8; + case RegNumArm::REGNUM_R9: return 9; + case RegNumArm::REGNUM_R10: return 10; + case RegNumArm::REGNUM_R11: return 11; + case RegNumArm::REGNUM_R12: return 12; + case RegNumArm::REGNUM_SP: return 13; + case RegNumArm::REGNUM_LR: return 14; + case RegNumArm::REGNUM_PC: return 15; + // fp registers + default: + return (RegNum - static_cast(RegNumArm::REGNUM_COUNT)) / 2 + 256; + } + case Triple::aarch64: // fall through + case Triple::aarch64_be: + switch (static_cast(RegNum)) { + case RegNumArm64::REGNUM_X0: return 0; + case RegNumArm64::REGNUM_X1: return 1; + case RegNumArm64::REGNUM_X2: return 2; + case RegNumArm64::REGNUM_X3: return 3; + case RegNumArm64::REGNUM_X4: return 4; + case RegNumArm64::REGNUM_X5: return 5; + case RegNumArm64::REGNUM_X6: return 6; + case RegNumArm64::REGNUM_X7: return 7; + case RegNumArm64::REGNUM_X8: return 8; + case RegNumArm64::REGNUM_X9: return 9; + case RegNumArm64::REGNUM_X10: return 10; + case RegNumArm64::REGNUM_X11: return 11; + case RegNumArm64::REGNUM_X12: return 12; + case RegNumArm64::REGNUM_X13: return 13; + case RegNumArm64::REGNUM_X14: return 14; + case RegNumArm64::REGNUM_X15: return 15; + case RegNumArm64::REGNUM_X16: return 16; + case RegNumArm64::REGNUM_X17: return 17; + case RegNumArm64::REGNUM_X18: return 18; + case RegNumArm64::REGNUM_X19: return 19; + case RegNumArm64::REGNUM_X20: return 20; + case RegNumArm64::REGNUM_X21: return 21; + case RegNumArm64::REGNUM_X22: return 22; + case RegNumArm64::REGNUM_X23: return 23; + case RegNumArm64::REGNUM_X24: return 24; + case RegNumArm64::REGNUM_X25: return 25; + case RegNumArm64::REGNUM_X26: return 26; + case RegNumArm64::REGNUM_X27: return 27; + case RegNumArm64::REGNUM_X28: return 28; + case RegNumArm64::REGNUM_FP: return 29; + case RegNumArm64::REGNUM_LR: return 30; + case RegNumArm64::REGNUM_SP: return 31; + case RegNumArm64::REGNUM_PC: return 32; + // fp registers + default: + return RegNum - static_cast(RegNumArm64::REGNUM_COUNT) + 64; + } + case Triple::x86_64: + switch (static_cast(RegNum)) { + case RegNumAmd64::REGNUM_RAX: return 0; + case RegNumAmd64::REGNUM_RDX: return 1; + case RegNumAmd64::REGNUM_RCX: return 2; + case RegNumAmd64::REGNUM_RBX: return 3; + case RegNumAmd64::REGNUM_RSI: return 4; + case RegNumAmd64::REGNUM_RDI: return 5; + case RegNumAmd64::REGNUM_RBP: return 6; + case RegNumAmd64::REGNUM_RSP: return 7; + case RegNumAmd64::REGNUM_R8: return 8; + case RegNumAmd64::REGNUM_R9: return 9; + case RegNumAmd64::REGNUM_R10: return 10; + case RegNumAmd64::REGNUM_R11: return 11; + case RegNumAmd64::REGNUM_R12: return 12; + case RegNumAmd64::REGNUM_R13: return 13; + case RegNumAmd64::REGNUM_R14: return 14; + case RegNumAmd64::REGNUM_R15: return 15; + // fp registers + default: + return RegNum - static_cast(RegNumAmd64::REGNUM_COUNT) + 17; + } + default: + assert(false && "Unexpected architecture"); + return 0; + } +} + +static int GetDwarfFpRegNum(Triple::ArchType ArchType) +{ + switch (ArchType) { + case Triple::x86: + return GetDwarfRegNum(ArchType, static_cast(RegNumX86::REGNUM_FP)); + case Triple::arm: // fall through + case Triple::armeb: // fall through + case Triple::thumb: // fall through + case Triple::thumbeb: + return GetDwarfRegNum(ArchType, static_cast(RegNumArm::REGNUM_FP)); + case Triple::aarch64: // fall through + case Triple::aarch64_be: + return GetDwarfRegNum(ArchType, static_cast(RegNumArm64::REGNUM_FP)); + case Triple::x86_64: + return GetDwarfRegNum(ArchType, static_cast(RegNumAmd64::REGNUM_FP)); + default: + assert(false && "Unexpected architecture"); + return 0; + } +} + +static int GetRegOpSize(int DwarfRegNum) { + if (DwarfRegNum <= 31) { + return 1; + } + else if (DwarfRegNum < 128) { + return 2; + } + else if (DwarfRegNum < 16384) { + return 3; + } + else { + assert(false && "Too big register number"); + return 0; + } +} + +static void EmitBreg(MCObjectStreamer* Streamer, int DwarfRegNum, StringRef bytes) { + if (DwarfRegNum <= 31) { + Streamer->emitIntValue(DwarfRegNum + dwarf::DW_OP_breg0, 1); + } + else { + Streamer->emitIntValue(dwarf::DW_OP_bregx, 1); + Streamer->emitULEB128IntValue(DwarfRegNum); + } + Streamer->emitBytes(bytes); +} + +static void EmitBreg(MCObjectStreamer* Streamer, int DwarfRegNum, int value) { + if (DwarfRegNum <= 31) { + Streamer->emitIntValue(DwarfRegNum + dwarf::DW_OP_breg0, 1); + } + else { + Streamer->emitIntValue(dwarf::DW_OP_bregx, 1); + Streamer->emitULEB128IntValue(DwarfRegNum); + } + Streamer->emitSLEB128IntValue(value); +} + +static void EmitReg(MCObjectStreamer* Streamer, int DwarfRegNum) { + if (DwarfRegNum <= 31) { + Streamer->emitIntValue(DwarfRegNum + dwarf::DW_OP_reg0, 1); + } + else { + Streamer->emitIntValue(dwarf::DW_OP_regx, 1); + Streamer->emitULEB128IntValue(DwarfRegNum); + } +} + +static void EmitVarLocation(MCObjectStreamer *Streamer, + const ICorDebugInfo::NativeVarInfo &VarInfo, + bool IsLocList = false) { + MCContext &context = Streamer->getContext(); + unsigned TargetPointerSize = context.getAsmInfo()->getCodePointerSize(); + Triple::ArchType ArchType = context.getTargetTriple().getArch(); + + int DwarfRegNum; + int DwarfRegNum2; + int DwarfBaseRegNum; + unsigned Len; + + bool IsByRef = false; + bool IsStk2 = false; + bool IsRegStk = false; + + switch (VarInfo.loc.vlType) { + case ICorDebugInfo::VLT_REG_BYREF: // fall through + IsByRef = true; + case ICorDebugInfo::VLT_REG_FP: // fall through + case ICorDebugInfo::VLT_REG: { + DwarfRegNum = GetDwarfRegNum(ArchType, VarInfo.loc.vlReg.vlrReg); + if (IsByRef) { + Len = 1 + GetRegOpSize(DwarfRegNum); + if (IsLocList) { + Streamer->emitIntValue(Len, 2); + } else { + Streamer->emitULEB128IntValue(Len); + } + EmitBreg(Streamer, DwarfRegNum, 0); + } else { + Len = GetRegOpSize(DwarfRegNum); + if (IsLocList) { + Streamer->emitIntValue(Len, 2); + } else { + Streamer->emitULEB128IntValue(Len); + } + EmitReg(Streamer, DwarfRegNum); + } + + break; + } + case ICorDebugInfo::VLT_STK_BYREF: // fall through + IsByRef = true; + case ICorDebugInfo::VLT_STK2: + IsStk2 = true; + case ICorDebugInfo::VLT_FPSTK: + case ICorDebugInfo::VLT_STK: { + DwarfBaseRegNum = GetDwarfRegNum(ArchType, IsStk2 ? VarInfo.loc.vlStk2.vls2BaseReg : + VarInfo.loc.vlStk.vlsBaseReg); + + SmallString<128> Tmp; + raw_svector_ostream OSE(Tmp); + encodeSLEB128(IsStk2 ? VarInfo.loc.vlStk2.vls2Offset : + VarInfo.loc.vlStk.vlsOffset, OSE); + StringRef OffsetRepr = OSE.str(); + + if (IsByRef) { + Len = OffsetRepr.size() + 1 + GetRegOpSize(DwarfBaseRegNum); + if (IsLocList) { + Streamer->emitIntValue(Len, 2); + } else { + Streamer->emitULEB128IntValue(Len); + } + EmitBreg(Streamer, DwarfBaseRegNum, OffsetRepr); + Streamer->emitIntValue(dwarf::DW_OP_deref, 1); + } else { + Len = OffsetRepr.size() + GetRegOpSize(DwarfBaseRegNum); + if (IsLocList) { + Streamer->emitIntValue(Len, 2); + } else { + Streamer->emitULEB128IntValue(Len); + } + EmitBreg(Streamer, DwarfBaseRegNum, OffsetRepr); + } + + break; + } + case ICorDebugInfo::VLT_REG_REG: { + DwarfRegNum = GetDwarfRegNum(ArchType, VarInfo.loc.vlRegReg.vlrrReg1); + DwarfRegNum2 = GetDwarfRegNum(ArchType, VarInfo.loc.vlRegReg.vlrrReg2); + + Len = (GetRegOpSize(DwarfRegNum2) /* DW_OP_reg */ + 1 /* DW_OP_piece */ + 1 /* Reg size */) + + (GetRegOpSize(DwarfRegNum) /* DW_OP_reg */ + 1 /* DW_OP_piece */ + 1 /* Reg size */); + if (IsLocList) { + Streamer->emitIntValue(Len, 2); + } else { + Streamer->emitULEB128IntValue(Len); + } + + EmitReg(Streamer, DwarfRegNum2); + Streamer->emitIntValue(dwarf::DW_OP_piece, 1); + Streamer->emitULEB128IntValue(TargetPointerSize); + + EmitReg(Streamer, DwarfRegNum); + Streamer->emitIntValue(dwarf::DW_OP_piece, 1); + Streamer->emitULEB128IntValue(TargetPointerSize); + + break; + } + case ICorDebugInfo::VLT_REG_STK: // fall through + IsRegStk = true; + case ICorDebugInfo::VLT_STK_REG: { + DwarfRegNum = GetDwarfRegNum(ArchType, IsRegStk ? VarInfo.loc.vlRegStk.vlrsReg : + VarInfo.loc.vlStkReg.vlsrReg); + DwarfBaseRegNum = GetDwarfRegNum(ArchType, IsRegStk ? VarInfo.loc.vlRegStk.vlrsStk.vlrssBaseReg : + VarInfo.loc.vlStkReg.vlsrStk.vlsrsBaseReg); + + SmallString<128> Tmp; + raw_svector_ostream OSE(Tmp); + encodeSLEB128(IsRegStk ? VarInfo.loc.vlRegStk.vlrsStk.vlrssOffset : + VarInfo.loc.vlStkReg.vlsrStk.vlsrsOffset, OSE); + StringRef OffsetRepr = OSE.str(); + + Len = (GetRegOpSize(DwarfRegNum) /* DW_OP_reg */ + 1 /* DW_OP_piece */ + 1 /* Reg size */) + + (GetRegOpSize(DwarfBaseRegNum) /*DW_OP_breg */ + OffsetRepr.size() + 1 /* DW_OP_piece */ + 1 /* Reg size */); + + if (IsLocList) { + Streamer->emitIntValue(Len, 2); + } else { + Streamer->emitULEB128IntValue(Len + 1); + } + + if (IsRegStk) { + EmitReg(Streamer, DwarfRegNum); + Streamer->emitIntValue(dwarf::DW_OP_piece, 1); + Streamer->emitULEB128IntValue(TargetPointerSize); + + EmitBreg(Streamer, DwarfBaseRegNum, OffsetRepr); + Streamer->emitIntValue(dwarf::DW_OP_piece, 1); + Streamer->emitULEB128IntValue(TargetPointerSize); + } else { + EmitBreg(Streamer, DwarfBaseRegNum, OffsetRepr); + Streamer->emitIntValue(dwarf::DW_OP_piece, 1); + Streamer->emitULEB128IntValue(TargetPointerSize); + + EmitReg(Streamer, DwarfRegNum); + Streamer->emitIntValue(dwarf::DW_OP_piece, 1); + Streamer->emitULEB128IntValue(TargetPointerSize); + } + + break; + } + case ICorDebugInfo::VLT_FIXED_VA: + assert(false && "Unsupported varloc type!"); + default: + assert(false && "Unknown varloc type!"); + if (IsLocList) { + Streamer->emitIntValue(0, 2); + } else { + Streamer->emitULEB128IntValue(0); + } + } +} + +// Lexical scope + +class LexicalScope +{ +public: + LexicalScope(uint64_t Start, uint64_t End, bool IsFuncScope = false) : + Start(Start), + End(End), + IsFuncScope(IsFuncScope) {} + + LexicalScope(VarInfo *Info) : + Start(Info->GetStartOffset()), + End(Info->GetEndOffset()), + IsFuncScope(false) { Vars.push_back(Info); } + + bool IsContains(const VarInfo *Info) const { + return Start <= Info->GetStartOffset() && End >= Info->GetEndOffset(); + } + + void AddVar(VarInfo *Info); + + void Dump(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer, + MCSection *TypeSection, MCSection *StrSection, const MCExpr *SymExpr); + +private: + uint64_t Start; + uint64_t End; + bool IsFuncScope; + std::vector Vars; + std::vector InnerScopes; +}; + +void LexicalScope::AddVar(VarInfo *Info) { + if (Info->IsParam() && IsFuncScope) { + Vars.push_back(Info); + return; + } + + if (!IsContains(Info)) + return; + + uint64_t VarStart = Info->GetStartOffset(); + uint64_t VarEnd = Info->GetEndOffset(); + + // Var belongs to inner scope + if (VarStart != Start || VarEnd != End) { + // Try to add variable to one the inner scopes + for (auto &Scope : InnerScopes) { + if (Scope.IsContains(Info)) { + Scope.AddVar(Info); + return; + } + } + // We need to create new inner scope for this var + InnerScopes.emplace_back(Info); + } else { + Vars.push_back(Info); + } +} + +void LexicalScope::Dump(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer, + MCSection *TypeSection, MCSection *StrSection, const MCExpr *SymExpr) { + Streamer->switchSection(TypeSection); + + if (!IsFuncScope) + { + // Dump lexical block DIE + MCContext &context = Streamer->getContext(); + unsigned TargetPointerSize = context.getAsmInfo()->getCodePointerSize(); + + // Abbrev Number + Streamer->emitULEB128IntValue(DwarfAbbrev::LexicalBlock); + + // DW_AT_low_pc + const MCExpr *StartExpr = MCConstantExpr::create(Start, context); + const MCExpr *LowPcExpr = MCBinaryExpr::create(MCBinaryExpr::Add, SymExpr, + StartExpr, context); + Streamer->emitValue(LowPcExpr, TargetPointerSize); + + // DW_AT_high_pc + Streamer->emitIntValue(End - Start, TargetPointerSize); + } + + for (auto *Var : Vars) { + Var->Dump(TypeBuilder, Streamer, TypeSection, StrSection); + } + + for (auto &Scope : InnerScopes) { + Scope.Dump(TypeBuilder, Streamer, TypeSection, StrSection, SymExpr); + } + + if (!IsFuncScope) { + // Terminate block + Streamer->emitIntValue(0, 1); + } +} + +// StaticVarInfo + +class StaticVarInfo : public DwarfInfo +{ +public: + StaticVarInfo(const DwarfStaticDataField *StaticField) : StaticField(StaticField) {} + + void Dump(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer, + MCSection *TypeSection, MCSection *StrSection) override; + +protected: + void DumpStrings(MCObjectStreamer *Streamer) override {}; + void DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) override; + +private: + const DwarfStaticDataField *StaticField; + + void EmitLocation(MCObjectStreamer *Streamer); +}; + +void StaticVarInfo::Dump(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer, + MCSection *TypeSection, MCSection *StrSection) { + MCContext &context = Streamer->getContext(); + MCSymbol *Sym = context.getOrCreateSymbol(Twine(StaticField->GetStaticDataName())); + if (Sym->isUndefined()) + return; + + DwarfInfo::Dump(TypeBuilder, Streamer, TypeSection, StrSection); +} + +void StaticVarInfo::DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) { + // Abbrev Number + Streamer->emitULEB128IntValue(DwarfAbbrev::VariableStatic); + + // DW_AT_specification + EmitInfoOffset(Streamer, StaticField, 4); + + // DW_AT_location + EmitLocation(Streamer); +} + +void StaticVarInfo::EmitLocation(MCObjectStreamer *Streamer) { + MCContext &context = Streamer->getContext(); + unsigned TargetPointerSize = context.getAsmInfo()->getCodePointerSize(); + + MCSymbol *Sym = context.getOrCreateSymbol(Twine(StaticField->GetStaticDataName())); + + SmallString<128> Tmp; + raw_svector_ostream OSE(Tmp); + encodeULEB128(StaticField->GetStaticOffset(), OSE); + StringRef OffsetRepr = OSE.str(); + + unsigned Len = 1 /* DW_OP_addr */ + TargetPointerSize; + + // Need double deref + if (StaticField->IsStaticDataInObject()) { + Len += (1 /* DW_OP_deref */) * 2; + } + + if (StaticField->GetStaticOffset() != 0) { + Len += 1 /* DW_OP_plus_uconst */ + OffsetRepr.size(); + } + + Streamer->emitULEB128IntValue(Len); + Streamer->emitIntValue(dwarf::DW_OP_addr, 1); + Streamer->emitSymbolValue(Sym, TargetPointerSize); + + if (StaticField->IsStaticDataInObject()) { + Streamer->emitIntValue(dwarf::DW_OP_deref, 1); + Streamer->emitIntValue(dwarf::DW_OP_deref, 1); + } + + if (StaticField->GetStaticOffset() != 0) { + Streamer->emitIntValue(dwarf::DW_OP_plus_uconst, 1); + Streamer->emitBytes(OffsetRepr); + } +} + +// VarInfo + +VarInfo::VarInfo(const DebugVarInfo &Info, bool IsThis) : + DebugInfo(Info), + LocSymbol(nullptr), + IsThis(IsThis) { + if (!Info.IsParam) { + assert(!Info.Ranges.empty()); + StartOffset = Info.Ranges.front().startOffset; + EndOffset = Info.Ranges.back().endOffset; + } else { + // Params belong to func scope + StartOffset = 0xFFFFFFFF; + EndOffset = 0xFFFFFFFF; + } +} + +void VarInfo::DumpLocsIfNeeded(MCObjectStreamer *Streamer, + MCSection *LocSection, + const MCExpr *SymExpr) { + if (!IsDebugLocNeeded()) + return; + + Streamer->switchSection(LocSection); + + MCContext &context = Streamer->getContext(); + unsigned TargetPointerSize = context.getAsmInfo()->getCodePointerSize(); + + LocSymbol = context.createTempSymbol(); + Streamer->emitLabel(LocSymbol); + + for (const auto &NativeInfo : DebugInfo.Ranges) { + const MCExpr *StartOffsetExpr = MCConstantExpr::create(NativeInfo.startOffset, context); + const MCExpr *EndOffsetExpr = MCConstantExpr::create(NativeInfo.endOffset, context); + + // Begin address + const MCExpr *BeginAddrExpr = MCBinaryExpr::create(MCBinaryExpr::Add, SymExpr, + StartOffsetExpr, context); + Streamer->emitValue(BeginAddrExpr, TargetPointerSize); + + // End address + const MCExpr *EndAddrExpr = MCBinaryExpr::create(MCBinaryExpr::Add, SymExpr, + EndOffsetExpr, context); + Streamer->emitValue(EndAddrExpr, TargetPointerSize); + + // Expression + EmitVarLocation(Streamer, NativeInfo, true); + } + + // Terminate list entry + Streamer->emitIntValue(0, TargetPointerSize); + Streamer->emitIntValue(0, TargetPointerSize); +} + +void VarInfo::DumpStrings(MCObjectStreamer *Streamer) { + if (IsThis) { + Streamer->emitBytes(StringRef("this")); + } else { + Streamer->emitBytes(StringRef(DebugInfo.Name)); + } + Streamer->emitIntValue(0, 1); +} + +void VarInfo::DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) { + bool IsDebugLocUsed = IsDebugLocNeeded(); + + // Abbrev Number + if (DebugInfo.IsParam) { + if (IsThis) { + Streamer->emitULEB128IntValue(IsDebugLocUsed ? DwarfAbbrev::FormalParameterThisLoc : + DwarfAbbrev::FormalParameterThis); + } else { + Streamer->emitULEB128IntValue(IsDebugLocUsed ? DwarfAbbrev::FormalParameterLoc : + DwarfAbbrev::FormalParameter); + } + } else { + Streamer->emitULEB128IntValue(IsDebugLocUsed ? DwarfAbbrev::VariableLoc : + DwarfAbbrev::Variable); + } + + // DW_AT_name + EmitSectionOffset(Streamer, StrSymbol, 4); + + // DW_AT_decl_file + Streamer->emitIntValue(1, 1); + + // DW_AT_decl_line + Streamer->emitIntValue(1, 1); + + // DW_AT_type + DwarfInfo *Info = TypeBuilder->GetTypeInfoByIndex(DebugInfo.TypeIndex); + assert(Info != nullptr); + + EmitInfoOffset(Streamer, Info, 4); + + // DW_AT_location + if (IsDebugLocUsed) { + EmitSectionOffset(Streamer, LocSymbol, 4); + } else { + assert(DebugInfo.Ranges.size() == 1); + EmitVarLocation(Streamer, DebugInfo.Ranges[0]); + } +} + +// SubprogramInfo + +SubprogramInfo::SubprogramInfo(const char *Name, + int Size, + DwarfMemberFunctionIdTypeInfo *MethodTypeInfo, + const std::vector &DebugVarInfos, + const std::vector &DebugEHClauseInfos) : + Name(Name), + Size(Size), + MethodTypeInfo(MethodTypeInfo), + DebugEHClauseInfos(DebugEHClauseInfos) { + bool IsStatic = MethodTypeInfo->IsStatic(); + for (unsigned i = 0; i < DebugVarInfos.size(); i++) { + VarInfos.emplace_back(DebugVarInfos[i], i == 0 && !IsStatic); + } +} + +void SubprogramInfo::Dump(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer, + MCSection *TypeSection, MCSection *StrSection, MCSection *LocSection) { + DumpDebugLoc(Streamer, LocSection); + + DwarfInfo::Dump(TypeBuilder, Streamer, TypeSection, StrSection); + + // Dump vars + DumpVars(TypeBuilder, Streamer, TypeSection, StrSection); + + // Dump try-catch blocks + Streamer->switchSection(TypeSection); + DumpEHClauses(Streamer, TypeSection); + + DwarfInfo::EndChildrenList(Streamer); +} + +void SubprogramInfo::DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) { + MCContext &context = Streamer->getContext(); + bool IsStatic = MethodTypeInfo->IsStatic(); + unsigned TargetPointerSize = context.getAsmInfo()->getCodePointerSize(); + Triple::ArchType ArchType = context.getTargetTriple().getArch(); + + // Subprogram DIE + + // Abbrev Number + auto abbrev = IsStatic + ? HasChildren() ? DwarfAbbrev::SubprogramStatic + : DwarfAbbrev::SubprogramStaticNoChildren + : HasChildren() ? DwarfAbbrev::Subprogram + : DwarfAbbrev::SubprogramNoChildren; + + Streamer->emitULEB128IntValue(abbrev); + + // DW_AT_specification + EmitInfoOffset(Streamer, MethodTypeInfo, 4); + + // DW_AT_low_pc + MCSymbol *Sym = context.lookupSymbol(Twine(Name)); + const MCExpr *SymExpr = MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_None, context); + Streamer->emitValue(SymExpr, TargetPointerSize); + + // DW_AT_high_pc + Streamer->emitIntValue(Size, TargetPointerSize); + + // DW_AT_frame_base + Streamer->emitULEB128IntValue(1); + Streamer->emitIntValue(GetDwarfFpRegNum(ArchType) + dwarf::DW_OP_reg0, 1); + + if (!IsStatic) { + // DW_AT_object_pointer + uint32_t Offset = Streamer->getOrCreateDataFragment()->getContents().size(); + + Streamer->emitIntValue(Offset + 4, 4); + } +} + +void SubprogramInfo::DumpDebugLoc(MCObjectStreamer *Streamer, MCSection *LocSection) { + MCContext &context = Streamer->getContext(); + MCSymbol *Sym = context.getOrCreateSymbol(Twine(Name)); + const MCExpr *SymExpr = MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_None, context); + + for (auto &VarInfo : VarInfos) { + VarInfo.DumpLocsIfNeeded(Streamer, LocSection, SymExpr); + } +} + +void SubprogramInfo::DumpVars(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer, + MCSection *TypeSection, MCSection *StrSection) { + MCContext &context = Streamer->getContext(); + MCSymbol *Sym = context.getOrCreateSymbol(Twine(Name)); + const MCExpr *SymExpr = MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_None, context); + + LexicalScope FuncScope(0, Size, true); + + for (unsigned i = 0; i < VarInfos.size(); i++) { + FuncScope.AddVar(&VarInfos[i]); + } + + FuncScope.Dump(TypeBuilder, Streamer, TypeSection, StrSection, SymExpr); +} + +static void DumpEHClause(MCObjectStreamer *Streamer, MCSection *TypeSection, int Abbrev, + const MCExpr *SymExpr, unsigned Offset, unsigned Length) { + MCContext &context = Streamer->getContext(); + unsigned TargetPointerSize = context.getAsmInfo()->getCodePointerSize(); + + // Abbrev Number + Streamer->emitULEB128IntValue(Abbrev); + + // DW_AT_low_pc + const MCExpr *OffsetExpr = MCConstantExpr::create(Offset, context); + const MCExpr *AddrExpr = MCBinaryExpr::create(MCBinaryExpr::Add, SymExpr, + OffsetExpr, context); + + Streamer->emitValue(AddrExpr, TargetPointerSize); + + // DW_AT_high_pc + Streamer->emitIntValue(Length, TargetPointerSize); +} + +void SubprogramInfo::DumpEHClauses(MCObjectStreamer *Streamer, MCSection *TypeSection) { + MCContext &context = Streamer->getContext(); + + MCSymbol *Sym = context.getOrCreateSymbol(Twine(Name)); + const MCExpr *SymExpr = MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_None, context); + + for (const auto &EHClause: DebugEHClauseInfos) { + // Try block DIE + DumpEHClause(Streamer, TypeSection, DwarfAbbrev::TryBlock, + SymExpr, EHClause.TryOffset, EHClause.TryLength); + + // Catch block DIE + DumpEHClause(Streamer, TypeSection, DwarfAbbrev::CatchBlock, + SymExpr, EHClause.HandlerOffset, EHClause.HandlerLength); + } +} + +bool SubprogramInfo::HasChildren() { + return !MethodTypeInfo->IsStatic() || !DebugEHClauseInfos.empty() || !VarInfos.empty(); +} + +// DwarfGen + +void DwarfGen::SetTypeBuilder(UserDefinedDwarfTypesBuilder *TypeBuilder) { + assert(this->TypeBuilder == nullptr); + assert(TypeBuilder != nullptr); + this->TypeBuilder = TypeBuilder; + this->Streamer = TypeBuilder->GetStreamer(); +} + +void DwarfGen::EmitCompileUnit() { + MCContext &context = Streamer->getContext(); + unsigned TargetPointerSize = context.getAsmInfo()->getCodePointerSize(); + + MCSymbol *LineSectionSymbol = nullptr; + MCSymbol *AbbrevSectionSymbol = nullptr; + if (context.getAsmInfo()->doesDwarfUseRelocationsAcrossSections()) { + LineSectionSymbol = Streamer->getDwarfLineTableSymbol(0); + + Streamer->switchSection(context.getObjectFileInfo()->getDwarfAbbrevSection()); + AbbrevSectionSymbol = context.createTempSymbol(); + Streamer->emitLabel(AbbrevSectionSymbol); + } + + // Create strings for producer, name and directory in the compile unit. + Streamer->switchSection(context.getObjectFileInfo()->getDwarfStrSection()); + + MCSymbol *ProducerStrSymbol = context.createTempSymbol(); + Streamer->emitLabel(ProducerStrSymbol); + Streamer->emitBytes(StringRef("NetRuntime")); + Streamer->emitIntValue(0, 1); + + MCSymbol *NameStrSymbol = context.createTempSymbol(); + Streamer->emitLabel(NameStrSymbol); + Streamer->emitBytes(StringRef("il.cpp")); + Streamer->emitIntValue(0, 1); + + MCSymbol *DirStrSymbol = context.createTempSymbol(); + Streamer->emitLabel(DirStrSymbol); + Streamer->emitBytes(StringRef("/_")); + Streamer->emitIntValue(0, 1); + + MCSection *debugSection = context.getObjectFileInfo()->getDwarfInfoSection(); + Streamer->switchSection(debugSection); + + InfoStart = debugSection->getBeginSymbol(); + InfoEnd = context.createTempSymbol(); + + // Length + const MCExpr *Length = MakeStartMinusEndExpr(*Streamer, *InfoStart, *InfoEnd, 4); + emitAbsValue(*Streamer, Length, 4); + + // Version + Streamer->emitIntValue(context.getDwarfVersion(), 2); + + // Unit type, Addr Size and Abbrev offset - DWARF >= 5 + // Abbrev offset, Addr Size - DWARF <= 4 + unsigned addrSize = context.getAsmInfo()->getCodePointerSize(); + if (context.getDwarfVersion() >= 5) { + Streamer->emitIntValue(dwarf::DW_UT_compile, 1); + Streamer->emitIntValue(addrSize, 1); + } + + // Abbrev Offset + if (AbbrevSectionSymbol == nullptr) { + Streamer->emitIntValue(0, 4); + } else { + Streamer->emitSymbolValue(AbbrevSectionSymbol, 4, + context.getAsmInfo()->needsDwarfSectionOffsetDirective()); + } + + if (context.getDwarfVersion() <= 4) + Streamer->emitIntValue(addrSize, 1); + + // CompileUnit DIE + + // Abbrev Number + Streamer->emitULEB128IntValue(DwarfAbbrev::CompileUnit); + + // DW_AT_producer: NetRuntime + DwarfInfo::EmitSectionOffset(Streamer, ProducerStrSymbol, 4); + + // DW_AT_language +#ifdef FEATURE_LANGID_CS + Streamer->EmitIntValue(DW_LANG_MICROSOFT_CSHARP, 2); +#else + Streamer->emitIntValue(dwarf::DW_LANG_C_plus_plus, 2); +#endif + + // We need to generate DW_AT_name and DW_AT_comp_dir to get Apple's ld64 to correctly + // generate debug map in final executable. If we don't generate it then the linker + // will skip over the object file. + // Ref: https://github.com/apple-oss-distributions/ld64/blob/dbf8f7feb5579761f1623b004bd468bdea7c6225/src/ld/OutputFile.cpp#L7166 + + // DW_AT_name + DwarfInfo::EmitSectionOffset(Streamer, NameStrSymbol, 4); + + // DW_AT_comp_dir + DwarfInfo::EmitSectionOffset(Streamer, DirStrSymbol, 4); + + // There need to be global DW_AT_low_pc/DW_AT_high_pc symbols to indicate the base and + // size of the range covered by the symbols. Currently we use a shortcut where we emit + // a range starting at the beginning of file and ending at the start of the debug section + // which is located at the end of the object file. + + // DW_AT_low_pc + Streamer->emitIntValue(0, TargetPointerSize); + + // DW_AT_high_pc + const MCExpr *SymExpr = MCSymbolRefExpr::create(debugSection->getBeginSymbol(), MCSymbolRefExpr::VK_None, context); + Streamer->emitValue(SymExpr, TargetPointerSize); + + // DW_AT_stmt_list + if (LineSectionSymbol == nullptr) { + Streamer->emitIntValue(0, 4); + } else { + Streamer->emitSymbolValue(LineSectionSymbol, 4, + context.getAsmInfo()->needsDwarfSectionOffsetDirective()); + } +} + +void DwarfGen::EmitSubprogramInfo(const char *FunctionName, + int FunctionSize, + unsigned MethodTypeIndex, + const std::vector &VarInfos, + const std::vector &DebugEHClauseInfos) { + // return if CU isn't emitted + if (InfoStart == nullptr) + return; + + if (MethodTypeIndex == 0) + return; + + DwarfMemberFunctionIdTypeInfo *MethodTypeInfo = static_cast( + TypeBuilder->GetTypeInfoByIndex(MethodTypeIndex)); + assert(MethodTypeInfo != nullptr); + + MethodTypeInfo->SetLinkageName(FunctionName); + + Subprograms.emplace_back(FunctionName, FunctionSize, MethodTypeInfo, VarInfos, DebugEHClauseInfos); +} + +void DwarfGen::EmitAbbrev() { + // return if CU isn't emitted + if (InfoStart == nullptr) + return; + + MCContext &context = Streamer->getContext(); + + DwarfAbbrev::Dump(Streamer, context.getDwarfVersion(), + context.getAsmInfo()->getCodePointerSize()); +} + +void DwarfGen::EmitAranges() { + // return if CU isn't emitted + if (InfoStart == nullptr) + return; + + MCContext &context = Streamer->getContext(); + Streamer->switchSection(context.getObjectFileInfo()->getDwarfARangesSection()); + + auto &Sections = context.getGenDwarfSectionSyms(); + + int Length = 4 + 2 + 4 + 1 + 1; + int AddrSize = context.getAsmInfo()->getCodePointerSize(); + int Pad = 2 * AddrSize - (Length & (2 * AddrSize - 1)); + if (Pad == 2 * AddrSize) + Pad = 0; + Length += Pad; + + Length += 2 * AddrSize * Sections.size(); + Length += 2 * AddrSize; + + // Emit the header for this section. + // The 4 byte length not including the 4 byte value for the length. + Streamer->emitIntValue(Length - 4, 4); + + // The 2 byte version, which is 2. + Streamer->emitIntValue(2, 2); + + // The 4 byte offset to the compile unit in the .debug_info from the start + // of the .debug_info. + Streamer->emitSymbolValue(InfoStart, 4, + context.getAsmInfo()->needsDwarfSectionOffsetDirective()); + + Streamer->emitIntValue(AddrSize, 1); + + Streamer->emitIntValue(0, 1); + + for(int i = 0; i < Pad; i++) + Streamer->emitIntValue(0, 1); + + for (MCSection *Sec : Sections) { + const MCSymbol *StartSymbol = Sec->getBeginSymbol(); + MCSymbol *EndSymbol = Sec->getEndSymbol(context); + assert(StartSymbol && "StartSymbol must not be NULL"); + assert(EndSymbol && "EndSymbol must not be NULL"); + + const MCExpr *Addr = MCSymbolRefExpr::create( + StartSymbol, MCSymbolRefExpr::VK_None, context); + const MCExpr *Size = MakeStartMinusEndExpr(*Streamer, + *StartSymbol, *EndSymbol, 0); + Streamer->emitValue(Addr, AddrSize); + emitAbsValue(*Streamer, Size, AddrSize); + } + + // Terminating zeros. + Streamer->emitIntValue(0, AddrSize); + Streamer->emitIntValue(0, AddrSize); +} + +void DwarfGen::Finish() { + // return if CU isn't emitted + if (InfoStart == nullptr) + return; + + MCContext &context = Streamer->getContext(); + + // Dump type info + + MCSection *InfoSection = context.getObjectFileInfo()->getDwarfInfoSection(); + MCSection *StrSection = context.getObjectFileInfo()->getDwarfStrSection(); + MCSection *LocSection = context.getObjectFileInfo()->getDwarfLocSection(); + + TypeBuilder->EmitTypeInformation(InfoSection, StrSection); + + // Dump subprograms + + for (auto &Subprogram : Subprograms) { + Subprogram.Dump(TypeBuilder, Streamer, InfoSection, StrSection, LocSection); + } + + // Dump static vars + + for (const auto *ClassTypeInfo : TypeBuilder->GetClassesWithStaticFields()) { + for (const auto &StaticField : ClassTypeInfo->GetStaticFields()) { + StaticVarInfo Info(&StaticField); + Info.Dump(TypeBuilder, Streamer, InfoSection, StrSection); + } + } + + // Add the NULL terminating the Compile Unit DIE's. + Streamer->switchSection(context.getObjectFileInfo()->getDwarfInfoSection()); + + Streamer->emitIntValue(0, 1); + + Streamer->emitLabel(InfoEnd); + + Streamer->switchSection(context.getObjectFileInfo()->getDwarfAbbrevSection()); + + // Terminate the abbreviations for this compilation unit + Streamer->emitIntValue(0, 1); +} diff --git a/llvm/tools/objwriter/debugInfo/dwarf/dwarfGen.h b/llvm/tools/objwriter/debugInfo/dwarf/dwarfGen.h new file mode 100644 index 00000000000000..b3a9b4c0c7ba64 --- /dev/null +++ b/llvm/tools/objwriter/debugInfo/dwarf/dwarfGen.h @@ -0,0 +1,106 @@ +//===---- dwarfGen.h --------------------------------------------*- C++ -*-===// +// +// dwarf generator is used to generate dwarf debuginfo. +// +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +//===----------------------------------------------------------------------===// + +#pragma once + +#include "llvm/MC/MCObjectStreamer.h" + +#include "dwarfTypeBuilder.h" +#include "jitDebugInfo.h" + +#include + +class VarInfo : public DwarfInfo +{ +public: + VarInfo(const DebugVarInfo &Info, bool IsThis); + + bool IsDebugLocNeeded() const { return DebugInfo.Ranges.size() > 1; } + + void DumpLocsIfNeeded(MCObjectStreamer *Streamer, MCSection *LocSection, const MCExpr *SymExpr); + + uint64_t GetStartOffset() const { return StartOffset; } + + uint64_t GetEndOffset() const { return EndOffset; } + + bool IsParam() const { return DebugInfo.IsParam; } + +protected: + void DumpStrings(MCObjectStreamer *Streamer) override; + void DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) override; + +private: + DebugVarInfo DebugInfo; + MCSymbol *LocSymbol; + bool IsThis; + uint64_t StartOffset; + uint64_t EndOffset; +}; + +class SubprogramInfo : public DwarfInfo +{ +public: + using DwarfInfo::Dump; + + SubprogramInfo(const char *Name, + int Size, + DwarfMemberFunctionIdTypeInfo *MethodTypeInfo, + const std::vector &DebugVarInfos, + const std::vector &DebugEHClauseInfos); + + void Dump(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer, + MCSection *TypeSection, MCSection *StrSection, MCSection *LocSection); + +protected: + void DumpStrings(MCObjectStreamer *Streamer) override {} + void DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) override; + bool HasChildren() override; + +private: + void DumpDebugLoc(MCObjectStreamer *Streamer, MCSection *LocSection); + void DumpVars(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer, + MCSection *TypeSection, MCSection *StrSection); + void DumpEHClauses(MCObjectStreamer *Streamer, MCSection *TypeSection); + + std::string Name; + int Size; + DwarfMemberFunctionIdTypeInfo *MethodTypeInfo; + std::vector DebugEHClauseInfos; + std::vector VarInfos; +}; + +class DwarfGen +{ +public: + DwarfGen() : Streamer(nullptr), + TypeBuilder(nullptr), + InfoStart(nullptr), + InfoEnd(nullptr) {} + + void SetTypeBuilder(UserDefinedDwarfTypesBuilder *TypeBuilder); + void EmitCompileUnit(); + void EmitSubprogramInfo(const char *FunctionName, + int FunctionSize, + unsigned MethodTypeIndex, + const std::vector &VarsInfo, + const std::vector &DebugEHClauseInfos); + + void EmitAbbrev(); + void EmitAranges(); + void Finish(); + +private: + MCObjectStreamer *Streamer; + UserDefinedDwarfTypesBuilder *TypeBuilder; + + MCSymbol *InfoStart; + MCSymbol *InfoEnd; + + std::vector Subprograms; +}; diff --git a/llvm/tools/objwriter/debugInfo/dwarf/dwarfTypeBuilder.cpp b/llvm/tools/objwriter/debugInfo/dwarf/dwarfTypeBuilder.cpp new file mode 100644 index 00000000000000..35bac197e01f21 --- /dev/null +++ b/llvm/tools/objwriter/debugInfo/dwarf/dwarfTypeBuilder.cpp @@ -0,0 +1,846 @@ +//===---- dwarfTypeBuilder.cpp ----------------------------------*- C++ -*-===// +// +// dwarf type builder implementation +// +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +//===----------------------------------------------------------------------===// + +#include "dwarfTypeBuilder.h" +#include "dwarfAbbrev.h" +#include "llvm/MC/MCContext.h" +#include "llvm/MC/MCAsmInfo.h" +#include "llvm/MC/MCExpr.h" +#include "llvm/MC/MCObjectFileInfo.h" +#include "llvm/MC/MCSymbol.h" + +#include +#include + +// DwarfInfo + +void DwarfInfo::Dump(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer, + MCSection *TypeSection, MCSection *StrSection) { + if (IsDumped) + return; + + IsDumped = true; + + MCContext &context = Streamer->getContext(); + + InfoSymbol = context.createTempSymbol(); + InfoExpr = CreateOffsetExpr(context, TypeSection->getBeginSymbol(), InfoSymbol); + + DumpTypes(TypeBuilder, Streamer, TypeSection, StrSection); + + Streamer->switchSection(StrSection); + StrSymbol = context.createTempSymbol(); + Streamer->emitLabel(StrSymbol); + DumpStrings(Streamer); + + Streamer->switchSection(TypeSection); + Streamer->emitLabel(InfoSymbol); + DumpTypeInfo(Streamer, TypeBuilder); +} + +void DwarfInfo::DumpTypes(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer, + MCSection *TypeSection, MCSection *StrSection) { + if (IsDumpedTypes) + return; + + IsDumpedTypes = true; +} + +void DwarfInfo::EndChildrenList(MCObjectStreamer* Streamer) { + if (HasChildren()) { + // Emit null entry + Streamer->emitIntValue(0, 1); + } +} + +void DwarfInfo::EmitSectionOffset(MCObjectStreamer *Streamer, + MCSymbol *Symbol, + unsigned Size, + uint32_t Offset) { + MCContext &context = Streamer->getContext(); + + if (context.getAsmInfo()->doesDwarfUseRelocationsAcrossSections()) { + if (Offset == 0) { + Streamer->emitSymbolValue(Symbol, Size); + } else { + const MCSymbolRefExpr *SymbolExpr = MCSymbolRefExpr::create(Symbol, + MCSymbolRefExpr::VK_None, context); + const MCExpr *OffsetExpr = MCConstantExpr::create(Offset, context); + const MCExpr *Expr = MCBinaryExpr::createAdd(SymbolExpr, OffsetExpr, context); + Streamer->emitValue(Expr, Size); + } + } else { + Streamer->emitIntValue(Symbol->getOffset() + Offset, Size); + } +} + +const MCExpr *DwarfInfo::CreateOffsetExpr(MCContext &Context, + MCSymbol *BeginSymbol, + MCSymbol *Symbol) { + MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None; + const MCExpr *StartExpr = + MCSymbolRefExpr::create(BeginSymbol, Variant, Context); + const MCExpr *EndExpr = + MCSymbolRefExpr::create(Symbol, Variant, Context); + return MCBinaryExpr::createSub(EndExpr, StartExpr, Context); +} + +void DwarfInfo::EmitOffset(MCObjectStreamer *Streamer, + const MCExpr *OffsetExpr, + unsigned Size) { + MCContext &context = Streamer->getContext(); + + if (!context.getAsmInfo()->hasAggressiveSymbolFolding()) { + MCSymbol *Temp = context.createTempSymbol(); + Streamer->emitAssignment(Temp, OffsetExpr); + OffsetExpr = MCSymbolRefExpr::create(Temp, context); + } + + Streamer->emitValue(OffsetExpr, Size); +} + +void DwarfInfo::EmitInfoOffset(MCObjectStreamer *Streamer, const DwarfInfo *Info, unsigned Size) { + uint64_t Offset = Info->InfoSymbol->getOffset(); + if (Offset != 0) { + Streamer->emitIntValue(Offset, Size); + } else { + EmitOffset(Streamer, Info->InfoExpr, Size); + } +} + +// DwarfPrimitiveTypeInfo + +struct PrimitiveTypeDesc { + const char *Name; + int Encoding; + unsigned ByteSize; +}; + +static PrimitiveTypeDesc GetPrimitiveTypeDesc(PrimitiveTypeFlags Type, unsigned TargetPointerSize) { + switch (Type) { + case PrimitiveTypeFlags::Boolean: return {"bool", dwarf::DW_ATE_boolean, 1}; + case PrimitiveTypeFlags::Char: return {"char16_t", dwarf::DW_ATE_UTF, 2}; + case PrimitiveTypeFlags::SByte: return {"sbyte", dwarf::DW_ATE_signed, 1}; + case PrimitiveTypeFlags::Byte: return {"byte", dwarf::DW_ATE_unsigned, 1}; + case PrimitiveTypeFlags::Int16: return {"short", dwarf::DW_ATE_signed, 2}; + case PrimitiveTypeFlags::UInt16: return {"ushort", dwarf::DW_ATE_unsigned, 2}; + case PrimitiveTypeFlags::Int32: return {"int", dwarf::DW_ATE_signed, 4}; + case PrimitiveTypeFlags::UInt32: return {"uint", dwarf::DW_ATE_unsigned, 4}; + case PrimitiveTypeFlags::Int64: return {"long", dwarf::DW_ATE_signed, 8}; + case PrimitiveTypeFlags::UInt64: return {"ulong", dwarf::DW_ATE_unsigned, 8}; + case PrimitiveTypeFlags::IntPtr: return {"System.IntPtr", dwarf::DW_ATE_signed, TargetPointerSize}; + case PrimitiveTypeFlags::UIntPtr: return {"System.UIntPtr", dwarf::DW_ATE_unsigned, TargetPointerSize}; + case PrimitiveTypeFlags::Single: return {"float", dwarf::DW_ATE_float, 4}; + case PrimitiveTypeFlags::Double: return {"double", dwarf::DW_ATE_float, 8}; + default: + assert(false && "Unexpected type"); + return {nullptr, 0, 0}; + } +} + +void DwarfPrimitiveTypeInfo::DumpStrings(MCObjectStreamer *Streamer) { + MCContext &context = Streamer->getContext(); + unsigned TargetPointerSize = context.getAsmInfo()->getCodePointerSize(); + + PrimitiveTypeDesc TD = GetPrimitiveTypeDesc(Type, TargetPointerSize); + if (TD.Name == nullptr) + return; + + Streamer->emitBytes(StringRef(TD.Name)); + Streamer->emitIntValue(0, 1); +} + +void DwarfPrimitiveTypeInfo::DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) { + MCContext &context = Streamer->getContext(); + unsigned TargetPointerSize = context.getAsmInfo()->getCodePointerSize(); + + PrimitiveTypeDesc TD = GetPrimitiveTypeDesc(Type, TargetPointerSize); + if (TD.Name == nullptr) + return; + + // Abbrev Number + Streamer->emitULEB128IntValue(DwarfAbbrev::BaseType); + + // DW_AT_name + EmitSectionOffset(Streamer, StrSymbol, 4); + + // DW_AT_encoding + Streamer->emitIntValue(TD.Encoding, 1); + + // DW_AT_byte_size + Streamer->emitIntValue(TD.ByteSize, 1); +} + +// DwarfVoidTypeInfo + +void DwarfVoidTypeInfo::DumpStrings(MCObjectStreamer* Streamer) { + Streamer->emitBytes(StringRef("void")); + Streamer->emitIntValue(0, 1); +} + +void DwarfVoidTypeInfo::DumpTypeInfo(MCObjectStreamer* Streamer, UserDefinedDwarfTypesBuilder* TypeBuilder) { + // Abbrev Number + Streamer->emitULEB128IntValue(DwarfAbbrev::VoidType); + + // DW_AT_name + EmitSectionOffset(Streamer, StrSymbol, 4); +} + +// DwarfEnumerator + +void DwarfEnumerator::DumpStrings(MCObjectStreamer *Streamer) { + Streamer->emitBytes(Name); + Streamer->emitIntValue(0, 1); +} + +void DwarfEnumerator::DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) { + uint8_t Size = EnumTypeInfo->GetByteSize(); + + // Abbrev Number + switch (Size) { + case 1: + Streamer->emitULEB128IntValue(DwarfAbbrev::Enumerator1); + break; + case 2: + Streamer->emitULEB128IntValue(DwarfAbbrev::Enumerator2); + break; + case 4: + Streamer->emitULEB128IntValue(DwarfAbbrev::Enumerator4); + break; + case 8: + Streamer->emitULEB128IntValue(DwarfAbbrev::Enumerator8); + break; + default: + assert(false && "Unexpected byte size value"); + } + + // DW_AT_name + EmitSectionOffset(Streamer, StrSymbol, 4); + + // DW_AT_const_value + Streamer->emitIntValue(Value, Size); +} + +// DwarfEnumTypeInfo + +DwarfEnumTypeInfo::DwarfEnumTypeInfo(const EnumTypeDescriptor &TypeDescriptor, + const EnumRecordTypeDescriptor *TypeRecords) : + Name(TypeDescriptor.Name), + ElementType(TypeDescriptor.ElementType) { + for (uint64 i = 0; i < TypeDescriptor.ElementCount; i++) { + Records.emplace_back(TypeRecords[i], this); + } +} + +void DwarfEnumTypeInfo::DumpTypes(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer, + MCSection *TypeSection, MCSection *StrSection) { + if (IsDumpedTypes) + return; + + DwarfInfo::DumpTypes(TypeBuilder, Streamer, TypeSection, StrSection); + + DwarfInfo *Info = TypeBuilder->GetTypeInfoByIndex(ElementType); + assert(Info != nullptr); + + Info->Dump(TypeBuilder, Streamer, TypeSection, StrSection); +} + +void DwarfEnumTypeInfo::Dump(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer, + MCSection *TypeSection, MCSection *StrSection) { + if (IsDumped) + return; + + MCContext &context = Streamer->getContext(); + unsigned TargetPointerSize = context.getAsmInfo()->getCodePointerSize(); + + DwarfPrimitiveTypeInfo *ElementTypeInfo = static_cast( + TypeBuilder->GetTypeInfoByIndex(ElementType)); + assert(ElementTypeInfo != nullptr); + + PrimitiveTypeDesc TD = GetPrimitiveTypeDesc(ElementTypeInfo->GetType(), TargetPointerSize); + ByteSize = TD.ByteSize; + + DwarfInfo::Dump(TypeBuilder, Streamer, TypeSection, StrSection); + + for (auto &Enumerator : Records) { + Enumerator.Dump(TypeBuilder, Streamer, TypeSection, StrSection); + } + + // Terminate DIE + Streamer->switchSection(TypeSection); + EndChildrenList(Streamer); +} + +void DwarfEnumTypeInfo::DumpStrings(MCObjectStreamer *Streamer) { + Streamer->emitBytes(Name); + Streamer->emitIntValue(0, 1); +} + +void DwarfEnumTypeInfo::DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) { + // Abbrev Number + Streamer->emitULEB128IntValue(DwarfAbbrev::EnumerationType); + + // DW_AT_name + EmitSectionOffset(Streamer, StrSymbol, 4); + + // DW_AT_type + DwarfInfo *Info = TypeBuilder->GetTypeInfoByIndex(ElementType); + assert(Info != nullptr); + + EmitInfoOffset(Streamer, Info, 4); + + // DW_AT_byte_size + Streamer->emitIntValue(ByteSize, 1); +} + +// DwarfDataField + +void DwarfDataField::DumpStrings(MCObjectStreamer *Streamer) { + Streamer->emitBytes(StringRef(Name)); + Streamer->emitIntValue(0, 1); +} + +void DwarfDataField::DumpTypes(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer, + MCSection *TypeSection, MCSection *StrSection) { + if (IsDumpedTypes) + return; + + DwarfInfo::DumpTypes(TypeBuilder, Streamer, TypeSection, StrSection); + + DwarfInfo *MemberTypeInfo = TypeBuilder->GetTypeInfoByIndex(TypeIndex); + assert(MemberTypeInfo != nullptr); + + MemberTypeInfo->Dump(TypeBuilder, Streamer, TypeSection, StrSection); +} + +void DwarfDataField::DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) { + // Abbrev Number + Streamer->emitULEB128IntValue(DwarfAbbrev::ClassMember); + + // DW_AT_name + EmitSectionOffset(Streamer, StrSymbol, 4); + + // DW_AT_type + DwarfInfo *MemberTypeInfo = TypeBuilder->GetTypeInfoByIndex(TypeIndex); + assert(MemberTypeInfo != nullptr); + EmitInfoOffset(Streamer, MemberTypeInfo, 4); + + // DW_AT_data_member_location + Streamer->emitIntValue(Offset, 4); +} + +// DwarfStaticDataField + +void DwarfStaticDataField::DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) { + // Abbrev Number + Streamer->emitULEB128IntValue(DwarfAbbrev::ClassMemberStatic); + + // DW_AT_name + EmitSectionOffset(Streamer, StrSymbol, 4); + + // DW_AT_type + DwarfInfo *MemberTypeInfo = TypeBuilder->GetTypeInfoByIndex(TypeIndex); + assert(MemberTypeInfo != nullptr); + EmitInfoOffset(Streamer, MemberTypeInfo, 4); +} + +// DwarfClassTypeInfo + +DwarfClassTypeInfo::DwarfClassTypeInfo(const ClassTypeDescriptor &ClassDescriptor, + const ClassFieldsTypeDescriptior &ClassFieldsDescriptor, + const DataFieldDescriptor *FieldsDescriptors, + const StaticDataFieldDescriptor *StaticsDescriptors) : + Name(ClassDescriptor.Name), + IsStruct(ClassDescriptor.IsStruct), + BaseClassId(ClassDescriptor.BaseClassId), + Size(ClassDescriptor.InstanceSize), + IsForwardDecl(false) { + int32_t staticIdx = 0; + for (int32_t i = 0; i < ClassFieldsDescriptor.FieldsCount; i++) { + if (FieldsDescriptors[i].Offset == 0xFFFFFFFF) { + StaticFields.emplace_back(FieldsDescriptors[i], StaticsDescriptors[staticIdx++]); + } else { + Fields.emplace_back(FieldsDescriptors[i]); + } + } +} + +void DwarfClassTypeInfo::DumpTypes(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer, + MCSection *TypeSection, MCSection *StrSection) { + if (IsDumpedTypes) + return; + + DwarfInfo::DumpTypes(TypeBuilder, Streamer, TypeSection, StrSection); + + if (BaseClassId != 0) { + DwarfInfo *BaseClassInfo = TypeBuilder->GetTypeInfoByIndex(BaseClassId); + assert(BaseClassInfo != nullptr); + + BaseClassInfo->Dump(TypeBuilder, Streamer, TypeSection, StrSection); + } + + for (auto &Field : Fields) { + Field.DumpTypes(TypeBuilder, Streamer, TypeSection, StrSection); + } + + for (auto &StaticField : StaticFields) { + StaticField.DumpTypes(TypeBuilder, Streamer, TypeSection, StrSection); + } + + for (auto *Function : MemberFunctions) { + Function->DumpTypes(TypeBuilder, Streamer, TypeSection, StrSection); + } +} + +void DwarfClassTypeInfo::Dump(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer, + MCSection *TypeSection, MCSection *StrSection) { + if (IsDumped) + return; + + DwarfInfo::Dump(TypeBuilder, Streamer, TypeSection, StrSection); + + if (IsForwardDecl) + return; + + for (auto &Field : Fields) { + Field.Dump(TypeBuilder, Streamer, TypeSection, StrSection); + } + + for (auto &StaticField : StaticFields) { + StaticField.Dump(TypeBuilder, Streamer, TypeSection, StrSection); + } + + for (auto *Function : MemberFunctions) { + Function->Dump(TypeBuilder, Streamer, TypeSection, StrSection); + } + + // Terminate DIE + Streamer->switchSection(TypeSection); + DwarfInfo::EndChildrenList(Streamer); +} + +void DwarfClassTypeInfo::DumpStrings(MCObjectStreamer *Streamer) { + Streamer->emitBytes(StringRef(Name)); + Streamer->emitIntValue(0, 1); +} + +void DwarfClassTypeInfo::DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) { + // Abbrev Number + auto abbrev = IsForwardDecl ? DwarfAbbrev::ClassTypeDecl + : HasChildren() ? DwarfAbbrev::ClassType + : DwarfAbbrev::ClassTypeNoChildren; + + Streamer->emitULEB128IntValue(abbrev); + + // DW_AT_name + EmitSectionOffset(Streamer, StrSymbol, 4); + + if (!IsForwardDecl) { + // DW_AT_byte_size + Streamer->emitIntValue(Size, 4); + } + + if (BaseClassId != 0) { + DwarfInfo *BaseClassInfo = TypeBuilder->GetTypeInfoByIndex(BaseClassId); + assert(BaseClassInfo != nullptr); + + // DW_TAG_inheritance DIE + + // Abbrev Number + Streamer->emitULEB128IntValue(DwarfAbbrev::ClassInheritance); + + // DW_AT_type + EmitInfoOffset(Streamer, BaseClassInfo, 4); + + // DW_AT_data_member_location = 0 + Streamer->emitIntValue(0, 1); + } +} + +bool DwarfClassTypeInfo::HasChildren() { + return BaseClassId != 0 || !Fields.empty() || !StaticFields.empty() || !MemberFunctions.empty(); +} + +// DwarfSimpleArrayTypeInfo + +void DwarfSimpleArrayTypeInfo::DumpTypes(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer, + MCSection *TypeSection, MCSection *StrSection) { + if (IsDumpedTypes) + return; + + DwarfInfo::DumpTypes(TypeBuilder, Streamer, TypeSection, StrSection); + + DwarfInfo *ElementInfo = TypeBuilder->GetTypeInfoByIndex(ElementType); + assert(ElementInfo != nullptr); + + ElementInfo->Dump(TypeBuilder, Streamer, TypeSection, StrSection); +} + +void DwarfSimpleArrayTypeInfo::DumpStrings(MCObjectStreamer *Streamer) { + // nothing to dump +} + +void DwarfSimpleArrayTypeInfo::DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) { + // Abbrev Number + Streamer->emitULEB128IntValue(DwarfAbbrev::ArrayType); + + DwarfInfo *Info = TypeBuilder->GetTypeInfoByIndex(ElementType); + assert(Info != nullptr); + + // DW_AT_type + EmitInfoOffset(Streamer, Info, 4); + + // DW_TAG_subrange_type DIE + + // Abbrev Number + Streamer->emitULEB128IntValue(DwarfAbbrev::SubrangeType); + + // DW_AT_upper_bound + Streamer->emitULEB128IntValue(Size - 1); + + // Terminate DIE + EndChildrenList(Streamer); +} + +// DwarfPointerTypeInfo + +void DwarfPointerTypeInfo::DumpTypes(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer, + MCSection *TypeSection, MCSection *StrSection) { + if (IsDumpedTypes) + return; + + DwarfInfo::DumpTypes(TypeBuilder, Streamer, TypeSection, StrSection); + + DwarfInfo *Info = TypeBuilder->GetTypeInfoByIndex(TypeDesc.ElementType); + assert(Info != nullptr); + + Info->Dump(TypeBuilder, Streamer, TypeSection, StrSection); +} + +void DwarfPointerTypeInfo::DumpStrings(MCObjectStreamer *Streamer) { + // nothing to dump +} + +void DwarfPointerTypeInfo::DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) { + // Abbrev Number + Streamer->emitULEB128IntValue(TypeDesc.IsReference ? DwarfAbbrev::ReferenceType : DwarfAbbrev::PointerType); + + DwarfInfo *Info = TypeBuilder->GetTypeInfoByIndex(TypeDesc.ElementType); + assert(Info != nullptr); + + // DW_AT_type + EmitInfoOffset(Streamer, Info, 4); + + // DW_AT_byte_size + Streamer->emitIntValue(TypeDesc.Is64Bit ? 8 : 4, 1); +} + +// DwarfVoidPtrTypeInfo + +void DwarfVoidPtrTypeInfo::DumpStrings(MCObjectStreamer* Streamer) { + // nothing to dump +} + +void DwarfVoidPtrTypeInfo::DumpTypeInfo(MCObjectStreamer* Streamer, UserDefinedDwarfTypesBuilder* TypeBuilder) { + // Abbrev Number + Streamer->emitULEB128IntValue(DwarfAbbrev::VoidPointerType); +} + +// DwarfMemberFunctionTypeInfo + +DwarfMemberFunctionTypeInfo::DwarfMemberFunctionTypeInfo( + const MemberFunctionTypeDescriptor& MemberDescriptor, + uint32_t const *const ArgumentTypes, + bool IsStaticMethod) : + TypeDesc(MemberDescriptor), + IsStaticMethod(IsStaticMethod) { + for (uint16_t i = 0; i < MemberDescriptor.NumberOfArguments; i++) { + this->ArgumentTypes.push_back(ArgumentTypes[i]); + } +} + +void DwarfMemberFunctionTypeInfo::DumpStrings(MCObjectStreamer *Streamer) { + // nothing to dump +} + +void DwarfMemberFunctionTypeInfo::DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) { + // nothing to dump +} + +// DwarfMemberFunctionIdTypeInfo + +void DwarfMemberFunctionIdTypeInfo::DumpTypes(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer, + MCSection *TypeSection, MCSection *StrSection) { + if (IsDumpedTypes) + return; + + DwarfInfo::DumpTypes(TypeBuilder, Streamer, TypeSection, StrSection); + + // Dump return type + DwarfInfo *ReturnTypeInfo = TypeBuilder->GetTypeInfoByIndex(MemberFunctionTypeInfo->GetReturnTypeIndex()); + assert(ReturnTypeInfo != nullptr); + + ReturnTypeInfo->Dump(TypeBuilder, Streamer, TypeSection, StrSection); + + // Dump this pointer type + if (!MemberFunctionTypeInfo->IsStatic()) { + DwarfInfo *ThisPtrTypeInfo = TypeBuilder->GetTypeInfoByIndex(MemberFunctionTypeInfo->GetThisPtrTypeIndex()); + assert(ThisPtrTypeInfo != nullptr); + + ThisPtrTypeInfo->Dump(TypeBuilder, Streamer, TypeSection, StrSection); + } + + // Dump argument types + for (uint32_t ArgTypeIndex : MemberFunctionTypeInfo->GetArgTypes()) { + DwarfInfo *ArgTypeInfo = TypeBuilder->GetTypeInfoByIndex(ArgTypeIndex); + assert(ArgTypeInfo != nullptr); + ArgTypeInfo->Dump(TypeBuilder, Streamer, TypeSection, StrSection); + } +} + +void DwarfMemberFunctionIdTypeInfo::DumpStrings(MCObjectStreamer *Streamer) { + Streamer->emitBytes(StringRef(Name)); + Streamer->emitIntValue(0, 1); + + MCContext &context = Streamer->getContext(); + LinkageNameSymbol = context.createTempSymbol(); + Streamer->emitLabel(LinkageNameSymbol); + Streamer->emitBytes(StringRef(LinkageName)); + Streamer->emitIntValue(0, 1); +} + +void DwarfMemberFunctionIdTypeInfo::DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) { + // Abbrev Number + bool IsStatic = MemberFunctionTypeInfo->IsStatic(); + bool HasParameters = MemberFunctionTypeInfo->GetArgTypes().size(); + + Streamer->emitULEB128IntValue( + IsStatic ? (HasParameters ? DwarfAbbrev::SubprogramStaticSpec + : DwarfAbbrev::SubprogramStaticNoChildrenSpec) + : DwarfAbbrev::SubprogramSpec); + + // DW_AT_name + EmitSectionOffset(Streamer, StrSymbol, 4); + + // DW_AT_linkage_name + EmitSectionOffset(Streamer, LinkageNameSymbol, 4); + + // DW_AT_decl_file + Streamer->emitIntValue(1, 1); + + // DW_AT_decl_line + Streamer->emitIntValue(1, 1); + + // DW_AT_type + DwarfInfo *ReturnTypeInfo = TypeBuilder->GetTypeInfoByIndex(MemberFunctionTypeInfo->GetReturnTypeIndex()); + assert(ReturnTypeInfo != nullptr); + + EmitInfoOffset(Streamer, ReturnTypeInfo, 4); + + if (!IsStatic) { + // DW_AT_object_pointer + uint32_t Offset = Streamer->getOrCreateDataFragment()->getContents().size(); + + Streamer->emitIntValue(Offset + 4, 4); + + // This formal parameter DIE + DwarfInfo *ThisTypeInfo = TypeBuilder->GetTypeInfoByIndex(MemberFunctionTypeInfo->GetThisPtrTypeIndex()); + assert(ThisTypeInfo != nullptr); + + // Abbrev Number + Streamer->emitULEB128IntValue(DwarfAbbrev::FormalParameterThisSpec); + + // DW_AT_type + EmitInfoOffset(Streamer, ThisTypeInfo, 4); + } + + for (uint32_t ArgTypeIndex : MemberFunctionTypeInfo->GetArgTypes()) { + DwarfInfo *ArgTypeInfo = TypeBuilder->GetTypeInfoByIndex(ArgTypeIndex); + assert(ArgTypeInfo != nullptr); + + // Formal parameter DIE + + // Abbrev Number + Streamer->emitULEB128IntValue(DwarfAbbrev::FormalParameterSpec); + + // DW_AT_type + EmitInfoOffset(Streamer, ArgTypeInfo, 4); + } + + // Terminate DIE (skip for SubprogramStaticNoChildrenSpec which has no children) + if (!IsStatic || HasParameters) { + Streamer->emitIntValue(0, 1); + } +} + +// DwarfTypesBuilder + +void UserDefinedDwarfTypesBuilder::EmitTypeInformation( + MCSection *TypeSection, + MCSection *StrSection) { + for (auto &Info : DwarfTypes) { + Info->Dump(this, Streamer, TypeSection, StrSection); + } +} + +unsigned UserDefinedDwarfTypesBuilder::GetEnumTypeIndex( + const EnumTypeDescriptor &TypeDescriptor, + const EnumRecordTypeDescriptor *TypeRecords) { + unsigned TypeIndex = ArrayIndexToTypeIndex(DwarfTypes.size()); + UserDefinedTypes.push_back(std::make_pair(TypeDescriptor.Name, TypeIndex)); + DwarfTypes.push_back(std::make_unique(TypeDescriptor, TypeRecords)); + return TypeIndex; +} + +unsigned UserDefinedDwarfTypesBuilder::GetClassTypeIndex( + const ClassTypeDescriptor &ClassDescriptor) { + unsigned TypeIndex = ArrayIndexToTypeIndex(DwarfTypes.size()); + DwarfTypes.push_back(std::make_unique(ClassDescriptor)); + return TypeIndex; +} + +unsigned UserDefinedDwarfTypesBuilder::GetCompleteClassTypeIndex( + const ClassTypeDescriptor &ClassDescriptor, + const ClassFieldsTypeDescriptior &ClassFieldsDescriptor, + const DataFieldDescriptor *FieldsDescriptors, + const StaticDataFieldDescriptor *StaticsDescriptors) { + unsigned TypeIndex = ArrayIndexToTypeIndex(DwarfTypes.size()); + UserDefinedTypes.push_back(std::make_pair(ClassDescriptor.Name, TypeIndex)); + + DwarfClassTypeInfo *ClassTypeInfo = new DwarfClassTypeInfo(ClassDescriptor, ClassFieldsDescriptor, + FieldsDescriptors, StaticsDescriptors); + + DwarfTypes.push_back(std::unique_ptr(ClassTypeInfo)); + + if (ClassTypeInfo->GetStaticFields().size() > 0) { + ClassesWithStaticFields.push_back(ClassTypeInfo); + } + + return TypeIndex; +} + +unsigned UserDefinedDwarfTypesBuilder::GetArrayTypeIndex( + const ClassTypeDescriptor &ClassDescriptor, + const ArrayTypeDescriptor &ArrayDescriptor) { + // Create corresponding class info + ClassTypeDescriptor ArrayClassDescriptor = ClassDescriptor; + + std::vector FieldDescs; + unsigned FieldOffset = TargetPointerSize; + + FieldDescs.push_back({GetPrimitiveTypeIndex(PrimitiveTypeFlags::Int32), FieldOffset, "m_NumComponents"}); + FieldOffset += TargetPointerSize; + + if (ArrayDescriptor.IsMultiDimensional == 1) { + unsigned BoundsTypeIndex = GetSimpleArrayTypeIndex(GetPrimitiveTypeIndex(PrimitiveTypeFlags::Int32), ArrayDescriptor.Rank); + FieldDescs.push_back({BoundsTypeIndex, FieldOffset, "m_Bounds"}); + FieldOffset += 2 * 4 * ArrayDescriptor.Rank; + } + + unsigned DataTypeIndex = GetSimpleArrayTypeIndex(ArrayDescriptor.ElementType, 0); + FieldDescs.push_back({DataTypeIndex, FieldOffset, "m_Data"}); + + ClassFieldsTypeDescriptior FieldsTypeDesc = + {TargetPointerSize, ArrayDescriptor.IsMultiDimensional ? 3 : 2}; + + ArrayClassDescriptor.InstanceSize = FieldOffset; + + unsigned TypeIndex = ArrayIndexToTypeIndex(DwarfTypes.size()); + UserDefinedTypes.push_back(std::make_pair(ArrayClassDescriptor.Name, TypeIndex)); + DwarfTypes.push_back(std::make_unique(ArrayClassDescriptor, FieldsTypeDesc, FieldDescs.data(), nullptr)); + + return TypeIndex; +} + +unsigned UserDefinedDwarfTypesBuilder::GetPointerTypeIndex(const PointerTypeDescriptor& PointerDescriptor) +{ + unsigned VoidTypeIndex = GetPrimitiveTypeIndex(PrimitiveTypeFlags::Void); + + unsigned TypeIndex = ArrayIndexToTypeIndex(DwarfTypes.size()); + + // Creating a pointer to what DWARF considers Void type (DW_TAG_unspecified_type - + // per http://eagercon.com/dwarf/issues/minutes-001017.htm) leads to unhappines + // since debuggers don't really know how to handle that. The Clang symbol parser + // in LLDB only handles DW_TAG_unspecified_type if it's named + // "nullptr_t" or "decltype(nullptr)". + // + // We resort to this kludge to generate the exact same debug info for void* that + // clang would generate (pointer type with no element type specified). + if (PointerDescriptor.ElementType == VoidTypeIndex) + DwarfTypes.push_back(std::make_unique()); + else + DwarfTypes.push_back(std::make_unique(PointerDescriptor)); + + return TypeIndex; +} + +unsigned UserDefinedDwarfTypesBuilder::GetMemberFunctionTypeIndex(const MemberFunctionTypeDescriptor& MemberDescriptor, + uint32_t const *const ArgumentTypes) +{ + bool IsStatic = MemberDescriptor.TypeIndexOfThisPointer == GetPrimitiveTypeIndex(PrimitiveTypeFlags::Void); + unsigned TypeIndex = ArrayIndexToTypeIndex(DwarfTypes.size()); + DwarfTypes.push_back(std::make_unique(MemberDescriptor, ArgumentTypes, IsStatic)); + return TypeIndex; +} + +unsigned UserDefinedDwarfTypesBuilder::GetMemberFunctionId(const MemberFunctionIdTypeDescriptor& MemberIdDescriptor) +{ + unsigned TypeIndex = ArrayIndexToTypeIndex(DwarfTypes.size()); + + DwarfMemberFunctionTypeInfo *MemberFunctionTypeInfo = static_cast( + GetTypeInfoByIndex(MemberIdDescriptor.MemberFunction)); + assert(MemberFunctionTypeInfo != nullptr); + + DwarfMemberFunctionIdTypeInfo *MemberFunctionIdTypeInfo = + new DwarfMemberFunctionIdTypeInfo(MemberIdDescriptor, MemberFunctionTypeInfo); + + DwarfTypes.push_back(std::unique_ptr(MemberFunctionIdTypeInfo)); + + DwarfClassTypeInfo *ParentClassInfo = static_cast( + GetTypeInfoByIndex(MemberIdDescriptor.ParentClass)); + assert(ParentClassInfo != nullptr); + + ParentClassInfo->AddMemberFunction(MemberFunctionIdTypeInfo); + + return TypeIndex; +} + +unsigned UserDefinedDwarfTypesBuilder::GetPrimitiveTypeIndex(PrimitiveTypeFlags Type) { + auto Iter = PrimitiveDwarfTypes.find(Type); + if (Iter != PrimitiveDwarfTypes.end()) + return Iter->second; + + unsigned TypeIndex = ArrayIndexToTypeIndex(DwarfTypes.size()); + + if (Type == PrimitiveTypeFlags::Void) + DwarfTypes.push_back(std::make_unique()); + else + DwarfTypes.push_back(std::make_unique(Type)); + + PrimitiveDwarfTypes.insert(std::make_pair(Type, TypeIndex)); + + return TypeIndex; +} + +unsigned UserDefinedDwarfTypesBuilder::GetSimpleArrayTypeIndex(unsigned ElemIndex, unsigned Size) { + auto Iter = SimpleArrayDwarfTypes.find(ElemIndex); + if (Iter != SimpleArrayDwarfTypes.end()) { + auto CountMap = Iter->second; + auto CountIter = CountMap.find(Size); + if (CountIter != CountMap.end()) + return CountIter->second; + } + + unsigned TypeIndex = ArrayIndexToTypeIndex(DwarfTypes.size()); + DwarfTypes.push_back(std::make_unique(ElemIndex, Size)); + + SimpleArrayDwarfTypes[ElemIndex][Size] = TypeIndex; + + return TypeIndex; +} diff --git a/llvm/tools/objwriter/debugInfo/dwarf/dwarfTypeBuilder.h b/llvm/tools/objwriter/debugInfo/dwarf/dwarfTypeBuilder.h new file mode 100644 index 00000000000000..ea6a9ad307860d --- /dev/null +++ b/llvm/tools/objwriter/debugInfo/dwarf/dwarfTypeBuilder.h @@ -0,0 +1,390 @@ +//===---- dwarfTypeBuilder.h ------------------------------------*- C++ -*-===// +// +// type builder is used to convert .Net types into Dwarf debuginfo. +// +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +//===----------------------------------------------------------------------===// + +#pragma once + +#include "debugInfo/typeBuilder.h" + +#include +#include + +class UserDefinedDwarfTypesBuilder; + +class DwarfInfo +{ +public: + DwarfInfo() : + StrSymbol(nullptr), + InfoSymbol(nullptr), + IsDumped(false), + IsDumpedTypes(false) {} + + virtual ~DwarfInfo() {} + + virtual void Dump(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer, + MCSection *TypeSection, MCSection *StrSection); + + virtual void DumpTypes(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer, + MCSection *TypeSection, MCSection *StrSection); + + MCSymbol *GetInfoSymbol() { return InfoSymbol; } + + const MCExpr *GetInfoExpr() { return InfoExpr; } + + static void EmitSectionOffset(MCObjectStreamer *Streamer, + MCSymbol *Symbol, + unsigned Size, + uint32_t Offset = 0); + +protected: + virtual void DumpStrings(MCObjectStreamer *Streamer) = 0; + virtual void DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) = 0; + virtual bool HasChildren() { return false; } + virtual void EndChildrenList(MCObjectStreamer *Streamer); + + static const MCExpr *CreateOffsetExpr(MCContext &Context, + MCSymbol *BeginSymbol, + MCSymbol *Symbol); + + static void EmitOffset(MCObjectStreamer *Streamer, + const MCExpr *OffsetExpr, + unsigned Size); + + static void EmitInfoOffset(MCObjectStreamer *Streamer, const DwarfInfo *Info, unsigned Size); + + MCSymbol *StrSymbol; + MCSymbol *InfoSymbol; + const MCExpr *InfoExpr; + + bool IsDumped; + bool IsDumpedTypes; +}; + +class DwarfPrimitiveTypeInfo : public DwarfInfo +{ +public: + DwarfPrimitiveTypeInfo(PrimitiveTypeFlags PrimitiveType) : Type(PrimitiveType) {} + + PrimitiveTypeFlags GetType() { return Type; } + +protected: + void DumpStrings(MCObjectStreamer *Streamer) override; + void DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) override; + +private: + PrimitiveTypeFlags Type; +}; + +class DwarfVoidTypeInfo : public DwarfPrimitiveTypeInfo +{ +public: + DwarfVoidTypeInfo() : DwarfPrimitiveTypeInfo(PrimitiveTypeFlags::Void) {} + +protected: + void DumpStrings(MCObjectStreamer* Streamer) override; + void DumpTypeInfo(MCObjectStreamer* Streamer, UserDefinedDwarfTypesBuilder* TypeBuilder) override; +}; + +class DwarfEnumTypeInfo; + +class DwarfEnumerator : public DwarfInfo +{ +public: + DwarfEnumerator(const EnumRecordTypeDescriptor &Descriptor, DwarfEnumTypeInfo *TypeInfo) : + Name(Descriptor.Name), Value(Descriptor.Value), EnumTypeInfo(TypeInfo) {} + +protected: + void DumpStrings(MCObjectStreamer *Streamer) override; + void DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) override; + +private: + std::string Name; + uint64 Value; + DwarfEnumTypeInfo *EnumTypeInfo; +}; + +class DwarfEnumTypeInfo : public DwarfInfo +{ +public: + DwarfEnumTypeInfo(const EnumTypeDescriptor &TypeDescriptor, + const EnumRecordTypeDescriptor *TypeRecords); + + void Dump(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer, + MCSection *TypeSection, MCSection *StrSection) override; + + void DumpTypes(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer, + MCSection *TypeSection, MCSection *StrSection) override; + + uint8_t GetByteSize() const { return ByteSize; } + +protected: + void DumpStrings(MCObjectStreamer *Streamer) override; + void DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) override; + bool HasChildren() override { return !Records.empty(); } + +private: + std::string Name; + uint32_t ElementType; + std::vector Records; + uint8_t ByteSize; +}; + +class DwarfDataField : public DwarfInfo +{ +public: + DwarfDataField(const DataFieldDescriptor &Descriptor) : + Name(Descriptor.Name), + TypeIndex(Descriptor.FieldTypeIndex), + Offset(Descriptor.Offset) {} + + void DumpTypes(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer, + MCSection *TypeSection, MCSection *StrSection) override; + + uint32_t GetTypeIndex() const { return TypeIndex; } + + const std::string &GetName() const { return Name; } + +protected: + void DumpStrings(MCObjectStreamer *Streamer) override; + void DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) override; + + std::string Name; + uint32_t TypeIndex; + uint64 Offset; +}; + +class DwarfStaticDataField : public DwarfDataField +{ +public: + DwarfStaticDataField(const DataFieldDescriptor &Descriptor, + const StaticDataFieldDescriptor &StaticDescriptor) : + DwarfDataField(Descriptor), + StaticDataName(StaticDescriptor.StaticDataName), + StaticOffset(StaticDescriptor.StaticOffset), + StaticDataInObject(StaticDescriptor.IsStaticDataInObject) {} + + const std::string &GetStaticDataName() const { return StaticDataName; } + uint64 GetStaticOffset() const { return StaticOffset; } + bool IsStaticDataInObject() const { return StaticDataInObject; } + +protected: + void DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) override; + +private: + std::string StaticDataName; + uint64 StaticOffset; + bool StaticDataInObject; +}; + +class DwarfMemberFunctionIdTypeInfo; + +class DwarfClassTypeInfo : public DwarfInfo +{ +public: + DwarfClassTypeInfo(const ClassTypeDescriptor &ClassDescriptor) : + Name(ClassDescriptor.Name), + IsStruct(ClassDescriptor.IsStruct), + BaseClassId(ClassDescriptor.BaseClassId), + Size(ClassDescriptor.InstanceSize), + IsForwardDecl(true) {} + + DwarfClassTypeInfo(const ClassTypeDescriptor &ClassDescriptor, + const ClassFieldsTypeDescriptior &ClassFieldsDescriptor, + const DataFieldDescriptor *FieldsDescriptors, + const StaticDataFieldDescriptor *StaticsDescriptors); + + void Dump(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer, + MCSection *TypeSection, MCSection *StrSection) override; + + void DumpTypes(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer, + MCSection *TypeSection, MCSection *StrSection) override; + + void AddMemberFunction(DwarfMemberFunctionIdTypeInfo* TypeInfo) { + MemberFunctions.push_back(TypeInfo); + } + + const std::vector &GetStaticFields() const { return StaticFields; } + + const std::string &GetName() const { return Name; } + +protected: + void DumpStrings(MCObjectStreamer *Streamer) override; + void DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) override; + bool HasChildren() override; + + std::string Name; + bool IsStruct; + uint32_t BaseClassId; + uint64 Size; + bool IsForwardDecl; + std::vector Fields; + std::vector StaticFields; + std::vector MemberFunctions; +}; + +class DwarfSimpleArrayTypeInfo : public DwarfInfo +{ +public: + DwarfSimpleArrayTypeInfo(uint32_t ArrayElementType, uint64_t Size) : + ElementType(ArrayElementType), + Size(Size) {} + + void DumpTypes(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer, + MCSection *TypeSection, MCSection *StrSection) override; + +protected: + void DumpStrings(MCObjectStreamer *Streamer) override; + void DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) override; + // ArrayTypeInfo always contains a SubrangeType entry + bool HasChildren() override { return true; } + +private: + uint32_t ElementType; + uint64_t Size; +}; + +class DwarfPointerTypeInfo : public DwarfInfo +{ +public: + DwarfPointerTypeInfo(const PointerTypeDescriptor& PointerDescriptor) : + TypeDesc(PointerDescriptor) {} + + void DumpTypes(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer, + MCSection *TypeSection, MCSection *StrSection) override; + +protected: + void DumpStrings(MCObjectStreamer *Streamer) override; + void DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) override; + +private: + PointerTypeDescriptor TypeDesc; +}; + +class DwarfVoidPtrTypeInfo : public DwarfInfo +{ +public: + DwarfVoidPtrTypeInfo() {} + +protected: + void DumpStrings(MCObjectStreamer* Streamer) override; + void DumpTypeInfo(MCObjectStreamer* Streamer, UserDefinedDwarfTypesBuilder* TypeBuilder) override; +}; + +class DwarfMemberFunctionTypeInfo : public DwarfInfo +{ +public: + DwarfMemberFunctionTypeInfo(const MemberFunctionTypeDescriptor& MemberDescriptor, + uint32_t const *const ArgumentTypes, + bool IsStaticMethod); + + const std::vector &GetArgTypes() const { return ArgumentTypes; } + + bool IsStatic() const { return IsStaticMethod; } + + uint32_t GetReturnTypeIndex() const { return TypeDesc.ReturnType; } + + uint32_t GetThisPtrTypeIndex() const { return TypeDesc.TypeIndexOfThisPointer; } + +protected: + void DumpStrings(MCObjectStreamer *Streamer) override; + void DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) override; + +private: + MemberFunctionTypeDescriptor TypeDesc; + std::vector ArgumentTypes; + bool IsStaticMethod; +}; + +class DwarfMemberFunctionIdTypeInfo : public DwarfInfo +{ +public: + DwarfMemberFunctionIdTypeInfo(const MemberFunctionIdTypeDescriptor& MemberIdDescriptor, + DwarfMemberFunctionTypeInfo *TypeInfo) : + LinkageName(MemberIdDescriptor.Name), + Name(MemberIdDescriptor.Name), + ParentClass(MemberIdDescriptor.ParentClass), + MemberFunctionTypeInfo(TypeInfo), + LinkageNameSymbol(nullptr) {} + + const std::vector &GetArgTypes() const { return MemberFunctionTypeInfo->GetArgTypes(); } + + void SetLinkageName(const char *Name) { LinkageName = Name; } + + void DumpTypes(UserDefinedDwarfTypesBuilder *TypeBuilder, MCObjectStreamer *Streamer, + MCSection *TypeSection, MCSection *StrSection) override; + + bool IsStatic() const { return MemberFunctionTypeInfo->IsStatic(); } + +protected: + void DumpStrings(MCObjectStreamer *Streamer) override; + void DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) override; + +private: + std::string LinkageName; + std::string Name; + uint32_t ParentClass; + DwarfMemberFunctionTypeInfo *MemberFunctionTypeInfo; + MCSymbol *LinkageNameSymbol; +}; + +template +class EnumHash +{ + typedef typename std::underlying_type::type enumType; +public: + size_t operator()(const T& elem) const { + return std::hash()(static_cast(elem)); + } +}; + +class UserDefinedDwarfTypesBuilder : public UserDefinedTypesBuilder +{ +public: + UserDefinedDwarfTypesBuilder() {} + void EmitTypeInformation(MCSection *TypeSection, MCSection *StrSection = nullptr) override; + + unsigned GetEnumTypeIndex(const EnumTypeDescriptor &TypeDescriptor, + const EnumRecordTypeDescriptor *TypeRecords) override; + unsigned GetClassTypeIndex(const ClassTypeDescriptor &ClassDescriptor) override; + unsigned GetCompleteClassTypeIndex( + const ClassTypeDescriptor &ClassDescriptor, + const ClassFieldsTypeDescriptior &ClassFieldsDescriptor, + const DataFieldDescriptor *FieldsDescriptors, + const StaticDataFieldDescriptor *StaticsDescriptors) override; + + unsigned GetArrayTypeIndex(const ClassTypeDescriptor &ClassDescriptor, + const ArrayTypeDescriptor &ArrayDescriptor) override; + + unsigned GetPointerTypeIndex(const PointerTypeDescriptor& PointerDescriptor) override; + + unsigned GetMemberFunctionTypeIndex(const MemberFunctionTypeDescriptor& MemberDescriptor, + uint32_t const *const ArgumentTypes) override; + + unsigned GetMemberFunctionId(const MemberFunctionIdTypeDescriptor& MemberIdDescriptor) override; + + unsigned GetPrimitiveTypeIndex(PrimitiveTypeFlags Type) override; + + DwarfInfo *GetTypeInfoByIndex(unsigned Index) const { return DwarfTypes[TypeIndexToArrayIndex(Index)].get(); } + + unsigned GetSimpleArrayTypeIndex(unsigned ElemIndex, unsigned Size); + + const std::vector &GetClassesWithStaticFields() const { return ClassesWithStaticFields; } + +private: + static const unsigned StartTypeIndex = 1; // Make TypeIndex 0 - Invalid + static unsigned TypeIndexToArrayIndex(unsigned TypeIndex) { return TypeIndex - StartTypeIndex; } + static unsigned ArrayIndexToTypeIndex(unsigned ArrayIndex) { return ArrayIndex + StartTypeIndex; } + + std::vector> DwarfTypes; + std::unordered_map> PrimitiveDwarfTypes; + // map[ElemTypeIndex][Size] -> ArrTypeIndex + std::unordered_map> SimpleArrayDwarfTypes; + + std::vector ClassesWithStaticFields; +}; diff --git a/llvm/tools/objwriter/debugInfo/typeBuilder.h b/llvm/tools/objwriter/debugInfo/typeBuilder.h new file mode 100644 index 00000000000000..67a5004d248b9a --- /dev/null +++ b/llvm/tools/objwriter/debugInfo/typeBuilder.h @@ -0,0 +1,157 @@ +//===---- typeBuilder.h -----------------------------------------*- C++ -*-===// +// +// type builder is used to convert .Net types into debuginfo. +// +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +//===----------------------------------------------------------------------===// + +#pragma once + +#include "llvm/MC/MCObjectStreamer.h" + +#include +#include + +using namespace llvm; + +// Keep in sync with Internal.TypeSystem.TypeFlags (Common/src/TypeSystem/Common/TypeFlags.cs) +enum class PrimitiveTypeFlags { + Unknown = 0x00, + Void = 0x01, + Boolean = 0x02, + Char = 0x03, + SByte = 0x04, + Byte = 0x05, + Int16 = 0x06, + UInt16 = 0x07, + Int32 = 0x08, + UInt32 = 0x09, + Int64 = 0x0A, + UInt64 = 0x0B, + IntPtr = 0x0C, + UIntPtr = 0x0D, + Single = 0x0E, + Double = 0x0F +}; + +typedef unsigned long long uint64; + +#pragma pack(push, 8) + +extern "C" struct EnumRecordTypeDescriptor { + uint64 Value; + const char *Name; +}; + +extern "C" struct EnumTypeDescriptor { + uint32_t ElementType; + uint64 ElementCount; + const char *Name; +}; + +extern "C" struct ClassTypeDescriptor { + int32_t IsStruct; + const char *Name; + uint32_t BaseClassId; + uint64 InstanceSize; +}; + +extern "C" struct DataFieldDescriptor { + uint32_t FieldTypeIndex; + uint64 Offset; + const char *Name; +}; + +extern "C" struct StaticDataFieldDescriptor { + const char *StaticDataName; + uint64 StaticOffset; + int IsStaticDataInObject; +}; + +extern "C" struct ClassFieldsTypeDescriptior { + uint64 Size; + int32_t FieldsCount; +}; + +extern "C" struct ArrayTypeDescriptor { + uint32_t Rank; + uint32_t ElementType; + uint32_t Size; // ElementSize + int32_t IsMultiDimensional; +}; + +extern "C" struct PointerTypeDescriptor { + uint32_t ElementType; + int32_t IsReference; + int32_t IsConst; + int32_t Is64Bit; +}; + +extern "C" struct MemberFunctionTypeDescriptor { + uint32_t ReturnType; + uint32_t ContainingClass; + uint32_t TypeIndexOfThisPointer; + int32_t ThisAdjust; + uint32_t CallingConvention; + uint16_t NumberOfArguments; +}; + +extern "C" struct MemberFunctionIdTypeDescriptor { + uint32_t MemberFunction; + uint32_t ParentClass; + const char *Name; +}; + +#pragma pack(pop) +class UserDefinedTypesBuilder { +public: + UserDefinedTypesBuilder() : Streamer(nullptr), TargetPointerSize(0) {} + virtual ~UserDefinedTypesBuilder() {} + void SetStreamer(MCObjectStreamer *Streamer) { + assert(this->Streamer == nullptr); + assert(Streamer != nullptr); + this->Streamer = Streamer; + } + MCObjectStreamer *GetStreamer() const { + return Streamer; + } + void SetTargetPointerSize(unsigned TargetPointerSize) { + assert(this->TargetPointerSize == 0); + assert(TargetPointerSize != 0); + this->TargetPointerSize = TargetPointerSize; + } + virtual void EmitTypeInformation(MCSection *TypeSection, MCSection *StrSection = nullptr) = 0; + + virtual unsigned GetEnumTypeIndex(const EnumTypeDescriptor &TypeDescriptor, + const EnumRecordTypeDescriptor *TypeRecords) = 0; + virtual unsigned GetClassTypeIndex(const ClassTypeDescriptor &ClassDescriptor) = 0; + virtual unsigned GetCompleteClassTypeIndex( + const ClassTypeDescriptor &ClassDescriptor, + const ClassFieldsTypeDescriptior &ClassFieldsDescriptor, + const DataFieldDescriptor *FieldsDescriptors, + const StaticDataFieldDescriptor *StaticsDescriptors) = 0; + + virtual unsigned GetArrayTypeIndex(const ClassTypeDescriptor &ClassDescriptor, + const ArrayTypeDescriptor &ArrayDescriptor) = 0; + + virtual unsigned GetPointerTypeIndex(const PointerTypeDescriptor& PointerDescriptor) = 0; + + virtual unsigned GetMemberFunctionTypeIndex(const MemberFunctionTypeDescriptor& MemberDescriptor, + uint32_t const *const ArgumentTypes) = 0; + + virtual unsigned GetMemberFunctionId(const MemberFunctionIdTypeDescriptor& MemberIdDescriptor) = 0; + + virtual unsigned GetPrimitiveTypeIndex(PrimitiveTypeFlags Type) = 0; + + virtual const std::vector> &GetUDTs() { + return UserDefinedTypes; + } + +protected: + MCObjectStreamer *Streamer; + unsigned TargetPointerSize; + + std::vector> UserDefinedTypes; +}; diff --git a/llvm/tools/objwriter/jitDebugInfo.h b/llvm/tools/objwriter/jitDebugInfo.h new file mode 100644 index 00000000000000..88a96f76732878 --- /dev/null +++ b/llvm/tools/objwriter/jitDebugInfo.h @@ -0,0 +1,66 @@ +#ifndef JIT_DEBUG_INFO_H +#define JIT_DEBUG_INFO_H + +typedef unsigned int DWORD; + +#define PORTABILITY_WARNING(msg) +#include "cordebuginfo.h" + +// RegNum enumeration is architecture-specific and we need it for all +// architectures we support. + +namespace X86 { +#define TARGET_X86 1 +#include "cordebuginfo.h" +#undef TARGET_X86 +} + +namespace Amd64 { +#define TARGET_AMD64 1 +#include "cordebuginfo.h" +#undef TARGET_AMD64 +} + +namespace Arm { +#define TARGET_ARM 1 +#include "cordebuginfo.h" +#undef TARGET_ARM +} + +namespace Arm64 { +#define TARGET_ARM64 1 +#include "cordebuginfo.h" +#undef TARGET_ARM64 +} + +struct DebugLocInfo { + int NativeOffset; + int FileId; + int LineNumber; + int ColNumber; +}; + +struct DebugVarInfo { + std::string Name; + int TypeIndex; + bool IsParam; + std::vector Ranges; + + DebugVarInfo() {} + DebugVarInfo(char *ArgName, int ArgTypeIndex, bool ArgIsParam) + : Name(ArgName), TypeIndex(ArgTypeIndex), IsParam(ArgIsParam) {} +}; + +struct DebugEHClauseInfo { + unsigned TryOffset; + unsigned TryLength; + unsigned HandlerOffset; + unsigned HandlerLength; + + DebugEHClauseInfo(unsigned TryOffset, unsigned TryLength, + unsigned HandlerOffset, unsigned HandlerLength) : + TryOffset(TryOffset), TryLength(TryLength), + HandlerOffset(HandlerOffset), HandlerLength(HandlerLength) {} +}; + +#endif // JIT_DEBUG_INFO_H diff --git a/llvm/tools/objwriter/objwriter.cpp b/llvm/tools/objwriter/objwriter.cpp new file mode 100644 index 00000000000000..a195fb956b25c1 --- /dev/null +++ b/llvm/tools/objwriter/objwriter.cpp @@ -0,0 +1,1214 @@ +//===---- objwriter.cpp -----------------------------------------*- C++ -*-===// +// +// object writer +// +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// \brief Implementation of object writer API for JIT/AOT +/// +//===----------------------------------------------------------------------===// + +#include "objwriter.h" +#include "debugInfo/dwarf/dwarfTypeBuilder.h" +#include "debugInfo/codeView/codeViewTypeBuilder.h" +#include "cvconst.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/Line.h" +#include "llvm/DebugInfo/CodeView/SymbolRecord.h" +#include "llvm/MC/MCAsmBackend.h" +#include "llvm/MC/MCAsmInfo.h" +#include "llvm/MC/MCAssembler.h" +#include "llvm/MC/MCContext.h" +#include "llvm/MC/MCCodeEmitter.h" +#include "llvm/MC/MCDwarf.h" +#include "llvm/MC/MCInstPrinter.h" +#include "llvm/MC/MCInstrInfo.h" +#include "llvm/MC/MCParser/AsmLexer.h" +#include "llvm/MC/MCParser/MCTargetAsmParser.h" +#include "llvm/MC/MCRegisterInfo.h" +#include "llvm/MC/MCSectionCOFF.h" +#include "llvm/MC/MCSectionELF.h" +#include "llvm/MC/MCSectionMachO.h" +#include "llvm/MC/MCObjectStreamer.h" +#include "llvm/MC/MCObjectWriter.h" +#include "llvm/MC/MCSubtargetInfo.h" +#include "llvm/MC/MCTargetOptionsCommandFlags.h" +#include "llvm/MC/MCELFStreamer.h" +#include "llvm/MC/TargetRegistry.h" +#include "llvm/BinaryFormat/COFF.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Compression.h" +#include "llvm/BinaryFormat/ELF.h" +#include "llvm/Support/FileUtilities.h" +#include "llvm/Support/FormattedStream.h" +#include "llvm/Support/Host.h" +#include "llvm/Support/ManagedStatic.h" +#include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/PrettyStackTrace.h" +#include "llvm/Support/SourceMgr.h" +#include "llvm/Support/TargetSelect.h" +#include "llvm/Support/ToolOutputFile.h" +#include "llvm/Support/Win64EH.h" +#include "llvm/Target/TargetMachine.h" +#include "../../lib/Target/AArch64/MCTargetDesc/AArch64MCExpr.h" + +using namespace llvm; +using namespace llvm::codeview; + +bool error(const Twine &Error) { + errs() << Twine("error: ") + Error + "\n"; + return false; +} + +void ObjectWriter::InitTripleName(const char* tripleName) { + TripleName = tripleName != nullptr ? tripleName : sys::getDefaultTargetTriple(); +} + +bool ObjectWriter::Init(llvm::StringRef ObjectFilePath, const char* tripleName) { + llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. + + // Initialize targets + InitializeAllTargetInfos(); + InitializeAllTargetMCs(); + + InitTripleName(tripleName); + Triple TheTriple(TripleName); + + // Get the target specific parser. + std::string TargetError; + const Target *TheTarget = + TargetRegistry::lookupTarget(TripleName, TargetError); + if (!TheTarget) { + return error("Unable to create target for " + ObjectFilePath + ": " + + TargetError); + } + + std::error_code EC; + OS.reset(new raw_fd_ostream(ObjectFilePath, EC, sys::fs::OF_None)); + if (EC) + return error("Unable to create file for " + ObjectFilePath + ": " + + EC.message()); + + RegisterInfo.reset(TheTarget->createMCRegInfo(TripleName)); + if (!RegisterInfo) + return error("Unable to create target register info!"); + + AsmInfo.reset(TheTarget->createMCAsmInfo(*RegisterInfo, TripleName, TargetMOptions)); + if (!AsmInfo) + return error("Unable to create target asm info!"); + + InstrInfo.reset(TheTarget->createMCInstrInfo()); + if (!InstrInfo) + return error("no instr info info for target " + TripleName); + + std::string FeaturesStr; + std::string MCPU; + SubtargetInfo.reset( + TheTarget->createMCSubtargetInfo(TripleName, MCPU, FeaturesStr)); + if (!SubtargetInfo) + return error("no subtarget info for target " + TripleName); + + OutContext.reset( + new MCContext(TheTriple, AsmInfo.get(), RegisterInfo.get(), SubtargetInfo.get())); + ObjFileInfo.reset(TheTarget->createMCObjectFileInfo(*OutContext, false)); + OutContext->setObjectFileInfo(ObjFileInfo.get()); + + CodeEmitter = + TheTarget->createMCCodeEmitter(*InstrInfo, *OutContext); + if (!CodeEmitter) + return error("no code emitter for target " + TripleName); + + AsmBackend = TheTarget->createMCAsmBackend(*SubtargetInfo, *RegisterInfo, TargetMOptions); + if (!AsmBackend) + return error("no asm backend for target " + TripleName); + + Streamer = (MCObjectStreamer *)TheTarget->createMCObjectStreamer( + TheTriple, *OutContext, std::unique_ptr(AsmBackend), AsmBackend->createObjectWriter(*OS), + std::unique_ptr(CodeEmitter), *SubtargetInfo, + /*RelaxAll*/ true, + /*IncrementalLinkerCompatible*/ false, + /*DWARFMustBeAtTheEnd*/ false); + if (!Streamer) + return error("no object streamer for target " + TripleName); + Streamer->initSections(/* NoExecStack */ true, *SubtargetInfo); + Assembler = &Streamer->getAssembler(); + + FrameOpened = false; + FuncId = 1; + + if (OutContext->getObjectFileType() == MCContext::IsCOFF) { + TypeBuilder.reset(new UserDefinedCodeViewTypesBuilder()); + } else { + TypeBuilder.reset(new UserDefinedDwarfTypesBuilder()); + } + + TypeBuilder->SetStreamer(Streamer); + unsigned TargetPointerSize = Streamer->getContext().getAsmInfo()->getCodePointerSize(); + TypeBuilder->SetTargetPointerSize(TargetPointerSize); + + DwarfGenerator.reset(new DwarfGen()); + DwarfGenerator->SetTypeBuilder(static_cast(TypeBuilder.get())); + + CFIsPerOffset.truncate(0); + + return true; +} + +void ObjectWriter::Finish() { + + if (OutContext->getObjectFileType() == MCContext::IsCOFF + && AddressTakenFunctions.size() > 0) { + + // Emit all address-taken functions into the GFIDs section + // to support control flow guard. + Streamer->switchSection(ObjFileInfo->getGFIDsSection()); + for (const MCSymbol* S : AddressTakenFunctions) { + Streamer->emitCOFFSymbolIndex(S); + } + + // Emit the feat.00 symbol that controls various linker behaviors + MCSymbol* S = OutContext->getOrCreateSymbol(StringRef("@feat.00")); + Streamer->beginCOFFSymbolDef(S); + Streamer->emitCOFFSymbolStorageClass(COFF::IMAGE_SYM_CLASS_STATIC); + Streamer->emitCOFFSymbolType(COFF::IMAGE_SYM_DTYPE_NULL); + Streamer->endCOFFSymbolDef(); + int64_t Feat00Flags = 0; + + Feat00Flags |= 0x800; // cfGuardCF flags this object as control flow guard aware + + Streamer->emitSymbolAttribute(S, MCSA_Global); + Streamer->emitAssignment( + S, MCConstantExpr::create(Feat00Flags, *OutContext)); + } + + Streamer->finish(); +} + +void ObjectWriter::SetDwarfVersion(uint16_t v) { + Streamer->getContext().setDwarfVersion(v); +} + +void ObjectWriter::SwitchSection(const char *SectionName, + CustomSectionAttributes attributes, + const char *ComdatName) { + MCSection *Section = GetSection(SectionName, attributes, ComdatName); + Streamer->switchSection(Section); + if (Sections.count(Section) == 0) { + Sections.insert(Section); + if (OutContext->getObjectFileType() == MCContext::IsMachO) { + assert(!Section->getBeginSymbol()); + // Output a DWARF linker-local symbol. + // This symbol is used as a base for other symbols in a section. + MCSymbol *SectionStartSym = OutContext->createLinkerPrivateTempSymbol(); + Streamer->emitLabel(SectionStartSym); + Section->setBeginSymbol(SectionStartSym); + } + } +} + +MCSection *ObjectWriter::GetSection(const char *SectionName, + CustomSectionAttributes attributes, + const char *ComdatName) { + MCSection *Section = nullptr; + + if (strcmp(SectionName, "text") == 0) { + Section = ObjFileInfo->getTextSection(); + } else if (strcmp(SectionName, "data") == 0) { + Section = ObjFileInfo->getDataSection(); + } else if (strcmp(SectionName, "rdata") == 0) { + Section = ObjFileInfo->getReadOnlySection(); + } else if (strcmp(SectionName, "xdata") == 0) { + Section = ObjFileInfo->getXDataSection(); + } else if (strcmp(SectionName, "bss") == 0) { + if (OutContext->getObjectFileType() == MCContext::IsMachO) { + Section = ObjFileInfo->getDataBSSSection(); + } else { + Section = ObjFileInfo->getBSSSection(); + } + } else if (strcmp(SectionName, "comment") == 0 && OutContext->getObjectFileType() == MCContext::IsELF) { + Section = OutContext->getELFSection(".comment", ELF::SHT_PROGBITS, ELF::SHF_MERGE | ELF::SHF_STRINGS | ELF::SHF_GNU_RETAIN, 1); + } else { + Section = GetSpecificSection(SectionName, attributes, ComdatName); + } + assert(Section); + return Section; +} + +MCSection *ObjectWriter::GetSpecificSection(const char *SectionName, + CustomSectionAttributes attributes, + const char *ComdatName) { + Triple TheTriple(TripleName); + MCSection *Section = nullptr; + SectionKind Kind; + if (attributes & CustomSectionAttributes_Executable) + Kind = SectionKind::getText(); + else if (attributes & CustomSectionAttributes_Uninitialized) + Kind = SectionKind::getBSS(); + else if (attributes & CustomSectionAttributes_Writeable) + Kind = SectionKind::getData(); + else + Kind = SectionKind::getReadOnly(); + + switch (TheTriple.getObjectFormat()) { + case Triple::MachO: { + unsigned typeAndAttributes = 0; + if (attributes & CustomSectionAttributes_MachO_Init_Func_Pointers) { + typeAndAttributes |= MachO::SectionType::S_MOD_INIT_FUNC_POINTERS; + } + if (attributes & CustomSectionAttributes_Executable) { + // Needs to be set on sections with actual code. The linker uses + // it to determine code sections and emit information about function + // boundaries. + typeAndAttributes |= MachO::S_ATTR_PURE_INSTRUCTIONS; + } + if (attributes & CustomSectionAttributes_Uninitialized) { + typeAndAttributes |= MachO::S_ZEROFILL; + } + Section = OutContext->getMachOSection( + (attributes & CustomSectionAttributes_Executable) ? "__TEXT" : "__DATA", + SectionName, typeAndAttributes, Kind); + break; + } + case Triple::COFF: { + unsigned Characteristics = COFF::IMAGE_SCN_MEM_READ; + + if (attributes & CustomSectionAttributes_Executable) { + Characteristics |= COFF::IMAGE_SCN_CNT_CODE | COFF::IMAGE_SCN_MEM_EXECUTE; + } else if (attributes & CustomSectionAttributes_Writeable) { + Characteristics |= COFF::IMAGE_SCN_MEM_WRITE; + if (attributes & CustomSectionAttributes_Uninitialized) + Characteristics |= COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA; + else + Characteristics |= COFF::IMAGE_SCN_CNT_INITIALIZED_DATA; + } else { + Characteristics |= COFF::IMAGE_SCN_CNT_INITIALIZED_DATA; + } + + if (ComdatName != nullptr) { + Section = OutContext->getCOFFSection( + SectionName, Characteristics | COFF::IMAGE_SCN_LNK_COMDAT, Kind, + ComdatName, COFF::COMDATType::IMAGE_COMDAT_SELECT_ANY); + } else { + Section = OutContext->getCOFFSection(SectionName, Characteristics, Kind); + } + break; + } + case Triple::ELF: { + unsigned Flags = ELF::SHF_ALLOC; + if (ComdatName != nullptr) { + MCSymbolELF *GroupSym = + cast(OutContext->getOrCreateSymbol(ComdatName)); + OutContext->createELFGroupSection(GroupSym, true); + Flags |= ELF::SHF_GROUP; + } + if (attributes & CustomSectionAttributes_Executable) { + Flags |= ELF::SHF_EXECINSTR; + } else if (attributes & CustomSectionAttributes_Writeable) { + Flags |= ELF::SHF_WRITE; + } + unsigned SectionType = (attributes & CustomSectionAttributes_Uninitialized) + ? ELF::SHT_NOBITS + : ELF::SHT_PROGBITS; + Section = + OutContext->getELFSection(SectionName, SectionType, Flags, 0, + ComdatName != nullptr ? ComdatName : "", + ComdatName != nullptr); + break; + } + default: + error("Unknown output format for target " + TripleName); + break; + } + return Section; +} + +void ObjectWriter::SetCodeSectionAttribute(const char *SectionName, + CustomSectionAttributes attributes, + const char *ComdatName) { + MCSection *Section = GetSection(SectionName, attributes, ComdatName); + + assert(!Section->hasInstructions()); + Section->setHasInstructions(true); + if (OutContext->getObjectFileType() != MCContext::IsCOFF) { + OutContext->addGenDwarfSection(Section); + } +} + +void ObjectWriter::EmitAlignment(int ByteAlignment) { + int64_t fillValue = 0; + + if (Streamer->getCurrentSectionOnly()->getKind().isText()) { + if (OutContext->getTargetTriple().getArch() == llvm::Triple::ArchType::x86 || + OutContext->getTargetTriple().getArch() == llvm::Triple::ArchType::x86_64) { + fillValue = 0x90; // x86 nop + } + } + + Streamer->emitValueToAlignment(Align(ByteAlignment), fillValue); +} + +void ObjectWriter::EmitBlob(int BlobSize, const char *Blob) { + if (Streamer->getCurrentSectionOnly()->getKind().isText()) { + Streamer->emitInstructionBytes(StringRef(Blob, BlobSize)); + } else { + Streamer->emitBytes(StringRef(Blob, BlobSize)); + } +} + +void ObjectWriter::EmitIntValue(uint64_t Value, unsigned Size) { + Streamer->emitIntValue(Value, Size); +} + +void ObjectWriter::EmitSymbolDef(const char *SymbolName, bool global) { + MCSymbol *Sym = OutContext->getOrCreateSymbol(Twine(SymbolName)); + + Streamer->emitSymbolAttribute(Sym, MCSA_Global); + + Triple TheTriple = OutContext->getTargetTriple(); + + if (TheTriple.getObjectFormat() == Triple::ELF) { + // An ARM function symbol should be marked with an appropriate ELF attribute + // to make later computation of a relocation address value correct + if (Streamer->getCurrentSectionOnly()->getKind().isText()) { + switch (TheTriple.getArch()) { + case Triple::arm: + case Triple::armeb: + case Triple::thumb: + case Triple::thumbeb: + case Triple::aarch64: + case Triple::aarch64_be: + Streamer->emitSymbolAttribute(Sym, MCSA_ELF_TypeFunction); + break; + default: + break; + } + } + + // Mark the symbol hidden if requested + if (!global) { + Streamer->emitSymbolAttribute(Sym, MCSA_Hidden); + } + } + + Streamer->emitLabel(Sym); +} + +const MCSymbolRefExpr * +ObjectWriter::GetSymbolRefExpr(const char *SymbolName, + MCSymbolRefExpr::VariantKind Kind) { + // Create symbol reference + MCSymbol *T = OutContext->getOrCreateSymbol(SymbolName); + Assembler->registerSymbol(*T); + return MCSymbolRefExpr::create(T, Kind, *OutContext); +} + +unsigned ObjectWriter::GetDFSize() { + return Streamer->getOrCreateDataFragment()->getContents().size(); +} + +void ObjectWriter::EmitRelocDirective(const int Offset, StringRef Name, const MCExpr *Expr) { + const MCExpr *OffsetExpr = MCConstantExpr::create(Offset, *OutContext); + std::optional> result = Streamer->emitRelocDirective(*OffsetExpr, Name, Expr, SMLoc(), *SubtargetInfo); + assert(!result.hasValue()); +} + +const MCExpr *ObjectWriter::GenTargetExpr(const MCSymbol* Symbol, MCSymbolRefExpr::VariantKind Kind, + int Delta, bool IsPCRel, int Size) { + const MCExpr *TargetExpr = MCSymbolRefExpr::create(Symbol, Kind, *OutContext); + if (IsPCRel && Size != 0) { + // If the fixup is pc-relative, we need to bias the value to be relative to + // the start of the field, not the end of the field + TargetExpr = MCBinaryExpr::createSub( + TargetExpr, MCConstantExpr::create(Size, *OutContext), *OutContext); + } + if (Delta != 0) { + TargetExpr = MCBinaryExpr::createAdd( + TargetExpr, MCConstantExpr::create(Delta, *OutContext), *OutContext); + } + return TargetExpr; +} + +int ObjectWriter::EmitSymbolRef(const char *SymbolName, + RelocType RelocationType, int Delta, SymbolRefFlags Flags) { + bool IsPCRel = false; + int Size = 0; + MCSymbolRefExpr::VariantKind Kind = MCSymbolRefExpr::VK_None; + + MCSymbol* Symbol = OutContext->getOrCreateSymbol(SymbolName); + Assembler->registerSymbol(*Symbol); + + if ((int)Flags & (int)SymbolRefFlags::SymbolRefFlags_AddressTakenFunction) { + AddressTakenFunctions.insert(Symbol); + } + + // Convert RelocationType to MCSymbolRefExpr + switch (RelocationType) { + case RelocType::IMAGE_REL_BASED_ABSOLUTE: + assert(OutContext->getObjectFileType() == MCContext::IsCOFF); + Kind = MCSymbolRefExpr::VK_COFF_IMGREL32; + Size = 4; + break; + case RelocType::IMAGE_REL_BASED_HIGHLOW: + Size = 4; + break; + case RelocType::IMAGE_REL_BASED_DIR64: + Size = 8; + break; + case RelocType::IMAGE_REL_BASED_REL32: + if (OutContext->getObjectFileType() == MCContext::IsMachO && + OutContext->getTargetTriple().getArch() == Triple::aarch64) { + MCSymbol *TempSymbol = OutContext->createTempSymbol(); + Streamer->emitLabel(TempSymbol); + const MCExpr *TargetExpr = MCSymbolRefExpr::create(Symbol, Kind, *OutContext); + const MCSymbolRefExpr *SectionExpr = MCSymbolRefExpr::create(TempSymbol, Kind, *OutContext); + TargetExpr = MCBinaryExpr::createSub( + TargetExpr, SectionExpr, *OutContext); + // If the fixup is pc-relative, we need to bias the value to be relative to + // the start of the field, not the end of the field + TargetExpr = MCBinaryExpr::createSub( + TargetExpr, MCConstantExpr::create(4, *OutContext), *OutContext); + if (Delta != 0) { + TargetExpr = MCBinaryExpr::createAdd( + TargetExpr, MCConstantExpr::create(Delta, *OutContext), *OutContext); + } + Streamer->emitValueImpl(TargetExpr, 4, SMLoc(), false); + return 4; + } + Size = 4; + IsPCRel = true; + if (OutContext->getObjectFileType() == MCContext::IsELF) { + // PLT is valid only for code symbols, + // but there shouldn't be references to global data symbols + Kind = MCSymbolRefExpr::VK_PLT; + } + break; + case RelocType::IMAGE_REL_BASED_RELPTR32: + if (OutContext->getObjectFileType() == MCContext::IsMachO && + OutContext->getTargetTriple().getArch() == Triple::aarch64) { + MCSymbol *TempSymbol = OutContext->createTempSymbol(); + Streamer->emitLabel(TempSymbol); + const MCExpr *TargetExpr = MCSymbolRefExpr::create(Symbol, Kind, *OutContext); + const MCSymbolRefExpr *SectionExpr = MCSymbolRefExpr::create(TempSymbol, Kind, *OutContext); + TargetExpr = MCBinaryExpr::createSub( + TargetExpr, SectionExpr, *OutContext); + if (Delta != 0) { + TargetExpr = MCBinaryExpr::createAdd( + TargetExpr, MCConstantExpr::create(Delta, *OutContext), *OutContext); + } + Streamer->emitValueImpl(TargetExpr, 4, SMLoc(), false); + return 4; + } + Size = 4; + IsPCRel = true; + Delta += 4; + break; + case RelocType::IMAGE_REL_BASED_THUMB_MOV32: { + const unsigned Offset = GetDFSize(); + const MCExpr *TargetExpr = GenTargetExpr(Symbol, Kind, Delta); + EmitRelocDirective(Offset, "R_ARM_THM_MOVW_ABS_NC", TargetExpr); + EmitRelocDirective(Offset + 4, "R_ARM_THM_MOVT_ABS", TargetExpr); + return 8; + } + case RelocType::IMAGE_REL_BASED_THUMB_BRANCH24: { + const MCExpr *TargetExpr = GenTargetExpr(Symbol, Kind, Delta); + EmitRelocDirective(GetDFSize(), "R_ARM_THM_CALL", TargetExpr); + return 4; + } + case RelocType::IMAGE_REL_BASED_ARM64_BRANCH26: { + const MCExpr *TargetExpr = GenTargetExpr(Symbol, Kind, Delta); + EmitRelocDirective(GetDFSize(), "R_AARCH64_CALL26", TargetExpr); + return 4; + } + case RelocType::IMAGE_REL_BASED_ARM64_PAGEBASE_REL21: { + if (OutContext->getObjectFileType() == MCContext::IsMachO) { + Kind = MCSymbolRefExpr::VK_PAGE; + } + const MCExpr *TargetExpr = GenTargetExpr(Symbol, Kind, Delta); + TargetExpr = + AArch64MCExpr::create(TargetExpr, AArch64MCExpr::VK_CALL, *OutContext); + EmitRelocDirective(GetDFSize(), "R_AARCH64_ADR_PREL_PG_HI21", TargetExpr); + return 4; + } + case RelocType::IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A: { + if (OutContext->getObjectFileType() == MCContext::IsMachO) { + Kind = MCSymbolRefExpr::VK_PAGEOFF; + } + const MCExpr *TargetExpr = GenTargetExpr(Symbol, Kind, Delta); + TargetExpr = + AArch64MCExpr::create(TargetExpr, AArch64MCExpr::VK_LO12, *OutContext); + EmitRelocDirective(GetDFSize(), "R_AARCH64_ADD_ABS_LO12_NC", TargetExpr); + return 4; + } + } + + const MCExpr *TargetExpr = GenTargetExpr(Symbol, Kind, Delta, IsPCRel, Size); + Streamer->emitValueImpl(TargetExpr, Size, SMLoc(), IsPCRel); + return Size; +} + +void ObjectWriter::EmitWinFrameInfo(const char *FunctionName, int StartOffset, + int EndOffset, const char *BlobSymbolName) { + assert(OutContext->getObjectFileType() == MCContext::IsCOFF); + + // .pdata emission + MCSection *Section = ObjFileInfo->getPDataSection(); + + // If the function was emitted to a Comdat section, create an associative + // section to place the frame info in. This is due to the Windows linker + // requirement that a function and its unwind info come from the same + // object file. + MCSymbol *Fn = OutContext->getOrCreateSymbol(Twine(FunctionName)); + const MCSectionCOFF *FunctionSection = cast(&Fn->getSection()); + if (FunctionSection->getCharacteristics() & COFF::IMAGE_SCN_LNK_COMDAT) { + Section = OutContext->getAssociativeCOFFSection( + cast(Section), FunctionSection->getCOMDATSymbol()); + } + + Streamer->switchSection(Section); + Streamer->emitValueToAlignment(Align(4)); + + const MCExpr *BaseRefRel = + GetSymbolRefExpr(FunctionName, MCSymbolRefExpr::VK_COFF_IMGREL32); + + Triple::ArchType Arch = OutContext->getTargetTriple().getArch(); + + if (Arch == Triple::thumb || Arch == Triple::thumbeb) { + StartOffset |= 1; + } + + // start Offset + const MCExpr *StartOfs = MCConstantExpr::create(StartOffset, *OutContext); + Streamer->emitValue( + MCBinaryExpr::createAdd(BaseRefRel, StartOfs, *OutContext), 4); + + if (Arch == Triple::x86 || Arch == Triple::x86_64) { + // end Offset + const MCExpr *EndOfs = MCConstantExpr::create(EndOffset, *OutContext); + Streamer->emitValue( + MCBinaryExpr::createAdd(BaseRefRel, EndOfs, *OutContext), 4); + } + + // frame symbol reference + Streamer->emitValue( + GetSymbolRefExpr(BlobSymbolName, MCSymbolRefExpr::VK_COFF_IMGREL32), 4); +} + +void ObjectWriter::EmitCFIStart(int Offset) { + assert(!FrameOpened && "frame should be closed before CFIStart"); + Streamer->emitCFIStartProc(false); + FrameOpened = true; + FrameHasCompactEncoding = false; +} + +void ObjectWriter::EmitCFIEnd(int Offset) { + assert(FrameOpened && "frame should be opened before CFIEnd"); + + // If compact unwinding was not set through EmitCFICompactUnwindEncoding + // force compact unwinding to use DWARF references which allow unwinding + // prologs and epilogs correctly. + if (!FrameHasCompactEncoding) { + Streamer->emitCFICompactUnwindEncoding(ObjFileInfo->getCompactUnwindDwarfEHFrameOnly()); + } + + Streamer->emitCFIEndProc(); + FrameOpened = false; +} + +void ObjectWriter::EmitCFILsda(const char *LsdaBlobSymbolName) { + assert(FrameOpened && "frame should be opened before CFILsda"); + + // Create symbol reference + MCSymbol *T = OutContext->getOrCreateSymbol(LsdaBlobSymbolName); + Assembler->registerSymbol(*T); + if (OutContext->getObjectFileType() == MCContext::IsMachO) { + Streamer->emitCFILsda(T, llvm::dwarf::Constants::DW_EH_PE_pcrel); + } else { + Streamer->emitCFILsda(T, llvm::dwarf::Constants::DW_EH_PE_pcrel | + llvm::dwarf::Constants::DW_EH_PE_sdata4); + } +} + +void ObjectWriter::EmitCFICode(int Offset, const char *Blob) { + assert(FrameOpened && "frame should be opened before CFICode"); + + const CFI_CODE *CfiCode = (const CFI_CODE *)Blob; + switch (CfiCode->CfiOpCode) { + case CFI_ADJUST_CFA_OFFSET: + assert(CfiCode->DwarfReg == DWARF_REG_ILLEGAL && + "Unexpected Register Value for OpAdjustCfaOffset"); + Streamer->emitCFIAdjustCfaOffset(CfiCode->Offset); + break; + case CFI_REL_OFFSET: + Streamer->emitCFIRelOffset(CfiCode->DwarfReg, CfiCode->Offset); + break; + case CFI_DEF_CFA_REGISTER: + assert(CfiCode->Offset == 0 && + "Unexpected Offset Value for OpDefCfaRegister"); + Streamer->emitCFIDefCfaRegister(CfiCode->DwarfReg); + break; + case CFI_DEF_CFA: + assert(CfiCode->Offset != 0 && + "Unexpected Offset Value for OpDefCfa"); + Streamer->emitCFIDefCfa(CfiCode->DwarfReg, CfiCode->Offset); + break; + default: + assert(false && "Unrecognized CFI"); + break; + } +} + +void ObjectWriter::EmitCFICompactUnwindEncoding(unsigned int Encoding) +{ + // Emits architecture specific compact unwinding encoding for MachO + // files on Apple platforms. Currently that's the only platform where + // compact unwinding tables are used. + // + // If EmitCFICompactUnwindEncoding is never called then EmitCFIEnd + // will cause compact unwinding to reference DWARF CFI info. It + // essentially turns the compact unwinding tables into an index for + // the DWARF CFI data, much like .eh_frame_hdr works in ELF files. + // + // If Encoding is set to zero it instructs LLVM to infer the compact + // unwinding encoding from the DWARF CFI data. + // + // Any non-zero value in Encoding is emitted directly into the + // __compact_unwind section and then processed by the linker. + // + // See generateCompactUnwindEncoding in AArch64AsmBackend.cpp and + // X86AsmBackend.cpp for specific encodings for a given architecture. + FrameHasCompactEncoding = true; + Streamer->emitCFICompactUnwindEncoding(Encoding); +} + +void ObjectWriter::EmitLabelDiff(const MCSymbol *From, const MCSymbol *To, + unsigned int Size) { + MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None; + const MCExpr *FromRef = MCSymbolRefExpr::create(From, Variant, *OutContext), + *ToRef = MCSymbolRefExpr::create(To, Variant, *OutContext); + const MCExpr *AddrDelta = + MCBinaryExpr::create(MCBinaryExpr::Sub, ToRef, FromRef, *OutContext); + Streamer->emitValue(AddrDelta, Size); +} + +void ObjectWriter::EmitSymRecord(int Size, SymbolRecordKind SymbolKind) { + RecordPrefix Rec; + Rec.RecordLen = ulittle16_t(Size + sizeof(ulittle16_t)); + Rec.RecordKind = ulittle16_t((uint16_t)SymbolKind); + Streamer->emitBytes(StringRef((char *)&Rec, sizeof(Rec))); +} + +void ObjectWriter::EmitCOFFSecRel32Value(MCExpr const *Value) { + MCDataFragment *DF = Streamer->getOrCreateDataFragment(); + MCFixup Fixup = MCFixup::create(DF->getContents().size(), Value, FK_SecRel_4); + DF->getFixups().push_back(Fixup); + DF->getContents().resize(DF->getContents().size() + 4, 0); +} + +void ObjectWriter::EmitVarDefRange(const MCSymbol *Fn, + const LocalVariableAddrRange &Range) { + const MCSymbolRefExpr *BaseSym = MCSymbolRefExpr::create(Fn, *OutContext); + const MCExpr *Offset = MCConstantExpr::create(Range.OffsetStart, *OutContext); + const MCExpr *Expr = MCBinaryExpr::createAdd(BaseSym, Offset, *OutContext); + EmitCOFFSecRel32Value(Expr); + Streamer->emitCOFFSectionIndex(Fn); + Streamer->emitIntValue(Range.Range, 2); +} + +// Maps an ICorDebugInfo register number to the corresponding CodeView +// register number +CVRegNum ObjectWriter::GetCVRegNum(unsigned RegNum) { + static const CVRegNum CVRegMapAmd64[] = { + CV_AMD64_RAX, CV_AMD64_RCX, CV_AMD64_RDX, CV_AMD64_RBX, + CV_AMD64_RSP, CV_AMD64_RBP, CV_AMD64_RSI, CV_AMD64_RDI, + CV_AMD64_R8, CV_AMD64_R9, CV_AMD64_R10, CV_AMD64_R11, + CV_AMD64_R12, CV_AMD64_R13, CV_AMD64_R14, CV_AMD64_R15, + }; + + switch (OutContext->getTargetTriple().getArch()) { + case Triple::x86: + if (X86::ICorDebugInfo::REGNUM_EAX <= RegNum && + RegNum <= X86::ICorDebugInfo::REGNUM_EDI) { + return RegNum - X86::ICorDebugInfo::REGNUM_EAX + CV_REG_EAX; + } + break; + case Triple::x86_64: + if (RegNum < sizeof(CVRegMapAmd64) / sizeof(CVRegMapAmd64[0])) { + return CVRegMapAmd64[RegNum]; + } + break; + case Triple::arm: + case Triple::armeb: + case Triple::thumb: + case Triple::thumbeb: + if (Arm::ICorDebugInfo::REGNUM_R0 <= RegNum && + RegNum <= Arm::ICorDebugInfo::REGNUM_PC) { + return RegNum - Arm::ICorDebugInfo::REGNUM_R0 + CV_ARM_R0; + } + break; + case Triple::aarch64: + case Triple::aarch64_be: + if (Arm64::ICorDebugInfo::REGNUM_X0 <= RegNum && + RegNum < Arm64::ICorDebugInfo::REGNUM_PC) { + return RegNum - Arm64::ICorDebugInfo::REGNUM_X0 + CV_ARM64_X0; + } + // Special registers are ordered FP, LR, SP, PC in ICorDebugInfo's + // enumeration and FP, LR, SP, *ZR*, PC in CodeView's enumeration. + // For that reason handle the PC register separately. + if (RegNum == Arm64::ICorDebugInfo::REGNUM_PC) { + return CV_ARM64_PC; + } + break; + default: + assert(false && "Unexpected architecture"); + break; + } + return CV_REG_NONE; +} + +void ObjectWriter::EmitCVDebugVarInfo(const MCSymbol *Fn, + const DebugVarInfo LocInfos[], + int NumVarInfos) { + for (int I = 0; I < NumVarInfos; I++) { + // Emit an S_LOCAL record + DebugVarInfo Var = LocInfos[I]; + TypeIndex Type = TypeIndex(Var.TypeIndex); + LocalSymFlags Flags = LocalSymFlags::None; + unsigned SizeofSym = sizeof(Type) + sizeof(Flags); + unsigned NameLength = Var.Name.length() + 1; + EmitSymRecord(SizeofSym + NameLength, SymbolRecordKind::LocalSym); + if (Var.IsParam) { + Flags |= LocalSymFlags::IsParameter; + } + Streamer->emitBytes(StringRef((char *)&Type, sizeof(Type))); + Streamer->emitIntValue(static_cast(Flags), sizeof(Flags)); + Streamer->emitBytes(StringRef(Var.Name.c_str(), NameLength)); + + for (const auto &Range : Var.Ranges) { + // Emit a range record + switch (Range.loc.vlType) { + case ICorDebugInfo::VLT_REG: + case ICorDebugInfo::VLT_REG_FP: { + + // Currently only support integer registers. + // TODO: support xmm registers + CVRegNum CVReg = GetCVRegNum(Range.loc.vlReg.vlrReg); + if (CVReg == CV_REG_NONE) { + break; + } + SymbolRecordKind SymbolKind = SymbolRecordKind::DefRangeRegisterSym; + unsigned SizeofDefRangeRegisterSym = sizeof(DefRangeRegisterSym::Hdr) + + sizeof(DefRangeRegisterSym::Range); + EmitSymRecord(SizeofDefRangeRegisterSym, SymbolKind); + + DefRangeRegisterSym DefRangeRegisterSymbol(SymbolKind); + DefRangeRegisterSymbol.Range.OffsetStart = Range.startOffset; + DefRangeRegisterSymbol.Range.Range = + Range.endOffset - Range.startOffset; + DefRangeRegisterSymbol.Range.ISectStart = 0; + DefRangeRegisterSymbol.Hdr.Register = CVReg; + DefRangeRegisterSymbol.Hdr.MayHaveNoName = 0; + + unsigned Length = sizeof(DefRangeRegisterSymbol.Hdr); + Streamer->emitBytes( + StringRef((char *)&DefRangeRegisterSymbol.Hdr, Length)); + EmitVarDefRange(Fn, DefRangeRegisterSymbol.Range); + break; + } + + case ICorDebugInfo::VLT_STK: { + + // TODO: support REGNUM_AMBIENT_SP + CVRegNum CVReg = GetCVRegNum(Range.loc.vlStk.vlsBaseReg); + if (CVReg == CV_REG_NONE) { + break; + } + + SymbolRecordKind SymbolKind = SymbolRecordKind::DefRangeRegisterRelSym; + unsigned SizeofDefRangeRegisterRelSym = + sizeof(DefRangeRegisterRelSym::Hdr) + + sizeof(DefRangeRegisterRelSym::Range); + EmitSymRecord(SizeofDefRangeRegisterRelSym, SymbolKind); + + DefRangeRegisterRelSym DefRangeRegisterRelSymbol(SymbolKind); + DefRangeRegisterRelSymbol.Range.OffsetStart = Range.startOffset; + DefRangeRegisterRelSymbol.Range.Range = + Range.endOffset - Range.startOffset; + DefRangeRegisterRelSymbol.Range.ISectStart = 0; + DefRangeRegisterRelSymbol.Hdr.Register = CVReg; + DefRangeRegisterRelSymbol.Hdr.Flags = 0; + DefRangeRegisterRelSymbol.Hdr.BasePointerOffset = + Range.loc.vlStk.vlsOffset; + + unsigned Length = sizeof(DefRangeRegisterRelSymbol.Hdr); + Streamer->emitBytes( + StringRef((char *)&DefRangeRegisterRelSymbol.Hdr, Length)); + EmitVarDefRange(Fn, DefRangeRegisterRelSymbol.Range); + break; + } + + case ICorDebugInfo::VLT_REG_BYREF: + case ICorDebugInfo::VLT_STK_BYREF: + case ICorDebugInfo::VLT_REG_REG: + case ICorDebugInfo::VLT_REG_STK: + case ICorDebugInfo::VLT_STK_REG: + case ICorDebugInfo::VLT_STK2: + case ICorDebugInfo::VLT_FPSTK: + case ICorDebugInfo::VLT_FIXED_VA: + // TODO: for optimized debugging + break; + + default: + assert(false && "Unknown varloc type!"); + break; + } + } + } +} + +void ObjectWriter::EmitCVDebugFunctionInfo(const char *FunctionName, + int FunctionSize) { + assert(OutContext->getObjectFileType() == MCContext::IsCOFF); + + // Mark the end of function. + MCSymbol *FnEnd = OutContext->createTempSymbol(); + Streamer->emitLabel(FnEnd); + + MCSection *Section = ObjFileInfo->getCOFFDebugSymbolsSection(); + Streamer->switchSection(Section); + // Emit debug section magic before the first entry. + if (FuncId == 1) { + Streamer->emitIntValue(COFF::DEBUG_SECTION_MAGIC, 4); + } + MCSymbol *Fn = OutContext->getOrCreateSymbol(Twine(FunctionName)); + + // Emit a symbol subsection, required by VS2012+ to find function boundaries. + MCSymbol *SymbolsBegin = OutContext->createTempSymbol(), + *SymbolsEnd = OutContext->createTempSymbol(); + Streamer->emitIntValue(unsigned(DebugSubsectionKind::Symbols), 4); + EmitLabelDiff(SymbolsBegin, SymbolsEnd); + Streamer->emitLabel(SymbolsBegin); + { + ProcSym ProcSymbol(SymbolRecordKind::GlobalProcIdSym); + ProcSymbol.CodeSize = FunctionSize; + ProcSymbol.DbgEnd = FunctionSize; + + unsigned FunctionNameLength = strlen(FunctionName) + 1; + unsigned HeaderSize = + sizeof(ProcSymbol.Parent) + sizeof(ProcSymbol.End) + + sizeof(ProcSymbol.Next) + sizeof(ProcSymbol.CodeSize) + + sizeof(ProcSymbol.DbgStart) + sizeof(ProcSymbol.DbgEnd) + + sizeof(ProcSymbol.FunctionType); + unsigned SymbolSize = HeaderSize + 4 + 2 + 1 + FunctionNameLength; + EmitSymRecord(SymbolSize, SymbolRecordKind::GlobalProcIdSym); + + Streamer->emitBytes(StringRef((char *)&ProcSymbol.Parent, HeaderSize)); + // Emit relocation + Streamer->emitCOFFSecRel32(Fn, 0); + Streamer->emitCOFFSectionIndex(Fn); + + // Emit flags + Streamer->emitIntValue(0, 1); + + // Emit the function display name as a null-terminated string. + + Streamer->emitBytes(StringRef(FunctionName, FunctionNameLength)); + + // Emit local var info + int NumVarInfos = DebugVarInfos.size(); + if (NumVarInfos > 0) { + EmitCVDebugVarInfo(Fn, &DebugVarInfos[0], NumVarInfos); + DebugVarInfos.clear(); + } + + // We're done with this function. + EmitSymRecord(0, SymbolRecordKind::ProcEnd); + } + + Streamer->emitLabel(SymbolsEnd); + + // Every subsection must be aligned to a 4-byte boundary. + Streamer->emitValueToAlignment(Align(4)); + + // We have an assembler directive that takes care of the whole line table. + // We also increase function id for the next function. + Streamer->emitCVLinetableDirective(FuncId++, Fn, FnEnd); +} + +void ObjectWriter::EmitDwarfFunctionInfo(const char *FunctionName, + int FunctionSize, + unsigned MethodTypeIndex) { + if (FuncId == 1) { + DwarfGenerator->EmitCompileUnit(); + } + + DwarfGenerator->EmitSubprogramInfo(FunctionName, FunctionSize, + MethodTypeIndex, DebugVarInfos, DebugEHClauseInfos); + + DebugVarInfos.clear(); + DebugEHClauseInfos.clear(); + + FuncId++; +} + +void ObjectWriter::EmitDebugFileInfo(int FileId, const char *FileName) { + assert(FileId > 0 && "FileId should be greater than 0."); + if (OutContext->getObjectFileType() == MCContext::IsCOFF) { + // TODO: we could pipe through the checksum and hash algorithm from the managed PDB + ArrayRef ChecksumAsBytes; + Streamer->emitCVFileDirective(FileId, FileName, ChecksumAsBytes, 0); + } else { + Streamer->emitDwarfFileDirective(FileId, "", FileName); + } +} + +void ObjectWriter::EmitDebugFunctionInfo(const char *FunctionName, + int FunctionSize, + unsigned MethodTypeIndex) { + if (OutContext->getObjectFileType() == MCContext::IsCOFF) { + Streamer->emitCVFuncIdDirective(FuncId); + EmitCVDebugFunctionInfo(FunctionName, FunctionSize); + } else { + if (OutContext->getObjectFileType() == MCContext::IsELF) { + MCSymbol *Sym = OutContext->getOrCreateSymbol(Twine(FunctionName)); + Streamer->emitSymbolAttribute(Sym, MCSA_ELF_TypeFunction); + Streamer->emitELFSize(Sym, + MCConstantExpr::create(FunctionSize, *OutContext)); + } + EmitDwarfFunctionInfo(FunctionName, FunctionSize, MethodTypeIndex); + } +} + +void ObjectWriter::EmitDebugVar(char *Name, int TypeIndex, bool IsParm, + int RangeCount, + const ICorDebugInfo::NativeVarInfo *Ranges) { + assert(RangeCount != 0); + DebugVarInfo NewVar(Name, TypeIndex, IsParm); + + for (int I = 0; I < RangeCount; I++) { + assert(Ranges[0].varNumber == Ranges[I].varNumber); + NewVar.Ranges.push_back(Ranges[I]); + } + + DebugVarInfos.push_back(NewVar); +} + +void ObjectWriter::EmitDebugEHClause(unsigned TryOffset, unsigned TryLength, + unsigned HandlerOffset, unsigned HandlerLength) { + if (OutContext->getObjectFileType() == MCContext::IsELF) { + DebugEHClauseInfos.emplace_back(TryOffset, TryLength, HandlerOffset, HandlerLength); + } +} + +void ObjectWriter::EmitDebugLoc(int NativeOffset, int FileId, int LineNumber, + int ColNumber) { + assert(FileId > 0 && "FileId should be greater than 0."); + if (OutContext->getObjectFileType() == MCContext::IsCOFF) { + Streamer->emitCVFuncIdDirective(FuncId); + Streamer->emitCVLocDirective(FuncId, FileId, LineNumber, ColNumber, false, + true, "", SMLoc()); + } else { + Streamer->emitDwarfLocDirective(FileId, LineNumber, ColNumber, 1, 0, 0, ""); + } +} + +void ObjectWriter::EmitCVUserDefinedTypesSymbols() { + const auto &UDTs = TypeBuilder->GetUDTs(); + if (UDTs.empty()) { + return; + } + MCSection *Section = ObjFileInfo->getCOFFDebugSymbolsSection(); + Streamer->switchSection(Section); + + MCSymbol *SymbolsBegin = OutContext->createTempSymbol(), + *SymbolsEnd = OutContext->createTempSymbol(); + Streamer->emitIntValue(unsigned(DebugSubsectionKind::Symbols), 4); + EmitLabelDiff(SymbolsBegin, SymbolsEnd); + Streamer->emitLabel(SymbolsBegin); + + for (const std::pair &UDT : UDTs) { + unsigned NameLength = UDT.first.length() + 1; + unsigned RecordLength = 2 + 4 + NameLength; + Streamer->emitIntValue(RecordLength, 2); + Streamer->emitIntValue(unsigned(SymbolKind::S_UDT), 2); + Streamer->emitIntValue(UDT.second, 4); + Streamer->emitBytes(StringRef(UDT.first.c_str(), NameLength)); + } + Streamer->emitLabel(SymbolsEnd); + Streamer->emitValueToAlignment(Align(4)); +} + +void ObjectWriter::EmitDebugModuleInfo() { + if (OutContext->getObjectFileType() == MCContext::IsCOFF) { + TypeBuilder->EmitTypeInformation(ObjFileInfo->getCOFFDebugTypesSection()); + EmitCVUserDefinedTypesSymbols(); + } + + // Ensure ending all sections. + for (auto Section : Sections) { + Streamer->endSection(Section); + } + + if (OutContext->getObjectFileType() == MCContext::IsCOFF) { + MCSection *Section = ObjFileInfo->getCOFFDebugSymbolsSection(); + Streamer->switchSection(Section); + Streamer->emitCVFileChecksumsDirective(); + Streamer->emitCVStringTableDirective(); + } else { + DwarfGenerator->EmitAbbrev(); + DwarfGenerator->EmitAranges(); + DwarfGenerator->Finish(); + } +} + +unsigned +ObjectWriter::GetEnumTypeIndex(const EnumTypeDescriptor &TypeDescriptor, + const EnumRecordTypeDescriptor *TypeRecords) { + return TypeBuilder->GetEnumTypeIndex(TypeDescriptor, TypeRecords); +} + +unsigned +ObjectWriter::GetClassTypeIndex(const ClassTypeDescriptor &ClassDescriptor) { + unsigned res = TypeBuilder->GetClassTypeIndex(ClassDescriptor); + return res; +} + +unsigned ObjectWriter::GetCompleteClassTypeIndex( + const ClassTypeDescriptor &ClassDescriptor, + const ClassFieldsTypeDescriptior &ClassFieldsDescriptor, + const DataFieldDescriptor *FieldsDescriptors, + const StaticDataFieldDescriptor *StaticsDescriptors) { + unsigned res = TypeBuilder->GetCompleteClassTypeIndex(ClassDescriptor, + ClassFieldsDescriptor, FieldsDescriptors, StaticsDescriptors); + return res; +} + +unsigned +ObjectWriter::GetArrayTypeIndex(const ClassTypeDescriptor &ClassDescriptor, + const ArrayTypeDescriptor &ArrayDescriptor) { + return TypeBuilder->GetArrayTypeIndex(ClassDescriptor, ArrayDescriptor); +} + +unsigned +ObjectWriter::GetPointerTypeIndex(const PointerTypeDescriptor& PointerDescriptor) { + return TypeBuilder->GetPointerTypeIndex(PointerDescriptor); +} + +unsigned +ObjectWriter::GetMemberFunctionTypeIndex(const MemberFunctionTypeDescriptor& MemberDescriptor, + uint32_t const *const ArgumentTypes) { + return TypeBuilder->GetMemberFunctionTypeIndex(MemberDescriptor, ArgumentTypes); +} + +unsigned +ObjectWriter::GetMemberFunctionId(const MemberFunctionIdTypeDescriptor& MemberIdDescriptor) { + return TypeBuilder->GetMemberFunctionId(MemberIdDescriptor); +} + +unsigned +ObjectWriter::GetPrimitiveTypeIndex(int Type) { + return TypeBuilder->GetPrimitiveTypeIndex(static_cast(Type)); +} + +void +ObjectWriter::EmitARMFnStart() { + MCTargetStreamer &TS = *(Streamer->getTargetStreamer()); + ARMTargetStreamer &ATS = static_cast(TS); + + ATS.emitFnStart(); +} + +void ObjectWriter::EmitARMFnEnd() { + + if (!CFIsPerOffset.empty()) + { + EmitARMExIdxPerOffset(); + } + + MCTargetStreamer &TS = *(Streamer->getTargetStreamer()); + ARMTargetStreamer &ATS = static_cast(TS); + + ATS.emitFnEnd(); +} + +void ObjectWriter::EmitARMExIdxLsda(const char *LsdaBlobSymbolName) +{ + MCTargetStreamer &TS = *(Streamer->getTargetStreamer()); + ARMTargetStreamer &ATS = static_cast(TS); + + MCSymbol *T = OutContext->getOrCreateSymbol(LsdaBlobSymbolName); + Assembler->registerSymbol(*T); + + ATS.emitLsda(T); +} + +void ObjectWriter::EmitARMExIdxPerOffset() +{ + MCTargetStreamer &TS = *(Streamer->getTargetStreamer()); + ARMTargetStreamer &ATS = static_cast(TS); + const MCRegisterInfo *MRI = OutContext->getRegisterInfo(); + + SmallVector RegSet; + bool IsVector = false; + + // LLVM reverses opcodes that are fed to ARMTargetStreamer, so we do the same, + // but per code offset. Opcodes with different code offsets are already given in + // the correct order. + for (int i = CFIsPerOffset.size() - 1; i >= 0; --i) + { + unsigned char opCode = CFIsPerOffset[i].CfiOpCode; + short Reg = CFIsPerOffset[i].DwarfReg; + + if (RegSet.empty() && opCode == CFI_REL_OFFSET) + { + IsVector = Reg >= 16; + } + else if (!RegSet.empty() && opCode != CFI_REL_OFFSET) + { + ATS.emitRegSave(RegSet, IsVector); + RegSet.clear(); + } + + switch (opCode) + { + case CFI_REL_OFFSET: + assert(IsVector == (Reg >= 16) && "Unexpected Register Type"); + RegSet.push_back(MRI->getLLVMRegNum(Reg, true).value()); + break; + case CFI_ADJUST_CFA_OFFSET: + assert(Reg == DWARF_REG_ILLEGAL && + "Unexpected Register Value for OpAdjustCfaOffset"); + ATS.emitPad(CFIsPerOffset[i].Offset); + break; + case CFI_DEF_CFA_REGISTER: + ATS.emitMovSP(MRI->getLLVMRegNum(Reg, true).value()); + break; + default: + assert(false && "Unrecognized CFI"); + break; + } + } + + // if we have some registers left over, emit them + if (!RegSet.empty()) + { + ATS.emitRegSave(RegSet, IsVector); + } + + CFIsPerOffset.clear(); +} + +void ObjectWriter::EmitARMExIdxCode(int Offset, const char *Blob) +{ + const CFI_CODE *CfiCode = (const CFI_CODE *)Blob; + + if (!CFIsPerOffset.empty() && CFIsPerOffset[0].CodeOffset != CfiCode->CodeOffset) + { + EmitARMExIdxPerOffset(); + } + + CFIsPerOffset.push_back(*CfiCode); +} diff --git a/llvm/tools/objwriter/objwriter.exports b/llvm/tools/objwriter/objwriter.exports new file mode 100644 index 00000000000000..d8a22c2b45afaa --- /dev/null +++ b/llvm/tools/objwriter/objwriter.exports @@ -0,0 +1,34 @@ +InitObjWriter +FinishObjWriter +SetDwarfVersion +SwitchSection +SetCodeSectionAttribute +EmitAlignment +EmitBlob +EmitIntValue +EmitSymbolDef +EmitSymbolRef +EmitWinFrameInfo +EmitCFIStart +EmitCFIEnd +EmitCFILsda +EmitCFICode +EmitCFICompactUnwindEncoding +EmitDebugFileInfo +EmitDebugFunctionInfo +EmitDebugVar +EmitDebugEHClause +EmitDebugLoc +EmitDebugModuleInfo +GetEnumTypeIndex +GetClassTypeIndex +GetCompleteClassTypeIndex +GetArrayTypeIndex +GetPointerTypeIndex +GetMemberFunctionTypeIndex +GetMemberFunctionIdTypeIndex +GetPrimitiveTypeIndex +EmitARMFnStart +EmitARMFnEnd +EmitARMExIdxLsda +EmitARMExIdxCode diff --git a/llvm/tools/objwriter/objwriter.h b/llvm/tools/objwriter/objwriter.h new file mode 100644 index 00000000000000..860312f92a13e2 --- /dev/null +++ b/llvm/tools/objwriter/objwriter.h @@ -0,0 +1,410 @@ +//===---- objwriter.h ------------------------------------------*- C++ -*-===// +// +// object writer +// +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// +//===----------------------------------------------------------------------===// + +#include "llvm/CodeGen/AsmPrinter.h" +#include "llvm/MC/MCInstrInfo.h" +#include "llvm/MC/MCObjectFileInfo.h" +#include "llvm/Target/TargetOptions.h" +#include "llvm/DebugInfo/CodeView/SymbolRecord.h" + +#include "cfi.h" +#include "jitDebugInfo.h" +#include "debugInfo/dwarf/dwarfGen.h" + +#include +#include + +using namespace llvm; +using namespace llvm::codeview; + +#ifdef _WIN32 +#define DLL_EXPORT extern "C" __declspec(dllexport) +#else +#define DLL_EXPORT extern "C" __attribute((visibility("default"))) +#endif + +// *** +// Define default call conventions +// *** +#if defined(HOST_X86) && !defined(HOST_UNIX) +#define STDMETHODCALLTYPE __stdcall +#else +#define STDMETHODCALLTYPE +#endif // defined(HOST_X86) && !defined(HOST_UNIX) + +typedef uint16_t CVRegNum; + +enum CustomSectionAttributes : int32_t { + CustomSectionAttributes_ReadOnly = 0x0000, + CustomSectionAttributes_Writeable = 0x0001, + CustomSectionAttributes_Executable = 0x0002, + CustomSectionAttributes_Uninitialized = 0x0004, + CustomSectionAttributes_MachO_Init_Func_Pointers = 0x0100, +}; + +enum class RelocType { + IMAGE_REL_BASED_ABSOLUTE = 0x00, + IMAGE_REL_BASED_HIGHLOW = 0x03, + IMAGE_REL_BASED_THUMB_MOV32 = 0x07, + IMAGE_REL_BASED_DIR64 = 0x0A, + IMAGE_REL_BASED_REL32 = 0x10, + IMAGE_REL_BASED_THUMB_BRANCH24 = 0x13, + IMAGE_REL_BASED_ARM64_BRANCH26 = 0x15, + IMAGE_REL_BASED_RELPTR32 = 0x7C, + IMAGE_REL_BASED_ARM64_PAGEBASE_REL21 = 0x81, + IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A = 0x82, +}; + +enum class SymbolRefFlags +{ + SymbolRefFlags_AddressTakenFunction = 0x0001, +}; + +class ObjectWriter { +public: + bool Init(StringRef FunctionName, const char* tripleName = nullptr); + void Finish(); + + void SetDwarfVersion(uint16_t v); + void SwitchSection(const char *SectionName, + CustomSectionAttributes attributes, + const char *ComdatName); + void SetCodeSectionAttribute(const char *SectionName, + CustomSectionAttributes attributes, + const char *ComdatName); + + void EmitAlignment(int ByteAlignment); + void EmitBlob(int BlobSize, const char *Blob); + void EmitIntValue(uint64_t Value, unsigned Size); + void EmitSymbolDef(const char *SymbolName, bool global); + void EmitWinFrameInfo(const char *FunctionName, int StartOffset, + int EndOffset, const char *BlobSymbolName); + int EmitSymbolRef(const char *SymbolName, RelocType RelocType, int Delta, SymbolRefFlags Flags); + + void EmitDebugFileInfo(int FileId, const char *FileName); + void EmitDebugFunctionInfo(const char *FunctionName, int FunctionSize, unsigned MethodTypeIndex); + void EmitDebugVar(char *Name, int TypeIndex, bool IsParm, int RangeCount, + const ICorDebugInfo::NativeVarInfo *Ranges); + void EmitDebugLoc(int NativeOffset, int FileId, int LineNumber, + int ColNumber); + void EmitDebugEHClause(unsigned TryOffset, unsigned TryLength, + unsigned HandlerOffset, unsigned HandlerLength); + void EmitDebugModuleInfo(); + + void EmitCFIStart(int Offset); + void EmitCFIEnd(int Offset); + void EmitCFILsda(const char *LsdaBlobSymbolName); + void EmitCFICode(int Offset, const char *Blob); + void EmitCFICompactUnwindEncoding(unsigned int Encoding); + + unsigned GetEnumTypeIndex(const EnumTypeDescriptor &TypeDescriptor, + const EnumRecordTypeDescriptor *TypeRecords); + unsigned GetClassTypeIndex(const ClassTypeDescriptor &ClassDescriptor); + unsigned GetCompleteClassTypeIndex( + const ClassTypeDescriptor &ClassDescriptor, + const ClassFieldsTypeDescriptior &ClassFieldsDescriptor, + const DataFieldDescriptor *FieldsDescriptors, + const StaticDataFieldDescriptor *StaticsDescriptors); + + unsigned GetArrayTypeIndex(const ClassTypeDescriptor &ClassDescriptor, + const ArrayTypeDescriptor &ArrayDescriptor); + + unsigned GetPointerTypeIndex(const PointerTypeDescriptor& PointerDescriptor); + + unsigned GetMemberFunctionTypeIndex(const MemberFunctionTypeDescriptor& MemberDescriptor, + uint32_t const *const ArgumentTypes); + + unsigned GetMemberFunctionId(const MemberFunctionIdTypeDescriptor& MemberIdDescriptor); + + unsigned GetPrimitiveTypeIndex(int Type); + + void EmitARMFnStart(); + void EmitARMFnEnd(); + void EmitARMExIdxCode(int Offset, const char *Blob); + void EmitARMExIdxLsda(const char *Blob); + +private: + void EmitLabelDiff(const MCSymbol *From, const MCSymbol *To, + unsigned int Size = 4); + void EmitSymRecord(int Size, SymbolRecordKind SymbolKind); + void EmitCOFFSecRel32Value(MCExpr const *Value); + + void EmitVarDefRange(const MCSymbol *Fn, const LocalVariableAddrRange &Range); + + CVRegNum GetCVRegNum(unsigned RegNum); + void EmitCVDebugVarInfo(const MCSymbol *Fn, const DebugVarInfo LocInfos[], + int NumVarInfos); + void EmitCVDebugFunctionInfo(const char *FunctionName, int FunctionSize); + + void EmitDwarfFunctionInfo(const char *FunctionName, int FunctionSize, unsigned MethodTypeIndex); + + const MCSymbolRefExpr *GetSymbolRefExpr( + const char *SymbolName, + MCSymbolRefExpr::VariantKind Kind = MCSymbolRefExpr::VK_None); + + MCSection *GetSection(const char *SectionName, + CustomSectionAttributes attributes, + const char *ComdatName); + + MCSection *GetSpecificSection(const char *SectionName, + CustomSectionAttributes attributes, + const char *ComdatName); + + void EmitCVUserDefinedTypesSymbols(); + + void InitTripleName(const char* tripleName = nullptr); + unsigned GetDFSize(); + void EmitRelocDirective(const int Offset, StringRef Name, const MCExpr *Expr); + const MCExpr *GenTargetExpr(const MCSymbol* Symbol, + MCSymbolRefExpr::VariantKind Kind, int Delta, + bool IsPCRel = false, int Size = 0); + void EmitARMExIdxPerOffset(); + + +private: + std::unique_ptr RegisterInfo; + std::unique_ptr AsmInfo; + std::unique_ptr ObjFileInfo; + std::unique_ptr OutContext; + MCAsmBackend *AsmBackend; // Owned by MCStreamer + std::unique_ptr InstrInfo; + std::unique_ptr SubtargetInfo; + MCCodeEmitter *CodeEmitter; // Owned by MCStreamer + MCAssembler *Assembler; // Owned by MCStreamer + std::unique_ptr DwarfGenerator; + + std::unique_ptr OS; + MCTargetOptions TargetMOptions; + bool FrameOpened; + bool FrameHasCompactEncoding; + std::vector DebugVarInfos; + std::vector DebugEHClauseInfos; + DenseSet AddressTakenFunctions; + + std::set Sections; + int FuncId; + + std::unique_ptr TypeBuilder; + + std::string TripleName; + + MCObjectStreamer *Streamer; // Owned by AsmPrinter + + SmallVector CFIsPerOffset; +}; + +// When object writer is created/initialized successfully, it is returned. +// Or null object is returned. Client should check this. +DLL_EXPORT STDMETHODCALLTYPE ObjectWriter *InitObjWriter(const char *ObjectFilePath, const char* TripleName = nullptr) { + ObjectWriter *OW = new ObjectWriter(); + if (OW->Init(ObjectFilePath, TripleName)) { + return OW; + } + delete OW; + return nullptr; +} + +DLL_EXPORT STDMETHODCALLTYPE void FinishObjWriter(ObjectWriter *OW) { + assert(OW && "ObjWriter is null"); + OW->Finish(); + delete OW; +} + +DLL_EXPORT STDMETHODCALLTYPE void SetDwarfVersion(ObjectWriter *OW, uint16_t v) { + assert(OW && "ObjWriter is null"); + OW->SetDwarfVersion(v); +} + +DLL_EXPORT STDMETHODCALLTYPE void SwitchSection(ObjectWriter *OW, const char *SectionName, + CustomSectionAttributes attributes, + const char *ComdatName) { + assert(OW && "ObjWriter is null"); + OW->SwitchSection(SectionName, attributes, ComdatName); +} + +DLL_EXPORT STDMETHODCALLTYPE void SetCodeSectionAttribute(ObjectWriter *OW, + const char *SectionName, + CustomSectionAttributes attributes, + const char *ComdatName) { + assert(OW && "ObjWriter is null"); + OW->SetCodeSectionAttribute(SectionName, attributes, ComdatName); +} + +DLL_EXPORT STDMETHODCALLTYPE void EmitAlignment(ObjectWriter *OW, int ByteAlignment) { + assert(OW && "ObjWriter is null"); + OW->EmitAlignment(ByteAlignment); +} + +DLL_EXPORT STDMETHODCALLTYPE void EmitBlob(ObjectWriter *OW, int BlobSize, const char *Blob) { + assert(OW && "ObjWriter null"); + OW->EmitBlob(BlobSize, Blob); +} + +DLL_EXPORT STDMETHODCALLTYPE void EmitIntValue(ObjectWriter *OW, uint64_t Value, unsigned Size) { + assert(OW && "ObjWriter is null"); + OW->EmitIntValue(Value, Size); +} + +DLL_EXPORT STDMETHODCALLTYPE void EmitSymbolDef(ObjectWriter *OW, const char *SymbolName, bool global) { + assert(OW && "ObjWriter is null"); + OW->EmitSymbolDef(SymbolName, global); +} + +DLL_EXPORT STDMETHODCALLTYPE int EmitSymbolRef(ObjectWriter *OW, const char *SymbolName, + RelocType RelocType, int Delta, SymbolRefFlags Flags) { + assert(OW && "ObjWriter is null"); + return OW->EmitSymbolRef(SymbolName, RelocType, Delta, Flags); +} + +DLL_EXPORT STDMETHODCALLTYPE void EmitWinFrameInfo(ObjectWriter *OW, const char *FunctionName, + int StartOffset, int EndOffset, + const char *BlobSymbolName) { + assert(OW && "ObjWriter is null"); + OW->EmitWinFrameInfo(FunctionName, StartOffset, EndOffset, BlobSymbolName); +} + +DLL_EXPORT STDMETHODCALLTYPE void EmitCFIStart(ObjectWriter *OW, int Offset) { + assert(OW && "ObjWriter is null"); + OW->EmitCFIStart(Offset); +} + +DLL_EXPORT STDMETHODCALLTYPE void EmitCFIEnd(ObjectWriter *OW, int Offset) { + assert(OW && "ObjWriter is null"); + OW->EmitCFIEnd(Offset); +} + +DLL_EXPORT STDMETHODCALLTYPE void EmitCFILsda(ObjectWriter *OW, const char *LsdaBlobSymbolName) { + assert(OW && "ObjWriter is null"); + OW->EmitCFILsda(LsdaBlobSymbolName); +} + +DLL_EXPORT STDMETHODCALLTYPE void EmitCFICode(ObjectWriter *OW, int Offset, const char *Blob) { + assert(OW && "ObjWriter is null"); + OW->EmitCFICode(Offset, Blob); +} + +DLL_EXPORT STDMETHODCALLTYPE void EmitCFICompactUnwindEncoding(ObjectWriter *OW, unsigned int Encoding) { + assert(OW && "ObjWriter is null"); + OW->EmitCFICompactUnwindEncoding(Encoding); +} + +DLL_EXPORT STDMETHODCALLTYPE void EmitDebugFileInfo(ObjectWriter *OW, int FileId, + const char *FileName) { + assert(OW && "ObjWriter is null"); + OW->EmitDebugFileInfo(FileId, FileName); +} + +DLL_EXPORT STDMETHODCALLTYPE void EmitDebugFunctionInfo(ObjectWriter *OW, + const char *FunctionName, + int FunctionSize, + unsigned MethodTypeIndex) { + assert(OW && "ObjWriter is null"); + OW->EmitDebugFunctionInfo(FunctionName, FunctionSize, MethodTypeIndex); +} + +DLL_EXPORT STDMETHODCALLTYPE void EmitDebugVar(ObjectWriter *OW, char *Name, int TypeIndex, + bool IsParam, int RangeCount, + ICorDebugInfo::NativeVarInfo *Ranges) { + assert(OW && "ObjWriter is null"); + OW->EmitDebugVar(Name, TypeIndex, IsParam, RangeCount, Ranges); +} + +DLL_EXPORT STDMETHODCALLTYPE void EmitDebugEHClause(ObjectWriter *OW, unsigned TryOffset, + unsigned TryLength, unsigned HandlerOffset, + unsigned HandlerLength) { + assert(OW && "ObjWriter is null"); + OW->EmitDebugEHClause(TryOffset, TryLength, HandlerOffset, HandlerLength); +} + +DLL_EXPORT STDMETHODCALLTYPE void EmitDebugLoc(ObjectWriter *OW, int NativeOffset, int FileId, + int LineNumber, int ColNumber) { + assert(OW && "ObjWriter is null"); + OW->EmitDebugLoc(NativeOffset, FileId, LineNumber, ColNumber); +} + +// This should be invoked at the end of module emission to finalize +// debug module info. +DLL_EXPORT STDMETHODCALLTYPE void EmitDebugModuleInfo(ObjectWriter *OW) { + assert(OW && "ObjWriter is null"); + OW->EmitDebugModuleInfo(); +} + +DLL_EXPORT STDMETHODCALLTYPE unsigned GetEnumTypeIndex(ObjectWriter *OW, + EnumTypeDescriptor TypeDescriptor, + EnumRecordTypeDescriptor *TypeRecords) { + assert(OW && "ObjWriter is null"); + return OW->GetEnumTypeIndex(TypeDescriptor, TypeRecords); +} + +DLL_EXPORT STDMETHODCALLTYPE unsigned GetClassTypeIndex(ObjectWriter *OW, + ClassTypeDescriptor ClassDescriptor) { + assert(OW && "ObjWriter is null"); + return OW->GetClassTypeIndex(ClassDescriptor); +} + +DLL_EXPORT STDMETHODCALLTYPE unsigned +GetCompleteClassTypeIndex(ObjectWriter *OW, ClassTypeDescriptor ClassDescriptor, + ClassFieldsTypeDescriptior ClassFieldsDescriptor, + DataFieldDescriptor *FieldsDescriptors, + StaticDataFieldDescriptor *StaticsDescriptors) { + assert(OW && "ObjWriter is null"); + return OW->GetCompleteClassTypeIndex(ClassDescriptor, ClassFieldsDescriptor, + FieldsDescriptors, StaticsDescriptors); +} + +DLL_EXPORT STDMETHODCALLTYPE unsigned GetArrayTypeIndex(ObjectWriter *OW, + ClassTypeDescriptor ClassDescriptor, + ArrayTypeDescriptor ArrayDescriptor) { + assert(OW && "ObjWriter is null"); + return OW->GetArrayTypeIndex(ClassDescriptor, ArrayDescriptor); +} + +DLL_EXPORT STDMETHODCALLTYPE unsigned GetPointerTypeIndex(ObjectWriter *OW, + PointerTypeDescriptor PointerDescriptor) { + assert(OW && "ObjWriter is null"); + return OW->GetPointerTypeIndex(PointerDescriptor); +} + +DLL_EXPORT STDMETHODCALLTYPE unsigned GetMemberFunctionTypeIndex(ObjectWriter *OW, + MemberFunctionTypeDescriptor MemberDescriptor, + uint32_t *ArgumentTypes) { + assert(OW && "ObjWriter is null"); + return OW->GetMemberFunctionTypeIndex(MemberDescriptor, ArgumentTypes); +} + +DLL_EXPORT STDMETHODCALLTYPE unsigned GetMemberFunctionIdTypeIndex(ObjectWriter *OW, + MemberFunctionIdTypeDescriptor MemberIdDescriptor) { + assert(OW && "ObjWriter is null"); + return OW->GetMemberFunctionId(MemberIdDescriptor); +} + +DLL_EXPORT STDMETHODCALLTYPE unsigned GetPrimitiveTypeIndex(ObjectWriter *OW, int Type) { + assert(OW && "ObjWriter is null"); + return OW->GetPrimitiveTypeIndex(Type); +} + +DLL_EXPORT STDMETHODCALLTYPE void EmitARMFnStart(ObjectWriter *OW) { + assert(OW && "ObjWriter is null"); + return OW->EmitARMFnStart(); +} + +DLL_EXPORT STDMETHODCALLTYPE void EmitARMFnEnd(ObjectWriter *OW) { + assert(OW && "ObjWriter is null"); + return OW->EmitARMFnEnd(); +} + +DLL_EXPORT STDMETHODCALLTYPE void EmitARMExIdxLsda(ObjectWriter *OW, const char *Blob) { + assert(OW && "ObjWriter is null"); + return OW->EmitARMExIdxLsda(Blob); +} + +DLL_EXPORT STDMETHODCALLTYPE void EmitARMExIdxCode(ObjectWriter *OW, int Offset, const char *Blob) { + assert(OW && "ObjWriter is null"); + return OW->EmitARMExIdxCode(Offset, Blob); +} diff --git a/llvm/utils/docker/debian10/Dockerfile b/llvm/utils/docker/debian10/Dockerfile deleted file mode 100644 index b898c935b9726f..00000000000000 --- a/llvm/utils/docker/debian10/Dockerfile +++ /dev/null @@ -1,47 +0,0 @@ -#===- llvm/utils/docker/debian10/build/Dockerfile -------------------------===// -# -# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# -#===----------------------------------------------------------------------===// -# Stage 1. Check out LLVM source code and run the build. -FROM launcher.gcr.io/google/debian10:latest as builder -LABEL maintainer "LLVM Developers" -# Install build dependencies of llvm. -# First, Update the apt's source list and include the sources of the packages. -RUN grep deb /etc/apt/sources.list | \ - sed 's/^deb/deb-src /g' >> /etc/apt/sources.list -# Install compiler, python and subversion. -RUN apt-get update && \ - apt-get install -y --no-install-recommends ca-certificates gnupg \ - build-essential cmake make python3 zlib1g wget subversion unzip git && \ - rm -rf /var/lib/apt/lists/* -# Install a newer ninja release. It seems the older version in the debian repos -# randomly crashes when compiling llvm. -RUN wget "https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip" && \ - echo "d2fea9ff33b3ef353161ed906f260d565ca55b8ca0568fa07b1d2cab90a84a07 ninja-linux.zip" \ - | sha256sum -c && \ - unzip ninja-linux.zip -d /usr/local/bin && \ - rm ninja-linux.zip - -ADD checksums /tmp/checksums -ADD scripts /tmp/scripts - -# Checkout the source code. -ARG checkout_args -RUN /tmp/scripts/checkout.sh ${checkout_args} -# Run the build. Results of the build will be available at /tmp/clang-install/. -ARG buildscript_args -RUN /tmp/scripts/build_install_llvm.sh --to /tmp/clang-install ${buildscript_args} - - -# Stage 2. Produce a minimal release image with build results. -FROM launcher.gcr.io/google/debian10:latest -LABEL maintainer "LLVM Developers" -# Install packages for minimal useful image. -RUN apt-get update && \ - apt-get install -y --no-install-recommends libstdc++-7-dev binutils && \ - rm -rf /var/lib/apt/lists/* -# Copy build results of stage 1 to /usr/local. -COPY --from=builder /tmp/clang-install/ /usr/local/ diff --git a/llvm/utils/docker/example/Dockerfile b/llvm/utils/docker/example/Dockerfile deleted file mode 100644 index ebfb0e49c82c86..00000000000000 --- a/llvm/utils/docker/example/Dockerfile +++ /dev/null @@ -1,39 +0,0 @@ -#===- llvm/utils/docker/example/build/Dockerfile -------------------------===// -# -# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# -#===----------------------------------------------------------------------===// -# This is an example Dockerfile to build an image that compiles clang. -# Replace FIXMEs to prepare your own image. - -# Stage 1. Check out LLVM source code and run the build. -# FIXME: Replace 'ubuntu' with your base image -FROM ubuntu as builder -# FIXME: Change maintainer name -LABEL maintainer "Maintainer " -# FIXME: Install llvm/clang build dependencies here. Including compiler to -# build stage1, cmake, subversion, ninja, etc. - -ADD checksums /tmp/checksums -ADD scripts /tmp/scripts - -# Checkout the source code. -ARG checkout_args -RUN /tmp/scripts/checkout.sh ${checkout_args} -# Run the build. Results of the build will be available at /tmp/clang-install/. -ARG buildscript_args -RUN /tmp/scripts/build_install_llvm.sh --to /tmp/clang-install ${buildscript_args} - - -# Stage 2. Produce a minimal release image with build results. -# FIXME: Replace 'ubuntu' with your base image. -FROM ubuntu -# FIXME: Change maintainer name. -LABEL maintainer "Maintainer " -# FIXME: Install all packages you want to have in your release container. -# A minimal useful installation should include at least libstdc++ and binutils. - -# Copy build results of stage 1 to /usr/local. -COPY --from=builder /tmp/clang-install/ /usr/local/ diff --git a/llvm/utils/docker/nvidia-cuda/Dockerfile b/llvm/utils/docker/nvidia-cuda/Dockerfile deleted file mode 100644 index 91ad53c57b1655..00000000000000 --- a/llvm/utils/docker/nvidia-cuda/Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -#===- llvm/utils/docker/nvidia-cuda/build/Dockerfile ---------------------===// -# -# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# -#===----------------------------------------------------------------------===// -# Stage 1. Check out LLVM source code and run the build. -FROM nvidia/cuda:8.0-devel as builder -LABEL maintainer "LLVM Developers" -# Install llvm build dependencies. -RUN apt-get update && \ - apt-get install -y --no-install-recommends ca-certificates cmake python \ - subversion ninja-build git && \ - rm -rf /var/lib/apt/lists/* - -ADD checksums /tmp/checksums -ADD scripts /tmp/scripts - -# Checkout the source code. -ARG checkout_args -RUN /tmp/scripts/checkout.sh ${checkout_args} -# Run the build. Results of the build will be available at /tmp/clang-install/. -ARG buildscript_args -RUN /tmp/scripts/build_install_llvm.sh --to /tmp/clang-install ${buildscript_args} - - -# Stage 2. Produce a minimal release image with build results. -FROM nvidia/cuda:8.0-devel -LABEL maintainer "LLVM Developers" -# Copy clang installation into this container. -COPY --from=builder /tmp/clang-install/ /usr/local/ -# C++ standard library and binutils are already included in the base package. diff --git a/llvm/utils/vscode/llvm/.npmrc b/llvm/utils/vscode/llvm/.npmrc new file mode 100644 index 00000000000000..8701ec2998ee74 --- /dev/null +++ b/llvm/utils/vscode/llvm/.npmrc @@ -0,0 +1 @@ +registry=https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/ diff --git a/llvm/version.txt.in b/llvm/version.txt.in new file mode 100644 index 00000000000000..a24f9877ac158c --- /dev/null +++ b/llvm/version.txt.in @@ -0,0 +1 @@ +@PACKAGE_VERSION@ diff --git a/mlir/utils/vscode/.npmrc b/mlir/utils/vscode/.npmrc new file mode 100644 index 00000000000000..8701ec2998ee74 --- /dev/null +++ b/mlir/utils/vscode/.npmrc @@ -0,0 +1 @@ +registry=https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/ diff --git a/nuget/Directory.Build.props b/nuget/Directory.Build.props new file mode 100644 index 00000000000000..9b159f511261d2 --- /dev/null +++ b/nuget/Directory.Build.props @@ -0,0 +1,205 @@ + + + + + + + + + + + AnyCPU + + + <_parseDistroRid>$(__DistroRid) + <_parseDistroRid Condition="'$(_parseDistroRid)' == '' and '$(__BuildOS)' == 'OSX'">osx-$(Platform) + <_distroRidIndex>$(_parseDistroRid.IndexOfAny("-")) + <_archRidIndex>$([MSBuild]::Add($(_distroRidIndex), 1)) + $(_parseDistroRid.SubString(0, $(_distroRidIndex))) + linux + win10 + + $(_parseDistroRid.SubString($(_archRidIndex))) + $(Platform) + $(BuildArch) + + $(OSRid) + + Windows_NT;OSX;Android;Linux;FreeBSD + ;$(SupportedPackageOSGroups); + + + <_runtimeOSVersionIndex>$(RuntimeOS.IndexOfAny(".-0123456789")) + <_runtimeOSFamily Condition="'$(_runtimeOSVersionIndex)' != '-1'">$(RuntimeOS.SubString(0, $(_runtimeOSVersionIndex))) + <_runtimeOSFamily Condition="'$(_runtimeOSVersionIndex)' == '-1'">$(RuntimeOS) + <_isSupportedOSGroup>true + + + + + <_derivedPackageTargetOSGroup Condition="'$(_derivedPackageTargetOSGroup)' == '' and '$(_runtimeOSFamily)' == 'osx'">OSX + <_derivedPackageTargetOSGroup Condition="'$(_derivedPackageTargetOSGroup)' == '' and '$(_runtimeOSFamily)' == 'android'">Android + <_derivedPackageTargetOSGroup Condition="'$(_derivedPackageTargetOSGroup)' == '' and '$(_runtimeOSFamily)' == 'win'">Windows_NT + <_derivedPackageTargetOSGroup Condition="'$(_derivedPackageTargetOSGroup)' == '' and '$(__BuildOS)' != ''">$(__BuildOS) + <_derivedPackageTargetOSGroup Condition="'$(_derivedPackageTargetOSGroup)' == ''">Linux + + <_isSupportedOSGroup Condition="!$(SupportedPackageOSGroups.Contains(';$(_derivedPackageTargetOSGroup);'))">false + + + + + <_packageTargetOSGroup>$(_derivedPackageTargetOSGroup) + <_packageTargetOSGroup Condition="'$(_derivedPackageTargetOSGroup)' == 'Android'">Linux + + + true + $(PackageOutputPath) + + + + true + + + + + + + + $(OutputRID) + + + + + + win-$(ArchGroup) + + + + + osx-$(ArchGroup) + + osx-$(ArchGroup) + + + + + freebsd.11-$(ArchGroup) + + freebsd-$(ArchGroup) + + + + + android.21-$(ArchGroup) + + android-$(ArchGroup) + + + + + $(OSRid)-$(ArchGroup) + + linux-$(ArchGroup) + + + + + $(RuntimeOS)-$(ArchGroup) + + linux-$(ArchGroup) + + + + + + + + + + .dylib + .dwarf + + + + + .so + + .debug + + + + + .so + .dbg + + + + + + + + + + arm + + + arm64 + + + arm64 + + + armel + + + armel + + + + + + + + + + + x86 + + + + arm + + + arm64 + + + + + + + amd64 + $(ArchGroup) + + + + + <_project Include="@(BuildRID)"> + amd64 + %(Identity) + PackageTargetRuntime=%(Identity);Platform=%(Platform) + + + <_buildRidProjects Include="@(_project->'$(MSBuildProjectName).pkgproj')" /> + + + + + + + + + diff --git a/nuget/Directory.Build.targets b/nuget/Directory.Build.targets new file mode 100644 index 00000000000000..f5aaa3315faa15 --- /dev/null +++ b/nuget/Directory.Build.targets @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + runtimes/$(PackageTargetRuntime)/native + + + + runtimes/$(PackageTargetRuntime)/lib/netstandard1.0 + + + tools + + + + + + + + + + + + + + + + + + + + + + + true + + + + + true + + + + + runtimes/$(PackageTargetRuntime)/native + true + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.JIT.Tools/Directory.Build.props b/nuget/Microsoft.NETCore.Runtime.JIT.Tools/Directory.Build.props new file mode 100644 index 00000000000000..f4a1490ea1da54 --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.JIT.Tools/Directory.Build.props @@ -0,0 +1,4 @@ + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.JIT.Tools/Microsoft.NETCore.Runtime.JIT.Tools.builds b/nuget/Microsoft.NETCore.Runtime.JIT.Tools/Microsoft.NETCore.Runtime.JIT.Tools.builds new file mode 100644 index 00000000000000..eaae7d884d1c9f --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.JIT.Tools/Microsoft.NETCore.Runtime.JIT.Tools.builds @@ -0,0 +1,4 @@ + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.JIT.Tools/Microsoft.NETCore.Runtime.JIT.Tools.pkgproj b/nuget/Microsoft.NETCore.Runtime.JIT.Tools/Microsoft.NETCore.Runtime.JIT.Tools.pkgproj new file mode 100644 index 00000000000000..a574caec29e4f6 --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.JIT.Tools/Microsoft.NETCore.Runtime.JIT.Tools.pkgproj @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.JIT.Tools/runtime.Linux.Microsoft.NETCore.Runtime.JIT.Tools.props b/nuget/Microsoft.NETCore.Runtime.JIT.Tools/runtime.Linux.Microsoft.NETCore.Runtime.JIT.Tools.props new file mode 100644 index 00000000000000..7819e88686aba9 --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.JIT.Tools/runtime.Linux.Microsoft.NETCore.Runtime.JIT.Tools.props @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.JIT.Tools/runtime.OSX.Microsoft.NETCore.Runtime.JIT.Tools.props b/nuget/Microsoft.NETCore.Runtime.JIT.Tools/runtime.OSX.Microsoft.NETCore.Runtime.JIT.Tools.props new file mode 100644 index 00000000000000..c4fb271a831615 --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.JIT.Tools/runtime.OSX.Microsoft.NETCore.Runtime.JIT.Tools.props @@ -0,0 +1,7 @@ + + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.JIT.Tools/runtime.Windows_NT.Microsoft.NETCore.Runtime.JIT.Tools.props b/nuget/Microsoft.NETCore.Runtime.JIT.Tools/runtime.Windows_NT.Microsoft.NETCore.Runtime.JIT.Tools.props new file mode 100644 index 00000000000000..0efb2beedbf524 --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.JIT.Tools/runtime.Windows_NT.Microsoft.NETCore.Runtime.JIT.Tools.props @@ -0,0 +1,7 @@ + + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk/Directory.Build.props b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk/Directory.Build.props new file mode 100644 index 00000000000000..f4a1490ea1da54 --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk/Directory.Build.props @@ -0,0 +1,4 @@ + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk.Debug.builds b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk.Debug.builds new file mode 100644 index 00000000000000..eaae7d884d1c9f --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk.Debug.builds @@ -0,0 +1,4 @@ + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk.Debug.pkgproj b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk.Debug.pkgproj new file mode 100644 index 00000000000000..10df842e48c1ed --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk.Debug.pkgproj @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk.builds b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk.builds new file mode 100644 index 00000000000000..eaae7d884d1c9f --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk.builds @@ -0,0 +1,4 @@ + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk.pkgproj b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk.pkgproj new file mode 100644 index 00000000000000..a574caec29e4f6 --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk.pkgproj @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk/runtime.Linux.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk.props b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk/runtime.Linux.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk.props new file mode 100644 index 00000000000000..fbf98adad6dbd5 --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk/runtime.Linux.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk.props @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk/runtime.OSX.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk.props b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk/runtime.OSX.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk.props new file mode 100644 index 00000000000000..81f1ea3a623383 --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk/runtime.OSX.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk.props @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk/runtime.Windows_NT.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk.props b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk/runtime.Windows_NT.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk.props new file mode 100644 index 00000000000000..e58d01f1bac106 --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Sdk/runtime.Windows_NT.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk.props @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Tools/Directory.Build.props b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Tools/Directory.Build.props new file mode 100644 index 00000000000000..f4a1490ea1da54 --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Tools/Directory.Build.props @@ -0,0 +1,4 @@ + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Tools/Microsoft.NETCore.Runtime.Mono.LLVM.Tools.Debug.builds b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Tools/Microsoft.NETCore.Runtime.Mono.LLVM.Tools.Debug.builds new file mode 100644 index 00000000000000..eaae7d884d1c9f --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Tools/Microsoft.NETCore.Runtime.Mono.LLVM.Tools.Debug.builds @@ -0,0 +1,4 @@ + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Tools/Microsoft.NETCore.Runtime.Mono.LLVM.Tools.Debug.pkgproj b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Tools/Microsoft.NETCore.Runtime.Mono.LLVM.Tools.Debug.pkgproj new file mode 100644 index 00000000000000..10df842e48c1ed --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Tools/Microsoft.NETCore.Runtime.Mono.LLVM.Tools.Debug.pkgproj @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Tools/Microsoft.NETCore.Runtime.Mono.LLVM.Tools.builds b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Tools/Microsoft.NETCore.Runtime.Mono.LLVM.Tools.builds new file mode 100644 index 00000000000000..eaae7d884d1c9f --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Tools/Microsoft.NETCore.Runtime.Mono.LLVM.Tools.builds @@ -0,0 +1,4 @@ + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Tools/Microsoft.NETCore.Runtime.Mono.LLVM.Tools.pkgproj b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Tools/Microsoft.NETCore.Runtime.Mono.LLVM.Tools.pkgproj new file mode 100644 index 00000000000000..a574caec29e4f6 --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Tools/Microsoft.NETCore.Runtime.Mono.LLVM.Tools.pkgproj @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Tools/runtime.Linux.Microsoft.NETCore.Runtime.Mono.LLVM.Tools.props b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Tools/runtime.Linux.Microsoft.NETCore.Runtime.Mono.LLVM.Tools.props new file mode 100644 index 00000000000000..618c55664f811d --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Tools/runtime.Linux.Microsoft.NETCore.Runtime.Mono.LLVM.Tools.props @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Tools/runtime.OSX.Microsoft.NETCore.Runtime.Mono.LLVM.Tools.props b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Tools/runtime.OSX.Microsoft.NETCore.Runtime.Mono.LLVM.Tools.props new file mode 100644 index 00000000000000..c2c6b0392785ef --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Tools/runtime.OSX.Microsoft.NETCore.Runtime.Mono.LLVM.Tools.props @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Tools/runtime.Windows_NT.Microsoft.NETCore.Runtime.Mono.LLVM.Tools.props b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Tools/runtime.Windows_NT.Microsoft.NETCore.Runtime.Mono.LLVM.Tools.props new file mode 100644 index 00000000000000..cf9091a3ed976d --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Tools/runtime.Windows_NT.Microsoft.NETCore.Runtime.Mono.LLVM.Tools.props @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport/Directory.Build.props b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport/Directory.Build.props new file mode 100644 index 00000000000000..f4a1490ea1da54 --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport/Directory.Build.props @@ -0,0 +1,4 @@ + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport/Linux.Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport.props b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport/Linux.Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport.props new file mode 100644 index 00000000000000..3976908e3e5c60 --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport/Linux.Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport.props @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport.builds b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport.builds new file mode 100644 index 00000000000000..eaae7d884d1c9f --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport.builds @@ -0,0 +1,4 @@ + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport.pkgproj b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport.pkgproj new file mode 100644 index 00000000000000..be55eebf48af8c --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport.pkgproj @@ -0,0 +1,14 @@ + + + + + false + + + + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport/OSX.Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport.props b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport/OSX.Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport.props new file mode 100644 index 00000000000000..e8146eb1811963 --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport/OSX.Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport.props @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport/Windows_NT.Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport.props b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport/Windows_NT.Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport.props new file mode 100644 index 00000000000000..0879ed76c94b16 --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport/Windows_NT.Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport.props @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport/Directory.Build.props b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport/Directory.Build.props new file mode 100644 index 00000000000000..f4a1490ea1da54 --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport/Directory.Build.props @@ -0,0 +1,4 @@ + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport/Linux.Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport.props b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport/Linux.Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport.props new file mode 100644 index 00000000000000..984176ab475323 --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport/Linux.Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport.props @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport.builds b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport.builds new file mode 100644 index 00000000000000..eaae7d884d1c9f --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport.builds @@ -0,0 +1,4 @@ + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport.pkgproj b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport.pkgproj new file mode 100644 index 00000000000000..be55eebf48af8c --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport.pkgproj @@ -0,0 +1,14 @@ + + + + + false + + + + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport/OSX.Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport.props b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport/OSX.Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport.props new file mode 100644 index 00000000000000..6756b85d79d79b --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport/OSX.Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport.props @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport/Windows_NT.Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport.props b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport/Windows_NT.Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport.props new file mode 100644 index 00000000000000..759913ef6ef165 --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport/Windows_NT.Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport.props @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.ObjWriter/Directory.Build.props b/nuget/Microsoft.NETCore.Runtime.ObjWriter/Directory.Build.props new file mode 100644 index 00000000000000..f4a1490ea1da54 --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.ObjWriter/Directory.Build.props @@ -0,0 +1,4 @@ + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.ObjWriter/Microsoft.NETCore.Runtime.ObjWriter.builds b/nuget/Microsoft.NETCore.Runtime.ObjWriter/Microsoft.NETCore.Runtime.ObjWriter.builds new file mode 100644 index 00000000000000..eaae7d884d1c9f --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.ObjWriter/Microsoft.NETCore.Runtime.ObjWriter.builds @@ -0,0 +1,4 @@ + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.ObjWriter/Microsoft.NETCore.Runtime.ObjWriter.pkgproj b/nuget/Microsoft.NETCore.Runtime.ObjWriter/Microsoft.NETCore.Runtime.ObjWriter.pkgproj new file mode 100644 index 00000000000000..a574caec29e4f6 --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.ObjWriter/Microsoft.NETCore.Runtime.ObjWriter.pkgproj @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.ObjWriter/runtime.Linux.Microsoft.NETCore.Runtime.ObjWriter.props b/nuget/Microsoft.NETCore.Runtime.ObjWriter/runtime.Linux.Microsoft.NETCore.Runtime.ObjWriter.props new file mode 100644 index 00000000000000..b960ffb4eecb2a --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.ObjWriter/runtime.Linux.Microsoft.NETCore.Runtime.ObjWriter.props @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.ObjWriter/runtime.OSX.Microsoft.NETCore.Runtime.ObjWriter.props b/nuget/Microsoft.NETCore.Runtime.ObjWriter/runtime.OSX.Microsoft.NETCore.Runtime.ObjWriter.props new file mode 100644 index 00000000000000..5ae09a3211786c --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.ObjWriter/runtime.OSX.Microsoft.NETCore.Runtime.ObjWriter.props @@ -0,0 +1,6 @@ + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.ObjWriter/runtime.Windows_NT.Microsoft.NETCore.Runtime.ObjWriter.props b/nuget/Microsoft.NETCore.Runtime.ObjWriter/runtime.Windows_NT.Microsoft.NETCore.Runtime.ObjWriter.props new file mode 100644 index 00000000000000..f2e842f9163fbf --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.ObjWriter/runtime.Windows_NT.Microsoft.NETCore.Runtime.ObjWriter.props @@ -0,0 +1,6 @@ + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Wasm.LLVM.Transport/Directory.Build.props b/nuget/Microsoft.NETCore.Runtime.Wasm.LLVM.Transport/Directory.Build.props new file mode 100644 index 00000000000000..f4a1490ea1da54 --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Wasm.LLVM.Transport/Directory.Build.props @@ -0,0 +1,4 @@ + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Wasm.LLVM.Transport/Linux.Microsoft.NETCore.Runtime.Wasm.LLVM.Transport.props b/nuget/Microsoft.NETCore.Runtime.Wasm.LLVM.Transport/Linux.Microsoft.NETCore.Runtime.Wasm.LLVM.Transport.props new file mode 100644 index 00000000000000..ad96fab1a7fa20 --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Wasm.LLVM.Transport/Linux.Microsoft.NETCore.Runtime.Wasm.LLVM.Transport.props @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Wasm.LLVM.Transport/Microsoft.NETCore.Runtime.Wasm.LLVM.Transport.builds b/nuget/Microsoft.NETCore.Runtime.Wasm.LLVM.Transport/Microsoft.NETCore.Runtime.Wasm.LLVM.Transport.builds new file mode 100644 index 00000000000000..eaae7d884d1c9f --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Wasm.LLVM.Transport/Microsoft.NETCore.Runtime.Wasm.LLVM.Transport.builds @@ -0,0 +1,4 @@ + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Wasm.LLVM.Transport/Microsoft.NETCore.Runtime.Wasm.LLVM.Transport.pkgproj b/nuget/Microsoft.NETCore.Runtime.Wasm.LLVM.Transport/Microsoft.NETCore.Runtime.Wasm.LLVM.Transport.pkgproj new file mode 100644 index 00000000000000..be55eebf48af8c --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Wasm.LLVM.Transport/Microsoft.NETCore.Runtime.Wasm.LLVM.Transport.pkgproj @@ -0,0 +1,14 @@ + + + + + false + + + + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Wasm.LLVM.Transport/OSX.Microsoft.NETCore.Runtime.Wasm.LLVM.Transport.props b/nuget/Microsoft.NETCore.Runtime.Wasm.LLVM.Transport/OSX.Microsoft.NETCore.Runtime.Wasm.LLVM.Transport.props new file mode 100644 index 00000000000000..c52357c74e2c02 --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Wasm.LLVM.Transport/OSX.Microsoft.NETCore.Runtime.Wasm.LLVM.Transport.props @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nuget/Microsoft.NETCore.Runtime.Wasm.LLVM.Transport/Windows_NT.Microsoft.NETCore.Runtime.Wasm.LLVM.Transport.props b/nuget/Microsoft.NETCore.Runtime.Wasm.LLVM.Transport/Windows_NT.Microsoft.NETCore.Runtime.Wasm.LLVM.Transport.props new file mode 100644 index 00000000000000..36e0efb5b87e0c --- /dev/null +++ b/nuget/Microsoft.NETCore.Runtime.Wasm.LLVM.Transport/Windows_NT.Microsoft.NETCore.Runtime.Wasm.LLVM.Transport.props @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nuget/builds.targets b/nuget/builds.targets new file mode 100644 index 00000000000000..d58f010d3939b8 --- /dev/null +++ b/nuget/builds.targets @@ -0,0 +1,31 @@ + + + + true + + + true + + + false + + + + + + + + <_projectsToBuild Include="@(Project)" Condition="'%(Project.PackageTargetRuntime)' == '$(PackageRID)'" /> + + + + <_projectsToBuild Include="@(Project)" Condition="'%(Project.PackageTargetRuntime)' == ''" /> + + + + + + + \ No newline at end of file diff --git a/nuget/descriptions.json b/nuget/descriptions.json new file mode 100644 index 00000000000000..ce29eef3020b17 --- /dev/null +++ b/nuget/descriptions.json @@ -0,0 +1,57 @@ +[ + { + "Name": "RuntimePackage", + "Description": "Internal implementation package not meant for direct consumption. Please do not reference directly.", + "CommonTypes": [ ] + }, + { + "Name": "NuGet3MinVersion", + "Description": "When using NuGet 3.x this package requires at least version {0}.", + "CommonTypes": [ ] + }, + { + "Name": "Microsoft.NETCore.Runtime.Mono.LLVM.Sdk", + "Description": "The .NET Core fork of the LLVM project, used to compile the Mono .NET Core runtime in LLVM JIT mode. Internal implementation package not meant for direct consumption. Please do not reference directly.", + "CommonTypes": [ ] + }, + { + "Name": "Microsoft.NETCore.Runtime.Mono.LLVM.Sdk.Debug", + "Description": "The .NET Core fork of the LLVM project, used to compile the Mono .NET Core runtime in LLVM JIT mode (Debug runtime). Internal implementation package not meant for direct consumption. Please do not reference directly.", + "CommonTypes": [ ] + }, + { + "Name": "Microsoft.NETCore.Runtime.Mono.LLVM.Tools", + "Description": "The llvm-as, llc and opt tools, used by the Mono .NET Core runtime in LLVM AOT mode.", + "CommonTypes": [ ] + }, + { + "Name": "Microsoft.NETCore.Runtime.Mono.LLVM.Tools.Debug", + "Description": "The llvm-as, llc and opt tools, used by the Mono .NET Core runtime in LLVM AOT mode (Debug runtime).", + "CommonTypes": [ ] + }, + { + "Name": "Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.A.Transport", + "Description": "Clang compiler and tools, used by the Mono .NET Core runtime to target WASI (Part 1).", + "CommonTypes": [ ] + }, + { + "Name": "Microsoft.NETCore.Runtime.Mono.LLVM.Wasm.B.Transport", + "Description": "Clang compiler and tools, used by the Mono .NET Core runtime to target WASI (Part 2).", + "CommonTypes": [ ] + }, + { + "Name": "Microsoft.NETCore.Runtime.ObjWriter", + "Description": "ELF/PE/Mach-O object file writer based on LLVM used in .NET AOT compiler. Internal implementation package not meant for direct consumption. Please do not reference directly.", + "CommonTypes": [ ] + }, + { + "Name": "Microsoft.NETCore.Runtime.JIT.Tools", + "Description": "Tools such as FileCheck and llvm-mca used for testing the .NET JIT compiler. Internal implementation package not meant for direct consumption. Please do not reference directly.", + "CommonTypes": [ ] + }, + { + "Name": "Microsoft.NETCore.Runtime.Wasm.LLVM.Transport", + "Description": "Clang compiler and tools, used by the Mono .NET Core runtime to target WebAssembly.", + "CommonTypes": [ ] + }, +] diff --git a/nuget/packageIndex.json b/nuget/packageIndex.json new file mode 100644 index 00000000000000..7a73a41bfdf76d --- /dev/null +++ b/nuget/packageIndex.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/nuget/packages.builds b/nuget/packages.builds new file mode 100644 index 00000000000000..8bd384023bd7bc --- /dev/null +++ b/nuget/packages.builds @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nuget/packaging.props b/nuget/packaging.props new file mode 100644 index 00000000000000..34248365261674 --- /dev/null +++ b/nuget/packaging.props @@ -0,0 +1,39 @@ + + + + + $(MSBuildThisFileDirectory)/descriptions.json + $(RepoRoot)/llvm/LICENSE.TXT + $(RepoRoot)/THIRD-PARTY-NOTICES.TXT + + https://go.microsoft.com/fwlink/?LinkID=799421 + + https://dot.net + https://github.com/dotnet/llvm-project/blob/dotnet/main/llvm/LICENSE.TXT + + $(MSBuildThisFileDirectory)/packageIndex.json + + + true + + + + + + + true + + + true + + + + + + true + + + diff --git a/polly/lib/External/isl/imath/tests/linux/Dockerfile b/polly/lib/External/isl/imath/tests/linux/Dockerfile deleted file mode 100644 index 50e1a91e8f530b..00000000000000 --- a/polly/lib/External/isl/imath/tests/linux/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -# Build IMath and run tests with GCC on Linux. -# -# Usage (from the imath root): -# -# docker run --rm -it "$(docker build -f tests/linux/Dockerfile -q .)" -# -FROM alpine:latest AS base - -RUN apk add --no-cache bash build-base gcc gmp-dev make python2 - -FROM base AS test -COPY . /imath -WORKDIR /imath -CMD make distclean examples check diff --git a/utils/bazel/.bazelignore b/utils/bazel/.bazelignore deleted file mode 100644 index 1463bcc9c490e4..00000000000000 --- a/utils/bazel/.bazelignore +++ /dev/null @@ -1,2 +0,0 @@ -llvm-project-overlay -examples diff --git a/utils/bazel/.bazelrc b/utils/bazel/.bazelrc deleted file mode 100644 index c06e9b3416263f..00000000000000 --- a/utils/bazel/.bazelrc +++ /dev/null @@ -1,198 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -############################################################################### -# Common flags that apply to all configurations. -# Use sparingly for things common to all compilers and platforms. -############################################################################### -# Prevent invalid caching if input files are modified during a build. -build --experimental_guard_against_concurrent_changes - -# In opt mode, bazel by default builds both PIC and non-PIC object files for -# tests vs binaries. We don't need this feature and it slows down opt builds -# considerably. -build --force_pic - -# Shared objects take up more space. With fast linkers and binaries that aren't -# super large, the benefits of shared objects are minimal. -build --dynamic_mode=off - -# Rely on compiler flags to compile with debug info/strip rather than stripping -# based on compilation_mode. -build --strip=never - -# Add layering check to all projects. -build --features=layering_check - -# Opt out of legacy lax behavior implicitly exporting files that are rule inputs -# with default visibility. -# See: https://bazel.build/reference/be/functions#exports_files -build --incompatible_no_implicit_file_export - -############################################################################### -# Options to select different strategies for linking potential dependent -# libraries. The default leaves it disabled. -############################################################################### - -build:zlib_external --repo_env=BAZEL_LLVM_ZLIB_STRATEGY=external -build:zlib_system --repo_env=BAZEL_LLVM_ZLIB_STRATEGY=system - -build:terminfo_external --repo_env=BAZEL_LLVM_TERMINFO_STRATEGY=external -build:terminfo_system --repo_env=BAZEL_LLVM_TERMINFO_STRATEGY=system - -############################################################################### -# Options for "generic_clang" builds: these options should generally apply to -# builds using a Clang-based compiler, and default to the `clang` executable on -# the `PATH`. While these are provided for convenience and may serve as a -# reference, it would be preferable for users to configure an explicit C++ -# toolchain instead of relying on `.bazelrc` files. -############################################################################### - -# Set the default compiler to the `clang` binary on the `PATH`. -build:generic_clang --repo_env=CC=clang - -# C++17 standard version is required. -build:generic_clang --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 - -# Use `-Wall` for Clang. -build:generic_clang --copt=-Wall --host_copt=-Wall - -# The Clang available on MacOS has a warning that isn't clean on MLIR code. The -# warning doesn't show up with more recent Clangs, so just disable for now. -build:generic_clang --cxxopt=-Wno-range-loop-analysis --host_cxxopt=-Wno-range-loop-analysis - -# Build errors are not a helpful way to enforce deprecation in-repo and it is -# not the point of the Bazel build to catch usage of deprecated APIs. -build:generic_clang --copt=-Wno-deprecated --host_copt=-Wno-deprecated - -# lld links faster than other linkers. Assume that anybody using clang also has -# lld available. -build:generic_clang --linkopt=-fuse-ld=lld --host_linkopt=-fuse-ld=lld - -############################################################################### -# Options for "generic_gcc" builds: these options should generally apply to -# builds using a GCC-based compiler, and default to the `gcc` executable on -# the `PATH`. While these are provided for convenience and may serve as a -# reference, it would be preferable for users to configure an explicit C++ -# toolchain instead of relying on `.bazelrc` files. -############################################################################### - -# Set the default compiler to the `gcc` binary on the `PATH`. -build:generic_gcc --repo_env=CC=gcc - -# C++17 standard version is required. -build:generic_gcc --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 - -# Build errors are not a helpful way to enforce deprecation in-repo and it is -# not the point of the Bazel build to catch usage of deprecated APIs. -build:generic_gcc --copt=-Wno-deprecated --host_copt=-Wno-deprecated - -# Disable GCC warnings that are noisy and/or false positives on LLVM code. -# These need to be global as some code triggering these is in header files. -build:generic_gcc --copt=-Wno-unused-parameter --host_copt=-Wno-unused-parameter -build:generic_gcc --copt=-Wno-comment --host_copt=-Wno-comment -build:generic_gcc --cxxopt=-Wno-class-memaccess --host_cxxopt=-Wno-class-memaccess -build:generic_gcc --copt=-Wno-maybe-uninitialized --host_copt=-Wno-maybe-uninitialized -build:generic_gcc --copt=-Wno-misleading-indentation --host_copt=-Wno-misleading-indentation - -############################################################################### -# Generic Windows flags common to both MSVC and Clang. -############################################################################### - -# C++17 standard version is required. -build:windows --cxxopt=/std:c++17 --host_cxxopt=/std:c++17 - -# Other generic dialect flags. -build:windows --copt=/Zc:strictStrings --host_copt=/Zc:strictStrings -build:windows --copt=/Oi --host_copt=/Oi -build:windows --cxxopt=/Zc:rvalueCast --host_cxxopt=/Zc:rvalueCast - -# Use the more flexible bigobj format for C++ files that have lots of symbols. -build:windows --cxxopt=/bigobj --host_cxxopt=/bigobj - -############################################################################### -# Windows specific flags for building with MSVC. -############################################################################### - -build:msvc --config=windows - -build:msvc --copt=/WX --host_copt=/WX # Treat warnings as errors... -# ...but disable the ones that are violated -build:msvc --copt=/wd4141 --host_copt=/wd4141 # inline used more than once -build:msvc --copt=/wd4244 --host_copt=/wd4244 # conversion type -> type -build:msvc --copt=/wd4267 --host_copt=/wd4267 # conversion size_t -> type -build:msvc --copt=/wd4273 --host_copt=/wd4273 # multiple definitions with different dllimport -build:msvc --copt=/wd4319 --host_copt=/wd4319 # zero-extending after complement -build:msvc --copt=/wd4624 --host_copt=/wd4624 # destructor was implicitly defined as deleted -build:msvc --copt=/wd4804 --host_copt=/wd4804 # comparisons between bool and int -build:msvc --copt=/wd4805 --host_copt=/wd4805 # comparisons between bool and int - -build:msvc --linkopt=/WX --host_linkopt=/WX # Treat warnings as errors... -# ...but disable the ones that are violated. -build:msvc --linkopt=/IGNORE:4001 --host_linkopt=/IGNORE:4001 # no object files - -############################################################################### -# Options for Windows `clang-cl` builds. -############################################################################### - -# We just start with the baseline Windows config as `clang-cl` doesn't accept -# some of the generic Clang flags. -build:clang-cl --config=windows - -# Switch from MSVC to the `clang-cl` compiler. -build:clang-cl --compiler=clang-cl - -# Use Clang's internal warning flags instead of the ones that sometimes map -# through to MSVC's flags. -build:clang-cl --copt=/clang:-Wall --host_copt=/clang:-Wall -build:clang-cl --copt=/clang:-Werror --host_copt=/clang:-Werror - -# This doesn't appear to be enforced by any upstream bot. -build:clang-cl --copt=/clang:-Wno-unused --host_copt=/clang:-Wno-unused - -# There appears to be an unused constant in GoogleTest on Windows. -build:clang-cl --copt=/clang:-Wno-unused-const-variable --host_copt=/clang:-Wno-unused-const-variable - -# Disable some warnings hit even with `clang-cl` in Clang's own code. -build:clang-cl --copt=/clang:-Wno-inconsistent-dllimport --host_copt=/clang:-Wno-inconsistent-dllimport -build:clang-cl --cxxopt=/clang:-Wno-c++11-narrowing --host_cxxopt=/clang:-Wno-c++11-narrowing - -############################################################################### -# Options for continuous integration. -############################################################################### - -# -O1 tries to provide a reasonable tradeoff between compile times and runtime -# performance. However, if we start running more tests (e.g. all of -# check-clang) we may want more optimizations. -# Note for anybody considering using --compilation_mode=opt in CI, it builds -# most files twice, one PIC version for shared libraries in tests, and one -# non-PIC version for binaries. -build:ci --copt=-O1 - -# Use clang. -build:ci --config=generic_clang - -# Speedup bazel using a ramdisk. -build:ci --sandbox_base=/dev/shm - -# Use system's mpfr and pfm instead of building it from source. -# This is non hermetic but helps with compile time. -build:ci --@llvm-project//libc:mpfr=system -build:ci --@llvm-project//llvm:pfm=system - -# Don't build/test targets tagged with "nobuildkite". -build:ci --build_tag_filters=-nobuildkite -build:ci --test_tag_filters=-nobuildkite - -# Show as many errors as possible. -build:ci --keep_going - -# Show test errors. -build:ci --test_output=errors - -############################################################################### - -# The user.bazelrc file is not checked in but available for local mods. -# Always keep this at the end of the file so that user flags override. -try-import %workspace%/user.bazelrc diff --git a/utils/bazel/.bazelversion b/utils/bazel/.bazelversion deleted file mode 100644 index 5e3254243a3b27..00000000000000 --- a/utils/bazel/.bazelversion +++ /dev/null @@ -1 +0,0 @@ -6.1.2 diff --git a/utils/bazel/.gitignore b/utils/bazel/.gitignore deleted file mode 100644 index 6bb9fd1ef0a2a4..00000000000000 --- a/utils/bazel/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -# Bazel artifacts -**/bazel-* - -# Per-user bazelrc files -user.bazelrc diff --git a/utils/bazel/BUILD.bazel b/utils/bazel/BUILD.bazel deleted file mode 100644 index dd837093c62ac1..00000000000000 --- a/utils/bazel/BUILD.bazel +++ /dev/null @@ -1,5 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# Required to reference .bzl files in this package diff --git a/utils/bazel/README.md b/utils/bazel/README.md deleted file mode 100644 index ba74947b6d4766..00000000000000 --- a/utils/bazel/README.md +++ /dev/null @@ -1,111 +0,0 @@ -# Introduction - -*Warning* The Bazel build is experimental and best-effort, supported in line -with the policy for -[LLVM's peripheral support tier](https://llvm.org/docs/SupportPolicy.html). -LLVM's official build system is CMake. If in doubt use that. If you make changes -to LLVM, you're expected to update the CMake build but you don't need to update -Bazel build files. Reviewers should not ask authors to update Bazel build files -unless the author has opted in to support Bazel. Keeping the Bazel build files -up-to-date is on the people who use the Bazel build. - -[Bazel](https://bazel.build/) is a multi-language build system focused on -reproducible builds to enable dependency analysis and caching for fast -incremental builds. - -The main motivation behind the existence of an LLVM Bazel build is that a number -of projects that depend on LLVM use Bazel, and Bazel works best when it knows -about the whole source tree (as opposed to installing artifacts coming from -another build system). Community members are also welcome to use Bazel for their -own development as long as they continue to maintain the official CMake build -system. See also, the -[proposal](https://github.com/llvm/llvm-www/blob/main/proposals/LP0002-BazelBuildConfiguration.md) -for adding this configuration. - -# Quick Start - -1. `git clone https://github.com/llvm/llvm-project.git; cd llvm-project` if - you don't have a checkout yet. -2. Install Bazel at the version indicated by [.bazelversion](./.bazelversion), - following the official instructions, if you don't have it installed yet: - https://docs.bazel.build/versions/main/install.html. - * You can also install and use - [bazelisk](https://github.com/bazelbuild/bazelisk) which automates - downloading the proper bazel version -3. `cd utils/bazel` -4. `bazel build --config=generic_clang @llvm-project//...` - * If you're using clang, it's expected that lld is also available - * If you're using MSVC or gcc, instead of `--config=generic_clang`, pass - `--config=generic_gcc` or `--config=msvc` - * To specify a specific local compiler to use, add the following bazel - flag: `--repo_env=CC=/usr/bin/clang` - * `--config=generic_clang`/`--config=generic_gcc` by default set - `--repo_env=CC=clang`/`--repo_env=CC=gcc`, using `clang`/`gcc` on the - `PATH` - -# Configuration - -The repository `.bazelrc` will import user-specific settings from a -`user.bazelrc` file (in addition to the standard locations). Adding your typical -config setting is recommended. - -```.bazelrc -build --config=generic_clang -``` - -You can enable -[disk caching](https://docs.bazel.build/versions/main/remote-caching.html#disk-cache), -which will cache build results - -```.bazelrc -build --disk_cache=~/.cache/bazel-disk-cache -``` - -You can instruct Bazel to use a ramdisk for its sandboxing operations via -[--sandbox_base](https://docs.bazel.build/versions/main/command-line-reference.html#flag--sandbox_base), -which can help avoid IO bottlenecks for the symlink strategy used for -sandboxing. This is especially important with many inputs and many cores (see -https://github.com/bazelbuild/bazel/issues/11868): - -```.bazelrc -build --sandbox_base=/dev/shm -``` - -Bear in mind that this requires that your ramdisk is of sufficient size to hold -any temporary files. Anecdotally, 1GB should be sufficient. - -# Coverage - -The LLVM, MLIR, and Clang subprojects have configurations for Linux (Clang and -GCC), Mac (Clang and GCC), and Windows (MSVC). Configuration options that are -platform-specific are selected for in defines. Many are also hardcoded to the -values currently used by all supported configurations. If there is a -configuration you'd like to use that isn't supported, please send a patch. - -# Continuous Testing - -A [Buildkite pipeline](https://buildkite.com/llvm-project/upstream-bazel) -runs the full Bazel build on every commit to the main branch. Notifications of -failures are sent to the -[llvm-bazel-alerts google group](https://groups.google.com/g/llvm-bazel-alerts), -which anyone is free to join. Currently, the behavior is just to send an email -on each failure using Buildkite's built-in notification system, so if you -subscribe, it is highly recommended that you set up email filters or some other -mechanism to not flood your inbox. More sophisticated notifications, e.g. only -on status change or routed based on blamelist are TODO (contributions welcome). - -# Pre-merge Testing - -A Buildkite pipeline runs the full Bazel build as a pre-merge test using the -[LLVM pre-merge testing](https://github.com/google/llvm-premerge-checks/). It -is triggered on all changes to the utils/bazel directory and when the patch -author is a member of the -[Bazel Phabricator project](https://reviews.llvm.org/project/members/107/). If -you use or benefit from the Bazel build, please join the project so that you -can help keep it green. As a bonus, it runs in under 5 minutes, much faster -than any of the other pre-merge builds. - -# Usage in Downstream Projects - -To use in dependent projects using Bazel, you can import LLVM and then use the -provided configuration rule. See example usage in the `examples/` directory. diff --git a/utils/bazel/WORKSPACE b/utils/bazel/WORKSPACE deleted file mode 100644 index f4ae2c7ce4562e..00000000000000 --- a/utils/bazel/WORKSPACE +++ /dev/null @@ -1,118 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository", "new_git_repository") -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") - -SKYLIB_VERSION = "1.3.0" - -http_archive( - name = "bazel_skylib", - sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/{version}/bazel-skylib-{version}.tar.gz".format(version = SKYLIB_VERSION), - "https://github.com/bazelbuild/bazel-skylib/releases/download/{version}/bazel-skylib-{version}.tar.gz".format(version = SKYLIB_VERSION), - ], -) - -new_local_repository( - name = "llvm-raw", - build_file_content = "# empty", - path = "../../", -) - -load("@llvm-raw//utils/bazel:configure.bzl", "llvm_configure") - -llvm_configure(name = "llvm-project") - -maybe( - http_archive, - name = "llvm_zlib", - build_file = "@llvm-raw//utils/bazel/third_party_build:zlib-ng.BUILD", - sha256 = "e36bb346c00472a1f9ff2a0a4643e590a254be6379da7cddd9daeb9a7f296731", - strip_prefix = "zlib-ng-2.0.7", - urls = [ - "https://github.com/zlib-ng/zlib-ng/archive/refs/tags/2.0.7.zip", - ], -) - -maybe( - http_archive, - name = "vulkan_headers", - build_file = "@llvm-raw//utils/bazel/third_party_build:vulkan_headers.BUILD", - sha256 = "19f491784ef0bc73caff877d11c96a48b946b5a1c805079d9006e3fbaa5c1895", - strip_prefix = "Vulkan-Headers-9bd3f561bcee3f01d22912de10bb07ce4e23d378", - urls = [ - "https://github.com/KhronosGroup/Vulkan-Headers/archive/9bd3f561bcee3f01d22912de10bb07ce4e23d378.tar.gz", - ], -) - -load("@llvm-raw//utils/bazel:vulkan_sdk.bzl", "vulkan_sdk_setup") - -maybe( - vulkan_sdk_setup, - name = "vulkan_sdk", -) - -# llvm libc math tests reply on `mpfr`. -# The availability of `mpfr` is controlled by a flag and can be either `disable`, `system` or `external`. -# Continuous integration uses `system` to speed up the build process (see .bazelrc). -# Otherwise by default it is set to `external`: `mpfr` and `gmp` are built from source by using `rules_foreign_cc`. -# Note: that building from source requires `m4` to be installed on the host machine. -# This is a known issue: https://github.com/bazelbuild/rules_foreign_cc/issues/755. - -git_repository( - name = "rules_foreign_cc", - remote = "https://github.com/bazelbuild/rules_foreign_cc.git", - tag = "0.9.0", -) - -load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies") - -rules_foreign_cc_dependencies() - -maybe( - http_archive, - name = "gmp", - build_file = "@llvm-raw//utils/bazel/third_party_build:gmp.BUILD", - sha256 = "fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2", - strip_prefix = "gmp-6.2.1", - urls = [ - "https://gmplib.org/download/gmp/gmp-6.2.1.tar.xz", - "https://ftp.gnu.org/gnu/gmp/gmp-6.2.1.tar.xz", - ], -) - -# https://www.mpfr.org/mpfr-current/ -# -# When updating to a newer version, don't use URLs with "mpfr-current" in them. -# Instead, find a stable URL like the one used currently. -maybe( - http_archive, - name = "mpfr", - build_file = "@llvm-raw//utils/bazel/third_party_build:mpfr.BUILD", - sha256 = "9cbed5d0af0d9ed5e9f8dd013e17838eb15e1db9a6ae0d371d55d35f93a782a7", - strip_prefix = "mpfr-4.1.1", - urls = ["https://www.mpfr.org/mpfr-4.1.1/mpfr-4.1.1.tar.gz"], -) - -maybe( - new_git_repository, - name = "pfm", - build_file = "@llvm-raw//utils/bazel/third_party_build:pfm.BUILD", - remote = "https://git.code.sf.net/p/perfmon2/libpfm4", - tag = "v4.12.1", -) - -maybe( - http_archive, - name = "llvm_zstd", - build_file = "@llvm-raw//utils/bazel/third_party_build:zstd.BUILD", - sha256 = "7c42d56fac126929a6a85dbc73ff1db2411d04f104fae9bdea51305663a83fd0", - strip_prefix = "zstd-1.5.2", - urls = [ - "https://github.com/facebook/zstd/releases/download/v1.5.2/zstd-1.5.2.tar.gz", - ], -) diff --git a/utils/bazel/configure.bzl b/utils/bazel/configure.bzl deleted file mode 100644 index d6cd6aa0813e4d..00000000000000 --- a/utils/bazel/configure.bzl +++ /dev/null @@ -1,182 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -"""Helper macros to configure the LLVM overlay project.""" - -load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") - -# Directory of overlay files relative to WORKSPACE -DEFAULT_OVERLAY_PATH = "llvm-project-overlay" - -DEFAULT_TARGETS = [ - "AArch64", - "AMDGPU", - "ARM", - "AVR", - "BPF", - "Hexagon", - "Lanai", - "LoongArch", - "Mips", - "MSP430", - "NVPTX", - "PowerPC", - "RISCV", - "Sparc", - "SystemZ", - "VE", - "WebAssembly", - "X86", - "XCore", -] - -def _overlay_directories(repository_ctx): - src_path = repository_ctx.path(Label("@llvm-raw//:WORKSPACE")).dirname - bazel_path = src_path.get_child("utils").get_child("bazel") - overlay_path = bazel_path.get_child("llvm-project-overlay") - script_path = bazel_path.get_child("overlay_directories.py") - - python_bin = repository_ctx.which("python3") - if not python_bin: - # Windows typically just defines "python" as python3. The script itself - # contains a check to ensure python3. - python_bin = repository_ctx.which("python") - - if not python_bin: - fail("Failed to find python3 binary") - - cmd = [ - python_bin, - script_path, - "--src", - src_path, - "--overlay", - overlay_path, - "--target", - ".", - ] - exec_result = repository_ctx.execute(cmd, timeout = 20) - - if exec_result.return_code != 0: - fail(("Failed to execute overlay script: '{cmd}'\n" + - "Exited with code {return_code}\n" + - "stdout:\n{stdout}\n" + - "stderr:\n{stderr}\n").format( - cmd = " ".join([str(arg) for arg in cmd]), - return_code = exec_result.return_code, - stdout = exec_result.stdout, - stderr = exec_result.stderr, - )) - -def _extract_cmake_settings(repository_ctx, llvm_cmake): - # The list to be written to vars.bzl - # `CMAKE_CXX_STANDARD` may be used from WORKSPACE for the toolchain. - c = { - "CMAKE_CXX_STANDARD": None, - "LLVM_VERSION_MAJOR": None, - "LLVM_VERSION_MINOR": None, - "LLVM_VERSION_PATCH": None, - } - - # It would be easier to use external commands like sed(1) and python. - # For portability, the parser should run on Starlark. - llvm_cmake_path = repository_ctx.path(Label("//:" + llvm_cmake)) - for line in repository_ctx.read(llvm_cmake_path).splitlines(): - # Extract "set ( FOO bar ... " - setfoo = line.partition("(") - if setfoo[1] != "(": - continue - if setfoo[0].strip().lower() != "set": - continue - - # `kv` is assumed as \s*KEY\s+VAL\s*\).* - # Typical case is like - # LLVM_REQUIRED_CXX_STANDARD 17) - # Possible case -- It should be ignored. - # CMAKE_CXX_STANDARD ${...} CACHE STRING "...") - kv = setfoo[2].strip() - i = kv.find(" ") - if i < 0: - continue - k = kv[:i] - - # Prefer LLVM_REQUIRED_CXX_STANDARD instead of CMAKE_CXX_STANDARD - if k == "LLVM_REQUIRED_CXX_STANDARD": - k = "CMAKE_CXX_STANDARD" - c[k] = None - if k not in c: - continue - - # Skip if `CMAKE_CXX_STANDARD` is set with - # `LLVM_REQUIRED_CXX_STANDARD`. - # Then `v` will not be desired form, like "${...} CACHE" - if c[k] != None: - continue - - # Pick up 1st word as the value. - # Note: It assumes unquoted word. - v = kv[i:].strip().partition(")")[0].partition(" ")[0] - c[k] = v - - # Synthesize `LLVM_VERSION` for convenience. - c["LLVM_VERSION"] = "{}.{}.{}".format( - c["LLVM_VERSION_MAJOR"], - c["LLVM_VERSION_MINOR"], - c["LLVM_VERSION_PATCH"], - ) - - return c - -def _write_dict_to_file(repository_ctx, filepath, header, vars): - # (fci + individual vars) + (fcd + dict items) + (fct) - fci = header - fcd = "\nllvm_vars={\n" - fct = "}\n" - - for k, v in vars.items(): - fci += '{} = "{}"\n'.format(k, v) - fcd += ' "{}": "{}",\n'.format(k, v) - - repository_ctx.file(filepath, content = fci + fcd + fct) - -def _llvm_configure_impl(repository_ctx): - _overlay_directories(repository_ctx) - - llvm_cmake = "llvm/CMakeLists.txt" - vars = _extract_cmake_settings( - repository_ctx, - llvm_cmake, - ) - - # Grab version info and merge it with the other vars - version = _extract_cmake_settings( - repository_ctx, - "cmake/Modules/LLVMVersion.cmake", - ) - version = {k: v for k, v in version.items() if v != None} - vars.update(version) - - _write_dict_to_file( - repository_ctx, - filepath = "vars.bzl", - header = "# Generated from {}\n\n".format(llvm_cmake), - vars = vars, - ) - - # Create a starlark file with the requested LLVM targets. - targets = repository_ctx.attr.targets - repository_ctx.file( - "llvm/targets.bzl", - content = "llvm_targets = " + str(targets), - executable = False, - ) - -llvm_configure = repository_rule( - implementation = _llvm_configure_impl, - local = True, - configure = True, - attrs = { - "targets": attr.string_list(default = DEFAULT_TARGETS), - }, -) diff --git a/utils/bazel/examples/http_archive/WORKSPACE b/utils/bazel/examples/http_archive/WORKSPACE deleted file mode 100644 index efc3a083e059dc..00000000000000 --- a/utils/bazel/examples/http_archive/WORKSPACE +++ /dev/null @@ -1,62 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -"""An example WORKSPACE for configuring LLVM using http_archive.""" - -workspace(name = "http_archive_example") - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -SKYLIB_VERSION = "1.0.3" - -http_archive( - name = "bazel_skylib", - sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/{version}/bazel-skylib-{version}.tar.gz".format(version = SKYLIB_VERSION), - "https://github.com/bazelbuild/bazel-skylib/releases/download/{version}/bazel-skylib-{version}.tar.gz".format(version = SKYLIB_VERSION), - ], -) - -# Replace with the LLVM commit you want to use. -LLVM_COMMIT = "926f85db98aae66ab8f57b9981f47ddddb868c51" - -# The easiest way to calculate this for a new commit is to set it to empty and -# then run a bazel build and it will report the digest necessary to cache the -# archive and make the build reproducible. -LLVM_SHA256 = "c78c94b2a03b2cf6ef1ba035c31a6f1b0bb7913da8af5aa8d5c2061f6499d589" - -http_archive( - name = "llvm-raw", - build_file_content = "# empty", - sha256 = LLVM_SHA256, - strip_prefix = "llvm-project-" + LLVM_COMMIT, - urls = ["https://github.com/llvm/llvm-project/archive/{commit}.tar.gz".format(commit = LLVM_COMMIT)], -) - -load("@llvm-raw//utils/bazel:configure.bzl", "llvm_configure") - -llvm_configure(name = "llvm-project") - -maybe( - http_archive, - name = "llvm_zlib", - build_file = "@llvm-raw//utils/bazel/third_party_build:zlib-ng.BUILD", - sha256 = "e36bb346c00472a1f9ff2a0a4643e590a254be6379da7cddd9daeb9a7f296731", - strip_prefix = "zlib-ng-2.0.7", - urls = [ - "https://github.com/zlib-ng/zlib-ng/archive/refs/tags/2.0.7.zip", - ], -) - -maybe( - http_archive, - name = "llvm_zstd", - build_file = "@llvm-raw//utils/bazel/third_party_build:zstd.BUILD", - sha256 = "7c42d56fac126929a6a85dbc73ff1db2411d04f104fae9bdea51305663a83fd0", - strip_prefix = "zstd-1.5.2", - urls = [ - "https://github.com/facebook/zstd/releases/download/v1.5.2/zstd-1.5.2.tar.gz", - ], -) diff --git a/utils/bazel/examples/submodule/WORKSPACE b/utils/bazel/examples/submodule/WORKSPACE deleted file mode 100644 index e8eff85ffda521..00000000000000 --- a/utils/bazel/examples/submodule/WORKSPACE +++ /dev/null @@ -1,51 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -"""An example WORKSPACE for configuring LLVM using a git submodule.""" - -workspace(name = "submodule_example") - -SKYLIB_VERSION = "1.0.3" - -http_archive( - name = "bazel_skylib", - sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/{version}/bazel-skylib-{version}.tar.gz".format(version = SKYLIB_VERSION), - "https://github.com/bazelbuild/bazel-skylib/releases/download/{version}/bazel-skylib-{version}.tar.gz".format(version = SKYLIB_VERSION), - ], -) - -new_local_repository( - name = "llvm-raw", - build_file_content = "# empty", - # Or wherever your submodule is located. - path = "third_party/llvm-project", -) - -load("@llvm-raw//utils/bazel:configure.bzl", "llvm_configure") - -llvm_configure(name = "llvm-project") - -maybe( - http_archive, - name = "llvm_zlib", - build_file = "@llvm-raw//utils/bazel/third_party_build:zlib-ng.BUILD", - sha256 = "e36bb346c00472a1f9ff2a0a4643e590a254be6379da7cddd9daeb9a7f296731", - strip_prefix = "zlib-ng-2.0.7", - urls = [ - "https://github.com/zlib-ng/zlib-ng/archive/refs/tags/2.0.7.zip", - ], -) - -maybe( - http_archive, - name = "llvm_zstd", - build_file = "@llvm-raw//utils/bazel/third_party_build:zstd.BUILD", - sha256 = "7c42d56fac126929a6a85dbc73ff1db2411d04f104fae9bdea51305663a83fd0", - strip_prefix = "zstd-1.5.2", - urls = [ - "https://github.com/facebook/zstd/releases/download/v1.5.2/zstd-1.5.2.tar.gz", - ], -) diff --git a/utils/bazel/llvm-project-overlay/.bazelignore b/utils/bazel/llvm-project-overlay/.bazelignore deleted file mode 100644 index f3d19a94233d66..00000000000000 --- a/utils/bazel/llvm-project-overlay/.bazelignore +++ /dev/null @@ -1,6 +0,0 @@ -# Ignore the utils/bazel directory when this is overlayed onto the repo root. -utils/bazel -# Ignore third-party projects. These should be configured separately and some -# include Bazel configs. -libcxx/utils/google-benchmark -third-party/benchmark diff --git a/utils/bazel/llvm-project-overlay/bolt/BUILD.bazel b/utils/bazel/llvm-project-overlay/bolt/BUILD.bazel deleted file mode 100644 index 043a3b61a75f03..00000000000000 --- a/utils/bazel/llvm-project-overlay/bolt/BUILD.bazel +++ /dev/null @@ -1,301 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -load("@bazel_skylib//rules:expand_template.bzl", "expand_template") - -package( - default_visibility = ["//visibility:public"], -) - -licenses(["notice"]) - -cc_binary( - name = "llvm-bolt-heatmap", - srcs = glob([ - "tools/heatmap/*.cpp", - ]), - deps = [ - ":Profile", - ":Rewrite", - ":Utils", - "//llvm:AllTargetsAsmParsers", - "//llvm:AllTargetsDisassemblers", - "//llvm:MC", - "//llvm:Object", - "//llvm:Support", - ], -) - -cc_binary( - name = "merge-fdata", - srcs = glob([ - "tools/merge-fdata/*.cpp", - ]), - deps = [ - ":Profile", - "//llvm:Support", - ], -) - -cc_binary( - name = "llvm-bolt", - srcs = glob([ - "tools/driver/*.cpp", - ]), - includes = ["include"], - deps = [ - ":Profile", - ":Rewrite", - ":RuntimeLibs", - ":TargetAArch64", - ":TargetX86", - ":Utils", - "//llvm:AllTargetsAsmParsers", - "//llvm:AllTargetsCodeGens", - "//llvm:AllTargetsDisassemblers", - "//llvm:ExecutionEngine", - "//llvm:MC", - "//llvm:Object", - "//llvm:Support", - ], -) - -cc_library( - name = "Rewrite", - srcs = glob([ - "lib/Rewrite/*.cpp", - ]), - hdrs = glob([ - "include/bolt/Rewrite/*.h", - ]), - includes = ["include"], - deps = [ - ":Core", - ":Passes", - ":Profile", - ":RuntimeLibs", - ":TargetX86", - ":Utils", - "//llvm:Analysis", - "//llvm:BinaryFormat", - "//llvm:CodeGen", - "//llvm:DWARFLinker", - "//llvm:DWP", - "//llvm:DebugInfoDWARF", - "//llvm:Demangle", - "//llvm:JITLink", - "//llvm:MC", - "//llvm:MCDisassembler", - "//llvm:MCParser", - "//llvm:Object", - "//llvm:OrcShared", - "//llvm:Support", - "//llvm:ir_headers", - ], -) - -expand_template( - name = "RuntimeLibraryVariables_inc", - out = "include/bolt/RuntimeLibs/RuntimeLibraryVariables.inc", - substitutions = { - # FIXME this is a total guess - "@LLVM_LIBDIR_SUFFIX@": "lib", - }, - template = "include/bolt/RuntimeLibs/RuntimeLibraryVariables.inc.in", -) - -cc_library( - name = "RuntimeLibs", - srcs = glob([ - "lib/RuntimeLibs/*.cpp", - ]), - includes = ["include"], - textual_hdrs = glob([ - "include/bolt/RuntimeLibs/*.h", - ]) + ["include/bolt/RuntimeLibs/RuntimeLibraryVariables.inc"], - deps = [ - ":Core", - ":Passes", - ":Utils", - "//llvm:Analysis", - "//llvm:BinaryFormat", - "//llvm:CodeGen", - "//llvm:DWP", - "//llvm:DebugInfoDWARF", - "//llvm:Demangle", - "//llvm:MC", - "//llvm:MCDisassembler", - "//llvm:MCParser", - "//llvm:Object", - "//llvm:Support", - ], -) - -cc_library( - name = "Profile", - srcs = glob([ - "lib/Profile/*.cpp", - ]), - hdrs = glob([ - "include/bolt/Profile/*.h", - ]), - includes = ["include"], - deps = [ - ":Core", - ":Passes", - ":Utils", - "//llvm:Analysis", - "//llvm:BinaryFormat", - "//llvm:CodeGen", - "//llvm:DebugInfoDWARF", - "//llvm:Demangle", - "//llvm:ExecutionEngine", - "//llvm:MC", - "//llvm:MCDisassembler", - "//llvm:MCParser", - "//llvm:Object", - "//llvm:Support", - "//llvm:TransformUtils", - ], -) - -cc_library( - name = "Passes", - srcs = glob([ - "lib/Passes/*.cpp", - ]), - hdrs = glob([ - "include/bolt/Passes/*.h", - ]), - includes = ["include"], - deps = [ - ":Core", - ":Utils", - "//llvm:Analysis", - "//llvm:BinaryFormat", - "//llvm:CodeGen", - "//llvm:DebugInfoDWARF", - "//llvm:Demangle", - "//llvm:ExecutionEngine", - "//llvm:MC", - "//llvm:MCDisassembler", - "//llvm:MCParser", - "//llvm:Object", - "//llvm:Support", - "//llvm:Target", - "//llvm:TransformUtils", - ], -) - -cc_library( - name = "TargetX86", - srcs = glob([ - "lib/Target/X86/*.cpp", - ]), - hdrs = glob([ - "lib/Target/X86/*.h", - ]), - includes = ["include"], - deps = [ - ":Core", - "//llvm:Analysis", - "//llvm:BinaryFormat", - "//llvm:CodeGen", - "//llvm:DWP", - "//llvm:DebugInfoDWARF", - "//llvm:Demangle", - "//llvm:ExecutionEngine", - "//llvm:MC", - "//llvm:MCDisassembler", - "//llvm:MCParser", - "//llvm:Object", - "//llvm:Support", - "//llvm:X86CommonTableGen", - "//llvm:X86UtilsAndDesc", - ], -) - -cc_library( - name = "TargetAArch64", - srcs = glob([ - "lib/Target/AArch64/*.cpp", - ]), - hdrs = glob([ - ]), - includes = ["include"], - deps = [ - ":Core", - ":Utils", - "//llvm:AArch64CommonTableGen", - "//llvm:AArch64UtilsAndDesc", - "//llvm:Analysis", - "//llvm:BinaryFormat", - "//llvm:CodeGen", - "//llvm:DWP", - "//llvm:DebugInfoDWARF", - "//llvm:Demangle", - "//llvm:ExecutionEngine", - "//llvm:MC", - "//llvm:MCDisassembler", - "//llvm:MCParser", - "//llvm:Object", - "//llvm:Support", - ], -) - -cc_library( - name = "Core", - srcs = glob([ - "lib/Core/*.cpp", - ]), - hdrs = glob([ - "include/bolt/Core/*.h", - "include/bolt/RuntimeLibs/*.h", - "include/bolt/Passes/*.h", - "include/bolt/Rewrite/*.h", - ]), - includes = ["include"], - deps = [ - ":Utils", - "//llvm:Analysis", - "//llvm:BinaryFormat", - "//llvm:CodeGen", - "//llvm:DebugInfoDWARF", - "//llvm:Demangle", - "//llvm:ExecutionEngine", - "//llvm:MC", - "//llvm:MCDisassembler", - "//llvm:MCParser", - "//llvm:Object", - "//llvm:ObjectYAML", - "//llvm:Support", - "//llvm:TargetParser", - "//llvm:ir_headers", - ], -) - -cc_library( - name = "Utils", - srcs = glob([ - "lib/Utils/*.cpp", - ]), - hdrs = glob([ - "include/bolt/Utils/*.h", - ]), - includes = ["include"], - deps = [ - "//llvm:Analysis", - "//llvm:BinaryFormat", - "//llvm:CodeGen", - "//llvm:DWP", - "//llvm:DebugInfoDWARF", - "//llvm:Demangle", - "//llvm:ExecutionEngine", - "//llvm:MC", - "//llvm:MCDisassembler", - "//llvm:MCParser", - "//llvm:Object", - "//llvm:Support", - ], -) diff --git a/utils/bazel/llvm-project-overlay/clang-tools-extra/clang-tidy/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang-tools-extra/clang-tidy/BUILD.bazel deleted file mode 100644 index 317863de3b36ca..00000000000000 --- a/utils/bazel/llvm-project-overlay/clang-tools-extra/clang-tidy/BUILD.bazel +++ /dev/null @@ -1,382 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") -load("@bazel_skylib//rules:expand_template.bzl", "expand_template") -load("@bazel_skylib//rules:native_binary.bzl", "native_binary") -load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") -load("defs.bzl", "clang_tidy_library") - -package( - default_visibility = ["//visibility:public"], - features = ["layering_check"], -) - -licenses(["notice"]) - -# Include static analyzer checks in clang-tidy. Usage: -# $ bazel build --@llvm-project//clang-tools-extra/clang-tidy:enable_static_analyzer=true //... -# $ bazel build --@llvm-project//clang-tools-extra/clang-tidy:enable_static_analyzer=false //... -bool_flag( - name = "enable_static_analyzer", - build_setting_default = True, -) - -config_setting( - name = "static_analyzer_enabled", - flag_values = { - ":enable_static_analyzer": "true", - }, -) - -expand_template( - name = "config", - out = "clang-tidy-config.h", - substitutions = select({ - ":static_analyzer_enabled": { - "#cmakedefine01 CLANG_TIDY_ENABLE_STATIC_ANALYZER": "#define CLANG_TIDY_ENABLE_STATIC_ANALYZER 1", - }, - "//conditions:default": { - "#cmakedefine01 CLANG_TIDY_ENABLE_STATIC_ANALYZER": "#define CLANG_TIDY_ENABLE_STATIC_ANALYZER 0", - }, - }), - template = "clang-tidy-config.h.cmake", - visibility = ["//visibility:private"], -) - -cc_binary( - name = "confusable_table_builder", - srcs = ["misc/ConfusableTable/BuildConfusableTable.cpp"], - visibility = ["//visibility:private"], - deps = ["//llvm:Support"], -) - -genrule( - name = "confusables_inc", - srcs = ["misc/ConfusableTable/confusables.txt"], - outs = ["Confusables.inc"], - cmd = "$(location :confusable_table_builder) $(SRCS) $(OUTS)", - tools = [":confusable_table_builder"], - visibility = ["//visibility:private"], -) - -cc_library( - name = "confusables", - hdrs = [":confusables_inc"], - include_prefix = ".", -) - -clang_tidy_library( - name = "lib", - srcs = glob(["*.cpp"]) + [":config"], - hdrs = glob(["*.h"]), - includes = ["."], - deps = [ - "//clang:analysis", - "//clang:format", - "//clang:frontend_rewrite", - "//clang:rewrite", - "//clang:sema", - "//clang:serialization", - "//clang:tooling", - "//clang:tooling_core", - ] + select({ - ":static_analyzer_enabled": [ - "//clang:static_analyzer_core", - "//clang:static_analyzer_frontend", - ], - "//conditions:default": [], - }), -) - -clang_tidy_library( - name = "misc", - deps = [ - ":confusables", - ":lib", - ":utils", - "//clang:analysis", - "//clang:format", - "//clang:serialization", - "//clang:tooling", - "//clang:tooling_core", - "//clang:tooling_inclusions", - "//clang-tools-extra/include-cleaner:include_cleaner", - ], -) - -clang_tidy_library( - name = "portability", - deps = [ - ":lib", - "//llvm:TargetParser", - ], -) - -clang_tidy_library( - name = "utils", - deps = [ - ":lib", - "//clang:analysis", - "//clang:sema", - "//clang:tooling", - "//clang:transformer", - ], -) - -clang_tidy_library( - name = "readability", - deps = [ - ":lib", - ":utils", - "//clang:analysis", - "//clang:tooling", - ], -) - -clang_tidy_library( - name = "google", - deps = [ - ":lib", - ":readability", - ":utils", - ], -) - -clang_tidy_library( - name = "fuchsia", - deps = [ - ":google", - ":lib", - ], -) - -clang_tidy_library( - name = "llvm", - deps = [ - ":lib", - ":readability", - ":utils", - "//clang:tooling", - ], -) - -clang_tidy_library( - name = "llvmlibc", - deps = [ - ":lib", - ":portability", - ":utils", - ], -) - -clang_tidy_library( - name = "abseil", - deps = [ - ":lib", - ":utils", - "//clang:tooling", - "//clang:transformer", - ], -) - -clang_tidy_library( - name = "altera", - deps = [":lib"], -) - -clang_tidy_library( - name = "android", - deps = [ - ":lib", - ":utils", - ], -) - -clang_tidy_library( - name = "boost", - deps = [":lib"], -) - -clang_tidy_library( - name = "concurrency", - deps = [":lib"], -) - -clang_tidy_library( - name = "darwin", - deps = [":lib"], -) - -clang_tidy_library( - name = "linuxkernel", - deps = [":lib"], -) - -clang_tidy_library( - name = "modernize", - deps = [ - ":lib", - ":utils", - "//clang:tooling", - ], -) - -clang_tidy_library( - name = "mpi", - deps = [ - ":lib", - "//clang:static_analyzer_checkers", - "//clang:static_analyzer_core", - "//clang:static_analyzer_frontend", - "//clang:tooling", - ], -) - -clang_tidy_library( - name = "objc", - deps = [ - ":lib", - ":utils", - ], -) - -clang_tidy_library( - name = "openmp", - deps = [ - ":lib", - ":utils", - ], -) - -clang_tidy_library( - name = "zircon", - deps = [ - ":lib", - ":utils", - ], -) - -clang_tidy_library( - name = "cppcoreguidelines", - deps = [ - ":lib", - ":misc", - ":modernize", - ":performance", - ":readability", - ":utils", - "//clang:analysis", - ], -) - -clang_tidy_library( - name = "bugprone", - deps = [ - ":cppcoreguidelines", - ":lib", - ":utils", - "//clang:analysis", - "//clang:tooling", - "//clang:transformer", - ], -) - -clang_tidy_library( - name = "performance", - deps = [ - ":lib", - ":utils", - "//clang:analysis", - "//clang:tooling", - ], -) - -clang_tidy_library( - name = "cert", - deps = [ - ":bugprone", - ":concurrency", - ":google", - ":lib", - ":misc", - ":performance", - ":readability", - ":utils", - ], -) - -clang_tidy_library( - name = "hicpp", - deps = [ - ":bugprone", - ":cppcoreguidelines", - ":google", - ":lib", - ":misc", - ":modernize", - ":performance", - ":readability", - ], -) - -clang_tidy_library( - name = "plugin", - deps = [":lib"], -) - -CHECKS = [ - ":abseil", - ":altera", - ":android", - ":boost", - ":bugprone", - ":cert", - ":concurrency", - ":cppcoreguidelines", - ":darwin", - ":fuchsia", - ":google", - ":hicpp", - ":linuxkernel", - ":llvm", - ":llvmlibc", - ":misc", - ":modernize", - ":objc", - ":openmp", - ":performance", - ":portability", - ":readability", - ":zircon", -] + select({ - ":static_analyzer_enabled": [":mpi"], - "//conditions:default": [], -}) - -cc_library( - name = "tool", - srcs = ["tool/ClangTidyMain.cpp"], - hdrs = ["tool/ClangTidyMain.h"], - deps = CHECKS + [ - ":lib", - ":utils", - "//clang:tooling", - "//llvm:Support", - ], -) - -cc_binary( - name = "clang-tidy", - srcs = ["tool/ClangTidyToolMain.cpp"], - stamp = 0, - deps = [":tool"], -) - -native_binary( - name = "run-clang-tidy", - src = "tool/run-clang-tidy.py", - out = "run-clang-tidy", - data = [":clang-tidy"], -) diff --git a/utils/bazel/llvm-project-overlay/clang-tools-extra/clang-tidy/defs.bzl b/utils/bazel/llvm-project-overlay/clang-tools-extra/clang-tidy/defs.bzl deleted file mode 100644 index 41c03aad871c71..00000000000000 --- a/utils/bazel/llvm-project-overlay/clang-tools-extra/clang-tidy/defs.bzl +++ /dev/null @@ -1,25 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -load("@bazel_skylib//lib:paths.bzl", "paths") -load("@rules_cc//cc:defs.bzl", "cc_library") - -_common_library_deps = [ - "//clang:ast", - "//clang:ast_matchers", - "//clang:basic", - "//clang:lex", - "//clang:frontend", - "//llvm:FrontendOpenMP", - "//llvm:Support", -] - -def clang_tidy_library(name, **kwargs): - kwargs["srcs"] = kwargs.get("srcs", native.glob([paths.join(name, "*.cpp")])) - kwargs["hdrs"] = kwargs.get("hdrs", native.glob([paths.join(name, "*.h")])) - kwargs["deps"] = kwargs.get("deps", []) + _common_library_deps - cc_library( - name = name, - **kwargs - ) diff --git a/utils/bazel/llvm-project-overlay/clang-tools-extra/include-cleaner/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang-tools-extra/include-cleaner/BUILD.bazel deleted file mode 100644 index 28f90efb3ba7f3..00000000000000 --- a/utils/bazel/llvm-project-overlay/clang-tools-extra/include-cleaner/BUILD.bazel +++ /dev/null @@ -1,63 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") - -package( - default_visibility = ["//visibility:public"], - features = ["layering_check"], -) - -licenses(["notice"]) - -cc_library( - name = "include_cleaner", - srcs = glob([ - "lib/*.h", - "lib/*.cpp", - ]), - hdrs = glob(["include/clang-include-cleaner/*.h"]), - includes = ["include/"], - deps = [ - "//clang:ast", - "//clang:basic", - "//clang:format", - "//clang:frontend", - "//clang:lex", - "//clang:tooling_core", - "//clang:tooling_inclusions", - "//llvm:Support", - ], -) - -cc_library( - name = "include_cleaner_internal", - hdrs = glob(["lib/*.h"]), - includes = ["lib/"], - visibility = [":__subpackages__"], - deps = [ - ":include_cleaner", - "//clang:ast", - "//clang:basic", - "//clang:frontend", - "//clang:lex", - "//clang:tooling_inclusions", - "//llvm:Support", - ], -) - -cc_binary( - name = "clang-include-cleaner", - srcs = glob([ - "tool/*.cpp", - ]), - deps = [ - ":include_cleaner", - ":include_cleaner_internal", - "//clang:frontend", - "//clang:lex", - "//clang:tooling", - "//llvm:Support", - ], -) diff --git a/utils/bazel/llvm-project-overlay/clang-tools-extra/unittests/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang-tools-extra/unittests/BUILD.bazel deleted file mode 100644 index 12e87cec4b76b8..00000000000000 --- a/utils/bazel/llvm-project-overlay/clang-tools-extra/unittests/BUILD.bazel +++ /dev/null @@ -1,55 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -load("@rules_cc//cc:defs.bzl", "cc_test") - -package( - default_visibility = ["//visibility:public"], - features = ["layering_check"], -) - -licenses(["notice"]) - -cc_test( - name = "clang_tidy_test", - size = "small", - srcs = glob( - [ - "clang-tidy/*.cpp", - "clang-tidy/*.h", - ], - allow_empty = False, - ), - includes = ["clang-tidy/include"], - deps = [ - "//clang:ast", - "//clang:ast_matchers", - "//clang:basic", - "//clang:frontend", - "//clang:lex", - "//clang:serialization", - "//clang:testing", - "//clang:tooling", - "//clang:tooling_core", - "//clang:transformer", - "//clang-tools-extra/clang-tidy:android", - "//clang-tools-extra/clang-tidy:google", - "//clang-tools-extra/clang-tidy:lib", - "//clang-tools-extra/clang-tidy:llvm", - "//clang-tools-extra/clang-tidy:misc", - "//clang-tools-extra/clang-tidy:modernize", - "//clang-tools-extra/clang-tidy:objc", - "//clang-tools-extra/clang-tidy:performance", - "//clang-tools-extra/clang-tidy:readability", - "//clang-tools-extra/clang-tidy:tool", - "//clang-tools-extra/clang-tidy:utils", - "//llvm:FrontendOpenMP", - "//llvm:Support", - "//llvm:TestingAnnotations", - "//llvm:TestingSupport", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) diff --git a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel deleted file mode 100644 index d6b124f9d8e4c9..00000000000000 --- a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel +++ /dev/null @@ -1,2683 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -load("@bazel_skylib//rules:expand_template.bzl", "expand_template") -load( - "//:vars.bzl", - "LLVM_VERSION", - "LLVM_VERSION_MAJOR", - "LLVM_VERSION_MINOR", - "LLVM_VERSION_PATCH", -) -load("//:workspace_root.bzl", "workspace_root") -load("//llvm:binary_alias.bzl", "binary_alias") -load("//llvm:cc_plugin_library.bzl", "cc_plugin_library") -load("//llvm:tblgen.bzl", "gentbl") - -package( - default_visibility = ["//visibility:public"], - features = ["layering_check"], -) - -licenses(["notice"]) - -exports_files([ - "tools/clang-format/clang-format.el", - "tools/clang-format/clang-format-test.el", - "tools/clang-format/clang-format.py", - "tools/clang-rename/clang-rename.el", - "tools/extra/clang-include-fixer/tool/clang-include-fixer.el", - "tools/extra/clang-include-fixer/tool/clang-include-fixer-test.el", -]) - -cc_binary( - name = "clang-tblgen", - srcs = glob([ - "utils/TableGen/*.cpp", - "utils/TableGen/*.h", - ]), - copts = [ - "$(STACK_FRAME_UNLIMITED)", - ], - stamp = 0, - deps = [ - ":support", - "//llvm:Support", - "//llvm:TableGen", - "//llvm:config", - ], -) - -gentbl( - name = "diagnostic_defs_gen", - tbl_outs = [( - "-gen-clang-diags-defs -clang-component=%s" % c, - "include/clang/Basic/Diagnostic%sKinds.inc" % c, - ) for c in [ - "AST", - "Analysis", - "Comment", - "Common", - "CrossTU", - "Driver", - "Frontend", - "Lex", - "Parse", - "Refactoring", - "Sema", - "Serialization", - ]] + [ - ( - "-gen-clang-diag-groups", - "include/clang/Basic/DiagnosticGroups.inc", - ), - ( - "-gen-clang-diags-index-name", - "include/clang/Basic/DiagnosticIndexName.inc", - ), - ], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/Diagnostic.td", - td_srcs = glob(["include/clang/Basic/*.td"]), -) - -gentbl( - name = "basic_arm_neon_inc_gen", - tbl_outs = [( - "-gen-arm-neon-sema", - "include/clang/Basic/arm_neon.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/arm_neon.td", - td_srcs = [ - "include/clang/Basic/arm_neon.td", - "include/clang/Basic/arm_neon_incl.td", - ], -) - -gentbl( - name = "basic_arm_fp16_inc_gen", - tbl_outs = [( - "-gen-arm-neon-sema", - "include/clang/Basic/arm_fp16.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/arm_fp16.td", - td_srcs = [ - "include/clang/Basic/arm_fp16.td", - "include/clang/Basic/arm_neon_incl.td", - ], -) - -gentbl( - name = "basic_arm_mve_aliases_gen", - tbl_outs = [( - "-gen-arm-mve-builtin-aliases", - "include/clang/Basic/arm_mve_builtin_aliases.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/arm_mve.td", - td_srcs = [ - "include/clang/Basic/arm_mve.td", - "include/clang/Basic/arm_mve_defs.td", - ], -) - -gentbl( - name = "basic_arm_sve_builtins_gen", - tbl_outs = [( - "-gen-arm-sve-builtins", - "include/clang/Basic/arm_sve_builtins.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/arm_sve.td", - td_srcs = [ - "include/clang/Basic/arm_sve.td", - "include/clang/Basic/arm_sve_sme_incl.td", - ], -) - -gentbl( - name = "basic_arm_sve_builtin_cg_gen", - tbl_outs = [( - "-gen-arm-sve-builtin-codegen", - "include/clang/Basic/arm_sve_builtin_cg.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/arm_sve.td", - td_srcs = [ - "include/clang/Basic/arm_sve.td", - "include/clang/Basic/arm_sve_sme_incl.td", - ], -) - -gentbl( - name = "basic_arm_sve_typeflags_gen", - tbl_outs = [( - "-gen-arm-sve-typeflags", - "include/clang/Basic/arm_sve_typeflags.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/arm_sve.td", - td_srcs = [ - "include/clang/Basic/arm_sve.td", - "include/clang/Basic/arm_sve_sme_incl.td", - ], -) - -gentbl( - name = "basic_arm_sve_sema_rangechecks_gen", - tbl_outs = [( - "-gen-arm-sve-sema-rangechecks", - "include/clang/Basic/arm_sve_sema_rangechecks.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/arm_sve.td", - td_srcs = [ - "include/clang/Basic/arm_sve.td", - "include/clang/Basic/arm_sve_sme_incl.td", - ], -) - -gentbl( - name = "basic_arm_sve_streaming_attrs_gen", - tbl_outs = [( - "-gen-arm-sve-streaming-attrs", - "include/clang/Basic/arm_sve_streaming_attrs.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/arm_sve.td", - td_srcs = [ - "include/clang/Basic/arm_sve.td", - "include/clang/Basic/arm_sve_sme_incl.td", - ], -) - -gentbl( - name = "basic_arm_sme_builtins_gen", - tbl_outs = [( - "-gen-arm-sme-builtins", - "include/clang/Basic/arm_sme_builtins.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/arm_sme.td", - td_srcs = [ - "include/clang/Basic/arm_sme.td", - "include/clang/Basic/arm_sve_sme_incl.td", - ], -) - -gentbl( - name = "basic_arm_sme_builtin_cg_gen", - tbl_outs = [( - "-gen-arm-sme-builtin-codegen", - "include/clang/Basic/arm_sme_builtin_cg.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/arm_sme.td", - td_srcs = [ - "include/clang/Basic/arm_sme.td", - "include/clang/Basic/arm_sve_sme_incl.td", - ], -) - -gentbl( - name = "basic_arm_sme_builtins_za_state_gen", - tbl_outs = [( - "-gen-arm-sme-builtin-za-state", - "include/clang/Basic/arm_sme_builtins_za_state.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/arm_sme.td", - td_srcs = [ - "include/clang/Basic/arm_sme.td", - "include/clang/Basic/arm_sve_sme_incl.td", - ], -) - -gentbl( - name = "basic_arm_sme_sema_rangechecks_gen", - tbl_outs = [( - "-gen-arm-sme-sema-rangechecks", - "include/clang/Basic/arm_sme_sema_rangechecks.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/arm_sme.td", - td_srcs = [ - "include/clang/Basic/arm_sme.td", - "include/clang/Basic/arm_sve_sme_incl.td", - ], -) - -gentbl( - name = "basic_arm_sme_streaming_attrs_gen", - tbl_outs = [( - "-gen-arm-sme-streaming-attrs", - "include/clang/Basic/arm_sme_streaming_attrs.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/arm_sme.td", - td_srcs = [ - "include/clang/Basic/arm_sme.td", - "include/clang/Basic/arm_sve_sme_incl.td", - ], -) - -gentbl( - name = "basic_arm_mve_cg_gen", - tbl_outs = [( - "-gen-arm-mve-builtin-codegen", - "include/clang/Basic/arm_mve_builtin_cg.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/arm_mve.td", - td_srcs = [ - "include/clang/Basic/arm_mve.td", - "include/clang/Basic/arm_mve_defs.td", - ], -) - -gentbl( - name = "basic_arm_mve_inc_gen", - tbl_outs = [( - "-gen-arm-mve-builtin-def", - "include/clang/Basic/arm_mve_builtins.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/arm_mve.td", - td_srcs = [ - "include/clang/Basic/arm_mve.td", - "include/clang/Basic/arm_mve_defs.td", - ], -) - -gentbl( - name = "basic_arm_mve_sema_gen", - tbl_outs = [( - "-gen-arm-mve-builtin-sema", - "include/clang/Basic/arm_mve_builtin_sema.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/arm_mve.td", - td_srcs = [ - "include/clang/Basic/arm_mve.td", - "include/clang/Basic/arm_mve_defs.td", - ], -) - -gentbl( - name = "basic_builtins_bpf_gen", - tbl_outs = [( - "-gen-clang-builtins", - "include/clang/Basic/BuiltinsBPF.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/BuiltinsBPF.td", - td_srcs = [ - "include/clang/Basic/BuiltinsBPF.td", - "include/clang/Basic/BuiltinsBase.td", - ], -) - -gentbl( - name = "basic_builtins_riscv_gen", - tbl_outs = [( - "-gen-clang-builtins", - "include/clang/Basic/BuiltinsRISCV.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/BuiltinsRISCV.td", - td_srcs = [ - "include/clang/Basic/BuiltinsRISCV.td", - "include/clang/Basic/BuiltinsBase.td", - ], -) - -gentbl( - name = "basic_builtins_gen", - tbl_outs = [( - "-gen-clang-builtins", - "include/clang/Basic/Builtins.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/Builtins.td", - td_srcs = [ - "include/clang/Basic/Builtins.td", - "include/clang/Basic/BuiltinsBase.td", - ], -) - -gentbl( - name = "basic_riscv_vector_builtins_gen", - tbl_outs = [( - "-gen-riscv-vector-builtins", - "include/clang/Basic/riscv_vector_builtins.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/riscv_vector.td", - td_srcs = [ - "include/clang/Basic/riscv_vector.td", - "include/clang/Basic/riscv_vector_common.td", - ], -) - -gentbl( - name = "basic_riscv_vector_builtin_cg_gen", - tbl_outs = [( - "-gen-riscv-vector-builtin-codegen", - "include/clang/Basic/riscv_vector_builtin_cg.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/riscv_vector.td", - td_srcs = [ - "include/clang/Basic/riscv_vector.td", - "include/clang/Basic/riscv_vector_common.td", - ], -) - -gentbl( - name = "basic_riscv_vector_builtin_sema_gen", - tbl_outs = [( - "-gen-riscv-vector-builtin-sema", - "include/clang/Basic/riscv_vector_builtin_sema.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/riscv_vector.td", - td_srcs = [ - "include/clang/Basic/riscv_vector.td", - "include/clang/Basic/riscv_vector_common.td", - ], -) - -gentbl( - name = "basic_riscv_sifive_vector_builtins_gen", - tbl_outs = [( - "-gen-riscv-sifive-vector-builtins", - "include/clang/Basic/riscv_sifive_vector_builtins.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/riscv_sifive_vector.td", - td_srcs = [ - "include/clang/Basic/riscv_sifive_vector.td", - "include/clang/Basic/riscv_vector_common.td", - ], -) - -gentbl( - name = "basic_riscv_sifive_vector_builtin_cg_gen", - tbl_outs = [( - "-gen-riscv-sifive-vector-builtin-codegen", - "include/clang/Basic/riscv_sifive_vector_builtin_cg.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/riscv_sifive_vector.td", - td_srcs = [ - "include/clang/Basic/riscv_sifive_vector.td", - "include/clang/Basic/riscv_vector_common.td", - ], -) - -gentbl( - name = "basic_riscv_sifive_vector_builtin_sema_gen", - tbl_outs = [( - "-gen-riscv-sifive-vector-builtin-sema", - "include/clang/Basic/riscv_sifive_vector_builtin_sema.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/riscv_sifive_vector.td", - td_srcs = [ - "include/clang/Basic/riscv_sifive_vector.td", - "include/clang/Basic/riscv_vector_common.td", - ], -) - -gentbl( - name = "basic_arm_cde_gen", - tbl_outs = [( - "-gen-arm-cde-builtin-def", - "include/clang/Basic/arm_cde_builtins.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/arm_cde.td", - td_srcs = [ - "include/clang/Basic/arm_cde.td", - "include/clang/Basic/arm_mve_defs.td", - ], -) - -gentbl( - name = "basic_arm_cde_aliases_gen", - tbl_outs = [( - "-gen-arm-cde-builtin-aliases", - "include/clang/Basic/arm_cde_builtin_aliases.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/arm_cde.td", - td_srcs = [ - "include/clang/Basic/arm_cde.td", - "include/clang/Basic/arm_mve_defs.td", - ], -) - -gentbl( - name = "basic_arm_cde_cg_gen", - tbl_outs = [( - "-gen-arm-cde-builtin-codegen", - "include/clang/Basic/arm_cde_builtin_cg.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/arm_cde.td", - td_srcs = [ - "include/clang/Basic/arm_cde.td", - "include/clang/Basic/arm_mve_defs.td", - ], -) - -gentbl( - name = "basic_arm_cde_sema_gen", - tbl_outs = [( - "-gen-arm-cde-builtin-sema", - "include/clang/Basic/arm_cde_builtin_sema.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/arm_cde.td", - td_srcs = [ - "include/clang/Basic/arm_cde.td", - "include/clang/Basic/arm_mve_defs.td", - ], -) - -gentbl( - name = "basic_attr_gen", - tbl_outs = [ - ( - "-gen-clang-attr-has-attribute-impl", - "include/clang/Basic/AttrHasAttributeImpl.inc", - ), - ( - "-gen-clang-attr-list", - "include/clang/Basic/AttrList.inc", - ), - ( - "-gen-clang-attr-subject-match-rule-list", - "include/clang/Basic/AttrSubMatchRulesList.inc", - ), - ( - "-gen-clang-regular-keyword-attr-info", - "include/clang/Basic/RegularKeywordAttrInfo.inc", - ), - ], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/Attr.td", - td_srcs = [ - "include/clang/Basic/ASTNode.td", - "include/clang/Basic/Attr.td", - "include/clang/Basic/AttrDocs.td", - "include/clang/Basic/DeclNodes.td", - "include/clang/Basic/StmtNodes.td", - ], -) - -gentbl( - name = "libsema_openclbuiltins_inc_gen", - strip_include_prefix = "lib/Sema", - tbl_outs = [( - "-gen-clang-opencl-builtins", - "lib/Sema/OpenCLBuiltins.inc", - )], - tblgen = ":clang-tblgen", - td_file = "lib/Sema/OpenCLBuiltins.td", - td_srcs = [ - "lib/Sema/OpenCLBuiltins.td", - ], -) - -# Table definition files can be used for documentation: -filegroup( - name = "all_table_defs", - srcs = glob(["include/**/*.td"]), -) - -exports_files( - glob(["include/**/*.td"]), -) - -genrule( - name = "basic_version_gen", - outs = ["include/clang/Basic/Version.inc"], - cmd = ( - "echo '#define CLANG_VERSION {vers}' >> $@\n" + - "echo '#define CLANG_VERSION_MAJOR {major}' >> $@\n" + - "echo '#define CLANG_VERSION_MAJOR_STRING \"{major}\"' >> $@\n" + - "echo '#define CLANG_VERSION_MINOR {minor}' >> $@\n" + - "echo '#define CLANG_VERSION_PATCHLEVEL {patch}' >> $@\n" + - "echo '#define CLANG_VERSION_STRING \"{vers}git\"' >> $@\n" - ).format( - major = LLVM_VERSION_MAJOR, - minor = LLVM_VERSION_MINOR, - patch = LLVM_VERSION_PATCH, - vers = LLVM_VERSION, - ), -) - -cc_library( - name = "config", - hdrs = [ - "include/clang/Basic/Version.inc", - "include/clang/Config/config.h", - ], - includes = ["include"], - deps = [ - # We rely on the LLVM config library to provide configuration defines. - "//llvm:config", - ], -) - -# TODO: This should get replaced with something that actually generates the -# correct version number. -genrule( - name = "vcs_version_gen", - # This should be under lib/Basic, but because of how the include paths - # are passed through bazel, it's easier to drop generated files next to - # the other includes. - outs = ["include/VCSVersion.inc"], - cmd = "echo '#undef CLANG_REVISION' > $@", -) - -py_binary( - name = "bundle_resources", - srcs = [ - "utils/bundle_resources.py", - ], - main = "utils/bundle_resources.py", -) - -# A hacky library to expose some internal headers of the `basic` library to its -# own implementation source files using a stripped include prefix rather than -# file-relative-inclusion. This is inherently non-modular as these headers will -# be repeated in the sources below for file-relative-inclusion. -cc_library( - name = "basic_internal_headers", - hdrs = glob([ - "lib/Basic/*.h", - ]), - features = ["-header_modules"], - strip_include_prefix = "lib/Basic", -) - -cc_library( - name = "basic", - srcs = [ - "include/VCSVersion.inc", - "include/clang/Basic/Version.inc", - ] + glob([ - "lib/Basic/*.cpp", - "lib/Basic/*.c", - "lib/Basic/*.h", - "lib/Basic/Targets/*.cpp", - "lib/Basic/Targets/*.h", - ]), - hdrs = glob([ - "include/clang/Basic/*.h", - ]), - copts = [ - "-DHAVE_VCS_VERSION_INC", - "$(STACK_FRAME_UNLIMITED)", - ], - includes = ["include"], - textual_hdrs = [ - "include/clang/Basic/arm_fp16.inc", - "include/clang/Basic/arm_mve_builtins.inc", - "include/clang/Basic/arm_mve_builtin_aliases.inc", - "include/clang/Basic/arm_mve_builtin_cg.inc", - "include/clang/Basic/arm_mve_builtin_sema.inc", - "include/clang/Basic/arm_sme_builtins.inc", - "include/clang/Basic/arm_sme_builtin_cg.inc", - "include/clang/Basic/arm_neon.inc", - "include/clang/Basic/AttrHasAttributeImpl.inc", - "include/clang/Basic/AttrList.inc", - "include/clang/Basic/AttrSubMatchRulesList.inc", - "include/clang/Basic/DiagnosticASTKinds.inc", - "include/clang/Basic/DiagnosticGroups.inc", - "include/clang/Basic/DiagnosticRefactoringKinds.inc", - "include/clang/Basic/DiagnosticAnalysisKinds.inc", - "include/clang/Basic/DiagnosticSemaKinds.inc", - "include/clang/Basic/DiagnosticCommentKinds.inc", - "include/clang/Basic/DiagnosticParseKinds.inc", - "include/clang/Basic/DiagnosticLexKinds.inc", - "include/clang/Basic/DiagnosticSerializationKinds.inc", - "include/clang/Basic/DiagnosticFrontendKinds.inc", - "include/clang/Basic/DiagnosticDriverKinds.inc", - "include/clang/Basic/DiagnosticCrossTUKinds.inc", - "include/clang/Basic/DiagnosticCommonKinds.inc", - "include/clang/Basic/DiagnosticIndexName.inc", - ] + glob([ - "include/clang/Basic/*.def", - ]), - deps = [ - ":basic_arm_cde_gen", - ":basic_arm_fp16_inc_gen", - ":basic_arm_mve_aliases_gen", - ":basic_arm_mve_cg_gen", - ":basic_arm_mve_inc_gen", - ":basic_arm_mve_sema_gen", - ":basic_arm_neon_inc_gen", - ":basic_arm_sme_builtin_cg_gen", - ":basic_arm_sme_builtins_gen", - ":basic_arm_sve_builtins_gen", - ":basic_arm_sve_typeflags_gen", - ":basic_attr_gen", - ":basic_builtins_bpf_gen", - ":basic_builtins_gen", - ":basic_builtins_riscv_gen", - ":basic_internal_headers", - ":basic_riscv_sifive_vector_builtins_gen", - ":basic_riscv_vector_builtin_cg_gen", - ":basic_riscv_vector_builtins_gen", - ":config", - ":diagnostic_defs_gen", - ":sema_attr_gen", - "//llvm:Core", - "//llvm:FrontendDebug", - "//llvm:FrontendDriver", - "//llvm:FrontendOpenMP", - "//llvm:Instrumentation", - "//llvm:MC", - "//llvm:Support", - "//llvm:Target", - "//llvm:TargetParser", - "//llvm:config", - ], -) - -cc_library( - name = "lex", - srcs = glob([ - "lib/Lex/*.cpp", - "lib/Lex/*.h", - ]), - hdrs = glob([ - "include/clang/Lex/*.h", - ]), - includes = ["include"], - deps = [ - ":basic", - ":config", - "//llvm:Support", - "//llvm:TargetParser", - ], -) - -gentbl( - name = "ast_attr_gen", - tbl_outs = [ - ( - "-gen-clang-attr-ast-visitor", - "include/clang/AST/AttrVisitor.inc", - ), - ( - "-gen-clang-attr-classes", - "include/clang/AST/Attrs.inc", - ), - ( - "-gen-clang-attr-doc-table", - "lib/AST/AttrDocTable.inc", - ), - ( - "-gen-clang-attr-text-node-dump", - "include/clang/AST/AttrTextNodeDump.inc", - ), - ( - "-gen-clang-attr-node-traverse", - "include/clang/AST/AttrNodeTraverse.inc", - ), - ( - "-gen-clang-attr-impl", - "include/clang/AST/AttrImpl.inc", - ), - ( - "-gen-clang-attr-can-print-left-list", - "include/clang/Basic/AttrLeftSideCanPrintList.inc", - ), - ( - "-gen-clang-attr-must-print-left-list", - "include/clang/Basic/AttrLeftSideMustPrintList.inc", - ), - ], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/Attr.td", - td_srcs = [ - "include/clang/Basic/Attr.td", - "include/clang/Basic/AttrDocs.td", - "include/clang/Basic/ASTNode.td", - "include/clang/Basic/DeclNodes.td", - "include/clang/Basic/StmtNodes.td", - ], -) - -gentbl( - name = "ast_decl_nodes_gen", - tbl_outs = [( - "-gen-clang-decl-nodes", - "include/clang/AST/DeclNodes.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/DeclNodes.td", - td_srcs = [ - "include/clang/Basic/ASTNode.td", - "include/clang/Basic/DeclNodes.td", - ], -) - -gentbl( - name = "ast_stmt_nodes_gen", - tbl_outs = [( - "-gen-clang-stmt-nodes", - "include/clang/AST/StmtNodes.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/StmtNodes.td", - td_srcs = [ - "include/clang/Basic/ASTNode.td", - "include/clang/Basic/StmtNodes.td", - ], -) - -gentbl( - name = "ast_comment_nodes_gen", - tbl_outs = [( - "-gen-clang-comment-nodes", - "include/clang/AST/CommentNodes.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/CommentNodes.td", - td_srcs = [ - "include/clang/Basic/ASTNode.td", - "include/clang/Basic/CommentNodes.td", - ], -) - -gentbl( - name = "ast_comment_command_info_gen", - tbl_outs = [ - ( - "-gen-clang-comment-command-info", - "include/clang/AST/CommentCommandInfo.inc", - ), - ( - "-gen-clang-comment-command-list", - "include/clang/AST/CommentCommandList.inc", - ), - ], - tblgen = ":clang-tblgen", - td_file = "include/clang/AST/CommentCommands.td", - td_srcs = ["include/clang/AST/CommentCommands.td"], -) - -gentbl( - name = "ast_comment_html_tags_gen", - tbl_outs = [( - "-gen-clang-comment-html-tags", - "include/clang/AST/CommentHTMLTags.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/AST/CommentHTMLTags.td", - td_srcs = ["include/clang/AST/CommentHTMLTags.td"], -) - -gentbl( - name = "ast_comment_html_tags_properties_gen", - tbl_outs = [( - "-gen-clang-comment-html-tags-properties", - "include/clang/AST/CommentHTMLTagsProperties.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/AST/CommentHTMLTags.td", - td_srcs = ["include/clang/AST/CommentHTMLTags.td"], -) - -gentbl( - name = "ast_comment_html_named_character_references_gen", - tbl_outs = [( - "-gen-clang-comment-html-named-character-references", - "include/clang/AST/CommentHTMLNamedCharacterReferences.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/AST/CommentHTMLNamedCharacterReferences.td", - td_srcs = ["include/clang/AST/CommentHTMLNamedCharacterReferences.td"], -) - -gentbl( - name = "ast_stmt_data_collectors_gen", - tbl_outs = [( - "-gen-clang-data-collectors", - "include/clang/AST/StmtDataCollectors.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/AST/StmtDataCollectors.td", - td_srcs = ["include/clang/AST/StmtDataCollectors.td"], -) - -gentbl( - name = "ast_interp_opcodes_gen", - tbl_outs = [( - "-gen-clang-opcodes", - "lib/AST/Interp/Opcodes.inc", - )], - tblgen = ":clang-tblgen", - td_file = "lib/AST/Interp/Opcodes.td", - td_srcs = ["lib/AST/Interp/Opcodes.td"], -) - -gentbl( - name = "ast_properties_base_gen", - tbl_outs = [ - ( - "-gen-clang-basic-reader", - "include/clang/AST/AbstractBasicReader.inc", - ), - ( - "-gen-clang-basic-writer", - "include/clang/AST/AbstractBasicWriter.inc", - ), - ], - tblgen = ":clang-tblgen", - td_file = "include/clang/AST/PropertiesBase.td", - td_srcs = ["include/clang/AST/PropertiesBase.td"], -) - -gentbl( - name = "ast_type_properties_gen", - tbl_outs = [ - ( - "-gen-clang-type-reader", - "include/clang/AST/AbstractTypeReader.inc", - ), - ( - "-gen-clang-type-writer", - "include/clang/AST/AbstractTypeWriter.inc", - ), - ], - tblgen = ":clang-tblgen", - td_file = "include/clang/AST/TypeProperties.td", - td_srcs = [ - "include/clang/AST/PropertiesBase.td", - "include/clang/AST/TypeProperties.td", - "include/clang/Basic/ASTNode.td", - "include/clang/Basic/TypeNodes.td", - ], -) - -gentbl( - name = "type_nodes_gen", - tbl_outs = [( - "-gen-clang-type-nodes", - "include/clang/AST/TypeNodes.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/TypeNodes.td", - td_srcs = [ - "include/clang/Basic/ASTNode.td", - "include/clang/Basic/TypeNodes.td", - ], -) - -workspace_root(name = "workspace_root") - -cc_library( - name = "ast", - srcs = glob([ - "lib/AST/*.cpp", - "lib/AST/*.h", - "lib/AST/Interp/*.cpp", - "lib/AST/Interp/*.h", - ]) + [ - "lib/AST/AttrDocTable.inc", - "lib/AST/Interp/Opcodes.inc", - ], - hdrs = glob([ - "include/clang/AST/*.h", - ]), - copts = [ - # FIXME: This is necessary to allow "file relative" include paths from - # non-generated `srcs` to find generated `srcs` above. Bazel should - # either make this work automatically by creating a unified tree of - # `srcs` or at least provide a `local_includes` that has the path - # translation logic of `includes` but is only used locally (similar to - # `local_defines` vs. `defines`). Until one of those lands, this is the - # least bad approach. Using `includes` is *specifically* problematic for - # this library because it contains files that collide easily with system - # headers such as `CXXABI.h`. - "-I$(GENDIR)/$(WORKSPACE_ROOT)/clang/lib/AST", - "-I$(GENDIR)/$(WORKSPACE_ROOT)/clang/lib/AST/Interp", - ], - textual_hdrs = [ - "include/clang/AST/AttrImpl.inc", - "include/clang/AST/AttrNodeTraverse.inc", - "include/clang/AST/Attrs.inc", - "include/clang/AST/AttrTextNodeDump.inc", - "include/clang/AST/AttrVisitor.inc", - "include/clang/AST/CommentCommandInfo.inc", - "include/clang/AST/CommentCommandList.inc", - "include/clang/AST/CommentHTMLNamedCharacterReferences.inc", - "include/clang/AST/CommentHTMLTags.inc", - "include/clang/AST/CommentHTMLTagsProperties.inc", - "include/clang/AST/CommentNodes.inc", - "include/clang/AST/DeclNodes.inc", - "include/clang/AST/StmtDataCollectors.inc", - "include/clang/AST/StmtNodes.inc", - ] + glob([ - "include/clang/AST/*.def", - ]), - toolchains = [ - ":workspace_root", - ], - deps = [ - ":ast_attr_gen", - ":ast_comment_command_info_gen", - ":ast_comment_html_named_character_references_gen", - ":ast_comment_html_tags_gen", - ":ast_comment_html_tags_properties_gen", - ":ast_comment_nodes_gen", - ":ast_decl_nodes_gen", - ":ast_interp_opcodes_gen", - ":ast_properties_base_gen", - ":ast_stmt_data_collectors_gen", - ":ast_stmt_nodes_gen", - ":ast_type_properties_gen", - ":basic", - ":basic_builtins_gen", - ":lex", - ":type_nodes_gen", - "//llvm:BinaryFormat", - "//llvm:Core", - "//llvm:FrontendHLSL", - "//llvm:FrontendOpenMP", - "//llvm:Support", - "//llvm:TargetParser", - ], -) - -cc_library( - name = "index", - srcs = glob([ - "lib/Index/*.cpp", - "lib/Index/*.h", - ]), - hdrs = glob([ - "include/clang/Index/*.h", - "include/clang-c/*.h", - ]), - includes = ["include"], - deps = [ - ":ast", - ":basic", - ":format", - ":frontend", - ":lex", - ":rewrite", - ":serialization", - "//llvm:Core", - "//llvm:Support", - ], -) - -genrule( - name = "analysis_htmllogger_gen", - srcs = [ - "lib/Analysis/FlowSensitive/HTMLLogger.html", - "lib/Analysis/FlowSensitive/HTMLLogger.css", - "lib/Analysis/FlowSensitive/HTMLLogger.js", - ], - outs = ["lib/Analysis/FlowSensitive/HTMLLogger.inc"], - cmd = "$(location :bundle_resources) $@ $(SRCS)", - tools = [":bundle_resources"], -) - -cc_library( - name = "analysis", - srcs = glob([ - "lib/Analysis/FlowSensitive/Models/*.cpp", - "lib/Analysis/FlowSensitive/*.cpp", - "lib/Analysis/*.cpp", - "lib/Analysis/*.h", - ]) + [ - ":analysis_htmllogger_gen", - ], - hdrs = glob([ - "include/clang/Analysis/**/*.h", - ]), - includes = [ - "include", - "lib/Analysis/FlowSensitive", - ], - textual_hdrs = glob([ - "include/clang/Analysis/**/*.def", - ]), - deps = [ - ":ast", - ":ast_matchers", - ":basic", - ":lex", - "//llvm:Support", - ], -) - -gentbl( - name = "sema_attr_gen", - tbl_outs = [ - ( - "-gen-clang-attr-parsed-attr-impl", - "include/clang/Sema/AttrParsedAttrImpl.inc", - ), - ( - "-gen-clang-attr-parsed-attr-kinds", - "include/clang/Sema/AttrParsedAttrKinds.inc", - ), - ( - "-gen-clang-attr-parsed-attr-list", - "include/clang/Sema/AttrParsedAttrList.inc", - ), - ( - "-gen-clang-attr-spelling-index", - "include/clang/Sema/AttrSpellingListIndex.inc", - ), - ( - "-gen-clang-attr-template-instantiate", - "include/clang/Sema/AttrTemplateInstantiate.inc", - ), - ], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/Attr.td", - td_srcs = [ - "include/clang/Basic/ASTNode.td", - "include/clang/Basic/Attr.td", - "include/clang/Basic/AttrDocs.td", - "include/clang/Basic/DeclNodes.td", - "include/clang/Basic/StmtNodes.td", - ], -) - -cc_library( - name = "sema", - srcs = glob([ - "lib/Sema/*.cpp", - "lib/Sema/*.h", - ]), - hdrs = glob([ - "include/clang/Sema/*.h", - "include/clang-c/*.h", - ]), - copts = ["$(STACK_FRAME_UNLIMITED)"], - includes = ["include"], - textual_hdrs = [ - "include/clang/Sema/AttrParsedAttrImpl.inc", - "include/clang/Sema/AttrParsedAttrKinds.inc", - "include/clang/Sema/AttrParsedAttrList.inc", - "include/clang/Sema/AttrSpellingListIndex.inc", - "include/clang/Sema/AttrTemplateInstantiate.inc", - "lib/Sema/OpenCLBuiltins.inc", - ], - deps = [ - ":analysis", - ":apinotes", - ":ast", - ":basic", - ":basic_arm_cde_aliases_gen", - ":basic_arm_cde_sema_gen", - ":basic_arm_sme_builtins_gen", - ":basic_arm_sme_builtins_za_state_gen", - ":basic_arm_sme_sema_rangechecks_gen", - ":basic_arm_sme_streaming_attrs_gen", - ":basic_arm_sve_builtins_gen", - ":basic_arm_sve_sema_rangechecks_gen", - ":basic_arm_sve_streaming_attrs_gen", - ":basic_builtins_gen", - ":basic_riscv_sifive_vector_builtin_sema_gen", - ":basic_riscv_vector_builtin_sema_gen", - ":edit", - ":lex", - ":libsema_openclbuiltins_inc_gen", - ":sema_attr_gen", - ":support", - ":type_nodes_gen", - "//llvm:AllTargetsAsmParsers", - "//llvm:AllTargetsCodeGens", - "//llvm:Core", - "//llvm:FrontendHLSL", - "//llvm:FrontendOpenMP", - "//llvm:MC", - "//llvm:MCParser", - "//llvm:Support", - "//llvm:TargetParser", - ], -) - -gentbl( - name = "parse_attr_gen", - tbl_outs = [ - ( - "-gen-clang-attr-parser-string-switches", - "include/clang/Parse/AttrParserStringSwitches.inc", - ), - ( - "-gen-clang-attr-subject-match-rules-parser-string-switches", - "include/clang/Parse/AttrSubMatchRulesParserStringSwitches.inc", - ), - ], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/Attr.td", - td_srcs = [ - "include/clang/Basic/ASTNode.td", - "include/clang/Basic/Attr.td", - "include/clang/Basic/AttrDocs.td", - "include/clang/Basic/DeclNodes.td", - "include/clang/Basic/StmtNodes.td", - ], -) - -cc_library( - name = "parse", - srcs = [ - ] + glob([ - "lib/Parse/*.cpp", - "lib/Parse/*.h", - ]), - hdrs = [ - "include/clang/Parse/AttrParserStringSwitches.inc", - "include/clang/Parse/AttrSubMatchRulesParserStringSwitches.inc", - ] + glob(["include/clang/Parse/*.h"]), - includes = ["include"], - deps = [ - ":ast", - ":basic", - ":lex", - ":parse_attr_gen", - ":sema", - "//llvm:FrontendOpenMP", - "//llvm:MC", - "//llvm:MCParser", - "//llvm:Support", - ], -) - -cc_library( - name = "ast_matchers", - srcs = glob([ - "lib/ASTMatchers/*.cpp", - "lib/ASTMatchers/*.h", - ]), - hdrs = glob(["include/clang/ASTMatchers/*.h"]), - includes = ["include"], - deps = [ - ":ast", - ":basic", - ":lex", - "//llvm:Support", - ], -) - -cc_library( - name = "ast_matchers_dynamic", - srcs = glob([ - "lib/ASTMatchers/Dynamic/*.cpp", - "lib/ASTMatchers/Dynamic/*.h", - ]), - hdrs = glob(["include/clang/ASTMatchers/Dynamic/*.h"]), - copts = ["$(STACK_FRAME_UNLIMITED)"], - includes = ["include"], - deps = [ - ":ast", - ":ast_matchers", - ":basic", - "//llvm:FrontendOpenMP", - "//llvm:Support", - ], -) - -cc_library( - name = "rewrite", - srcs = glob([ - "lib/Rewrite/*.cpp", - "lib/Rewrite/*.h", - ]), - hdrs = glob(["include/clang/Rewrite/Core/*.h"]), - includes = ["include"], - deps = [ - ":ast", - ":basic", - ":edit", - ":lex", - "//llvm:Support", - ], -) - -cc_library( - name = "testing", - testonly = 1, - srcs = glob([ - "lib/Testing/*.cpp", - ]), - hdrs = glob(["include/clang/Testing/*.h"]), - includes = ["include"], - deps = [ - ":basic", - ":frontend", - "//llvm:MC", - "//llvm:Support", - "//third-party/unittest:gtest", - ], -) - -cc_library( - name = "tooling_core", - srcs = glob([ - "lib/Tooling/Core/*.cpp", - "lib/Tooling/Core/*.h", - ]), - hdrs = glob(["include/clang/Tooling/Core/*.h"]), - includes = ["include"], - deps = [ - ":ast", - ":basic", - ":lex", - ":rewrite", - "//llvm:Support", - ], -) - -cc_library( - name = "tooling", - srcs = glob( - [ - "lib/Tooling/*.cpp", - ], - # Temporarily disable until we support the generated file. - exclude = ["lib/Tooling/NodeIntrospection.cpp"], - ), - hdrs = glob([ - "include/clang/Tooling/*.h", - ]), - includes = ["include"], - deps = [ - ":ast", - ":ast_matchers", - ":basic", - ":driver", - ":format", - ":frontend", - ":lex", - ":rewrite", - ":tooling_core", - "//llvm:Option", - "//llvm:Support", - "//llvm:TargetParser", - ], -) - -cc_library( - name = "tooling_inclusions", - srcs = glob([ - "lib/Tooling/Inclusions/**/*.cpp", - "lib/Tooling/Inclusions/**/*.inc", - ]), - hdrs = glob([ - "include/clang/Tooling/Inclusions/**/*.h", - ]), - deps = [ - ":ast", - ":basic", - ":lex", - ":rewrite", - ":tooling_core", - "//llvm:Support", - ], -) - -cc_library( - name = "tooling_refactoring", - srcs = glob([ - "lib/Tooling/Refactoring/**/*.cpp", - "lib/Tooling/Refactoring/**/*.h", - ]), - hdrs = glob([ - "include/clang/Tooling/Refactoring/**/*.h", - "include/clang/Tooling/Refactoring/**/*.def", - ]), - deps = [ - ":ast", - ":ast_matchers", - ":basic", - ":format", - ":frontend", - ":index", - ":lex", - ":rewrite", - ":tooling", - ":tooling_core", - "//llvm:Support", - ], -) - -gentbl( - name = "tooling_syntax_gen", - tbl_outs = [ - ("-gen-clang-syntax-node-list", "include/clang/Tooling/Syntax/Nodes.inc"), - ("-gen-clang-syntax-node-classes", "include/clang/Tooling/Syntax/NodeClasses.inc"), - ], - tblgen = ":clang-tblgen", - td_file = "include/clang/Tooling/Syntax/Nodes.td", - td_srcs = [ - "include/clang/Tooling/Syntax/Nodes.td", - "include/clang/Tooling/Syntax/Syntax.td", - ], -) - -cc_library( - name = "tooling_syntax", - srcs = glob(["lib/Tooling/Syntax/**/*.cpp"]), - hdrs = glob(["include/clang/Tooling/Syntax/**/*.h"]), - deps = [ - ":ast", - ":basic", - ":lex", - ":tooling_core", - ":tooling_syntax_gen", - "//llvm:Support", - ], -) - -cc_library( - name = "tooling_dependency_scanning", - srcs = glob(["lib/Tooling/DependencyScanning/**/*.cpp"]), - hdrs = glob(["include/clang/Tooling/DependencyScanning/**/*.h"]), - deps = [ - ":basic", - ":codegen", - ":driver", - ":frontend", - ":lex", - ":serialization", - ":tooling", - "//llvm:Support", - "//llvm:TargetParser", - ], -) - -cc_library( - name = "transformer", - srcs = glob(["lib/Tooling/Transformer/**/*.cpp"]), - hdrs = glob(["include/clang/Tooling/Transformer/**/*.h"]), - deps = [ - ":ast", - ":ast_matchers", - ":basic", - ":lex", - ":rewrite", - ":tooling_refactoring", - "//llvm:Support", - ], -) - -cc_library( - name = "ast-diff", - srcs = glob(["lib/Tooling/ASTDiff/*.cpp"]), - hdrs = glob(["include/clang/Tooling/ASTDiff/*.h"]), - deps = [ - ":ast", - ":basic", - ":lex", - "//llvm:Support", - ], -) - -cc_library( - name = "crosstu", - srcs = glob(["lib/CrossTU/*.cpp"]), - hdrs = glob(["include/clang/CrossTU/*.h"]), - deps = [ - ":analysis", - ":ast", - ":basic", - ":frontend", - ":index", - "//llvm:Option", - "//llvm:Support", - "//llvm:TargetParser", - ], -) - -cc_library( - name = "format", - srcs = glob( - [ - "lib/Format/*.cpp", - "lib/Format/*.h", - ], - ), - hdrs = [ - "lib/Format/FormatTokenLexer.h", - "lib/Format/FormatTokenSource.h", - "lib/Format/Macros.h", - "lib/Format/QualifierAlignmentFixer.h", - "lib/Format/UnwrappedLineParser.h", - ] + glob([ - "include/clang/Format/*.h", - ]), - includes = ["include"], - deps = [ - ":basic", - ":lex", - ":tooling_core", - ":tooling_inclusions", - "//llvm:Support", - ], -) - -cc_library( - name = "edit", - srcs = glob(["lib/Edit/*.cpp"]), - hdrs = glob(["include/clang/Edit/*.h"]), - includes = ["include"], - deps = [ - ":ast", - ":basic", - ":lex", - "//llvm:Support", - ], -) - -cc_library( - name = "static_analyzer_core_options", - hdrs = [ - "include/clang/StaticAnalyzer/Core/AnalyzerOptions.h", - ], - textual_hdrs = [ - "include/clang/StaticAnalyzer/Core/Analyses.def", - "include/clang/StaticAnalyzer/Core/AnalyzerOptions.def", - ], - deps = [ - ":basic", - ":static_analyzer_checkers_gen", - "//llvm:Support", - ], -) - -cc_library( - name = "static_analyzer_core", - srcs = glob([ - "lib/StaticAnalyzer/Core/**/*.cpp", - "lib/StaticAnalyzer/Core/**/*.h", - ]), - hdrs = glob([ - "include/clang/StaticAnalyzer/Core/**/*.h", - ]), - includes = ["include"], - textual_hdrs = glob([ - "include/clang/StaticAnalyzer/Core/**/*.def", - ]), - deps = [ - ":analysis", - ":ast", - ":ast_matchers", - ":basic", - ":crosstu", - ":driver", - ":frontend", - ":lex", - ":rewrite", - ":static_analyzer_checkers_gen", - ":tooling", - ":tooling_core", - "//llvm:Support", - ], -) - -gentbl( - name = "static_analyzer_checkers_gen", - tbl_outs = [( - "-gen-clang-sa-checkers", - "include/clang/StaticAnalyzer/Checkers/Checkers.inc", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/StaticAnalyzer/Checkers/Checkers.td", - td_srcs = [ - "include/clang/StaticAnalyzer/Checkers/CheckerBase.td", - "include/clang/StaticAnalyzer/Checkers/Checkers.td", - ], -) - -cc_library( - name = "static_analyzer_checkers", - srcs = glob([ - "lib/StaticAnalyzer/Checkers/**/*.cpp", - "lib/StaticAnalyzer/Checkers/**/*.h", - ]), - hdrs = [ - "include/clang/StaticAnalyzer/Checkers/Checkers.inc", - ] + glob([ - "include/clang/StaticAnalyzer/Checkers/**/*.h", - ]), - copts = ["$(STACK_FRAME_UNLIMITED)"], - includes = ["include"], - deps = [ - ":analysis", - ":ast", - ":ast_matchers", - ":basic", - ":driver", - ":lex", - ":static_analyzer_checkers_gen", - ":static_analyzer_core", - "//llvm:Support", - ], -) - -gentbl( - name = "driver_options_inc_gen", - tbl_outs = [( - "-gen-opt-parser-defs", - "include/clang/Driver/Options.inc", - )], - tblgen = "//llvm:llvm-tblgen", - td_file = "include/clang/Driver/Options.td", - td_srcs = [ - "//llvm:include/llvm/Option/OptParser.td", - ], -) - -cc_library( - name = "driver", - srcs = glob( - [ - "lib/Driver/*.cpp", - "lib/Driver/*.h", - "lib/Driver/Arch/*.cpp", - "lib/Driver/Arch/*.h", - "lib/Driver/ToolChains/*.cpp", - "lib/Driver/ToolChains/*.h", - "lib/Driver/ToolChains/Arch/*.cpp", - "lib/Driver/ToolChains/Arch/*.h", - ], - exclude = [ - "lib/Driver/ToolChains/MSVCSetupApi.h", - ], - ), - hdrs = glob([ - "include/clang/Driver/*.h", - ]), - copts = ["$(STACK_FRAME_UNLIMITED)"], - includes = [ - "include", - # TODO: This is likely a layering issue, but files in Arch are currently - # directly #including "Tools.h". - "lib/Driver", - ], - linkopts = select({ - "@platforms//os:windows": ["version.lib"], - "//conditions:default": [], - }), - textual_hdrs = glob([ - "include/clang/Driver/*.def", - ]), - deps = [ - ":ast", - ":basic", - ":config", - ":driver_options_inc_gen", - ":parse", - ":static_analyzer_checkers_gen", - "//llvm:BinaryFormat", - "//llvm:FrontendDebug", - "//llvm:Instrumentation", - "//llvm:MC", - "//llvm:Object", - "//llvm:Option", - "//llvm:ProfileData", - "//llvm:Support", - "//llvm:Target", - "//llvm:TargetParser", - "//llvm:WindowsDriver", - "//llvm:config", - ], -) - -gentbl( - name = "headers_arm_neon_gen", - tbl_outs = [( - "-gen-arm-neon", - "lib/Headers/arm_neon.h", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/arm_neon.td", - td_srcs = [ - "include/clang/Basic/arm_neon.td", - "include/clang/Basic/arm_neon_incl.td", - ], -) - -gentbl( - name = "headers_arm_fp16_gen", - tbl_outs = [( - "-gen-arm-fp16", - "lib/Headers/arm_fp16.h", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/arm_fp16.td", - td_srcs = [ - "include/clang/Basic/arm_fp16.td", - "include/clang/Basic/arm_neon_incl.td", - ], -) - -gentbl( - name = "headers_arm_mve_gen", - tbl_outs = [( - "-gen-arm-mve-header", - "lib/Headers/arm_mve.h", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/arm_mve.td", - td_srcs = [ - "include/clang/Basic/arm_mve.td", - "include/clang/Basic/arm_mve_defs.td", - ], -) - -gentbl( - name = "headers_arm_cde_gen", - tbl_outs = [( - "-gen-arm-cde-header", - "lib/Headers/arm_cde.h", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/arm_cde.td", - td_srcs = [ - "include/clang/Basic/arm_cde.td", - "include/clang/Basic/arm_mve_defs.td", - ], -) - -gentbl( - name = "headers_arm_sve_gen", - tbl_outs = [( - "-gen-arm-sve-header", - "lib/Headers/arm_sve.h", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/arm_sve.td", - td_srcs = [ - "include/clang/Basic/arm_sve.td", - "include/clang/Basic/arm_sve_sme_incl.td", - ], -) - -gentbl( - name = "headers_arm_bf16_gen", - tbl_outs = [( - "-gen-arm-bf16", - "lib/Headers/arm_bf16.h", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/arm_bf16.td", - td_srcs = [ - "include/clang/Basic/arm_bf16.td", - "include/clang/Basic/arm_neon_incl.td", - ], -) - -gentbl( - name = "headers_arm_sme_gen", - copts = [ - "-Wno-implicit-fallthrough", - "-Wno-error=frame-larger-than=", - ], - tbl_outs = [( - "-gen-arm-sme-header", - "lib/Headers/arm_sme.h", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/arm_sme.td", - td_srcs = [ - "include/clang/Basic/arm_sme.td", - "include/clang/Basic/arm_sve_sme_incl.td", - ], -) - -gentbl( - name = "headers_arm_vector_type_gen", - tbl_outs = [( - "-gen-arm-vector-type", - "lib/Headers/arm_vector_types.h", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/arm_neon.td", - td_srcs = [ - "include/clang/Basic/arm_neon.td", - "include/clang/Basic/arm_neon_incl.td", - ], -) - -gentbl( - name = "headers_riscv_vector", - tbl_outs = [( - "-gen-riscv-vector-header", - "lib/Headers/riscv_vector.h", - )], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/riscv_vector.td", - td_srcs = [ - "include/clang/Basic/riscv_vector.td", - "include/clang/Basic/riscv_vector_common.td", - ], -) - -# We generate the set of builtin headers under a special subdirectory in the -# 'bin' section of the bazel output so that they can be used as data -# dependencies. It requires listing explicitly all the generated inputs here. -builtin_headers = glob( - ["lib/Headers/**/*.h"], - exclude = [ - # FIXME: They are not handled in CMake side. - "lib/Headers/openmp_wrappers/stdlib.h", - "lib/Headers/openmp_wrappers/time.h", - "lib/Headers/ppc_wrappers/nmmintrin.h", - ], -) + [ - "lib/Headers/arm_cde.h", - "lib/Headers/arm_fp16.h", - "lib/Headers/arm_mve.h", - "lib/Headers/arm_neon.h", - "lib/Headers/arm_sve.h", - "lib/Headers/arm_sme.h", - "lib/Headers/arm_vector_types.h", - "lib/Headers/arm_bf16.h", - "lib/Headers/module.modulemap", - "lib/Headers/riscv_vector.h", - "lib/Headers/cuda_wrappers/algorithm", - "lib/Headers/cuda_wrappers/complex", - "lib/Headers/cuda_wrappers/new", - "lib/Headers/openmp_wrappers/cmath", - "lib/Headers/openmp_wrappers/complex", - "lib/Headers/openmp_wrappers/new", -] - -genrule( - name = "builtin_headers_gen", - srcs = builtin_headers, - outs = [hdr.replace("lib/Headers/", "staging/include/") for hdr in builtin_headers], - cmd = """ - for src in $(SRCS); do - relsrc=$${src#*"$(WORKSPACE_ROOT)"/clang/lib/Headers} - target=$(@D)/staging/include/$$relsrc - mkdir -p $$(dirname $$target) - cp $$src $$target - done""", - output_to_bindir = 1, - toolchains = [ - ":workspace_root", - ], -) - -cc_library( - name = "frontend", - srcs = glob([ - "lib/Frontend/*.cpp", - "lib/Frontend/*.h", - ]), - hdrs = glob([ - "include/clang/Frontend/*.h", - ]), - copts = ["$(STACK_FRAME_UNLIMITED)"], - data = [":builtin_headers_gen"], - includes = ["include"], - textual_hdrs = glob([ - "include/clang/Frontend/*.def", - ]), - deps = [ - ":apinotes", - ":ast", - ":basic", - ":config", - ":driver", - ":driver_options_inc_gen", - ":edit", - ":lex", - ":parse", - ":sema", - ":serialization", - ":static_analyzer_core_options", - "//llvm:BinaryFormat", - "//llvm:BitReader", - "//llvm:BitstreamReader", - "//llvm:BitstreamWriter", - "//llvm:Core", - "//llvm:FrontendDebug", - "//llvm:Linker", - "//llvm:MC", - "//llvm:Option", - "//llvm:ProfileData", - "//llvm:Remarks", - "//llvm:Support", - "//llvm:Target", - "//llvm:TargetParser", - "//llvm:TextAPI", - "//llvm:config", - ], -) - -cc_library( - name = "frontend_rewrite", - srcs = glob([ - "lib/Frontend/Rewrite/*.cpp", - "lib/Frontend/Rewrite/*.h", - ]), - hdrs = glob(["include/clang/Rewrite/Frontend/*.h"]), - includes = ["include"], - deps = [ - ":ast", - ":basic", - ":config", - ":edit", - ":frontend", - ":lex", - ":parse", - ":rewrite", - ":serialization", - "//llvm:Support", - ], -) - -cc_library( - name = "interpreter", - srcs = glob([ - "lib/Interpreter/*.cpp", - "lib/Interpreter/*.h", - ]), - hdrs = glob(["include/clang/Interpreter/*.h"]), - includes = ["include"], - deps = [ - ":analysis", - ":ast", - ":basic", - ":codegen", - ":driver", - ":edit", - ":frontend", - ":frontend_tool", - ":lex", - ":parse", - ":sema", - ":serialization", - "//llvm:AllTargetsAsmParsers", - "//llvm:AllTargetsCodeGens", - "//llvm:Core", - "//llvm:ExecutionEngine", - "//llvm:MC", - "//llvm:Option", - "//llvm:OrcDebugging", - "//llvm:OrcJIT", - "//llvm:OrcShared", - "//llvm:OrcTargetProcess", - "//llvm:Support", - "//llvm:Target", - "//llvm:TargetParser", - ], -) - -cc_library( - name = "codegen", - srcs = glob([ - "lib/CodeGen/**/*.cpp", - "lib/CodeGen/**/*.h", - ]), - hdrs = glob(["include/clang/CodeGen/*.h"]), - copts = ["$(STACK_FRAME_UNLIMITED)"], - includes = [ - "include", - "lib/CodeGen", - ], - deps = [ - ":analysis", - ":ast", - ":basic", - ":basic_arm_cde_cg_gen", - ":basic_arm_sme_builtin_cg_gen", - ":basic_arm_sve_builtin_cg_gen", - ":basic_riscv_sifive_vector_builtin_cg_gen", - ":basic_riscv_vector_builtin_cg_gen", - ":driver", - ":frontend", - ":lex", - ":sema", - ":type_nodes_gen", - "//llvm:AllTargetsAsmParsers", - "//llvm:Analysis", - "//llvm:BinaryFormat", - "//llvm:BitReader", - "//llvm:BitWriter", - "//llvm:BitstreamReader", - "//llvm:CodeGen", - "//llvm:CodeGenTypes", - "//llvm:Core", - "//llvm:Coroutines", - "//llvm:Coverage", - "//llvm:DebugInfoDWARF", - "//llvm:Demangle", - "//llvm:FrontendDriver", - "//llvm:FrontendHLSL", - "//llvm:FrontendOffloading", - "//llvm:FrontendOpenMP", - "//llvm:HipStdPar", - "//llvm:IPO", - "//llvm:IRPrinter", - "//llvm:IRReader", - "//llvm:InstCombine", - "//llvm:Instrumentation", - "//llvm:LTO", - "//llvm:Linker", - "//llvm:MC", - "//llvm:ObjCARC", - "//llvm:Object", - "//llvm:Passes", - "//llvm:ProfileData", - "//llvm:Scalar", - "//llvm:Support", - "//llvm:Target", - "//llvm:TargetParser", - "//llvm:TransformUtils", - ], -) - -cc_library( - name = "static_analyzer_frontend", - srcs = glob([ - "lib/StaticAnalyzer/Frontend/**/*.cpp", - "lib/StaticAnalyzer/Frontend/**/*.h", - ]), - hdrs = glob(["include/clang/StaticAnalyzer/Frontend/**/*.h"]), - includes = ["include"], - deps = [ - ":analysis", - ":ast", - ":basic", - ":crosstu", - ":driver", - ":frontend", - ":lex", - ":rewrite", - ":serialization", - ":static_analyzer_checkers", - ":static_analyzer_core", - ":tooling", - ":tooling_core", - "//llvm:Support", - ], -) - -gentbl( - name = "serialization_attr_gen", - tbl_outs = [ - ( - "-gen-clang-attr-pch-read", - "include/clang/Serialization/AttrPCHRead.inc", - ), - ( - "-gen-clang-attr-pch-write", - "include/clang/Serialization/AttrPCHWrite.inc", - ), - ], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/Attr.td", - td_srcs = [ - "include/clang/Basic/ASTNode.td", - "include/clang/Basic/Attr.td", - "include/clang/Basic/AttrDocs.td", - "include/clang/Basic/DeclNodes.td", - "include/clang/Basic/StmtNodes.td", - ], -) - -cc_library( - name = "support", - srcs = glob([ - "lib/Support/*.cpp", - ]), - hdrs = glob([ - "include/clang/Support/*.h", - ]), - includes = ["include"], - deps = [ - "//llvm:Support", - ], -) - -cc_library( - name = "install_api", - srcs = glob([ - "lib/InstallAPI/*.cpp", - ]), - hdrs = glob([ - "include/clang/InstallAPI/*.h", - ]), - includes = ["include"], - deps = [ - ":ast", - ":basic", - ":frontend", - ":support", - "//llvm:Core", - "//llvm:Support", - "//llvm:TextAPI", - ], -) - -cc_library( - name = "serialization", - srcs = [ - "include/clang/Serialization/AttrPCHRead.inc", - "include/clang/Serialization/AttrPCHWrite.inc", - ] + glob([ - "include/clang/Frontend/*.h", - "lib/Serialization/*.cpp", - "lib/Serialization/*.h", - ]), - hdrs = glob([ - "include/clang/Serialization/*.h", - ]), - includes = ["include"], - textual_hdrs = glob([ - "include/clang/Serialization/*.def", - ]), - deps = [ - ":apinotes", - ":ast", - ":basic", - ":driver", - ":lex", - ":sema", - ":serialization_attr_gen", - ":static_analyzer_core_options", - ":type_nodes_gen", - "//llvm:BitReader", - "//llvm:BitWriter", - "//llvm:BitstreamReader", - "//llvm:BitstreamWriter", - "//llvm:FrontendOpenMP", - "//llvm:Support", - "//llvm:TargetParser", - ], -) - -cc_library( - name = "frontend_tool", - srcs = glob([ - "lib/FrontendTool/*.cpp", - "lib/FrontendTool/*.h", - ]), - hdrs = glob(["include/clang/FrontendTool/*.h"]), - includes = ["include"], - deps = [ - ":arc_migrate", - ":codegen", - ":config", - ":driver", - ":extract_api", - ":frontend", - ":frontend_rewrite", - ":static_analyzer_frontend", - "//llvm:Option", - "//llvm:Support", - ], -) - -cc_library( - name = "arc_migrate", - srcs = glob([ - "lib/ARCMigrate/*.cpp", - "lib/ARCMigrate/*.h", - ]), - hdrs = glob(["include/clang/ARCMigrate/*.h"]), - includes = ["include"], - deps = [ - ":analysis", - ":ast", - ":basic", - ":edit", - ":frontend", - ":frontend_rewrite", - ":lex", - ":parse", - ":rewrite", - ":sema", - ":serialization", - ":static_analyzer_checkers", - ":static_analyzer_core", - "//llvm:Support", - "//llvm:TargetParser", - ], -) - -cc_library( - name = "libclang_static", - srcs = glob([ - "tools/libclang/*.cpp", - "tools/libclang/*.h", - ]), - hdrs = glob(["include/clang-c/*.h"]), - defines = ["CINDEX_NO_EXPORTS"], - deps = [ - ":arc_migrate", - ":ast", - ":basic", - ":codegen", - ":config", - ":driver", - ":extract_api", - ":frontend", - ":index", - ":lex", - ":rewrite", - ":sema", - ":tooling", - "//llvm:BitstreamReader", - "//llvm:FrontendOpenMP", - "//llvm:Support", - "//llvm:config", - ], -) - -cc_plugin_library( - name = "libclang", - srcs = glob([ - "tools/libclang/*.cpp", - "tools/libclang/*.h", - ]), - hdrs = glob(["include/clang-c/*.h"]), - copts = select({ - "@platforms//os:windows": ["-D_CINDEX_LIB_"], - "//conditions:default": [], - }), - strip_include_prefix = "include", - deps = [ - ":arc_migrate", - ":ast", - ":basic", - ":codegen", - ":config", - ":driver", - ":extract_api", - ":frontend", - ":index", - ":lex", - ":rewrite", - ":sema", - ":tooling", - "//llvm:BitstreamReader", - "//llvm:FrontendOpenMP", - "//llvm:Support", - "//llvm:config", - ], -) - -filegroup( - name = "python-sources", - srcs = [ - "bindings/python/clang/cindex.py", - "bindings/python/clang/enumerations.py", - ], -) - -filegroup( - name = "python-cindex-examples", - srcs = [ - "bindings/python/examples/cindex/cindex-dump.py", - "bindings/python/examples/cindex/cindex-includes.py", - ], -) - -cc_binary( - name = "c-index-test", - testonly = 1, - srcs = [ - "tools/c-index-test/c-index-test.c", - "tools/c-index-test/core_main.cpp", - ], - copts = [ - "-Wno-uninitialized", - ], - stamp = 0, - deps = [ - ":ast", - ":basic", - ":codegen", - ":config", - ":frontend", - ":index", - ":lex", - ":libclang", - ":serialization", - "//llvm:Core", - "//llvm:MC", - "//llvm:Support", - ], -) - -cc_library( - name = "apinotes", - srcs = glob([ - "lib/APINotes/*.cpp", - "lib/APINotes/*.h", - ]), - hdrs = glob(["include/clang/APINotes/*.h"]), - deps = [ - ":basic", - "//llvm:BitWriter", - "//llvm:BitstreamReader", - "//llvm:BitstreamWriter", - "//llvm:Support", - ], -) - -cc_binary( - name = "arcmt-test", - testonly = 1, - srcs = ["tools/arcmt-test/arcmt-test.cpp"], - stamp = 0, - deps = [ - ":arc_migrate", - ":ast", - ":basic", - ":frontend", - ":frontend_rewrite", - ":lex", - "//llvm:Support", - ], -) - -cc_binary( - name = "c-arcmt-test", - testonly = 1, - srcs = ["tools/c-arcmt-test/c-arcmt-test.c"], - copts = select({ - "@platforms//os:windows": [], - "//conditions:default": ["-std=gnu99"], - }), - stamp = 0, - deps = [ - ":codegen", - ":libclang", - "//llvm:MC", - "//llvm:Support", - ], -) - -cc_binary( - name = "clang-import-test", - testonly = 1, - srcs = glob([ - "tools/clang-import-test/*.cpp", - "tools/clang-import-test/*.h", - ]), - stamp = 0, - deps = [ - ":ast", - ":basic", - ":codegen", - ":driver", - ":frontend", - ":lex", - ":parse", - "//llvm:Core", - "//llvm:Support", - "//llvm:TargetParser", - ], -) - -expand_template( - name = "clang_main", - out = "clang-driver.cpp", - substitutions = { - "@TOOL_NAME@": "clang", - }, - template = "//llvm:cmake/modules/llvm-driver-template.cpp.in", -) - -cc_library( - name = "clang-driver", - srcs = glob([ - "tools/driver/*.cpp", - "tools/driver/*.h", - ]) + ["clang-driver.cpp"], - copts = [ - # Disable stack frame size checks in the driver because - # clang::ensureStackAddressSpace allocates a large array on the stack. - "$(STACK_FRAME_UNLIMITED)", - ], - deps = [ - ":analysis", - ":ast", - ":basic", - ":codegen", - ":config", - ":driver", - ":frontend", - ":frontend_rewrite", - ":frontend_tool", - ":lex", - ":parse", - ":sema", - ":serialization", - ":static_analyzer_frontend", - "//llvm:AllTargetsAsmParsers", - "//llvm:AllTargetsCodeGens", - "//llvm:BitReader", - "//llvm:BitWriter", - "//llvm:CodeGen", - "//llvm:Core", - "//llvm:IPO", - "//llvm:MC", - "//llvm:MCParser", - "//llvm:Option", - "//llvm:Support", - "//llvm:Target", - "//llvm:TargetParser", - "//llvm:config", - ], -) - -cc_binary( - name = "clang", - srcs = [], - stamp = 0, - deps = [ - ":clang-driver", - ], -) - -cc_binary( - name = "diagtool", - srcs = glob([ - "tools/diagtool/*.cpp", - "tools/diagtool/*.h", - ]), - stamp = 0, - deps = [ - ":basic", - ":frontend", - ":lex", - ":sema", - "//llvm:Support", - ], -) - -filegroup( - name = "exploded_graph_rewriter", - testonly = 1, - data = ["utils/analyzer/exploded-graph-rewriter.py"], -) - -filegroup( - name = "module-deps-to-rsp", - testonly = 1, - data = ["utils/module-deps-to-rsp.py"], -) - -filegroup( - name = "hmaptool", - testonly = 1, - data = ["utils/hmaptool/hmaptool"], -) - -binary_alias( - name = "clang++", - binary = ":clang", -) - -cc_binary( - name = "clang-check", - srcs = ["tools/clang-check/ClangCheck.cpp"], - stamp = 0, - deps = [ - ":ast", - ":codegen", - ":driver", - ":frontend", - ":frontend_rewrite", - ":serialization", - ":static_analyzer_frontend", - ":tooling", - ":tooling_syntax", - "//llvm:Option", - "//llvm:Support", - ], -) - -cc_binary( - name = "clang-format", - srcs = [ - "lib/Format/MatchFilePath.h", - "tools/clang-format/ClangFormat.cpp", - ], - stamp = 0, - deps = [ - ":basic", - ":format", - ":frontend", - ":rewrite", - "//llvm:Support", - ], -) - -cc_binary( - name = "clang-diff", - srcs = glob(["tools/clang-diff/*.cpp"]), - stamp = 0, - deps = [ - ":ast-diff", - ":tooling", - "//llvm:Support", - ], -) - -cc_binary( - name = "clang-offload-bundler", - srcs = glob(["tools/clang-offload-bundler/*.cpp"]), - stamp = 0, - deps = [ - ":basic", - ":driver", - ":tooling", - "//llvm:BitWriter", - "//llvm:Core", - "//llvm:Object", - "//llvm:Support", - "//llvm:TargetParser", - ], -) - -cc_binary( - name = "clang-offload-packager", - srcs = glob(["tools/clang-offload-packager/*.cpp"]), - stamp = 0, - deps = [ - ":basic", - "//llvm:BinaryFormat", - "//llvm:Object", - "//llvm:Support", - ], -) - -gentbl( - name = "linker_wrapper_opts_gen", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/clang-linker-wrapper/LinkerWrapperOpts.inc", - )], - tblgen = "//llvm:llvm-tblgen", - td_file = "tools/clang-linker-wrapper/LinkerWrapperOpts.td", - td_srcs = [ - "tools/clang-linker-wrapper/LinkerWrapperOpts.td", - "//llvm:include/llvm/Option/OptParser.td", - ], -) - -cc_binary( - name = "clang-linker-wrapper", - srcs = [ - "tools/clang-linker-wrapper/ClangLinkerWrapper.cpp", - ], - copts = [ - "-I$(GENDIR)/$(WORKSPACE_ROOT)/clang/tools/clang-linker-wrapper", - ], - stamp = 0, - toolchains = [ - ":workspace_root", - ], - deps = [ - ":basic", - ":linker_wrapper_opts_gen", - "//llvm:AllTargetsAsmParsers", - "//llvm:Analysis", - "//llvm:BinaryFormat", - "//llvm:BitWriter", - "//llvm:CodeGen", - "//llvm:Core", - "//llvm:FrontendOffloading", - "//llvm:IRReader", - "//llvm:LTO", - "//llvm:MC", - "//llvm:Object", - "//llvm:Option", - "//llvm:Passes", - "//llvm:Support", - "//llvm:Target", - "//llvm:TargetParser", - "//llvm:TransformUtils", - ], -) - -cc_binary( - name = "clang-refactor", - srcs = glob([ - "tools/clang-refactor/*.cpp", - "tools/clang-refactor/*.h", - ]), - stamp = 0, - deps = [ - ":ast", - ":basic", - ":format", - ":frontend", - ":lex", - ":rewrite", - ":tooling", - ":tooling_refactoring", - "//llvm:Support", - ], -) - -cc_binary( - name = "clang-rename", - srcs = glob(["tools/clang-rename/*.cpp"]), - stamp = 0, - deps = [ - ":basic", - ":frontend", - ":rewrite", - ":tooling", - ":tooling_refactoring", - "//llvm:Support", - ], -) - -cc_binary( - name = "clang-repl", - srcs = glob(["tools/clang-repl/*.cpp"]), - stamp = 0, - deps = [ - ":basic", - ":frontend", - ":interpreter", - ":lex", - ":sema", - ":tooling", - "//llvm:Core", - "//llvm:LineEditor", - "//llvm:Option", - "//llvm:OrcJIT", - "//llvm:Support", - ], -) - -cc_binary( - name = "clang-extdef-mapping", - srcs = glob(["tools/clang-extdef-mapping/*.cpp"]), - stamp = 0, - deps = [ - ":ast", - ":basic", - ":crosstu", - ":frontend", - ":tooling", - "//llvm:Support", - ], -) - -gentbl( - name = "ScanDepsTableGen", - strip_include_prefix = "tools/clang-scan-deps", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/clang-scan-deps/Opts.inc", - )], - tblgen = "//llvm:llvm-tblgen", - td_file = "tools/clang-scan-deps/Opts.td", - td_srcs = ["//llvm:include/llvm/Option/OptParser.td"], -) - -expand_template( - name = "clang-scan-deps-main", - out = "clang-scan-deps-driver.cpp", - substitutions = { - "@TOOL_NAME@": "clang_scan_deps", - }, - template = "//llvm:cmake/modules/llvm-driver-template.cpp.in", -) - -cc_binary( - name = "clang-scan-deps", - srcs = glob(["tools/clang-scan-deps/*.cpp"]) + ["clang-scan-deps-driver.cpp"], - stamp = 0, - deps = [ - ":ScanDepsTableGen", - ":driver", - ":frontend", - ":tooling", - ":tooling_dependency_scanning", - "//llvm:Support", - "//llvm:TargetParser", - ], -) - -cc_library( - name = "extract_api", - srcs = glob([ - "lib/ExtractAPI/**/*.cpp", - "lib/ExtractAPI/**/*.h", - ]), - hdrs = glob(["include/clang/ExtractAPI/**/*.h"]), - includes = ["include"], - deps = [ - ":ast", - ":basic", - ":frontend", - ":index", - ":install_api", - ":lex", - "//llvm:Option", - "//llvm:Support", - "//llvm:TargetParser", - ], -) diff --git a/utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h b/utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h deleted file mode 100644 index ac0d9eb24931f1..00000000000000 --- a/utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h +++ /dev/null @@ -1,116 +0,0 @@ -/*===------- clang/Config/config.h - llvm configuration -----------*- C -*-===*/ -/* */ -/* Part of the LLVM Project, under the Apache License v2.0 with LLVM */ -/* Exceptions. */ -/* See https://llvm.org/LICENSE.txt for license information. */ -/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ -/* */ -/*===----------------------------------------------------------------------===*/ - -/* This is a manual port of config.h.cmake for the symbols that do not change - based on platform. Those that do change should not be defined here and - instead use Bazel cc_library defines. Some attempt has been made to extract - such symbols that do vary based on platform (for the platforms we care about) - into Bazel defines, but it is by no means complete, so if you see something - that looks wrong, it probably is. */ - -#ifdef CLANG_CONFIG_H -#error config.h can only be included once -#else -#define CLANG_CONFIG_H - -/* Bug report URL. */ -#define BUG_REPORT_URL "https://github.com/llvm/llvm-project/issues/" - -/* Default to -fPIE and -pie on Linux. */ -#define CLANG_DEFAULT_PIE_ON_LINUX 1 - -/* Default linker to use. */ -#define CLANG_DEFAULT_LINKER "" - -/* Default C++ stdlib to use. */ -#define CLANG_DEFAULT_CXX_STDLIB "" - -/* Default runtime library to use. */ -#define CLANG_DEFAULT_RTLIB "" - -/* Default unwind library to use. */ -#define CLANG_DEFAULT_UNWINDLIB "" - -/* Default objcopy to use */ -#define CLANG_DEFAULT_OBJCOPY "objcopy" - -/* Default OpenMP runtime used by -fopenmp. */ -#define CLANG_DEFAULT_OPENMP_RUNTIME "libomp" - -/* Default architecture for SystemZ. */ -#define CLANG_SYSTEMZ_DEFAULT_ARCH "z10" - -/* Multilib basename for libdir. */ -#define CLANG_INSTALL_LIBDIR_BASENAME "lib" - -/* Relative directory for resource files */ -#define CLANG_RESOURCE_DIR "" - -/* Directories clang will search for headers */ -#define C_INCLUDE_DIRS "" - -/* Directories clang will search for configuration files */ -/* #undef CLANG_CONFIG_FILE_SYSTEM_DIR */ -/* #undef CLANG_CONFIG_FILE_USER_DIR */ - -/* Default to all compiler invocations for --sysroot=. */ -#define DEFAULT_SYSROOT "" - -/* Directory where gcc is installed. */ -#define GCC_INSTALL_PREFIX "" - -/* Define if we have libxml2 */ -/* #undef CLANG_HAVE_LIBXML */ - -/* Define if we have sys/resource.h (rlimits) */ -/* CLANG_HAVE_RLIMITS defined conditionally below */ - -/* Define if we have dlfcn.h */ -#define CLANG_HAVE_DLFCN_H 1 - -/* Define if dladdr() is available on this platform. */ -#define CLANG_HAVE_DLADDR 1 - -/* Linker version detected at compile time. */ -/* #undef HOST_LINK_VERSION */ - -/* pass --build-id to ld */ -/* #undef ENABLE_LINKER_BUILD_ID */ - -/* enable x86 relax relocations by default */ -#define ENABLE_X86_RELAX_RELOCATIONS 1 - -/* enable IEEE binary128 as default long double format on PowerPC Linux. */ -#define PPC_LINUX_DEFAULT_IEEELONGDOUBLE 0 - -/* Enable the experimental new pass manager by default */ -#define ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER 0 - -/* Enable each functionality of modules */ -#define CLANG_ENABLE_ARCMT 1 -#define CLANG_ENABLE_OBJC_REWRITER 1 -#define CLANG_ENABLE_STATIC_ANALYZER 1 - -/* Spawn a new process clang.exe for the CC1 tool invocation, when necessary */ -#define CLANG_SPAWN_CC1 0 - -/* Whether to enable opaque pointers by default */ -#define CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL 1 - -/* Directly provide definitions here behind platform preprocessor definitions. - * The preprocessor conditions are sufficient to handle all of the configuration - * on platforms targeted by Bazel, and defining these here more faithfully - * matches how the users of this header expect things to work with CMake. - */ - -#ifndef _WIN32 -#define CLANG_HAVE_RLIMITS 1 -#endif - -#endif diff --git a/utils/bazel/llvm-project-overlay/clang/unittests/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang/unittests/BUILD.bazel deleted file mode 100644 index 9823027b766c22..00000000000000 --- a/utils/bazel/llvm-project-overlay/clang/unittests/BUILD.bazel +++ /dev/null @@ -1,551 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -package( - default_visibility = ["//visibility:public"], -) - -licenses(["notice"]) - -cc_test( - name = "ast_tests", - size = "medium", - srcs = glob( - [ - "AST/*.cpp", - "AST/*.h", - ], - allow_empty = False, - ), - shard_count = 20, - deps = [ - "//clang:ast", - "//clang:ast_matchers", - "//clang:basic", - "//clang:frontend", - "//clang:lex", - "//clang:testing", - "//clang:tooling", - "//llvm:Core", - "//llvm:Support", - "//llvm:TargetParser", - "//llvm:TestingAnnotations", - "//llvm:TestingSupport", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_library( - name = "ast_matchers_tests_hdrs", - testonly = 1, - hdrs = glob( - ["ASTMatchers/*.h"], - allow_empty = False, - ), - deps = [ - "//clang:ast_matchers", - "//clang:frontend", - "//clang:testing", - "//clang:tooling", - "//third-party/unittest:gtest", - ], -) - -cc_test( - name = "ast_matchers_tests", - size = "medium", - srcs = glob( - ["ASTMatchers/*.cpp"], - allow_empty = False, - ), - shard_count = 20, - deps = [ - ":ast_matchers_tests_hdrs", - "//clang:ast", - "//clang:ast_matchers", - "//clang:frontend", - "//clang:tooling", - "//llvm:Support", - "//llvm:TargetParser", - "//llvm:TestingSupport", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "ast_matchers_dynamic_tests", - size = "small", - srcs = glob( - ["ASTMatchers/Dynamic/*.cpp"], - allow_empty = False, - ), - deps = [ - ":ast_matchers_tests_hdrs", - "//clang:ast_matchers", - "//clang:ast_matchers_dynamic", - "//clang:frontend", - "//clang:tooling", - "//llvm:Support", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "analysis_tests", - size = "small", - srcs = glob( - [ - "Analysis/*.cpp", - "Analysis/*.h", - ], - allow_empty = False, - ), - deps = [ - "//clang:analysis", - "//clang:ast", - "//clang:ast_matchers", - "//clang:basic", - "//clang:lex", - "//clang:parse", - "//clang:tooling", - "//llvm:Support", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "analysis_flow_sensitive_tests", - srcs = glob( - [ - "Analysis/FlowSensitive/*.cpp", - "Analysis/FlowSensitive/*.h", - ], - allow_empty = False, - ), - deps = [ - "//clang:analysis", - "//clang:ast", - "//clang:ast_matchers", - "//clang:basic", - "//clang:frontend", - "//clang:lex", - "//clang:serialization", - "//clang:testing", - "//clang:tooling", - "//llvm:Support", - "//llvm:TestingADT", - "//llvm:TestingAnnotations", - "//llvm:TestingSupport", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "basic_tests", - size = "small", - srcs = glob( - ["Basic/*.cpp"], - allow_empty = False, - ), - deps = [ - "//clang:basic", - "//clang:frontend", - "//clang:lex", - "//llvm:Support", - "//llvm:TestingSupport", - "//llvm:config", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "codegen_tests", - size = "small", - srcs = glob( - [ - "CodeGen/*.cpp", - "CodeGen/*.h", - ], - allow_empty = False, - ), - deps = [ - "//clang:ast", - "//clang:basic", - "//clang:codegen", - "//clang:frontend", - "//clang:lex", - "//clang:parse", - "//clang:sema", - "//llvm:Core", - "//llvm:Support", - "//llvm:TargetParser", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "format_tests", - size = "medium", - srcs = glob( - [ - "Format/*.cpp", - "Format/*.h", - "Tooling/*.h", - ], - allow_empty = False, - ), - copts = ["$(STACK_FRAME_UNLIMITED)"], - features = ["-layering_check"], # #include "../../lib/Format/TokenAnalyzer.h" - shard_count = 20, - deps = [ - "//clang:basic", - "//clang:format", - "//clang:frontend", - "//clang:rewrite", - "//clang:tooling_core", - "//llvm:Support", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "frontend_tests", - size = "small", - srcs = glob( - ["Frontend/*.cpp"], - allow_empty = False, - ), - deps = [ - "//clang:ast", - "//clang:basic", - "//clang:codegen", - "//clang:driver_options_inc_gen", - "//clang:frontend", - "//clang:frontend_tool", - "//clang:lex", - "//clang:sema", - "//clang:serialization", - "//llvm:Support", - "//llvm:TargetParser", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "lex_tests", - size = "small", - srcs = glob( - [ - "Lex/*.cpp", - "Lex/*.h", - ], - allow_empty = False, - ), - copts = ["$(STACK_FRAME_UNLIMITED)"], - deps = [ - "//clang:ast", - "//clang:basic", - "//clang:frontend", - "//clang:lex", - "//clang:parse", - "//clang:sema", - "//clang:serialization", - "//llvm:Support", - "//llvm:TestingAnnotations", - "//llvm:TestingSupport", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -# A library to carefully expose the tooling headers using the include prefix -# expected by the `rename_tests`. -cc_library( - name = "rename_tests_tooling_hdrs", - testonly = 1, - hdrs = glob( - ["Tooling/*.h"], - allow_empty = False, - ), - include_prefix = "unittests", - deps = [ - "//clang:ast", - "//clang:basic", - "//clang:frontend", - "//clang:rewrite", - "//clang:tooling", - "//clang:tooling_core", - "//llvm:Support", - "//third-party/unittest:gtest", - ], -) - -cc_test( - name = "rename_tests", - size = "small", - timeout = "moderate", - srcs = glob( - [ - "Rename/*.cpp", - "Rename/*.h", - ], - allow_empty = False, - ), - shard_count = 20, - deps = [ - ":rename_tests_tooling_hdrs", - "//clang:ast_matchers", - "//clang:basic", - "//clang:format", - "//clang:frontend", - "//clang:tooling", - "//clang:tooling_refactoring", - "//llvm:Support", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "rewrite_tests", - size = "small", - srcs = glob( - ["Rewrite/*.cpp"], - allow_empty = False, - ), - deps = [ - "//clang:rewrite", - "//clang:tooling", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "sema_tests", - size = "small", - srcs = glob( - ["Sema/*.cpp"], - allow_empty = False, - ), - deps = [ - ":ast_matchers_tests_hdrs", - "//clang:ast", - "//clang:ast_matchers", - "//clang:frontend", - "//clang:lex", - "//clang:parse", - "//clang:sema", - "//clang:tooling", - "//llvm:TestingAnnotations", - "//llvm:TestingSupport", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_library( - name = "static_analyzer_test_headers", - testonly = 1, - hdrs = glob( - ["StaticAnalyzer/*.h"], - allow_empty = False, - ), - deps = [ - "//clang:ast_matchers", - "//clang:crosstu", - "//clang:frontend", - "//clang:static_analyzer_core", - "//clang:static_analyzer_frontend", - "//clang:testing", - "//clang:tooling", - "//third-party/unittest:gtest", - ], -) - -cc_test( - name = "static_analyzer_tests", - size = "small", - srcs = glob( - ["StaticAnalyzer/*.cpp"], - allow_empty = False, - exclude = [ - # New test has unused-variable warnings. - "StaticAnalyzer/ParamRegionTest.cpp", - ], - ), - deps = [ - ":static_analyzer_test_headers", - "//clang:analysis", - "//clang:ast", - "//clang:ast_matchers", - "//clang:basic", - "//clang:frontend", - "//clang:static_analyzer_core", - "//clang:static_analyzer_frontend", - "//clang:testing", - "//clang:tooling", - "//llvm:Support", - "//llvm:config", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "tooling_tests", - size = "medium", - srcs = glob( - [ - "Tooling/*.cpp", - "Tooling/*.h", - ], - allow_empty = False, - ), - shard_count = 20, - deps = [ - "//clang:ast", - "//clang:ast_matchers", - "//clang:basic", - "//clang:driver", - "//clang:format", - "//clang:frontend", - "//clang:lex", - "//clang:rewrite", - "//clang:testing", - "//clang:tooling", - "//clang:tooling_core", - "//clang:tooling_dependency_scanning", - "//clang:tooling_inclusions", - "//clang:tooling_refactoring", - "//clang:transformer", - "//llvm:MC", - "//llvm:Support", - "//llvm:TargetParser", - "//llvm:TestingAnnotations", - "//llvm:TestingSupport", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -# A library to carefully expose the tooling headers using the include prefix -# expected by the `tooling_recursive_ast_visitor_tests`. -cc_library( - name = "tooling_recursive_ast_visitor_tests_tooling_hdrs", - testonly = 1, - hdrs = glob( - ["Tooling/*.h"], - allow_empty = False, - ), - strip_include_prefix = "Tooling", - deps = [ - "//clang:ast", - "//clang:basic", - "//clang:frontend", - "//clang:rewrite", - "//clang:tooling", - "//clang:tooling_core", - "//llvm:Support", - "//third-party/unittest:gtest", - ], -) - -cc_test( - name = "tooling_recursive_ast_visitor_tests", - size = "medium", - srcs = glob( - ["Tooling/RecursiveASTVisitorTests/*.cpp"], - allow_empty = False, - ) + [ - "Tooling/RecursiveASTVisitorTests/CallbacksCommon.h", - ], - deps = [ - ":tooling_recursive_ast_visitor_tests_tooling_hdrs", - "//clang:ast", - "//clang:basic", - "//clang:frontend", - "//clang:lex", - "//clang:tooling", - "//clang:tooling_syntax", - "//llvm:Support", - "//llvm:TargetParser", - "//llvm:TestingSupport", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "tooling_syntax_tests", - size = "medium", - srcs = glob( - [ - "Tooling/Syntax/*.cpp", - "Tooling/Syntax/*.h", - ], - allow_empty = False, - ), - shard_count = 20, - deps = [ - "//clang:ast", - "//clang:basic", - "//clang:frontend", - "//clang:lex", - "//clang:testing", - "//clang:tooling", - "//clang:tooling_core", - "//clang:tooling_syntax", - "//llvm:Support", - "//llvm:TestingAnnotations", - "//llvm:TestingSupport", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "libclang_tests", - size = "small", - srcs = glob( - ["libclang/*.cpp"], - allow_empty = False, - ) + [ - "libclang/TestUtils.h", - ], - args = select({ - "@platforms//os:windows": [ - # Need to disable the VFS tests that don't use Windows friendly - # paths. These are also disabled on Windows in the CMake build. - "--gtest_filter=-*VirtualFileOverlay*", - ], - "//conditions:default": [], - }), - deps = [ - "//clang:libclang", - "//llvm:Support", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) diff --git a/utils/bazel/llvm-project-overlay/compiler-rt/BUILD.bazel b/utils/bazel/llvm-project-overlay/compiler-rt/BUILD.bazel deleted file mode 100644 index 9bdd454e1e3641..00000000000000 --- a/utils/bazel/llvm-project-overlay/compiler-rt/BUILD.bazel +++ /dev/null @@ -1,52 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -package( - default_visibility = ["//visibility:public"], - features = ["layering_check"], -) - -licenses(["notice"]) - -cc_library( - name = "config", - defines = select({ - "@platforms//os:linux": [ - "COMPILER_RT_HAS_ATOMICS=1", - "COMPILER_RT_HAS_FCNTL_LCK=1", - "COMPILER_RT_HAS_UNAME=1", - ], - # Will raise error unless supported platforms. - }), -) - -WIN32_ONLY_FILES = [ - "lib/profile/WindowsMMap.c", -] - -cc_library( - name = "profile", - srcs = glob( - [ - "lib/profile/*.c", - "lib/profile/*.cpp", - "lib/profile/*.h", - ], - exclude = WIN32_ONLY_FILES, - ) + select({ - "@platforms//os:windows": WIN32_ONLY_FILES, - "//conditions:default": [], - }), - hdrs = glob([ - "include/profile/*.h", - "include/profile/*.inc", - ]), - includes = [ - "include", - ], - linkstatic = True, - deps = [ - ":config", - ], -) diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel deleted file mode 100644 index 073353a89c8907..00000000000000 --- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel +++ /dev/null @@ -1,3292 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# LLVM libc project. -load("@bazel_skylib//lib:selects.bzl", "selects") -load("@bazel_skylib//rules:common_settings.bzl", "string_flag") -load( - ":libc_build_rules.bzl", - "libc_function", - "libc_math_function", - "libc_support_library", -) -load(":platforms.bzl", "PLATFORM_CPU_ARM64", "PLATFORM_CPU_X86_64") - -package( - default_visibility = ["//visibility:public"], - features = [ - "-use_header_modules", - "-layering_check", - ], -) - -licenses(["notice"]) - -PRINTF_COPTS = [ - "LIBC_COPT_STDIO_USE_SYSTEM_FILE", - "LIBC_COPT_PRINTF_DISABLE_WRITE_INT", -] - -MEMORY_COPTS = [ - # "LIBC_COPT_MEMCPY_X86_USE_REPMOVSB_FROM_SIZE=0", - # "LIBC_COPT_MEMCPY_X86_USE_SOFTWARE_PREFETCHING", - # "LIBC_COPT_MEMSET_X86_USE_SOFTWARE_PREFETCHING", -] - -# A flag to pick which `mpfr` to use for math tests. -# Usage: `--@llvm-project//libc:mpfr=`. -# Flag documentation: https://bazel.build/extending/config -string_flag( - name = "mpfr", - build_setting_default = "external", - values = [ - "disable", # Skip tests that need mpfr - "external", # Build mpfr from source - "system", # Use system mpfr (non hermetic) - ], -) - -config_setting( - name = "mpfr_disable", - flag_values = {":mpfr": "disable"}, -) - -config_setting( - name = "mpfr_external", - flag_values = {":mpfr": "external"}, -) - -config_setting( - name = "mpfr_system", - flag_values = {":mpfr": "system"}, -) - -############################## Support libraries ############################# - -libc_support_library( - name = "__support_macros_properties_architectures", - hdrs = ["src/__support/macros/properties/architectures.h"], -) - -libc_support_library( - name = "__support_macros_properties_compiler", - hdrs = ["src/__support/macros/properties/compiler.h"], -) - -libc_support_library( - name = "__support_macros_properties_os", - hdrs = ["src/__support/macros/properties/os.h"], -) - -libc_support_library( - name = "__support_macros_properties_types", - hdrs = ["src/__support/macros/properties/types.h"], - deps = [ - ":__support_macros_properties_architectures", - ":__support_macros_properties_compiler", - ":__support_macros_properties_cpu_features", - ":__support_macros_properties_os", - ":llvm_libc_macros_float_macros", - ":llvm_libc_types_float128", - ], -) - -libc_support_library( - name = "__support_macros_properties_cpu_features", - hdrs = ["src/__support/macros/properties/cpu_features.h"], - deps = [ - "__support_macros_properties_architectures", - ], -) - -libc_support_library( - name = "__support_macros_config", - hdrs = ["src/__support/macros/config.h"], -) - -libc_support_library( - name = "__support_macros_attributes", - hdrs = ["src/__support/macros/attributes.h"], - deps = [ - ":__support_macros_properties_architectures", - ], -) - -libc_support_library( - name = "__support_macros_optimization", - hdrs = ["src/__support/macros/optimization.h"], - deps = [ - ":__support_macros_attributes", - ":__support_macros_config", - ":__support_macros_properties_compiler", - ], -) - -libc_support_library( - name = "__support_macros_sanitizer", - hdrs = ["src/__support/macros/sanitizer.h"], - deps = [ - ":__support_macros_config", - ], -) - -libc_support_library( - name = "__support_common", - hdrs = [ - "src/__support/common.h", - "src/__support/endian.h", - ], - deps = [ - ":__support_macros_attributes", - ":__support_macros_properties_architectures", - ], -) - -libc_support_library( - name = "__support_cpp_algorithm", - hdrs = ["src/__support/CPP/algorithm.h"], - deps = [ - ":__support_macros_attributes", - ], -) - -libc_support_library( - name = "__support_cpp_array", - hdrs = ["src/__support/CPP/array.h"], - deps = [ - ":__support_macros_attributes", - ], -) - -libc_support_library( - name = "__support_cpp_bit", - hdrs = ["src/__support/CPP/bit.h"], - deps = [ - ":__support_cpp_limits", - ":__support_cpp_type_traits", - ":__support_macros_attributes", - ":__support_macros_config", - ":__support_macros_sanitizer", - ], -) - -libc_support_library( - name = "__support_cpp_bitset", - hdrs = ["src/__support/CPP/bitset.h"], - deps = [ - ":__support_macros_attributes", - ], -) - -libc_support_library( - name = "__support_cpp_cstddef", - hdrs = ["src/__support/CPP/cstddef.h"], - deps = [ - ":__support_cpp_type_traits", - ":__support_macros_attributes", - ], -) - -libc_support_library( - name = "__support_cpp_expected", - hdrs = ["src/__support/CPP/expected.h"], - deps = [ - ], -) - -libc_support_library( - name = "__support_cpp_functional", - hdrs = ["src/__support/CPP/functional.h"], - deps = [ - "__support_cpp_type_traits", - "__support_cpp_utility", - "__support_macros_attributes", - ], -) - -libc_support_library( - name = "__support_cpp_limits", - hdrs = ["src/__support/CPP/limits.h"], - deps = [ - "__support_cpp_type_traits", - "__support_macros_attributes", - ":__support_macros_properties_types", - ":llvm_libc_macros_limits_macros", - ], -) - -libc_support_library( - name = "__support_cpp_new", - srcs = ["src/__support/CPP/new.cpp"], - hdrs = ["src/__support/CPP/new.h"], - deps = [ - ":__support_common", - ], -) - -libc_support_library( - name = "__support_cpp_optional", - hdrs = ["src/__support/CPP/optional.h"], - deps = [ - ":__support_cpp_utility", - ], -) - -libc_support_library( - name = "__support_cpp_span", - hdrs = ["src/__support/CPP/span.h"], - deps = [ - ":__support_cpp_array", - ":__support_cpp_type_traits", - ], -) - -libc_support_library( - name = "__support_cpp_string_view", - hdrs = ["src/__support/CPP/string_view.h"], - deps = [ - ":__support_common", - ], -) - -libc_support_library( - name = "__support_cpp_stringstream", - hdrs = ["src/__support/CPP/stringstream.h"], - deps = [ - ":__support_cpp_span", - ":__support_cpp_string_view", - ":__support_cpp_type_traits", - ":__support_integer_to_string", - ], -) - -libc_support_library( - name = "__support_cpp_string", - hdrs = ["src/__support/CPP/string.h"], - deps = [ - ":__support_common", - ":__support_cpp_string_view", - ":__support_integer_to_string", - ":string_memory_utils", - ":string_utils", - ], -) - -libc_support_library( - name = "__support_cpp_type_traits", - hdrs = [ - "src/__support/CPP/type_traits.h", - "src/__support/CPP/type_traits/add_lvalue_reference.h", - "src/__support/CPP/type_traits/add_pointer.h", - "src/__support/CPP/type_traits/add_rvalue_reference.h", - "src/__support/CPP/type_traits/always_false.h", - "src/__support/CPP/type_traits/bool_constant.h", - "src/__support/CPP/type_traits/conditional.h", - "src/__support/CPP/type_traits/decay.h", - "src/__support/CPP/type_traits/enable_if.h", - "src/__support/CPP/type_traits/false_type.h", - "src/__support/CPP/type_traits/integral_constant.h", - "src/__support/CPP/type_traits/invoke.h", - "src/__support/CPP/type_traits/invoke_result.h", - "src/__support/CPP/type_traits/is_arithmetic.h", - "src/__support/CPP/type_traits/is_array.h", - "src/__support/CPP/type_traits/is_base_of.h", - "src/__support/CPP/type_traits/is_class.h", - "src/__support/CPP/type_traits/is_const.h", - "src/__support/CPP/type_traits/is_convertible.h", - "src/__support/CPP/type_traits/is_destructible.h", - "src/__support/CPP/type_traits/is_enum.h", - "src/__support/CPP/type_traits/is_fixed_point.h", - "src/__support/CPP/type_traits/is_floating_point.h", - "src/__support/CPP/type_traits/is_function.h", - "src/__support/CPP/type_traits/is_integral.h", - "src/__support/CPP/type_traits/is_lvalue_reference.h", - "src/__support/CPP/type_traits/is_member_pointer.h", - "src/__support/CPP/type_traits/is_null_pointer.h", - "src/__support/CPP/type_traits/is_object.h", - "src/__support/CPP/type_traits/is_pointer.h", - "src/__support/CPP/type_traits/is_reference.h", - "src/__support/CPP/type_traits/is_rvalue_reference.h", - "src/__support/CPP/type_traits/is_same.h", - "src/__support/CPP/type_traits/is_scalar.h", - "src/__support/CPP/type_traits/is_signed.h", - "src/__support/CPP/type_traits/is_trivially_constructible.h", - "src/__support/CPP/type_traits/is_trivially_copyable.h", - "src/__support/CPP/type_traits/is_trivially_destructible.h", - "src/__support/CPP/type_traits/is_union.h", - "src/__support/CPP/type_traits/is_unsigned.h", - "src/__support/CPP/type_traits/is_void.h", - "src/__support/CPP/type_traits/make_signed.h", - "src/__support/CPP/type_traits/make_unsigned.h", - "src/__support/CPP/type_traits/remove_all_extents.h", - "src/__support/CPP/type_traits/remove_cv.h", - "src/__support/CPP/type_traits/remove_cvref.h", - "src/__support/CPP/type_traits/remove_extent.h", - "src/__support/CPP/type_traits/remove_reference.h", - "src/__support/CPP/type_traits/true_type.h", - "src/__support/CPP/type_traits/type_identity.h", - "src/__support/CPP/type_traits/void_t.h", - "src/__support/CPP/utility/declval.h", - "src/__support/CPP/utility/forward.h", - ], - deps = [ - ":__support_macros_attributes", - ":__support_macros_config", - ":__support_macros_properties_types", - ":llvm_libc_macros_stdfix_macros", - ], -) - -libc_support_library( - name = "__support_cpp_utility", - hdrs = [ - "src/__support/CPP/utility.h", - "src/__support/CPP/utility/declval.h", - "src/__support/CPP/utility/forward.h", - "src/__support/CPP/utility/in_place.h", - "src/__support/CPP/utility/integer_sequence.h", - "src/__support/CPP/utility/move.h", - ], - deps = [ - ":__support_cpp_type_traits", - ":__support_macros_attributes", - ], -) - -libc_support_library( - name = "__support_cpp_atomic", - hdrs = ["src/__support/CPP/atomic.h"], - deps = [ - ":__support_cpp_type_traits", - ":__support_macros_attributes", - ":__support_macros_properties_architectures", - ], -) - -libc_support_library( - name = "__support_blockstore", - hdrs = ["src/__support/blockstore.h"], - deps = [ - ":__support_cpp_new", - ":__support_libc_assert", - ], -) - -libc_support_library( - name = "__support_arg_list", - hdrs = ["src/__support/arg_list.h"], - deps = [ - ":__support_common", - ], -) - -libc_support_library( - name = "__support_c_string", - hdrs = ["src/__support/c_string.h"], - deps = [ - ":__support_cpp_string", - ], -) - -libc_support_library( - name = "__support_fixedvector", - hdrs = ["src/__support/fixedvector.h"], - deps = [ - ":__support_cpp_array", - ], -) - -libc_support_library( - name = "__support_char_vector", - hdrs = ["src/__support/char_vector.h"], - deps = [ - ":__support_common", - ], -) - -libc_support_library( - name = "__support_error_or", - hdrs = ["src/__support/error_or.h"], - deps = [ - ":__support_common", - ":__support_cpp_expected", - ], -) - -libc_support_library( - name = "__support_float_to_string", - hdrs = [ - "src/__support/float_to_string.h", - "src/__support/ryu_constants.h", - "src/__support/ryu_long_double_constants.h", - ], - deps = [ - ":__support_common", - ":__support_cpp_type_traits", - ":__support_fputil_dyadic_float", - ":__support_fputil_fp_bits", - ":__support_libc_assert", - ":__support_uint", - ], -) - -libc_support_library( - name = "__support_number_pair", - hdrs = ["src/__support/number_pair.h"], - deps = [ - ":__support_cpp_type_traits", - ], -) - -libc_support_library( - name = "__support_uint", - hdrs = ["src/__support/UInt.h"], - deps = [ - ":__support_cpp_array", - ":__support_cpp_bit", - ":__support_cpp_limits", - ":__support_cpp_optional", - ":__support_cpp_type_traits", - ":__support_macros_attributes", - ":__support_macros_optimization", - ":__support_macros_properties_types", - ":__support_math_extras", - ":__support_number_pair", - ], -) - -libc_support_library( - name = "__support_uint128", - hdrs = ["src/__support/UInt128.h"], - deps = [ - ":__support_macros_properties_types", - ":__support_uint", - ], -) - -libc_support_library( - name = "__support_integer_literals", - hdrs = ["src/__support/integer_literals.h"], - deps = [ - ":__support_cpp_limits", - ":__support_uint128", - ], -) - -libc_support_library( - name = "__support_str_to_num_result", - hdrs = ["src/__support/str_to_num_result.h"], - deps = [":__support_macros_attributes"], -) - -libc_support_library( - name = "__support_integer_operations", - hdrs = ["src/__support/integer_operations.h"], - deps = [":__support_cpp_type_traits"], -) - -libc_support_library( - name = "__support_integer_to_string", - hdrs = ["src/__support/integer_to_string.h"], - deps = [ - ":__support_common", - ":__support_cpp_algorithm", - ":__support_cpp_bit", - ":__support_cpp_limits", - ":__support_cpp_optional", - ":__support_cpp_span", - ":__support_cpp_string_view", - ":__support_cpp_type_traits", - ":__support_uint", - ], -) - -libc_support_library( - name = "__support_libc_assert", - hdrs = ["src/__support/libc_assert.h"], - deps = [ - ":__support_integer_to_string", - ":__support_macros_attributes", - ":__support_osutil_io", - ":__support_osutil_quick_exit", - ], -) - -libc_support_library( - name = "__support_ctype_utils", - hdrs = ["src/__support/ctype_utils.h"], - deps = [":__support_macros_attributes"], -) - -libc_support_library( - name = "__support_str_to_integer", - hdrs = ["src/__support/str_to_integer.h"], - deps = [ - ":__support_common", - ":__support_cpp_limits", - ":__support_cpp_type_traits", - ":__support_ctype_utils", - ":__support_str_to_num_result", - ":errno", - ], -) - -libc_support_library( - name = "__support_str_to_float", - hdrs = [ - "src/__support/detailed_powers_of_ten.h", - "src/__support/high_precision_decimal.h", - "src/__support/str_to_float.h", - ], - deps = [ - ":__support_common", - ":__support_cpp_bit", - ":__support_cpp_limits", - ":__support_cpp_optional", - ":__support_cpp_string_view", - ":__support_ctype_utils", - ":__support_fputil_dyadic_float", - ":__support_fputil_fenv_impl", - ":__support_fputil_fp_bits", - ":__support_fputil_rounding_mode", - ":__support_str_to_integer", - ":__support_str_to_num_result", - ":__support_uint128", - ":errno", - ], -) - -libc_support_library( - name = "__support_fputil_basic_operations", - hdrs = ["src/__support/FPUtil/BasicOperations.h"], - deps = [ - ":__support_common", - ":__support_cpp_type_traits", - ":__support_fputil_fp_bits", - ], -) - -libc_support_library( - name = "__support_file_file", - srcs = ["src/__support/File/file.cpp"], - hdrs = ["src/__support/File/file.h"], - deps = [ - ":__support_cpp_new", - ":__support_cpp_span", - ":__support_error_or", - ":__support_threads_mutex", - ":errno", - ], -) - -libc_support_library( - name = "__support_file_linux_lseekimpl", - hdrs = ["src/__support/File/linux/lseekImpl.h"], - deps = [ - ":__support_common", - ":__support_error_or", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_support_library( - name = "__support_math_extras", - hdrs = ["src/__support/math_extras.h"], - deps = [ - ":__support_cpp_bit", - ":__support_cpp_limits", - ":__support_cpp_type_traits", - ":__support_macros_attributes", - ":__support_macros_config", - ], -) - -libc_support_library( - name = "__support_fixed_point", - hdrs = [ - "src/__support/fixed_point/fx_bits.h", - "src/__support/fixed_point/fx_rep.h", - ], - deps = [ - ":__support_cpp_bit", - ":__support_cpp_type_traits", - ":__support_macros_attributes", - ":__support_macros_optimization", - ":__support_math_extras", - ":llvm_libc_macros_stdfix_macros", - ], -) - -libc_support_library( - name = "__support_fputil_generic_fmod", - hdrs = ["src/__support/FPUtil/generic/FMod.h"], - deps = [ - ":__support_common", - ":__support_cpp_bit", - ":__support_cpp_limits", - ":__support_cpp_type_traits", - ":__support_fputil_fenv_impl", - ":__support_fputil_fp_bits", - ":math_utils", - ], -) - -libc_support_library( - name = "__support_fputil_division_and_remainder_operations", - hdrs = ["src/__support/FPUtil/DivisionAndRemainderOperations.h"], - deps = [ - ":__support_common", - ":__support_cpp_type_traits", - ":__support_fputil_fp_bits", - ":__support_fputil_manipulation_functions", - ":__support_fputil_normal_float", - ], -) - -libc_support_library( - name = "__support_fputil_except_value_utils", - hdrs = ["src/__support/FPUtil/except_value_utils.h"], - deps = [ - ":__support_cpp_optional", - ":__support_fputil_fenv_impl", - ":__support_fputil_fp_bits", - ":__support_fputil_rounding_mode", - ], -) - -libc_support_library( - name = "__support_fputil_fenv_impl", - hdrs = ["src/__support/FPUtil/FEnvImpl.h"], - textual_hdrs = [ - "src/__support/FPUtil/x86_64/FEnvImpl.h", - "src/__support/FPUtil/aarch64/FEnvImpl.h", - "src/__support/FPUtil/aarch64/fenv_darwin_impl.h", - ], - deps = [ - ":__support_fputil_fp_bits", - ":__support_macros_attributes", - ":__support_macros_properties_architectures", - ":__support_macros_sanitizer", - ":errno", - ], -) - -libc_support_library( - name = "__support_fputil_rounding_mode", - hdrs = ["src/__support/FPUtil/rounding_mode.h"], - deps = [ - ":__support_macros_attributes", - ], -) - -libc_support_library( - name = "__support_fputil_fp_bits", - hdrs = ["src/__support/FPUtil/FPBits.h"], - deps = [ - ":__support_common", - ":__support_cpp_bit", - ":__support_cpp_type_traits", - ":__support_libc_assert", - ":__support_macros_attributes", - ":__support_macros_properties_types", - ":__support_math_extras", - ":__support_uint128", - ], -) - -libc_support_library( - name = "__support_fputil_fpbits_str", - hdrs = ["src/__support/FPUtil/fpbits_str.h"], - deps = [ - ":__support_common", - ":__support_cpp_string", - ":__support_cpp_type_traits", - ":__support_fputil_fp_bits", - ":__support_integer_to_string", - ":__support_uint128", - ], -) - -libc_support_library( - name = "__support_fputil_hypot", - hdrs = ["src/__support/FPUtil/Hypot.h"], - deps = [ - ":__support_common", - ":__support_cpp_bit", - ":__support_cpp_type_traits", - ":__support_fputil_basic_operations", - ":__support_fputil_fenv_impl", - ":__support_fputil_fp_bits", - ":__support_fputil_rounding_mode", - ":__support_uint128", - ], -) - -libc_support_library( - name = "__support_fputil_manipulation_functions", - hdrs = ["src/__support/FPUtil/ManipulationFunctions.h"], - textual_hdrs = ["src/__support/FPUtil/x86_64/NextAfterLongDouble.h"], - deps = [ - ":__support_common", - ":__support_cpp_bit", - ":__support_cpp_limits", - ":__support_cpp_type_traits", - ":__support_fputil_dyadic_float", - ":__support_fputil_fp_bits", - ":__support_fputil_nearest_integer_operations", - ":__support_fputil_normal_float", - ":__support_macros_optimization", - ":__support_uint128", - ], -) - -libc_support_library( - name = "__support_fputil_nearest_integer_operations", - hdrs = ["src/__support/FPUtil/NearestIntegerOperations.h"], - deps = [ - ":__support_common", - ":__support_cpp_type_traits", - ":__support_fputil_fenv_impl", - ":__support_fputil_fp_bits", - ":__support_fputil_rounding_mode", - ":__support_macros_attributes", - ], -) - -libc_support_library( - name = "__support_fputil_normal_float", - hdrs = ["src/__support/FPUtil/NormalFloat.h"], - deps = [ - ":__support_common", - ":__support_cpp_type_traits", - ":__support_fputil_fp_bits", - ], -) - -sqrt_common_hdrs = [ - "src/__support/FPUtil/sqrt.h", - "src/__support/FPUtil/generic/sqrt.h", - "src/__support/FPUtil/generic/sqrt_80_bit_long_double.h", -] - -sqrt_hdrs = selects.with_or({ - "//conditions:default": sqrt_common_hdrs, - PLATFORM_CPU_X86_64: sqrt_common_hdrs + [ - "src/__support/FPUtil/x86_64/sqrt.h", - ], - PLATFORM_CPU_ARM64: sqrt_common_hdrs + [ - "src/__support/FPUtil/aarch64/sqrt.h", - ], -}) - -libc_support_library( - name = "__support_fputil_sqrt", - hdrs = sqrt_hdrs, - deps = [ - ":__support_common", - ":__support_cpp_bit", - ":__support_cpp_type_traits", - ":__support_fputil_fenv_impl", - ":__support_fputil_fp_bits", - ":__support_fputil_rounding_mode", - ":__support_uint128", - ], -) - -fma_common_hdrs = [ - "src/__support/FPUtil/FMA.h", - "src/__support/FPUtil/generic/FMA.h", -] - -fma_platform_hdrs = [ - "src/__support/FPUtil/x86_64/FMA.h", - "src/__support/FPUtil/aarch64/FMA.h", -] - -libc_support_library( - name = "__support_fputil_fma", - hdrs = fma_common_hdrs, - # These are conditionally included and will #error out if the platform - # doesn't support FMA, so they can't be compiled on their own. - textual_hdrs = fma_platform_hdrs, - deps = [ - ":__support_cpp_bit", - ":__support_cpp_type_traits", - ":__support_fputil_fenv_impl", - ":__support_fputil_fp_bits", - ":__support_fputil_rounding_mode", - ":__support_macros_attributes", - ":__support_macros_optimization", - ":__support_macros_properties_cpu_features", - ":__support_uint128", - ], -) - -libc_support_library( - name = "__support_fputil_multiply_add", - hdrs = [ - "src/__support/FPUtil/multiply_add.h", - ], - deps = [ - ":__support_common", - ":__support_fputil_fma", - ], -) - -libc_support_library( - name = "__support_fputil_polyeval", - hdrs = [ - "src/__support/FPUtil/PolyEval.h", - ], - deps = [ - ":__support_common", - ":__support_fputil_multiply_add", - ], -) - -nearest_integer_common_hdrs = [ - "src/__support/FPUtil/nearest_integer.h", -] - -nearest_integer_platform_hdrs = [ - "src/__support/FPUtil/x86_64/nearest_integer.h", - "src/__support/FPUtil/aarch64/nearest_integer.h", -] - -libc_support_library( - name = "__support_fputil_nearest_integer", - hdrs = nearest_integer_common_hdrs, - # These are conditionally included and will #error out if the platform - # doesn't support rounding instructions, so they can't be compiled on their - # own. - textual_hdrs = nearest_integer_platform_hdrs, - deps = [ - ":__support_common", - ":__support_macros_optimization", - ":__support_macros_properties_architectures", - ":__support_macros_properties_cpu_features", - ], -) - -libc_support_library( - name = "__support_fputil_double_double", - hdrs = ["src/__support/FPUtil/double_double.h"], - deps = [ - ":__support_common", - ":__support_fputil_multiply_add", - ":__support_number_pair", - ], -) - -libc_support_library( - name = "__support_fputil_triple_double", - hdrs = ["src/__support/FPUtil/triple_double.h"], - deps = [ - ":__support_common", - ], -) - -libc_support_library( - name = "__support_fputil_dyadic_float", - hdrs = ["src/__support/FPUtil/dyadic_float.h"], - deps = [ - ":__support_common", - ":__support_fputil_fp_bits", - ":__support_fputil_multiply_add", - ":__support_macros_optimization", - ":__support_uint", - ], -) - -libc_support_library( - name = "__support_osutil_syscall", - hdrs = ["src/__support/OSUtil/syscall.h"], - textual_hdrs = [ - "src/__support/OSUtil/linux/syscall.h", - "src/__support/OSUtil/linux/aarch64/syscall.h", - "src/__support/OSUtil/linux/x86_64/syscall.h", - ], - deps = [ - ":__support_common", - ":__support_cpp_bit", - ], -) - -libc_support_library( - name = "__support_osutil_io", - hdrs = ["src/__support/OSUtil/io.h"], - textual_hdrs = [ - "src/__support/OSUtil/linux/io.h", - ], - deps = [ - ":__support_common", - ":__support_cpp_string_view", - ":__support_osutil_syscall", - ":string_utils", - ], -) - -libc_support_library( - name = "__support_osutil_quick_exit", - hdrs = ["src/__support/OSUtil/quick_exit.h"], - textual_hdrs = [ - "src/__support/OSUtil/linux/quick_exit.h", - #TODO: add support for GPU quick_exit (isn't just in a header.) - ], - deps = [ - ":__support_osutil_syscall", - ], -) - -libc_support_library( - name = "__support_stringutil", - srcs = glob(["src/__support/StringUtil/tables/**/*.h"]) + [ - "src/__support/StringUtil/error_to_string.cpp", - "src/__support/StringUtil/message_mapper.h", - "src/__support/StringUtil/platform_errors.h", - "src/__support/StringUtil/platform_signals.h", - "src/__support/StringUtil/signal_to_string.cpp", - ], - hdrs = [ - "src/__support/StringUtil/error_to_string.h", - "src/__support/StringUtil/signal_to_string.h", - ], - deps = [ - ":__support_cpp_array", - ":__support_cpp_span", - ":__support_cpp_string_view", - ":__support_cpp_stringstream", - ":__support_integer_to_string", - ":__support_macros_attributes", - ":errno", - ], -) - -libc_support_library( - name = "__support_threads_mutex", - hdrs = [ - "src/__support/threads/mutex.h", - "src/__support/threads/mutex_common.h", - ], - textual_hdrs = [ - "src/__support/threads/linux/mutex.h", - "src/__support/threads/linux/futex_word.h", - ], - deps = [ - ":__support_cpp_atomic", - ":__support_osutil_syscall", - ], -) - -libc_support_library( - name = "llvm_libc_macros_limits_macros", - hdrs = ["include/llvm-libc-macros/limits-macros.h"], -) - -libc_support_library( - name = "llvm_libc_macros_float_macros", - hdrs = ["include/llvm-libc-macros/float-macros.h"], -) - -libc_support_library( - name = "llvm_libc_macros_stdint_macros", - hdrs = ["include/llvm-libc-macros/stdint-macros.h"], -) - -libc_support_library( - name = "llvm_libc_macros_stdfix_macros", - hdrs = ["include/llvm-libc-macros/stdfix-macros.h"], - deps = [":llvm_libc_macros_float_macros"], -) - -libc_support_library( - name = "llvm_libc_types_float128", - hdrs = ["include/llvm-libc-types/float128.h"], - deps = [":llvm_libc_macros_float_macros"], -) - -############################### errno targets ################################ - -libc_function( - name = "errno", - srcs = ["src/errno/libc_errno.cpp"], - hdrs = ["src/errno/libc_errno.h"], - deps = [ - ":__support_common", - ":__support_macros_attributes", - ":__support_macros_properties_architectures", - ], -) - -################################ fenv targets ################################ - -libc_function( - name = "fetestexcept", - srcs = ["src/fenv/fetestexcept.cpp"], - hdrs = ["src/fenv/fetestexcept.h"], - deps = [ - ":__support_common", - ":__support_fputil_fenv_impl", - ], -) - -libc_function( - name = "feclearexcept", - srcs = ["src/fenv/feclearexcept.cpp"], - hdrs = ["src/fenv/feclearexcept.h"], - deps = [ - ":__support_common", - ":__support_fputil_fenv_impl", - ], -) - -libc_function( - name = "feraiseexcept", - srcs = ["src/fenv/feraiseexcept.cpp"], - hdrs = ["src/fenv/feraiseexcept.h"], - deps = [ - ":__support_common", - ":__support_fputil_fenv_impl", - ], -) - -libc_function( - name = "fegetround", - srcs = ["src/fenv/fegetround.cpp"], - hdrs = ["src/fenv/fegetround.h"], - deps = [ - ":__support_common", - ":__support_fputil_fenv_impl", - ], -) - -libc_function( - name = "fesetround", - srcs = ["src/fenv/fesetround.cpp"], - hdrs = ["src/fenv/fesetround.h"], - deps = [ - ":__support_common", - ":__support_fputil_fenv_impl", - ], -) - -libc_function( - name = "fedisableexcept", - srcs = ["src/fenv/fedisableexcept.cpp"], - hdrs = ["src/fenv/fedisableexcept.h"], - deps = [ - ":__support_common", - ":__support_fputil_fenv_impl", - ], -) - -libc_function( - name = "feenableexcept", - srcs = ["src/fenv/feenableexcept.cpp"], - hdrs = ["src/fenv/feenableexcept.h"], - deps = [ - ":__support_common", - ":__support_fputil_fenv_impl", - ], -) - -libc_function( - name = "fegetexcept", - srcs = ["src/fenv/fegetexcept.cpp"], - hdrs = ["src/fenv/fegetexcept.h"], - deps = [ - ":__support_common", - ":__support_fputil_fenv_impl", - ], -) - -libc_function( - name = "fegetenv", - srcs = ["src/fenv/fegetenv.cpp"], - hdrs = ["src/fenv/fegetenv.h"], - deps = [ - ":__support_common", - ":__support_fputil_fenv_impl", - ], -) - -libc_function( - name = "fesetenv", - srcs = ["src/fenv/fesetenv.cpp"], - hdrs = ["src/fenv/fesetenv.h"], - deps = [ - ":__support_common", - ":__support_fputil_fenv_impl", - ], -) - -libc_function( - name = "feupdateenv", - srcs = ["src/fenv/feupdateenv.cpp"], - hdrs = ["src/fenv/feupdateenv.h"], - deps = [ - ":__support_common", - ":__support_fputil_fenv_impl", - ], -) - -libc_function( - name = "fegetexceptflag", - srcs = ["src/fenv/fegetexceptflag.cpp"], - hdrs = ["src/fenv/fegetexceptflag.h"], - deps = [ - ":__support_common", - ":__support_fputil_fenv_impl", - ], -) - -libc_function( - name = "fesetexceptflag", - srcs = ["src/fenv/fesetexceptflag.cpp"], - hdrs = ["src/fenv/fesetexceptflag.h"], - deps = [ - ":__support_common", - ":__support_fputil_fenv_impl", - ], -) - -libc_function( - name = "feholdexcept", - srcs = ["src/fenv/feholdexcept.cpp"], - hdrs = ["src/fenv/feholdexcept.h"], - deps = [ - ":__support_common", - ":__support_fputil_fenv_impl", - ], -) - -################################ math targets ################################ - -libc_support_library( - name = "math_utils", - srcs = ["src/math/generic/math_utils.cpp"], - hdrs = ["src/math/generic/math_utils.h"], - deps = [ - "__support_cpp_bit", - "__support_cpp_type_traits", - ":__support_common", - ":errno", - ], -) - -libc_support_library( - name = "common_constants", - srcs = ["src/math/generic/common_constants.cpp"], - hdrs = ["src/math/generic/common_constants.h"], - deps = [ - ":__support_fputil_triple_double", - ":__support_number_pair", - ], -) - -libc_support_library( - name = "range_reduction", - hdrs = [ - "src/math/generic/range_reduction.h", - "src/math/generic/range_reduction_fma.h", - ], - deps = [ - ":__support_common", - ":__support_fputil_fma", - ":__support_fputil_fp_bits", - ":__support_fputil_multiply_add", - ":__support_fputil_nearest_integer", - ], -) - -libc_support_library( - name = "sincosf_utils", - hdrs = ["src/math/generic/sincosf_utils.h"], - deps = [ - ":__support_fputil_fp_bits", - ":__support_fputil_polyeval", - ":range_reduction", - ], -) - -libc_support_library( - name = "explogxf", - srcs = ["src/math/generic/explogxf.cpp"], - hdrs = ["src/math/generic/explogxf.h"], - deps = [ - ":__support_common", - ":__support_fputil_fenv_impl", - ":__support_fputil_fma", - ":__support_fputil_fp_bits", - ":__support_fputil_multiply_add", - ":__support_fputil_nearest_integer", - ":__support_fputil_polyeval", - ":common_constants", - ":math_utils", - ], -) - -libc_support_library( - name = "inv_trigf_utils", - srcs = ["src/math/generic/inv_trigf_utils.cpp"], - hdrs = ["src/math/generic/inv_trigf_utils.h"], - deps = [ - ":__support_common", - ":__support_fputil_fenv_impl", - ":__support_fputil_fma", - ":__support_fputil_fp_bits", - ":__support_fputil_multiply_add", - ":__support_fputil_nearest_integer", - ":__support_fputil_polyeval", - ":math_utils", - ], -) - -libc_support_library( - name = "log_range_reduction", - hdrs = ["src/math/generic/log_range_reduction.h"], - deps = [ - ":__support_common", - ":__support_fputil_dyadic_float", - ":__support_uint128", - ":common_constants", - ], -) - -libc_support_library( - name = "exp10f_impl", - hdrs = ["src/math/generic/exp10f_impl.h"], - deps = [ - ":__support_fputil_basic_operations", - ":__support_fputil_fma", - ":__support_fputil_multiply_add", - ":__support_fputil_nearest_integer", - ":__support_fputil_polyeval", - ":__support_fputil_rounding_mode", - ":__support_macros_optimization", - ":common_constants", - ":explogxf", - ], -) - -libc_support_library( - name = "exp2f_impl", - hdrs = ["src/math/generic/exp2f_impl.h"], - deps = [ - ":__support_fputil_except_value_utils", - ":__support_fputil_fma", - ":__support_fputil_multiply_add", - ":__support_fputil_nearest_integer", - ":__support_fputil_polyeval", - ":__support_fputil_rounding_mode", - ":__support_macros_optimization", - ":common_constants", - ":explogxf", - ], -) - -libc_math_function( - name = "erff", - additional_deps = [ - ":__support_fputil_multiply_add", - ":__support_fputil_polyeval", - ":__support_macros_optimization", - ], -) - -libc_math_function( - name = "expm1", - additional_deps = [ - ":__support_fputil_double_double", - ":__support_fputil_dyadic_float", - ":__support_fputil_multiply_add", - ":__support_fputil_nearest_integer", - ":__support_fputil_polyeval", - ":__support_fputil_rounding_mode", - ":__support_fputil_triple_double", - ":__support_integer_literals", - ":__support_macros_optimization", - ":common_constants", - ":explogxf", - ], -) - -libc_math_function( - name = "expm1f", - additional_deps = [ - ":__support_fputil_fma", - ":__support_fputil_multiply_add", - ":__support_fputil_nearest_integer", - ":__support_fputil_polyeval", - ":__support_fputil_rounding_mode", - ":__support_macros_optimization", - ":__support_macros_properties_cpu_features", - ":common_constants", - ], -) - -libc_math_function( - name = "exp", - additional_deps = [ - ":__support_fputil_double_double", - ":__support_fputil_dyadic_float", - ":__support_fputil_multiply_add", - ":__support_fputil_nearest_integer", - ":__support_fputil_polyeval", - ":__support_fputil_rounding_mode", - ":__support_fputil_triple_double", - ":__support_integer_literals", - ":__support_macros_optimization", - ":common_constants", - ":explogxf", - ], -) - -libc_math_function( - name = "expf", - additional_deps = [ - ":__support_fputil_fma", - ":__support_fputil_multiply_add", - ":__support_fputil_nearest_integer", - ":__support_fputil_polyeval", - ":__support_fputil_rounding_mode", - ":__support_macros_optimization", - ":common_constants", - ], -) - -libc_math_function( - name = "exp10", - additional_deps = [ - ":__support_fputil_double_double", - ":__support_fputil_dyadic_float", - ":__support_fputil_multiply_add", - ":__support_fputil_nearest_integer", - ":__support_fputil_polyeval", - ":__support_fputil_rounding_mode", - ":__support_fputil_triple_double", - ":__support_integer_literals", - ":__support_macros_optimization", - ":common_constants", - ":explogxf", - ], -) - -libc_math_function( - name = "exp10f", - additional_deps = [ - ":exp10f_impl", - ], -) - -libc_math_function( - name = "exp2", - additional_deps = [ - ":__support_fputil_double_double", - ":__support_fputil_dyadic_float", - ":__support_fputil_multiply_add", - ":__support_fputil_nearest_integer", - ":__support_fputil_polyeval", - ":__support_fputil_rounding_mode", - ":__support_fputil_triple_double", - ":__support_integer_literals", - ":__support_macros_optimization", - ":common_constants", - ":explogxf", - ], -) - -libc_math_function( - name = "exp2f", - additional_deps = [ - ":exp2f_impl", - ], -) - -libc_math_function( - name = "logf", - additional_deps = [ - ":__support_fputil_fma", - ":__support_fputil_multiply_add", - ":__support_fputil_polyeval", - ":__support_macros_optimization", - ":__support_macros_properties_cpu_features", - ":common_constants", - ], -) - -libc_math_function( - name = "log2f", - additional_deps = [ - ":__support_fputil_fma", - ":__support_fputil_multiply_add", - ":__support_fputil_polyeval", - ":__support_macros_optimization", - ":common_constants", - ], -) - -libc_math_function( - name = "log10f", - additional_deps = [ - ":__support_fputil_fma", - ":__support_fputil_multiply_add", - ":__support_fputil_polyeval", - ":__support_macros_optimization", - ":__support_macros_properties_cpu_features", - ":common_constants", - ], -) - -libc_math_function( - name = "log1pf", - additional_deps = [ - ":__support_fputil_fma", - ":__support_fputil_multiply_add", - ":__support_fputil_polyeval", - ":__support_macros_optimization", - ":__support_macros_properties_cpu_features", - ":common_constants", - ], -) - -libc_math_function( - name = "log", - additional_deps = [ - ":__support_fputil_double_double", - ":__support_fputil_dyadic_float", - ":__support_fputil_fma", - ":__support_fputil_multiply_add", - ":__support_fputil_polyeval", - ":__support_integer_literals", - ":__support_macros_optimization", - ":__support_macros_properties_cpu_features", - ":common_constants", - ":log_range_reduction", - ], -) - -libc_math_function( - name = "log2", - additional_deps = [ - ":__support_fputil_double_double", - ":__support_fputil_dyadic_float", - ":__support_fputil_fma", - ":__support_fputil_multiply_add", - ":__support_fputil_polyeval", - ":__support_integer_literals", - ":__support_macros_optimization", - ":__support_macros_properties_cpu_features", - ":common_constants", - ":log_range_reduction", - ], -) - -libc_math_function( - name = "log10", - additional_deps = [ - ":__support_fputil_double_double", - ":__support_fputil_dyadic_float", - ":__support_fputil_fma", - ":__support_fputil_multiply_add", - ":__support_fputil_polyeval", - ":__support_integer_literals", - ":__support_macros_optimization", - ":__support_macros_properties_cpu_features", - ":common_constants", - ":log_range_reduction", - ], -) - -libc_math_function( - name = "log1p", - additional_deps = [ - ":__support_fputil_double_double", - ":__support_fputil_dyadic_float", - ":__support_fputil_fma", - ":__support_fputil_multiply_add", - ":__support_fputil_polyeval", - ":__support_integer_literals", - ":__support_macros_optimization", - ":__support_macros_properties_cpu_features", - ":common_constants", - ], -) - -libc_math_function( - name = "sinhf", - additional_deps = [ - ":__support_fputil_fma", - ":__support_fputil_multiply_add", - ":__support_fputil_nearest_integer", - ":__support_fputil_polyeval", - ":__support_fputil_rounding_mode", - ":__support_macros_optimization", - ":common_constants", - ":explogxf", - ], -) - -libc_math_function( - name = "coshf", - additional_deps = [ - ":__support_fputil_fma", - ":__support_fputil_multiply_add", - ":__support_fputil_nearest_integer", - ":__support_fputil_polyeval", - ":__support_fputil_rounding_mode", - ":__support_macros_optimization", - ":common_constants", - ":explogxf", - ], -) - -libc_math_function( - name = "tanhf", - additional_deps = [ - ":__support_fputil_fma", - ":__support_fputil_multiply_add", - ":__support_fputil_nearest_integer", - ":__support_fputil_polyeval", - ":__support_fputil_rounding_mode", - ":__support_macros_optimization", - ":__support_macros_properties_cpu_features", - ":common_constants", - ":explogxf", - ], -) - -libc_math_function( - name = "asinhf", - additional_deps = [ - ":__support_fputil_fma", - ":__support_fputil_multiply_add", - ":__support_fputil_nearest_integer", - ":__support_fputil_polyeval", - ":__support_fputil_sqrt", - ":__support_macros_optimization", - ":common_constants", - ":explogxf", - ], -) - -libc_math_function( - name = "acoshf", - additional_deps = [ - ":__support_fputil_fma", - ":__support_fputil_multiply_add", - ":__support_fputil_nearest_integer", - ":__support_fputil_polyeval", - ":__support_fputil_sqrt", - ":__support_macros_optimization", - ":common_constants", - ":explogxf", - ], -) - -libc_math_function( - name = "atanhf", - additional_deps = [ - ":__support_fputil_fma", - ":__support_fputil_multiply_add", - ":__support_fputil_nearest_integer", - ":__support_fputil_polyeval", - ":__support_macros_optimization", - ":common_constants", - ":explogxf", - ], -) - -libc_math_function( - name = "asinf", - additional_deps = [ - ":__support_fputil_fma", - ":__support_fputil_multiply_add", - ":__support_fputil_nearest_integer", - ":__support_fputil_polyeval", - ":__support_fputil_sqrt", - ":__support_macros_optimization", - ":__support_macros_properties_cpu_features", - ":inv_trigf_utils", - ], -) - -libc_math_function( - name = "acosf", - additional_deps = [ - ":__support_fputil_fma", - ":__support_fputil_multiply_add", - ":__support_fputil_nearest_integer", - ":__support_fputil_polyeval", - ":__support_fputil_sqrt", - ":__support_macros_optimization", - ":inv_trigf_utils", - ], -) - -libc_math_function( - name = "atanf", - additional_deps = [ - ":__support_fputil_fma", - ":__support_fputil_multiply_add", - ":__support_fputil_nearest_integer", - ":__support_fputil_polyeval", - ":__support_fputil_rounding_mode", - ":__support_macros_optimization", - ":inv_trigf_utils", - ":math_utils", - ], -) - -libc_math_function( - name = "powf", - additional_deps = [ - ":__support_fputil_double_double", - ":__support_fputil_multiply_add", - ":__support_fputil_nearest_integer", - ":__support_fputil_polyeval", - ":__support_fputil_rounding_mode", - ":__support_fputil_sqrt", - ":__support_fputil_triple_double", - ":__support_macros_optimization", - ":common_constants", - ":explogxf", - ":exp2f_impl", - ":exp10f_impl", - ], -) - -libc_math_function(name = "fabs") - -libc_math_function(name = "fabsf") - -libc_math_function(name = "fabsl") - -libc_math_function(name = "fdim") - -libc_math_function(name = "fdimf") - -libc_math_function(name = "fdiml") - -libc_math_function( - name = "ceil", - specializations = [ - "aarch64", - "generic", - ], -) - -libc_math_function( - name = "ceilf", - specializations = [ - "aarch64", - "generic", - ], -) - -libc_math_function( - name = "ceill", - specializations = [ - "generic", - ], -) - -libc_math_function( - name = "floor", - specializations = [ - "aarch64", - "generic", - ], -) - -libc_math_function( - name = "floorf", - specializations = [ - "aarch64", - "generic", - ], -) - -libc_math_function(name = "floorl") - -libc_math_function(name = "ldexp") - -libc_math_function(name = "ldexpf") - -libc_math_function(name = "ldexpl") - -libc_math_function( - name = "trunc", - specializations = [ - "aarch64", - "generic", - ], -) - -libc_math_function( - name = "truncf", - specializations = [ - "aarch64", - "generic", - ], -) - -libc_math_function(name = "truncl") - -libc_math_function( - name = "round", - specializations = [ - "aarch64", - "generic", - ], -) - -libc_math_function( - name = "roundf", - specializations = [ - "aarch64", - "generic", - ], -) - -libc_math_function(name = "roundl") - -libc_math_function( - name = "fmod", - additional_deps = [ - ":__support_fputil_generic_fmod", - ], -) - -libc_math_function( - name = "fmodf", - additional_deps = [ - ":__support_fputil_generic_fmod", - ], -) - -libc_math_function(name = "frexp") - -libc_math_function(name = "frexpf") - -libc_math_function(name = "frexpl") - -libc_math_function(name = "hypot") - -libc_math_function( - name = "hypotf", - additional_deps = [ - ":__support_fputil_sqrt", - ], -) - -libc_math_function(name = "logb") - -libc_math_function(name = "logbf") - -libc_math_function(name = "logbl") - -libc_math_function(name = "modf") - -libc_math_function(name = "modff") - -libc_math_function(name = "modfl") - -libc_math_function(name = "remquo") - -libc_math_function(name = "remquof") - -libc_math_function(name = "remquol") - -libc_math_function(name = "remainder") - -libc_math_function(name = "remainderf") - -libc_math_function(name = "remainderl") - -libc_math_function(name = "fmin") - -libc_math_function(name = "fminf") - -libc_math_function(name = "fminl") - -libc_math_function(name = "fmax") - -libc_math_function(name = "fmaxf") - -libc_math_function(name = "fmaxl") - -libc_math_function( - name = "cosf", - additional_deps = [ - ":__support_fputil_fma", - ":__support_fputil_multiply_add", - ":__support_macros_optimization", - ":__support_macros_properties_cpu_features", - ":sincosf_utils", - ], -) - -libc_math_function( - name = "sincosf", - additional_deps = [ - ":__support_fputil_fma", - ":__support_fputil_multiply_add", - ":__support_fputil_rounding_mode", - ":__support_macros_optimization", - ":__support_macros_properties_cpu_features", - ":sincosf_utils", - ], -) - -libc_math_function( - name = "sinf", - additional_deps = [ - ":__support_fputil_fma", - ":__support_fputil_multiply_add", - ":__support_fputil_polyeval", - ":__support_fputil_rounding_mode", - ":__support_macros_optimization", - ":__support_macros_properties_cpu_features", - ":range_reduction", - ":sincosf_utils", - ], -) - -libc_math_function( - name = "tanf", - additional_deps = [ - ":__support_fputil_fma", - ":__support_fputil_multiply_add", - ":__support_fputil_nearest_integer", - ":__support_fputil_polyeval", - ":__support_macros_optimization", - ":__support_macros_properties_cpu_features", - ":range_reduction", - ":sincosf_utils", - ], -) - -libc_math_function( - name = "sqrt", - additional_deps = [ - ":__support_fputil_sqrt", - ], -) - -libc_math_function( - name = "sqrtf", - additional_deps = [ - ":__support_fputil_sqrt", - ], -) - -libc_math_function( - name = "sqrtl", - additional_deps = [ - ":__support_fputil_sqrt", - ], -) - -libc_math_function(name = "copysign") - -libc_math_function(name = "copysignf") - -libc_math_function(name = "copysignl") - -libc_math_function(name = "copysignf128") - -libc_math_function(name = "ilogb") - -libc_math_function(name = "ilogbf") - -libc_math_function(name = "ilogbl") - -libc_math_function(name = "rint") - -libc_math_function(name = "rintf") - -libc_math_function(name = "rintl") - -libc_math_function(name = "lrint") - -libc_math_function(name = "lrintf") - -libc_math_function(name = "lrintl") - -libc_math_function(name = "llrint") - -libc_math_function(name = "llrintf") - -libc_math_function(name = "llrintl") - -libc_math_function(name = "lround") - -libc_math_function(name = "lroundf") - -libc_math_function(name = "lroundl") - -libc_math_function(name = "llround") - -libc_math_function(name = "llroundf") - -libc_math_function(name = "llroundl") - -libc_math_function( - name = "nan", - additional_deps = [ - ":__support_str_to_float", - ":errno", - ], -) - -libc_math_function( - name = "nanf", - additional_deps = [ - ":__support_str_to_float", - ":errno", - ], -) - -libc_math_function( - name = "nanl", - additional_deps = [ - ":__support_str_to_float", - ":errno", - ], -) - -libc_math_function(name = "nearbyint") - -libc_math_function(name = "nearbyintf") - -libc_math_function(name = "nearbyintl") - -libc_math_function(name = "nextafter") - -libc_math_function(name = "nextafterf") - -libc_math_function(name = "nextafterl") - -libc_math_function(name = "nexttoward") - -libc_math_function(name = "nexttowardf") - -libc_math_function(name = "nexttowardl") - -libc_math_function(name = "scalbn") - -libc_math_function(name = "scalbnf") - -libc_math_function(name = "scalbnl") - -############################## inttypes targets ############################## - -libc_function( - name = "imaxabs", - srcs = ["src/inttypes/imaxabs.cpp"], - hdrs = ["src/inttypes/imaxabs.h"], - deps = [ - ":__support_common", - ":__support_integer_operations", - ], -) - -libc_function( - name = "imaxdiv", - srcs = ["src/inttypes/imaxdiv.cpp"], - hdrs = ["src/inttypes/imaxdiv.h"], - deps = [ - ":__support_common", - ":__support_integer_operations", - ], -) - -############################### stdlib targets ############################### - -libc_function( - name = "abs", - srcs = ["src/stdlib/abs.cpp"], - hdrs = ["src/stdlib/abs.h"], - deps = [ - ":__support_common", - ":__support_integer_operations", - ], -) - -libc_function( - name = "labs", - srcs = ["src/stdlib/labs.cpp"], - hdrs = ["src/stdlib/labs.h"], - deps = [ - ":__support_common", - ":__support_integer_operations", - ], -) - -libc_function( - name = "llabs", - srcs = ["src/stdlib/llabs.cpp"], - hdrs = ["src/stdlib/llabs.h"], - deps = [ - ":__support_common", - ":__support_integer_operations", - ], -) - -libc_function( - name = "div", - srcs = ["src/stdlib/div.cpp"], - hdrs = ["src/stdlib/div.h"], - deps = [ - ":__support_common", - ":__support_integer_operations", - ], -) - -libc_function( - name = "ldiv", - srcs = ["src/stdlib/ldiv.cpp"], - hdrs = ["src/stdlib/ldiv.h"], - deps = [ - ":__support_common", - ":__support_integer_operations", - ], -) - -libc_function( - name = "lldiv", - srcs = ["src/stdlib/lldiv.cpp"], - hdrs = ["src/stdlib/lldiv.h"], - deps = [ - ":__support_common", - ":__support_integer_operations", - ], -) - -libc_function( - name = "atoi", - srcs = ["src/stdlib/atoi.cpp"], - hdrs = ["src/stdlib/atoi.h"], - deps = [ - ":__support_common", - ":__support_str_to_integer", - ":errno", - ], -) - -libc_function( - name = "atol", - srcs = ["src/stdlib/atol.cpp"], - hdrs = ["src/stdlib/atol.h"], - deps = [ - ":__support_common", - ":__support_str_to_integer", - ":errno", - ], -) - -libc_function( - name = "atoll", - srcs = ["src/stdlib/atoll.cpp"], - hdrs = ["src/stdlib/atoll.h"], - deps = [ - ":__support_common", - ":__support_str_to_integer", - ":errno", - ], -) - -libc_function( - name = "atof", - srcs = ["src/stdlib/atof.cpp"], - hdrs = ["src/stdlib/atof.h"], - deps = [ - ":__support_common", - ":__support_str_to_float", - ":errno", - ], -) - -libc_function( - name = "bsearch", - srcs = ["src/stdlib/bsearch.cpp"], - hdrs = ["src/stdlib/bsearch.h"], - deps = [ - ":__support_common", - ], -) - -libc_support_library( - name = "qsort_util", - hdrs = ["src/stdlib/qsort_util.h"], - deps = [ - ":__support_common", - ":__support_macros_attributes", - ], -) - -libc_function( - name = "qsort", - srcs = ["src/stdlib/qsort.cpp"], - hdrs = ["src/stdlib/qsort.h"], - deps = [ - ":__support_common", - ":qsort_util", - ], -) - -libc_function( - name = "qsort_r", - srcs = ["src/stdlib/qsort_r.cpp"], - hdrs = ["src/stdlib/qsort_r.h"], - deps = [ - ":__support_common", - ":qsort_util", - ], -) - -libc_function( - name = "strtol", - srcs = ["src/stdlib/strtol.cpp"], - hdrs = ["src/stdlib/strtol.h"], - deps = [ - ":__support_common", - ":__support_str_to_integer", - ":errno", - ], -) - -libc_function( - name = "strtoll", - srcs = ["src/stdlib/strtoll.cpp"], - hdrs = ["src/stdlib/strtoll.h"], - deps = [ - ":__support_common", - ":__support_str_to_integer", - ":errno", - ], -) - -libc_function( - name = "strtoul", - srcs = ["src/stdlib/strtoul.cpp"], - hdrs = ["src/stdlib/strtoul.h"], - deps = [ - ":__support_common", - ":__support_str_to_integer", - ":errno", - ], -) - -libc_function( - name = "strtoull", - srcs = ["src/stdlib/strtoull.cpp"], - hdrs = ["src/stdlib/strtoull.h"], - deps = [ - ":__support_common", - ":__support_str_to_integer", - ":errno", - ], -) - -libc_function( - name = "strtof", - srcs = ["src/stdlib/strtof.cpp"], - hdrs = ["src/stdlib/strtof.h"], - deps = [ - ":__support_common", - ":__support_str_to_float", - ":errno", - ], -) - -libc_function( - name = "strtod", - srcs = ["src/stdlib/strtod.cpp"], - hdrs = ["src/stdlib/strtod.h"], - deps = [ - ":__support_common", - ":__support_str_to_float", - ":errno", - ], -) - -libc_function( - name = "strtold", - srcs = ["src/stdlib/strtold.cpp"], - hdrs = ["src/stdlib/strtold.h"], - deps = [ - ":__support_common", - ":__support_str_to_float", - ":errno", - ], -) - -############################### string targets ############################### - -no_sanitize_features = [ - "-asan", - "-msan", - "-tsan", - "-ubsan", -] - -libc_support_library( - name = "string_memory_utils", - hdrs = [ - "src/string/memory_utils/op_aarch64.h", - "src/string/memory_utils/op_builtin.h", - "src/string/memory_utils/op_generic.h", - "src/string/memory_utils/op_riscv.h", - "src/string/memory_utils/op_x86.h", - "src/string/memory_utils/utils.h", - ], - defines = MEMORY_COPTS, - textual_hdrs = [ - "src/string/memory_utils/aarch64/inline_bcmp.h", - "src/string/memory_utils/aarch64/inline_memcmp.h", - "src/string/memory_utils/aarch64/inline_memcpy.h", - "src/string/memory_utils/aarch64/inline_memmove.h", - "src/string/memory_utils/aarch64/inline_memset.h", - "src/string/memory_utils/generic/aligned_access.h", - "src/string/memory_utils/generic/byte_per_byte.h", - "src/string/memory_utils/inline_bcmp.h", - "src/string/memory_utils/inline_bzero.h", - "src/string/memory_utils/inline_memcmp.h", - "src/string/memory_utils/inline_memcpy.h", - "src/string/memory_utils/inline_memmem.h", - "src/string/memory_utils/inline_memmove.h", - "src/string/memory_utils/inline_memset.h", - "src/string/memory_utils/inline_strcmp.h", - "src/string/memory_utils/inline_strstr.h", - "src/string/memory_utils/riscv/inline_bcmp.h", - "src/string/memory_utils/riscv/inline_memcmp.h", - "src/string/memory_utils/riscv/inline_memcpy.h", - "src/string/memory_utils/riscv/inline_memmove.h", - "src/string/memory_utils/riscv/inline_memset.h", - "src/string/memory_utils/x86_64/inline_bcmp.h", - "src/string/memory_utils/x86_64/inline_memcmp.h", - "src/string/memory_utils/x86_64/inline_memcpy.h", - "src/string/memory_utils/x86_64/inline_memmove.h", - "src/string/memory_utils/x86_64/inline_memset.h", - ], - deps = [ - ":__support_common", - ":__support_cpp_array", - ":__support_cpp_bit", - ":__support_cpp_cstddef", - ":__support_cpp_type_traits", - ":__support_macros_attributes", - ":__support_macros_config", - ":__support_macros_optimization", - ":__support_macros_properties_architectures", - ":__support_macros_properties_cpu_features", - ], -) - -libc_support_library( - name = "string_utils", - hdrs = ["src/string/string_utils.h"], - deps = [ - ":__support_common", - ":__support_cpp_bitset", - ":__support_macros_optimization", - ":string_memory_utils", - ], -) - -libc_function( - name = "memchr", - srcs = ["src/string/memchr.cpp"], - hdrs = ["src/string/memchr.h"], - deps = [ - ":__support_common", - ":string_utils", - ], -) - -libc_function( - name = "memcpy", - srcs = ["src/string/memcpy.cpp"], - hdrs = ["src/string/memcpy.h"], - copts = ["-mllvm --tail-merge-threshold=0"], - features = no_sanitize_features, - weak = True, - deps = [ - ":__support_common", - ":string_memory_utils", - ], -) - -libc_function( - name = "memset", - srcs = ["src/string/memset.cpp"], - hdrs = ["src/string/memset.h"], - features = no_sanitize_features, - weak = True, - deps = [ - ":__support_common", - ":string_memory_utils", - ], -) - -libc_function( - name = "memmove", - srcs = ["src/string/memmove.cpp"], - hdrs = ["src/string/memmove.h"], - features = no_sanitize_features, - weak = True, - deps = [ - ":__support_common", - ":string_memory_utils", - ], -) - -libc_function( - name = "mempcpy", - srcs = ["src/string/mempcpy.cpp"], - hdrs = ["src/string/mempcpy.h"], - copts = ["-mllvm --tail-merge-threshold=0"], - features = no_sanitize_features, - weak = True, - deps = [ - ":__support_common", - ":string_memory_utils", - ], -) - -libc_function( - name = "bcopy", - srcs = ["src/string/bcopy.cpp"], - hdrs = ["src/string/bcopy.h"], - features = no_sanitize_features, - deps = [ - ":__support_common", - ":string_memory_utils", - ], -) - -libc_function( - name = "memcmp", - srcs = ["src/string/memcmp.cpp"], - hdrs = ["src/string/memcmp.h"], - features = no_sanitize_features, - weak = True, - deps = [ - ":__support_common", - ":__support_integer_operations", - ":string_memory_utils", - ], -) - -libc_function( - name = "bcmp", - srcs = ["src/string/bcmp.cpp"], - hdrs = ["src/string/bcmp.h"], - features = no_sanitize_features, - weak = True, - deps = [ - ":__support_common", - ":string_memory_utils", - ], -) - -libc_function( - name = "bzero", - srcs = ["src/string/bzero.cpp"], - hdrs = ["src/string/bzero.h"], - features = no_sanitize_features, - weak = True, - deps = [ - ":__support_common", - ":string_memory_utils", - ], -) - -libc_function( - name = "memrchr", - srcs = ["src/string/memrchr.cpp"], - hdrs = ["src/string/memrchr.h"], - deps = [ - ":__support_common", - ":string_utils", - ], -) - -libc_function( - name = "strlen", - srcs = ["src/string/strlen.cpp"], - hdrs = ["src/string/strlen.h"], - features = no_sanitize_features, - deps = [ - ":__support_common", - ":string_utils", - ], -) - -libc_function( - name = "strcpy", - srcs = ["src/string/strcpy.cpp"], - hdrs = ["src/string/strcpy.h"], - features = no_sanitize_features, - deps = [ - ":__support_common", - ":memcpy", - ":string_memory_utils", - ":string_utils", - ], -) - -# A sanitizer instrumented flavor of strcpy to be used with unittests. -libc_function( - name = "strcpy_sanitized", - testonly = 1, - srcs = ["src/string/strcpy.cpp"], - hdrs = ["src/string/strcpy.h"], - deps = [ - ":__support_common", - ":memcpy", - ":string_memory_utils", - ":string_utils", - ], -) - -libc_function( - name = "strncpy", - srcs = ["src/string/strncpy.cpp"], - hdrs = ["src/string/strncpy.h"], - deps = [ - ":__support_common", - ], -) - -libc_function( - name = "strcmp", - srcs = ["src/string/strcmp.cpp"], - hdrs = ["src/string/strcmp.h"], - deps = [ - ":__support_common", - ":string_memory_utils", - ":string_utils", - ], -) - -libc_function( - name = "strchr", - srcs = ["src/string/strchr.cpp"], - hdrs = ["src/string/strchr.h"], - deps = [ - ":__support_common", - ":string_utils", - ], -) - -libc_function( - name = "strrchr", - srcs = ["src/string/strrchr.cpp"], - hdrs = ["src/string/strrchr.h"], - deps = [ - ":__support_common", - ":string_utils", - ], -) - -libc_function( - name = "strstr", - srcs = ["src/string/strstr.cpp"], - hdrs = ["src/string/strstr.h"], - deps = [ - ":__support_common", - ":string_memory_utils", - ":string_utils", - ], -) - -libc_function( - name = "strnlen", - srcs = ["src/string/strnlen.cpp"], - hdrs = ["src/string/strnlen.h"], - deps = [ - ":__support_common", - ":string_utils", - ], -) - -libc_function( - name = "strcspn", - srcs = ["src/string/strcspn.cpp"], - hdrs = ["src/string/strcspn.h"], - deps = [ - ":__support_common", - ":string_utils", - ], -) - -libc_function( - name = "strspn", - srcs = ["src/string/strspn.cpp"], - hdrs = ["src/string/strspn.h"], - deps = [ - ":__support_common", - ":__support_cpp_bitset", - ":string_utils", - ], -) - -libc_function( - name = "strpbrk", - srcs = ["src/string/strpbrk.cpp"], - hdrs = ["src/string/strpbrk.h"], - deps = [ - ":__support_common", - ":string_utils", - ], -) - -libc_function( - name = "strtok", - srcs = ["src/string/strtok.cpp"], - hdrs = ["src/string/strtok.h"], - deps = [ - ":__support_common", - ":string_utils", - ], -) - -################################ fcntl targets ################################# - -libc_function( - name = "open", - srcs = ["src/fcntl/linux/open.cpp"], - hdrs = ["src/fcntl/open.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "openat", - srcs = ["src/fcntl/linux/openat.cpp"], - hdrs = ["src/fcntl/openat.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "creat", - srcs = ["src/fcntl/linux/creat.cpp"], - hdrs = ["src/fcntl/creat.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -################################ unistd targets ################################ - -libc_function( - name = "access", - srcs = ["src/unistd/linux/access.cpp"], - hdrs = ["src/unistd/access.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "chdir", - srcs = ["src/unistd/linux/chdir.cpp"], - hdrs = ["src/unistd/chdir.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "close", - srcs = ["src/unistd/linux/close.cpp"], - hdrs = ["src/unistd/close.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "dup", - srcs = ["src/unistd/linux/dup.cpp"], - hdrs = ["src/unistd/dup.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "dup2", - srcs = ["src/unistd/linux/dup2.cpp"], - hdrs = ["src/unistd/dup2.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "dup3", - srcs = ["src/unistd/linux/dup3.cpp"], - hdrs = ["src/unistd/dup3.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "environ", - srcs = ["src/unistd/environ.cpp"], - hdrs = ["src/unistd/environ.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "fchdir", - srcs = ["src/unistd/linux/fchdir.cpp"], - hdrs = ["src/unistd/fchdir.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "fsync", - srcs = ["src/unistd/linux/fsync.cpp"], - hdrs = ["src/unistd/fsync.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "ftruncate", - srcs = ["src/unistd/linux/ftruncate.cpp"], - hdrs = ["src/unistd/ftruncate.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -# libc_function( -# name = "getcwd", -# srcs = ["src/unistd/linux/getcwd.cpp"], -# hdrs = ["src/unistd/getcwd.h"], -# deps = [ -# ":__support_common", -# ":__support_osutil_syscall", -# ":errno", -# ], -# ) - -libc_function( - name = "geteuid", - srcs = ["src/unistd/linux/geteuid.cpp"], - hdrs = ["src/unistd/geteuid.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "getpid", - srcs = ["src/unistd/linux/getpid.cpp"], - hdrs = ["src/unistd/getpid.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "getppid", - srcs = ["src/unistd/linux/getppid.cpp"], - hdrs = ["src/unistd/getppid.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "getuid", - srcs = ["src/unistd/linux/getuid.cpp"], - hdrs = ["src/unistd/getuid.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -# libc_function( -# name = "getopt", -# srcs = ["src/unistd/getopt.cpp"], -# hdrs = ["src/unistd/getopt.h"], -# deps = [ -# ":__support_common", -# ":__support_cpp_optional", -# ":__support_cpp_string_view", -# ":__support_file_file", -# ":__support_osutil_syscall", -# ":errno", -# ], -# ) - -libc_function( - name = "isatty", - srcs = ["src/unistd/linux/isatty.cpp"], - hdrs = ["src/unistd/isatty.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "link", - srcs = ["src/unistd/linux/link.cpp"], - hdrs = ["src/unistd/link.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "linkat", - srcs = ["src/unistd/linux/linkat.cpp"], - hdrs = ["src/unistd/linkat.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "lseek", - srcs = ["src/unistd/linux/lseek.cpp"], - hdrs = ["src/unistd/lseek.h"], - deps = [ - ":__support_common", - ":__support_file_linux_lseekimpl", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "pread", - srcs = ["src/unistd/linux/pread.cpp"], - hdrs = ["src/unistd/pread.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "pwrite", - srcs = ["src/unistd/linux/pwrite.cpp"], - hdrs = ["src/unistd/pwrite.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "read", - srcs = ["src/unistd/linux/read.cpp"], - hdrs = ["src/unistd/read.h"], - weak = True, - deps = [ - ":__support_common", - ":__support_macros_sanitizer", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "readlink", - srcs = ["src/unistd/linux/readlink.cpp"], - hdrs = ["src/unistd/readlink.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "readlinkat", - srcs = ["src/unistd/linux/readlinkat.cpp"], - hdrs = ["src/unistd/readlinkat.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "rmdir", - srcs = ["src/unistd/linux/rmdir.cpp"], - hdrs = ["src/unistd/rmdir.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "symlink", - srcs = ["src/unistd/linux/symlink.cpp"], - hdrs = ["src/unistd/symlink.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "symlinkat", - srcs = ["src/unistd/linux/symlinkat.cpp"], - hdrs = ["src/unistd/symlinkat.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -#TODO: Enable once fullbuild is added to bazel, since this depends on a macro -# definition in the public header - -# libc_function( -# name = "syscall", -# srcs = ["src/unistd/linux/syscall.cpp"], -# hdrs = ["src/unistd/syscall.h"], -# deps = [ -# ":__support_common", -# ":__support_osutil_syscall", -# ":errno", -# ], -# ) - -libc_function( - name = "swab", - srcs = ["src/unistd/swab.cpp"], - hdrs = ["src/unistd/swab.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "truncate", - srcs = ["src/unistd/linux/truncate.cpp"], - hdrs = ["src/unistd/truncate.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "unlink", - srcs = ["src/unistd/linux/unlink.cpp"], - hdrs = ["src/unistd/unlink.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "unlinkat", - srcs = ["src/unistd/linux/unlinkat.cpp"], - hdrs = ["src/unistd/unlinkat.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "write", - srcs = ["src/unistd/linux/write.cpp"], - hdrs = ["src/unistd/write.h"], - weak = True, - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -################################ stdio targets ################################# - -libc_support_library( - name = "printf_config", - hdrs = ["src/stdio/printf_core/printf_config.h"], - defines = PRINTF_COPTS, - deps = [ - ], -) - -libc_support_library( - name = "printf_core_structs", - hdrs = ["src/stdio/printf_core/core_structs.h"], - defines = PRINTF_COPTS, - deps = [ - ":__support_cpp_string_view", - ":__support_fputil_fp_bits", - ":printf_config", - ], -) - -libc_support_library( - name = "printf_parser", - hdrs = ["src/stdio/printf_core/parser.h"], - defines = PRINTF_COPTS, - deps = [ - ":__support_arg_list", - ":__support_common", - ":__support_cpp_bit", - ":__support_cpp_optional", - ":__support_cpp_string_view", - ":__support_cpp_type_traits", - ":__support_ctype_utils", - ":__support_fputil_fp_bits", - ":__support_str_to_integer", - ":printf_config", - ":printf_core_structs", - ], -) - -# Only used for testing. -libc_support_library( - name = "printf_mock_parser", - hdrs = ["src/stdio/printf_core/parser.h"], - defines = PRINTF_COPTS + ["LIBC_COPT_MOCK_ARG_LIST"], - deps = [ - ":__support_arg_list", - ":__support_common", - ":__support_cpp_bit", - ":__support_cpp_optional", - ":__support_cpp_string_view", - ":__support_cpp_type_traits", - ":__support_ctype_utils", - ":__support_fputil_fp_bits", - ":__support_str_to_integer", - ":printf_config", - ":printf_core_structs", - ], -) - -libc_support_library( - name = "printf_writer", - srcs = ["src/stdio/printf_core/writer.cpp"], - hdrs = ["src/stdio/printf_core/writer.h"], - defines = PRINTF_COPTS, - deps = [ - ":__support_cpp_string_view", - ":__support_macros_optimization", - ":printf_core_structs", - ":string_memory_utils", - ], -) - -libc_support_library( - name = "printf_converter", - srcs = ["src/stdio/printf_core/converter.cpp"], - hdrs = [ - "src/stdio/printf_core/char_converter.h", - "src/stdio/printf_core/converter.h", - "src/stdio/printf_core/converter_atlas.h", - "src/stdio/printf_core/converter_utils.h", - "src/stdio/printf_core/float_dec_converter.h", - "src/stdio/printf_core/float_hex_converter.h", - "src/stdio/printf_core/float_inf_nan_converter.h", - "src/stdio/printf_core/int_converter.h", - "src/stdio/printf_core/ptr_converter.h", - "src/stdio/printf_core/string_converter.h", - "src/stdio/printf_core/write_int_converter.h", - ], - defines = PRINTF_COPTS, - deps = [ - ":__support_common", - ":__support_cpp_limits", - ":__support_cpp_span", - ":__support_cpp_string_view", - ":__support_float_to_string", - ":__support_fputil_fenv_impl", - ":__support_fputil_fp_bits", - ":__support_fputil_rounding_mode", - ":__support_integer_to_string", - ":__support_libc_assert", - ":__support_uint", - ":__support_uint128", - ":printf_config", - ":printf_core_structs", - ":printf_writer", - ], -) - -libc_support_library( - name = "printf_main", - srcs = ["src/stdio/printf_core/printf_main.cpp"], - hdrs = ["src/stdio/printf_core/printf_main.h"], - defines = PRINTF_COPTS, - deps = [ - ":__support_arg_list", - ":printf_converter", - ":printf_core_structs", - ":printf_parser", - ":printf_writer", - ], -) - -libc_support_library( - name = "vfprintf_internal", - hdrs = ["src/stdio/printf_core/vfprintf_internal.h"], - defines = PRINTF_COPTS, - deps = [ - ":__support_arg_list", - ":__support_file_file", - ":__support_macros_attributes", - ":printf_main", - ":printf_writer", - ], -) - -libc_function( - name = "sprintf", - srcs = ["src/stdio/sprintf.cpp"], - hdrs = ["src/stdio/sprintf.h"], - defines = PRINTF_COPTS, - deps = [ - ":__support_arg_list", - ":__support_cpp_limits", - ":errno", - ":printf_main", - ":printf_writer", - ], -) - -libc_function( - name = "snprintf", - srcs = ["src/stdio/snprintf.cpp"], - hdrs = ["src/stdio/snprintf.h"], - defines = PRINTF_COPTS, - deps = [ - ":__support_arg_list", - ":errno", - ":printf_main", - ":printf_writer", - ], -) - -libc_function( - name = "printf", - srcs = ["src/stdio/printf.cpp"], - hdrs = ["src/stdio/printf.h"], - defines = PRINTF_COPTS, - deps = [ - ":__support_arg_list", - ":__support_file_file", - ":errno", - ":vfprintf_internal", - ], -) - -libc_function( - name = "fprintf", - srcs = ["src/stdio/fprintf.cpp"], - hdrs = ["src/stdio/fprintf.h"], - defines = PRINTF_COPTS, - deps = [ - ":__support_arg_list", - ":__support_file_file", - ":errno", - ":vfprintf_internal", - ], -) - -libc_function( - name = "vsprintf", - srcs = ["src/stdio/vsprintf.cpp"], - hdrs = ["src/stdio/vsprintf.h"], - defines = PRINTF_COPTS, - deps = [ - ":__support_arg_list", - ":__support_cpp_limits", - ":errno", - ":printf_main", - ":printf_writer", - ], -) - -libc_function( - name = "vsnprintf", - srcs = ["src/stdio/vsnprintf.cpp"], - hdrs = ["src/stdio/vsnprintf.h"], - defines = PRINTF_COPTS, - deps = [ - ":__support_arg_list", - ":errno", - ":printf_main", - ":printf_writer", - ], -) - -libc_function( - name = "vprintf", - srcs = ["src/stdio/vprintf.cpp"], - hdrs = ["src/stdio/vprintf.h"], - defines = PRINTF_COPTS, - deps = [ - ":__support_arg_list", - ":__support_file_file", - ":errno", - ":vfprintf_internal", - ], -) - -libc_function( - name = "vfprintf", - srcs = ["src/stdio/vfprintf.cpp"], - hdrs = ["src/stdio/vfprintf.h"], - defines = PRINTF_COPTS, - deps = [ - ":__support_arg_list", - ":__support_file_file", - ":errno", - ":vfprintf_internal", - ], -) - -libc_function( - name = "remove", - srcs = ["src/stdio/linux/remove.cpp"], - hdrs = ["src/stdio/remove.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -############################### sys/stat targets ############################### - -libc_function( - name = "mkdir", - srcs = ["src/sys/stat/linux/mkdir.cpp"], - hdrs = ["src/sys/stat/mkdir.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "mkdirat", - srcs = ["src/sys/stat/linux/mkdirat.cpp"], - hdrs = ["src/sys/stat/mkdirat.h"], - deps = [ - ":__support_common", - ":__support_osutil_syscall", - ":errno", - ], -) - -############################## sys/epoll targets ############################### - -libc_function( - name = "epoll_wait", - srcs = ["src/sys/epoll/linux/epoll_wait.cpp"], - hdrs = ["src/sys/epoll/epoll_wait.h"], - weak = True, - deps = [ - ":__support_osutil_syscall", - ":errno", - ], -) - -libc_function( - name = "epoll_pwait", - srcs = ["src/sys/epoll/linux/epoll_pwait.cpp"], - hdrs = ["src/sys/epoll/epoll_pwait.h"], - weak = True, - deps = [ - ":__support_osutil_syscall", - ":errno", - ], -) - -#TODO: Enable once epoll_pwait2 availablilty can be checked first. -# https://github.com/llvm/llvm-project/issues/80060 -# libc_function( -# name = "epoll_pwait2", -# srcs = ["src/sys/epoll/linux/epoll_pwait2.cpp"], -# hdrs = ["src/sys/epoll/epoll_pwait2.h"], -# weak = True, -# deps = [ -# ":__support_osutil_syscall", -# ":errno", -# ], -# ) diff --git a/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl b/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl deleted file mode 100644 index 7d815bc4a2299c..00000000000000 --- a/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl +++ /dev/null @@ -1,160 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -"""LLVM libc starlark rules for building individual functions.""" - -load("@bazel_skylib//lib:paths.bzl", "paths") -load("@bazel_skylib//lib:selects.bzl", "selects") -load(":libc_namespace.bzl", "LIBC_NAMESPACE") -load(":platforms.bzl", "PLATFORM_CPU_ARM64", "PLATFORM_CPU_X86_64") - -def libc_internal_target(name): - return name + ".__internal__" - -def libc_common_copts(): - root_label = Label(":libc") - libc_include_path = paths.join(root_label.workspace_root, root_label.package) - return [ - "-I" + libc_include_path, - "-I" + paths.join(libc_include_path, "include"), - "-DLIBC_NAMESPACE=" + LIBC_NAMESPACE, - ] - -def _libc_library(name, hidden, copts = [], deps = [], **kwargs): - """Internal macro to serve as a base for all other libc library rules. - - Args: - name: Target name. - copts: The special compiler options for the target. - deps: The list of target dependencies if any. - hidden: Whether the symbols should be explicitly hidden or not. - **kwargs: All other attributes relevant for the cc_library rule. - """ - - # We want all libc sources to be compiled with "hidden" visibility. - # The public symbols will be given "default" visibility explicitly. - # See src/__support/common.h for more information. - if hidden: - copts = copts + ["-fvisibility=hidden"] - native.cc_library( - name = name, - copts = copts + libc_common_copts(), - deps = deps, - linkstatic = 1, - **kwargs - ) - -# A convenience function which should be used to list all libc support libraries. -# Any library which does not define a public function should be listed with -# libc_support_library. -def libc_support_library(name, **kwargs): - _libc_library(name = name, hidden = False, **kwargs) - -def libc_function( - name, - srcs, - weak = False, - copts = None, - local_defines = None, - **kwargs): - """Add target for a libc function. - - The libc function is eventually available as a cc_library target by name - "name". LLVM libc implementations of libc functions are in C++. So, this - rule internally generates a C wrapper for the C++ implementation and adds - it to the source list of the cc_library. This way, the C++ implementation - and the C wrapper are both available in the cc_library. - - Args: - name: Target name. It is normally the name of the function this target is - for. - srcs: The .cpp files which contain the function implementation. - weak: Make the symbol corresponding to the libc function "weak". - deps: The list of target dependencies if any. - copts: The list of options to add to the C++ compilation command. - local_defines: The preprocessor defines which will be prepended with -D - and passed to the compile command of this target but not - its deps. - **kwargs: Other attributes relevant for a cc_library. For example, deps. - """ - - # We use the explicit equals pattern here because append and += mutate the - # original list, where this creates a new list and stores it in deps. - copts = copts or [] - copts = copts + [ - "-O3", - "-fno-builtin", - "-fno-lax-vector-conversions", - "-ftrivial-auto-var-init=pattern", - ] - - # We compile the code twice, the first target is suffixed with ".__internal__" and contains the - # C++ functions in the "LIBC_NAMESPACE" namespace. This allows us to test the function in the - # presence of another libc. - libc_support_library( - name = libc_internal_target(name), - srcs = srcs, - copts = copts, - **kwargs - ) - - # This second target is the llvm libc C function with either a default or hidden visibility. - # All other functions are hidden. - func_attrs = ["__attribute__((visibility(\"default\")))"] - if weak: - func_attrs = func_attrs + ["__attribute__((weak))"] - local_defines = local_defines or ["LIBC_COPT_PUBLIC_PACKAGING"] - local_defines = local_defines + ["LLVM_LIBC_FUNCTION_ATTR='%s'" % " ".join(func_attrs)] - _libc_library( - name = name, - hidden = True, - srcs = srcs, - copts = copts, - local_defines = local_defines, - **kwargs - ) - -def libc_math_function( - name, - specializations = None, - additional_deps = None): - """Add a target for a math function. - - Args: - name: The name of the function. - specializations: List of machine specializations available for this - function. Possible specializations are "generic", - "aarch64" and "x86_64". - additional_deps: Other deps like helper cc_library targes used by the - math function. - """ - additional_deps = additional_deps or [] - specializations = specializations or ["generic"] - select_map = {} - if "generic" in specializations: - select_map["//conditions:default"] = ["src/math/generic/" + name + ".cpp"] - if "aarch64" in specializations: - select_map[PLATFORM_CPU_ARM64] = ["src/math/aarch64/" + name + ".cpp"] - if "x86_64" in specializations: - select_map[PLATFORM_CPU_X86_64] = ["src/math/x86_64/" + name + ".cpp"] - - #TODO(michaelrj): Fix the floating point dependencies - OLD_FPUTIL_DEPS = [ - ":__support_fputil_basic_operations", - ":__support_fputil_division_and_remainder_operations", - ":__support_fputil_fenv_impl", - ":__support_fputil_fp_bits", - ":__support_fputil_hypot", - ":__support_fputil_manipulation_functions", - ":__support_fputil_nearest_integer_operations", - ":__support_fputil_normal_float", - ":__support_math_extras", - ":__support_fputil_except_value_utils", - ] - libc_function( - name = name, - srcs = selects.with_or(select_map), - hdrs = ["src/math/" + name + ".h"], - deps = [":__support_common"] + OLD_FPUTIL_DEPS + additional_deps, - ) diff --git a/utils/bazel/llvm-project-overlay/libc/libc_namespace.bzl b/utils/bazel/llvm-project-overlay/libc/libc_namespace.bzl deleted file mode 100644 index a59aeea73713d6..00000000000000 --- a/utils/bazel/llvm-project-overlay/libc/libc_namespace.bzl +++ /dev/null @@ -1,10 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -"""LLVM libc namespace declaration.""" - -load("//:vars.bzl", "LLVM_VERSION_MAJOR", "LLVM_VERSION_MINOR", "LLVM_VERSION_PATCH") - -# The default libc namespace that encloses all functions. -LIBC_NAMESPACE = "__llvm_libc_{}_{}_{}_git".format(LLVM_VERSION_MAJOR, LLVM_VERSION_MINOR, LLVM_VERSION_PATCH) diff --git a/utils/bazel/llvm-project-overlay/libc/platforms.bzl b/utils/bazel/llvm-project-overlay/libc/platforms.bzl deleted file mode 100644 index 7137984740e24d..00000000000000 --- a/utils/bazel/llvm-project-overlay/libc/platforms.bzl +++ /dev/null @@ -1,9 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -"""Defines global variables that lists target cpus""" - -PLATFORM_CPU_ARM64 = ("@platforms//cpu:arm64") - -PLATFORM_CPU_X86_64 = ("@platforms//cpu:x86_64") diff --git a/utils/bazel/llvm-project-overlay/libc/test/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/BUILD.bazel deleted file mode 100644 index 70b0196469eca1..00000000000000 --- a/utils/bazel/llvm-project-overlay/libc/test/BUILD.bazel +++ /dev/null @@ -1,7 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -package(default_visibility = ["//visibility:public"]) - -exports_files(["libc_test_rules.bzl"]) diff --git a/utils/bazel/llvm-project-overlay/libc/test/UnitTest/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/UnitTest/BUILD.bazel deleted file mode 100644 index 4a94916e1205e0..00000000000000 --- a/utils/bazel/llvm-project-overlay/libc/test/UnitTest/BUILD.bazel +++ /dev/null @@ -1,133 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# LLVM libc unittest library. - -load("//libc:libc_build_rules.bzl", "libc_support_library") - -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) - -libc_support_library( - name = "test_logger", - srcs = ["TestLogger.cpp"], - hdrs = ["TestLogger.h"], - deps = [ - "//libc:__support_cpp_string", - "//libc:__support_cpp_string_view", - "//libc:__support_macros_properties_types", - "//libc:__support_osutil_io", - "//libc:__support_uint", - "//libc:__support_uint128", - ], -) - -libc_support_library( - name = "LibcUnitTest", - srcs = [ - "BazelFilePath.cpp", - "ExecuteFunctionUnix.cpp", - "LibcTest.cpp", - "LibcTestMain.cpp", - ], - hdrs = [ - "ErrnoSetterMatcher.h", - "ExecuteFunction.h", - "LibcTest.h", - "PlatformDefs.h", - "Test.h", - ], - deps = [ - ":test_logger", - "//libc:__support_c_string", - "//libc:__support_cpp_bit", - "//libc:__support_cpp_bitset", - "//libc:__support_cpp_span", - "//libc:__support_cpp_string", - "//libc:__support_cpp_string_view", - "//libc:__support_cpp_type_traits", - "//libc:__support_fixed_point", - "//libc:__support_fputil_fp_bits", - "//libc:__support_fputil_fpbits_str", - "//libc:__support_fputil_rounding_mode", - "//libc:__support_macros_properties_architectures", - "//libc:__support_macros_properties_types", - "//libc:__support_stringutil", - "//libc:__support_uint128", - "//libc:errno", - "//libc:llvm_libc_macros_stdfix_macros", - "//llvm:Support", - ], -) - -libc_support_library( - name = "fp_test_helpers", - srcs = [ - "FPExceptMatcher.cpp", - "RoundingModeUtils.cpp", - ], - hdrs = [ - "FPExceptMatcher.h", - "FPMatcher.h", - "RoundingModeUtils.h", - ], - deps = [ - ":LibcUnitTest", - ":string_utils", - "//libc:__support_cpp_bit", - "//libc:__support_cpp_bitset", - "//libc:__support_cpp_span", - "//libc:__support_cpp_type_traits", - "//libc:__support_fputil_fenv_impl", - "//libc:__support_fputil_fp_bits", - "//libc:__support_fputil_fpbits_str", - "//libc:__support_fputil_rounding_mode", - ], -) - -libc_support_library( - name = "memory_matcher", - srcs = [ - "MemoryMatcher.cpp", - ], - hdrs = [ - "MemoryMatcher.h", - ], - deps = [ - ":LibcUnitTest", - "//libc:__support_cpp_bit", - "//libc:__support_cpp_bitset", - "//libc:__support_cpp_span", - "//libc:__support_cpp_type_traits", - ], -) - -libc_support_library( - name = "printf_matcher", - srcs = [ - "PrintfMatcher.cpp", - ], - hdrs = [ - "PrintfMatcher.h", - ], - deps = [ - ":LibcUnitTest", - ":string_utils", - "//libc:__support_fputil_fp_bits", - "//libc:printf_core_structs", - ], -) - -libc_support_library( - name = "string_utils", - hdrs = [ - "StringUtils.h", - ], - deps = [ - "//libc:__support_cpp_string", - "//libc:__support_cpp_type_traits", - "//libc:__support_uint", - ], -) diff --git a/utils/bazel/llvm-project-overlay/libc/test/libc_test_rules.bzl b/utils/bazel/llvm-project-overlay/libc/test/libc_test_rules.bzl deleted file mode 100644 index 18056bacfd50ce..00000000000000 --- a/utils/bazel/llvm-project-overlay/libc/test/libc_test_rules.bzl +++ /dev/null @@ -1,39 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -"""LLVM libc starlark rules for tests. - -libc functions are created though the libc_build_rules.bzl:libc_function. -They come in two flavors: - - the internal one that is scoped into the `LIBC_NAMESPACE` namespace. - - the libc one that is the regular C function. - -When performing tests we make sure to always use the internal version. -""" - -load("//libc:libc_build_rules.bzl", "libc_common_copts", "libc_internal_target") - -def libc_test(name, srcs, libc_function_deps = [], copts = [], deps = [], **kwargs): - """Add target for a libc test. - - Args: - name: Test target name - srcs: List of sources for the test. - libc_function_deps: List of libc_function targets used by this test. - copts: The list of options to add to the C++ compilation command. - deps: The list of other libraries to be linked in to the test target. - **kwargs: Attributes relevant for a libc_test. For example, name, srcs. - """ - all_function_deps = libc_function_deps + ["//libc:errno"] - native.cc_test( - name = name, - srcs = srcs, - deps = [libc_internal_target(d) for d in all_function_deps] + [ - "//libc/test/UnitTest:LibcUnitTest", - ] + deps, - features = ["-link_llvmlibc"], # Do not link libllvmlibc.a - copts = copts + libc_common_copts(), - linkstatic = 1, - **kwargs - ) diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/__support/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/__support/BUILD.bazel deleted file mode 100644 index 5434761a9b1392..00000000000000 --- a/utils/bazel/llvm-project-overlay/libc/test/src/__support/BUILD.bazel +++ /dev/null @@ -1,118 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# Tests for LLVM libc __support functions. - -load("//libc/test:libc_test_rules.bzl", "libc_test") - -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) - -libc_test( - name = "math_extras_test", - srcs = ["math_extras_test.cpp"], - deps = [ - "//libc:__support_integer_literals", - "//libc:__support_math_extras", - "//libc:__support_uint128", - ], -) - -# This test is currently disabled because of an issue in -# `libc/src/__support/CPP/new.h` which currently fails with -# "error: cannot apply asm label to function after its first use" -# libc_test( -# name = "blockstore_test", -# srcs = ["blockstore_test.cpp"], -# deps = ["//libc:__support_blockstore"], -# ) - -libc_test( - name = "endian_test", - srcs = ["endian_test.cpp"], - deps = ["//libc:__support_common"], -) - -libc_test( - name = "high_precision_decimal_test", - srcs = ["high_precision_decimal_test.cpp"], - deps = [ - "//libc:__support_str_to_float", - "//libc:__support_uint128", - ], -) - -libc_test( - name = "str_to_float_test", - srcs = [ - "str_to_double_test.cpp", - "str_to_float_test.cpp", - "str_to_fp_test.h", - "str_to_long_double_test.cpp", - ], - deps = [ - "//libc:__support_fputil_fp_bits", - "//libc:__support_integer_literals", - "//libc:__support_str_to_float", - "//libc:__support_uint128", - ], -) - -libc_test( - name = "integer_to_string_test", - srcs = ["integer_to_string_test.cpp"], - deps = [ - "//libc:__support_cpp_span", - "//libc:__support_cpp_limits", - "//libc:__support_cpp_string_view", - "//libc:__support_integer_literals", - "//libc:__support_integer_to_string", - "//libc:__support_uint", - "//libc:__support_uint128", - ], -) - -libc_test( - name = "arg_list_test", - srcs = ["arg_list_test.cpp"], - deps = [ - "//libc:__support_arg_list", - ], -) - -libc_test( - name = "uint_test", - srcs = ["uint_test.cpp"], - deps = [ - "//libc:__support_cpp_optional", - "//libc:__support_macros_properties_types", - "//libc:__support_uint", - ], -) - -libc_test( - name = "fixedvector_test", - srcs = ["fixedvector_test.cpp"], - deps = [ - "//libc:__support_fixedvector", - ], -) - -libc_test( - name = "char_vector_test", - srcs = ["char_vector_test.cpp"], - deps = [ - "//libc:__support_char_vector", - ], -) - -libc_test( - name = "integer_literals_test", - srcs = ["integer_literals_test.cpp"], - deps = [ - "//libc:__support_integer_literals", - "//libc:__support_macros_properties_types", - ], -) diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/__support/CPP/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/__support/CPP/BUILD.bazel deleted file mode 100644 index dad1c7708e448d..00000000000000 --- a/utils/bazel/llvm-project-overlay/libc/test/src/__support/CPP/BUILD.bazel +++ /dev/null @@ -1,97 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# Tests for LLVM libc CPP functions. - -load("//libc/test:libc_test_rules.bzl", "libc_test") - -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) - -libc_test( - name = "atomic_test", - srcs = ["atomic_test.cpp"], - deps = ["//libc:__support_cpp_atomic"], -) - -libc_test( - name = "bitset_test", - srcs = ["bitset_test.cpp"], - deps = ["//libc:__support_cpp_bitset"], -) - -libc_test( - name = "bit_test", - srcs = ["bit_test.cpp"], - deps = [ - "//libc:__support_cpp_bit", - "//libc:__support_macros_properties_types", - "//libc:__support_uint", - ], -) - -libc_test( - name = "cstddef_test", - srcs = ["cstddef_test.cpp"], - deps = ["//libc:__support_cpp_cstddef"], -) - -libc_test( - name = "integer_sequence_test", - srcs = ["integer_sequence_test.cpp"], - deps = ["//libc:__support_cpp_utility"], -) - -libc_test( - name = "limits_test", - srcs = ["limits_test.cpp"], - deps = [ - "//libc:__support_cpp_limits", - "//libc:__support_macros_properties_types", - "//libc:__support_uint", - ], -) - -libc_test( - name = "optional_test", - srcs = ["optional_test.cpp"], - deps = ["//libc:__support_cpp_optional"], -) - -libc_test( - name = "span_test", - srcs = ["span_test.cpp"], - deps = [ - "//libc:__support_cpp_array", - "//libc:__support_cpp_span", - ], -) - -libc_test( - name = "stringstream_test", - srcs = ["stringstream_test.cpp"], - deps = [ - "//libc:__support_cpp_span", - "//libc:__support_cpp_stringstream", - ], -) - -libc_test( - name = "string_test", - srcs = ["string_test.cpp"], - deps = ["//libc:__support_cpp_string"], -) - -libc_test( - name = "stringview_test", - srcs = ["stringview_test.cpp"], - deps = ["//libc:__support_cpp_string_view"], -) - -libc_test( - name = "type_traits_test", - srcs = ["type_traits_test.cpp"], - deps = ["//libc:__support_cpp_type_traits"], -) diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/__support/FPUtil/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/__support/FPUtil/BUILD.bazel deleted file mode 100644 index 76443fc5d9f85b..00000000000000 --- a/utils/bazel/llvm-project-overlay/libc/test/src/__support/FPUtil/BUILD.bazel +++ /dev/null @@ -1,44 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# Tests for LLVM libc __support functions. - -load("//libc/test:libc_test_rules.bzl", "libc_test") - -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) - -libc_test( - name = "fpbits_test", - srcs = ["fpbits_test.cpp"], - deps = [ - "//libc:__support_fputil_fp_bits", - "//libc:__support_fputil_fpbits_str", - "//libc:__support_integer_literals", - ], -) - -libc_test( - name = "dyadic_float_test", - srcs = ["dyadic_float_test.cpp"], - copts = ["-frounding-math"], - deps = [ - "//libc:__support_fputil_dyadic_float", - "//libc:__support_uint", - "//libc:__support_uint128", - "//libc/test/UnitTest:fp_test_helpers", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -libc_test( - name = "rounding_mode_test", - srcs = ["rounding_mode_test.cpp"], - deps = [ - "//libc:__support_fputil_rounding_mode", - "//libc:__support_uint128", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/fenv/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/fenv/BUILD.bazel deleted file mode 100644 index f64f78c113c01e..00000000000000 --- a/utils/bazel/llvm-project-overlay/libc/test/src/fenv/BUILD.bazel +++ /dev/null @@ -1,127 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# Tests for LLVM libc math.h functions. - -load("//libc/test:libc_test_rules.bzl", "libc_test") - -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) - -libc_test( - name = "exception_status_test", - srcs = ["exception_status_test.cpp"], - libc_function_deps = [ - "//libc:feclearexcept", - "//libc:feraiseexcept", - "//libc:fetestexcept", - ], - deps = [ - "//libc:__support_fputil_fenv_impl", - ], -) - -libc_test( - name = "rounding_mode_test", - srcs = ["rounding_mode_test.cpp"], - libc_function_deps = [ - "//libc:fegetround", - "//libc:fesetround", - ], -) - -libc_test( - name = "enabled_exceptions_test", - srcs = ["enabled_exceptions_test.cpp"], - libc_function_deps = [ - "//libc:feclearexcept", - "//libc:feraiseexcept", - "//libc:fetestexcept", - ], - tags = ["nosan"], - deps = [ - "//libc:__support_common", - "//libc:__support_fputil_fenv_impl", - "//libc:__support_macros_properties_architectures", - "//libc/test/UnitTest:fp_test_helpers", - ], -) - -libc_test( - name = "feholdexcept_test", - srcs = ["feholdexcept_test.cpp"], - libc_function_deps = [ - "//libc:feholdexcept", - ], - tags = ["nosan"], - deps = [ - "//libc:__support_common", - "//libc:__support_fputil_fenv_impl", - "//libc:__support_macros_properties_architectures", - "//libc/test/UnitTest:fp_test_helpers", - ], -) - -libc_test( - name = "exception_flags_test", - srcs = ["exception_flags_test.cpp"], - libc_function_deps = [ - "//libc:fegetexceptflag", - "//libc:fesetexceptflag", - ], - deps = [ - "//libc:__support_fputil_fenv_impl", - ], -) - -libc_test( - name = "feclearexcept_test", - srcs = ["feclearexcept_test.cpp"], - libc_function_deps = [ - "//libc:feclearexcept", - ], - deps = [ - "//libc:__support_fputil_fenv_impl", - ], -) - -libc_test( - name = "feenableexcept_test", - srcs = ["feenableexcept_test.cpp"], - libc_function_deps = [ - "//libc:fedisableexcept", - "//libc:feenableexcept", - "//libc:fegetexcept", - ], - deps = [ - "//libc:__support_common", - "//libc:__support_macros_properties_architectures", - ], -) - -libc_test( - name = "feupdateenv_test", - srcs = ["feupdateenv_test.cpp"], - libc_function_deps = [ - "//libc:feupdateenv", - ], - deps = [ - "//libc:__support_fputil_fenv_impl", - ], -) - -libc_test( - name = "getenv_and_setenv_test", - srcs = ["getenv_and_setenv_test.cpp"], - libc_function_deps = [ - "//libc:fegetenv", - "//libc:fegetround", - "//libc:fesetenv", - "//libc:fesetround", - ], - deps = [ - "//libc:__support_fputil_fenv_impl", - ], -) diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/inttypes/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/inttypes/BUILD.bazel deleted file mode 100644 index bda7245d1f6775..00000000000000 --- a/utils/bazel/llvm-project-overlay/libc/test/src/inttypes/BUILD.bazel +++ /dev/null @@ -1,30 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# Tests for LLVM libc inttypes.h functions. - -load("//libc/test:libc_test_rules.bzl", "libc_test") - -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) - -libc_test( - name = "imaxabs_test", - srcs = ["imaxabs_test.cpp"], - libc_function_deps = [ - "//libc:imaxabs", - ], -) - -libc_test( - name = "imaxdiv_test", - srcs = ["imaxdiv_test.cpp"], - libc_function_deps = [ - "//libc:imaxdiv", - ], - deps = [ - "//libc/test/src/stdlib:div_test_helper", - ], -) diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel deleted file mode 100644 index 63e18b83710918..00000000000000 --- a/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel +++ /dev/null @@ -1,807 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# Tests for LLVM libc math.h functions. - -load("//libc:libc_build_rules.bzl", "libc_support_library") -load("//libc/test/src/math:libc_math_test_rules.bzl", "math_test") - -package(default_visibility = ["//visibility:public"]) - -exports_files(["libc_math_test_rules.bzl"]) - -licenses(["notice"]) - -math_test( - name = "fabs", - hdrs = ["FAbsTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "fabsf", - hdrs = ["FAbsTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "fabsl", - hdrs = ["FAbsTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "ceil", - hdrs = ["CeilTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "ceilf", - hdrs = ["CeilTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "ceill", - hdrs = ["CeilTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "floor", - hdrs = ["FloorTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "floorf", - hdrs = ["FloorTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "floorl", - hdrs = ["FloorTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "trunc", - hdrs = ["TruncTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "truncf", - hdrs = ["TruncTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "truncl", - hdrs = ["TruncTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "round", - hdrs = ["RoundTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "roundf", - hdrs = ["RoundTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "roundl", - hdrs = ["RoundTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "frexp", - hdrs = ["FrexpTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "frexpf", - hdrs = ["FrexpTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "frexpl", - hdrs = ["FrexpTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "hypot", - hdrs = ["HypotTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "hypotf", - hdrs = [ - "HypotTest.h", - "hypotf_hard_to_round.h", - ], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "logb", - hdrs = ["LogbTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "logbf", - hdrs = ["LogbTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "logbl", - hdrs = ["LogbTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "modf", - hdrs = ["ModfTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "modff", - hdrs = ["ModfTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "modfl", - hdrs = ["ModfTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -libc_support_library( - name = "remquo_test_template", - hdrs = ["RemQuoTest.h"], - deps = [ - "//libc:__support_fputil_basic_operations", - "//libc:__support_fputil_fp_bits", - "//libc/test/UnitTest:LibcUnitTest", - "//libc/test/UnitTest:fp_test_helpers", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "remquo", - deps = [ - ":remquo_test_template", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "remquof", - deps = [ - ":remquo_test_template", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "remquol", - deps = [ - ":remquo_test_template", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "fmin", - hdrs = ["FMinTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "fminf", - hdrs = ["FMinTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "fminl", - hdrs = ["FMinTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "fmax", - hdrs = ["FMaxTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "fmaxf", - hdrs = ["FMaxTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "fmaxl", - hdrs = ["FMaxTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "sqrt", - hdrs = ["SqrtTest.h"], - deps = [ - "//libc:__support_cpp_bit", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "sqrtf", - hdrs = ["SqrtTest.h"], - deps = [ - "//libc:__support_cpp_bit", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "sqrtl", - hdrs = ["SqrtTest.h"], - deps = [ - "//libc:__support_cpp_bit", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "copysign", - hdrs = ["CopySignTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "copysignf", - hdrs = ["CopySignTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -math_test( - name = "copysignl", - hdrs = ["CopySignTest.h"], - deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], -) - -libc_support_library( - name = "ilogb_test_template", - hdrs = ["ILogbTest.h"], - deps = [ - "//libc:__support_cpp_limits", - "//libc:__support_fputil_fp_bits", - "//libc:__support_fputil_manipulation_functions", - "//libc/test/UnitTest:LibcUnitTest", - ], -) - -math_test( - name = "ilogb", - deps = [":ilogb_test_template"], -) - -math_test( - name = "ilogbf", - deps = [":ilogb_test_template"], -) - -math_test( - name = "ilogbl", - deps = [":ilogb_test_template"], -) - -libc_support_library( - name = "fdim_test_template", - hdrs = ["FDimTest.h"], - deps = [ - "//libc:__support_fputil_basic_operations", - "//libc:__support_fputil_fenv_impl", - "//libc:__support_fputil_fp_bits", - "//libc/test/UnitTest:LibcUnitTest", - "//libc/test/UnitTest:fp_test_helpers", - ], -) - -math_test( - name = "fdim", - deps = [":fdim_test_template"], -) - -math_test( - name = "fdimf", - deps = [":fdim_test_template"], -) - -math_test( - name = "fdiml", - deps = [":fdim_test_template"], -) - -libc_support_library( - name = "ldexp_test_template", - hdrs = ["LdExpTest.h"], - deps = [ - "//libc:__support_cpp_limits", - "//libc:__support_fputil_fp_bits", - "//libc:__support_fputil_normal_float", - "//libc/test/UnitTest:LibcUnitTest", - "//libc/test/UnitTest:fp_test_helpers", - ], -) - -math_test( - name = "ldexp", - deps = [":ldexp_test_template"], -) - -math_test( - name = "ldexpf", - deps = [":ldexp_test_template"], -) - -math_test( - name = "ldexpl", - deps = [":ldexp_test_template"], -) - -libc_support_library( - name = "rint_test_template", - hdrs = ["RIntTest.h"], - deps = [ - "//libc:__support_fputil_fenv_impl", - "//libc:__support_fputil_fp_bits", - "//libc/test/UnitTest:LibcUnitTest", - "//libc/test/UnitTest:fp_test_helpers", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "rint", - deps = [ - ":rint_test_template", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "rintf", - deps = [ - ":rint_test_template", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "rintl", - deps = [ - ":rint_test_template", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -libc_support_library( - name = "round_to_integer_test_template", - hdrs = ["RoundToIntegerTest.h"], - deps = [ - "//libc:__support_fputil_fenv_impl", - "//libc:__support_fputil_fp_bits", - "//libc/test/UnitTest:LibcUnitTest", - "//libc/test/UnitTest:fp_test_helpers", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "lrint", - deps = [ - ":round_to_integer_test_template", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "lrintf", - deps = [ - ":round_to_integer_test_template", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "lrintl", - deps = [ - ":round_to_integer_test_template", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "llrint", - deps = [ - ":round_to_integer_test_template", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "llrintf", - deps = [ - ":round_to_integer_test_template", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "llrintl", - deps = [ - ":round_to_integer_test_template", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "lround", - deps = [ - ":round_to_integer_test_template", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "lroundf", - deps = [ - ":round_to_integer_test_template", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "lroundl", - deps = [ - ":round_to_integer_test_template", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "llround", - deps = [ - ":round_to_integer_test_template", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "llroundf", - deps = [ - ":round_to_integer_test_template", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "llroundl", - deps = [ - ":round_to_integer_test_template", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -libc_support_library( - name = "nextafter_test_template", - hdrs = ["NextAfterTest.h"], - deps = [ - "//libc:__support_cpp_array", - "//libc:__support_cpp_bit", - "//libc:__support_cpp_type_traits", - "//libc:__support_fputil_basic_operations", - "//libc:__support_fputil_fp_bits", - "//libc/test/UnitTest:LibcUnitTest", - "//libc/test/UnitTest:fp_test_helpers", - ], -) - -math_test( - name = "nextafter", - deps = [":nextafter_test_template"], -) - -math_test( - name = "nextafterf", - deps = [":nextafter_test_template"], -) - -math_test( - name = "nextafterl", - deps = [":nextafter_test_template"], -) - -libc_support_library( - name = "sdcomp26094", - hdrs = ["sdcomp26094.h"], - deps = ["//libc:__support_cpp_array"], -) - -math_test( - name = "cosf", - deps = [ - ":sdcomp26094", - "//libc:__support_cpp_array", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "sincosf", - deps = [ - ":sdcomp26094", - "//libc:__support_cpp_array", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "sinf", - deps = [ - ":sdcomp26094", - "//libc:__support_cpp_array", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "tanf", - deps = [ - ":sdcomp26094", - "//libc:__support_cpp_array", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "expf", - deps = [ - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "exp2f", - deps = [ - "//libc:__support_macros_properties_cpu_features", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "exp10f", - deps = [ - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "expm1f", - deps = [ - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "logf", - deps = [ - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "log2f", - deps = [ - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "log10f", - deps = [ - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "log1pf", - deps = [ - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "log", - deps = [ - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "log2", - deps = [ - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "log10", - deps = [ - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "log1p", - deps = [ - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "sinhf", - deps = [ - "//libc:__support_cpp_array", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "coshf", - deps = [ - "//libc:__support_cpp_array", - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "tanhf", - deps = [ - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "asinhf", - deps = [ - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "acoshf", - deps = [ - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "atanhf", - deps = [ - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "asinf", - deps = [ - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "acosf", - deps = [ - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "atanf", - deps = [ - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "erff", - deps = [ - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "exp", - deps = [ - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "exp2", - deps = [ - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "exp10", - deps = [ - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "powf", - deps = [ - "//libc/utils/MPFRWrapper:mpfr_wrapper", - ], -) - -math_test( - name = "fmod", - hdrs = ["FModTest.h"], -) - -math_test( - name = "fmodf", - hdrs = ["FModTest.h"], -) - -math_test( - name = "scalbn", - hdrs = [ - "LdExpTest.h", - "ScalbnTest.h", - ], - deps = ["//libc:__support_cpp_limits"], -) - -math_test( - name = "scalbnf", - hdrs = [ - "LdExpTest.h", - "ScalbnTest.h", - ], - deps = ["//libc:__support_cpp_limits"], -) - -math_test( - name = "scalbnl", - hdrs = [ - "LdExpTest.h", - "ScalbnTest.h", - ], - deps = ["//libc:__support_cpp_limits"], -) diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/libc_math_test_rules.bzl b/utils/bazel/llvm-project-overlay/libc/test/src/math/libc_math_test_rules.bzl deleted file mode 100644 index aba259ba6401a5..00000000000000 --- a/utils/bazel/llvm-project-overlay/libc/test/src/math/libc_math_test_rules.bzl +++ /dev/null @@ -1,39 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -"""LLVM libc starlark rules for math tests. - -This rule delegates testing to libc_test_rules.bzl:libc_test. -It adds common math dependencies. -""" - -load("//libc/test:libc_test_rules.bzl", "libc_test") - -def math_test(name, hdrs = [], deps = [], **kwargs): - """Add a target for the unittest of a math function. - - Args: - name: The name of the function being tested. - hdrs: List of headers to add. - deps: The list of other libraries to be linked in to the test target. - **kwargs: Attributes relevant for a cc_test. For example, name, srcs. - """ - test_name = name + "_test" - libc_test( - name = test_name, - srcs = [test_name + ".cpp"] + hdrs, - libc_function_deps = ["//libc:func_name".replace("func_name", name)], - deps = [ - "//libc:__support_fputil_basic_operations", - "//libc:__support_fputil_fenv_impl", - "//libc:__support_fputil_fp_bits", - "//libc:__support_fputil_manipulation_functions", - "//libc:__support_fputil_nearest_integer_operations", - "//libc:__support_fputil_normal_float", - "//libc:__support_math_extras", - "//libc:__support_uint128", - "//libc/test/UnitTest:fp_test_helpers", - ] + deps, - **kwargs - ) diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/stdio/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/stdio/BUILD.bazel deleted file mode 100644 index 145ef86380b621..00000000000000 --- a/utils/bazel/llvm-project-overlay/libc/test/src/stdio/BUILD.bazel +++ /dev/null @@ -1,134 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# Tests for LLVM libc stdio.h functions. - -load("//libc/test:libc_test_rules.bzl", "libc_test") - -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) - -libc_test( - name = "printf_parser_test", - srcs = ["printf_core/parser_test.cpp"], - libc_function_deps = [ - ], - deps = [ - "//libc:__support_arg_list", - "//libc:__support_cpp_bit", - "//libc:__support_cpp_string_view", - "//libc:printf_core_structs", - "//libc:printf_parser", - "//libc/test/UnitTest:printf_matcher", - ], -) - -libc_test( - name = "printf_writer_test", - srcs = ["printf_core/writer_test.cpp"], - libc_function_deps = [ - ], - deps = [ - "//libc:__support_arg_list", - "//libc:__support_cpp_string_view", - "//libc:printf_core_structs", - "//libc:printf_writer", - "//libc:string_memory_utils", - ], -) - -libc_test( - name = "printf_converter_test", - srcs = ["printf_core/converter_test.cpp"], - libc_function_deps = [ - ], - deps = [ - "//libc:__support_arg_list", - "//libc:__support_cpp_string_view", - "//libc:printf_converter", - "//libc:printf_core_structs", - "//libc:printf_writer", - ], -) - -libc_test( - name = "sprintf_test", - srcs = ["sprintf_test.cpp"], - libc_function_deps = [ - "//libc:sprintf", - ], - deps = [ - "//libc:__support_fputil_fp_bits", - "//libc/test/UnitTest:fp_test_helpers", - ], -) - -libc_test( - name = "snprintf_test", - srcs = ["snprintf_test.cpp"], - libc_function_deps = [ - "//libc:snprintf", - ], -) - -libc_test( - name = "printf_test", - srcs = ["printf_test.cpp"], - libc_function_deps = [ - "//libc:printf", - ], -) - -libc_test( - name = "fprintf_test", - srcs = ["fprintf_test.cpp"], - libc_function_deps = [ - "//libc:fprintf", - ], -) - -libc_test( - name = "vsprintf_test", - srcs = ["vsprintf_test.cpp"], - libc_function_deps = [ - "//libc:vsprintf", - ], -) - -libc_test( - name = "vsnprintf_test", - srcs = ["vsnprintf_test.cpp"], - libc_function_deps = [ - "//libc:vsnprintf", - ], -) - -libc_test( - name = "vprintf_test", - srcs = ["vprintf_test.cpp"], - libc_function_deps = [ - "//libc:vprintf", - ], -) - -libc_test( - name = "vfprintf_test", - srcs = ["vfprintf_test.cpp"], - libc_function_deps = [ - "//libc:vfprintf", - ], -) - -libc_test( - name = "remove_test", - srcs = ["remove_test.cpp"], - libc_function_deps = [ - "//libc:remove", - "//libc:open", - "//libc:mkdirat", - "//libc:access", - "//libc:close", - ], -) diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/stdlib/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/stdlib/BUILD.bazel deleted file mode 100644 index b34e281ce0ecd6..00000000000000 --- a/utils/bazel/llvm-project-overlay/libc/test/src/stdlib/BUILD.bazel +++ /dev/null @@ -1,183 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# Tests for LLVM libc stdlib.h functions. - -load("//libc:libc_build_rules.bzl", "libc_support_library") -load("//libc/test:libc_test_rules.bzl", "libc_test") - -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) - -libc_test( - name = "abs_test", - srcs = ["abs_test.cpp"], - libc_function_deps = ["//libc:abs"], -) - -libc_test( - name = "labs_test", - srcs = ["labs_test.cpp"], - libc_function_deps = ["//libc:labs"], -) - -libc_test( - name = "llabs_test", - srcs = ["llabs_test.cpp"], - libc_function_deps = ["//libc:llabs"], -) - -libc_support_library( - name = "div_test_helper", - hdrs = ["DivTest.h"], - deps = ["//libc/test/UnitTest:LibcUnitTest"], -) - -libc_test( - name = "div_test", - srcs = ["div_test.cpp"], - libc_function_deps = ["//libc:div"], - deps = [":div_test_helper"], -) - -libc_test( - name = "ldiv_test", - srcs = ["ldiv_test.cpp"], - libc_function_deps = ["//libc:ldiv"], - deps = [":div_test_helper"], -) - -libc_test( - name = "lldiv_test", - srcs = ["lldiv_test.cpp"], - libc_function_deps = ["//libc:lldiv"], - deps = [":div_test_helper"], -) - -libc_support_library( - name = "atoi_test_helper", - hdrs = ["AtoiTest.h"], - deps = [ - "//libc:__support_cpp_limits", - "//libc:__support_cpp_type_traits", - "//libc/test/UnitTest:LibcUnitTest", - ], -) - -libc_test( - name = "atoi_test", - srcs = ["atoi_test.cpp"], - libc_function_deps = ["//libc:atoi"], - deps = [":atoi_test_helper"], -) - -libc_test( - name = "atol_test", - srcs = ["atol_test.cpp"], - libc_function_deps = ["//libc:atol"], - deps = [":atoi_test_helper"], -) - -libc_test( - name = "atoll_test", - srcs = ["atoll_test.cpp"], - libc_function_deps = ["//libc:atoll"], - deps = [":atoi_test_helper"], -) - -libc_test( - name = "atof_test", - srcs = ["atof_test.cpp"], - libc_function_deps = ["//libc:atof"], - deps = ["//libc:__support_fputil_fp_bits"], -) - -libc_test( - name = "bsearch_test", - srcs = ["bsearch_test.cpp"], - libc_function_deps = ["//libc:bsearch"], -) - -libc_test( - name = "qsort_test", - srcs = ["qsort_test.cpp"], - libc_function_deps = ["//libc:qsort"], -) - -libc_test( - name = "qsort_r_test", - srcs = ["qsort_r_test.cpp"], - libc_function_deps = ["//libc:qsort_r"], -) - -libc_support_library( - name = "strtol_test_helper", - hdrs = ["StrtolTest.h"], - deps = [ - "//libc:__support_cpp_limits", - "//libc:__support_cpp_type_traits", - "//libc:__support_macros_properties_architectures", - "//libc:errno.__internal__", - "//libc/test/UnitTest:LibcUnitTest", - ], -) - -libc_test( - name = "strtol_test", - srcs = ["strtol_test.cpp"], - libc_function_deps = ["//libc:strtol"], - deps = [":strtol_test_helper"], -) - -libc_test( - name = "strtoll_test", - srcs = ["strtoll_test.cpp"], - libc_function_deps = ["//libc:strtoll"], - deps = [":strtol_test_helper"], -) - -libc_test( - name = "strtoul_test", - srcs = ["strtoul_test.cpp"], - libc_function_deps = ["//libc:strtoul"], - deps = [":strtol_test_helper"], -) - -libc_test( - name = "strtoull_test", - srcs = ["strtoull_test.cpp"], - libc_function_deps = ["//libc:strtoull"], - deps = [":strtol_test_helper"], -) - -libc_test( - name = "strtof_test", - srcs = ["strtof_test.cpp"], - libc_function_deps = ["//libc:strtof"], - deps = [ - "//libc:__support_fputil_fp_bits", - "//libc/test/UnitTest:fp_test_helpers", - ], -) - -libc_test( - name = "strtod_test", - srcs = ["strtod_test.cpp"], - libc_function_deps = ["//libc:strtod"], - deps = [ - "//libc:__support_fputil_fp_bits", - "//libc/test/UnitTest:fp_test_helpers", - ], -) - -libc_test( - name = "strtold_test", - srcs = ["strtold_test.cpp"], - libc_function_deps = ["//libc:strtold"], - deps = [ - "//libc:__support_fputil_fp_bits", - "//libc:__support_uint128", - ], -) diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/string/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/string/BUILD.bazel deleted file mode 100644 index d96f390c0c3804..00000000000000 --- a/utils/bazel/llvm-project-overlay/libc/test/src/string/BUILD.bazel +++ /dev/null @@ -1,213 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# Tests for LLVM libc string.h functions. - -load("//libc:libc_build_rules.bzl", "libc_support_library") -load("//libc/test:libc_test_rules.bzl", "libc_test") - -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) - -libc_test( - name = "strlen_test", - srcs = ["strlen_test.cpp"], - libc_function_deps = [ - "//libc:strlen", - ], -) - -libc_test( - name = "strcpy_test", - srcs = ["strcpy_test.cpp"], - libc_function_deps = [ - "//libc:strcpy_sanitized", - ], -) - -libc_test( - name = "strcmp_test", - srcs = ["strcmp_test.cpp"], - libc_function_deps = [ - "//libc:strcmp", - ], -) - -libc_test( - name = "memchr_test", - srcs = ["memchr_test.cpp"], - libc_function_deps = [ - "//libc:memchr", - ], -) - -libc_support_library( - name = "strchr_test_helper", - hdrs = ["StrchrTest.h"], - deps = ["//libc/test/UnitTest:LibcUnitTest"], -) - -libc_test( - name = "strchr_test", - srcs = ["strchr_test.cpp"], - libc_function_deps = [ - "//libc:strchr", - ], - deps = [":strchr_test_helper"], -) - -libc_test( - name = "strstr_test", - srcs = ["strstr_test.cpp"], - libc_function_deps = [ - "//libc:strstr", - ], -) - -libc_test( - name = "strnlen_test", - srcs = ["strnlen_test.cpp"], - libc_function_deps = [ - "//libc:strnlen", - ], -) - -libc_test( - name = "memrchr_test", - srcs = ["memrchr_test.cpp"], - libc_function_deps = [ - "//libc:memrchr", - ], -) - -libc_test( - name = "strrchr_test", - srcs = ["strrchr_test.cpp"], - libc_function_deps = [ - "//libc:strrchr", - ], - deps = [":strchr_test_helper"], -) - -libc_test( - name = "strcspn_test", - srcs = ["strcspn_test.cpp"], - libc_function_deps = [ - "//libc:strcspn", - ], -) - -libc_test( - name = "strspn_test", - srcs = ["strspn_test.cpp"], - libc_function_deps = [ - "//libc:strspn", - ], -) - -libc_test( - name = "strtok_test", - srcs = ["strtok_test.cpp"], - libc_function_deps = [ - "//libc:strtok", - ], -) - -libc_support_library( - name = "memory_check_utils", - hdrs = ["memory_utils/memory_check_utils.h"], - deps = [ - "//libc:__support_cpp_span", - "//libc:__support_libc_assert", - "//libc:__support_macros_sanitizer", - "//libc:string_memory_utils", - ], -) - -libc_test( - name = "memcpy_test", - srcs = ["memcpy_test.cpp"], - libc_function_deps = [ - "//libc:memcpy", - ], - deps = [":memory_check_utils"], -) - -libc_test( - name = "mempcpy_test", - srcs = ["mempcpy_test.cpp"], - libc_function_deps = [ - "//libc:mempcpy", - ], -) - -libc_test( - name = "memset_test", - srcs = ["memset_test.cpp"], - libc_function_deps = [ - "//libc:memset", - ], - deps = [":memory_check_utils"], -) - -libc_test( - name = "memmove_test", - srcs = ["memmove_test.cpp"], - libc_function_deps = [ - "//libc:memcmp", - "//libc:memmove", - ], - deps = [ - ":memory_check_utils", - "//libc:__support_cpp_span", - "//libc/test/UnitTest:memory_matcher", - ], -) - -libc_test( - name = "bcopy_test", - srcs = ["bcopy_test.cpp"], - libc_function_deps = [ - "//libc:bcopy", - ], - deps = [ - ":memory_check_utils", - "//libc:__support_cpp_span", - "//libc/test/UnitTest:memory_matcher", - ], -) - -libc_test( - name = "memcmp_test", - srcs = ["memcmp_test.cpp"], - libc_function_deps = [ - "//libc:memcmp", - ], - deps = [ - ":memory_check_utils", - "//libc/test/UnitTest:test_logger", - ], -) - -libc_test( - name = "bcmp_test", - srcs = ["bcmp_test.cpp"], - libc_function_deps = [ - "//libc:bcmp", - ], - deps = [ - ":memory_check_utils", - "//libc/test/UnitTest:test_logger", - ], -) - -libc_test( - name = "bzero_test", - srcs = ["bzero_test.cpp"], - libc_function_deps = [ - "//libc:bzero", - ], - deps = [":memory_check_utils"], -) diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/sys/epoll/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/sys/epoll/BUILD.bazel deleted file mode 100644 index e6b63235757e51..00000000000000 --- a/utils/bazel/llvm-project-overlay/libc/test/src/sys/epoll/BUILD.bazel +++ /dev/null @@ -1,37 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# Tests for LLVM libc string.h functions. - -load("//libc/test:libc_test_rules.bzl", "libc_test") - -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) - -libc_test( - name = "epoll_wait_test", - srcs = ["linux/epoll_wait_test.cpp"], - libc_function_deps = [ - "//libc:epoll_wait", - ], -) - -libc_test( - name = "epoll_pwait_test", - srcs = ["linux/epoll_pwait_test.cpp"], - libc_function_deps = [ - "//libc:epoll_pwait", - ], -) - -#TODO: Enable once epoll_pwait2 availablilty can be checked first. -# https://github.com/llvm/llvm-project/issues/80060 -# libc_test( -# name = "epoll_pwait2_test", -# srcs = ["linux/epoll_pwait2_test.cpp"], -# libc_function_deps = [ -# "//libc:epoll_pwait2", -# ], -# ) diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/unistd/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/unistd/BUILD.bazel deleted file mode 100644 index 4549fa2a193fc0..00000000000000 --- a/utils/bazel/llvm-project-overlay/libc/test/src/unistd/BUILD.bazel +++ /dev/null @@ -1,340 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# Tests for LLVM libc unistd.h functions. - -load("//libc/test:libc_test_rules.bzl", "libc_test") - -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) - -libc_test( - name = "access_test", - srcs = ["access_test.cpp"], - libc_function_deps = [ - "//libc:open", - "//libc:access", - "//libc:close", - "//libc:unlink", - ], -) - -# libc_test( -# name = "chdir_test", -# srcs = ["chdir_test.cpp"], -# libc_function_deps = [ -# "//libc:open", -# "//libc:chdir", -# "//libc:close", -# ], -# ) - -libc_test( - name = "dup_test", - srcs = ["dup_test.cpp"], - libc_function_deps = [ - "//libc:open", - "//libc:close", - "//libc:dup", - "//libc:read", - "//libc:unlink", - "//libc:write", - ], -) - -libc_test( - name = "dup2_test", - srcs = ["dup2_test.cpp"], - libc_function_deps = [ - "//libc:open", - "//libc:close", - "//libc:dup2", - "//libc:read", - "//libc:unlink", - "//libc:write", - ], -) - -libc_test( - name = "dup3_test", - srcs = ["dup3_test.cpp"], - libc_function_deps = [ - "//libc:open", - "//libc:close", - "//libc:dup3", - "//libc:read", - "//libc:unlink", - "//libc:write", - ], -) - -# libc_test( -# name = "fchdir_test", -# srcs = ["fchdir_test.cpp"], -# libc_function_deps = [ -# "//libc:open", -# "//libc:fchdir", -# "//libc:close", -# ], -# ) - -libc_test( - name = "ftruncate_test", - srcs = ["ftruncate_test.cpp"], - libc_function_deps = [ - "//libc:open", - "//libc:close", - "//libc:read", - "//libc:ftruncate", - "//libc:unlink", - "//libc:write", - ], - deps = [ - "//libc:__support_cpp_string_view", - ], -) - -libc_test( - name = "pread_pwrite_test", - srcs = ["pread_pwrite_test.cpp"], - libc_function_deps = [ - "//libc:open", - "//libc:close", - "//libc:fsync", - "//libc:pread", - "//libc:pwrite", - "//libc:unlink", - "//libc:write", - ], -) - -libc_test( - name = "read_write_test", - srcs = ["read_write_test.cpp"], - libc_function_deps = [ - "//libc:open", - "//libc:close", - "//libc:fsync", - "//libc:read", - "//libc:write", - "//libc:remove", - ], -) - -libc_test( - name = "link_test", - srcs = ["link_test.cpp"], - libc_function_deps = [ - "//libc:open", - "//libc:close", - "//libc:link", - "//libc:unlink", - ], -) - -# libc_test( -# name = "linkat_test", -# srcs = ["linkat_test.cpp"], -# libc_function_deps = [ -# "//libc:open", -# "//libc:close", -# "//libc:linkat", -# "//libc:unlink", -# ], -# ) - -# libc_test( -# name = "lseek_test", -# srcs = ["lseek_test.cpp"], -# libc_function_deps = [ -# "//libc:open", -# "//libc:close", -# "//libc:lseek", -# "//libc:read", -# ], -# ) - -# libc_test( -# name = "rmdir_test", -# srcs = ["rmdir_test.cpp"], -# libc_function_deps = [ -# "//libc:mkdir", -# "//libc:rmdir", -# ], -# ) - -libc_test( - name = "swab_test", - srcs = ["swab_test.cpp"], - libc_function_deps = [ - "//libc:swab", - ], - deps = [ - "//libc:string_utils", - ], -) - -# libc_test( -# name = "readlink_test", -# srcs = ["readlink_test.cpp"], -# libc_function_deps = [ -# "//libc:readlink", -# "//libc:symlink", -# "//libc:unlink", -# ], -# deps = [ -# "//libc:__support_cpp_string_view", -# ], -# ) - -# libc_test( -# name = "readlinkat_test", -# srcs = ["readlinkat_test.cpp"], -# libc_function_deps = [ -# "//libc:readlinkat", -# "//libc:symlink", -# "//libc:unlink", -# ], -# deps = [ -# "//libc:__support_cpp_string_view", -# ], -# ) - -libc_test( - name = "symlink_test", - srcs = ["symlink_test.cpp"], - libc_function_deps = [ - "//libc:open", - "//libc:close", - "//libc:symlink", - "//libc:unlink", - ], -) - -# libc_test( -# name = "symlinkat_test", -# srcs = ["symlinkat_test.cpp"], -# libc_function_deps = [ -# "//libc:open", -# "//libc:close", -# "//libc:symlinkat", -# "//libc:unlink", -# ], -# ) - -libc_test( - name = "truncate_test", - srcs = ["truncate_test.cpp"], - libc_function_deps = [ - "//libc:open", - "//libc:close", - "//libc:read", - "//libc:truncate", - "//libc:unlink", - "//libc:write", - ], - deps = [ - "//libc:__support_cpp_string_view", - ], -) - -libc_test( - name = "unlink_test", - srcs = ["unlink_test.cpp"], - libc_function_deps = [ - "//libc:open", - "//libc:close", - "//libc:unlink", - ], -) - -# libc_test( -# name = "unlinkat_test", -# srcs = ["unlinkat_test.cpp"], -# libc_function_deps = [ -# "//libc:open", -# "//libc:openat", -# "//libc:close", -# "//libc:unlinkat", -# ], -# ) - -libc_test( - name = "getpid_test", - srcs = ["getpid_test.cpp"], - libc_function_deps = [ - "//libc:getpid", - ], -) - -libc_test( - name = "getppid_test", - srcs = ["getppid_test.cpp"], - libc_function_deps = [ - "//libc:getppid", - ], -) - -libc_test( - name = "getuid_test", - srcs = ["getuid_test.cpp"], - libc_function_deps = [ - "//libc:getuid", - ], -) - -libc_test( - name = "isatty_test", - srcs = ["isatty_test.cpp"], - libc_function_deps = [ - "//libc:isatty", - "//libc:open", - "//libc:close", - ], -) - -libc_test( - name = "geteuid_test", - srcs = ["geteuid_test.cpp"], - libc_function_deps = [ - "//libc:geteuid", - ], -) - -#TODO: Enable once fullbuild is added to bazel, since this depends on a macro -# definition in the public header - -# libc_test( -# name = "syscall_test", -# srcs = ["syscall_test.cpp"], -# libc_function_deps = [ -# "//libc:syscall", -# ], -# ) - -# TODO: add once sysconf is complete - -# libc_test( -# name = "sysconf_test", -# srcs = ["sysconf_test.cpp"], -# libc_function_deps = [ -# "//libc:sysconf", -# ], -# ) - -# TODO: add fopencookie and fflush - -# libc_test( -# name = "getopt_test", -# srcs = ["getopt_test.cpp"], -# libc_function_deps = [ -# "//libc:getopt", -# "//libc:fopencookie", -# "//libc:fflush", -# ], -# deps = [ -# "//libc:__support_cpp_array", -# ], -# ) diff --git a/utils/bazel/llvm-project-overlay/libc/utils/MPFRWrapper/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/utils/MPFRWrapper/BUILD.bazel deleted file mode 100644 index 803010e8b3add5..00000000000000 --- a/utils/bazel/llvm-project-overlay/libc/utils/MPFRWrapper/BUILD.bazel +++ /dev/null @@ -1,53 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# A wrapper library over MPFR for use with LLVM libc math unittests. - -load("//libc:libc_build_rules.bzl", "libc_support_library") - -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) - -cc_library( - name = "mpfr_impl", - hdrs = ["mpfr_inc.h"], - target_compatible_with = select({ - "//conditions:default": [], - "//libc:mpfr_disable": ["@platforms//:incompatible"], - }), - deps = select( - { - "//conditions:default": [], - "//libc:mpfr_external": ["@mpfr//:mpfr_external"], - "//libc:mpfr_system": ["@mpfr//:mpfr_system"], - }, - ), -) - -libc_support_library( - name = "mpfr_wrapper", - srcs = ["MPFRUtils.cpp"], - hdrs = ["MPFRUtils.h"], - # Disable layering check when using mpfr_system. - features = select( - { - "//conditions:default": [], - "//libc:mpfr_system": ["-layering_check"], - }, - ), - deps = [ - "//libc:__support_common", - "//libc:__support_cpp_bit", - "//libc:__support_cpp_bitset", - "//libc:__support_cpp_string", - "//libc:__support_cpp_string_view", - "//libc:__support_cpp_type_traits", - "//libc:__support_fputil_fp_bits", - "//libc:__support_fputil_fpbits_str", - "//libc/test/UnitTest:LibcUnitTest", - "//libc/test/UnitTest:fp_test_helpers", - "//libc/utils/MPFRWrapper:mpfr_impl", - ], -) diff --git a/utils/bazel/llvm-project-overlay/libunwind/BUILD.bazel b/utils/bazel/llvm-project-overlay/libunwind/BUILD.bazel deleted file mode 100644 index f8448fb0e7268e..00000000000000 --- a/utils/bazel/llvm-project-overlay/libunwind/BUILD.bazel +++ /dev/null @@ -1,21 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -package( - default_visibility = ["//visibility:public"], -) - -licenses(["notice"]) - -# The ld64 linker and lld-macho use the libunwind headers only for the constant -# definitions, in order to parse and convert DWARF to the compact encoding. -cc_library( - name = "unwind_headers_only", - hdrs = [ - "include/__libunwind_config.h", - "include/libunwind.h", - "include/mach-o/compact_unwind_encoding.h", - ], - strip_include_prefix = "include", -) diff --git a/utils/bazel/llvm-project-overlay/lld/BUILD.bazel b/utils/bazel/llvm-project-overlay/lld/BUILD.bazel deleted file mode 100644 index 8fb71fc1f971e5..00000000000000 --- a/utils/bazel/llvm-project-overlay/lld/BUILD.bazel +++ /dev/null @@ -1,330 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -load("@bazel_skylib//rules:expand_template.bzl", "expand_template") -load( - "//:vars.bzl", - "LLVM_VERSION", -) -load("//llvm:binary_alias.bzl", "binary_alias") -load("//llvm:tblgen.bzl", "gentbl") - -package( - default_visibility = ["//visibility:public"], - features = ["layering_check"], -) - -licenses(["notice"]) - -# TODO: Actually compute version info -genrule( - name = "config_version_gen", - outs = ["include/lld/Common/Version.inc"], - cmd = "echo '#define LLD_VERSION_STRING \"{}\"' > $@".format(LLVM_VERSION), -) - -genrule( - name = "vcs_version_gen", - outs = ["Common/VCSVersion.inc"], - cmd = "echo '#undef LLD_REVISION' >> $@\n" + - "echo '#undef LLD_REPOSITORY' >> $@\n", -) - -# See https://github.com/bazelbuild/bazel/issues/13803 -cc_library( - name = "vcs_version", - hdrs = ["Common/VCSVersion.inc"], - strip_include_prefix = "Common", -) - -cc_library( - name = "Common", - srcs = [":config_version_gen"] + glob(["Common/*.cpp"]), - hdrs = glob(["include/lld/Common/*.h"]), - includes = ["include"], - deps = [ - ":vcs_version", - "//llvm:CodeGen", - "//llvm:Core", - "//llvm:DebugInfoDWARF", - "//llvm:IRPrinter", - "//llvm:Option", - "//llvm:Support", - "//llvm:Target", - "//llvm:TargetParser", - "//llvm:config", - ], -) - -gentbl( - name = "elf_options_inc_gen", - # See https://github.com/bazelbuild/bazel/issues/13803 - strip_include_prefix = "ELF", - tbl_outs = [( - "-gen-opt-parser-defs", - "ELF/Options.inc", - )], - tblgen = "//llvm:llvm-tblgen", - td_file = "ELF/Options.td", - td_srcs = [ - "//llvm:include/llvm/Option/OptParser.td", - ], -) - -cc_library( - name = "ELF", - srcs = glob([ - "ELF/*.cpp", - "ELF/*.h", - "ELF/Arch/*.cpp", - ]), - includes = ["ELF"], - textual_hdrs = [ - "ELF/Arch/PPCInsns.def", - ], - deps = [ - ":Common", - ":elf_options_inc_gen", - "//llvm:AllTargetsAsmParsers", - "//llvm:AllTargetsCodeGens", - "//llvm:AllTargetsDisassemblers", - "//llvm:Analysis", - "//llvm:BinaryFormat", - "//llvm:BitReader", - "//llvm:BitWriter", - "//llvm:CodeGen", - "//llvm:Core", - "//llvm:DebugInfoDWARF", - "//llvm:Demangle", - "//llvm:IPO", - "//llvm:LTO", - "//llvm:Linker", - "//llvm:MC", - "//llvm:Object", - "//llvm:Option", - "//llvm:Passes", - "//llvm:Remarks", - "//llvm:Support", - "//llvm:TargetParser", - "//llvm:TransformUtils", - "//llvm:config", - "@llvm_zlib//:zlib", - "@llvm_zstd//:zstd", - ], -) - -gentbl( - name = "coff_options_inc_gen", - # See https://github.com/bazelbuild/bazel/issues/13803 - strip_include_prefix = "COFF", - tbl_outs = [( - "-gen-opt-parser-defs", - "COFF/Options.inc", - )], - tblgen = "//llvm:llvm-tblgen", - td_file = "COFF/Options.td", - td_srcs = [ - "//llvm:include/llvm/Option/OptParser.td", - ], -) - -cc_library( - name = "COFF", - srcs = glob([ - "COFF/*.cpp", - "COFF/*.h", - ]), - includes = ["COFF"], - deps = [ - ":Common", - ":coff_options_inc_gen", - "//llvm:AllTargetsAsmParsers", - "//llvm:AllTargetsCodeGens", - "//llvm:AllTargetsDisassemblers", - "//llvm:Analysis", - "//llvm:BinaryFormat", - "//llvm:BitReader", - "//llvm:BitWriter", - "//llvm:Core", - "//llvm:DebugInfo", - "//llvm:DebugInfoCodeView", - "//llvm:DebugInfoMSF", - "//llvm:DebugInfoPDB", - "//llvm:Demangle", - "//llvm:IPO", - "//llvm:LTO", - "//llvm:LibDriver", - "//llvm:Linker", - "//llvm:MC", - "//llvm:Object", - "//llvm:Option", - "//llvm:Support", - "//llvm:Symbolize", - "//llvm:Target", - "//llvm:TargetParser", - "//llvm:TransformUtils", - "//llvm:WindowsDriver", - "//llvm:WindowsManifest", - "//llvm:config", - ], -) - -gentbl( - name = "mingw_options_inc_gen", - tbl_outs = [( - "-gen-opt-parser-defs", - "MinGW/Options.inc", - )], - tblgen = "//llvm:llvm-tblgen", - td_file = "MinGW/Options.td", - td_srcs = [ - "//llvm:include/llvm/Option/OptParser.td", - ], -) - -cc_library( - name = "MinGW", - srcs = glob([ - "MinGW/*.cpp", - "MinGW/*.h", - ]), - includes = ["MinGW"], - deps = [ - ":Common", - ":mingw_options_inc_gen", - "//llvm:Option", - "//llvm:Support", - "//llvm:TargetParser", - ], -) - -gentbl( - name = "macho_options_inc_gen", - # See https://github.com/bazelbuild/bazel/issues/13803 - strip_include_prefix = "MachO", - tbl_outs = [( - "-gen-opt-parser-defs", - "MachO/Options.inc", - )], - tblgen = "//llvm:llvm-tblgen", - td_file = "MachO/Options.td", - td_srcs = [ - "//llvm:include/llvm/Option/OptParser.td", - ], -) - -cc_library( - name = "MachO", - srcs = glob([ - "MachO/**/*.cpp", - "MachO/**/*.h", - ]), - includes = ["MachO"], - deps = [ - ":Common", - ":macho_options_inc_gen", - "//libunwind:unwind_headers_only", - "//llvm:BinaryFormat", - "//llvm:BitReader", - "//llvm:BitWriter", - "//llvm:Core", - "//llvm:DebugInfoDWARF", - "//llvm:Demangle", - "//llvm:LTO", - "//llvm:MC", - "//llvm:ObjCARC", - "//llvm:Object", - "//llvm:Option", - "//llvm:Support", - "//llvm:TargetParser", - "//llvm:TextAPI", - "//llvm:config", - ], -) - -gentbl( - name = "wasm_options_inc_gen", - # See https://github.com/bazelbuild/bazel/issues/13803 - strip_include_prefix = "wasm", - tbl_outs = [( - "-gen-opt-parser-defs", - "wasm/Options.inc", - )], - tblgen = "//llvm:llvm-tblgen", - td_file = "wasm/Options.td", - td_srcs = [ - "//llvm:include/llvm/Option/OptParser.td", - ], -) - -cc_library( - name = "Wasm", - srcs = glob([ - "wasm/*.cpp", - "wasm/*.h", - ]), - includes = ["wasm"], - deps = [ - ":Common", - ":wasm_options_inc_gen", - "//llvm:AllTargetsAsmParsers", - "//llvm:AllTargetsCodeGens", - "//llvm:BinaryFormat", - "//llvm:Core", - "//llvm:Demangle", - "//llvm:LTO", - "//llvm:MC", - "//llvm:Object", - "//llvm:Option", - "//llvm:Support", - "//llvm:TargetParser", - "//llvm:config", - ], -) - -expand_template( - name = "lld_main", - out = "lld-driver.cpp", - substitutions = { - "@TOOL_NAME@": "lld", - }, - template = "//llvm:cmake/modules/llvm-driver-template.cpp.in", -) - -cc_binary( - name = "lld", - srcs = glob([ - "tools/lld/*.cpp", - "tools/lld/*.h", - ]) + ["lld-driver.cpp"], - deps = [ - ":COFF", - ":Common", - ":ELF", - ":MachO", - ":MinGW", - ":Wasm", - "//llvm:Support", - "//llvm:TargetParser", - ], -) - -# These are the required names for lld running under different environs. -# -# Unix/Linux require that the binary be named "ld.lld". -# macOS require that the binary be named "ld64.lld". -# Windows require that the binary be named "lld-link". -# WebAssembly builds require that the binary be named "wasm-ld". -[ - binary_alias( - name = name, - binary = ":lld", - ) - for name in [ - "ld.lld", - "ld64.lld", - "lld-link", - "wasm-ld", - ] -] diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel deleted file mode 100644 index 4802daa66286ef..00000000000000 --- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel +++ /dev/null @@ -1,5414 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -load("@bazel_skylib//rules:common_settings.bzl", "string_flag") -load("@bazel_skylib//rules:expand_template.bzl", "expand_template") -load(":binary_alias.bzl", "binary_alias") -load(":config.bzl", "llvm_config_defines") -load(":enum_targets_gen.bzl", "enum_targets_gen") -load(":targets.bzl", "llvm_targets") -load(":tblgen.bzl", "gentbl") - -package( - default_visibility = ["//visibility:public"], - features = ["layering_check"], -) - -licenses(["notice"]) - -exports_files([ - "LICENSE.TXT", - "cmake/modules/llvm-driver-template.cpp.in", - "include/llvm/CodeGen/SDNodeProperties.td", - "include/llvm/CodeGen/ValueTypes.td", - "include/llvm/Frontend/Directive/DirectiveBase.td", - "include/llvm/Frontend/OpenACC/ACC.td", - "include/llvm/Frontend/OpenMP/OMP.td", - "include/llvm/IR/Intrinsics.td", - "include/llvm/Option/OptParser.td", - "utils/lit/lit.py", -]) - -# It may be tempting to add compiler flags here, but that should be avoided. -# The necessary warnings and other compile flags should be provided by the -# toolchain or the `.bazelrc` file. This is just a workaround until we have a -# widely available feature to enable unlimited stack frame instead of using -# this `Make` variable. -llvm_copts = [ - "$(STACK_FRAME_UNLIMITED)", -] - -enum_targets_gen( - name = "targets_def_gen", - src = "include/llvm/Config/Targets.def.in", - out = "include/llvm/Config/Targets.def", - macro_name = "TARGET", - targets = llvm_targets, -) - -# Enabled targets with ASM printers. -llvm_target_asm_printers = [ - t - for t in llvm_targets - if glob(["lib/Target/{}/*AsmPrinter.cpp".format(t)]) -] - -enum_targets_gen( - name = "asm_printers_def_gen", - src = "include/llvm/Config/AsmPrinters.def.in", - out = "include/llvm/Config/AsmPrinters.def", - macro_name = "ASM_PRINTER", - targets = llvm_target_asm_printers, -) - -# Enabled targets with ASM parsers. -llvm_target_asm_parsers = [ - t - for t in llvm_targets - if glob(["lib/Target/{}/AsmParser/CMakeLists.txt".format(t)]) -] - -enum_targets_gen( - name = "asm_parsers_def_gen", - src = "include/llvm/Config/AsmParsers.def.in", - out = "include/llvm/Config/AsmParsers.def", - macro_name = "ASM_PARSER", - targets = llvm_target_asm_parsers, -) - -# Enabled targets with disassemblers. -llvm_target_disassemblers = [ - t - for t in llvm_targets - if glob(["lib/Target/{}/Disassembler/CMakeLists.txt".format(t)]) -] - -enum_targets_gen( - name = "disassemblers_def_gen", - src = "include/llvm/Config/Disassemblers.def.in", - out = "include/llvm/Config/Disassemblers.def", - macro_name = "DISASSEMBLER", - targets = llvm_target_disassemblers, -) - -# Enabled targets with MCA. -llvm_target_mcas = [ - t - for t in llvm_targets - if glob(["lib/Target/{}/MCA/CMakeLists.txt".format(t)]) -] - -enum_targets_gen( - name = "target_mca_def_gen", - src = "include/llvm/Config/TargetMCAs.def.in", - out = "include/llvm/Config/TargetMCAs.def", - macro_name = "TARGETMCA", - targets = llvm_target_mcas, -) - -# Enabled targets with exegesis. -llvm_target_exegesis = [ - t - for t in llvm_targets - if glob(["tools/llvm-exegesis/lib/{}/CMakeLists.txt".format(t)]) -] - -enum_targets_gen( - name = "target_exegesis_def_gen", - src = "include/llvm/Config/TargetExegesis.def.in", - out = "include/llvm/Config/TargetExegesis.def", - macro_name = "EXEGESIS", - placeholder_name = "@LLVM_ENUM_EXEGESIS@", - targets = llvm_target_exegesis, -) - -expand_template( - name = "abi_breaking_h_gen", - out = "include/llvm/Config/abi-breaking.h", - substitutions = { - # Define to enable checks that alter the LLVM C++ ABI - "#cmakedefine01 LLVM_ENABLE_ABI_BREAKING_CHECKS": "#define LLVM_ENABLE_ABI_BREAKING_CHECKS 0", - - # Define to enable reverse iteration of unordered llvm containers - "#cmakedefine01 LLVM_ENABLE_REVERSE_ITERATION": "#define LLVM_ENABLE_REVERSE_ITERATION 0", - }, - template = "include/llvm/Config/abi-breaking.h.cmake", -) - -# To enable diff testing out of tree -exports_files([ - "include/llvm/Config/config.h.cmake", - "include/llvm/Config/llvm-config.h.cmake", - "include/llvm/Config/abi-breaking.h.cmake", -]) - -cc_library( - name = "config", - hdrs = [ - "include/llvm/Config/abi-breaking.h", - "include/llvm/Config/llvm-config.h", - ], - copts = llvm_copts, - defines = llvm_config_defines, - includes = ["include"], - textual_hdrs = [ - "include/llvm/Config/AsmParsers.def", - "include/llvm/Config/AsmPrinters.def", - "include/llvm/Config/Disassemblers.def", - "include/llvm/Config/Targets.def", - "include/llvm/Config/TargetExegesis.def", - "include/llvm/Config/TargetMCAs.def", - # Needed for include scanner to find execinfo.h - "include/llvm/Config/config.h", - ], -) - -cc_library( - name = "Demangle", - srcs = glob([ - "lib/Demangle/*.cpp", - "lib/Demangle/*.h", - ]), - hdrs = glob([ - "include/llvm/Demangle/*.h", - "include/llvm/Demangle/*.def", - ]), - copts = llvm_copts, - deps = [":config"], -) - -genrule( - name = "generate_vcs_revision", - outs = ["include/llvm/Support/VCSRevision.h"], - cmd = "echo '#undef LLVM_REVISION' >> $@\n" + - "echo '#undef LLVM_REPOSITORY' >> $@\n", -) - -genrule( - name = "generate_static_extension_registry", - outs = ["include/llvm/Support/Extension.def"], - cmd = "echo -e '// extension handlers' >> $@\n" + - "echo -e '#undef HANDLE_EXTENSION' >> $@\n", -) - -cc_library( - name = "Support", - srcs = glob([ - "lib/Support/*.c", - "lib/Support/*.cpp", - "lib/Support/*.h", - "lib/Support/*.inc", - # To avoid a dependency cycle. - "include/llvm/Option/*.h", - ]) + select({ - "@platforms//os:windows": glob([ - "lib/Support/Windows/*.h", - "lib/Support/Windows/*.inc", - ]), - "//conditions:default": glob([ - "lib/Support/Unix/*.h", - "lib/Support/Unix/*.inc", - ]), - }) + [ - "lib/Support/BLAKE3/blake3.c", - "lib/Support/BLAKE3/blake3_dispatch.c", - "lib/Support/BLAKE3/blake3_impl.h", - "lib/Support/BLAKE3/blake3_portable.c", - "lib/Support/BLAKE3/llvm_blake3_prefix.h", - ] + select({ - "@platforms//cpu:aarch64": [ - "lib/Support/BLAKE3/blake3_neon.c", - ], - "@platforms//cpu:x86_64": [ - "lib/Support/BLAKE3/blake3_avx2_x86-64_unix.S", - "lib/Support/BLAKE3/blake3_avx512_x86-64_unix.S", - "lib/Support/BLAKE3/blake3_sse2_x86-64_unix.S", - "lib/Support/BLAKE3/blake3_sse41_x86-64_unix.S", - ], - "//conditions:default": [ - ], - }), - hdrs = glob([ - "include/llvm/Support/**/*.h", - "include/llvm/ADT/*.h", - ]) + [ - "include/llvm-c/Core.h", - "include/llvm-c/DataTypes.h", - "include/llvm-c/Deprecated.h", - "include/llvm-c/DisassemblerTypes.h", - "include/llvm-c/Error.h", - "include/llvm-c/ErrorHandling.h", - "include/llvm-c/ExternC.h", - "include/llvm-c/Support.h", - "include/llvm-c/Types.h", - "include/llvm-c/blake3.h", - "include/llvm/ExecutionEngine/JITSymbol.h", - "include/llvm/Support/Extension.def", - "include/llvm/Support/VCSRevision.h", - ], - copts = llvm_copts, - defines = select({ - "@platforms//cpu:aarch64": [ - ], - "//conditions:default": [ - "BLAKE3_USE_NEON=0", - ], - }) + select({ - "@platforms//cpu:x86_64": [ - ], - "//conditions:default": [ - "BLAKE3_NO_AVX2", - "BLAKE3_NO_AVX512", - "BLAKE3_NO_SSE2", - "BLAKE3_NO_SSE41", - ], - }), - includes = ["include"], - linkopts = select({ - "@platforms//os:windows": [ - "ws2_32.lib", - ], - "@platforms//os:freebsd": [ - "-pthread", - "-lexecinfo", - "-ldl", - "-lm", - ], - "//conditions:default": [ - "-pthread", - "-ldl", - "-lm", - ], - }), - textual_hdrs = glob([ - "include/llvm/Support/*.def", - ]), - deps = [ - ":config", - ":Demangle", - # We unconditionally depend on the custom LLVM zlib wrapper. This will - # be an empty library unless zlib is enabled, in which case it will - # both provide the necessary dependencies and configuration defines. - "@llvm_zlib//:zlib", - # We unconditionally depend on the custom LLVM zstd wrapper. This will - # be an empty library unless zstd is enabled, in which case it will - # both provide the necessary dependencies and configuration defines. - "@llvm_zstd//:zstd", - ], -) - -# Note: although FileCheck (the binary) is a test utility, some non-test -# targets depend on the FileCheck library target. -cc_library( - name = "FileCheckLib", - srcs = glob([ - "lib/FileCheck/*.cpp", - "lib/FileCheck/*.h", - ]), - hdrs = glob(["include/llvm/FileCheck/*.h"]), - copts = llvm_copts, - deps = [":Support"], -) - -cc_library( - name = "LineEditor", - srcs = glob([ - "lib/LineEditor/*.cpp", - "lib/LineEditor/*.h", - ]), - hdrs = glob(["include/llvm/LineEditor/*.h"]), - copts = llvm_copts, - deps = [ - ":Support", - ":config", - ], -) - -cc_library( - name = "Option", - srcs = glob([ - "lib/Option/*.cpp", - "lib/Option/*.h", - ]), - hdrs = glob(["include/llvm/Option/*.h"]), - copts = llvm_copts, - deps = [ - ":Support", - ":config", - ], -) - -cc_library( - name = "TableGen", - srcs = glob([ - "lib/TableGen/*.cpp", - "lib/TableGen/*.h", - ]), - hdrs = glob(["include/llvm/TableGen/*.h"]), - copts = llvm_copts, - deps = [ - ":Support", - ":config", - ], -) - -# This exists to avoid circular dependencies. -cc_library( - name = "ir_headers", - hdrs = glob( - [ - "include/llvm/*.h", - "include/llvm/IR/*.h", - ], - exclude = [ - "include/llvm/LinkAllPasses.h", - ], - ) + [ - "include/llvm-c/Comdat.h", - "include/llvm-c/DebugInfo.h", - "include/llvm/IR/Value.def", - ], - copts = llvm_copts, -) - -cc_library( - name = "BinaryFormat", - srcs = glob([ - "lib/BinaryFormat/*.cpp", - "lib/BinaryFormat/*.def", - "lib/BinaryFormat/*.h", - ]), - hdrs = glob([ - "include/llvm/BinaryFormat/*.h", - ]), - copts = llvm_copts, - includes = ["include"], - textual_hdrs = glob([ - "include/llvm/BinaryFormat/*.def", - "include/llvm/BinaryFormat/ELFRelocs/*.def", - ]), - deps = [ - ":Support", - ":TargetParser", - ], -) - -cc_library( - name = "DebugInfo", - hdrs = glob(["include/llvm/DebugInfo/**/*.h"]), - copts = llvm_copts, - textual_hdrs = glob(["include/llvm/DebugInfo/**/*.def"]), - deps = [ - ":Object", - ":Support", - ], -) - -cc_library( - name = "DebugInfoMSF", - srcs = glob([ - "lib/DebugInfo/MSF/*.cpp", - "lib/DebugInfo/MSF/*.h", - ]), - hdrs = glob(["include/llvm/DebugInfo/MSF/*.h"]), - copts = llvm_copts, - deps = [":Support"], -) - -cc_library( - name = "DebugInfoBTF", - srcs = glob([ - "lib/DebugInfo/BTF/*.cpp", - "lib/DebugInfo/BTF/*.h", - ]), - hdrs = glob(["include/llvm/DebugInfo/BTF/*.h"]) + [ - "include/llvm/DebugInfo/BTF/BTF.def", - ], - copts = llvm_copts, - deps = [ - ":DebugInfo", - ":Object", - ":Support", - ], -) - -cc_library( - name = "DebugInfoCodeView", - srcs = glob([ - "lib/DebugInfo/CodeView/*.cpp", - "lib/DebugInfo/CodeView/*.h", - ]), - hdrs = glob([ - "include/llvm/DebugInfo/CodeView/*.h", - ]), - copts = llvm_copts, - textual_hdrs = glob([ - "include/llvm/DebugInfo/CodeView/*.def", - ]), - deps = [ - ":BinaryFormat", - ":DebugInfoMSF", - ":Support", - ], -) - -cc_library( - name = "DebugInfoLogicalView", - srcs = glob([ - "lib/DebugInfo/LogicalView/**/*.cpp", - ]), - hdrs = glob([ - "include/llvm/DebugInfo/LogicalView/**/*.h", - ]), - copts = llvm_copts, - deps = [ - ":BinaryFormat", - ":DebugInfo", - ":DebugInfoCodeView", - ":DebugInfoDWARF", - ":DebugInfoPDB", - ":Demangle", - ":MC", - ":MCDisassembler", - ":Object", - ":Support", - ], -) - -cc_library( - name = "DebugInfoPDB", - srcs = glob([ - "lib/DebugInfo/PDB/*.cpp", - "lib/DebugInfo/PDB/*.h", - "lib/DebugInfo/PDB/Native/*.cpp", - "lib/DebugInfo/PDB/Native/*.h", - ]), - hdrs = glob([ - "include/llvm/DebugInfo/PDB/*.h", - "include/llvm/DebugInfo/PDB/Native/*.h", - ]), - copts = llvm_copts, - deps = [ - ":BinaryFormat", - ":DebugInfo", - ":DebugInfoBTF", - ":DebugInfoCodeView", - ":DebugInfoMSF", - ":Object", - ":Support", - ":config", - ], -) - -cc_library( - name = "Debuginfod", - srcs = glob([ - "lib/Debuginfod/*.cpp", - ]), - hdrs = glob([ - "include/llvm/Debuginfod/*.h", - ]), - copts = llvm_copts, - deps = [ - ":BinaryFormat", - ":DebugInfoDWARF", - ":Object", - ":Support", - ":Symbolize", - ], -) - -cc_library( - name = "MC", - srcs = glob([ - "lib/MC/*.cpp", - "lib/MC/*.h", - ]), - hdrs = glob([ - "include/llvm/MC/*.h", - "include/llvm/MC/*.def", - "include/llvm/MC/*.inc", - ]), - copts = llvm_copts, - deps = [ - ":BinaryFormat", - ":DebugInfoCodeView", - ":Support", - ":TargetParser", - ":config", - ":ir_headers", - ], -) - -cc_library( - name = "DebugInfoDWARF", - srcs = glob([ - "lib/DebugInfo/DWARF/*.cpp", - "lib/DebugInfo/DWARF/*.h", - ]), - hdrs = glob(["include/llvm/DebugInfo/DWARF/*.h"]), - copts = llvm_copts, - deps = [ - ":BinaryFormat", - ":DebugInfo", - ":MC", - ":Object", - ":Support", - ":TargetParser", - ], -) - -cc_library( - name = "DebugInfoGSYM", - srcs = glob([ - "lib/DebugInfo/GSYM/*.cpp", - "lib/DebugInfo/GSYM/*.h", - ]), - hdrs = glob(["include/llvm/DebugInfo/GSYM/*.h"]), - copts = llvm_copts, - deps = [ - ":DebugInfo", - ":DebugInfoDWARF", - ":MC", - ":Object", - ":Support", - ], -) - -cc_library( - name = "Symbolize", - srcs = glob([ - "lib/DebugInfo/Symbolize/*.cpp", - "lib/DebugInfo/Symbolize/*.h", - ]), - hdrs = glob([ - "include/llvm/DebugInfo/Symbolize/*.h", - "include/llvm/Debuginfod/*.h", - ]), - copts = llvm_copts, - deps = [ - ":BinaryFormat", - ":DebugInfo", - ":DebugInfoDWARF", - ":DebugInfoPDB", - ":Demangle", - ":Object", - ":Support", - ":TargetParser", - ], -) - -cc_binary( - name = "llvm-min-tblgen", - srcs = [ - "utils/TableGen/Attributes.cpp", - "utils/TableGen/CodeGenIntrinsics.cpp", - "utils/TableGen/CodeGenIntrinsics.h", - "utils/TableGen/DirectiveEmitter.cpp", - "utils/TableGen/IntrinsicEmitter.cpp", - "utils/TableGen/RISCVTargetDefEmitter.cpp", - "utils/TableGen/SDNodeProperties.cpp", - "utils/TableGen/SDNodeProperties.h", - "utils/TableGen/SequenceToOffsetTable.h", - "utils/TableGen/TableGen.cpp", - "utils/TableGen/VTEmitter.cpp", - ], - copts = llvm_copts, - stamp = 0, - deps = [ - ":Support", - ":TableGen", - ":config", - ], -) - -cc_library( - name = "TableGenGlobalISel", - srcs = [ - "utils/TableGen/GlobalISel/CodeExpander.cpp", - ], - hdrs = glob([ - # We have to include these headers here as well as in the `hdrs` below - # to allow the `.cpp` files to use file-relative-inclusion to find - # them, even though consumers of this library use inclusion relative to - # `utils/TableGen` with the `strip_includes_prefix` of this library. - # This mixture appears to be incompatible with header modules. - "utils/TableGen/GlobalISel/CodeExpander.h", - "utils/TableGen/GlobalISel/CodeExpansions.h", - ]), - copts = llvm_copts, - features = ["-header_modules"], - strip_include_prefix = "utils/TableGen", - deps = [ - ":CodeGenTypes", - ":Support", - ":TableGen", - ":config", - ], -) - -cc_library( - name = "llvm-tblgen-headers", - textual_hdrs = glob(["utils/TableGen/*.def"]), -) - -cc_binary( - name = "llvm-tblgen", - srcs = glob( - [ - "utils/TableGen/*.cpp", - "utils/TableGen/*.inc", - "utils/TableGen/*.h", - "utils/TableGen/GlobalISel/*.cpp", - "utils/TableGen/GlobalISel/*.h", - - # Some tablegen sources include headers from MC, so these have to be - # listed here. MC uses headers produced by tablegen, so it cannot be a - # regular dependency. - "include/llvm/MC/*.h", - "include/llvm/TargetParser/SubtargetFeature.h", - ], - exclude = ["utils/TableGen/GlobalISel/CodeExpander.cpp"], - ), - copts = llvm_copts, - stamp = 0, - deps = [ - ":CodeGenTypes", - ":Support", - ":TableGen", - ":TableGenGlobalISel", - ":TargetParser", - ":config", - ":llvm-tblgen-headers", - ], -) - -gentbl( - name = "intrinsic_enums_gen", - tbl_outs = [("-gen-intrinsic-enums", "include/llvm/IR/IntrinsicEnums.inc")], - tblgen = ":llvm-min-tblgen", - td_file = "include/llvm/IR/Intrinsics.td", - td_srcs = glob([ - "include/llvm/CodeGen/*.td", - "include/llvm/IR/Intrinsics*.td", - ]), -) - -gentbl( - name = "intrinsics_impl_gen", - tbl_outs = [("-gen-intrinsic-impl", "include/llvm/IR/IntrinsicImpl.inc")], - tblgen = ":llvm-min-tblgen", - td_file = "include/llvm/IR/Intrinsics.td", - td_srcs = glob([ - "include/llvm/CodeGen/*.td", - "include/llvm/IR/Intrinsics*.td", - ]), -) - -gentbl( - name = "vt_gen", - tbl_outs = [("-gen-vt", "include/llvm/CodeGen/GenVT.inc")], - tblgen = ":llvm-min-tblgen", - td_file = "include/llvm/CodeGen/ValueTypes.td", - td_srcs = [ - "include/llvm/CodeGen/ValueTypes.td", - ], -) - -# Note that the intrinsics are not currently set up so they can be pruned for -# disabled targets. -llvm_target_intrinsics_list = [ - { - "name": "AArch64", - "intrinsic_prefix": "aarch64", - }, - { - "name": "AMDGPU", - "intrinsic_prefix": "amdgcn", - }, - { - "name": "ARM", - "intrinsic_prefix": "arm", - }, - { - "name": "BPF", - "intrinsic_prefix": "bpf", - }, - { - "name": "DirectX", - "intrinsic_prefix": "dx", - }, - { - "name": "Hexagon", - "intrinsic_prefix": "hexagon", - }, - { - "name": "LoongArch", - "intrinsic_prefix": "loongarch", - }, - { - "name": "Mips", - "intrinsic_prefix": "mips", - }, - { - "name": "NVPTX", - "intrinsic_prefix": "nvvm", - }, - { - "name": "PowerPC", - "intrinsic_prefix": "ppc", - }, - { - "name": "R600", - "intrinsic_prefix": "r600", - }, - { - "name": "RISCV", - "intrinsic_prefix": "riscv", - }, - { - "name": "S390", - "intrinsic_prefix": "s390", - }, - { - "name": "SPIRV", - "intrinsic_prefix": "spv", - }, - { - "name": "VE", - "intrinsic_prefix": "ve", - }, - { - "name": "WebAssembly", - "intrinsic_prefix": "wasm", - }, - { - "name": "X86", - "intrinsic_prefix": "x86", - }, - { - "name": "XCore", - "intrinsic_prefix": "xcore", - }, -] - -[[ - gentbl( - name = "intrinsic_" + target["name"] + "_gen", - tbl_outs = [( - "-gen-intrinsic-enums -intrinsic-prefix=" + target["intrinsic_prefix"], - "include/llvm/IR/Intrinsics" + target["name"] + ".h", - )], - tblgen = ":llvm-min-tblgen", - td_file = "include/llvm/IR/Intrinsics.td", - td_srcs = glob([ - "include/llvm/CodeGen/*.td", - "include/llvm/IR/*.td", - ]), - ), -] for target in llvm_target_intrinsics_list] - -gentbl( - name = "attributes_gen", - tbl_outs = [("-gen-attrs", "include/llvm/IR/Attributes.inc")], - tblgen = ":llvm-min-tblgen", - td_file = "include/llvm/IR/Attributes.td", - td_srcs = ["include/llvm/IR/Attributes.td"], -) - -cc_library( - name = "BitstreamReader", - srcs = glob([ - "lib/Bitstream/Reader/*.cpp", - "lib/Bitstream/Reader/*.h", - ]), - hdrs = [ - "include/llvm/Bitstream/BitCodeEnums.h", - "include/llvm/Bitstream/BitCodes.h", - "include/llvm/Bitstream/BitstreamReader.h", - ], - copts = llvm_copts, - deps = [ - ":Support", - ], -) - -cc_library( - name = "BitstreamWriter", - srcs = glob([ - "lib/Bitstream/Writer/*.h", - ]), - hdrs = [ - "include/llvm/Bitstream/BitCodeEnums.h", - "include/llvm/Bitstream/BitCodes.h", - "include/llvm/Bitstream/BitstreamWriter.h", - ], - copts = llvm_copts, - deps = [ - ":Support", - ], -) - -cc_library( - name = "Remarks", - srcs = glob( - [ - "lib/Remarks/*.cpp", - "lib/Remarks/*.h", - ], - exclude = ["lib/Remarks/RemarkLinker.cpp"], - ), - hdrs = glob( - [ - "include/llvm/Remarks/*.h", - ], - exclude = ["include/llvm/Remarks/RemarkLinker.h"], - ) + [ - "include/llvm-c/Remarks.h", - ], - copts = llvm_copts, - deps = [ - ":BitstreamReader", - ":BitstreamWriter", - ":Support", - ], -) - -cc_library( - name = "remark_linker", - srcs = ["lib/Remarks/RemarkLinker.cpp"], - hdrs = ["include/llvm/Remarks/RemarkLinker.h"], - copts = llvm_copts, - deps = [ - ":Object", - ":Remarks", - ":Support", - ], -) - -filegroup( - name = "llvm_intrinsics_headers", - srcs = [ - "include/llvm/IR/Intrinsics" + target["name"] + ".h" - for target in llvm_target_intrinsics_list - ], -) - -cc_library( - name = "Core", - srcs = glob([ - "lib/IR/*.cpp", - "lib/IR/*.h", - ]), - hdrs = glob( - [ - "include/llvm/*.h", - "include/llvm/IR/*.h", - ], - exclude = [ - "include/llvm/LinkAllPasses.h", - ], - ) + [ - "include/llvm-c/Comdat.h", - "include/llvm-c/DebugInfo.h", - ] + [":llvm_intrinsics_headers"], - copts = llvm_copts, - textual_hdrs = glob(["include/llvm/IR/*.def"]), - deps = [ - ":BinaryFormat", - ":Demangle", - ":Remarks", - ":Support", - ":TargetParser", - ":attributes_gen", - ":config", - ":intrinsic_enums_gen", - ":intrinsics_impl_gen", - ], -) - -cc_library( - name = "BitReader", - srcs = glob([ - "lib/Bitcode/Reader/*.cpp", - "lib/Bitcode/Reader/*.h", - ]), - hdrs = [ - "include/llvm-c/BitReader.h", - "include/llvm/Bitcode/BitcodeAnalyzer.h", - "include/llvm/Bitcode/BitcodeCommon.h", - "include/llvm/Bitcode/BitcodeReader.h", - "include/llvm/Bitcode/LLVMBitCodes.h", - ], - copts = llvm_copts, - deps = [ - ":BinaryFormat", - ":BitstreamReader", - ":Core", - ":Support", - ":TargetParser", - ":config", - ], -) - -cc_library( - name = "MCParser", - srcs = glob([ - "lib/MC/MCParser/*.cpp", - "lib/MC/MCParser/*.h", - ]), - hdrs = glob(["include/llvm/MC/MCParser/*.h"]), - copts = llvm_copts, - deps = [ - ":BinaryFormat", - ":DebugInfoCodeView", - ":MC", - ":Support", - ":TargetParser", - ":config", - ], -) - -cc_library( - name = "TextAPI", - srcs = glob( - [ - "lib/TextAPI/**/*.cpp", - ], - exclude = ["lib/TextAPI/BinaryReader/**"], - ), - hdrs = glob( - [ - "include/llvm/TextAPI/**/*.h", - "include/llvm/TextAPI/**/*.def", - "lib/TextAPI/**/*.h", - ], - exclude = [ - "lib/TextAPI/BinaryReader/**", - "include/llvm/TextAPI/DylibReader.h", - ], - ), - copts = llvm_copts, - deps = [ - ":BinaryFormat", - ":Support", - ":TargetParser", - ], -) - -cc_library( - name = "TextAPIBinaryReader", - srcs = glob([ - "lib/TextAPI/BinaryReader/**/*.cpp", - ]), - hdrs = ["include/llvm/TextAPI/DylibReader.h"] + glob( - ["lib/TextAPI/BinaryReader/**/*.h"], - ), - copts = llvm_copts, - deps = [ - ":Object", - ":Support", - ":TargetParser", - ":TextAPI", - ], -) - -cc_library( - name = "ObjCopy", - srcs = glob([ - "lib/ObjCopy/**/*.cpp", - "lib/ObjCopy/**/*.h", - ]), - hdrs = glob([ - "include/llvm/ObjCopy/**/*.h", - ]), - copts = llvm_copts, - includes = ["lib/ObjCopy"], - deps = [ - ":BinaryFormat", - ":MC", - ":Object", - ":ObjectYAML", - ":Option", - ":Support", - ":Target", - ":intrinsics_impl_gen", - ], -) - -cc_library( - name = "Object", - srcs = glob([ - "lib/Object/*.cpp", - "lib/Object/*.h", - ]), - hdrs = glob([ - "include/llvm/Object/*.h", - ]) + [ - "include/llvm-c/Object.h", - ], - copts = llvm_copts, - deps = [ - ":BinaryFormat", - ":BitReader", - ":Core", - ":IRReader", - ":MC", - ":MCParser", - ":Support", - ":TargetParser", - ":TextAPI", - ":config", - ], -) - -cc_library( - name = "ObjectYAML", - srcs = glob([ - "lib/ObjectYAML/*.cpp", - "lib/ObjectYAML/*.h", - ]), - hdrs = glob(["include/llvm/ObjectYAML/*.h"]), - copts = llvm_copts, - deps = [ - ":BinaryFormat", - ":DebugInfoCodeView", - ":MC", - ":Object", - ":Support", - ":TargetParser", - ], -) - -cc_library( - name = "ProfileData", - srcs = glob([ - "lib/ProfileData/*.cpp", - "lib/ProfileData/*.h", - ]), - hdrs = glob([ - "include/llvm/ProfileData/*.h", - "include/llvm/ProfileData/*.inc", - ]), - copts = llvm_copts, - deps = [ - ":Core", - ":DebugInfo", - ":DebugInfoDWARF", - ":Demangle", - ":Object", - ":Support", - ":Symbolize", - ":TargetParser", - ":config", - ], -) - -cc_library( - name = "Coverage", - srcs = glob([ - "lib/ProfileData/Coverage/*.cpp", - "lib/ProfileData/Coverage/*.h", - ]), - hdrs = glob(["include/llvm/ProfileData/Coverage/*.h"]), - copts = llvm_copts, - deps = [ - ":Object", - ":ProfileData", - ":Support", - ":TargetParser", - ], -) - -cc_library( - name = "Analysis", - srcs = glob( - [ - "lib/Analysis/*.cpp", - "lib/Analysis/*.h", - "lib/Analysis/*.def", - ], - ), - hdrs = glob( - [ - "include/llvm/Analysis/*.h", - "include/llvm/Analysis/Utils/*.h", - ], - ) + [ - "include/llvm-c/Analysis.h", - ], - copts = llvm_copts, - textual_hdrs = glob([ - "include/llvm/Analysis/*.def", - ]), - deps = [ - ":BinaryFormat", - ":Core", - ":Object", - ":ProfileData", - ":Support", - ":TargetParser", - ":config", - ], -) - -cc_library( - name = "BitWriter", - srcs = glob([ - "lib/Bitcode/Writer/*.cpp", - "lib/Bitcode/Writer/*.h", - ]), - hdrs = [ - "include/llvm-c/BitWriter.h", - "include/llvm/Bitcode/BitcodeCommon.h", - "include/llvm/Bitcode/BitcodeConvenience.h", - "include/llvm/Bitcode/BitcodeWriter.h", - "include/llvm/Bitcode/BitcodeWriterPass.h", - "include/llvm/Bitcode/LLVMBitCodes.h", - ], - copts = llvm_copts, - deps = [ - ":Analysis", - ":BitReader", - ":BitstreamWriter", - ":Core", - ":MC", - ":Object", - ":Support", - ":TargetParser", - ":config", - ], -) - -cc_library( - name = "Target", - srcs = glob([ - "lib/Target/*.cpp", - "lib/Target/*.h", - ]), - hdrs = glob([ - "include/llvm/Target/*.h", - ]) + [ - "include/llvm-c/Target.h", - "include/llvm-c/TargetMachine.h", - ], - copts = llvm_copts, - deps = [ - ":Analysis", - ":BinaryFormat", - ":Core", - ":MC", - ":Support", - ":TargetParser", - ":config", - ], -) - -gentbl( - name = "RISCVTargetParserDefGen", - tbl_outs = [("-gen-riscv-target-def", "include/llvm/TargetParser/RISCVTargetParserDef.inc")], - tblgen = ":llvm-min-tblgen", - td_file = "lib/Target/RISCV/RISCV.td", - td_srcs = [ - ":common_target_td_sources", - ] + glob([ - "lib/Target/RISCV/**/*.td", - ]), -) - -cc_library( - name = "TargetParser", - srcs = glob([ - "lib/TargetParser/*.cpp", - "lib/TargetParser/*.h", - ]) + select({ - "@platforms//os:windows": glob([ - "lib/TargetParser/Windows/*.h", - "lib/TargetParser/Windows/*.inc", - ]), - "//conditions:default": glob([ - "lib/TargetParser/Unix/*.h", - "lib/TargetParser/Unix/*.inc", - ]), - }), - hdrs = glob([ - "include/llvm/TargetParser/*.h", - ]), - copts = llvm_copts, - includes = ["include"], - textual_hdrs = [ - "include/llvm/TargetParser/RISCVTargetParserDef.inc", - ] + glob([ - "include/llvm/TargetParser/*.def", - ]), - deps = [ - ":Support", - ":config", - ], -) - -cc_library( - name = "DWP", - srcs = glob([ - "lib/DWP/*.cpp", - "lib/DWP/*.h", - ]), - hdrs = glob(["include/llvm/DWP/*.h"]), - copts = llvm_copts, - deps = [ - ":DebugInfoDWARF", - ":MC", - ":Object", - ":Support", - ":Target", - ], -) - -cc_library( - name = "TransformUtils", - srcs = glob([ - "lib/Transforms/Utils/*.cpp", - "lib/Transforms/Utils/*.h", - ]), - hdrs = glob(["include/llvm/Transforms/Utils/*.h"]) + [ - "include/llvm/Transforms/Utils.h", - ], - copts = llvm_copts, - deps = [ - ":Analysis", - ":BinaryFormat", - ":BitWriter", - ":Core", - ":ProfileData", - ":Support", - ":Target", - ":TargetParser", - ":config", - ], -) - -gentbl( - name = "InstCombineTableGen", - strip_include_prefix = "lib/Target/AMDGPU", - tbl_outs = [( - "-gen-searchable-tables", - "lib/Target/AMDGPU/InstCombineTables.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "lib/Target/AMDGPU/InstCombineTables.td", - td_srcs = glob([ - "include/llvm/CodeGen/*.td", - "include/llvm/IR/Intrinsics*.td", - ]) + [ - "lib/Target/AMDGPU/InstCombineTables.td", - "include/llvm/TableGen/SearchableTable.td", - ], -) - -cc_library( - name = "InstCombine", - srcs = glob([ - "lib/Transforms/InstCombine/*.cpp", - "lib/Transforms/InstCombine/*.h", - ]), - hdrs = glob(["include/llvm/Transforms/InstCombine/*.h"]), - copts = llvm_copts, - deps = [ - ":Analysis", - ":Core", - ":Support", - ":Target", - ":TransformUtils", - ":config", - ], -) - -cc_library( - name = "AggressiveInstCombine", - srcs = glob([ - "lib/Transforms/AggressiveInstCombine/*.cpp", - "lib/Transforms/AggressiveInstCombine/*.h", - ]), - hdrs = [ - "include/llvm/Transforms/AggressiveInstCombine/AggressiveInstCombine.h", - ], - copts = llvm_copts, - deps = [ - ":Analysis", - ":Core", - ":Support", - ":TransformUtils", - ], -) - -cc_library( - name = "Instrumentation", - srcs = glob([ - "lib/Transforms/Instrumentation/*.cpp", - "lib/Transforms/Instrumentation/*.h", - "lib/Transforms/Instrumentation/*.inc", - ]), - hdrs = glob(["include/llvm/Transforms/Instrumentation/*.h"]) + [ - "include/llvm/Transforms/Instrumentation.h", - ], - copts = llvm_copts, - deps = [ - ":Analysis", - ":BinaryFormat", - ":Core", - ":Demangle", - ":MC", - ":ProfileData", - ":Support", - ":Target", - ":TargetParser", - ":TransformUtils", - ":config", - ], -) - -cc_library( - name = "ObjCARC", - srcs = glob([ - "lib/Transforms/ObjCARC/*.cpp", - "lib/Transforms/ObjCARC/*.h", - ]), - hdrs = ["include/llvm/Transforms/ObjCARC.h"], - copts = llvm_copts, - deps = [ - ":Analysis", - ":Core", - ":Support", - ":Target", - ":TransformUtils", - ":config", - ], -) - -cc_library( - name = "Scalar", - srcs = glob([ - "lib/Transforms/Scalar/*.cpp", - "lib/Transforms/Scalar/*.h", - ]), - hdrs = glob(["include/llvm/Transforms/Scalar/*.h"]) + [ - "include/llvm/Transforms/Scalar.h", - ], - copts = llvm_copts, - deps = [ - ":AggressiveInstCombine", - ":Analysis", - ":BinaryFormat", - ":Core", - ":InstCombine", - ":ProfileData", - ":Support", - ":Target", - ":TransformUtils", - ":config", - ], -) - -cc_library( - name = "Vectorize", - srcs = glob([ - "lib/Transforms/Vectorize/*.cpp", - "lib/Transforms/Vectorize/*.h", - ]), - hdrs = glob([ - "include/llvm/Transforms/Vectorize/*.h", - ]), - copts = llvm_copts, - deps = [ - ":Analysis", - ":Core", - ":Support", - ":Target", - ":TransformUtils", - ":config", - ], -) - -cc_library( - name = "FrontendDebug", - srcs = glob([ - "lib/Frontend/Debug/*.cpp", - ]), - hdrs = glob([ - "include/llvm/Frontend/Debug/*.h", - ]), - copts = llvm_copts, - deps = [ - ":Support", - ], -) - -cc_library( - name = "FrontendDriver", - srcs = glob([ - "lib/Frontend/Driver/*.cpp", - ]), - hdrs = glob([ - "include/llvm/Frontend/Driver/*.h", - ]), - copts = llvm_copts, - deps = [ - ":Analysis", - ":TargetParser", - ], -) - -cc_library( - name = "FrontendHLSL", - srcs = glob([ - "lib/Frontend/HLSL/*.cpp", - ]), - hdrs = glob([ - "include/llvm/Frontend/HLSL/*.h", - ]), - copts = llvm_copts, - deps = [ - ":Core", - ":Support", - ], -) - -cc_library( - name = "FrontendOffloading", - srcs = glob([ - "lib/Frontend/Offloading/*.cpp", - ]), - hdrs = glob([ - "include/llvm/Frontend/Offloading/*.h", - ]), - copts = llvm_copts, - deps = [ - ":BinaryFormat", - ":Core", - ":Object", - ":Support", - ":TargetParser", - ":TransformUtils", - ], -) - -filegroup( - name = "omp_td_files", - srcs = glob([ - "include/llvm/Frontend/OpenMP/*.td", - "include/llvm/Frontend/Directive/*.td", - ]), -) - -gentbl( - name = "omp_gen", - library = False, - tbl_outs = [ - ("--gen-directive-decl", "include/llvm/Frontend/OpenMP/OMP.h.inc"), - ], - tblgen = ":llvm-min-tblgen", - td_file = "include/llvm/Frontend/OpenMP/OMP.td", - td_srcs = [":omp_td_files"], -) - -gentbl( - name = "omp_gen_impl", - library = False, - tbl_outs = [ - ("--gen-directive-impl", "include/llvm/Frontend/OpenMP/OMP.inc"), - ], - tblgen = ":llvm-min-tblgen", - td_file = "include/llvm/Frontend/OpenMP/OMP.td", - td_srcs = [":omp_td_files"], -) - -cc_library( - name = "FrontendOpenMP", - srcs = glob([ - "lib/Frontend/OpenMP/*.cpp", - ]), - hdrs = glob([ - "include/llvm/Frontend/OpenMP/*.h", - "include/llvm/Frontend/OpenMP/OMP/*.h", - "include/llvm/Frontend/*.h", - ]) + [ - "include/llvm/Frontend/OpenMP/OMP.h.inc", - "include/llvm/Frontend/OpenMP/OMP.inc", - ], - copts = llvm_copts, - textual_hdrs = glob([ - "include/llvm/Frontend/OpenMP/*.def", - ]), - deps = [ - ":Analysis", - ":BitReader", - ":Core", - ":FrontendOffloading", - ":MC", - ":Scalar", - ":Support", - ":Target", - ":TargetParser", - ":TransformUtils", - ], -) - -filegroup( - name = "acc_td_files", - srcs = glob([ - "include/llvm/Frontend/OpenACC/*.td", - "include/llvm/Frontend/Directive/*.td", - ]), -) - -gentbl( - name = "acc_gen", - library = False, - tbl_outs = [ - ("--gen-directive-decl", "include/llvm/Frontend/OpenACC/ACC.h.inc"), - ], - tblgen = ":llvm-min-tblgen", - td_file = "include/llvm/Frontend/OpenACC/ACC.td", - td_srcs = [":acc_td_files"], -) - -gentbl( - name = "acc_gen_impl", - library = False, - tbl_outs = [ - ("--gen-directive-impl", "include/llvm/Frontend/OpenACC/ACC.inc"), - ], - tblgen = ":llvm-min-tblgen", - td_file = "include/llvm/Frontend/OpenACC/ACC.td", - td_srcs = [":acc_td_files"], -) - -cc_library( - name = "FrontendOpenACC", - srcs = glob([ - "lib/Frontend/OpenACC/*.cpp", - ]) + [ - "include/llvm/Frontend/OpenACC/ACC.inc", - ], - hdrs = glob([ - "include/llvm/Frontend/OpenACC/*.h", - ]) + ["include/llvm/Frontend/OpenACC/ACC.h.inc"], - copts = llvm_copts, - deps = [ - ":Analysis", - ":Core", - ":Support", - ":TransformUtils", - ], -) - -cc_library( - name = "AsmParser", - srcs = glob([ - "lib/AsmParser/*.cpp", - "lib/AsmParser/*.h", - ]), - hdrs = glob(["include/llvm/AsmParser/*.h"]), - copts = llvm_copts, - deps = [ - ":BinaryFormat", - ":Core", - ":Support", - ":attributes_gen", - ], -) - -cc_library( - name = "IRPrinter", - srcs = glob([ - "lib/IRPrinter/*.cpp", - "lib/IRPrinter/*.h", - ]), - hdrs = glob([ - "include/llvm/IRPrinter/*.h", - ]), - copts = llvm_copts, - deps = [ - ":Analysis", - ":Core", - ":Support", - ], -) - -cc_library( - name = "IRReader", - srcs = glob([ - "lib/IRReader/*.cpp", - "lib/IRReader/*.h", - ]), - hdrs = glob([ - "include/llvm/IRReader/*.h", - ]) + [ - "include/llvm-c/IRReader.h", - ], - copts = llvm_copts, - deps = [ - ":AsmParser", - ":BitReader", - ":Core", - ":Support", - ":config", - ], -) - -cc_library( - name = "Linker", - srcs = glob([ - "lib/Linker/*.cpp", - "lib/Linker/*.h", - ]), - hdrs = glob([ - "include/llvm/Linker/*.h", - ]) + [ - "include/llvm-c/Linker.h", - ], - copts = llvm_copts, - deps = [ - ":Core", - ":Object", - ":Support", - ":TargetParser", - ":TransformUtils", - ":config", - ], -) - -cc_library( - name = "IPO", - srcs = glob([ - "lib/Transforms/IPO/*.cpp", - "lib/Transforms/IPO/*.h", - ]), - hdrs = glob([ - "include/llvm/Transforms/IPO/*.h", - ]) + [ - "include/llvm/Transforms/IPO.h", - ], - copts = llvm_copts, - deps = [ - ":AggressiveInstCombine", - ":Analysis", - ":BinaryFormat", - ":BitReader", - ":BitWriter", - ":Core", - ":FrontendOpenMP", - ":IRPrinter", - ":IRReader", - ":InstCombine", - ":Instrumentation", - ":Linker", - ":ObjCARC", - ":Object", - ":ProfileData", - ":Scalar", - ":Support", - ":Target", - ":TargetParser", - ":TransformUtils", - ":Vectorize", - ":config", - ], -) - -cc_library( - name = "CFGuard", - srcs = glob([ - "lib/Transforms/CFGuard/*.cpp", - "lib/Transforms/CFGuard/*.h", - ]), - hdrs = ["include/llvm/Transforms/CFGuard.h"], - copts = llvm_copts, - deps = [ - ":Core", - ":Support", - ":TargetParser", - ], -) - -cc_library( - name = "HipStdPar", - srcs = glob([ - "lib/Transforms/HipStdPar/*.cpp", - "lib/Transforms/HipStdPar/*.h", - ]), - hdrs = ["include/llvm/Transforms/HipStdPar/HipStdPar.h"], - copts = llvm_copts, - deps = [ - ":Analysis", - ":Core", - ":Support", - ":TargetParser", - ":TransformUtils", - ], -) - -cc_library( - name = "Coroutines", - srcs = glob([ - "lib/Transforms/Coroutines/*.cpp", - "lib/Transforms/Coroutines/*.h", - ]), - hdrs = glob(["include/llvm/Transforms/Coroutines/*.h"]), - copts = llvm_copts, - deps = [ - ":Analysis", - ":BinaryFormat", - ":Core", - ":IPO", - ":Scalar", - ":Support", - ":TransformUtils", - ":config", - ], -) - -# Meta-target for clients which depend on all of the transforms libraries. -cc_library( - name = "common_transforms", - deps = [ - ":AggressiveInstCombine", - ":CFGuard", - ":Coroutines", - ":IPO", - ":InstCombine", - ":Instrumentation", - ":ObjCARC", - ":Scalar", - ":Vectorize", - ], -) - -cc_library( - name = "asm_printer_defs", - copts = llvm_copts, - textual_hdrs = glob(["lib/CodeGen/AsmPrinter/*.def"]), -) - -cc_library( - name = "CodeGenTypes", - srcs = glob([ - "lib/CodeGenTypes/**/*.cpp", - ]), - hdrs = glob([ - "include/llvm/CodeGenTypes/**/*.h", - ]), - copts = llvm_copts, - deps = [ - ":Support", - ":vt_gen", - ], -) - -cc_library( - name = "CodeGen", - srcs = glob( - [ - "lib/CodeGen/**/*.cpp", - "lib/CodeGen/**/*.h", - "lib/CodeGen/SelectionDAG/*.cpp", - "lib/CodeGen/SelectionDAG/*.h", - ], - ), - hdrs = [ - "include/llvm/LinkAllPasses.h", - ] + glob( - [ - "include/llvm/CodeGen/**/*.h", - ], - ), - copts = llvm_copts, - textual_hdrs = glob([ - "include/llvm/CodeGen/**/*.def", - "include/llvm/CodeGen/**/*.inc", - ]), - deps = [ - ":AggressiveInstCombine", - ":Analysis", - ":AsmParser", - ":BinaryFormat", - ":BitReader", - ":BitWriter", - ":CFGuard", - ":CodeGenTypes", - ":Core", - ":DebugInfoCodeView", - ":DebugInfoDWARF", - ":IPO", - ":IRPrinter", - ":Instrumentation", - ":MC", - ":MCParser", - ":Object", - ":ProfileData", - ":Remarks", - ":Scalar", - ":Support", - ":Target", - ":TargetParser", - ":TransformUtils", - ":asm_printer_defs", - ":config", - ":vt_gen", - ], -) - -cc_library( - name = "MCDisassembler", - srcs = glob([ - "lib/MC/MCDisassembler/*.cpp", - "lib/MC/MCDisassembler/*.h", - ]), - hdrs = glob([ - "include/llvm/MC/MCDisassembler/*.h", - ]) + [ - "include/llvm-c/Disassembler.h", - ], - copts = llvm_copts, - deps = [ - ":BinaryFormat", - ":MC", - ":Support", - ":TargetParser", - ":config", - ], -) - -llvm_target_lib_list = [lib for lib in [ - { - "name": "AArch64", - "short_name": "AArch64", - "tbl_outs": [ - ("-gen-register-bank", "lib/Target/AArch64/AArch64GenRegisterBank.inc"), - ("-gen-register-info", "lib/Target/AArch64/AArch64GenRegisterInfo.inc"), - ("-gen-instr-info", "lib/Target/AArch64/AArch64GenInstrInfo.inc"), - ("-gen-emitter", "lib/Target/AArch64/AArch64GenMCCodeEmitter.inc"), - ("-gen-pseudo-lowering", "lib/Target/AArch64/AArch64GenMCPseudoLowering.inc"), - ("-gen-asm-writer", "lib/Target/AArch64/AArch64GenAsmWriter.inc"), - ("-gen-asm-writer -asmwriternum=1", "lib/Target/AArch64/AArch64GenAsmWriter1.inc"), - ("-gen-asm-matcher", "lib/Target/AArch64/AArch64GenAsmMatcher.inc"), - ("-gen-dag-isel", "lib/Target/AArch64/AArch64GenDAGISel.inc"), - ("-gen-fast-isel", "lib/Target/AArch64/AArch64GenFastISel.inc"), - ("-gen-global-isel", "lib/Target/AArch64/AArch64GenGlobalISel.inc"), - ("-gen-global-isel-combiner -combiners=AArch64O0PreLegalizerCombiner", "lib/Target/AArch64/AArch64GenO0PreLegalizeGICombiner.inc"), - ("-gen-global-isel-combiner -combiners=AArch64PreLegalizerCombiner", "lib/Target/AArch64/AArch64GenPreLegalizeGICombiner.inc"), - ("-gen-global-isel-combiner -combiners=AArch64PostLegalizerCombiner", "lib/Target/AArch64/AArch64GenPostLegalizeGICombiner.inc"), - ("-gen-global-isel-combiner -combiners=AArch64PostLegalizerLowering", "lib/Target/AArch64/AArch64GenPostLegalizeGILowering.inc"), - ("-gen-callingconv", "lib/Target/AArch64/AArch64GenCallingConv.inc"), - ("-gen-subtarget", "lib/Target/AArch64/AArch64GenSubtargetInfo.inc"), - ("-gen-disassembler", "lib/Target/AArch64/AArch64GenDisassemblerTables.inc"), - ("-gen-searchable-tables", "lib/Target/AArch64/AArch64GenSystemOperands.inc"), - ("-gen-exegesis", "lib/Target/AArch64/AArch64GenExegesis.inc"), - ], - }, - { - "name": "ARM", - "short_name": "ARM", - "tbl_outs": [ - ("-gen-register-bank", "lib/Target/ARM/ARMGenRegisterBank.inc"), - ("-gen-register-info", "lib/Target/ARM/ARMGenRegisterInfo.inc"), - ("-gen-searchable-tables", "lib/Target/ARM/ARMGenSystemRegister.inc"), - ("-gen-instr-info", "lib/Target/ARM/ARMGenInstrInfo.inc"), - ("-gen-emitter", "lib/Target/ARM/ARMGenMCCodeEmitter.inc"), - ("-gen-pseudo-lowering", "lib/Target/ARM/ARMGenMCPseudoLowering.inc"), - ("-gen-asm-writer", "lib/Target/ARM/ARMGenAsmWriter.inc"), - ("-gen-asm-matcher", "lib/Target/ARM/ARMGenAsmMatcher.inc"), - ("-gen-dag-isel", "lib/Target/ARM/ARMGenDAGISel.inc"), - ("-gen-fast-isel", "lib/Target/ARM/ARMGenFastISel.inc"), - ("-gen-global-isel", "lib/Target/ARM/ARMGenGlobalISel.inc"), - ("-gen-callingconv", "lib/Target/ARM/ARMGenCallingConv.inc"), - ("-gen-subtarget", "lib/Target/ARM/ARMGenSubtargetInfo.inc"), - ("-gen-disassembler", "lib/Target/ARM/ARMGenDisassemblerTables.inc"), - ], - }, - { - "name": "AMDGPU", - "short_name": "AMDGPU", - "tbl_outs": [ - ("-gen-register-bank", "lib/Target/AMDGPU/AMDGPUGenRegisterBank.inc"), - ("-gen-register-info", "lib/Target/AMDGPU/AMDGPUGenRegisterInfo.inc"), - ("-gen-instr-info", "lib/Target/AMDGPU/AMDGPUGenInstrInfo.inc"), - ("-gen-emitter", "lib/Target/AMDGPU/AMDGPUGenMCCodeEmitter.inc"), - ("-gen-pseudo-lowering", "lib/Target/AMDGPU/AMDGPUGenMCPseudoLowering.inc"), - ("-gen-asm-writer", "lib/Target/AMDGPU/AMDGPUGenAsmWriter.inc"), - ("-gen-asm-matcher", "lib/Target/AMDGPU/AMDGPUGenAsmMatcher.inc"), - ("-gen-dag-isel", "lib/Target/AMDGPU/AMDGPUGenDAGISel.inc"), - ("-gen-callingconv", "lib/Target/AMDGPU/AMDGPUGenCallingConv.inc"), - ("-gen-subtarget", "lib/Target/AMDGPU/AMDGPUGenSubtargetInfo.inc"), - ("-gen-disassembler", "lib/Target/AMDGPU/AMDGPUGenDisassemblerTables.inc"), - ("-gen-searchable-tables", "lib/Target/AMDGPU/AMDGPUGenSearchableTables.inc"), - ], - "tbl_deps": [ - ":InstCombineTableGen", - ":amdgpu_isel_target_gen", - ":r600_target_gen", - ], - }, - { - "name": "AVR", - "short_name": "AVR", - "tbl_outs": [ - ("-gen-asm-matcher", "lib/Target/AVR/AVRGenAsmMatcher.inc"), - ("-gen-asm-writer", "lib/Target/AVR/AVRGenAsmWriter.inc"), - ("-gen-callingconv", "lib/Target/AVR/AVRGenCallingConv.inc"), - ("-gen-dag-isel", "lib/Target/AVR/AVRGenDAGISel.inc"), - ("-gen-disassembler", "lib/Target/AVR/AVRGenDisassemblerTables.inc"), - ("-gen-emitter", "lib/Target/AVR/AVRGenMCCodeEmitter.inc"), - ("-gen-instr-info", "lib/Target/AVR/AVRGenInstrInfo.inc"), - ("-gen-register-info", "lib/Target/AVR/AVRGenRegisterInfo.inc"), - ("-gen-subtarget", "lib/Target/AVR/AVRGenSubtargetInfo.inc"), - ], - }, - { - "name": "BPF", - "short_name": "BPF", - "tbl_outs": [ - ("-gen-register-bank", "lib/Target/BPF/BPFGenRegisterBank.inc"), - ("-gen-asm-writer", "lib/Target/BPF/BPFGenAsmWriter.inc"), - ("-gen-asm-matcher", "lib/Target/BPF/BPFGenAsmMatcher.inc"), - ("-gen-callingconv", "lib/Target/BPF/BPFGenCallingConv.inc"), - ("-gen-dag-isel", "lib/Target/BPF/BPFGenDAGISel.inc"), - ("-gen-global-isel", "lib/Target/BPF/BPFGenGlobalISel.inc"), - ("-gen-disassembler", "lib/Target/BPF/BPFGenDisassemblerTables.inc"), - ("-gen-emitter", "lib/Target/BPF/BPFGenMCCodeEmitter.inc"), - ("-gen-instr-info", "lib/Target/BPF/BPFGenInstrInfo.inc"), - ("-gen-register-info", "lib/Target/BPF/BPFGenRegisterInfo.inc"), - ("-gen-subtarget", "lib/Target/BPF/BPFGenSubtargetInfo.inc"), - ], - }, - { - "name": "Hexagon", - "short_name": "Hexagon", - "tbl_outs": [ - ("-gen-asm-matcher", "lib/Target/Hexagon/HexagonGenAsmMatcher.inc"), - ("-gen-asm-writer", "lib/Target/Hexagon/HexagonGenAsmWriter.inc"), - ("-gen-callingconv", "lib/Target/Hexagon/HexagonGenCallingConv.inc"), - ("-gen-dag-isel", "lib/Target/Hexagon/HexagonGenDAGISel.inc"), - ("-gen-dfa-packetizer", "lib/Target/Hexagon/HexagonGenDFAPacketizer.inc"), - ("-gen-disassembler", "lib/Target/Hexagon/HexagonGenDisassemblerTables.inc"), - ("-gen-instr-info", "lib/Target/Hexagon/HexagonGenInstrInfo.inc"), - ("-gen-emitter", "lib/Target/Hexagon/HexagonGenMCCodeEmitter.inc"), - ("-gen-register-info", "lib/Target/Hexagon/HexagonGenRegisterInfo.inc"), - ("-gen-subtarget", "lib/Target/Hexagon/HexagonGenSubtargetInfo.inc"), - ], - }, - { - "name": "Lanai", - "short_name": "Lanai", - "tbl_outs": [ - ("-gen-asm-matcher", "lib/Target/Lanai/LanaiGenAsmMatcher.inc"), - ("-gen-asm-writer", "lib/Target/Lanai/LanaiGenAsmWriter.inc"), - ("-gen-callingconv", "lib/Target/Lanai/LanaiGenCallingConv.inc"), - ("-gen-dag-isel", "lib/Target/Lanai/LanaiGenDAGISel.inc"), - ("-gen-disassembler", "lib/Target/Lanai/LanaiGenDisassemblerTables.inc"), - ("-gen-emitter", "lib/Target/Lanai/LanaiGenMCCodeEmitter.inc"), - ("-gen-instr-info", "lib/Target/Lanai/LanaiGenInstrInfo.inc"), - ("-gen-register-info", "lib/Target/Lanai/LanaiGenRegisterInfo.inc"), - ("-gen-subtarget", "lib/Target/Lanai/LanaiGenSubtargetInfo.inc"), - ], - }, - { - "name": "LoongArch", - "short_name": "LoongArch", - "tbl_outs": [ - ("-gen-asm-matcher", "lib/Target/LoongArch/LoongArchGenAsmMatcher.inc"), - ("-gen-asm-writer", "lib/Target/LoongArch/LoongArchGenAsmWriter.inc"), - ("-gen-dag-isel", "lib/Target/LoongArch/LoongArchGenDAGISel.inc"), - ("-gen-disassembler", "lib/Target/LoongArch/LoongArchGenDisassemblerTables.inc"), - ("-gen-emitter", "lib/Target/LoongArch/LoongArchGenMCCodeEmitter.inc"), - ("-gen-instr-info", "lib/Target/LoongArch/LoongArchGenInstrInfo.inc"), - ("-gen-pseudo-lowering", "lib/Target/LoongArch/LoongArchGenMCPseudoLowering.inc"), - ("-gen-register-info", "lib/Target/LoongArch/LoongArchGenRegisterInfo.inc"), - ("-gen-subtarget", "lib/Target/LoongArch/LoongArchGenSubtargetInfo.inc"), - ], - }, - { - "name": "Mips", - "short_name": "Mips", - "tbl_outs": [ - ("-gen-asm-matcher", "lib/Target/Mips/MipsGenAsmMatcher.inc"), - ("-gen-asm-writer", "lib/Target/Mips/MipsGenAsmWriter.inc"), - ("-gen-callingconv", "lib/Target/Mips/MipsGenCallingConv.inc"), - ("-gen-dag-isel", "lib/Target/Mips/MipsGenDAGISel.inc"), - ("-gen-disassembler", "lib/Target/Mips/MipsGenDisassemblerTables.inc"), - ("-gen-emitter", "lib/Target/Mips/MipsGenMCCodeEmitter.inc"), - ("-gen-exegesis", "lib/Target/Mips/MipsGenExegesis.inc"), - ("-gen-fast-isel", "lib/Target/Mips/MipsGenFastISel.inc"), - ("-gen-global-isel", "lib/Target/Mips/MipsGenGlobalISel.inc"), - ("-gen-global-isel-combiner -combiners=MipsPostLegalizerCombiner", "lib/Target/Mips/MipsGenPostLegalizeGICombiner.inc"), - ("-gen-instr-info", "lib/Target/Mips/MipsGenInstrInfo.inc"), - ("-gen-pseudo-lowering", "lib/Target/Mips/MipsGenMCPseudoLowering.inc"), - ("-gen-register-bank", "lib/Target/Mips/MipsGenRegisterBank.inc"), - ("-gen-register-info", "lib/Target/Mips/MipsGenRegisterInfo.inc"), - ("-gen-subtarget", "lib/Target/Mips/MipsGenSubtargetInfo.inc"), - ], - }, - { - "name": "MSP430", - "short_name": "MSP430", - "tbl_outs": [ - ("-gen-asm-matcher", "lib/Target/MSP430/MSP430GenAsmMatcher.inc"), - ("-gen-asm-writer", "lib/Target/MSP430/MSP430GenAsmWriter.inc"), - ("-gen-callingconv", "lib/Target/MSP430/MSP430GenCallingConv.inc"), - ("-gen-dag-isel", "lib/Target/MSP430/MSP430GenDAGISel.inc"), - ("-gen-disassembler", "lib/Target/MSP430/MSP430GenDisassemblerTables.inc"), - ("-gen-emitter", "lib/Target/MSP430/MSP430GenMCCodeEmitter.inc"), - ("-gen-instr-info", "lib/Target/MSP430/MSP430GenInstrInfo.inc"), - ("-gen-register-info", "lib/Target/MSP430/MSP430GenRegisterInfo.inc"), - ("-gen-subtarget", "lib/Target/MSP430/MSP430GenSubtargetInfo.inc"), - ], - }, - { - "name": "NVPTX", - "short_name": "NVPTX", - "tbl_outs": [ - ("-gen-register-info", "lib/Target/NVPTX/NVPTXGenRegisterInfo.inc"), - ("-gen-instr-info", "lib/Target/NVPTX/NVPTXGenInstrInfo.inc"), - ("-gen-asm-writer", "lib/Target/NVPTX/NVPTXGenAsmWriter.inc"), - ("-gen-dag-isel", "lib/Target/NVPTX/NVPTXGenDAGISel.inc"), - ("-gen-subtarget", "lib/Target/NVPTX/NVPTXGenSubtargetInfo.inc"), - ], - }, - { - "name": "PowerPC", - "short_name": "PPC", - "tbl_outs": [ - ("-gen-asm-writer", "lib/Target/PowerPC/PPCGenAsmWriter.inc"), - ("-gen-asm-matcher", "lib/Target/PowerPC/PPCGenAsmMatcher.inc"), - ("-gen-emitter", "lib/Target/PowerPC/PPCGenMCCodeEmitter.inc"), - ("-gen-register-info", "lib/Target/PowerPC/PPCGenRegisterInfo.inc"), - ("-gen-instr-info", "lib/Target/PowerPC/PPCGenInstrInfo.inc"), - ("-gen-dag-isel", "lib/Target/PowerPC/PPCGenDAGISel.inc"), - ("-gen-fast-isel", "lib/Target/PowerPC/PPCGenFastISel.inc"), - ("-gen-callingconv", "lib/Target/PowerPC/PPCGenCallingConv.inc"), - ("-gen-subtarget", "lib/Target/PowerPC/PPCGenSubtargetInfo.inc"), - ("-gen-disassembler", "lib/Target/PowerPC/PPCGenDisassemblerTables.inc"), - ("-gen-register-bank", "lib/Target/PowerPC/PPCGenRegisterBank.inc"), - ("-gen-global-isel", "lib/Target/PowerPC/PPCGenGlobalISel.inc"), - ("-gen-exegesis", "lib/Target/PowerPC/PPCGenExegesis.inc"), - ], - }, - { - "name": "Sparc", - "short_name": "Sparc", - "tbl_outs": [ - ("-gen-asm-writer", "lib/Target/Sparc/SparcGenAsmWriter.inc"), - ("-gen-asm-matcher", "lib/Target/Sparc/SparcGenAsmMatcher.inc"), - ("-gen-emitter", "lib/Target/Sparc/SparcGenMCCodeEmitter.inc"), - ("-gen-register-info", "lib/Target/Sparc/SparcGenRegisterInfo.inc"), - ("-gen-instr-info", "lib/Target/Sparc/SparcGenInstrInfo.inc"), - ("-gen-dag-isel", "lib/Target/Sparc/SparcGenDAGISel.inc"), - ("-gen-callingconv", "lib/Target/Sparc/SparcGenCallingConv.inc"), - ("-gen-subtarget", "lib/Target/Sparc/SparcGenSubtargetInfo.inc"), - ("-gen-disassembler", "lib/Target/Sparc/SparcGenDisassemblerTables.inc"), - ("-gen-searchable-tables", "lib/Target/Sparc/SparcGenSearchableTables.inc"), - ], - }, - { - "name": "SystemZ", - "short_name": "SystemZ", - "tbl_outs": [ - ("-gen-asm-matcher", "lib/Target/SystemZ/SystemZGenAsmMatcher.inc"), - ("-gen-asm-writer", "lib/Target/SystemZ/SystemZGenAsmWriter.inc"), - ("-gen-callingconv", "lib/Target/SystemZ/SystemZGenCallingConv.inc"), - ("-gen-dag-isel", "lib/Target/SystemZ/SystemZGenDAGISel.inc"), - ("-gen-disassembler", "lib/Target/SystemZ/SystemZGenDisassemblerTables.inc"), - ("-gen-emitter", "lib/Target/SystemZ/SystemZGenMCCodeEmitter.inc"), - ("-gen-instr-info", "lib/Target/SystemZ/SystemZGenInstrInfo.inc"), - ("-gen-register-info", "lib/Target/SystemZ/SystemZGenRegisterInfo.inc"), - ("-gen-subtarget", "lib/Target/SystemZ/SystemZGenSubtargetInfo.inc"), - ], - }, - { - "name": "RISCV", - "short_name": "RISCV", - "tbl_outs": [ - ("-gen-asm-matcher", "lib/Target/RISCV/RISCVGenAsmMatcher.inc"), - ("-gen-asm-writer", "lib/Target/RISCV/RISCVGenAsmWriter.inc"), - ("-gen-compress-inst-emitter", "lib/Target/RISCV/RISCVGenCompressInstEmitter.inc"), - ("-gen-dag-isel", "lib/Target/RISCV/RISCVGenDAGISel.inc"), - ("-gen-disassembler", "lib/Target/RISCV/RISCVGenDisassemblerTables.inc"), - ("-gen-instr-info", "lib/Target/RISCV/RISCVGenInstrInfo.inc"), - ("-gen-macro-fusion-pred", "lib/Target/RISCV/RISCVGenMacroFusion.inc"), - ("-gen-emitter", "lib/Target/RISCV/RISCVGenMCCodeEmitter.inc"), - ("-gen-pseudo-lowering", "lib/Target/RISCV/RISCVGenMCPseudoLowering.inc"), - ("-gen-register-bank", "lib/Target/RISCV/RISCVGenRegisterBank.inc"), - ("-gen-register-info", "lib/Target/RISCV/RISCVGenRegisterInfo.inc"), - ("-gen-subtarget", "lib/Target/RISCV/RISCVGenSubtargetInfo.inc"), - ("-gen-searchable-tables", "lib/Target/RISCV/RISCVGenSearchableTables.inc"), - ], - "tbl_deps": [ - ":riscv_isel_target_gen", - ], - }, - { - "name": "VE", - "short_name": "VE", - "tbl_outs": [ - ("-gen-asm-matcher", "lib/Target/VE/VEGenAsmMatcher.inc"), - ("-gen-asm-writer", "lib/Target/VE/VEGenAsmWriter.inc"), - ("-gen-callingconv", "lib/Target/VE/VEGenCallingConv.inc"), - ("-gen-dag-isel", "lib/Target/VE/VEGenDAGISel.inc"), - ("-gen-disassembler", "lib/Target/VE/VEGenDisassemblerTables.inc"), - ("-gen-emitter", "lib/Target/VE/VEGenMCCodeEmitter.inc"), - ("-gen-instr-info", "lib/Target/VE/VEGenInstrInfo.inc"), - ("-gen-register-info", "lib/Target/VE/VEGenRegisterInfo.inc"), - ("-gen-subtarget", "lib/Target/VE/VEGenSubtargetInfo.inc"), - ], - }, - { - "name": "WebAssembly", - "short_name": "WebAssembly", - "tbl_outs": [ - ("-gen-disassembler", "lib/Target/WebAssembly/WebAssemblyGenDisassemblerTables.inc"), - ("-gen-asm-writer", "lib/Target/WebAssembly/WebAssemblyGenAsmWriter.inc"), - ("-gen-instr-info", "lib/Target/WebAssembly/WebAssemblyGenInstrInfo.inc"), - ("-gen-dag-isel", "lib/Target/WebAssembly/WebAssemblyGenDAGISel.inc"), - ("-gen-fast-isel", "lib/Target/WebAssembly/WebAssemblyGenFastISel.inc"), - ("-gen-emitter", "lib/Target/WebAssembly/WebAssemblyGenMCCodeEmitter.inc"), - ("-gen-register-info", "lib/Target/WebAssembly/WebAssemblyGenRegisterInfo.inc"), - ("-gen-subtarget", "lib/Target/WebAssembly/WebAssemblyGenSubtargetInfo.inc"), - ("-gen-asm-matcher", "lib/Target/WebAssembly/WebAssemblyGenAsmMatcher.inc"), - ], - }, - { - "name": "X86", - "short_name": "X86", - "tbl_outs": [ - ("-gen-register-bank", "lib/Target/X86/X86GenRegisterBank.inc"), - ("-gen-register-info", "lib/Target/X86/X86GenRegisterInfo.inc"), - ("-gen-disassembler", "lib/Target/X86/X86GenDisassemblerTables.inc"), - ("-gen-instr-info", "lib/Target/X86/X86GenInstrInfo.inc"), - ("-gen-asm-writer", "lib/Target/X86/X86GenAsmWriter.inc"), - ("-gen-asm-writer -asmwriternum=1", "lib/Target/X86/X86GenAsmWriter1.inc"), - ("-gen-asm-matcher", "lib/Target/X86/X86GenAsmMatcher.inc"), - ("-gen-dag-isel", "lib/Target/X86/X86GenDAGISel.inc"), - ("-gen-fast-isel", "lib/Target/X86/X86GenFastISel.inc"), - ("-gen-global-isel", "lib/Target/X86/X86GenGlobalISel.inc"), - ("-gen-callingconv", "lib/Target/X86/X86GenCallingConv.inc"), - ("-gen-subtarget", "lib/Target/X86/X86GenSubtargetInfo.inc"), - ("-gen-x86-fold-tables -asmwriternum=1", "lib/Target/X86/X86GenFoldTables.inc"), - ("-gen-x86-compress-evex-tables", "lib/Target/X86/X86GenCompressEVEXTables.inc"), - ("-gen-exegesis", "lib/Target/X86/X86GenExegesis.inc"), - ("-gen-x86-mnemonic-tables -asmwriternum=1", "lib/Target/X86/X86GenMnemonicTables.inc"), - ], - }, - { - "name": "XCore", - "short_name": "XCore", - "tbl_outs": [ - ("-gen-asm-writer", "lib/Target/XCore/XCoreGenAsmWriter.inc"), - ("-gen-callingconv", "lib/Target/XCore/XCoreGenCallingConv.inc"), - ("-gen-dag-isel", "lib/Target/XCore/XCoreGenDAGISel.inc"), - ("-gen-disassembler", "lib/Target/XCore/XCoreGenDisassemblerTables.inc"), - ("-gen-instr-info", "lib/Target/XCore/XCoreGenInstrInfo.inc"), - ("-gen-register-info", "lib/Target/XCore/XCoreGenRegisterInfo.inc"), - ("-gen-subtarget", "lib/Target/XCore/XCoreGenSubtargetInfo.inc"), - ], - }, -] if lib["name"] in llvm_targets] - -cc_library( - name = "x86_target_layering_problem_hdrs", - textual_hdrs = ["lib/Target/X86/X86InstrInfo.h"], -) - -filegroup( - name = "common_target_td_sources", - srcs = glob([ - "include/llvm/CodeGen/*.td", - "include/llvm/Frontend/Directive/*.td", - "include/llvm/IR/Intrinsics*.td", - "include/llvm/TableGen/*.td", - "include/llvm/Target/*.td", - "include/llvm/Target/GlobalISel/*.td", - ]), -) - -gentbl( - name = "amdgpu_isel_target_gen", - strip_include_prefix = "lib/Target/AMDGPU", - tbl_outs = [ - ("-gen-global-isel", "lib/Target/AMDGPU/AMDGPUGenGlobalISel.inc"), - ("-gen-global-isel-combiner -combiners=AMDGPUPreLegalizerCombiner", "lib/Target/AMDGPU/AMDGPUGenPreLegalizeGICombiner.inc"), - ("-gen-global-isel-combiner -combiners=AMDGPUPostLegalizerCombiner", "lib/Target/AMDGPU/AMDGPUGenPostLegalizeGICombiner.inc"), - ("-gen-global-isel-combiner -combiners=AMDGPURegBankCombiner", "lib/Target/AMDGPU/AMDGPUGenRegBankGICombiner.inc"), - ], - tblgen = ":llvm-tblgen", - td_file = "lib/Target/AMDGPU/AMDGPUGISel.td", - td_srcs = [ - ":common_target_td_sources", - ] + glob([ - "lib/Target/AMDGPU/*.td", - ]), -) - -gentbl( - name = "r600_target_gen", - strip_include_prefix = "lib/Target/AMDGPU", - tbl_outs = [ - ("-gen-asm-writer", "lib/Target/AMDGPU/R600GenAsmWriter.inc"), - ("-gen-callingconv", "lib/Target/AMDGPU/R600GenCallingConv.inc"), - ("-gen-dag-isel", "lib/Target/AMDGPU/R600GenDAGISel.inc"), - ("-gen-dfa-packetizer", "lib/Target/AMDGPU/R600GenDFAPacketizer.inc"), - ("-gen-instr-info", "lib/Target/AMDGPU/R600GenInstrInfo.inc"), - ("-gen-emitter", "lib/Target/AMDGPU/R600GenMCCodeEmitter.inc"), - ("-gen-register-info", "lib/Target/AMDGPU/R600GenRegisterInfo.inc"), - ("-gen-subtarget", "lib/Target/AMDGPU/R600GenSubtargetInfo.inc"), - ], - tblgen = ":llvm-tblgen", - td_file = "lib/Target/AMDGPU/R600.td", - td_srcs = [ - ":common_target_td_sources", - ] + glob([ - "lib/Target/AMDGPU/*.td", - ]), -) - -gentbl( - name = "riscv_isel_target_gen", - strip_include_prefix = "lib/Target/RISCV", - tbl_outs = [ - ("-gen-global-isel", "lib/Target/RISCV/RISCVGenGlobalISel.inc"), - ("-gen-global-isel-combiner -combiners=RISCVO0PreLegalizerCombiner", "lib/Target/RISCV/RISCVGenO0PreLegalizeGICombiner.inc"), - ("-gen-global-isel-combiner -combiners=RISCVPostLegalizerCombiner", "lib/Target/RISCV/RISCVGenPostLegalizeGICombiner.inc"), - ("-gen-global-isel-combiner -combiners=RISCVPreLegalizerCombiner", "lib/Target/RISCV/RISCVGenPreLegalizeGICombiner.inc"), - ], - tblgen = ":llvm-tblgen", - td_file = "lib/Target/RISCV/RISCVGISel.td", - td_srcs = [ - ":common_target_td_sources", - ] + glob([ - "lib/Target/RISCV/**/*.td", - ]), -) - -[[ - [gentbl( - name = target["name"] + "CommonTableGen", - strip_include_prefix = "lib/Target/" + target["name"], - tbl_outs = target["tbl_outs"], - tblgen = ":llvm-tblgen", - # MSVC isn't happy with long string literals, while other compilers - # which support them get significant compile time improvements with - # them enabled. Ideally this flag would only be enabled on Windows via - # a select() on `@platforms//os:windows,`, but that would - # require refactoring gentbl from a macro into a rule. - # TODO(#92): Refactor gentbl to support this use - tblgen_args = "--long-string-literals=0", - td_file = "lib/Target/" + target["name"] + "/" + target["short_name"] + ".td", - td_srcs = [ - ":common_target_td_sources", - ] + glob([ - "lib/Target/" + target["name"] + "/*.td", - "lib/Target/" + target["name"] + "/GISel/*.td", - ]), - deps = target.get("tbl_deps", []), - )], - [cc_library( - name = target["name"] + "Info", - srcs = ["lib/Target/" + target["name"] + "/TargetInfo/" + target["name"] + "TargetInfo.cpp"], - hdrs = glob(["lib/Target/" + target["name"] + "/TargetInfo/*.h"]), - copts = llvm_copts, - # Workaround for https://github.com/bazelbuild/bazel/issues/3828 - # TODO(gcmn): Remove this when upgrading to a Bazel version containing - # https://github.com/bazelbuild/bazel/commit/e3b7e17b05f1 - includes = ["lib/Target/" + target["name"]], - strip_include_prefix = "lib/Target/" + target["name"], - deps = [ - ":" + target["name"] + "CommonTableGen", - ":MC", - ":Support", - ":Target", - ], - )], - # We cannot separate the `Utils` and `MCTargetDesc` sublibraries of - # a number of targets due to crisscrossing inclusion of headers. - [cc_library( - name = target["name"] + "UtilsAndDesc", - srcs = glob([ - "lib/Target/" + target["name"] + "/MCTargetDesc/*.cpp", - "lib/Target/" + target["name"] + "/Utils/*.cpp", - - # We have to include these headers here as well as in the `hdrs` - # below to allow the `.cpp` files to use file-relative-inclusion to - # find them, even though consumers of this library use inclusion - # relative to the target with the `strip_includes_prefix` of this - # library. This mixture is likely incompatible with header modules. - "lib/Target/" + target["name"] + "/MCTargetDesc/*.h", - "lib/Target/" + target["name"] + "/Utils/*.h", - ]), - hdrs = glob([ - "lib/Target/" + target["name"] + "/MCTargetDesc/*.h", - "lib/Target/" + target["name"] + "/Utils/*.h", - - # This a bit of a hack to allow us to expose common, internal - # target header files to other libraries within the target via - # target-relative includes. This usage of headers is inherently - # non-modular as there is a mixture of target-relative inclusion - # using this rule and file-relative inclusion using the repeated - # listing of these headers in the `srcs` of subsequent rules. - "lib/Target/" + target["name"] + "/*.h", - - # FIXME: The entries below should be `textual_hdrs` instead of - # `hdrs`, but unfortunately that doesn't work with - # `strip_include_prefix`: - # https://github.com/bazelbuild/bazel/issues/12424 - # - # Once that issue is fixed and released, we can switch this to - # `textual_hdrs` and remove the feature disabling the various Bazel - # features (both current and under-development) that motivated the - # distinction between these two. - "lib/Target/" + target["name"] + "/*.def", - "lib/Target/" + target["name"] + "/*.inc", - "lib/Target/" + target["name"] + "/MCTargetDesc/*.def", - ]), - copts = llvm_copts, - features = [ - "-parse_headers", - "-header_modules", - "-layering_check", - ], - strip_include_prefix = "lib/Target/" + target["name"], - deps = [ - ":BinaryFormat", - ":CodeGenTypes", - ":Core", - ":DebugInfoCodeView", - ":MC", - ":MCDisassembler", - ":Support", - ":Target", - ":config", - ":" + target["name"] + "CommonTableGen", - ":" + target["name"] + "Info", - ], - )], - [cc_library( - name = target["name"] + "CodeGen", - srcs = glob([ - "lib/Target/" + target["name"] + "/GISel/*.cpp", - "lib/Target/" + target["name"] + "/GISel/*.h", - "lib/Target/" + target["name"] + "/*.cpp", - "lib/Target/" + target["name"] + "/*.h", - ]), - hdrs = ["lib/Target/" + target["name"] + "/" + target["short_name"] + ".h"], - copts = llvm_copts, - features = ["-layering_check"], - strip_include_prefix = "lib/Target/" + target["name"], - textual_hdrs = glob([ - "lib/Target/" + target["name"] + "/*.def", - "lib/Target/" + target["name"] + "/*.inc", - ]), - deps = [ - ":Analysis", - ":BinaryFormat", - ":CFGuard", - ":CodeGen", - ":CodeGenTypes", - ":Core", - ":IPO", - ":MC", - ":Passes", # TODO(chandlerc): Likely a layering violation. - ":ProfileData", - ":Scalar", - ":Support", - ":Target", - ":TransformUtils", - ":Vectorize", - ":config", - ":" + target["name"] + "CommonTableGen", - ":" + target["name"] + "Info", - ":" + target["name"] + "UtilsAndDesc", - ], - )], - [cc_library( - name = target["name"] + "AsmParser", - srcs = glob([ - "lib/Target/" + target["name"] + "/AsmParser/*.cpp", - "lib/Target/" + target["name"] + "/AsmParser/*.h", - ]), - copts = llvm_copts, - deps = [ - ":BinaryFormat", - ":CodeGenTypes", - ":MC", - ":MCParser", - ":Support", - ":Target", - ":TargetParser", - ":" + target["name"] + "CodeGen", - ":" + target["name"] + "CommonTableGen", - ":" + target["name"] + "Info", - ":" + target["name"] + "UtilsAndDesc", - ], - )], - # This target is a bit of a hack to allow us to expose internal - # disassembler header files via internal target-relative include paths. - # This usage of headers is inherently non-modular as there is a mixture of - # target-relative inclusion using this rule and same-directory inclusion - # using the repeated listing of these headers in the `srcs` below. - [cc_library( - name = target["name"] + "DisassemblerInternalHeaders", - # FIXME: This should be `textual_hdrs` instead of `hdrs`, but - # unfortunately that doesn't work with `strip_include_prefix`: - # https://github.com/bazelbuild/bazel/issues/12424 - # - # Once that issue is fixed and released, we can switch this to - # `textual_hdrs` and remove the feature disabling the various Bazel - # features (both current and under-development) that motivated the - # distinction between these two. - hdrs = glob([ - "lib/Target/" + target["name"] + "/Disassembler/*.h", - ]), - features = [ - "-parse_headers", - "-header_modules", - ], - strip_include_prefix = "lib/Target/" + target["name"], - )], - [cc_library( - name = target["name"] + "Disassembler", - srcs = glob([ - "lib/Target/" + target["name"] + "/Disassembler/*.cpp", - "lib/Target/" + target["name"] + "/Disassembler/*.c", - "lib/Target/" + target["name"] + "/Disassembler/*.h", - ]), - copts = llvm_copts, - features = ["-layering_check"], - deps = [ - ":CodeGenTypes", - ":Core", - ":MC", - ":MCDisassembler", - ":Support", - ":Target", - ":" + target["name"] + "CodeGen", - ":" + target["name"] + "DisassemblerInternalHeaders", - ":" + target["name"] + "CommonTableGen", - ":" + target["name"] + "UtilsAndDesc", - ], - )], - [cc_library( - name = target["name"] + "TargetMCA", - srcs = glob([ - "lib/Target/" + target["name"] + "/MCA/*.cpp", - "lib/Target/" + target["name"] + "/MCA/*.c", - "lib/Target/" + target["name"] + "/MCA/*.h", - ]), - copts = llvm_copts, - features = ["-layering_check"], - deps = [ - ":CodeGenTypes", - ":MC", - ":MCA", - ":MCParser", - ":Support", - ":" + target["name"] + "DisassemblerInternalHeaders", - ":" + target["name"] + "Info", - ":" + target["name"] + "UtilsAndDesc", - ], - )], -] for target in llvm_target_lib_list] - -cc_library( - name = "AllTargetsCodeGens", - copts = llvm_copts, - deps = [ - target["name"] + "CodeGen" - for target in llvm_target_lib_list - ], -) - -cc_library( - name = "AllTargetsAsmParsers", - copts = llvm_copts, - deps = [ - target["name"] + "AsmParser" - for target in llvm_target_lib_list - ], -) - -cc_library( - name = "AllTargetsDisassemblers", - copts = llvm_copts, - deps = [ - target["name"] + "Disassembler" - for target in llvm_target_lib_list - ], -) - -cc_library( - name = "AllTargetsMCAs", - copts = llvm_copts, - deps = [ - target["name"] + "TargetMCA" - for target in llvm_target_lib_list - ], -) - -cc_library( - name = "pass_registry_def", - copts = llvm_copts, - textual_hdrs = ["lib/Passes/PassRegistry.def"], -) - -cc_library( - name = "MLPolicies", - srcs = glob([ - "lib/Analysis/ML/*.cpp", - "lib/Analysis/ML/*.h", - ]), - hdrs = glob([ - "include/llvm/Analysis/ML/*.h", - ]), - copts = llvm_copts, - deps = [ - ":Analysis", - ":Core", - ":Support", - ], -) - -cc_library( - name = "Passes", - srcs = glob([ - "lib/Passes/*.cpp", - "lib/Passes/*.h", - ]), - hdrs = glob([ - "include/llvm/Passes/*.h", - "include/llvm/Passes/*.def", - ]) + ["include/llvm-c/Transforms/PassBuilder.h"], - copts = llvm_copts, - deps = [ - ":AggressiveInstCombine", - ":Analysis", - ":CFGuard", - ":CodeGen", - ":Core", - ":Coroutines", - ":HipStdPar", - ":IPO", - ":IRPrinter", - ":InstCombine", - ":Instrumentation", - ":MC", - ":MLPolicies", - ":ObjCARC", - ":Scalar", - ":Support", - ":Target", - ":TransformUtils", - ":Vectorize", - ":common_transforms", - ":config", - ":pass_registry_def", - ], -) - -cc_library( - name = "LTO", - srcs = glob([ - "lib/LTO/*.cpp", - "lib/LTO/*.h", - ]), - hdrs = glob([ - "include/llvm/LTO/*.h", - "include/llvm/LTO/legacy/*.h", - ]) + [ - "include/llvm-c/lto.h", - ], - copts = llvm_copts, - deps = [ - ":Analysis", - ":BitReader", - ":BitWriter", - ":CodeGen", - ":CodeGenTypes", - ":Core", - ":IPO", - ":IRPrinter", - ":IRReader", - ":Linker", - ":MC", - ":MCParser", - ":ObjCARC", - ":Object", - ":Passes", - ":Remarks", - ":Scalar", - ":Support", - ":Target", - ":TargetParser", - ":TransformUtils", - ":common_transforms", - ":config", - ], -) - -cc_library( - name = "ExecutionEngine", - srcs = glob([ - "lib/ExecutionEngine/*.cpp", - "lib/ExecutionEngine/*.h", - "lib/ExecutionEngine/RuntimeDyld/*.cpp", - "lib/ExecutionEngine/RuntimeDyld/*.h", - "lib/ExecutionEngine/RuntimeDyld/Targets/*.cpp", - "lib/ExecutionEngine/RuntimeDyld/Targets/*.h", - ]), - hdrs = glob( - [ - "include/llvm/ExecutionEngine/*.h", - ], - exclude = [ - "include/llvm/ExecutionEngine/MCJIT*.h", - "include/llvm/ExecutionEngine/OProfileWrapper.h", - ], - ) + [ - "include/llvm-c/ExecutionEngine.h", - ], - copts = llvm_copts, - deps = [ - ":BinaryFormat", - ":CodeGen", - ":Core", - ":DebugInfo", - ":MC", - ":MCDisassembler", - ":Object", - ":OrcTargetProcess", - ":Passes", - ":Support", - ":Target", - ":TargetParser", - ":config", - ], -) - -cc_library( - name = "Interpreter", - srcs = glob([ - "lib/ExecutionEngine/Interpreter/*.cpp", - "lib/ExecutionEngine/Interpreter/*.h", - ]), - hdrs = ["include/llvm/ExecutionEngine/Interpreter.h"], - copts = llvm_copts, - deps = [ - ":CodeGen", - ":Core", - ":ExecutionEngine", - ":Support", - ":Target", - ":config", - ], -) - -gentbl( - name = "JITLinkTableGen", - strip_include_prefix = "lib/ExecutionEngine/JITLink", - tbl_outs = [( - "-gen-opt-parser-defs", - "lib/ExecutionEngine/JITLink/COFFOptions.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "lib/ExecutionEngine/JITLink/COFFOptions.td", - td_srcs = ["include/llvm/Option/OptParser.td"], -) - -cc_library( - name = "JITLink", - srcs = glob([ - "lib/ExecutionEngine/JITLink/*.cpp", - "lib/ExecutionEngine/JITLink/*.h", - ]), - hdrs = glob([ - "include/llvm/ExecutionEngine/JITLink/*.h", - "include/llvm/ExecutionEngine/Orc/*.h", - ]), - copts = llvm_copts, - deps = [ - ":BinaryFormat", - ":ExecutionEngine", - ":JITLinkTableGen", - ":Object", - ":Option", - ":OrcShared", - ":OrcTargetProcess", - ":Support", - ":TargetParser", - ":config", - ], -) - -cc_library( - name = "MCJIT", - srcs = glob([ - "lib/ExecutionEngine/MCJIT/*.cpp", - "lib/ExecutionEngine/MCJIT/*.h", - ]), - hdrs = glob(["include/llvm/ExecutionEngine/MCJIT*.h"]), - copts = llvm_copts, - deps = [ - ":CodeGen", - ":Core", - ":ExecutionEngine", - ":MC", - ":Object", - ":Support", - ":Target", - ":config", - ], -) - -cc_library( - name = "OrcJIT", - srcs = glob([ - "lib/ExecutionEngine/Orc/*.cpp", - "lib/ExecutionEngine/Orc/*.h", - ]), - hdrs = glob([ - "include/llvm/ExecutionEngine/Orc/*.h", - "include/llvm/ExecutionEngine/Orc/RPC/*.h", - ]) + [ - "include/llvm-c/LLJIT.h", - "include/llvm-c/Orc.h", - "include/llvm-c/OrcEE.h", - ], - copts = llvm_copts, - linkopts = select({ - "@platforms//os:android": [], - "@platforms//os:windows": [], - "@platforms//os:freebsd": [], - "@platforms//os:macos": [], - "//conditions:default": [ - "-lrt", - ], - }), - deps = [ - ":Analysis", - ":BinaryFormat", - ":BitReader", - ":BitWriter", - ":Core", - ":DebugInfoDWARF", - ":ExecutionEngine", - ":JITLink", - ":MC", - ":MCDisassembler", - ":Object", - ":OrcShared", - ":OrcTargetProcess", - ":Passes", - ":Support", - ":Target", - ":TargetParser", - ":TransformUtils", - ":WindowsDriver", - ":config", - ], -) - -cc_library( - name = "OrcShared", - srcs = glob([ - "lib/ExecutionEngine/Orc/Shared/*.cpp", - ]), - hdrs = glob([ - "include/llvm/ExecutionEngine/Orc/Shared/*.h", - ]), - copts = llvm_copts, - deps = [ - ":BinaryFormat", - ":CodeGen", - ":Core", - ":DebugInfo", - ":MC", - ":MCDisassembler", - ":Object", - ":Passes", - ":Support", - ":Target", - ":config", - ], -) - -cc_library( - name = "OrcDebugging", - srcs = glob([ - "lib/ExecutionEngine/Orc/Debugging/*.cpp", - ]), - hdrs = glob([ - "include/llvm/ExecutionEngine/Orc/Debugging/*.h", - ]) + ["include/llvm-c/LLJITUtils.h"], - copts = llvm_copts, - deps = [ - ":BinaryFormat", - ":DebugInfo", - ":JITLink", - ":OrcJIT", - ":OrcShared", - ":Support", - ":TargetParser", - ], -) - -cc_library( - name = "OrcTargetProcess", - srcs = glob([ - "lib/ExecutionEngine/Orc/TargetProcess/*.cpp", - "lib/ExecutionEngine/Orc/TargetProcess/*.h", - ]), - hdrs = glob([ - "include/llvm/ExecutionEngine/Orc/TargetProcess/*.h", - ]), - copts = llvm_copts, - linkopts = select({ - "@platforms//os:android": [], - "@platforms//os:windows": [], - "@platforms//os:freebsd": [], - "@platforms//os:macos": [], - "//conditions:default": [ - "-lrt", - ], - }), - deps = [ - ":BinaryFormat", - ":CodeGen", - ":Core", - ":DebugInfo", - ":MC", - ":MCDisassembler", - ":Object", - ":OrcShared", - ":Passes", - ":Support", - ":Target", - ":TargetParser", - ":config", - ], -) - -cc_library( - name = "DWARFLinker", - srcs = glob([ - "lib/DWARFLinker/Classic/*.cpp", - "lib/DWARFLinker/Classic/*.h", - ]), - hdrs = glob(["include/llvm/DWARFLinker/Classic/*.h"]), - copts = llvm_copts, - deps = [ - ":BinaryFormat", - ":CodeGen", - ":CodeGenTypes", - ":DWARFLinkerBase", - ":DebugInfoDWARF", - ":MC", - ":Support", - ":Target", - ":TargetParser", - ], -) - -cc_library( - name = "DWARFLinkerBase", - srcs = glob([ - "lib/DWARFLinker/*.cpp", - "lib/DWARFLinker/*.h", - ]), - hdrs = glob(["include/llvm/DWARFLinker/*.h"]), - copts = llvm_copts, - deps = [ - ":BinaryFormat", - ":CodeGen", - ":DebugInfoDWARF", - ":Support", - ":Target", - ], -) - -cc_library( - name = "DWARFLinkerParallel", - srcs = glob([ - "lib/DWARFLinker/Parallel/*.cpp", - "lib/DWARFLinker/Parallel/*.h", - ]), - hdrs = glob(["include/llvm/DWARFLinker/Parallel/*.h"]), - copts = llvm_copts, - deps = [ - ":BinaryFormat", - ":CodeGen", - ":DWARFLinkerBase", - ":DebugInfoDWARF", - ":MC", - ":Object", - ":Support", - ":Target", - ":TargetParser", - ], -) - -gentbl( - name = "DllOptionsTableGen", - strip_include_prefix = "lib/ToolDrivers/llvm-dlltool", - tbl_outs = [( - "-gen-opt-parser-defs", - "lib/ToolDrivers/llvm-dlltool/Options.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "lib/ToolDrivers/llvm-dlltool/Options.td", - td_srcs = ["include/llvm/Option/OptParser.td"], -) - -cc_library( - name = "DlltoolDriver", - srcs = glob(["lib/ToolDrivers/llvm-dlltool/*.cpp"]), - hdrs = glob(["include/llvm/ToolDrivers/llvm-dlltool/*.h"]), - copts = llvm_copts, - deps = [ - ":DllOptionsTableGen", - ":Object", - ":Option", - ":Support", - ":TargetParser", - ], -) - -gentbl( - name = "LibOptionsTableGen", - strip_include_prefix = "lib/ToolDrivers/llvm-lib", - tbl_outs = [( - "-gen-opt-parser-defs", - "lib/ToolDrivers/llvm-lib/Options.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "lib/ToolDrivers/llvm-lib/Options.td", - td_srcs = ["include/llvm/Option/OptParser.td"], -) - -cc_library( - name = "LibDriver", - srcs = glob(["lib/ToolDrivers/llvm-lib/*.cpp"]), - hdrs = glob(["include/llvm/ToolDrivers/llvm-lib/*.h"]), - copts = llvm_copts, - deps = [ - ":BinaryFormat", - ":BitReader", - ":LibOptionsTableGen", - ":Object", - ":Option", - ":Support", - ], -) - -cc_library( - name = "InterfaceStub", - srcs = glob([ - "lib/InterfaceStub/*.cpp", - "lib/InterfaceStub/*.h", - ]), - hdrs = glob([ - "include/llvm/InterfaceStub/*.h", - ]), - copts = llvm_copts, - deps = [ - ":BinaryFormat", - ":MC", - ":Object", - ":Support", - ":TargetParser", - ":config", - ], -) - -cc_library( - name = "WindowsDriver", - srcs = glob([ - "lib/WindowsDriver/*.cpp", - ]), - hdrs = glob([ - "include/llvm/WindowsDriver/*.h", - ]), - copts = llvm_copts, - deps = [ - ":Option", - ":Support", - ":TargetParser", - ], -) - -cc_library( - name = "WindowsManifest", - srcs = glob([ - "lib/WindowsManifest/*.cpp", - ]), - hdrs = glob([ - "include/llvm/WindowsManifest/*.h", - ]), - copts = llvm_copts, - deps = [ - ":Support", - ":config", - ], -) - -cc_library( - name = "MCA", - srcs = glob([ - "lib/MCA/**/*.cpp", - "lib/MCA/**/*.h", - ]), - hdrs = glob([ - "include/llvm/MCA/**/*.h", - ]), - copts = llvm_copts, - deps = [ - ":MC", - ":MCDisassembler", - ":Object", - ":Support", - ], -) - -cc_library( - name = "llvm-mca-headers", - hdrs = glob([ - "tools/llvm-mca/*.h", - "tools/llvm-mca/Views/*.h", - ]), - strip_include_prefix = "tools/llvm-mca", -) - -cc_library( - name = "XRay", - srcs = glob([ - "lib/XRay/*.cpp", - "lib/XRay/*.h", - ]), - hdrs = glob(["include/llvm/XRay/*.h"]), - copts = llvm_copts, - deps = [ - ":Object", - ":Support", - ":TargetParser", - ], -) - -# A flag to pick which `pfm` to use for Exegesis. -# Usage: `--@llvm-project//llvm:pfm=`. -# Flag documentation: https://bazel.build/extending/config -string_flag( - name = "pfm", - build_setting_default = "external", - values = [ - "disable", # Don't include pfm at all - "external", # Build pfm from source - "system", # Use system pfm (non hermetic) - ], -) - -config_setting( - name = "pfm_disable", - flag_values = {":pfm": "disable"}, -) - -config_setting( - name = "pfm_external", - flag_values = {":pfm": "external"}, -) - -config_setting( - name = "pfm_system", - flag_values = {":pfm": "system"}, -) - -cc_library( - name = "maybe_pfm", - # We want dependencies of this library to have -DHAVE_LIBPFM conditionally - # defined, so we set `defines` instead of `copts`. - defines = select({ - ":pfm_external": ["HAVE_LIBPFM=1"], - ":pfm_system": ["HAVE_LIBPFM=1"], - "//conditions:default": [], - }), - deps = select({ - ":pfm_external": ["@pfm//:pfm_external"], - ":pfm_system": ["@pfm//:pfm_system"], - "//conditions:default": [], - }), -) - -cc_library( - name = "Exegesis", - srcs = glob([ - "tools/llvm-exegesis/lib/*.cpp", - # We have to include these headers here as well as in the `hdrs` below - # to allow the `.cpp` files to use file-relative-inclusion to find - # them, even though consumers of this library use inclusion relative to - # `tools/llvm-exegesis/lib` with the `strip_includes_prefix` of this - # library. This mixture appears to be incompatible with header modules. - "tools/llvm-exegesis/lib/*.h", - ] + [ - "tools/llvm-exegesis/lib/{}/*.cpp".format(t) - for t in llvm_target_exegesis - ] + [ - "tools/llvm-exegesis/lib/{}/*.h".format(t) - for t in llvm_target_exegesis - ]), - hdrs = glob(["tools/llvm-exegesis/lib/*.h"]), - copts = llvm_copts, - features = [ - "-header_modules", - "-layering_check", - ], - strip_include_prefix = "tools/llvm-exegesis/lib", - deps = [ - ":AllTargetsAsmParsers", - ":AllTargetsCodeGens", - ":CodeGen", - ":CodeGenTypes", - ":Core", - ":ExecutionEngine", - ":MC", - ":MCA", - ":MCDisassembler", - ":Object", - ":ObjectYAML", - ":OrcJIT", - ":Support", - ":Target", - ":config", - ":maybe_pfm", - ], -) - -################################################################################ -# LLVM toolchain and development binaries - -gentbl( - name = "DsymutilTableGen", - strip_include_prefix = "tools/dsymutil", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/dsymutil/Options.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "tools/dsymutil/Options.td", - td_srcs = ["include/llvm/Option/OptParser.td"], -) - -expand_template( - name = "dsymutil_main", - out = "dsymutil-driver.cpp", - substitutions = { - "@TOOL_NAME@": "dsymutil", - }, - template = "cmake/modules/llvm-driver-template.cpp.in", -) - -cc_binary( - name = "dsymutil", - srcs = glob([ - "tools/dsymutil/*.cpp", - "tools/dsymutil/*.h", - ]) + ["dsymutil-driver.cpp"], - copts = llvm_copts, - stamp = 0, - deps = [ - ":AllTargetsCodeGens", - ":BinaryFormat", - ":CodeGen", - ":CodeGenTypes", - ":DWARFLinker", - ":DWARFLinkerParallel", - ":DebugInfo", - ":DebugInfoDWARF", - ":DsymutilTableGen", - ":MC", - ":Object", - ":Option", - ":Remarks", - ":Support", - ":Target", - ":TargetParser", - ":config", - ":remark_linker", - ], -) - -cc_binary( - name = "llc", - srcs = glob([ - "tools/llc/*.cpp", - "tools/llc/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":AllTargetsAsmParsers", - ":AllTargetsCodeGens", - ":Analysis", - ":AsmParser", - ":BitReader", - ":CodeGen", - ":CodeGenTypes", - ":Core", - ":IRPrinter", - ":IRReader", - ":MC", - ":Passes", - ":Remarks", - ":Scalar", - ":Support", - ":Target", - ":TargetParser", - ":TransformUtils", - ], -) - -cc_binary( - name = "lli", - srcs = glob([ - "tools/lli/*.cpp", - "tools/lli/*.h", - ]), - copts = llvm_copts, - # ll scripts rely on symbols from dependent - # libraries being resolvable. - linkopts = select({ - "@platforms//os:windows": [], - "@platforms//os:macos": [], - "//conditions:default": [ - "-Wl,--undefined=_ZTIi", - "-Wl,--export-dynamic-symbol=_ZTIi", - "-Wl,--export-dynamic-symbol=__cxa_begin_catch", - "-Wl,--export-dynamic-symbol=__cxa_end_catch", - "-Wl,--export-dynamic-symbol=__gxx_personality_v0", - "-Wl,--export-dynamic-symbol=__cxa_allocate_exception", - "-Wl,--export-dynamic-symbol=__cxa_throw", - "-Wl,--export-dynamic-symbol=llvm_orc_registerJITLoaderGDBWrapper", - "-Wl,--export-dynamic-symbol=llvm_orc_registerEHFrameSectionWrapper", - "-Wl,--export-dynamic-symbol=llvm_orc_deregisterEHFrameSectionWrapper", - ], - }), - stamp = 0, - deps = [ - ":AllTargetsAsmParsers", - ":AllTargetsCodeGens", - ":AsmParser", - ":BitReader", - ":CodeGen", - ":Core", - ":ExecutionEngine", - ":IRPrinter", - ":IRReader", - ":Instrumentation", - ":Interpreter", - ":MCJIT", - ":Object", - ":OrcDebugging", - ":OrcJIT", - ":OrcTargetProcess", - ":Support", - ":TargetParser", - ":config", - ], -) - -expand_template( - name = "ar_main", - out = "llvm-ar-driver.cpp", - substitutions = { - "@TOOL_NAME@": "llvm_ar", - }, - template = "cmake/modules/llvm-driver-template.cpp.in", -) - -cc_binary( - name = "llvm-ar", - srcs = glob([ - "tools/llvm-ar/*.cpp", - "tools/llvm-ar/*.h", - ]) + ["llvm-ar-driver.cpp"], - copts = llvm_copts, - stamp = 0, - deps = [ - ":AllTargetsAsmParsers", - ":AllTargetsCodeGens", - ":BinaryFormat", - ":Core", - ":DlltoolDriver", - ":LibDriver", - ":Object", - ":Support", - ":TargetParser", - ], -) - -# We need to run llvm-ar with different basenames to make it run with -# different behavior. -binary_alias( - name = "llvm-dlltool", - binary = ":llvm-ar", -) - -binary_alias( - name = "llvm-lib", - binary = ":llvm-ar", -) - -binary_alias( - name = "llvm-ranlib", - binary = ":llvm-ar", -) - -cc_binary( - name = "llvm-as", - srcs = glob([ - "tools/llvm-as/*.cpp", - "tools/llvm-as/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":Analysis", - ":AsmParser", - ":BitWriter", - ":Core", - ":Support", - ], -) - -cc_binary( - name = "llvm-bcanalyzer", - srcs = glob([ - "tools/llvm-bcanalyzer/*.cpp", - "tools/llvm-bcanalyzer/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":BitReader", - ":Support", - ], -) - -cc_binary( - name = "llvm-cat", - srcs = glob([ - "tools/llvm-cat/*.cpp", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":BitReader", - ":BitWriter", - ":Core", - ":IRPrinter", - ":IRReader", - ":Support", - ], -) - -cc_binary( - name = "llvm-cfi-verify", - srcs = glob([ - "tools/llvm-cfi-verify/*.cpp", - "tools/llvm-cfi-verify/lib/*.cpp", - "tools/llvm-cfi-verify/lib/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":AllTargetsAsmParsers", - ":AllTargetsCodeGens", - ":AllTargetsDisassemblers", - ":BinaryFormat", - ":DebugInfoDWARF", - ":MC", - ":MCDisassembler", - ":MCParser", - ":Object", - ":Support", - ":Symbolize", - ], -) - -cc_binary( - name = "llvm-cov", - srcs = glob([ - "tools/llvm-cov/*.cpp", - "tools/llvm-cov/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":Coverage", - ":Debuginfod", - ":Instrumentation", - ":Object", - ":ProfileData", - ":Support", - ":TargetParser", - ":config", - ], -) - -gentbl( - name = "CvtResTableGen", - strip_include_prefix = "tools/llvm-cvtres", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/llvm-cvtres/Opts.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "tools/llvm-cvtres/Opts.td", - td_srcs = ["include/llvm/Option/OptParser.td"], -) - -cc_binary( - name = "llvm-cvtres", - srcs = glob([ - "tools/llvm-cvtres/*.cpp", - "tools/llvm-cvtres/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":BinaryFormat", - ":CvtResTableGen", - ":Object", - ":Option", - ":Support", - ], -) - -cc_binary( - name = "llvm-cxxdump", - srcs = glob([ - "tools/llvm-cxxdump/*.cpp", - "tools/llvm-cxxdump/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":AllTargetsCodeGens", - ":BitReader", - ":MC", - ":Object", - ":Support", - ], -) - -cc_binary( - name = "llvm-cxxmap", - srcs = glob([ - "tools/llvm-cxxmap/*.cpp", - "tools/llvm-cxxmap/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":ProfileData", - ":Support", - ], -) - -gentbl( - name = "CxxfiltOptsTableGen", - strip_include_prefix = "tools/llvm-cxxfilt", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/llvm-cxxfilt/Opts.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "tools/llvm-cxxfilt/Opts.td", - td_srcs = ["include/llvm/Option/OptParser.td"], -) - -expand_template( - name = "cxxfilt_main", - out = "llvm-cxxfilt-driver.cpp", - substitutions = { - "@TOOL_NAME@": "llvm_cxxfilt", - }, - template = "cmake/modules/llvm-driver-template.cpp.in", -) - -cc_binary( - name = "llvm-cxxfilt", - srcs = glob([ - "tools/llvm-cxxfilt/*.cpp", - "tools/llvm-cxxfilt/*.h", - ]) + ["llvm-cxxfilt-driver.cpp"], - copts = llvm_copts, - stamp = 0, - deps = [ - ":CxxfiltOptsTableGen", - ":Demangle", - ":Option", - ":Support", - ":TargetParser", - ], -) - -cc_binary( - name = "llvm-debuginfo-analyzer", - srcs = glob([ - "tools/llvm-debuginfo-analyzer/*.cpp", - "tools/llvm-debuginfo-analyzer/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":AllTargetsCodeGens", - ":AllTargetsDisassemblers", - ":DebugInfoLogicalView", - ":Support", - ], -) - -cc_binary( - name = "llvm-debuginfod-find", - srcs = glob([ - "tools/llvm-debuginfod-find/*.cpp", - "tools/llvm-debuginfod-find/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":BitReader", - ":Core", - ":Debuginfod", - ":Support", - ":Symbolize", - ], -) - -cc_binary( - name = "llvm-dis", - srcs = glob([ - "tools/llvm-dis/*.cpp", - "tools/llvm-dis/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":Analysis", - ":BitReader", - ":Core", - ":Support", - ], -) - -cc_binary( - name = "llvm-dwarfdump", - srcs = glob([ - "tools/llvm-dwarfdump/*.cpp", - "tools/llvm-dwarfdump/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":AllTargetsCodeGens", - ":BinaryFormat", - ":DebugInfo", - ":DebugInfoDWARF", - ":MC", - ":Object", - ":Support", - ":TargetParser", - ], -) - -gentbl( - name = "DwarfutilOptionsTableGen", - strip_include_prefix = "tools/llvm-dwarfutil", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/llvm-dwarfutil/Options.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "tools/llvm-dwarfutil/Options.td", - td_srcs = ["include/llvm/Option/OptParser.td"], -) - -cc_binary( - name = "llvm-dwarfutil", - srcs = glob([ - "tools/llvm-dwarfutil/*.cpp", - "tools/llvm-dwarfutil/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":AllTargetsAsmParsers", - ":AllTargetsCodeGens", - ":CodeGenTypes", - ":DWARFLinker", - ":DWARFLinkerParallel", - ":DebugInfoDWARF", - ":DwarfutilOptionsTableGen", - ":MC", - ":ObjCopy", - ":Object", - ":Option", - ":Support", - ":Target", - ":TargetParser", - ], -) - -gentbl( - name = "DwpOptionsTableGen", - strip_include_prefix = "tools/llvm-dwp", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/llvm-dwp/Opts.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "tools/llvm-dwp/Opts.td", - td_srcs = ["include/llvm/Option/OptParser.td"], -) - -expand_template( - name = "dwp_main", - out = "llvm-dwp-driver.cpp", - substitutions = { - "@TOOL_NAME@": "llvm_dwp", - }, - template = "cmake/modules/llvm-driver-template.cpp.in", -) - -cc_binary( - name = "llvm-dwp", - srcs = glob([ - "tools/llvm-dwp/*.cpp", - "tools/llvm-dwp/*.h", - ]) + ["llvm-dwp-driver.cpp"], - copts = llvm_copts, - stamp = 0, - deps = [ - ":AllTargetsCodeGens", - ":DWP", - ":DwpOptionsTableGen", - ":MC", - ":Option", - ":Support", - ], -) - -cc_binary( - name = "llvm-exegesis", - srcs = [ - "tools/llvm-exegesis/llvm-exegesis.cpp", - ], - copts = llvm_copts, - stamp = 0, - deps = [ - ":AllTargetsAsmParsers", - ":AllTargetsCodeGens", - ":AllTargetsDisassemblers", - ":CodeGenTypes", - ":Exegesis", - ":MC", - ":MCParser", - ":Object", - ":Support", - ":TargetParser", - ":config", - ], -) - -cc_binary( - name = "llvm-extract", - srcs = glob([ - "tools/llvm-extract/*.cpp", - "tools/llvm-extract/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":AsmParser", - ":BitReader", - ":BitWriter", - ":Core", - ":IPO", - ":IRPrinter", - ":IRReader", - ":Passes", - ":Support", - ], -) - -gentbl( - name = "GSYMUtilOptionsTableGen", - strip_include_prefix = "tools/llvm-gsymutil", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/llvm-gsymutil/Opts.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "tools/llvm-gsymutil/Opts.td", - td_srcs = ["include/llvm/Option/OptParser.td"], -) - -expand_template( - name = "gsymutil_main", - out = "llvm-gsymutil-driver.cpp", - substitutions = { - "@TOOL_NAME@": "llvm_gsymutil", - }, - template = "cmake/modules/llvm-driver-template.cpp.in", -) - -cc_binary( - name = "llvm-gsymutil", - srcs = glob([ - "tools/llvm-gsymutil/*.cpp", - "tools/llvm-gsymutil/*.h", - ]) + ["llvm-gsymutil-driver.cpp"], - copts = llvm_copts, - stamp = 0, - deps = [ - ":AllTargetsCodeGens", - ":DebugInfo", - ":DebugInfoDWARF", - ":DebugInfoGSYM", - ":GSYMUtilOptionsTableGen", - ":MC", - ":Object", - ":Option", - ":Support", - ":Target", - ":TargetParser", - ], -) - -gentbl( - name = "IfsOptionsTableGen", - strip_include_prefix = "tools/llvm-ifs", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/llvm-ifs/Opts.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "tools/llvm-ifs/Opts.td", - td_srcs = ["include/llvm/Option/OptParser.td"], -) - -expand_template( - name = "ifs_main", - out = "llvm-ifs-driver.cpp", - substitutions = { - "@TOOL_NAME@": "llvm_ifs", - }, - template = "cmake/modules/llvm-driver-template.cpp.in", -) - -cc_binary( - name = "llvm-ifs", - srcs = glob([ - "tools/llvm-ifs/*.cpp", - "tools/llvm-ifs/*.h", - ]) + ["llvm-ifs-driver.cpp"], - copts = llvm_copts, - stamp = 0, - deps = [ - ":BinaryFormat", - ":IfsOptionsTableGen", - ":InterfaceStub", - ":ObjectYAML", - ":Option", - ":Support", - ":TargetParser", - ":TextAPI", - ], -) - -cc_binary( - name = "llvm-jitlink", - srcs = glob([ - "tools/llvm-jitlink/*.cpp", - "tools/llvm-jitlink/*.h", - ]), - copts = llvm_copts, - # Make symbols from the standard library dynamically resolvable. - linkopts = select({ - "@platforms//os:windows": [], - "@platforms//os:macos": [], - "//conditions:default": [ - "-Wl,--undefined=_ZTIi", - "-Wl,--export-dynamic-symbol=_ZTIi", - "-Wl,--export-dynamic-symbol=__cxa_begin_catch", - "-Wl,--export-dynamic-symbol=__cxa_end_catch", - "-Wl,--export-dynamic-symbol=__gxx_personality_v0", - "-Wl,--export-dynamic-symbol=__cxa_allocate_exception", - "-Wl,--export-dynamic-symbol=__cxa_throw", - "-Wl,--export-dynamic-symbol=llvm_orc_registerJITLoaderGDBWrapper", - ], - }), - stamp = 0, - deps = [ - ":AllTargetsAsmParsers", - ":AllTargetsCodeGens", - ":AllTargetsDisassemblers", - ":AsmParser", - ":BinaryFormat", - ":BitReader", - ":CodeGen", - ":ExecutionEngine", - ":MC", - ":MCDisassembler", - ":MCJIT", - ":Object", - ":OrcDebugging", - ":OrcJIT", - ":OrcShared", - ":OrcTargetProcess", - ":Support", - ":TargetParser", - ":config", - ], -) - -gentbl( - name = "LibtoolDarwinOptionsTableGen", - strip_include_prefix = "tools/llvm-libtool-darwin", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/llvm-libtool-darwin/Opts.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "tools/llvm-libtool-darwin/Opts.td", - td_srcs = ["include/llvm/Option/OptParser.td"], -) - -expand_template( - name = "libtool-darwin_main", - out = "llvm-libtool-darwin-driver.cpp", - substitutions = { - "@TOOL_NAME@": "llvm_libtool_darwin", - }, - template = "cmake/modules/llvm-driver-template.cpp.in", -) - -cc_binary( - name = "llvm-libtool-darwin", - srcs = glob([ - "tools/llvm-libtool-darwin/*.cpp", - "tools/llvm-libtool-darwin/*.h", - ]) + ["llvm-libtool-darwin-driver.cpp"], - copts = llvm_copts, - stamp = 0, - deps = [ - ":AllTargetsAsmParsers", - ":AllTargetsCodeGens", - ":BinaryFormat", - ":Core", - ":LibtoolDarwinOptionsTableGen", - ":Object", - ":Option", - ":Support", - ":TextAPI", - ], -) - -cc_binary( - name = "llvm-link", - srcs = glob([ - "tools/llvm-link/*.cpp", - "tools/llvm-link/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":AsmParser", - ":BinaryFormat", - ":BitReader", - ":BitWriter", - ":Core", - ":IPO", - ":IRPrinter", - ":IRReader", - ":Linker", - ":Object", - ":Support", - ":TransformUtils", - ], -) - -gentbl( - name = "LipoOptsTableGen", - strip_include_prefix = "tools/llvm-lipo", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/llvm-lipo/LipoOpts.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "tools/llvm-lipo/LipoOpts.td", - td_srcs = ["include/llvm/Option/OptParser.td"], -) - -expand_template( - name = "lipo_main", - out = "llvm-lipo-driver.cpp", - substitutions = { - "@TOOL_NAME@": "llvm_lipo", - }, - template = "cmake/modules/llvm-driver-template.cpp.in", -) - -cc_binary( - name = "llvm-lipo", - srcs = [ - "tools/llvm-lipo/llvm-lipo.cpp", - ] + ["llvm-lipo-driver.cpp"], - copts = llvm_copts, - stamp = 0, - deps = [ - ":AllTargetsAsmParsers", - ":BinaryFormat", - ":Core", - ":LipoOptsTableGen", - ":Object", - ":Option", - ":Support", - ":TargetParser", - ":TextAPI", - ], -) - -cc_binary( - name = "llvm-lto", - srcs = glob([ - "tools/llvm-lto/*.cpp", - "tools/llvm-lto/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":AllTargetsAsmParsers", - ":AllTargetsCodeGens", - ":BitReader", - ":BitWriter", - ":CodeGen", - ":Core", - ":IRPrinter", - ":IRReader", - ":LTO", - ":Support", - ":Target", - ], -) - -cc_binary( - name = "llvm-lto2", - srcs = glob([ - "tools/llvm-lto2/*.cpp", - "tools/llvm-lto2/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":AllTargetsAsmParsers", - ":AllTargetsCodeGens", - ":BitReader", - ":CodeGen", - ":Core", - ":LTO", - ":Passes", - ":Remarks", - ":Support", - ], -) - -cc_binary( - name = "llvm-mc", - srcs = glob([ - "tools/llvm-mc/*.cpp", - "tools/llvm-mc/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":AllTargetsAsmParsers", - ":AllTargetsCodeGens", - ":AllTargetsDisassemblers", - ":MC", - ":MCDisassembler", - ":MCParser", - ":Object", - ":Support", - ":TargetParser", - ], -) - -cc_binary( - name = "llvm-mca", - srcs = glob([ - "tools/llvm-mca/*.cpp", - "tools/llvm-mca/*.h", - "tools/llvm-mca/Views/*.cpp", - "tools/llvm-mca/Views/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":AllTargetsAsmParsers", - ":AllTargetsCodeGens", - ":AllTargetsDisassemblers", - ":AllTargetsMCAs", - ":MC", - ":MCA", - ":MCParser", - ":Support", - ":TargetParser", - ":llvm-mca-headers", - ], -) - -gentbl( - name = "MlTableGen", - strip_include_prefix = "tools/llvm-ml", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/llvm-ml/Opts.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "tools/llvm-ml/Opts.td", - td_srcs = ["include/llvm/Option/OptParser.td"], -) - -expand_template( - name = "ml_main", - out = "llvm-ml-driver.cpp", - substitutions = { - "@TOOL_NAME@": "llvm_ml", - }, - template = "cmake/modules/llvm-driver-template.cpp.in", -) - -cc_binary( - name = "llvm-ml", - srcs = glob([ - "tools/llvm-ml/*.cpp", - "tools/llvm-ml/*.h", - ]) + ["llvm-ml-driver.cpp"], - copts = llvm_copts, - stamp = 0, - deps = [ - ":AllTargetsAsmParsers", - ":AllTargetsCodeGens", - ":AllTargetsDisassemblers", - ":MC", - ":MCDisassembler", - ":MCParser", - ":MlTableGen", - ":Option", - ":Support", - ":TargetParser", - ], -) - -cc_binary( - name = "llvm-modextract", - srcs = glob([ - "tools/llvm-modextract/*.cpp", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":BitReader", - ":BitWriter", - ":IRPrinter", - ":IRReader", - ":Support", - ], -) - -gentbl( - name = "MtTableGen", - strip_include_prefix = "tools/llvm-mt", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/llvm-mt/Opts.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "tools/llvm-mt/Opts.td", - td_srcs = ["include/llvm/Option/OptParser.td"], -) - -expand_template( - name = "mt_main", - out = "llvm-mt-driver.cpp", - substitutions = { - "@TOOL_NAME@": "llvm_mt", - }, - template = "cmake/modules/llvm-driver-template.cpp.in", -) - -cc_binary( - name = "llvm-mt", - srcs = glob([ - "tools/llvm-mt/*.cpp", - "tools/llvm-mt/*.h", - ]) + ["llvm-mt-driver.cpp"], - copts = llvm_copts, - stamp = 0, - deps = [ - ":MtTableGen", - ":Option", - ":Support", - ":WindowsManifest", - ], -) - -gentbl( - name = "NmOptsTableGen", - strip_include_prefix = "tools/llvm-nm", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/llvm-nm/Opts.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "tools/llvm-nm/Opts.td", - td_srcs = ["include/llvm/Option/OptParser.td"], -) - -expand_template( - name = "nm_main", - out = "llvm-nm-driver.cpp", - substitutions = { - "@TOOL_NAME@": "llvm_nm", - }, - template = "cmake/modules/llvm-driver-template.cpp.in", -) - -cc_binary( - name = "llvm-nm", - srcs = glob([ - "tools/llvm-nm/*.cpp", - "tools/llvm-nm/*.h", - ]) + ["llvm-nm-driver.cpp"], - copts = llvm_copts, - stamp = 0, - deps = [ - ":AllTargetsAsmParsers", - ":AllTargetsCodeGens", - ":BinaryFormat", - ":BitReader", - ":Core", - ":Demangle", - ":NmOptsTableGen", - ":Object", - ":Option", - ":Support", - ":Symbolize", - ":TargetParser", - ], -) - -gentbl( - name = "llvm-objcopy-opts", - strip_include_prefix = "tools/llvm-objcopy", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/llvm-objcopy/ObjcopyOpts.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "tools/llvm-objcopy/ObjcopyOpts.td", - td_srcs = [ - "include/llvm/Option/OptParser.td", - "tools/llvm-objcopy/CommonOpts.td", - ], -) - -gentbl( - name = "llvm-installnametool-opts", - strip_include_prefix = "tools/llvm-objcopy", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/llvm-objcopy/InstallNameToolOpts.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "tools/llvm-objcopy/InstallNameToolOpts.td", - td_srcs = [ - "include/llvm/Option/OptParser.td", - "tools/llvm-objcopy/CommonOpts.td", - ], -) - -gentbl( - name = "llvm-strip-opts", - strip_include_prefix = "tools/llvm-objcopy", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/llvm-objcopy/StripOpts.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "tools/llvm-objcopy/StripOpts.td", - td_srcs = [ - "include/llvm/Option/OptParser.td", - "tools/llvm-objcopy/CommonOpts.td", - ], -) - -gentbl( - name = "llvm-bitcode-strip-opts", - strip_include_prefix = "tools/llvm-objcopy", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/llvm-objcopy/BitcodeStripOpts.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "tools/llvm-objcopy/BitcodeStripOpts.td", - td_srcs = [ - "include/llvm/Option/OptParser.td", - "tools/llvm-objcopy/CommonOpts.td", - ], -) - -cc_binary( - name = "llvm-stress", - srcs = glob([ - "tools/llvm-stress/*.cpp", - "tools/llvm-stress/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":Core", - ":Support", - ], -) - -expand_template( - name = "objcopy_main", - out = "llvm-objcopy-driver.cpp", - substitutions = { - "@TOOL_NAME@": "llvm_objcopy", - }, - template = "cmake/modules/llvm-driver-template.cpp.in", -) - -cc_binary( - name = "llvm-objcopy", - srcs = glob([ - "tools/llvm-objcopy/*.cpp", - "tools/llvm-objcopy/*.h", - ]) + ["llvm-objcopy-driver.cpp"], - copts = llvm_copts, - stamp = 0, - deps = [ - ":BinaryFormat", - ":MC", - ":ObjCopy", - ":Object", - ":ObjectYAML", - ":Option", - ":Support", - ":Target", - ":TargetParser", - ":llvm-bitcode-strip-opts", - ":llvm-installnametool-opts", - ":llvm-objcopy-opts", - ":llvm-strip-opts", - ], -) - -binary_alias( - name = "llvm-strip", - binary = ":llvm-objcopy", -) - -binary_alias( - name = "llvm-bitcode-strip", - binary = ":llvm-objcopy", -) - -binary_alias( - name = "llvm-install-name-tool", - binary = ":llvm-objcopy", -) - -expand_template( - name = "objdump_main", - out = "llvm-objdump-driver.cpp", - substitutions = { - "@TOOL_NAME@": "llvm_objdump", - }, - template = "cmake/modules/llvm-driver-template.cpp.in", -) - -cc_binary( - name = "llvm-objdump", - srcs = glob([ - "tools/llvm-objdump/*.cpp", - "tools/llvm-objdump/*.h", - ]) + ["llvm-objdump-driver.cpp"], - copts = llvm_copts, - stamp = 0, - deps = [ - ":AllTargetsAsmParsers", - ":AllTargetsCodeGens", - ":AllTargetsDisassemblers", - ":BinaryFormat", - ":CodeGen", - ":DebugInfo", - ":DebugInfoDWARF", - ":Debuginfod", - ":Demangle", - ":MC", - ":MCDisassembler", - ":ObjdumpOptsTableGen", - ":Object", - ":Option", - ":OtoolOptsTableGen", - ":Support", - ":Symbolize", - ":TargetParser", - ":config", - ], -) - -gentbl( - name = "ObjdumpOptsTableGen", - strip_include_prefix = "tools/llvm-objdump", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/llvm-objdump/ObjdumpOpts.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "tools/llvm-objdump/ObjdumpOpts.td", - td_srcs = ["include/llvm/Option/OptParser.td"], -) - -binary_alias( - name = "llvm-otool", - binary = ":llvm-objdump", -) - -gentbl( - name = "OtoolOptsTableGen", - strip_include_prefix = "tools/llvm-objdump", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/llvm-objdump/OtoolOpts.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "tools/llvm-objdump/OtoolOpts.td", - td_srcs = ["include/llvm/Option/OptParser.td"], -) - -cc_binary( - name = "llvm-opt-report", - srcs = glob([ - "tools/llvm-opt-report/*.cpp", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":AllTargetsCodeGens", - ":Demangle", - ":Remarks", - ":Support", - ], -) - -cc_binary( - name = "llvm-pdbutil", - srcs = glob([ - "tools/llvm-pdbutil/*.cpp", - "tools/llvm-pdbutil/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":BinaryFormat", - ":DebugInfoBTF", - ":DebugInfoCodeView", - ":DebugInfoMSF", - ":DebugInfoPDB", - ":Object", - ":ObjectYAML", - ":Support", - ":config", - ], -) - -expand_template( - name = "profdata_main", - out = "llvm-profdata-driver.cpp", - substitutions = { - "@TOOL_NAME@": "llvm_profdata", - }, - template = "cmake/modules/llvm-driver-template.cpp.in", -) - -cc_binary( - name = "llvm-profdata", - srcs = glob([ - "tools/llvm-profdata/*.cpp", - "tools/llvm-profdata/*.h", - ]) + ["llvm-profdata-driver.cpp"], - copts = llvm_copts, - stamp = 0, - deps = [ - ":Core", - ":Object", - ":ProfileData", - ":Support", - ], -) - -cc_binary( - name = "llvm-profgen", - srcs = glob([ - "tools/llvm-profgen/*.cpp", - "tools/llvm-profgen/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":AllTargetsCodeGens", - ":AllTargetsDisassemblers", - ":Core", - ":DebugInfoDWARF", - ":Demangle", - ":IPO", - ":MC", - ":MCDisassembler", - ":Object", - ":ProfileData", - ":Support", - ":Symbolize", - ":TargetParser", - ], -) - -gentbl( - name = "RcTableGen", - strip_include_prefix = "tools/llvm-rc", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/llvm-rc/Opts.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "tools/llvm-rc/Opts.td", - td_srcs = ["include/llvm/Option/OptParser.td"], -) - -gentbl( - name = "WindresTableGen", - strip_include_prefix = "tools/llvm-rc", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/llvm-rc/WindresOpts.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "tools/llvm-rc/WindresOpts.td", - td_srcs = ["include/llvm/Option/OptParser.td"], -) - -# Workaround inability to put `.def` files into `srcs` with a library. -cc_library( - name = "llvm-rc-defs-lib", - textual_hdrs = glob(["tools/llvm-rc/*.def"]), -) - -expand_template( - name = "rc_main", - out = "llvm-rc-driver.cpp", - substitutions = { - "@TOOL_NAME@": "llvm_rc", - }, - template = "cmake/modules/llvm-driver-template.cpp.in", -) - -cc_binary( - name = "llvm-rc", - srcs = glob([ - "tools/llvm-rc/*.cpp", - "tools/llvm-rc/*.h", - ]) + ["llvm-rc-driver.cpp"], - copts = llvm_copts, - stamp = 0, - deps = [ - ":Object", - ":Option", - ":RcTableGen", - ":Support", - ":TargetParser", - ":WindresTableGen", - ":config", - ":llvm-rc-defs-lib", - ], -) - -binary_alias( - name = "llvm-windres", - binary = ":llvm-rc", -) - -gentbl( - name = "ReadobjOptsTableGen", - strip_include_prefix = "tools/llvm-readobj", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/llvm-readobj/Opts.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "tools/llvm-readobj/Opts.td", - td_srcs = ["include/llvm/Option/OptParser.td"], -) - -expand_template( - name = "readobj_main", - out = "llvm-readobj-driver.cpp", - substitutions = { - "@TOOL_NAME@": "llvm_readobj", - }, - template = "cmake/modules/llvm-driver-template.cpp.in", -) - -cc_binary( - name = "llvm-readobj", - srcs = glob([ - "tools/llvm-readobj/*.cpp", - "tools/llvm-readobj/*.h", - ]) + ["llvm-readobj-driver.cpp"], - copts = llvm_copts, - stamp = 0, - deps = [ - ":AllTargetsCodeGens", - ":BinaryFormat", - ":BitReader", - ":DebugInfoCodeView", - ":DebugInfoDWARF", - ":Demangle", - ":MC", - ":Object", - ":Option", - ":ReadobjOptsTableGen", - ":Support", - ], -) - -# Create an 'llvm-readelf' named binary from the 'llvm-readobj' tool. -binary_alias( - name = "llvm-readelf", - binary = ":llvm-readobj", -) - -cc_binary( - name = "llvm-reduce", - srcs = glob([ - "tools/llvm-reduce/**/*.cpp", - "tools/llvm-reduce/**/*.h", - ]), - copts = llvm_copts, - includes = ["tools/llvm-reduce"], - stamp = 0, - deps = [ - ":AllTargetsAsmParsers", - ":AllTargetsCodeGens", - ":Analysis", - ":BitReader", - ":BitWriter", - ":CodeGen", - ":CodeGenTypes", - ":Core", - ":IPO", - ":IRReader", - ":MC", - ":Passes", - ":Support", - ":Target", - ":TargetParser", - ":TransformUtils", - ], -) - -cc_binary( - name = "llvm-rtdyld", - srcs = glob([ - "tools/llvm-rtdyld/*.cpp", - "tools/llvm-rtdyld/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":AllTargetsCodeGens", - ":AllTargetsDisassemblers", - ":DebugInfo", - ":DebugInfoDWARF", - ":ExecutionEngine", - ":MC", - ":MCDisassembler", - ":Object", - ":Support", - ], -) - -gentbl( - name = "SizeOptsTableGen", - strip_include_prefix = "tools/llvm-size", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/llvm-size/Opts.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "tools/llvm-size/Opts.td", - td_srcs = ["include/llvm/Option/OptParser.td"], -) - -expand_template( - name = "size_main", - out = "llvm-size-driver.cpp", - substitutions = { - "@TOOL_NAME@": "llvm_size", - }, - template = "cmake/modules/llvm-driver-template.cpp.in", -) - -cc_binary( - name = "llvm-size", - srcs = glob([ - "tools/llvm-size/*.cpp", - "tools/llvm-size/*.h", - ]) + ["llvm-size-driver.cpp"], - copts = llvm_copts, - stamp = 0, - deps = [ - ":Object", - ":Option", - ":SizeOptsTableGen", - ":Support", - ], -) - -cc_binary( - name = "llvm-split", - srcs = glob([ - "tools/llvm-split/*.cpp", - "tools/llvm-split/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":BitWriter", - ":Core", - ":IRPrinter", - ":IRReader", - ":Support", - ":TransformUtils", - ], -) - -gentbl( - name = "StringsOptsTableGen", - strip_include_prefix = "tools/llvm-strings", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/llvm-strings/Opts.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "tools/llvm-strings/Opts.td", - td_srcs = ["include/llvm/Option/OptParser.td"], -) - -cc_binary( - name = "llvm-strings", - srcs = glob([ - "tools/llvm-strings/*.cpp", - "tools/llvm-strings/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":Object", - ":Option", - ":StringsOptsTableGen", - ":Support", - ], -) - -gentbl( - name = "SymbolizerOptsTableGen", - strip_include_prefix = "tools/llvm-symbolizer", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/llvm-symbolizer/Opts.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "tools/llvm-symbolizer/Opts.td", - td_srcs = ["include/llvm/Option/OptParser.td"], -) - -expand_template( - name = "symbolizer_main", - out = "llvm-symbolizer-driver.cpp", - substitutions = { - "@TOOL_NAME@": "llvm_symbolizer", - }, - template = "cmake/modules/llvm-driver-template.cpp.in", -) - -cc_binary( - name = "llvm-symbolizer", - srcs = glob([ - "tools/llvm-symbolizer/*.cpp", - "tools/llvm-symbolizer/*.h", - ]) + ["llvm-symbolizer-driver.cpp"], - copts = llvm_copts, - stamp = 0, - deps = [ - ":DebugInfoDWARF", - ":DebugInfoPDB", - ":Debuginfod", - ":Object", - ":Option", - ":Support", - ":Symbolize", - ":SymbolizerOptsTableGen", - ":config", - ], -) - -binary_alias( - name = "llvm-addr2line", - binary = ":llvm-symbolizer", -) - -cc_binary( - name = "llvm-undname", - srcs = glob([ - "tools/llvm-undname/*.cpp", - "tools/llvm-undname/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":Demangle", - ":Support", - ], -) - -cc_binary( - name = "llvm-xray", - srcs = glob([ - "tools/llvm-xray/*.cpp", - "tools/llvm-xray/*.cc", - "tools/llvm-xray/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":DebugInfoDWARF", - ":Object", - ":Support", - ":Symbolize", - ":XRay", - ], -) - -cc_library( - name = "opt-driver", - srcs = glob([ - "tools/opt/*.cpp", - "tools/opt/*.h", - ]), - copts = llvm_copts, - linkopts = select({ - "@platforms//os:windows": [], - "@platforms//os:macos": [], - "//conditions:default": ["-Wl,--export-dynamic"], - }), - deps = [ - ":AllTargetsAsmParsers", - ":AllTargetsCodeGens", - ":Analysis", - ":AsmParser", - ":BitReader", - ":BitWriter", - ":CodeGen", - ":Core", - ":IPO", - ":IRPrinter", - ":IRReader", - ":Instrumentation", - ":MC", - ":Passes", - ":Remarks", - ":Scalar", - ":Support", - ":Target", - ":TargetParser", - ":TransformUtils", - ":common_transforms", - ":config", - ], -) - -cc_binary( - name = "opt", - stamp = 0, - deps = [":opt-driver"], -) - -gentbl( - name = "SancovOptsTableGen", - strip_include_prefix = "tools/sancov", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/sancov/Opts.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "tools/sancov/Opts.td", - td_srcs = ["include/llvm/Option/OptParser.td"], -) - -expand_template( - name = "sancov_main", - out = "sancov-driver.cpp", - substitutions = { - "@TOOL_NAME@": "sancov", - }, - template = "cmake/modules/llvm-driver-template.cpp.in", -) - -cc_binary( - name = "sancov", - srcs = glob([ - "tools/sancov/*.cpp", - "tools/sancov/*.h", - ]) + ["sancov-driver.cpp"], - copts = llvm_copts, - stamp = 0, - deps = [ - ":AllTargetsCodeGens", - ":AllTargetsDisassemblers", - ":DebugInfoDWARF", - ":DebugInfoPDB", - ":MC", - ":MCDisassembler", - ":Object", - ":Option", - ":SancovOptsTableGen", - ":Support", - ":Symbolize", - ], -) - -cc_binary( - name = "sanstats", - srcs = glob([ - "tools/sanstats/*.cpp", - "tools/sanstats/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":Support", - ":Symbolize", - ":TransformUtils", - ], -) - -cc_binary( - name = "split-file", - srcs = glob([ - "utils/split-file/*.cpp", - "utils/split-file/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":Support", - ], -) - -################################################################################ -# Begin testonly libraries - -cc_library( - name = "FuzzMutate", - testonly = True, - srcs = glob(["lib/FuzzMutate/*.cpp"]), - hdrs = glob(["include/llvm/FuzzMutate/*.h"]), - copts = llvm_copts, - includes = ["include"], - deps = [ - ":Analysis", - ":BitReader", - ":BitWriter", - ":Core", - ":Scalar", - ":Support", - ":TargetParser", - ":TransformUtils", - ], -) - -cc_library( - name = "Diff", - testonly = True, - srcs = glob(["tools/llvm-diff/lib/*.cpp"]), - hdrs = glob(["tools/llvm-diff/lib/*.h"]), - deps = [ - ":Core", - ":Support", - ], -) - -py_binary( - name = "lit", - testonly = True, - srcs = ["utils/lit/lit.py"] + glob(["utils/lit/lit/**/*.py"]), -) - -py_binary( - name = "extract_ir", - srcs = [ - "utils/mlgo-utils/mlgo/__init__.py", - "utils/mlgo-utils/mlgo/corpus/extract_ir.py", - "utils/mlgo-utils/mlgo/corpus/extract_ir_lib.py", - ], - imports = ["utils/mlgo-utils"], -) - -py_binary( - name = "combine_training_corpus", - srcs = [ - "utils/mlgo-utils/mlgo/__init__.py", - "utils/mlgo-utils/mlgo/corpus/combine_training_corpus.py", - "utils/mlgo-utils/mlgo/corpus/combine_training_corpus_lib.py", - ], - imports = ["utils/mlgo-utils"], -) - -py_binary( - name = "make_corpus", - srcs = [ - "utils/mlgo-utils/mlgo/__init__.py", - "utils/mlgo-utils/mlgo/corpus/make_corpus.py", - "utils/mlgo-utils/mlgo/corpus/make_corpus_lib.py", - ], - imports = ["utils/mlgo-utils"], -) - -cc_library( - name = "TestingADT", - testonly = True, - hdrs = glob([ - "include/llvm/Testing/ADT/*.h", - ]), - copts = llvm_copts, - deps = [ - ":Support", - "//third-party/unittest:gmock", - ], -) - -cc_library( - name = "TestingSupport", - testonly = True, - srcs = glob([ - "lib/Testing/Support/*.cpp", - "lib/Testing/Support/*.h", - ]), - hdrs = glob(["include/llvm/Testing/Support/*.h"]), - copts = llvm_copts, - deps = [ - ":Support", - ":config", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest", - ], -) - -cc_library( - name = "TestingAnnotations", - testonly = True, - srcs = ["lib/Testing/Annotations/Annotations.cpp"], - hdrs = ["include/llvm/Testing/Annotations/Annotations.h"], - copts = llvm_copts, - deps = [":Support"], -) - -################################################################################ -# Begin testonly binary utilities - -cc_binary( - name = "FileCheck", - testonly = True, - srcs = glob([ - "utils/FileCheck/*.cpp", - "utils/FileCheck/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":FileCheckLib", - ":Support", - ], -) - -cc_binary( - name = "bugpoint", - srcs = glob([ - "tools/bugpoint/*.cpp", - "tools/bugpoint/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":AllTargetsAsmParsers", - ":AllTargetsCodeGens", - ":Analysis", - ":AsmParser", - ":BitReader", - ":BitWriter", - ":CodeGen", - ":Core", - ":IPO", - ":IRPrinter", - ":IRReader", - ":Linker", - ":Passes", - ":Scalar", - ":Support", - ":TargetParser", - ":TransformUtils", - ":common_transforms", - ":config", - ], -) - -cc_binary( - name = "count", - testonly = True, - srcs = glob([ - "utils/count/*.c", - "utils/count/*.h", - ]), - stamp = 0, - deps = [":Support"], -) - -cc_binary( - name = "lli-child-target", - testonly = True, - srcs = glob([ - "tools/lli/ChildTarget/*.cpp", - "tools/lli/ChildTarget/*.h", - ]), - copts = llvm_copts, - # The tests load code into this binary that expect to see symbols - # from libstdc++ such as __cxa_begin_catch and _ZTIi. The latter - # isn't even used in the main binary, so we also need to force it - # to be included. - linkopts = select({ - "@platforms//os:windows": [], - "@platforms//os:macos": [], - "//conditions:default": [ - "-rdynamic", - "-u_ZTIi", - ], - }), - stamp = 0, - deps = [ - ":OrcJIT", - ":OrcTargetProcess", - ":Support", - ":attributes_gen", - ":config", - ":intrinsic_enums_gen", - ], -) - -cc_binary( - name = "llvm-c-test", - testonly = True, - srcs = glob([ - "tools/llvm-c-test/*.c", - "tools/llvm-c-test/*.cpp", - "tools/llvm-c-test/*.h", - ]), - stamp = 0, - deps = [ - ":AllTargetsAsmParsers", - ":AllTargetsCodeGens", - ":AllTargetsDisassemblers", - ":Analysis", - ":BitReader", - ":BitWriter", - ":Core", - ":ExecutionEngine", - ":IPO", - ":IRReader", - ":InstCombine", - ":LTO", - ":Linker", - ":MCDisassembler", - ":Object", - ":OrcJIT", - ":Passes", - ":Remarks", - ":Scalar", - ":Support", - ":Target", - ":TransformUtils", - ":Vectorize", - ], -) - -cc_binary( - name = "llvm-diff", - testonly = True, - srcs = glob([ - "tools/llvm-diff/*.cpp", - "tools/llvm-diff/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":Core", - ":Diff", - ":IRPrinter", - ":IRReader", - ":Support", - ], -) - -cc_binary( - name = "llvm-isel-fuzzer", - testonly = True, - srcs = glob([ - "tools/llvm-isel-fuzzer/*.cpp", - "tools/llvm-isel-fuzzer/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":AllTargetsAsmParsers", - ":AllTargetsCodeGens", - ":Analysis", - ":BitReader", - ":BitWriter", - ":CodeGen", - ":Core", - ":FuzzMutate", - ":IRPrinter", - ":IRReader", - ":MC", - ":Support", - ":Target", - ], -) - -# This is really a Python script, but call it sh_binary to ignore the hyphen in -# the path, which py_binary does not allow. -# Also, note: llvm-locstats expects llvm-dwarfdump to be in the same directory -# when executed. -sh_binary( - name = "llvm-locstats", - testonly = True, - srcs = glob([ - "utils/llvm-locstats/*.py", - ]), - # llvm-locstats is a thin wrapper around llvm-dwarfdump. - data = [":llvm-dwarfdump"], -) - -sh_binary( - name = "llvm-original-di-preservation", - testonly = True, - srcs = ["utils/llvm-original-di-preservation.py"], -) - -cc_binary( - name = "not", - testonly = True, - srcs = glob([ - "utils/not/*.cpp", - "utils/not/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [":Support"], -) - -cc_binary( - name = "llvm-opt-fuzzer", - testonly = True, - srcs = glob([ - "tools/llvm-opt-fuzzer/*.cpp", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":AllTargetsCodeGens", - ":Analysis", - ":BitReader", - ":BitWriter", - ":CodeGen", - ":Core", - ":Coroutines", - ":FuzzMutate", - ":MC", - ":Passes", - ":Support", - ":Target", - ], -) - -gentbl( - name = "ReadTAPIOptsTableGen", - strip_include_prefix = "tools/llvm-readtapi", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/llvm-readtapi/TapiOpts.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "tools/llvm-readtapi/TapiOpts.td", - td_srcs = ["include/llvm/Option/OptParser.td"], -) - -cc_binary( - name = "llvm-readtapi", - testonly = True, - srcs = glob([ - "tools/llvm-readtapi/*.cpp", - "tools/llvm-readtapi/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":BinaryFormat", - ":Object", - ":Option", - ":ReadTAPIOptsTableGen", - ":Support", - ":TextAPI", - ":TextAPIBinaryReader", - ], -) - -gentbl( - name = "TLICheckerOptsTableGen", - strip_include_prefix = "tools/llvm-tli-checker", - tbl_outs = [( - "-gen-opt-parser-defs", - "tools/llvm-tli-checker/Opts.inc", - )], - tblgen = ":llvm-tblgen", - td_file = "tools/llvm-tli-checker/Opts.td", - td_srcs = ["include/llvm/Option/OptParser.td"], -) - -cc_binary( - name = "llvm-tli-checker", - testonly = True, - srcs = glob([ - "tools/llvm-tli-checker/*.cpp", - "tools/llvm-tli-checker/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":Analysis", - ":BinaryFormat", - ":BitReader", - ":BitstreamReader", - ":Core", - ":Demangle", - ":MC", - ":MCParser", - ":Object", - ":Option", - ":Remarks", - ":Support", - ":TLICheckerOptsTableGen", - ":TargetParser", - ":TextAPI", - ":config", - ], -) - -cc_binary( - name = "obj2yaml", - testonly = True, - srcs = glob([ - "tools/obj2yaml/*.cpp", - "tools/obj2yaml/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":BinaryFormat", - ":DebugInfoCodeView", - ":DebugInfoDWARF", - ":Object", - ":ObjectYAML", - ":Support", - ], -) - -cc_binary( - name = "verify-uselistorder", - srcs = glob([ - "tools/verify-uselistorder/*.cpp", - "tools/verify-uselistorder/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":AsmParser", - ":BitReader", - ":BitWriter", - ":Core", - ":IRPrinter", - ":IRReader", - ":Support", - ], -) - -cc_binary( - name = "yaml2obj", - testonly = True, - srcs = glob([ - "tools/yaml2obj/*.cpp", - "tools/yaml2obj/*.h", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":BinaryFormat", - ":DebugInfoCodeView", - ":MC", - ":Object", - ":ObjectYAML", - ":Support", - ], -) - -cc_binary( - name = "yaml-bench", - testonly = True, - srcs = glob([ - "utils/yaml-bench/*.cpp", - ]), - copts = llvm_copts, - stamp = 0, - deps = [ - ":Support", - ], -) diff --git a/utils/bazel/llvm-project-overlay/llvm/binary_alias.bzl b/utils/bazel/llvm-project-overlay/llvm/binary_alias.bzl deleted file mode 100644 index 0108742f345eda..00000000000000 --- a/utils/bazel/llvm-project-overlay/llvm/binary_alias.bzl +++ /dev/null @@ -1,35 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -"""Creates a copy of a binary, giving it a different basename. - -binary_alias( - name = "my_binary_other_name", - binary = ":some_cc_binary", -) -""" - -def _binary_alias_impl(ctx): - ctx.actions.symlink( - target_file = ctx.executable.binary, - output = ctx.outputs.executable, - is_executable = True, - ) - - return [DefaultInfo( - executable = ctx.outputs.executable, - runfiles = ctx.attr.binary[DefaultInfo].default_runfiles, - )] - -binary_alias = rule( - _binary_alias_impl, - attrs = { - "binary": attr.label( - mandatory = True, - executable = True, - cfg = "target", - ), - }, - executable = True, -) diff --git a/utils/bazel/llvm-project-overlay/llvm/cc_plugin_library.bzl b/utils/bazel/llvm-project-overlay/llvm/cc_plugin_library.bzl deleted file mode 100644 index b28425efa39773..00000000000000 --- a/utils/bazel/llvm-project-overlay/llvm/cc_plugin_library.bzl +++ /dev/null @@ -1,75 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -"""A macro to produce a loadable plugin library for the target OS. - -This macro produces a set of platform-specific `cc_binary` rules, by appending -the platform suffix (`.dll`, `.dylib`, or `.so`) to the provided `name`. It then -connects these to a `cc_import` rule with `name` exactly and `hdrs` that can be -used by other Bazel rules to depend on the plugin library. - -The `srcs` attribute for the `cc_binary` rules is `srcs + hdrs`. Other explicit -arguments are passed to all of the rules where they apply, and can be used to -configure generic aspects of all generated rules such as `testonly`. Lastly, -`kwargs` is expanded into all the `cc_binary` rules. -""" - -load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_import", "cc_library") - -def cc_plugin_library(name, srcs, hdrs, include_prefix = None, strip_include_prefix = None, alwayslink = False, features = [], tags = [], testonly = False, **kwargs): - # Neither the name of the plugin binary nor tags on whether it is built are - # configurable. Instead, we build a `cc_binary` with each name and - # selectively depend on them based on platform. - # - # All-in-all, this is a pretty poor workaround. I think this is part of the - # Bazel issue: https://github.com/bazelbuild/bazel/issues/7538 - so_name = name + ".so" - dll_name = name + ".dll" - dylib_name = name + ".dylib" - interface_output_name = name + "_interface_output" - import_name = name + "_import" - for impl_name in [dll_name, dylib_name, so_name]: - cc_binary( - name = impl_name, - srcs = srcs + hdrs, - linkshared = True, - linkstatic = True, - features = features, - tags = ["manual"] + tags, - testonly = testonly, - **kwargs - ) - native.filegroup( - name = interface_output_name, - srcs = select({ - "@platforms//os:windows": [":" + dll_name], - "@platforms//os:macos": [":" + dylib_name], - "//conditions:default": [":" + so_name], - }), - output_group = "interface_library", - ) - cc_import( - name = import_name, - interface_library = ":" + interface_output_name, - shared_library = select({ - "@platforms//os:windows": ":" + dll_name, - "@platforms//os:macos": ":" + dylib_name, - "//conditions:default": ":" + so_name, - }), - alwayslink = alwayslink, - features = features, - tags = tags, - testonly = testonly, - ) - cc_library( - name = name, - hdrs = hdrs, - include_prefix = include_prefix, - strip_include_prefix = strip_include_prefix, - deps = [":" + import_name], - alwayslink = alwayslink, - features = features, - tags = tags, - testonly = testonly, - ) diff --git a/utils/bazel/llvm-project-overlay/llvm/config.bzl b/utils/bazel/llvm-project-overlay/llvm/config.bzl deleted file mode 100644 index 2e3bff53ead9df..00000000000000 --- a/utils/bazel/llvm-project-overlay/llvm/config.bzl +++ /dev/null @@ -1,120 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -"""Defines variables that use selects to configure LLVM based on platform.""" - -load( - "//:vars.bzl", - "LLVM_VERSION", - "LLVM_VERSION_MAJOR", - "LLVM_VERSION_MINOR", - "LLVM_VERSION_PATCH", -) - -def native_arch_defines(arch, triple): - return [ - r'LLVM_NATIVE_ARCH=\"{}\"'.format(arch), - "LLVM_NATIVE_ASMPARSER=LLVMInitialize{}AsmParser".format(arch), - "LLVM_NATIVE_ASMPRINTER=LLVMInitialize{}AsmPrinter".format(arch), - "LLVM_NATIVE_DISASSEMBLER=LLVMInitialize{}Disassembler".format(arch), - "LLVM_NATIVE_TARGET=LLVMInitialize{}Target".format(arch), - "LLVM_NATIVE_TARGETINFO=LLVMInitialize{}TargetInfo".format(arch), - "LLVM_NATIVE_TARGETMC=LLVMInitialize{}TargetMC".format(arch), - "LLVM_NATIVE_TARGETMCA=LLVMInitialize{}TargetMCA".format(arch), - r'LLVM_HOST_TRIPLE=\"{}\"'.format(triple), - r'LLVM_DEFAULT_TARGET_TRIPLE=\"{}\"'.format(triple), - ] - -posix_defines = [ - "LLVM_ON_UNIX=1", - "HAVE_BACKTRACE=1", - "BACKTRACE_HEADER=", - r'LTDL_SHLIB_EXT=\".so\"', - r'LLVM_PLUGIN_EXT=\".so\"', - "LLVM_ENABLE_THREADS=1", - "HAVE_DEREGISTER_FRAME=1", - "HAVE_LIBPTHREAD=1", - "HAVE_PTHREAD_GETNAME_NP=1", - "HAVE_PTHREAD_H=1", - "HAVE_PTHREAD_SETNAME_NP=1", - "HAVE_REGISTER_FRAME=1", - "HAVE_SETENV_R=1", - "HAVE_STRERROR_R=1", - "HAVE_SYSEXITS_H=1", - "HAVE_UNISTD_H=1", -] - -linux_defines = posix_defines + [ - "_GNU_SOURCE", - "HAVE_LINK_H=1", - "HAVE_MALLINFO=1", - "HAVE_SBRK=1", - "HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC=1", -] - -macos_defines = posix_defines + [ - "HAVE_MACH_MACH_H=1", - "HAVE_MALLOC_MALLOC_H=1", - "HAVE_MALLOC_ZONE_STATISTICS=1", - "HAVE_PROC_PID_RUSAGE=1", - "HAVE_UNW_ADD_DYNAMIC_FDE=1", -] - -win32_defines = [ - # Windows system library specific defines. - "_CRT_SECURE_NO_DEPRECATE", - "_CRT_SECURE_NO_WARNINGS", - "_CRT_NONSTDC_NO_DEPRECATE", - "_CRT_NONSTDC_NO_WARNINGS", - "_SCL_SECURE_NO_DEPRECATE", - "_SCL_SECURE_NO_WARNINGS", - "UNICODE", - "_UNICODE", - - # LLVM features - r'LTDL_SHLIB_EXT=\".dll\"', - r'LLVM_PLUGIN_EXT=\".dll\"', -] - -# TODO: We should switch to platforms-based config settings to make this easier -# to express. -os_defines = select({ - "@bazel_tools//src/conditions:windows": win32_defines, - "@bazel_tools//src/conditions:darwin": macos_defines, - "@bazel_tools//src/conditions:freebsd": posix_defines, - "//conditions:default": linux_defines, -}) - -# HAVE_BUILTIN_THREAD_POINTER is true for on Linux (outside of ppc64) for -# all recent toolchains. Add it here by default on Linux as we can't perform a -# configure time check. -builtin_thread_pointer = select({ - "@bazel_tools//src/conditions:linux_ppc64le": [], - "@bazel_tools//src/conditions:linux": ["HAVE_BUILTIN_THREAD_POINTER"], - "//conditions:default": [], -}) - -# TODO: We should split out host vs. target here. -llvm_config_defines = os_defines + builtin_thread_pointer + select({ - "@bazel_tools//src/conditions:windows": native_arch_defines("X86", "x86_64-pc-win32"), - "@bazel_tools//src/conditions:darwin_arm64": native_arch_defines("AArch64", "arm64-apple-darwin"), - "@bazel_tools//src/conditions:darwin_x86_64": native_arch_defines("X86", "x86_64-unknown-darwin"), - "@bazel_tools//src/conditions:linux_aarch64": native_arch_defines("AArch64", "aarch64-unknown-linux-gnu"), - "@bazel_tools//src/conditions:linux_ppc64le": native_arch_defines("PowerPC", "powerpc64le-unknown-linux-gnu"), - "@bazel_tools//src/conditions:linux_s390x": native_arch_defines("SystemZ", "systemz-unknown-linux_gnu"), - "//conditions:default": native_arch_defines("X86", "x86_64-unknown-linux-gnu"), -}) + [ - "LLVM_VERSION_MAJOR={}".format(LLVM_VERSION_MAJOR), - "LLVM_VERSION_MINOR={}".format(LLVM_VERSION_MINOR), - "LLVM_VERSION_PATCH={}".format(LLVM_VERSION_PATCH), - r'LLVM_VERSION_STRING=\"{}git\"'.format(LLVM_VERSION), - # These shouldn't be needed by the C++11 standard, but are for some - # platforms (e.g. glibc < 2.18. See - # https://sourceware.org/bugzilla/show_bug.cgi?id=15366). These are also - # included unconditionally in the CMake build: - # https://github.com/llvm/llvm-project/blob/cd0dd8ece8e/llvm/cmake/modules/HandleLLVMOptions.cmake#L907-L909 - "__STDC_LIMIT_MACROS", - "__STDC_CONSTANT_MACROS", - "__STDC_FORMAT_MACROS", -] diff --git a/utils/bazel/llvm-project-overlay/llvm/enum_targets_gen.bzl b/utils/bazel/llvm-project-overlay/llvm/enum_targets_gen.bzl deleted file mode 100644 index 79617490bf7a4c..00000000000000 --- a/utils/bazel/llvm-project-overlay/llvm/enum_targets_gen.bzl +++ /dev/null @@ -1,68 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -"""A rule to expand LLVM target enumerations. - -Replaces in a text file a single variable of the style `@LLVM_ENUM_FOOS@` with a -list of macro invocations, one for each target on its own line: - -``` -LLVM_FOO(TARGET1) -LLVM_FOO(TARGET2) -// ... -``` - -Example: -load(":enum_targets_gen.bzl", "enum_targets_gen") - -enum_targets_gen( - name = "disassemblers_def_gen", - src = "include/llvm/Config/Disassemblers.def.in", - out = "include/llvm/Config/Disassemblers.def", - macro_name = "DISASSEMBLER", - targets = llvm_target_disassemblers, -) - -This rule provides a slightly more semantic API than template_rule, but the main -reason it exists is to permit a list with selects to be passed for `targets` as -a select is not allowed to be passed to a rule within another data structure. -""" - -def enum_targets_gen_impl(ctx): - to_replace = ctx.attr.placeholder_name - if not to_replace: - to_replace = "@LLVM_ENUM_{}S@".format(ctx.attr.macro_name) - replacement = "\n".join([ - "LLVM_{}({})\n".format(ctx.attr.macro_name, t) - for t in ctx.attr.targets - ]) - - ctx.actions.expand_template( - template = ctx.file.src, - output = ctx.outputs.out, - substitutions = {to_replace: replacement}, - ) - -enum_targets_gen = rule( - attrs = { - "src": attr.label( - mandatory = True, - allow_single_file = True, - ), - "out": attr.output(mandatory = True), - "targets": attr.string_list(mandatory = True), - "macro_name": attr.string( - mandatory = True, - doc = "The name of the enumeration. This is the suffix of the" + - " placeholder being replaced `@LLVM_ENUM_{}S@` and of the" + - " macro invocations generated `LLVM_{}(TARGET)`. Should be" + - " all caps and singular, e.g. 'DISASSEMBLER'", - ), - "placeholder_name": attr.string( - doc = "The name of the placeholder. If unset, this defaults to" + - " `@LLVM_ENUM_{macro_name}S@`", - ), - }, - implementation = enum_targets_gen_impl, -) diff --git a/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h b/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h deleted file mode 100644 index b4fb2373d571fa..00000000000000 --- a/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h +++ /dev/null @@ -1,360 +0,0 @@ -/*===------- llvm/Config/config.h - llvm configuration ------------*- C -*-===*/ -/* */ -/* Part of the LLVM Project, under the Apache License v2.0 with LLVM */ -/* Exceptions. */ -/* See https://llvm.org/LICENSE.txt for license information. */ -/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ -/* */ -/*===----------------------------------------------------------------------===*/ - -/* This is a manual port of config.h.cmake for the symbols that do not change - based on platform. Those that do change should not be defined here and - instead use Bazel cc_library defines. Some attempt has been made to extract - such symbols that do vary based on platform (for the platforms we care about) - into Bazel defines, but it is by no means complete, so if you see something - that looks wrong, it probably is. */ - -#ifndef CONFIG_H -#define CONFIG_H - -// Include this header only under the llvm source tree. -// This is a private header. - -/* Exported configuration */ -#include "llvm/Config/llvm-config.h" - -/* Bug report URL. */ -#define BUG_REPORT_URL "https://github.com/llvm/llvm-project/issues/" - -/* Define to 1 to enable backtraces, and to 0 otherwise. */ -#define ENABLE_BACKTRACES 1 - -/* Define to 1 to enable crash overrides, and to 0 otherwise. */ -#define ENABLE_CRASH_OVERRIDES 1 - -/* Define to 1 to enable crash memory dumps, and to 0 otherwise. */ -#define LLVM_ENABLE_CRASH_DUMPS 0 - -/* Define to 1 to prefer forward slashes on Windows, and to 0 prefer - backslashes. */ -#define LLVM_WINDOWS_PREFER_FORWARD_SLASH 0 - -/* Define to 1 if you have the `backtrace' function. */ -/* HAVE_BACKTRACE defined in Bazel */ - -/* BACKTRACE_HEADER defined in Bazel */ - -/* Define to 1 if you have the header file. */ -/* HAVE_CRASHREPORTERCLIENT_H defined in Bazel */ - -/* can use __crashreporter_info__ */ -/* HAVE_CRASHREPORTER_INFO defined in Bazel */ - -/* Define to 1 if you have the declaration of `arc4random', and to 0 if you - don't. */ -#define HAVE_DECL_ARC4RANDOM 0 - -/* Define to 1 if you have the declaration of `FE_ALL_EXCEPT', and to 0 if you - don't. */ -#define HAVE_DECL_FE_ALL_EXCEPT 1 - -/* Define to 1 if you have the declaration of `FE_INEXACT', and to 0 if you - don't. */ -#define HAVE_DECL_FE_INEXACT 1 - -/* Define to 1 if you have the declaration of `strerror_s', and to 0 if you - don't. */ -#define HAVE_DECL_STRERROR_S 0 - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* Define if dlopen() is available on this platform. */ -#define HAVE_DLOPEN 1 - -/* Define if dladdr() is available on this platform. */ -#define HAVE_DLADDR 1 - -/* Define to 1 if we can register EH frames on this platform. */ -/* HAVE_REGISTER_FRAME defined in Bazel*/ - -/* Define to 1 if we can deregister EH frames on this platform. */ -/* HAVE_DEREGISTER_FRAME defined in Bazel*/ - -/* Define if __unw_add_dynamic_fde() is available on this platform. */ -/* HAVE_UNW_ADD_DYNAMIC_FDE defined in Bazel */ - -/* Define to 1 if you have the header file. */ -#define HAVE_ERRNO_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_FENV_H 1 - -/* Define if libffi is available on this platform. */ -/* #undef HAVE_FFI_CALL */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_FFI_FFI_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_FFI_H */ - -/* Define to 1 if you have the `futimens' function. */ -#define HAVE_FUTIMENS 1 - -/* Define to 1 if you have the `futimes' function. */ -#define HAVE_FUTIMES 1 - -/* Define to 1 if you have the `getpagesize' function. */ -#define HAVE_GETPAGESIZE 1 - -/* Define to 1 if you have the `getrlimit' function. */ -#define HAVE_GETRLIMIT 1 - -/* Define to 1 if you have the `getrusage' function. */ -#define HAVE_GETRUSAGE 1 - -/* Define to 1 if you have the `isatty' function. */ -#define HAVE_ISATTY 1 - -/* Define to 1 if you have the `edit' library (-ledit). */ -/* #undef HAVE_LIBEDIT */ - -/* Define to 1 if you have the `pfm' library (-lpfm). */ -/* #undef HAVE_LIBPFM */ - -/* Define to 1 if the `perf_branch_entry' struct has field cycles. */ -/* #undef LIBPFM_HAS_FIELD_CYCLES */ - -/* Define to 1 if you have the `psapi' library (-lpsapi). */ -/* #undef HAVE_LIBPSAPI */ - -/* Define to 1 if you have the `pthread' library (-lpthread). */ -#define HAVE_LIBPTHREAD 1 - -/* Define to 1 if you have the `pthread_getname_np' function. */ -#define HAVE_PTHREAD_GETNAME_NP 1 - -/* Define to 1 if you have the `pthread_setname_np' function. */ -#define HAVE_PTHREAD_SETNAME_NP 1 - -/* Define to 1 if you have the header file. */ -/* HAVE_LINK_H defined in Bazel */ - -/* Define to 1 if you have the header file. */ -/* HAVE_MACH_MACH_H defined in Bazel */ - -/* Define to 1 if you have the `mallctl' function. */ -/* #undef HAVE_MALLCTL */ - -/* Define to 1 if you have the `mallinfo' function. */ -/* HAVE_MALLINFO defined in Bazel */ - -/* Define to 1 if you have the header file. */ -/* HAVE_MALLOC_MALLOC_H defined in Bazel */ - -/* Define to 1 if you have the `malloc_zone_statistics' function. */ -/* HAVE_MALLOC_ZONE_STATISTICS defined in Bazel */ - -/* Define to 1 if you have the `posix_spawn' function. */ -#define HAVE_POSIX_SPAWN 1 - -/* Define to 1 if you have the `pread' function. */ -#define HAVE_PREAD 1 - -/* Define to 1 if you have the header file. */ -/* HAVE_PTHREAD_H defined in Bazel */ - -/* Have pthread_mutex_lock */ -#define HAVE_PTHREAD_MUTEX_LOCK 1 - -/* Have pthread_rwlock_init */ -#define HAVE_PTHREAD_RWLOCK_INIT 1 - -/* Define to 1 if you have the `sbrk' function. */ -/* HAVE_SBRK defined in Bazel */ - -/* Define to 1 if you have the `setenv' function. */ -/* HAVE_SETENV defined in Bazel */ - -/* Define to 1 if you have the `setrlimit' function. */ -#define HAVE_SETRLIMIT 1 - -/* Define to 1 if you have the `sigaltstack' function. */ -#define HAVE_SIGALTSTACK 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SIGNAL_H 1 - -/* Define to 1 if you have the `strerror_r' function. */ -/* HAVE_STRERROR_R defined in Bazel */ - -/* Define to 1 if you have the `sysconf' function. */ -#define HAVE_SYSCONF 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_IOCTL_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_MMAN_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_PARAM_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_RESOURCE_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TIME_H 1 - -/* Define to 1 if stat struct has st_mtimespec member .*/ -/* #undef HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC */ - -/* Define to 1 if stat struct has st_mtim member. */ -/* HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC defined in Bazel */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define if the setupterm() function is supported this platform. */ -/* LLVM_ENABLE_TERMINFO defined in Bazel */ - -/* Define to 1 if you have the header file. */ -#define HAVE_TERMIOS_H 1 - -/* Define to 1 if you have the header file. */ -/* HAVE_UNISTD_H defined in Bazel */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_VALGRIND_VALGRIND_H */ - -/* Have host's _alloca */ -/* #undef HAVE__ALLOCA */ - -/* Define to 1 if you have the `_chsize_s' function. */ -/* #undef HAVE__CHSIZE_S */ - -/* Define to 1 if you have the `_Unwind_Backtrace' function. */ -#define HAVE__UNWIND_BACKTRACE 1 - -/* Have host's __alloca */ -/* #undef HAVE___ALLOCA */ - -/* Have host's __ashldi3 */ -/* #undef HAVE___ASHLDI3 */ - -/* Have host's __ashrdi3 */ -/* #undef HAVE___ASHRDI3 */ - -/* Have host's __chkstk */ -/* #undef HAVE___CHKSTK */ - -/* Have host's __chkstk_ms */ -/* #undef HAVE___CHKSTK_MS */ - -/* Have host's __cmpdi2 */ -/* #undef HAVE___CMPDI2 */ - -/* Have host's __divdi3 */ -/* #undef HAVE___DIVDI3 */ - -/* Have host's __fixdfdi */ -/* #undef HAVE___FIXDFDI */ - -/* Have host's __fixsfdi */ -/* #undef HAVE___FIXSFDI */ - -/* Have host's __floatdidf */ -/* #undef HAVE___FLOATDIDF */ - -/* Have host's __lshrdi3 */ -/* #undef HAVE___LSHRDI3 */ - -/* Have host's __main */ -/* #undef HAVE___MAIN */ - -/* Have host's __moddi3 */ -/* #undef HAVE___MODDI3 */ - -/* Have host's __udivdi3 */ -/* #undef HAVE___UDIVDI3 */ - -/* Have host's __umoddi3 */ -/* #undef HAVE___UMODDI3 */ - -/* Have host's ___chkstk */ -/* #undef HAVE____CHKSTK */ - -/* Have host's ___chkstk_ms */ -/* #undef HAVE____CHKSTK_MS */ - -/* Linker version detected at compile time. */ -/* #undef HOST_LINK_VERSION */ - -/* Define if zlib compression is available */ -/* LLVM_ENABLE_ZLIB defined in Bazel */ - -/* Define if overriding target triple is enabled */ -/* #undef LLVM_TARGET_TRIPLE_ENV */ - -/* Whether tools show host and target info when invoked with --version */ -#define LLVM_VERSION_PRINTER_SHOW_HOST_TARGET_INFO 1 - -/* Define if libxml2 is supported on this platform. */ -/* #undef LLVM_ENABLE_LIBXML2 */ - -/* Define to the extension used for shared libraries, say, ".so". */ -/* LTDL_SHLIB_EXT defined in Bazel */ - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "https://github.com/llvm/llvm-project/issues/" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "LLVM" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING PACKAGE_NAME " " LLVM_VERSION_STRING - -/* Define to the version of this package. */ -#define PACKAGE_VERSION LLVM_VERSION_STRING - -/* Define to the vendor of this package. */ -/* #undef PACKAGE_VENDOR */ - -/* Define to a function implementing stricmp */ -/* stricmp defined conditionally below. */ - -/* Define to a function implementing strdup */ -/* strdup defined conditionally below. */ - -/* Whether GlobalISel rule coverage is being collected */ -#define LLVM_GISEL_COV_ENABLED 0 - -/* Define to the default GlobalISel coverage file prefix */ -/* #undef LLVM_GISEL_COV_PREFIX */ - -/* Whether Timers signpost passes in Xcode Instruments */ -#define LLVM_SUPPORT_XCODE_SIGNPOSTS 0 - -/* HAVE_PROC_PID_RUSAGE defined in Bazel */ - -/* Directly provide definitions here behind platform preprocessor definitions. - * The preprocessor conditions are sufficient to handle all of the configuration - * on platforms targeted by Bazel, and defining these here more faithfully - * matches how the users of this header expect things to work with CMake. - * FIXME: We should consider moving other platform defines to use this technique - * as well. - */ - -#ifdef _WIN32 -#define stricmp _stricmp -#define strdup _strdup -#endif - -#endif diff --git a/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/llvm-config.h b/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/llvm-config.h deleted file mode 100644 index 5240b8299c1091..00000000000000 --- a/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/llvm-config.h +++ /dev/null @@ -1,127 +0,0 @@ -/*===------- llvm/Config/llvm-config.h - llvm configuration -------*- C -*-===*/ -/* */ -/* Part of the LLVM Project, under the Apache License v2.0 with LLVM */ -/* Exceptions. */ -/* See https://llvm.org/LICENSE.txt for license information. */ -/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ -/* */ -/*===----------------------------------------------------------------------===*/ - -/* This is a manual port of config.h.cmake for the symbols that do not change - based on platform. Those that do change should not be defined here and - instead use Bazel cc_library defines. Some attempt has been made to extract - such symbols that do vary based on platform (for the platforms we care about) - into Bazel defines, but it is by no means complete, so if you see something - that looks wrong, it probably is. */ - - -/* This file enumerates variables from the LLVM configuration so that they - can be in exported headers and won't override package specific directives. - This is a C header that can be included in the llvm-c headers. */ - -#ifndef LLVM_CONFIG_H -#define LLVM_CONFIG_H - -/* Define if LLVM_ENABLE_DUMP is enabled */ -/* #undef LLVM_ENABLE_DUMP */ - -/* Target triple LLVM will generate code for by default */ -/* LLVM_DEFAULT_TARGET_TRIPLE defined in Bazel */ - -/* Define if threads enabled */ -#define LLVM_ENABLE_THREADS 1 - -/* Has gcc/MSVC atomic intrinsics */ -#define LLVM_HAS_ATOMICS 1 - -/* Host triple LLVM will be executed on */ -/* LLVM_HOST_TRIPLE defined in Bazel */ - -/* LLVM architecture name for the native architecture, if available */ -/* LLVM_NATIVE_ARCH defined in Bazel */ - -/* LLVM name for the native AsmParser init function, if available */ -/* LLVM_NATIVE_ASMPARSER defined in Bazel */ - -/* LLVM name for the native AsmPrinter init function, if available */ -/* LLVM_NATIVE_ASMPRINTER defined in Bazel */ - -/* LLVM name for the native Disassembler init function, if available */ -/* LLVM_NATIVE_DISASSEMBLER defined in Bazel */ - -/* LLVM name for the native Target init function, if available */ -/* LLVM_NATIVE_TARGET defined in Bazel */ - -/* LLVM name for the native TargetInfo init function, if available */ -/* LLVM_NATIVE_TARGETINFO defined in Bazel */ - -/* LLVM name for the native target MC init function, if available */ -/* LLVM_NATIVE_TARGETMC defined in Bazel */ - -/* LLVM name for the native target MCA init function, if available */ -/* LLVM_NATIVE_TARGETMCA defined in Bazel */ - -/* Define if this is Unixish platform */ -/* LLVM_ON_UNIX defined in Bazel */ - -/* Define if we have the Intel JIT API runtime support library */ -#define LLVM_USE_INTEL_JITEVENTS 0 - -/* Define if we have the oprofile JIT-support library */ -#define LLVM_USE_OPROFILE 0 - -/* Define if we have the perf JIT-support library */ -#define LLVM_USE_PERF 0 - -/* Major version of the LLVM API */ -/* #undef LLVM_VERSION_MAJOR */ - -/* Minor version of the LLVM API */ -/* #undef LLVM_VERSION_MINOR */ - -/* Patch version of the LLVM API */ -/* #undef LLVM_VERSION_PATCH */ - -/* LLVM version string */ -/* #undef LLVM_VERSION_STRING */ - -/* Whether LLVM records statistics for use with GetStatistics(), - * PrintStatistics() or PrintStatisticsJSON() - */ -#define LLVM_FORCE_ENABLE_STATS 0 - -/* Define if we have z3 and want to build it */ -/* #undef LLVM_WITH_Z3 */ - -/* Define if we have curl and want to use it */ -/* #undef LLVM_ENABLE_CURL */ - -/* Define if we have cpp-httplib and want to use it */ -/* #undef LLVM_ENABLE_HTTPLIB */ - -/* Define if LLVM was built with a dependency to the tensorflow compiler */ -/* #undef LLVM_HAVE_TF_AOT */ - -/* Define to 1 if you have the header file. */ -/* HAVE_SYSEXITS_H defined in Bazel */ - -/* Define if the xar_open() function is supported this platform. */ -/* #undef HAVE_LIBXAR */ - -/* Define if building libLLVM shared library */ -/* #undef LLVM_BUILD_LLVM_DYLIB */ - -/* Define if building LLVM with BUILD_SHARED_LIBS */ -/* #undef LLVM_BUILD_SHARED_LIBS */ - -/* Define if building LLVM with LLVM_FORCE_USE_OLD_TOOLCHAIN_LIBS */ -/* #undef LLVM_FORCE_USE_OLD_TOOLCHAIN ${LLVM_FORCE_USE_OLD_TOOLCHAIN} */ - -/* Define if llvm_unreachable should be optimized with undefined behavior - * in non assert builds */ -#define LLVM_UNREACHABLE_OPTIMIZE 1 - -/* Define to 1 if you have the DIA SDK installed, and to 0 if you don't. */ -#define LLVM_ENABLE_DIA_SDK 0 - -#endif diff --git a/utils/bazel/llvm-project-overlay/llvm/lit_test.bzl b/utils/bazel/llvm-project-overlay/llvm/lit_test.bzl deleted file mode 100644 index ce2a0a00c553a5..00000000000000 --- a/utils/bazel/llvm-project-overlay/llvm/lit_test.bzl +++ /dev/null @@ -1,49 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -"""Rules for running lit tests.""" - -load("@bazel_skylib//lib:paths.bzl", "paths") - -def lit_test( - name, - srcs, - args = None, - data = None, - **kwargs): - """Runs a single test file with LLVM's lit tool. - - Args: - name: string. the name of the generated test target. - srcs: label list. The files on which to run lit. - args: string list. Additional arguments to pass to lit. - Note that `-v` and the 'srcs' paths are added automatically. - data: label list. Additional data dependencies of the test. - Note that 'srcs' targets are added automatically. - **kwargs: additional keyword arguments. - - See https://llvm.org/docs/CommandGuide/lit.html for details on lit. - """ - - args = args or [] - data = data or [] - - native.py_test( - name = name, - srcs = [Label("//llvm:lit")], - main = Label("//llvm:utils/lit/lit.py"), - args = args + ["-v"] + ["$(execpath %s)" % src for src in srcs], - data = data + srcs, - legacy_create_init = False, - **kwargs - ) - -def package_path(label): - """Returns the path to the package of 'label'. - - Args: - label: label. The label to return the package path of. - - For example, package_path("@foo//bar:BUILD") returns 'external/foo/bar'. - """ - return paths.join(Label(label).workspace_root, Label(label).package) diff --git a/utils/bazel/llvm-project-overlay/llvm/tblgen.bzl b/utils/bazel/llvm-project-overlay/llvm/tblgen.bzl deleted file mode 100644 index d43390918e3909..00000000000000 --- a/utils/bazel/llvm-project-overlay/llvm/tblgen.bzl +++ /dev/null @@ -1,81 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -"""This file contains BUILD extensions for generating source code from LLVM's -table definition files using the TableGen tool. - -See http://llvm.org/cmds/tblgen.html for more information on the TableGen -tool. -TODO(chandlerc): Currently this expresses include-based dependencies as -"sources", and has no transitive understanding due to these files not being -correctly understood by the build system. -""" - -def gentbl( - name, - tblgen, - td_file, - td_srcs, - tbl_outs, - library = True, - tblgen_args = "", - **kwargs): - """gentbl() generates tabular code from a table definition file. - - Args: - name: The name of the build rule for use in dependencies. - tblgen: The binary used to produce the output. - td_file: The primary table definitions file. - td_srcs: A list of table definition files included transitively. - tbl_outs: A list of tuples (opts, out), where each opts is a string of - options passed to tblgen, and the out is the corresponding output file - produced. - library: Whether to bundle the generated files into a library. - tblgen_args: Extra arguments string to pass to the tblgen binary. - **kwargs: Keyword arguments to pass to subsidiary cc_library() rule. - """ - llvm_project_execroot_path = Label("//llvm:tblgen.bzl").workspace_root - - if td_file not in td_srcs: - td_srcs += [td_file] - for (opts, out) in tbl_outs: - rule_suffix = "_".join(opts.replace("-", "_").replace("=", "_").split(" ")) - native.genrule( - name = "%s_%s_genrule" % (name, rule_suffix), - srcs = td_srcs, - outs = [out], - tools = [tblgen], - message = "Generating code from table: %s" % td_file, - cmd = (("$(location %s) -I %s/llvm/include " + - "-I %s/clang/include " + - "-I $$(dirname $(location %s)) " + - "%s $(location %s) %s -o $@") % ( - tblgen, - llvm_project_execroot_path, - llvm_project_execroot_path, - td_file, - opts, - td_file, - tblgen_args, - )), - ) - - # For now, all generated files can be assumed to comprise public interfaces. - # If this is not true, you should specify library = False - # and list the generated '.inc' files in "srcs". - if library: - native.cc_library( - name = name, - # FIXME: This should be `textual_hdrs` instead of `hdrs`, but - # unfortunately that doesn't work with `strip_include_prefix`: - # https://github.com/bazelbuild/bazel/issues/12424 - # - # Once that issue is fixed and released, we can switch this to - # `textual_hdrs` and remove the feature disabling the various Bazel - # features (both current and under-development) that motivated the - # distinction between these two. - hdrs = [f for (_, f) in tbl_outs], - features = ["-parse_headers", "-header_modules"], - **kwargs - ) diff --git a/utils/bazel/llvm-project-overlay/llvm/unittests/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/unittests/BUILD.bazel deleted file mode 100644 index 99b924626c2afc..00000000000000 --- a/utils/bazel/llvm-project-overlay/llvm/unittests/BUILD.bazel +++ /dev/null @@ -1,811 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -load("//llvm:tblgen.bzl", "gentbl") - -package( - default_visibility = ["//visibility:public"], - features = ["layering_check"], -) - -licenses(["notice"]) - -cc_test( - name = "adt_tests", - size = "medium", - srcs = glob( - [ - "ADT/*.cpp", - "ADT/*.h", - ], - allow_empty = False, - ), - shard_count = 20, - deps = [ - "//llvm:Core", - "//llvm:Support", - "//llvm:TestingSupport", - "//llvm:config", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "analysis_tests", - size = "small", - srcs = glob( - ["Analysis/*.cpp"], - allow_empty = False, - exclude = [ - # TODO: Add this file to the build. - "Analysis/ConstraintSystemTest.cpp", - "Analysis/TFUtilsTest.cpp", - "Analysis/TrainingLoggerTest.cpp", - "Analysis/MLModelRunnerTest.cpp", - ], - ), - deps = [ - "//llvm:Analysis", - "//llvm:AsmParser", - "//llvm:CodeGen", - "//llvm:Core", - "//llvm:Passes", - "//llvm:Support", - "//llvm:TargetParser", - "//llvm:TestingSupport", - "//llvm:TransformUtils", - "//llvm:attributes_gen", - "//llvm:config", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "asm_parser_tests", - size = "small", - srcs = glob( - ["AsmParser/*.cpp"], - allow_empty = False, - ), - deps = [ - "//llvm:AsmParser", - "//llvm:Core", - "//llvm:Support", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "bitcode_tests", - size = "small", - srcs = glob( - [ - "Bitcode/*.cpp", - "Bitcode/*.h", - ], - allow_empty = False, - ), - deps = [ - "//llvm:AsmParser", - "//llvm:BitReader", - "//llvm:BitWriter", - "//llvm:Core", - "//llvm:Support", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "bitstream_tests", - size = "small", - srcs = glob( - ["Bitstream/*.cpp"], - allow_empty = False, - ), - deps = [ - "//llvm:BitstreamReader", - "//llvm:BitstreamWriter", - "//llvm:Support", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_library( - name = "codegen_tests_includes", - textual_hdrs = glob( - ["CodeGen/*.inc"], - allow_empty = False, - ), -) - -cc_test( - name = "codegen_tests", - size = "medium", - srcs = glob( - [ - "CodeGen/*.cpp", - "CodeGen/*.h", - ], - allow_empty = False, - ), - features = ["-layering_check"], # #include "../lib/CodeGen/AllocationOrder.h" - deps = [ - ":codegen_tests_includes", - "//llvm:AllTargetsAsmParsers", - "//llvm:AllTargetsCodeGens", - "//llvm:Analysis", - "//llvm:AsmParser", - "//llvm:BinaryFormat", - "//llvm:CodeGen", - "//llvm:CodeGenTypes", - "//llvm:Core", - "//llvm:MC", - "//llvm:Passes", - "//llvm:Support", - "//llvm:Target", - "//llvm:TestingSupport", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "codegen_globalisel_tests", - size = "small", - srcs = glob( - [ - "CodeGen/GlobalISel/*.cpp", - "CodeGen/GlobalISel/*.h", - ], - allow_empty = False, - ), - copts = [ - "$(STACK_FRAME_UNLIMITED)", - ], - deps = [ - "//llvm:AllTargetsAsmParsers", - "//llvm:AllTargetsCodeGens", - "//llvm:CodeGen", - "//llvm:CodeGenTypes", - "//llvm:Core", - "//llvm:FileCheckLib", - "//llvm:MC", - "//llvm:Support", - "//llvm:Target", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "debuginfo_tests", - size = "medium", - srcs = glob( - [ - "DebugInfo/DWARF/*.cpp", - "DebugInfo/DWARF/*.h", - # TODO: Re-enable these when they stop crashing. - #"DebugInfo/PDB/*.cpp", - #"DebugInfo/PDB/*.h", - ], - allow_empty = False, - ), - args = [ - # Skip a test that relies on reading files in a way that doesn't easily - # work with Bazel. - "--gtest_filter=-NativeSymbolReuseTest.*", - ], - features = ["-layering_check"], # #include "../lib/CodeGen/AsmPrinter/DwarfStringPool.h" - deps = [ - "//llvm:AllTargetsAsmParsers", - "//llvm:AllTargetsCodeGens", - "//llvm:BinaryFormat", - "//llvm:CodeGenTypes", - "//llvm:Core", - "//llvm:DebugInfo", - "//llvm:DebugInfoDWARF", - "//llvm:DebugInfoPDB", - "//llvm:MC", - "//llvm:Object", - "//llvm:ObjectYAML", - "//llvm:Support", - "//llvm:Target", - "//llvm:TestingSupport", - "//llvm:config", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "debuginfod_tests", - srcs = glob(["Debuginfod/*.cpp"]), - deps = [ - "//llvm:Debuginfod", - "//llvm:Support", - "//llvm:TestingSupport", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "execution_engine_tests", - size = "small", - srcs = glob( - ["ExecutionEngine/*.cpp"], - allow_empty = False, - ), - deps = [ - "//llvm:AllTargetsCodeGens", - "//llvm:AsmParser", - "//llvm:Core", - "//llvm:ExecutionEngine", - "//llvm:Interpreter", - "//llvm:Support", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "execution_engine_mcjit_tests", - size = "medium", - srcs = glob( - [ - "ExecutionEngine/MCJIT/*.cpp", - "ExecutionEngine/MCJIT/*.h", - ], - allow_empty = False, - ), - copts = [ - "$(STACK_FRAME_UNLIMITED)", - ], - deps = [ - "//llvm:AllTargetsCodeGens", - "//llvm:Analysis", - "//llvm:AsmParser", - "//llvm:Core", - "//llvm:ExecutionEngine", - "//llvm:MC", - "//llvm:MCJIT", - "//llvm:Passes", - "//llvm:Support", - "//llvm:Target", - "//llvm:TargetParser", - "//llvm:config", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "execution_engine_orc_tests", - size = "medium", - srcs = glob( - [ - "ExecutionEngine/Orc/*.cpp", - "ExecutionEngine/Orc/*.h", - ], - allow_empty = False, - ), - args = [ - # keep one-per-line - "--gtest_filter=-ObjectLinkingLayerTest.TestSetProcessAllSections", - ], - linkopts = select({ - "@platforms//os:macos": [], - "@platforms//os:windows": [], - "//conditions:default": [ - "-Wl,--export-dynamic-symbol=llvm_orc_registerJITLoaderGDBWrapper", - ], - }), - deps = [ - "//llvm:AllTargetsAsmParsers", - "//llvm:AllTargetsCodeGens", - "//llvm:AsmParser", - "//llvm:Core", - "//llvm:ExecutionEngine", - "//llvm:IRReader", - "//llvm:JITLink", - "//llvm:MC", - "//llvm:Object", - "//llvm:OrcDebugging", - "//llvm:OrcJIT", - "//llvm:OrcShared", - "//llvm:OrcTargetProcess", - "//llvm:Support", - "//llvm:TargetParser", - "//llvm:TestingSupport", - "//llvm:config", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "filecheck_tests", - size = "small", - srcs = glob( - ["FileCheck/*.cpp"], - allow_empty = False, - ), - features = ["-layering_check"], # #include "../lib/FileCheck/FileCheckImpl.h" - deps = [ - "//llvm:FileCheckLib", - "//llvm:Support", - "//llvm:TestingSupport", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "ir_tests", - size = "medium", - timeout = "long", # ConstantRangeTest cases may take several seconds each. - srcs = glob( - [ - "IR/*.cpp", - "IR/*.h", - "Support/KnownBitsTest.h", - ], - allow_empty = False, - ), - shard_count = 20, - deps = [ - "//llvm:Analysis", - "//llvm:AsmParser", - "//llvm:BinaryFormat", - "//llvm:CodeGen", - "//llvm:Core", - "//llvm:Passes", - "//llvm:Scalar", - "//llvm:Support", - "//llvm:TargetParser", - "//llvm:TestingSupport", - "//llvm:TransformUtils", - "//llvm:config", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "line_editor_tests", - size = "small", - srcs = glob( - ["LineEditor/*.cpp"], - allow_empty = False, - ), - deps = [ - "//llvm:LineEditor", - "//llvm:Support", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "frontend_tests", - size = "small", - srcs = glob( - ["Frontend/*.cpp"], - allow_empty = False, - ), - deps = [ - "//llvm:Analysis", - "//llvm:Core", - "//llvm:FrontendOpenACC", - "//llvm:FrontendOpenMP", - "//llvm:Passes", - "//llvm:Support", - "//llvm:TargetParser", - "//llvm:TransformUtils", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "linker_tests", - size = "small", - srcs = glob( - ["Linker/*.cpp"], - allow_empty = False, - ), - deps = [ - "//llvm:AsmParser", - "//llvm:Core", - "//llvm:Linker", - "//llvm:Support", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "mc_tests", - size = "small", - srcs = glob( - ["MC/*.cpp"], - allow_empty = False, - ), - deps = [ - "//llvm:AllTargetsCodeGens", - "//llvm:AllTargetsDisassemblers", - "//llvm:BinaryFormat", - "//llvm:MC", - "//llvm:MCDisassembler", - "//llvm:Object", - "//llvm:Support", - "//llvm:Target", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "mi_tests", - size = "medium", - srcs = glob( - ["MI/*.cpp"], - allow_empty = False, - ), - features = ["-layering_check"], # #include "../lib/CodeGen/RegisterCoalescer.h" - deps = [ - "//llvm:AllTargetsAsmParsers", - "//llvm:AllTargetsCodeGens", - "//llvm:CodeGen", - "//llvm:CodeGenTypes", - "//llvm:Core", - "//llvm:MC", - "//llvm:Support", - "//llvm:Target", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "objcopy_tests", - srcs = glob( - ["ObjCopy/*.cpp"], - allow_empty = False, - ), - deps = [ - "//llvm:ObjCopy", - "//llvm:Object", - "//llvm:ObjectYAML", - "//llvm:Support", - "//llvm:TestingSupport", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "object_tests", - size = "small", - srcs = glob( - ["Object/*.cpp"], - allow_empty = False, - ), - deps = [ - "//llvm:BinaryFormat", - "//llvm:Object", - "//llvm:ObjectYAML", - "//llvm:Support", - "//llvm:TargetParser", - "//llvm:TestingSupport", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "object_yaml_tests", - size = "small", - srcs = glob( - ["ObjectYAML/*.cpp"], - allow_empty = False, - ), - deps = [ - "//llvm:DebugInfoCodeView", - "//llvm:Object", - "//llvm:ObjectYAML", - "//llvm:Support", - "//llvm:TestingSupport", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -gentbl( - name = "option_tests_gen", - strip_include_prefix = "Option", - tbl_outs = [( - "-gen-opt-parser-defs", - "Option/Opts.inc", - )], - tblgen = "//llvm:llvm-tblgen", - td_file = "Option/Opts.td", - td_srcs = [ - "//llvm:include/llvm/Option/OptParser.td", - ], -) - -gentbl( - name = "automata_automata_gen", - strip_include_prefix = "TableGen", - tbl_outs = [( - "-gen-automata", - "TableGen/AutomataAutomata.inc", - )], - tblgen = "//llvm:llvm-tblgen", - td_file = "TableGen/Automata.td", - td_srcs = ["//llvm:common_target_td_sources"] + [ - "TableGen/Automata.td", - ], -) - -gentbl( - name = "automata_tables_gen", - strip_include_prefix = "TableGen", - tbl_outs = [( - "-gen-searchable-tables", - "TableGen/AutomataTables.inc", - )], - tblgen = "//llvm:llvm-tblgen", - td_file = "TableGen/Automata.td", - td_srcs = ["//llvm:common_target_td_sources"] + [ - "TableGen/Automata.td", - ], -) - -cc_test( - name = "option_tests", - size = "small", - srcs = glob( - ["Option/*.cpp"], - allow_empty = False, - ), - deps = [ - ":option_tests_gen", - "//llvm:Option", - "//llvm:Support", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "remarks_tests", - size = "small", - srcs = glob( - ["Remarks/*.cpp"], - allow_empty = False, - ), - deps = [ - "//llvm:BitReader", - "//llvm:Remarks", - "//llvm:Support", - "//llvm:remark_linker", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "profile_data_tests", - size = "small", - srcs = glob( - ["ProfileData/*.cpp"], - allow_empty = False, - ), - deps = [ - "//llvm:Core", - "//llvm:Coverage", - "//llvm:DebugInfo", - "//llvm:Object", - "//llvm:ProfileData", - "//llvm:Support", - "//llvm:Symbolize", - "//llvm:TestingSupport", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -# Note that the name of this test is important as it is used in the test itself. -cc_test( - name = "SupportTests", - size = "medium", - srcs = glob( - [ - "Support/*.cpp", - "Support/*.h", - ], - allow_empty = False, - exclude = [ - "Support/ParallelTest.cpp", - ], - ), - args = [ - # keep one-per-line - "--gtest_filter=-ProgramTest.CreateProcessTrailingSlash", - ], - copts = [ - "$(STACK_FRAME_UNLIMITED)", - ], - linkstatic = 1, - tags = [ - "local", # Not compatible with the sandbox on MacOS - ], - deps = [ - "//llvm:AllTargetsCodeGens", - "//llvm:BinaryFormat", - "//llvm:Core", - "//llvm:ProfileData", - "//llvm:Support", - "//llvm:TargetParser", - "//llvm:TestingSupport", - "//llvm:config", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "support_parallel_tests", - size = "small", - srcs = ["Support/ParallelTest.cpp"], - copts = [ - "$(STACK_FRAME_UNLIMITED)", - ], - linkstatic = 1, - deps = [ - "//llvm:AllTargetsCodeGens", - "//llvm:Support", - "//llvm:config", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "tablegen_tests", - size = "small", - srcs = glob( - [ - "TableGen/*.cpp", - ], - allow_empty = False, - ), - deps = [ - ":automata_automata_gen", - ":automata_tables_gen", - "//llvm:Support", - "//llvm:TableGen", - "//llvm:TableGenGlobalISel", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "target_aarch64_tests", - size = "small", - srcs = glob( - ["Target/AArch64/*.cpp"], - allow_empty = False, - ), - copts = [ - "$(STACK_FRAME_UNLIMITED)", - ], - features = ["-layering_check"], # #include "AArch64GenInstrInfo.inc" - deps = [ - "//llvm:AArch64CodeGen", - "//llvm:AArch64UtilsAndDesc", - "//llvm:AsmParser", - "//llvm:CodeGen", - "//llvm:CodeGenTypes", - "//llvm:Core", - "//llvm:MC", - "//llvm:Support", - "//llvm:Target", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "testing_adt_tests", - size = "small", - srcs = glob( - [ - "Testing/ADT/*.cpp", - ], - allow_empty = False, - ), - deps = [ - "//llvm:Support", - "//llvm:TestingADT", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "transforms_tests", - size = "small", - srcs = glob( - [ - "Transforms/IPO/*.cpp", - "Transforms/IPO/*.h", - "Transforms/Utils/*.cpp", - ], - allow_empty = False, - ), - deps = [ - "//llvm:Analysis", - "//llvm:AsmParser", - "//llvm:Core", - "//llvm:IPO", - "//llvm:IRReader", - "//llvm:Passes", - "//llvm:Support", - "//llvm:TestingSupport", - "//llvm:TransformUtils", - "//llvm:Vectorize", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "llvm_exegesis_tests", - size = "small", - srcs = glob( - [ - "tools/llvm-exegesis/*.cpp", - "tools/llvm-exegesis/X86/*.cpp", - "tools/llvm-exegesis/X86/*.h", - ], - allow_empty = False, - ) + [ - "tools/llvm-exegesis/Common/AssemblerUtils.h", - ], - includes = ["tools/llvm-exegesis"], - deps = [ - "//llvm:AllTargetsCodeGens", - "//llvm:AllTargetsDisassemblers", - "//llvm:CodeGen", - "//llvm:CodeGenTypes", - "//llvm:Exegesis", - "//llvm:MC", - "//llvm:MCDisassembler", - "//llvm:Support", - "//llvm:TargetParser", - "//llvm:TestingSupport", - "//llvm:X86CodeGen", - "//llvm:X86UtilsAndDesc", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) diff --git a/utils/bazel/llvm-project-overlay/llvm/utils/lit/tests/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/utils/lit/tests/BUILD.bazel deleted file mode 100644 index b9e0a2e153ac1e..00000000000000 --- a/utils/bazel/llvm-project-overlay/llvm/utils/lit/tests/BUILD.bazel +++ /dev/null @@ -1,37 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -load("@bazel_skylib//rules:expand_template.bzl", "expand_template") -load("//llvm:lit_test.bzl", "lit_test", "package_path") - -expand_template( - name = "lit_site_cfg", - testonly = True, - out = "lit.site.cfg", - substitutions = { - "@LIT_SITE_CFG_IN_HEADER@": "# Autogenerated, do not edit.", - "@LLVM_LIT_TOOLS_DIR@": package_path("//llvm/utils/lit:BUILD"), - "@LLVM_SOURCE_DIR@": package_path("//llvm:BUILD"), - "@LLVM_BINARY_DIR@": package_path("//llvm:BUILD"), - "@LLVM_TOOLS_DIR@": package_path("//llvm:BUILD"), - }, - template = "lit.site.cfg.in", -) - -[ - lit_test( - name = "%s.test" % src, - srcs = [src], - args = ["--path %s" % package_path("//llvm:BUILD")], - data = [ - "check-tested-lit-timeout-ability", - "lit.cfg", - "lit.site.cfg", - "//llvm:FileCheck", - "//llvm:count", - "//llvm:not", - ] + glob(["Inputs/**"]), - ) - for src in glob(["*/*.py"]) -] diff --git a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel deleted file mode 100644 index 080cbdfaea1848..00000000000000 --- a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel +++ /dev/null @@ -1,14067 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# Description: -# The MLIR "Multi-Level Intermediate Representation" Compiler Infrastructure - -load("@bazel_skylib//rules:expand_template.bzl", "expand_template") -load( - ":build_defs.bzl", - "cc_headers_only", - "if_cuda_available", - "mlir_c_api_cc_library", -) -load(":linalggen.bzl", "genlinalg") -load(":tblgen.bzl", "gentbl_cc_library", "td_library") - -package( - default_visibility = ["//visibility:public"], - features = ["layering_check"], -) - -licenses(["notice"]) - -exports_files([ - "LICENSE.TXT", - "run_lit.sh", - "utils/textmate/mlir.json", -]) - -expand_template( - name = "mlir_config_h_gen", - out = "include/mlir/Config/mlir-config.h", - substitutions = { - "#cmakedefine01 MLIR_DEPRECATED_GPU_SERIALIZATION_ENABLE": "#define MLIR_DEPRECATED_GPU_SERIALIZATION_ENABLE 0", - "#cmakedefine01 MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS": "#define MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS 0", - "#cmakedefine MLIR_GREEDY_REWRITE_RANDOMIZER_SEED ${MLIR_GREEDY_REWRITE_RANDOMIZER_SEED}": "/* #undef MLIR_GREEDY_REWRITE_RANDOMIZER_SEED */", - "#cmakedefine01 MLIR_ENABLE_NVPTXCOMPILER": "#define MLIR_ENABLE_NVPTXCOMPILER 0", - "#cmakedefine01 MLIR_ENABLE_PDL_IN_PATTERNMATCH": "#define MLIR_ENABLE_PDL_IN_PATTERNMATCH 1", - "#cmakedefine01 MLIR_ENABLE_ROCM_CONVERSIONS": "#define MLIR_ENABLE_ROCM_CONVERSIONS 0", - } | if_cuda_available( - {"#cmakedefine01 MLIR_ENABLE_CUDA_CONVERSIONS": "#define MLIR_ENABLE_CUDA_CONVERSIONS 1"}, - {"#cmakedefine01 MLIR_ENABLE_CUDA_CONVERSIONS": "#define MLIR_ENABLE_CUDA_CONVERSIONS 0"}, - ), - template = "include/mlir/Config/mlir-config.h.cmake", -) - -cc_library( - name = "config", - hdrs = [ - "include/mlir/Config/mlir-config.h", - ], -) - -filegroup( - name = "c_headers", - srcs = glob(["include/mlir-c/**/*"]), # <== i.e. match the entire tree -) - -exports_files(glob(["include/**/*.td"])) - -[ - gentbl_cc_library( - name = name + "IncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/IR/" + name + ".h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/IR/" + name + ".cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/IR/" + name + ".td", - deps = [":OpBaseTdFiles"], - ) - for name in [ - "OpAsmInterface", - "RegionKindInterface", - "SymbolInterfaces", - ] -] - -gentbl_cc_library( - name = "TensorEncodingIncGen", - tbl_outs = [ - ( - ["-gen-attr-interface-decls"], - "include/mlir/IR/TensorEncInterfaces.h.inc", - ), - ( - ["-gen-attr-interface-defs"], - "include/mlir/IR/TensorEncInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/IR/TensorEncoding.td", - deps = [":TensorOpsTdFiles"], -) - -td_library( - name = "BuiltinDialectTdFiles", - srcs = [ - "include/mlir/IR/BuiltinAttributeInterfaces.td", - "include/mlir/IR/BuiltinAttributes.td", - "include/mlir/IR/BuiltinDialect.td", - "include/mlir/IR/BuiltinLocationAttributes.td", - "include/mlir/IR/BuiltinOps.td", - "include/mlir/IR/BuiltinTypeInterfaces.td", - "include/mlir/IR/BuiltinTypes.td", - ], - includes = ["include"], - deps = [ - ":BytecodeTdFiles", - ":CallInterfacesTdFiles", - ":CastInterfacesTdFiles", - ":DataLayoutInterfacesTdFiles", - ":OpBaseTdFiles", - ":SideEffectInterfacesTdFiles", - ], -) - -td_library( - name = "BuiltinDialectBytecodeTdFiles", - srcs = ["include/mlir/IR/BuiltinDialectBytecode.td"], - includes = ["include"], - deps = [ - ":BytecodeTdFiles", - ], -) - -gentbl_cc_library( - name = "BuiltinDialectIncGen", - tbl_outs = [ - ( - ["-gen-dialect-decls"], - "include/mlir/IR/BuiltinDialect.h.inc", - ), - ( - ["-gen-dialect-defs"], - "include/mlir/IR/BuiltinDialect.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/IR/BuiltinDialect.td", - deps = [":BuiltinDialectTdFiles"], -) - -gentbl_cc_library( - name = "BuiltinDialectBytecodeGen", - tbl_outs = [ - ( - [ - "-gen-bytecode", - "-bytecode-dialect=Builtin", - ], - "include/mlir/IR/BuiltinDialectBytecode.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/IR/BuiltinDialectBytecode.td", - deps = [":BuiltinDialectTdFiles"], -) - -gentbl_cc_library( - name = "BuiltinAttributesIncGen", - tbl_outs = [ - ( - ["--gen-attrdef-decls"], - "include/mlir/IR/BuiltinAttributes.h.inc", - ), - ( - ["--gen-attrdef-defs"], - "include/mlir/IR/BuiltinAttributes.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/IR/BuiltinAttributes.td", - deps = [":BuiltinDialectTdFiles"], -) - -gentbl_cc_library( - name = "BuiltinAttributeInterfacesIncGen", - tbl_outs = [ - ( - ["--gen-attr-interface-decls"], - "include/mlir/IR/BuiltinAttributeInterfaces.h.inc", - ), - ( - ["--gen-attr-interface-defs"], - "include/mlir/IR/BuiltinAttributeInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/IR/BuiltinAttributeInterfaces.td", - deps = [":BuiltinDialectTdFiles"], -) - -gentbl_cc_library( - name = "BuiltinLocationAttributesIncGen", - tbl_outs = [ - ( - ["--gen-attrdef-decls"], - "include/mlir/IR/BuiltinLocationAttributes.h.inc", - ), - ( - ["--gen-attrdef-defs"], - "include/mlir/IR/BuiltinLocationAttributes.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/IR/BuiltinLocationAttributes.td", - deps = [":BuiltinDialectTdFiles"], -) - -gentbl_cc_library( - name = "BuiltinOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/IR/BuiltinOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/IR/BuiltinOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/IR/BuiltinOps.td", - deps = [ - ":BuiltinDialectTdFiles", - ":OpBaseTdFiles", - ], -) - -gentbl_cc_library( - name = "BuiltinTypesIncGen", - tbl_outs = [ - ( - ["--gen-typedef-decls"], - "include/mlir/IR/BuiltinTypes.h.inc", - ), - ( - ["--gen-typedef-defs"], - "include/mlir/IR/BuiltinTypes.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/IR/BuiltinTypes.td", - deps = [":BuiltinDialectTdFiles"], -) - -gentbl_cc_library( - name = "BuiltinTypeInterfacesIncGen", - tbl_outs = [ - ( - ["--gen-type-interface-decls"], - "include/mlir/IR/BuiltinTypeInterfaces.h.inc", - ), - ( - ["--gen-type-interface-defs"], - "include/mlir/IR/BuiltinTypeInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/IR/BuiltinTypeInterfaces.td", - deps = [ - ":BuiltinDialectTdFiles", - ], -) - -td_library( - name = "FunctionInterfacesTdFiles", - srcs = ["include/mlir/Interfaces/FunctionInterfaces.td"], - includes = ["include"], - deps = [ - ":CallInterfacesTdFiles", - ":OpBaseTdFiles", - ], -) - -gentbl_cc_library( - name = "FunctionInterfacesIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Interfaces/FunctionInterfaces.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Interfaces/FunctionInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Interfaces/FunctionInterfaces.td", - deps = [ - ":FunctionInterfacesTdFiles", - ], -) - -cc_library( - name = "FunctionInterfaces", - srcs = [ - "lib/Interfaces/FunctionImplementation.cpp", - "lib/Interfaces/FunctionInterfaces.cpp", - ], - hdrs = [ - "include/mlir/Interfaces/FunctionImplementation.h", - "include/mlir/Interfaces/FunctionInterfaces.h", - ], - includes = ["include"], - deps = [ - ":CallOpInterfaces", - ":FunctionInterfacesIncGen", - ":IR", - "//llvm:Support", - ], -) - -cc_library( - name = "IR", - srcs = glob([ - "lib/IR/*.cpp", - "lib/IR/*.h", - "lib/IR/PDL/*.cpp", - "lib/Bytecode/Reader/*.h", - "lib/Bytecode/Writer/*.h", - "lib/Bytecode/*.h", - ]) + [ - "include/mlir/IR/PDLPatternMatch.h.inc", - "lib/Bytecode/BytecodeOpInterface.cpp", - ], - hdrs = glob([ - "include/mlir/IR/*.h", - "include/mlir/Bytecode/*.h", - ]) + [ - "include/mlir/Interfaces/CallInterfaces.h", - "include/mlir/Interfaces/DataLayoutInterfaces.h", - "include/mlir/Interfaces/FoldInterfaces.h", - "include/mlir/Interfaces/SideEffectInterfaces.h", - ], - includes = ["include"], - deps = [ - ":BuiltinAttributeInterfacesIncGen", - ":BuiltinAttributesIncGen", - ":BuiltinDialectBytecodeGen", - ":BuiltinDialectIncGen", - ":BuiltinLocationAttributesIncGen", - ":BuiltinOpsIncGen", - ":BuiltinTypeInterfacesIncGen", - ":BuiltinTypesIncGen", - ":BytecodeOpInterfaceIncGen", - ":CallOpInterfacesIncGen", - ":DataLayoutInterfacesIncGen", - ":InferTypeOpInterfaceIncGen", - ":OpAsmInterfaceIncGen", - ":RegionKindInterfaceIncGen", - ":SideEffectInterfacesIncGen", - ":Support", - ":SymbolInterfacesIncGen", - ":TensorEncodingIncGen", - ":config", - "//llvm:Support", - ], -) - -cc_library( - name = "Pass", - srcs = glob([ - "lib/Pass/*.cpp", - "lib/Pass/*.h", - ]), - hdrs = glob([ - "include/mlir/Pass/*.h", - ]), - includes = ["include"], - deps = [ - ":IR", - ":Parser", - ":Support", - "//llvm:Support", - ], -) - -mlir_c_api_cc_library( - name = "CAPIIR", - srcs = [ - "lib/CAPI/Dialect/Func.cpp", - "lib/CAPI/IR/AffineExpr.cpp", - "lib/CAPI/IR/AffineMap.cpp", - "lib/CAPI/IR/BuiltinAttributes.cpp", - "lib/CAPI/IR/BuiltinTypes.cpp", - "lib/CAPI/IR/Diagnostics.cpp", - "lib/CAPI/IR/DialectHandle.cpp", - "lib/CAPI/IR/IR.cpp", - "lib/CAPI/IR/IntegerSet.cpp", - "lib/CAPI/IR/Pass.cpp", - "lib/CAPI/IR/Support.cpp", - ], - hdrs = [ - "include/mlir-c/AffineExpr.h", - "include/mlir-c/AffineMap.h", - "include/mlir-c/BuiltinAttributes.h", - "include/mlir-c/BuiltinTypes.h", - "include/mlir-c/Diagnostics.h", - "include/mlir-c/Dialect/Func.h", - "include/mlir-c/ExecutionEngine.h", - "include/mlir-c/IR.h", - "include/mlir-c/IntegerSet.h", - "include/mlir-c/Interfaces.h", - "include/mlir-c/Pass.h", - "include/mlir-c/RegisterEverything.h", - "include/mlir-c/Support.h", - "include/mlir/CAPI/AffineExpr.h", - "include/mlir/CAPI/AffineMap.h", - "include/mlir/CAPI/Diagnostics.h", - "include/mlir/CAPI/IR.h", - "include/mlir/CAPI/IntegerSet.h", - "include/mlir/CAPI/Interfaces.h", - "include/mlir/CAPI/Pass.h", - "include/mlir/CAPI/Registration.h", - "include/mlir/CAPI/Support.h", - "include/mlir/CAPI/Utils.h", - "include/mlir/CAPI/Wrap.h", - ], - header_deps = [ - ":BytecodeWriter", - ":IR", - ":Pass", - ":Support", - "//llvm:Support", - ], - includes = ["include"], - deps = [ - ":AsmParser", - ":ConversionPassIncGen", - ":FuncDialect", - ":InferTypeOpInterface", - ":Parser", - ], -) - -mlir_c_api_cc_library( - name = "CAPIInterfaces", - srcs = [ - "lib/CAPI/Interfaces/Interfaces.cpp", - ], - capi_deps = [ - ":CAPIIR", - ], - includes = ["include"], - deps = [ - ":IR", - ":InferTypeOpInterface", - "//llvm:Support", - ], -) - -mlir_c_api_cc_library( - name = "CAPIAMDGPU", - srcs = ["lib/CAPI/Dialect/AMDGPU.cpp"], - hdrs = ["include/mlir-c/Dialect/AMDGPU.h"], - capi_deps = [ - ":CAPIIR", - ], - includes = ["include"], - deps = [ - ":AMDGPUDialect", - ], -) - -mlir_c_api_cc_library( - name = "CAPIArith", - srcs = ["lib/CAPI/Dialect/Arith.cpp"], - hdrs = ["include/mlir-c/Dialect/Arith.h"], - capi_deps = [ - ":CAPIIR", - ], - includes = ["include"], - deps = [ - ":ArithDialect", - ], -) - -mlir_c_api_cc_library( - name = "CAPIAsync", - srcs = [ - "lib/CAPI/Dialect/Async.cpp", - "lib/CAPI/Dialect/AsyncPasses.cpp", - ], - hdrs = ["include/mlir-c/Dialect/Async.h"], - capi_deps = [ - ":CAPIIR", - ], - header_deps = [ - ":AsyncPassIncGen", - ], - includes = ["include"], - deps = [ - ":AsyncDialect", - ":AsyncTransforms", - ":Pass", - ], -) - -mlir_c_api_cc_library( - name = "CAPILinalg", - srcs = [ - "lib/CAPI/Dialect/Linalg.cpp", - "lib/CAPI/Dialect/LinalgPasses.cpp", - ], - hdrs = [ - "include/mlir-c/Dialect/Linalg.h", - ], - capi_deps = [ - ":CAPIIR", - ], - header_deps = [ - ":LinalgPassIncGen", - ], - includes = ["include"], - deps = [ - ":LinalgDialect", - ":LinalgTransforms", - ":Pass", - ], -) - -mlir_c_api_cc_library( - name = "CAPILLVM", - srcs = [ - "lib/CAPI/Dialect/LLVM.cpp", - ], - hdrs = [ - "include/mlir-c/Dialect/LLVM.h", - ], - capi_deps = [ - ":CAPIIR", - ], - includes = ["include"], - deps = [ - ":LLVMDialect", - "//llvm:Support", - ], -) - -mlir_c_api_cc_library( - name = "CAPIMath", - srcs = ["lib/CAPI/Dialect/Math.cpp"], - hdrs = ["include/mlir-c/Dialect/Math.h"], - capi_deps = [ - ":CAPIIR", - ], - includes = ["include"], - deps = [ - ":MathDialect", - ], -) - -mlir_c_api_cc_library( - name = "CAPIMemRef", - srcs = ["lib/CAPI/Dialect/MemRef.cpp"], - hdrs = ["include/mlir-c/Dialect/MemRef.h"], - capi_deps = [ - ":CAPIIR", - ], - includes = ["include"], - deps = [ - ":MemRefDialect", - ], -) - -mlir_c_api_cc_library( - name = "CAPINVGPU", - srcs = ["lib/CAPI/Dialect/NVGPU.cpp"], - hdrs = ["include/mlir-c/Dialect/NVGPU.h"], - capi_deps = [ - ":CAPIIR", - ], - includes = ["include"], - deps = [ - ":NVGPUDialect", - ], -) - -mlir_c_api_cc_library( - name = "CAPINVVM", - srcs = ["lib/CAPI/Dialect/NVVM.cpp"], - hdrs = ["include/mlir-c/Dialect/NVVM.h"], - capi_deps = [ - ":CAPIIR", - ], - includes = ["include"], - deps = [ - ":NVVMDialect", - ], -) - -mlir_c_api_cc_library( - name = "CAPITarget", - srcs = ["lib/CAPI/Target/LLVMIR.cpp"], - hdrs = ["include/mlir-c/Target/LLVMIR.h"], - capi_deps = [ - ":CAPIIR", - ], - header_deps = [ - "//llvm:Support", - ], - includes = ["include"], - deps = [ - ":LLVMToLLVMIRTranslation", - ":Support", - ":ToLLVMIRTranslation", - ":ToLLVMIRTranslationRegistration", - "//llvm:Core", - ], -) - -mlir_c_api_cc_library( - name = "CAPIGPU", - srcs = [ - "lib/CAPI/Dialect/GPU.cpp", - "lib/CAPI/Dialect/GPUPasses.cpp", - ], - hdrs = [ - "include/mlir-c/Dialect/GPU.h", - ], - capi_deps = [ - ":CAPIIR", - ], - header_deps = [ - ":GPUPassIncGen", - ], - includes = ["include"], - deps = [ - ":GPUDialect", - ":GPUTransforms", - ":Pass", - ], -) - -mlir_c_api_cc_library( - name = "CAPIROCDL", - srcs = ["lib/CAPI/Dialect/ROCDL.cpp"], - hdrs = ["include/mlir-c/Dialect/ROCDL.h"], - capi_deps = [ - ":CAPIIR", - ], - includes = ["include"], - deps = [ - ":ROCDLDialect", - ], -) - -mlir_c_api_cc_library( - name = "CAPISCF", - srcs = ["lib/CAPI/Dialect/SCF.cpp"], - hdrs = ["include/mlir-c/Dialect/SCF.h"], - capi_deps = [ - ":CAPIIR", - ], - includes = ["include"], - deps = [ - ":SCFDialect", - ], -) - -mlir_c_api_cc_library( - name = "CAPISparseTensor", - srcs = [ - "lib/CAPI/Dialect/SparseTensor.cpp", - "lib/CAPI/Dialect/SparseTensorPasses.cpp", - ], - hdrs = [ - "include/mlir-c/Dialect/SparseTensor.h", - ], - capi_deps = [ - ":CAPIIR", - ], - header_deps = [ - ":SparseTensorPassIncGen", - ], - includes = ["include"], - deps = [ - ":Pass", - ":SparseTensorDialect", - ":SparseTensorTransforms", - ":Support", - ], -) - -mlir_c_api_cc_library( - name = "CAPIQuant", - srcs = [ - "lib/CAPI/Dialect/Quant.cpp", - ], - hdrs = [ - "include/mlir-c/Dialect/Quant.h", - ], - capi_deps = [ - ":CAPIIR", - ], - includes = ["include"], - deps = [ - ":QuantOps", - ], -) - -mlir_c_api_cc_library( - name = "CAPIPDL", - srcs = [ - "lib/CAPI/Dialect/PDL.cpp", - ], - hdrs = [ - "include/mlir-c/Dialect/PDL.h", - ], - header_deps = [ - ":CAPIIRHeaders", - ], - includes = ["include"], - deps = [ - ":CAPIIR", - ":PDLDialect", - ":PDLOpsIncGen", - ":PDLTypesIncGen", - ], -) - -mlir_c_api_cc_library( - name = "CAPITransformDialect", - srcs = [ - "lib/CAPI/Dialect/Transform.cpp", - ], - hdrs = [ - "include/mlir-c/Dialect/Transform.h", - ], - capi_deps = [ - ":CAPIIR", - ], - includes = ["include"], - deps = [ - ":TransformDialect", - ], -) - -mlir_c_api_cc_library( - name = "CAPITransformDialectTransforms", - srcs = [ - "lib/CAPI/Dialect/TransformInterpreter.cpp", - ], - hdrs = [ - "include/mlir-c/Dialect/Transform/Interpreter.h", - ], - capi_deps = [ - ":CAPIIR", - ":CAPITransformDialect", - ], - includes = ["include"], - deps = [ - ":TransformDialect", - ":TransformDialectTransforms", - ], -) - -mlir_c_api_cc_library( - name = "CAPIMLProgram", - srcs = [ - "lib/CAPI/Dialect/MLProgram.cpp", - ], - hdrs = [ - "include/mlir-c/Dialect/MLProgram.h", - ], - header_deps = [ - ":CAPIIRHeaders", - ], - includes = ["include"], - deps = [ - ":CAPIIR", - ":MLProgramDialect", - ":MLProgramOpsIncGen", - ":MLProgramTypesIncGen", - ], -) - -mlir_c_api_cc_library( - name = "CAPIVector", - srcs = ["lib/CAPI/Dialect/Vector.cpp"], - hdrs = ["include/mlir-c/Dialect/Vector.h"], - capi_deps = [ - ":CAPIIR", - ], - includes = ["include"], - deps = [ - ":VectorDialect", - ], -) - -mlir_c_api_cc_library( - name = "CAPIConversion", - srcs = ["lib/CAPI/Conversion/Passes.cpp"], - hdrs = ["include/mlir-c/Conversion.h"], - capi_deps = [ - ":CAPIIR", - ], - header_deps = [ - ":ConversionPassIncGen", - ], - includes = ["include"], - deps = [ - ":ConversionPasses", - ":Pass", - ], -) - -mlir_c_api_cc_library( - name = "CAPIDebug", - srcs = ["lib/CAPI/Debug/Debug.cpp"], - hdrs = ["include/mlir-c/Debug.h"], - capi_deps = [ - ":CAPIIR", - ], - includes = ["include"], - deps = [ - ":Support", - "//llvm:Support", - ], -) - -mlir_c_api_cc_library( - name = "CAPIExecutionEngine", - srcs = ["lib/CAPI/ExecutionEngine/ExecutionEngine.cpp"], - hdrs = [ - "include/mlir-c/ExecutionEngine.h", - "include/mlir/CAPI/ExecutionEngine.h", - ], - capi_deps = [ - ":CAPIIR", - ], - header_deps = [ - ":ExecutionEngine", - ], - includes = ["include"], - deps = [ - ":BuiltinToLLVMIRTranslation", - ":ExecutionEngineUtils", - ":LLVMToLLVMIRTranslation", - ":OpenMPToLLVMIRTranslation", - "//llvm:OrcJIT", - "//llvm:Support", - ], -) - -mlir_c_api_cc_library( - name = "CAPITransforms", - srcs = ["lib/CAPI/Transforms/Passes.cpp"], - hdrs = ["include/mlir-c/Transforms.h"], - capi_deps = [ - ":CAPIIR", - ], - header_deps = [ - ":TransformsPassIncGen", - ], - includes = ["include"], - deps = [ - ":Pass", - ":Transforms", - ], -) - -mlir_c_api_cc_library( - name = "CAPIRegisterEverything", - srcs = ["lib/CAPI/RegisterEverything/RegisterEverything.cpp"], - hdrs = ["include/mlir-c/RegisterEverything.h"], - capi_deps = [ - ":CAPIIR", - ], - includes = ["include"], - deps = [ - ":AllExtensions", - ":AllPassesAndDialects", - ":AllToLLVMIRTranslations", - ":BuiltinToLLVMIRTranslation", - ":IR", - ":LLVMToLLVMIRTranslation", - ], -) - -##---------------------------------------------------------------------------## -# Sources of Python bindings. -#----------------------------------------------------------------------------## - -exports_files( - glob(["lib/Bindings/Python/**/*.cpp"]), -) - -# In the targets related to Python bindings, the projects @pybind11 and -# @local_config_python are defined by @pybind11_bazel. The latter contains -# python headers, and can be configured in an out-of-tree bazel project via -# -# load("@pybind11_bazel//:python_configure.bzl", "python_configure") -# python_configure(name = "local_config_python") -# -# For more up-to-date instructions, see -# https://github.com/pybind/pybind11_bazel -# -# Some out-of-tree projects alias @python_runtime//:headers to -# @local_config_python//:python_headers. - -MLIR_BINDINGS_PYTHON_HEADERS = [ - "lib/Bindings/Python/*.h", - "include/mlir-c/Bindings/Python/*.h", - "include/mlir/Bindings/Python/*.h", -] - -cc_library( - name = "MLIRBindingsPythonHeaders", - includes = [ - "include", - "lib/Bindings/Python", - ], - tags = [ - "manual", # External dependency - "nobuildkite", # TODO(gcmn): Add support for this target - ], - textual_hdrs = glob(MLIR_BINDINGS_PYTHON_HEADERS), - deps = [ - ":CAPIIRHeaders", - "@local_config_python//:python_headers", - "@pybind11", - ], -) - -cc_library( - name = "MLIRBindingsPythonHeadersAndDeps", - includes = [ - "include", - "lib/Bindings/Python", - ], - tags = [ - "manual", # External dependency - "nobuildkite", # TODO(gcmn): Add support for this target - ], - textual_hdrs = glob(MLIR_BINDINGS_PYTHON_HEADERS), - deps = [ - ":CAPIIR", - "@local_config_python//:python_headers", - "@pybind11", - ], -) - -# These flags are needed for pybind11 to work. -PYBIND11_COPTS = [ - "-fexceptions", - "-frtti", -] - -PYBIND11_FEATURES = [ - # Cannot use header_modules (parse_headers feature fails). - "-use_header_modules", -] - -MLIR_PYTHON_BINDINGS_SOURCES = [ - "lib/Bindings/Python/IRAffine.cpp", - "lib/Bindings/Python/IRAttributes.cpp", - "lib/Bindings/Python/IRCore.cpp", - "lib/Bindings/Python/IRInterfaces.cpp", - "lib/Bindings/Python/IRModule.cpp", - "lib/Bindings/Python/IRTypes.cpp", - "lib/Bindings/Python/Pass.cpp", -] - -cc_library( - name = "MLIRBindingsPythonCore", - srcs = MLIR_PYTHON_BINDINGS_SOURCES, - copts = PYBIND11_COPTS, - features = PYBIND11_FEATURES, - tags = [ - "manual", # External dependency - "nobuildkite", # TODO(gcmn): Add support for this target - ], - deps = [ - ":CAPIAsync", - ":CAPIDebug", - ":CAPIIR", - ":CAPIInterfaces", - ":MLIRBindingsPythonHeadersAndDeps", - ":Support", - "//llvm:Support", - "@local_config_python//:python_headers", - "@pybind11", - ], -) - -cc_library( - name = "MLIRBindingsPythonCoreNoCAPI", - srcs = MLIR_PYTHON_BINDINGS_SOURCES, - copts = PYBIND11_COPTS, - features = PYBIND11_FEATURES, - tags = [ - "manual", # External dependency - "nobuildkite", # TODO(gcmn): Add support for this target - ], - deps = [ - ":CAPIAsyncHeaders", - ":CAPIDebugHeaders", - ":CAPIIRHeaders", - ":MLIRBindingsPythonHeaders", - "//llvm:Support", - "@local_config_python//:python_headers", - "@pybind11", - ], -) - -# Target that bundles together the CAPI objects needed for -# MLIRBindingsPythonCoreNoCAPI. -cc_library( - name = "MLIRBindingsPythonCAPIObjects", - tags = [ - "manual", # External dependency - "nobuildkite", # TODO(gcmn): Add support for this target - ], - deps = [ - ":CAPIAsyncObjects", - ":CAPIDebugObjects", - ":CAPIIRObjects", - ":CAPIInterfacesObjects", - ], -) - -# Dynamic library with the MLIR Python extension. -cc_binary( - name = "_mlir.so", - srcs = ["lib/Bindings/Python/MainModule.cpp"], - # These flags are needed for pybind11 to work. - copts = PYBIND11_COPTS, - features = PYBIND11_FEATURES, - linkshared = 1, - linkstatic = 0, - tags = [ - "manual", # External dependency - "nobuildkite", # TODO(gcmn): Add support for this target - ], - deps = [ - ":MLIRBindingsPythonCore", - ":MLIRBindingsPythonHeadersAndDeps", - ], -) - -cc_binary( - name = "_mlirDialectsLinalg.so", - srcs = ["lib/Bindings/Python/DialectLinalg.cpp"], - copts = PYBIND11_COPTS, - features = PYBIND11_FEATURES, - linkshared = 1, - linkstatic = 0, - tags = [ - "manual", # External dependency - "nobuildkite", # TODO(gcmn): Add support for this target - ], - deps = [ - ":CAPIIR", - ":CAPILinalg", - ":MLIRBindingsPythonHeadersAndDeps", - ], -) - -cc_binary( - name = "_mlirDialectsLLVM.so", - srcs = ["lib/Bindings/Python/DialectLLVM.cpp"], - copts = PYBIND11_COPTS, - features = PYBIND11_FEATURES, - linkshared = 1, - linkstatic = 0, - tags = [ - "manual", # External dependency - "nobuildkite", - ], - deps = [ - ":CAPIIR", - ":CAPILLVM", - ":MLIRBindingsPythonHeadersAndDeps", - "@pybind11", - ], -) - -cc_binary( - name = "_mlirDialectsQuant.so", - srcs = ["lib/Bindings/Python/DialectQuant.cpp"], - copts = PYBIND11_COPTS, - features = PYBIND11_FEATURES, - linkshared = 1, - linkstatic = 0, - tags = [ - "manual", # External dependency - "nobuildkite", # TODO(gcmn): Add support for this target - ], - deps = [ - ":CAPIIR", - ":CAPIQuant", - ":MLIRBindingsPythonHeadersAndDeps", - "@pybind11", - ], -) - -cc_binary( - name = "_mlirDialectsSparseTensor.so", - srcs = ["lib/Bindings/Python/DialectSparseTensor.cpp"], - copts = PYBIND11_COPTS, - features = PYBIND11_FEATURES, - linkshared = 1, - linkstatic = 0, - tags = [ - "manual", # External dependency - "nobuildkite", # TODO(gcmn): Add support for this target - ], - deps = [ - ":CAPIIR", - ":CAPISparseTensor", - ":MLIRBindingsPythonHeadersAndDeps", - "@pybind11", - ], -) - -# Dynamic library with the MLIR Conversions Python extension. -cc_binary( - name = "_mlirExecutionEngine.so", - srcs = ["lib/Bindings/Python/ExecutionEngineModule.cpp"], - copts = PYBIND11_COPTS, - features = PYBIND11_FEATURES, - linkshared = 1, - linkstatic = 0, - tags = [ - "manual", # External dependency - "nobuildkite", # TODO(gcmn): Add support for this target - ], - deps = [ - ":CAPIExecutionEngine", - ":MLIRBindingsPythonHeadersAndDeps", - "@local_config_python//:python_headers", - "@pybind11", - ], -) - -# Dynamic library with the MLIR Linalg dialect+passes Python extension. -cc_binary( - name = "_mlirLinalgPasses.so", - srcs = ["lib/Bindings/Python/LinalgPasses.cpp"], - copts = PYBIND11_COPTS, - features = PYBIND11_FEATURES, - linkshared = 1, - linkstatic = 0, - tags = [ - "manual", # External dependency - "nobuildkite", # TODO(gcmn): Add support for this target - ], - deps = [ - ":CAPILinalg", - ":MLIRBindingsPythonHeadersAndDeps", - "@local_config_python//:python_headers", - "@pybind11", - ], -) - -##---------------------------------------------------------------------------## - -td_library( - name = "AttrTdFiles", - srcs = [ - "include/mlir/IR/AttrTypeBase.td", - "include/mlir/IR/EnumAttr.td", - ], - includes = ["include"], -) - -td_library( - name = "OpBaseTdFiles", - srcs = [ - "include/mlir/IR/CommonAttrConstraints.td", - "include/mlir/IR/CommonTypeConstraints.td", - "include/mlir/IR/Constraints.td", - "include/mlir/IR/DialectBase.td", - "include/mlir/IR/Interfaces.td", - "include/mlir/IR/OpAsmInterface.td", - "include/mlir/IR/OpBase.td", - "include/mlir/IR/PatternBase.td", - "include/mlir/IR/Properties.td", - "include/mlir/IR/RegionKindInterface.td", - "include/mlir/IR/SymbolInterfaces.td", - "include/mlir/IR/TensorEncoding.td", - "include/mlir/IR/Traits.td", - "include/mlir/IR/Utils.td", - ], - includes = ["include"], - deps = [ - ":AttrTdFiles", - ], -) - -td_library( - name = "BytecodeTdFiles", - srcs = ["include/mlir/IR/BytecodeBase.td"], - includes = ["include"], -) - -td_library( - name = "CallInterfacesTdFiles", - srcs = ["include/mlir/Interfaces/CallInterfaces.td"], - includes = ["include"], - deps = [":OpBaseTdFiles"], -) - -td_library( - name = "CastInterfacesTdFiles", - srcs = ["include/mlir/Interfaces/CastInterfaces.td"], - includes = ["include"], - deps = [":OpBaseTdFiles"], -) - -td_library( - name = "ControlFlowInterfacesTdFiles", - srcs = ["include/mlir/Interfaces/ControlFlowInterfaces.td"], - includes = ["include"], - deps = [":OpBaseTdFiles"], -) - -td_library( - name = "BytecodeOpInterfaceTdFiles", - srcs = ["include/mlir/Bytecode/BytecodeOpInterface.td"], - includes = ["include"], - deps = [":OpBaseTdFiles"], -) - -td_library( - name = "CopyOpInterfaceTdFiles", - srcs = ["include/mlir/Interfaces/CopyOpInterface.td"], - includes = ["include"], - deps = [":OpBaseTdFiles"], -) - -td_library( - name = "DerivedAttributeOpInterfaceTdFiles", - srcs = ["include/mlir/Interfaces/DerivedAttributeOpInterface.td"], - includes = ["include"], - deps = [":OpBaseTdFiles"], -) - -td_library( - name = "DestinationStyleOpInterfaceTdFiles", - srcs = ["include/mlir/Interfaces/DestinationStyleOpInterface.td"], - includes = ["include"], - deps = [":OpBaseTdFiles"], -) - -td_library( - name = "InferIntRangeInterfaceTdFiles", - srcs = ["include/mlir/Interfaces/InferIntRangeInterface.td"], - includes = ["include"], - deps = [":OpBaseTdFiles"], -) - -td_library( - name = "InferTypeOpInterfaceTdFiles", - srcs = ["include/mlir/Interfaces/InferTypeOpInterface.td"], - includes = ["include"], - deps = [":OpBaseTdFiles"], -) - -td_library( - name = "LoopLikeInterfaceTdFiles", - srcs = ["include/mlir/Interfaces/LoopLikeInterface.td"], - includes = ["include"], - deps = [":OpBaseTdFiles"], -) - -td_library( - name = "MemorySlotInterfacesTdFiles", - srcs = ["include/mlir/Interfaces/MemorySlotInterfaces.td"], - includes = ["include"], - deps = [":OpBaseTdFiles"], -) - -td_library( - name = "ShapedOpInterfacesTdFiles", - srcs = ["include/mlir/Interfaces/ShapedOpInterfaces.td"], - includes = ["include"], - deps = [":OpBaseTdFiles"], -) - -td_library( - name = "ParallelCombiningOpInterfaceTdFiles", - srcs = ["include/mlir/Interfaces/ParallelCombiningOpInterface.td"], - includes = ["include"], - deps = [":OpBaseTdFiles"], -) - -td_library( - name = "RuntimeVerifiableOpInterfaceTdFiles", - srcs = ["include/mlir/Interfaces/RuntimeVerifiableOpInterface.td"], - includes = ["include"], - deps = [":OpBaseTdFiles"], -) - -td_library( - name = "SideEffectInterfacesTdFiles", - srcs = [ - "include/mlir/Interfaces/SideEffectInterfaceBase.td", - "include/mlir/Interfaces/SideEffectInterfaces.td", - ], - includes = ["include"], - deps = [":OpBaseTdFiles"], -) - -td_library( - name = "TilingInterfaceTdFiles", - srcs = ["include/mlir/Interfaces/TilingInterface.td"], - includes = ["include"], - deps = [":OpBaseTdFiles"], -) - -td_library( - name = "VectorInterfacesTdFiles", - srcs = ["include/mlir/Interfaces/VectorInterfaces.td"], - includes = ["include"], - deps = [":OpBaseTdFiles"], -) - -td_library( - name = "ViewLikeInterfaceTdFiles", - srcs = ["include/mlir/Interfaces/ViewLikeInterface.td"], - includes = ["include"], - deps = [":OpBaseTdFiles"], -) - -td_library( - name = "ReducerTdFiles", - srcs = ["include/mlir/Reducer/Passes.td"], - includes = ["include"], - deps = [":OpBaseTdFiles"], -) - -##---------------------------------------------------------------------------## -# Affine dialect. -##---------------------------------------------------------------------------## - -td_library( - name = "PassBaseTdFiles", - srcs = ["include/mlir/Pass/PassBase.td"], - includes = ["include"], -) - -td_library( - name = "RewritePassBaseTdFiles", - srcs = ["include/mlir/Rewrite/PassUtil.td"], - includes = ["include"], -) - -td_library( - name = "AffineOpsTdFiles", - srcs = [ - "include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.td", - "include/mlir/Dialect/Affine/IR/AffineOps.td", - ], - includes = ["include"], - deps = [ - ":ArithOpsTdFiles", - ":FuncTdFiles", - ":LoopLikeInterfaceTdFiles", - ":OpBaseTdFiles", - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "AffineOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/Affine/IR/AffineOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/Affine/IR/AffineOps.cpp.inc", - ), - ( - [ - "-gen-dialect-decls", - "-dialect=affine", - ], - "include/mlir/Dialect/Affine/IR/AffineOpsDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=affine", - ], - "include/mlir/Dialect/Affine/IR/AffineOpsDialect.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Affine/IR/AffineOps.td", - deps = [":AffineOpsTdFiles"], -) - -gentbl_cc_library( - name = "AffineMemoryOpInterfacesIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Affine/IR/AffineMemoryOpInterfaces.td", - deps = [":AffineOpsTdFiles"], -) - -td_library( - name = "AffineTransformOpsTdFiles", - srcs = [ - "include/mlir/Dialect/Affine/TransformOps/AffineTransformOps.td", - ], - includes = ["include"], - deps = [ - ":TransformDialectTdFiles", - ], -) - -gentbl_cc_library( - name = "AffineTransformOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/Affine/TransformOps/AffineTransformOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/Affine/TransformOps/AffineTransformOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Affine/TransformOps/AffineTransformOps.td", - deps = [ - ":AffineTransformOpsTdFiles", - ], -) - -cc_library( - name = "AffineTransformOps", - srcs = glob(["lib/Dialect/Affine/TransformOps/*.cpp"]), - hdrs = glob(["include/mlir/Dialect/Affine/TransformOps/*.h"]), - includes = ["include"], - deps = [ - ":AffineAnalysis", - ":AffineDialect", - ":AffineTransformOpsIncGen", - ":AffineTransforms", - ":AffineUtils", - ":FuncDialect", - ":IR", - ":TransformDialect", - ":Transforms", - ":VectorDialect", - ], -) - -##---------------------------------------------------------------------------## -# AMDGPU dialect. -##---------------------------------------------------------------------------## - -td_library( - name = "AMDGPUTdFiles", - srcs = ["include/mlir/Dialect/AMDGPU/IR/AMDGPU.td"], - includes = ["include"], - deps = [ - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "AMDGPUIncGen", - tbl_outs = [ - ( - [ - "-gen-attrdef-decls", - "-dialect=amdgpu", - ], - "include/mlir/Dialect/AMDGPU/IR/AMDGPUAttributes.h.inc", - ), - ( - [ - "-gen-attrdef-defs", - "-dialect=amdgpu", - ], - "include/mlir/Dialect/AMDGPU/IR/AMDGPUAttributes.cpp.inc", - ), - ( - [ - "-gen-dialect-decls", - "-dialect=amdgpu", - ], - "include/mlir/Dialect/AMDGPU/IR/AMDGPUDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=amdgpu", - ], - "include/mlir/Dialect/AMDGPU/IR/AMDGPUDialect.cpp.inc", - ), - ( - ["-gen-enum-decls"], - "include/mlir/Dialect/AMDGPU/IR/AMDGPUEnums.h.inc", - ), - ( - ["-gen-enum-defs"], - "include/mlir/Dialect/AMDGPU/IR/AMDGPUEnums.cpp.inc", - ), - ( - ["-gen-op-decls"], - "include/mlir/Dialect/AMDGPU/IR/AMDGPU.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/AMDGPU/IR/AMDGPU.cpp.inc", - ), - ( - ["-gen-op-doc"], - "g3doc/Dialects/AMDGPU/IR/AMDGPU.md", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/AMDGPU/IR/AMDGPU.td", - deps = [":AMDGPUTdFiles"], -) - -cc_library( - name = "AMDGPUDialect", - srcs = ["lib/Dialect/AMDGPU/IR/AMDGPUDialect.cpp"], - hdrs = ["include/mlir/Dialect/AMDGPU/IR/AMDGPUDialect.h"], - includes = ["include"], - deps = [ - ":AMDGPUIncGen", - ":ArithDialect", - ":GPUDialect", - ":IR", - ":SideEffectInterfaces", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "AMDGPUTransformOps", - srcs = glob([ - "lib/Dialect/AMDGPU/TransformOps/*.cpp", - ]), - hdrs = glob([ - "include/mlir/Dialect/AMDGPU/TransformOps/*.h", - ]), - includes = ["include"], - deps = [ - ":AMDGPUDialect", - ":AMDGPUTransformOpsIncGen", - ":AMDGPUTransforms", - ":AffineDialect", - ":FuncDialect", - ":IR", - ":TransformDialect", - ":VectorDialect", - ], -) - -td_library( - name = "AMDGPUTransformOpsTdFiles", - srcs = glob([ - "include/mlir/Dialect/AMDGPU/TransformOps/*.td", - ]), - includes = ["include"], - deps = [ - ":TransformDialectTdFiles", - ], -) - -gentbl_cc_library( - name = "AMDGPUTransformOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/AMDGPU/TransformOps/AMDGPUTransformOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/AMDGPU/TransformOps/AMDGPUTransformOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/AMDGPU/TransformOps/AMDGPUTransformOps.td", - deps = [ - ":AMDGPUTransformOpsTdFiles", - ], -) - -gentbl_cc_library( - name = "AMDGPUPassIncGen", - tbl_outs = [ - ( - [ - "-gen-pass-decls", - "-name=AMDGPU", - ], - "include/mlir/Dialect/AMDGPU/Transforms/Passes.h.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/AMDGPU/Transforms/Passes.td", - deps = [":PassBaseTdFiles"], -) - -cc_library( - name = "AMDGPUTransforms", - srcs = glob( - [ - "lib/Dialect/AMDGPU/Transforms/*.cpp", - "lib/Dialect/AMDGPU/Transforms/*.h", - ], - ), - hdrs = glob(["include/mlir/Dialect/AMDGPU/Transforms/*.h"]), - includes = ["include"], - deps = [ - ":AMDGPUDialect", - ":AMDGPUPassIncGen", - ":AMDGPUUtils", - ":ArithDialect", - ":ControlFlowDialect", - ":FuncDialect", - ":GPUDialect", - ":IR", - ":MemRefDialect", - ":Pass", - ":Support", - ":TransformUtils", - ":Transforms", - ":VectorDialect", - "//llvm:Support", - ], -) - -cc_library( - name = "AMDGPUUtils", - srcs = glob(["lib/Dialect/AMDGPU/Utils/*.cpp"]), - hdrs = glob(["include/mlir/Dialect/AMDGPU/Utils/*.h"]), - includes = ["include"], - deps = [ - ":AMDGPUDialect", - ":Support", - "//llvm:Support", - ], -) - -##---------------------------------------------------------------------------## -# EmitC dialect. -##---------------------------------------------------------------------------## - -td_library( - name = "EmitCTdFiles", - srcs = [ - "include/mlir/Dialect/EmitC/IR/EmitC.td", - "include/mlir/Dialect/EmitC/IR/EmitCAttributes.td", - "include/mlir/Dialect/EmitC/IR/EmitCBase.td", - "include/mlir/Dialect/EmitC/IR/EmitCTypes.td", - ], - includes = ["include"], - deps = [ - ":BuiltinDialectTdFiles", - ":CallInterfacesTdFiles", - ":CastInterfacesTdFiles", - ":ControlFlowInterfacesTdFiles", - ":FunctionInterfacesTdFiles", - ":OpBaseTdFiles", - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "EmitCAttributesIncGen", - tbl_outs = [ - ( - ["--gen-attrdef-decls"], - "include/mlir/Dialect/EmitC/IR/EmitCAttributes.h.inc", - ), - ( - ["--gen-attrdef-defs"], - "include/mlir/Dialect/EmitC/IR/EmitCAttributes.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/EmitC/IR/EmitCAttributes.td", - deps = [":EmitCTdFiles"], -) - -gentbl_cc_library( - name = "EmitCOpsIncGen", - tbl_outs = [ - ( - ["-gen-dialect-decls"], - "include/mlir/Dialect/EmitC/IR/EmitCDialect.h.inc", - ), - ( - ["-gen-dialect-defs"], - "include/mlir/Dialect/EmitC/IR/EmitCDialect.cpp.inc", - ), - ( - ["-gen-enum-decls"], - "include/mlir/Dialect/EmitC/IR/EmitCEnums.h.inc", - ), - ( - ["-gen-enum-defs"], - "include/mlir/Dialect/EmitC/IR/EmitCEnums.cpp.inc", - ), - ( - ["-gen-op-decls"], - "include/mlir/Dialect/EmitC/IR/EmitC.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/EmitC/IR/EmitC.cpp.inc", - ), - ( - ["-gen-typedef-decls"], - "include/mlir/Dialect/EmitC/IR/EmitCTypes.h.inc", - ), - ( - ["-gen-typedef-defs"], - "include/mlir/Dialect/EmitC/IR/EmitCTypes.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/EmitC/IR/EmitC.td", - deps = [":EmitCTdFiles"], -) - -gentbl_cc_library( - name = "EmitCPassIncGen", - tbl_outs = [ - ( - [ - "-gen-pass-decls", - "-name=EmitC", - ], - "include/mlir/Dialect/EmitC/Transforms/Passes.h.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/EmitC/Transforms/Passes.td", - deps = [":PassBaseTdFiles"], -) - -cc_library( - name = "TargetCpp", - srcs = glob([ - "lib/Target/Cpp/*.cpp", - "lib/Target/Cpp/*.h", - ]), - hdrs = glob(["include/mlir/Target/Cpp/*.h"]), - deps = [ - ":ControlFlowDialect", - ":EmitCDialect", - ":FuncDialect", - ":IR", - ":Support", - ":TranslateLib", - "//llvm:Support", - ], -) - -##---------------------------------------------------------------------------## -# Async dialect. -##---------------------------------------------------------------------------## - -td_library( - name = "AsyncOpsTdFiles", - srcs = [ - "include/mlir/Dialect/Async/IR/AsyncDialect.td", - "include/mlir/Dialect/Async/IR/AsyncOps.td", - "include/mlir/Dialect/Async/IR/AsyncTypes.td", - ], - includes = ["include"], - deps = [ - ":CallInterfacesTdFiles", - ":ControlFlowInterfacesTdFiles", - ":FunctionInterfacesTdFiles", - ":InferTypeOpInterfaceTdFiles", - ":OpBaseTdFiles", - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "AsyncOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/Async/IR/AsyncOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/Async/IR/AsyncOps.cpp.inc", - ), - ( - ["-gen-dialect-decls"], - "include/mlir/Dialect/Async/IR/AsyncOpsDialect.h.inc", - ), - ( - ["-gen-dialect-defs"], - "include/mlir/Dialect/Async/IR/AsyncOpsDialect.cpp.inc", - ), - ( - ["-gen-typedef-decls"], - "include/mlir/Dialect/Async/IR/AsyncOpsTypes.h.inc", - ), - ( - ["-gen-typedef-defs"], - "include/mlir/Dialect/Async/IR/AsyncOpsTypes.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Async/IR/AsyncOps.td", - deps = [":AsyncOpsTdFiles"], -) - -gentbl_cc_library( - name = "AsyncPassIncGen", - tbl_outs = [ - ( - [ - "-gen-pass-decls", - "-name=Async", - ], - "include/mlir/Dialect/Async/Passes.h.inc", - ), - ( - [ - "-gen-pass-capi-header", - "--prefix=Async", - ], - "include/mlir/Dialect/Async/Passes.capi.h.inc", - ), - ( - [ - "-gen-pass-capi-impl", - "--prefix=Async", - ], - "include/mlir/Dialect/Async/Passes.capi.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Async/Passes.td", - deps = [":PassBaseTdFiles"], -) - -##---------------------------------------------------------------------------## -# ArmNeon dialect. -##---------------------------------------------------------------------------## - -td_library( - name = "ArmNeonTdFiles", - srcs = ["include/mlir/Dialect/ArmNeon/ArmNeon.td"], - includes = ["include"], - deps = [ - ":LLVMOpsTdFiles", - ":OpBaseTdFiles", - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "ArmNeonIncGen", - tbl_outs = [ - ( - [ - "-gen-dialect-decls", - "-dialect=arm_neon", - ], - "include/mlir/Dialect/ArmNeon/ArmNeonDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=arm_neon", - ], - "include/mlir/Dialect/ArmNeon/ArmNeonDialect.cpp.inc", - ), - ( - ["-gen-op-decls"], - "include/mlir/Dialect/ArmNeon/ArmNeon.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/ArmNeon/ArmNeon.cpp.inc", - ), - ( - ["-gen-op-doc"], - "g3doc/Dialects/ArmNeon/ArmNeon.md", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/ArmNeon/ArmNeon.td", - deps = [":ArmNeonTdFiles"], -) - -cc_library( - name = "ArmNeonDialect", - srcs = ["lib/Dialect/ArmNeon/IR/ArmNeonDialect.cpp"], - hdrs = ["include/mlir/Dialect/ArmNeon/ArmNeonDialect.h"], - includes = ["include"], - deps = [ - ":ArmNeonIncGen", - ":IR", - ":SideEffectInterfaces", - ":VectorDialect", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "ArmNeonTransforms", - srcs = glob(["lib/Dialect/ArmNeon/Transforms/*.cpp"]), - hdrs = ["include/mlir/Dialect/ArmNeon/Transforms.h"], - includes = ["include"], - deps = [ - ":ArithDialect", - ":ArmNeonIncGen", - ":ArmNeonDialect", - ":FuncDialect", - ":IR", - ":LLVMDialect", - ":SideEffectInterfaces", - ":Support", - ":VectorDialect", - ":Transforms", - "//llvm:Core", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "ArmNeonConversionIncGen", - tbl_outs = [ - ( - ["-gen-llvmir-conversions"], - "include/mlir/Dialect/ArmNeon/ArmNeonConversions.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/ArmNeon/ArmNeon.td", - deps = [":ArmNeonTdFiles"], -) - -cc_library( - name = "ArmNeon2dToIntr", - srcs = glob([ - "lib/Conversion/ArmNeon2dToIntr/*.cpp", - "lib/Conversion/ArmNeon2dToIntr/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/ArmNeon2dToIntr/*.h", - ]), - includes = ["include"], - deps = [ - ":ArmNeonDialect", - ":ConversionPassIncGen", - ":FuncDialect", - ":IR", - ":MemRefDialect", - ":OpenACCDialect", - ":Pass", - ":SCFDialect", - ":Support", - ":Transforms", - ":VectorDialect", - ], -) - -##---------------------------------------------------------------------------## -# ArmSME dialect. -##---------------------------------------------------------------------------## - -td_library( - name = "ArmSMETdFiles", - srcs = [ - "include/mlir/Dialect/ArmSME/IR/ArmSME.td", - ], - includes = ["include"], - deps = [ - ":ArithOpsTdFiles", - ":FuncTdFiles", - ":LLVMOpsTdFiles", - ":OpBaseTdFiles", - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "ArmSMETransformsPassIncGen", - tbl_outs = [ - ( - [ - "-gen-pass-decls", - "-name=ArmSME", - ], - "include/mlir/Dialect/ArmSME/Transforms/Passes.h.inc", - ), - ( - ["-gen-enum-decls"], - "include/mlir/Dialect/ArmSME/Transforms/PassesEnums.h.inc", - ), - ( - ["-gen-enum-defs"], - "include/mlir/Dialect/ArmSME/Transforms/PassesEnums.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/ArmSME/Transforms/Passes.td", - deps = [ - ":OpBaseTdFiles", - ":PassBaseTdFiles", - ], -) - -gentbl_cc_library( - name = "ArmSMEIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/ArmSME/IR/ArmSME.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/ArmSME/IR/ArmSME.cpp.inc", - ), - ( - ["-gen-typedef-decls"], - "include/mlir/Dialect/ArmSME/IR/ArmSMETypes.h.inc", - ), - ( - ["-gen-typedef-defs"], - "include/mlir/Dialect/ArmSME/IR/ArmSMETypes.cpp.inc", - ), - ( - [ - "-gen-dialect-decls", - "-dialect=arm_sme", - ], - "include/mlir/Dialect/ArmSME/IR/ArmSMEDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=arm_sme", - ], - "include/mlir/Dialect/ArmSME/IR/ArmSMEDialect.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/ArmSME/IR/ArmSME.td", - deps = [":ArmSMETdFiles"], -) - -gentbl_cc_library( - name = "ArmSMEOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/ArmSME/IR/ArmSMEOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/ArmSME/IR/ArmSMEOps.cpp.inc", - ), - ( - ["-gen-enum-decls"], - "include/mlir/Dialect/ArmSME/IR/ArmSMEEnums.h.inc", - ), - ( - ["-gen-enum-defs"], - "include/mlir/Dialect/ArmSME/IR/ArmSMEEnums.cpp.inc", - ), - ( - [ - "-gen-attrdef-decls", - "-attrdefs-dialect=arm_sme", - ], - "include/mlir/Dialect/ArmSME/IR/ArmSMEAttrDefs.h.inc", - ), - ( - [ - "-gen-attrdef-defs", - "-attrdefs-dialect=arm_sme", - ], - "include/mlir/Dialect/ArmSME/IR/ArmSMEAttrDefs.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/ArmSME/IR/ArmSMEOps.td", - deps = [":ArmSMETdFiles"], -) - -gentbl_cc_library( - name = "ArmSMEConversionIncGen", - tbl_outs = [ - ( - ["-gen-llvmir-conversions"], - "include/mlir/Dialect/ArmSME/IR/ArmSMEOpsConversions.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/ArmSME/IR/ArmSMEOps.td", - deps = [":ArmSMETdFiles"], -) - -gentbl_cc_library( - name = "ArmSMEOpInterfacesIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Dialect/ArmSME/IR/ArmSMEOpInterfaces.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Dialect/ArmSME/IR/ArmSMEOpInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/ArmSME/IR/ArmSMEOps.td", - deps = [":ArmSMETdFiles"], -) - -gentbl_cc_library( - name = "ArmSMEIntrinsicOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/ArmSME/IR/ArmSMEIntrinsicOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/ArmSME/IR/ArmSMEIntrinsicOps.cpp.inc", - ), - ( - ["-gen-llvmir-conversions"], - "include/mlir/Dialect/ArmSME/IR/ArmSMEIntrinsicConversions.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/ArmSME/IR/ArmSMEIntrinsicOps.td", - deps = [":ArmSMETdFiles"], -) - -cc_library( - name = "ArmSMEEnums", - hdrs = [ - "include/mlir/Dialect/ArmSME/IR/ArmSMEEnums.h", - ], - deps = [ - ":ArmSMEIncGen", - ":ArmSMEOpsIncGen", - ":IR", - ], -) - -cc_library( - name = "ArmSMEDialect", - srcs = glob(["lib/Dialect/ArmSME/IR/*.cpp"]), - hdrs = [ - "include/mlir/Dialect/ArmSME/IR/ArmSME.h", - "include/mlir/Dialect/ArmSME/Utils/Utils.h", - ], - includes = ["include"], - deps = [ - ":ArmSMEEnums", - ":ArmSMEIncGen", - ":ArmSMEIntrinsicOpsIncGen", - ":ArmSMEOpInterfacesIncGen", - ":ArmSMEOpsIncGen", - ":IR", - ":LLVMDialect", - ":MemRefDialect", - ":SCFDialect", - ":SideEffectInterfaces", - ":VectorDialect", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "ArmSMETransforms", - srcs = glob(["lib/Dialect/ArmSME/Transforms/*.cpp"]), - hdrs = glob(["include/mlir/Dialect/ArmSME/Transforms/*.h"]), - includes = ["include"], - deps = [ - ":ArithDialect", - ":ArithUtils", - ":ArmSMEDialect", - ":ArmSMETransformsPassIncGen", - ":ControlFlowDialect", - ":DialectUtils", - ":FuncDialect", - ":FuncTransforms", - ":IR", - ":LLVMCommonConversion", - ":LLVMDialect", - ":MemRefDialect", - ":Pass", - ":SCFDialect", - ":SCFTransforms", - ":Transforms", - ":VectorDialect", - "//llvm:Support", - ], -) - -cc_library( - name = "ArmSMEToSCF", - srcs = glob(["lib/Conversion/ArmSMEToSCF/*.cpp"]), - hdrs = glob(["include/mlir/Conversion/ArmSMEToSCF/*.h"]), - includes = ["include"], - deps = [ - ":ArithDialect", - ":ArmSMEDialect", - ":ConversionPassIncGen", - ":Pass", - ":SCFDialect", - ":Transforms", - ], -) - -cc_library( - name = "ArmSMEToLLVM", - srcs = glob(["lib/Conversion/ArmSMEToLLVM/*.cpp"]), - hdrs = glob(["include/mlir/Conversion/ArmSMEToLLVM/*.h"]), - includes = ["include"], - deps = [ - ":ArithDialect", - ":ArmSMEDialect", - ":ArmSMETransforms", - ":ConversionPassIncGen", - ":FuncDialect", - ":LLVMCommonConversion", - ":LLVMDialect", - ":MemRefDialect", - ":Pass", - ":Transforms", - ":VectorDialect", - ], -) - -##---------------------------------------------------------------------------## -# ArmSVE dialect. -##---------------------------------------------------------------------------## - -td_library( - name = "ArmSVETdFiles", - srcs = [ - "include/mlir/Dialect/ArmSVE/IR/ArmSVE.td", - ], - includes = ["include"], - deps = [ - ":ArithOpsTdFiles", - ":FuncTdFiles", - ":LLVMOpsTdFiles", - ":OpBaseTdFiles", - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "ArmSVEIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/ArmSVE/IR/ArmSVE.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/ArmSVE/IR/ArmSVE.cpp.inc", - ), - ( - ["-gen-typedef-decls"], - "include/mlir/Dialect/ArmSVE/IR/ArmSVETypes.h.inc", - ), - ( - ["-gen-typedef-defs"], - "include/mlir/Dialect/ArmSVE/IR/ArmSVETypes.cpp.inc", - ), - ( - [ - "-gen-dialect-decls", - "-dialect=arm_sve", - ], - "include/mlir/Dialect/ArmSVE/IR/ArmSVEDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=arm_sve", - ], - "include/mlir/Dialect/ArmSVE/IR/ArmSVEDialect.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/ArmSVE/IR/ArmSVE.td", - deps = [":ArmSVETdFiles"], -) - -cc_library( - name = "ArmSVEDialect", - srcs = ["lib/Dialect/ArmSVE/IR/ArmSVEDialect.cpp"], - hdrs = ["include/mlir/Dialect/ArmSVE/IR/ArmSVEDialect.h"], - includes = ["include"], - deps = [ - ":ArmSVEIncGen", - ":IR", - ":LLVMDialect", - ":SideEffectInterfaces", - ":VectorDialect", - "//llvm:Core", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "ArmSVEPassIncGen", - tbl_outs = [ - ( - [ - "-gen-pass-decls", - "-name=ArmSVE", - ], - "include/mlir/Dialect/ArmSVE/Transforms/Passes.h.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/ArmSVE/Transforms/Passes.td", - deps = [":PassBaseTdFiles"], -) - -cc_library( - name = "ArmSVETransforms", - srcs = glob(["lib/Dialect/ArmSVE/Transforms/*.cpp"]), - hdrs = glob(["include/mlir/Dialect/ArmSVE/Transforms/*.h"]), - includes = ["include"], - deps = [ - ":ArmSVEDialect", - ":ArmSVEPassIncGen", - ":DialectUtils", - ":FuncDialect", - ":IR", - ":LLVMCommonConversion", - ":LLVMDialect", - ":MemRefDialect", - ":Pass", - ":TransformUtils", - ":VectorDialect", - ], -) - -gentbl_cc_library( - name = "ArmSVEConversionIncGen", - tbl_outs = [ - ( - ["-gen-llvmir-conversions"], - "include/mlir/Dialect/ArmSVE/IR/ArmSVEConversions.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/ArmSVE/IR/ArmSVE.td", - deps = [":ArmSVETdFiles"], -) - -##---------------------------------------------------------------------------## -# AMX dialect. -##---------------------------------------------------------------------------## - -td_library( - name = "AMXTdFiles", - srcs = ["include/mlir/Dialect/AMX/AMX.td"], - includes = ["include"], - deps = [ - ":LLVMOpsTdFiles", - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "AMXIncGen", - tbl_outs = [ - ( - [ - "-gen-dialect-decls", - "-dialect=amx", - ], - "include/mlir/Dialect/AMX/AMXDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=amx", - ], - "include/mlir/Dialect/AMX/AMXDialect.cpp.inc", - ), - ( - ["-gen-op-decls"], - "include/mlir/Dialect/AMX/AMX.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/AMX/AMX.cpp.inc", - ), - ( - ["-gen-op-doc"], - "g3doc/Dialects/AMX/AMX.md", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/AMX/AMX.td", - deps = [":AMXTdFiles"], -) - -cc_library( - name = "AMXDialect", - srcs = ["lib/Dialect/AMX/IR/AMXDialect.cpp"], - hdrs = ["include/mlir/Dialect/AMX/AMXDialect.h"], - includes = ["include"], - deps = [ - ":AMXIncGen", - ":IR", - ":LLVMDialect", - ":SideEffectInterfaces", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "AMXTransforms", - srcs = glob(["lib/Dialect/AMX/Transforms/*.cpp"]), - hdrs = ["include/mlir/Dialect/AMX/Transforms.h"], - includes = ["include"], - deps = [ - ":AMXDialect", - ":FuncDialect", - ":IR", - ":LLVMCommonConversion", - ":LLVMDialect", - "//llvm:Core", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "AMXConversionIncGen", - tbl_outs = [ - ( - ["-gen-llvmir-conversions"], - "include/mlir/Dialect/AMX/AMXConversions.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/AMX/AMX.td", - deps = [":AMXTdFiles"], -) - -##---------------------------------------------------------------------------## -# X86Vector dialect. -##---------------------------------------------------------------------------## - -td_library( - name = "X86VectorTdFiles", - srcs = ["include/mlir/Dialect/X86Vector/X86Vector.td"], - includes = ["include"], - deps = [ - ":InferTypeOpInterfaceTdFiles", - ":LLVMOpsTdFiles", - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "X86VectorIncGen", - tbl_outs = [ - ( - [ - "-gen-dialect-decls", - "-dialect=x86vector", - ], - "include/mlir/Dialect/X86Vector/X86VectorDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=x86vector", - ], - "include/mlir/Dialect/X86Vector/X86VectorDialect.cpp.inc", - ), - ( - ["-gen-op-decls"], - "include/mlir/Dialect/X86Vector/X86Vector.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/X86Vector/X86Vector.cpp.inc", - ), - ( - ["-gen-op-doc"], - "g3doc/Dialects/X86Vector/X86Vector.md", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/X86Vector/X86Vector.td", - deps = [":X86VectorTdFiles"], -) - -cc_library( - name = "X86VectorDialect", - srcs = ["lib/Dialect/X86Vector/IR/X86VectorDialect.cpp"], - hdrs = ["include/mlir/Dialect/X86Vector/X86VectorDialect.h"], - includes = ["include"], - deps = [ - ":IR", - ":InferTypeOpInterface", - ":LLVMDialect", - ":SideEffectInterfaces", - ":X86VectorIncGen", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "X86VectorTransforms", - srcs = glob(["lib/Dialect/X86Vector/Transforms/*.cpp"]), - hdrs = ["include/mlir/Dialect/X86Vector/Transforms.h"], - includes = ["include"], - deps = [ - ":ArithDialect", - ":FuncDialect", - ":IR", - ":LLVMCommonConversion", - ":LLVMDialect", - ":VectorDialect", - ":VectorUtils", - ":X86VectorDialect", - "//llvm:Core", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "X86VectorConversionIncGen", - tbl_outs = [ - ( - ["-gen-llvmir-conversions"], - "include/mlir/Dialect/X86Vector/X86VectorConversions.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/X86Vector/X86Vector.td", - deps = [":X86VectorTdFiles"], -) - -##---------------------------------------------------------------------------## -# IRDL dialect. -##---------------------------------------------------------------------------## - -td_library( - name = "IRDLTdFiles", - srcs = [ - "include/mlir/Dialect/IRDL/IR/IRDL.td", - "include/mlir/Dialect/IRDL/IR/IRDLAttributes.td", - "include/mlir/Dialect/IRDL/IR/IRDLInterfaces.td", - "include/mlir/Dialect/IRDL/IR/IRDLOps.td", - "include/mlir/Dialect/IRDL/IR/IRDLTypes.td", - ], - includes = ["include"], - deps = [ - ":InferTypeOpInterfaceTdFiles", - ":OpBaseTdFiles", - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "IRDLIncGen", - tbl_outs = [ - ( - ["-gen-dialect-decls"], - "include/mlir/Dialect/IRDL/IR/IRDLDialect.h.inc", - ), - ( - ["-gen-dialect-defs"], - "include/mlir/Dialect/IRDL/IR/IRDLDialect.cpp.inc", - ), - ( - ["-gen-op-decls"], - "include/mlir/Dialect/IRDL/IR/IRDL.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/IRDL/IR/IRDL.cpp.inc", - ), - ( - ["-gen-typedef-decls"], - "include/mlir/Dialect/IRDL/IR/IRDLTypes.h.inc", - ), - ( - ["-gen-typedef-defs"], - "include/mlir/Dialect/IRDL/IR/IRDLTypes.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/IRDL/IR/IRDLOps.td", - deps = [":IRDLTdFiles"], -) - -gentbl_cc_library( - name = "IRDLInterfacesIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Dialect/IRDL/IR/IRDLInterfaces.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Dialect/IRDL/IR/IRDLInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/IRDL/IR/IRDLInterfaces.td", - deps = [":IRDLTdFiles"], -) - -gentbl_cc_library( - name = "IRDLAttributesIncGen", - tbl_outs = [ - ( - ["-gen-attrdef-decls"], - "include/mlir/Dialect/IRDL/IR/IRDLAttributes.h.inc", - ), - ( - ["-gen-attrdef-defs"], - "include/mlir/Dialect/IRDL/IR/IRDLAttributes.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/IRDL/IR/IRDLAttributes.td", - deps = [":IRDLTdFiles"], -) - -gentbl_cc_library( - name = "IRDLEnumsIncGen", - tbl_outs = [ - ( - ["-gen-enum-decls"], - "include/mlir/Dialect/IRDL/IR/IRDLEnums.h.inc", - ), - ( - ["-gen-enum-defs"], - "include/mlir/Dialect/IRDL/IR/IRDLEnums.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/IRDL/IR/IRDLAttributes.td", - deps = [":IRDLTdFiles"], -) - -gentbl_cc_library( - name = "IRDLOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/IRDL/IR/IRDLOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/IRDL/IR/IRDLOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/IRDL/IR/IRDLOps.td", - deps = [":IRDLTdFiles"], -) - -gentbl_cc_library( - name = "IRDLTypesIncGen", - tbl_outs = [ - ( - ["-gen-typedef-decls"], - "include/mlir/Dialect/IRDL/IR/IRDLTypesGen.h.inc", - ), - ( - ["-gen-typedef-defs"], - "include/mlir/Dialect/IRDL/IR/IRDLTypesGen.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/IRDL/IR/IRDLTypes.td", - deps = [":IRDLTdFiles"], -) - -cc_library( - name = "IRDLDialect", - srcs = [ - "lib/Dialect/IRDL/IR/IRDL.cpp", - "lib/Dialect/IRDL/IR/IRDLOps.cpp", - "lib/Dialect/IRDL/IRDLLoading.cpp", - "lib/Dialect/IRDL/IRDLVerifiers.cpp", - ], - hdrs = [ - "include/mlir/Dialect/IRDL/IR/IRDL.h", - "include/mlir/Dialect/IRDL/IR/IRDLInterfaces.h", - "include/mlir/Dialect/IRDL/IR/IRDLTraits.h", - "include/mlir/Dialect/IRDL/IRDLLoading.h", - "include/mlir/Dialect/IRDL/IRDLVerifiers.h", - ], - includes = ["include"], - deps = [ - ":Dialect", - ":IR", - ":IRDLAttributesIncGen", - ":IRDLEnumsIncGen", - ":IRDLIncGen", - ":IRDLInterfacesIncGen", - ":IRDLOpsIncGen", - ":IRDLTypesIncGen", - ":InferTypeOpInterface", - ":Support", - "//llvm:Core", - "//llvm:Support", - ], -) - -##---------------------------------------------------------------------------## -# SCF dialect. -##---------------------------------------------------------------------------## - -td_library( - name = "SCFTdFiles", - srcs = [ - "include/mlir/Dialect/SCF/IR/DeviceMappingInterface.td", - "include/mlir/Dialect/SCF/IR/SCFOps.td", - ], - includes = ["include"], - deps = [ - ":ControlFlowInterfacesTdFiles", - ":DestinationStyleOpInterfaceTdFiles", - ":InferTypeOpInterfaceTdFiles", - ":LoopLikeInterfaceTdFiles", - ":ParallelCombiningOpInterfaceTdFiles", - ":SideEffectInterfacesTdFiles", - ":ViewLikeInterfaceTdFiles", - ], -) - -gentbl_cc_library( - name = "SCFIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/SCF/IR/SCFOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/SCF/IR/SCFOps.cpp.inc", - ), - ( - ["-gen-dialect-decls"], - "include/mlir/Dialect/SCF/IR/SCFOpsDialect.h.inc", - ), - ( - ["-gen-dialect-defs"], - "include/mlir/Dialect/SCF/IR/SCFOpsDialect.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/SCF/IR/SCFOps.td", - deps = [":SCFTdFiles"], -) - -gentbl_cc_library( - name = "SCFDeviceMappingInterfacesIncGen", - tbl_outs = [ - ( - ["-gen-attr-interface-decls"], - "include/mlir/Dialect/SCF/IR/DeviceMappingAttrInterface.h.inc", - ), - ( - ["-gen-attr-interface-defs"], - "include/mlir/Dialect/SCF/IR/DeviceMappingAttrInterface.cpp.inc", - ), - ( - ["-gen-attrdef-decls"], - "include/mlir/Dialect/SCF/IR/DeviceMappingAttributes.h.inc", - ), - ( - ["-gen-attrdef-defs"], - "include/mlir/Dialect/SCF/IR/DeviceMappingAttributes.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/SCF/IR/DeviceMappingInterface.td", - deps = [":SCFTdFiles"], -) - -gentbl_cc_library( - name = "SCFPassIncGen", - tbl_outs = [ - ( - [ - "-gen-pass-decls", - "-name=SCF", - ], - "include/mlir/Dialect/SCF/Transforms/Passes.h.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/SCF/Transforms/Passes.td", - deps = [":PassBaseTdFiles"], -) - -cc_library( - name = "SCFTransforms", - srcs = glob([ - "lib/Dialect/SCF/Transforms/*.cpp", - "lib/Dialect/SCF/Transforms/*.h", - ]), - hdrs = glob([ - "include/mlir/Dialect/SCF/Transforms/*.h", - ]), - includes = ["include"], - deps = [ - ":AffineAnalysis", - ":AffineDialect", - ":Analysis", - ":ArithDialect", - ":ArithUtils", - ":BufferizationDialect", - ":BufferizationTransforms", - ":DestinationStyleOpInterface", - ":DialectUtils", - ":FuncDialect", - ":IR", - ":LoopLikeInterface", - ":MemRefDialect", - ":Pass", - ":SCFDialect", - ":SCFPassIncGen", - ":SCFUtils", - ":SideEffectInterfaces", - ":Support", - ":TensorDialect", - ":TensorTransforms", - ":TilingInterface", - ":Transforms", - "//llvm:Support", - ], -) - -td_library( - name = "SCFTransformOpsTdFiles", - srcs = [ - "include/mlir/Dialect/SCF/TransformOps/SCFTransformOps.td", - ], - includes = ["include"], - deps = [ - ":PDLDialect", - ":TransformLoopExtensionTdFiles", - ], -) - -gentbl_cc_library( - name = "SCFTransformOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/SCF/TransformOps/SCFTransformOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/SCF/TransformOps/SCFTransformOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/SCF/TransformOps/SCFTransformOps.td", - deps = [ - ":SCFTransformOpsTdFiles", - ], -) - -cc_library( - name = "SCFTransformOps", - srcs = glob(["lib/Dialect/SCF/TransformOps/*.cpp"]), - hdrs = glob(["include/mlir/Dialect/SCF/TransformOps/*.h"]), - includes = ["include"], - deps = [ - ":AffineDialect", - ":AffineUtils", - ":ArithDialect", - ":ArithUtils", - ":DialectUtils", - ":FuncDialect", - ":IR", - ":LoopLikeInterface", - ":SCFDialect", - ":SCFTransformOpsIncGen", - ":SCFTransforms", - ":SCFUtils", - ":SideEffectInterfaces", - ":TransformDialect", - ":VectorDialect", - "//llvm:Support", - ], -) - -##---------------------------------------------------------------------------## -# SparseTensor dialect. -##---------------------------------------------------------------------------## - -td_library( - name = "SparseTensorTdFiles", - srcs = glob([ - "include/mlir/Dialect/SparseTensor/IR/*.td", - ]), - includes = ["include"], - deps = [ - ":InferTypeOpInterfaceTdFiles", - ":OpBaseTdFiles", - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "SparseTensorAttrDefsIncGen", - tbl_outs = [ - ( - ["--gen-attrdef-decls"], - "include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.h.inc", - ), - ( - ["--gen-attrdef-defs"], - "include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.cpp.inc", - ), - ( - ["--gen-enum-decls"], - "include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrEnums.h.inc", - ), - ( - ["--gen-enum-defs"], - "include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrEnums.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.td", - deps = [":SparseTensorTdFiles"], -) - -gentbl_cc_library( - name = "SparseTensorOpsIncGen", - tbl_outs = [ - ( - [ - "-gen-dialect-decls", - "-dialect=sparse_tensor", - ], - "include/mlir/Dialect/SparseTensor/IR/SparseTensorOpsDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=sparse_tensor", - ], - "include/mlir/Dialect/SparseTensor/IR/SparseTensorOpsDialect.cpp.inc", - ), - ( - ["-gen-op-decls"], - "include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.cpp.inc", - ), - ( - ["-gen-op-doc"], - "g3doc/Dialects/SparseTensor/SparseTensor.md", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td", - deps = [":SparseTensorTdFiles"], -) - -gentbl_cc_library( - name = "SparseTensorTypesIncGen", - tbl_outs = [ - ( - ["--gen-typedef-decls"], - "include/mlir/Dialect/SparseTensor/IR/SparseTensorTypes.h.inc", - ), - ( - ["--gen-typedef-defs"], - "include/mlir/Dialect/SparseTensor/IR/SparseTensorTypes.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/SparseTensor/IR/SparseTensorTypes.td", - deps = [":SparseTensorTdFiles"], -) - -gentbl_cc_library( - name = "SparseTensorPassIncGen", - tbl_outs = [ - ( - [ - "-gen-pass-decls", - "-name=SparseTensor", - ], - "include/mlir/Dialect/SparseTensor/Transforms/Passes.h.inc", - ), - ( - [ - "-gen-pass-capi-header", - "--prefix=SparseTensor", - ], - "include/mlir/Dialect/SparseTensor/Transforms/Passes.capi.h.inc", - ), - ( - [ - "-gen-pass-capi-impl", - "--prefix=SparseTensor", - ], - "include/mlir/Dialect/SparseTensor/Transforms/Passes.capi.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/SparseTensor/Transforms/Passes.td", - deps = [":PassBaseTdFiles"], -) - -gentbl_cc_library( - name = "SparseTensorInterfacesIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Dialect/SparseTensor/IR/SparseTensorInterfaces.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Dialect/SparseTensor/IR/SparseTensorInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/SparseTensor/IR/SparseTensorInterfaces.td", - deps = [":SparseTensorTdFiles"], -) - -td_library( - name = "SparseTensorTransformOpsTdFiles", - srcs = glob([ - "include/mlir/Dialect/SparseTensor/TransformOps/*.td", - ]), - includes = ["include"], - deps = [ - ":TransformDialectTdFiles", - ], -) - -gentbl_cc_library( - name = "SparseTensorTransformOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/SparseTensor/TransformOps/SparseTensorTransformOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/SparseTensor/TransformOps/SparseTensorTransformOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/SparseTensor/TransformOps/SparseTensorTransformOps.td", - deps = [ - ":SparseTensorTransformOpsTdFiles", - ], -) - -# This library is shared by both SparseTensorDialect and -# SparseTensorRuntime, so it must not depend on any of the MLIR/LLVM -# internals or else mlir_c_runner_utils will inherit that dependency. -cc_library( - name = "SparseTensorEnums", - hdrs = ["include/mlir/Dialect/SparseTensor/IR/Enums.h"], - includes = ["include"], -) - -cc_library( - name = "SparseTensorDialect", - srcs = glob([ - "lib/Dialect/SparseTensor/IR/*.cpp", - "lib/Dialect/SparseTensor/IR/Detail/*.cpp", - "lib/Dialect/SparseTensor/IR/Detail/*.h", - ]), - hdrs = [ - "include/mlir/Dialect/SparseTensor/IR/SparseTensor.h", - "include/mlir/Dialect/SparseTensor/IR/SparseTensorInterfaces.h", - "include/mlir/Dialect/SparseTensor/IR/SparseTensorStorageLayout.h", - "include/mlir/Dialect/SparseTensor/IR/SparseTensorType.h", - ], - includes = ["include"], - deps = [ - ":ArithDialect", - ":DialectUtils", - ":IR", - ":InferTypeOpInterface", - ":SparseTensorAttrDefsIncGen", - ":SparseTensorEnums", - ":SparseTensorInterfacesIncGen", - ":SparseTensorOpsIncGen", - ":SparseTensorTypesIncGen", - "//llvm:Support", - ], -) - -cc_library( - name = "SparseTensorTransformOps", - srcs = glob([ - "lib/Dialect/SparseTensor/TransformOps/*.cpp", - ]), - hdrs = glob([ - "include/mlir/Dialect/SparseTensor/TransformOps/*.h", - ]), - includes = ["include"], - deps = [ - ":IR", - ":LinalgDialect", - ":LinalgTransformOps", - ":SparseTensorDialect", - ":SparseTensorTransformOpsIncGen", - ":Support", - ":TransformDialect", - "//llvm:Support", - ], -) - -cc_library( - name = "SparseTensorUtils", - srcs = glob([ - "lib/Dialect/SparseTensor/Utils/*.cpp", - ]), - hdrs = glob([ - "include/mlir/Dialect/SparseTensor/Utils/*.h", - ]), - includes = ["include"], - deps = [ - ":ArithDialect", - ":ComplexDialect", - ":IR", - ":LinalgDialect", - ":MathDialect", - ":SparseTensorDialect", - ":SparseTensorEnums", - "//llvm:Support", - ], -) - -cc_library( - name = "SparseTensorTransforms", - srcs = glob([ - "lib/Dialect/SparseTensor/Transforms/*.cpp", - "lib/Dialect/SparseTensor/Transforms/*.h", - "lib/Dialect/SparseTensor/Transforms/Utils/*.cpp", - "lib/Dialect/SparseTensor/Transforms/Utils/*.h", - ]), - hdrs = [ - "include/mlir/Dialect/SparseTensor/Transforms/BufferizableOpInterfaceImpl.h", - "include/mlir/Dialect/SparseTensor/Transforms/Passes.h", - ], - includes = ["include"], - deps = [ - ":AffineDialect", - ":ArithDialect", - ":ArithUtils", - ":BufferizationDialect", - ":BufferizationTransforms", - ":ComplexDialect", - ":DialectUtils", - ":FuncDialect", - ":FuncTransforms", - ":GPUDialect", - ":IR", - ":LLVMCommonConversion", - ":LLVMDialect", - ":LinalgDialect", - ":LinalgTransforms", - ":LinalgUtils", - ":MathDialect", - ":MemRefDialect", - ":Pass", - ":SCFDialect", - ":SCFTransforms", - ":SparseTensorDialect", - ":SparseTensorEnums", - ":SparseTensorPassIncGen", - ":SparseTensorUtils", - ":Support", - ":TensorDialect", - ":Transforms", - ":VectorDialect", - "//llvm:Support", - ], -) - -cc_library( - name = "SparseTensorPipelines", - srcs = glob([ - "lib/Dialect/SparseTensor/Pipelines/*.cpp", - ]), - hdrs = [ - "include/mlir/Dialect/SparseTensor/Pipelines/Passes.h", - ], - includes = ["include"], - local_defines = if_cuda_available(["MLIR_GPU_TO_CUBIN_PASS_ENABLE"]), - deps = [ - ":ArithTransforms", - ":BufferizationTransforms", - ":ConversionPasses", - ":FuncDialect", - ":FuncTransforms", - ":GPUDialect", - ":GPUToNVVMTransforms", - ":GPUTransforms", - ":LinalgTransforms", - ":MemRefTransforms", - ":NVVMDialect", - ":Pass", - ":SparseTensorDialect", - ":SparseTensorTransforms", - ":TensorTransforms", - ":Transforms", - ":VectorToLLVM", - ":VectorTransforms", - ], -) - -##---------------------------------------------------------------------------## -# Mesh Dialect -##---------------------------------------------------------------------------## - -td_library( - name = "MeshTdFiles", - srcs = [ - "include/mlir/Dialect/Mesh/IR/MeshBase.td", - "include/mlir/Dialect/Mesh/IR/MeshOps.td", - ], - includes = ["include"], - deps = [ - ":BuiltinDialectTdFiles", - ":InferTypeOpInterfaceTdFiles", - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "MeshIncGen", - tbl_outs = [ - ( - [ - "-gen-op-decls", - "-dialect=mesh", - ], - "include/mlir/Dialect/Mesh/IR/MeshOps.h.inc", - ), - ( - [ - "-gen-op-defs", - "-dialect=mesh", - ], - "include/mlir/Dialect/Mesh/IR/MeshOps.cpp.inc", - ), - ( - [ - "-gen-dialect-decls", - "-dialect=mesh", - ], - "include/mlir/Dialect/Mesh/IR/MeshDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=mesh", - ], - "include/mlir/Dialect/Mesh/IR/MeshDialect.cpp.inc", - ), - ( - [ - "-gen-enum-decls", - "-dialect=mesh", - ], - "include/mlir/Dialect/Mesh/IR/MeshEnums.h.inc", - ), - ( - [ - "-gen-enum-defs", - "-dialect=mesh", - ], - "include/mlir/Dialect/Mesh/IR/MeshEnums.cpp.inc", - ), - ( - [ - "-gen-attrdef-decls", - "-dialect=mesh", - ], - "include/mlir/Dialect/Mesh/IR/MeshAttributes.h.inc", - ), - ( - [ - "-gen-attrdef-defs", - "-dialect=mesh", - ], - "include/mlir/Dialect/Mesh/IR/MeshAttributes.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Mesh/IR/MeshOps.td", - deps = [ - ":MeshTdFiles", - ":ShapeOpsTdFiles", - ], -) - -gentbl_cc_library( - name = "MeshShardingInterfaceIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Dialect/Mesh/Interfaces/ShardingInterface.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Dialect/Mesh/Interfaces/ShardingInterface.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Mesh/Interfaces/ShardingInterface.td", - deps = [":OpBaseTdFiles"], -) - -cc_library( - name = "MeshShardingInterface", - srcs = ["lib/Dialect/Mesh/Interfaces/ShardingInterface.cpp"], - hdrs = [ - "include/mlir/Dialect/Mesh/Interfaces/ShardingInterface.h", - "include/mlir/Dialect/Mesh/Interfaces/ShardingInterfaceImpl.h", - ], - includes = ["include"], - deps = [ - ":DialectUtils", - ":IR", - ":MeshDialect", - ":MeshShardingInterfaceIncGen", - ":Support", - "//llvm:Support", - ], -) - -cc_library( - name = "MeshDialect", - srcs = ["lib/Dialect/Mesh/IR/MeshOps.cpp"], - hdrs = [ - "include/mlir/Dialect/Mesh/IR/MeshDialect.h", - "include/mlir/Dialect/Mesh/IR/MeshOps.h", - ], - includes = ["include"], - deps = [ - ":ArithDialect", - ":DialectUtils", - ":IR", - ":InferTypeOpInterface", - ":MeshIncGen", - ":Support", - ":ViewLikeInterface", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "MeshTransformsPassIncGen", - tbl_outs = [ - ( - [ - "-gen-pass-decls", - "-name=Mesh", - ], - "include/mlir/Dialect/Mesh/Transforms/Passes.h.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Mesh/Transforms/Passes.td", - deps = [":PassBaseTdFiles"], -) - -cc_library( - name = "MeshTransforms", - srcs = glob([ - "lib/Dialect/Mesh/Transforms/*.cpp", - "lib/Dialect/Mesh/Transforms/*.h", - ]), - hdrs = glob(["include/mlir/Dialect/Mesh/Transforms/*.h"]), - includes = ["include"], - deps = [ - ":AffineDialect", - ":AffineUtils", - ":ArithDialect", - ":ArithUtils", - ":ControlFlowDialect", - ":ControlFlowInterfaces", - ":DialectUtils", - ":FuncDialect", - ":FunctionInterfaces", - ":IR", - ":MeshDialect", - ":MeshShardingInterface", - ":MeshTransformsPassIncGen", - ":Pass", - ":Support", - ":TensorDialect", - ":TransformUtils", - "//llvm:Support", - ], -) - -##---------------------------------------------------------------------------## -# NVGPU dialect. -##---------------------------------------------------------------------------## - -td_library( - name = "NVGPUTdFiles", - srcs = ["include/mlir/Dialect/NVGPU/IR/NVGPU.td"], - includes = ["include"], - deps = [ - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "NVGPUIncGen", - tbl_outs = [ - ( - [ - "-gen-dialect-decls", - "-dialect=nvgpu", - ], - "include/mlir/Dialect/NVGPU/IR/NVGPUDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=nvgpu", - ], - "include/mlir/Dialect/NVGPU/IR/NVGPUDialect.cpp.inc", - ), - ( - ["-gen-op-decls"], - "include/mlir/Dialect/NVGPU/IR/NVGPU.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/NVGPU/IR/NVGPU.cpp.inc", - ), - ( - ["-gen-op-doc"], - "g3doc/Dialects/NVGPU/NVGPU.md", - ), - ( - ["-gen-typedef-decls"], - "include/mlir/Dialect/NVGPU/IR/NVGPUTypes.h.inc", - ), - ( - ["-gen-typedef-defs"], - "include/mlir/Dialect/NVGPU/IR/NVGPUTypes.cpp.inc", - ), - ( - ["-gen-enum-decls"], - "include/mlir/Dialect/NVGPU/IR/NVGPUEnums.h.inc", - ), - ( - ["-gen-enum-defs"], - "include/mlir/Dialect/NVGPU/IR/NVGPUEnums.cpp.inc", - ), - ( - ["-gen-attrdef-decls"], - "include/mlir/Dialect/NVGPU/IR/NVGPUAttrDefs.h.inc", - ), - ( - ["-gen-attrdef-defs"], - "include/mlir/Dialect/NVGPU/IR/NVGPUAttrDefs.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/NVGPU/IR/NVGPU.td", - deps = [":NVGPUTdFiles"], -) - -gentbl_cc_library( - name = "NVGPUPassIncGen", - tbl_outs = [ - ( - [ - "-gen-pass-decls", - "-name=NVGPU", - ], - "include/mlir/Dialect/NVGPU/Transforms/Passes.h.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/NVGPU/Transforms/Passes.td", - deps = [":PassBaseTdFiles"], -) - -cc_library( - name = "NVGPUDialect", - srcs = ["lib/Dialect/NVGPU/IR/NVGPUDialect.cpp"], - hdrs = ["include/mlir/Dialect/NVGPU/IR/NVGPUDialect.h"], - includes = ["include"], - deps = [ - ":GPUDialect", - ":IR", - ":LLVMDialect", - ":NVGPUIncGen", - ":SideEffectInterfaces", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "NVGPUTransformOps", - srcs = glob([ - "lib/Dialect/NVGPU/TransformOps/*.cpp", - ]), - hdrs = glob([ - "include/mlir/Dialect/NVGPU/TransformOps/*.h", - ]), - includes = ["include"], - deps = [ - ":AffineDialect", - ":Analysis", - ":ArithDialect", - ":ArithUtils", - ":DialectUtils", - ":GPUCommonTransforms", - ":GPUCompilationAttrInterfacesIncGen", - ":GPUDialect", - ":IR", - ":LLVMCommonConversion", - ":LinalgDialect", - ":MemRefDialect", - ":NVGPUDialect", - ":NVGPUToNVVM", - ":NVGPUTransformOpsIncGen", - ":NVGPUTransforms", - ":NVVMDialect", - ":SCFDialect", - ":SCFTransforms", - ":Support", - ":TransformDialect", - ":VectorDialect", - "//llvm:Support", - ], -) - -td_library( - name = "NVGPUTransformOpsTdFiles", - srcs = glob([ - "include/mlir/Dialect/NVGPU/TransformOps/*.td", - ]), - includes = ["include"], - deps = [ - ":TransformDialectTdFiles", - ], -) - -gentbl_cc_library( - name = "NVGPUTransformOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/NVGPU/TransformOps/NVGPUTransformOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/NVGPU/TransformOps/NVGPUTransformOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/NVGPU/TransformOps/NVGPUTransformOps.td", - deps = [ - ":NVGPUTransformOpsTdFiles", - ], -) - -cc_library( - name = "NVGPUUtils", - srcs = ["lib/Dialect/NVGPU/Utils/MMAUtils.cpp"], - hdrs = ["include/mlir/Dialect/NVGPU/Utils/MMAUtils.h"], - includes = ["include"], - deps = [ - ":AffineDialect", - ":ArithDialect", - ":IR", - ":NVGPUDialect", - ":NVVMDialect", - ":VectorDialect", - ], -) - -cc_library( - name = "NVGPUTransforms", - srcs = glob([ - "lib/Dialect/NVGPU/Transforms/*.cpp", - ]), - hdrs = glob([ - "include/mlir/Dialect/NVGPU/Transforms/*.h", - ]), - includes = ["include"], - deps = [ - ":AffineDialect", - ":ArithDialect", - ":FuncDialect", - ":GPUDialect", - ":IR", - ":MemRefDialect", - ":NVGPUDialect", - ":NVGPUPassIncGen", - ":Pass", - ":SideEffectInterfaces", - ":Support", - ":Transforms", - ":VectorDialect", - "//llvm:Core", - "//llvm:Support", - ], -) - -##---------------------------------------------------------------------------## -# XeGPU dialect. -##---------------------------------------------------------------------------## - -td_library( - name = "XeGPUTdFiles", - srcs = glob(["include/mlir/Dialect/XeGPU/IR/*.td"]), - includes = ["include"], - deps = [ - ":BuiltinDialectTdFiles", - ":OpBaseTdFiles", - ], -) - -gentbl_cc_library( - name = "XeGPUIncGen", - tbl_outs = [ - ( - [ - "-gen-dialect-decls", - "-dialect=xegpu", - ], - "include/mlir/Dialect/XeGPU/IR/XeGPUDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=xegpu", - ], - "include/mlir/Dialect/XeGPU/IR/XeGPUDialect.cpp.inc", - ), - ( - ["-gen-op-decls"], - "include/mlir/Dialect/XeGPU/IR/XeGPU.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/XeGPU/IR/XeGPU.cpp.inc", - ), - ( - ["-gen-op-doc"], - "g3doc/Dialects/XeGPU/XeGPU.md", - ), - ( - [ - "-gen-typedef-decls", - "-typedefs-dialect=xegpu", - ], - "include/mlir/Dialect/XeGPU/IR/XeGPUTypes.h.inc", - ), - ( - [ - "-gen-typedef-defs", - "-typedefs-dialect=xegpu", - ], - "include/mlir/Dialect/XeGPU/IR/XeGPUTypes.cpp.inc", - ), - ( - ["-gen-enum-decls"], - "include/mlir/Dialect/XeGPU/IR/XeGPUEnums.h.inc", - ), - ( - ["-gen-enum-defs"], - "include/mlir/Dialect/XeGPU/IR/XeGPUEnums.cpp.inc", - ), - ( - [ - "-gen-attrdef-decls", - "-attrdefs-dialect=xegpu", - ], - "include/mlir/Dialect/XeGPU/IR/XeGPUAttrs.h.inc", - ), - ( - [ - "-gen-attrdef-defs", - "-attrdefs-dialect=xegpu", - ], - "include/mlir/Dialect/XeGPU/IR/XeGPUAttrs.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/XeGPU/IR/XeGPU.td", - deps = [":XeGPUTdFiles"], -) - -cc_library( - name = "XeGPUDialect", - srcs = [ - "lib/Dialect/XeGPU/IR/XeGPUDialect.cpp", - "lib/Dialect/XeGPU/IR/XeGPUOps.cpp", - ], - hdrs = ["include/mlir/Dialect/XeGPU/IR/XeGPU.h"], - includes = ["include"], - deps = [ - ":IR", - ":XeGPUIncGen", - "//llvm:Core", - "//llvm:Support", - ], -) - -td_library( - name = "FuncTdFiles", - srcs = [ - "include/mlir/Dialect/Func/IR/FuncOps.td", - ], - includes = ["include"], - deps = [ - ":AttrTdFiles", - ":CallInterfacesTdFiles", - ":CastInterfacesTdFiles", - ":ControlFlowInterfacesTdFiles", - ":FunctionInterfacesTdFiles", - ":InferTypeOpInterfaceTdFiles", - ":OpBaseTdFiles", - ":SideEffectInterfacesTdFiles", - ":VectorInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "FuncIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/Func/IR/FuncOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/Func/IR/FuncOps.cpp.inc", - ), - ( - ["-gen-dialect-decls"], - "include/mlir/Dialect/Func/IR/FuncOpsDialect.h.inc", - ), - ( - ["-gen-dialect-defs"], - "include/mlir/Dialect/Func/IR/FuncOpsDialect.cpp.inc", - ), - ( - ["-gen-enum-decls"], - "include/mlir/Dialect/Func/IR/FuncOpsEnums.h.inc", - ), - ( - ["-gen-enum-defs"], - "include/mlir/Dialect/Func/IR/FuncOpsEnums.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Func/IR/FuncOps.td", - deps = [":FuncTdFiles"], -) - -cc_library( - name = "Dialect", - srcs = glob([ - "lib/Dialect/*.cpp", - "lib/Dialect/*.h", - ]), - hdrs = glob([ - "include/mlir/Dialect/*.h", - ]), - includes = ["include"], - deps = [ - ":IR", - "//llvm:Support", - ], -) - -td_library( - name = "DialectUtilsTdFiles", - srcs = [ - "include/mlir/Dialect/Utils/StructuredOpsUtils.td", - ], - includes = ["include"], - deps = [":OpBaseTdFiles"], -) - -gentbl_cc_library( - name = "DialectUtilsIncGen", - tbl_outs = [ - ( - ["-gen-enum-decls"], - "include/mlir/Dialect/Utils/DialectUtilsEnums.h.inc", - ), - ( - ["-gen-enum-defs"], - "include/mlir/Dialect/Utils/DialectUtilsEnums.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Utils/StructuredOpsUtils.td", - deps = [":DialectUtilsTdFiles"], -) - -cc_library( - name = "DialectUtils", - srcs = glob([ - "lib/Dialect/Utils/*.cpp", - "lib/Dialect/Utils/*.h", - ]), - hdrs = glob([ - "include/mlir/Dialect/Utils/*.h", - ]), - includes = ["include"], - deps = [ - ":ArithUtils", - ":DialectUtilsIncGen", - ":IR", - ":Support", - "//llvm:Support", - ], -) - -cc_library( - name = "AffineDialect", - srcs = glob([ - "lib/Dialect/Affine/IR/*.cpp", - "lib/Dialect/Affine/IR/*.h", - ]), - hdrs = glob([ - "include/mlir/Dialect/Affine/IR/*.h", - ]), - includes = ["include"], - deps = [ - ":AffineMemoryOpInterfacesIncGen", - ":AffineOpsIncGen", - ":ArithDialect", - ":ControlFlowInterfaces", - ":DialectUtils", - ":IR", - ":LoopLikeInterface", - ":MemRefDialect", - ":ShapedOpInterfaces", - ":SideEffectInterfaces", - ":Support", - ":UBDialect", - ":ValueBoundsOpInterface", - "//llvm:Support", - ], -) - -cc_library( - name = "EmitCDialect", - srcs = glob([ - "lib/Dialect/EmitC/IR/*.cpp", - ]), - hdrs = glob([ - "include/mlir/Dialect/EmitC/IR/*.h", - ]), - includes = ["include"], - deps = [ - ":CallOpInterfaces", - ":CastInterfaces", - ":ControlFlowInterfaces", - ":EmitCAttributesIncGen", - ":EmitCOpsIncGen", - ":FunctionInterfaces", - ":IR", - ":SideEffectInterfaces", - "//llvm:Support", - ], -) - -cc_library( - name = "EmitCTransforms", - srcs = glob([ - "lib/Dialect/EmitC/Transforms/*.cpp", - ]), - hdrs = glob([ - "include/mlir/Dialect/EmitC/Transforms/*.h", - ]), - includes = ["include"], - deps = [ - ":EmitCDialect", - ":EmitCPassIncGen", - ":IR", - ":Pass", - ":TransformUtils", - "//llvm:Support", - ], -) - -cc_library( - name = "AsyncDialect", - srcs = glob([ - "lib/Dialect/Async/IR/*.cpp", - ]), - hdrs = glob([ - "include/mlir/Dialect/Async/IR/*.h", - ]), - includes = ["include"], - deps = [ - ":AsyncOpsIncGen", - ":ControlFlowInterfaces", - ":FunctionInterfaces", - ":IR", - ":InferTypeOpInterface", - ":SideEffectInterfaces", - "//llvm:Support", - ], -) - -cc_library( - name = "AsyncTransforms", - srcs = glob([ - "lib/Dialect/Async/Transforms/*.cpp", - "lib/Dialect/Async/Transforms/*.h", - ]), - hdrs = [ - "include/mlir/Dialect/Async/Passes.h", - "include/mlir/Dialect/Async/Transforms.h", - ], - includes = ["include"], - deps = [ - ":Analysis", - ":ArithDialect", - ":AsyncDialect", - ":AsyncPassIncGen", - ":ControlFlowDialect", - ":FuncDialect", - ":IR", - ":Pass", - ":SCFDialect", - ":SCFToControlFlow", - ":Support", - ":TransformUtils", - ":Transforms", - ":TransformsPassIncGen", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "AffineAnalysis", - srcs = glob([ - "lib/Dialect/Affine/Analysis/*.cpp", - "lib/Dialect/Affine/Analysis/*.h", - ]), - hdrs = glob(["include/mlir/Dialect/Affine/Analysis/*.h"]), - includes = ["include"], - deps = [ - ":AffineDialect", - ":Analysis", - ":ArithDialect", - ":DialectUtils", - ":FuncDialect", - ":IR", - ":SideEffectInterfaces", - ":Support", - ":ViewLikeInterface", - "//llvm:Support", - ], -) - -cc_library( - name = "AffineUtils", - srcs = glob( - [ - "lib/Dialect/Affine/Utils/*.cpp", - "lib/Dialect/Affine/Utils/*.h", - ], - ), - hdrs = [ - "include/mlir/Dialect/Affine/LoopFusionUtils.h", - "include/mlir/Dialect/Affine/LoopUtils.h", - "include/mlir/Dialect/Affine/Utils.h", - "include/mlir/Dialect/Affine/ViewLikeInterfaceUtils.h", - ], - includes = ["include"], - deps = [ - ":AffineAnalysis", - ":AffineDialect", - ":Analysis", - ":ArithUtils", - ":DialectUtils", - ":FuncDialect", - ":IR", - ":MemRefDialect", - ":SCFDialect", - ":Support", - ":TransformUtils", - ":ViewLikeInterface", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "AffinePassIncGen", - tbl_outs = [ - ( - [ - "-gen-pass-decls", - "-name=Affine", - ], - "include/mlir/Dialect/Affine/Passes.h.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Affine/Passes.td", - deps = [":PassBaseTdFiles"], -) - -cc_library( - name = "AffineTransforms", - srcs = glob([ - "lib/Dialect/Affine/Transforms/*.cpp", - "lib/Dialect/Affine/Transforms/*.h", - ]), - hdrs = [ - "include/mlir/Dialect/Affine/Passes.h", - "include/mlir/Dialect/Affine/Transforms/Transforms.h", - ], - includes = ["include"], - deps = [ - ":AffineAnalysis", - ":AffineDialect", - ":AffinePassIncGen", - ":AffineUtils", - ":Analysis", - ":ArithDialect", - ":ArithUtils", - ":FuncDialect", - ":IR", - ":MemRefDialect", - ":Pass", - ":SCFDialect", - ":SCFUtils", - ":Support", - ":TensorDialect", - ":Transforms", - ":ValueBoundsOpInterface", - ":VectorDialect", - ":VectorUtils", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "ConversionPassIncGen", - tbl_outs = [ - ( - [ - "-gen-pass-decls", - "-name=Conversion", - ], - "include/mlir/Conversion/Passes.h.inc", - ), - ( - [ - "-gen-pass-capi-header", - "--prefix=Conversion", - ], - "include/mlir/Conversion/Passes.capi.h.inc", - ), - ( - [ - "-gen-pass-capi-impl", - "--prefix=Conversion", - ], - "include/mlir/Conversion/Passes.capi.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Conversion/Passes.td", - deps = [":PassBaseTdFiles"], -) - -cc_library( - name = "ConversionPasses", - hdrs = ["include/mlir/Conversion/Passes.h"], - includes = ["include"], - deps = [ - ":AMDGPUToROCDL", - ":AffineToStandard", - ":ArithToAMDGPU", - ":ArithToArmSME", - ":ArithToEmitC", - ":ArithToLLVM", - ":ArithToSPIRV", - ":ArmNeon2dToIntr", - ":ArmSMEToLLVM", - ":ArmSMEToSCF", - ":AsyncToLLVM", - ":BufferizationToMemRef", - ":ComplexToLLVM", - ":ComplexToLibm", - ":ComplexToSPIRV", - ":ComplexToStandard", - ":ControlFlowToLLVM", - ":ControlFlowToSCF", - ":ControlFlowToSPIRV", - ":ConversionPassIncGen", - ":ConvertToLLVM", - ":FuncToEmitC", - ":FuncToLLVM", - ":FuncToSPIRV", - ":GPUToGPURuntimeTransforms", - ":GPUToNVVMTransforms", - ":GPUToROCDLTransforms", - ":GPUToSPIRV", - ":GPUToVulkanTransforms", - ":IndexToLLVM", - ":IndexToSPIRV", - ":LinalgToStandard", - ":MathToFuncs", - ":MathToLLVM", - ":MathToLibm", - ":MathToSPIRV", - ":MemRefToLLVM", - ":MemRefToSPIRV", - ":NVGPUToNVVM", - ":NVVMToLLVM", - ":OpenACCToLLVM", - ":OpenACCToSCF", - ":OpenMPToLLVM", - ":PDLToPDLInterp", - ":ReconcileUnrealizedCasts", - ":SCFToControlFlow", - ":SCFToEmitC", - ":SCFToGPU", - ":SCFToOpenMP", - ":SCFToSPIRV", - ":SPIRVToLLVM", - ":ShapeToStandard", - ":TensorToLinalg", - ":TensorToSPIRV", - ":TosaToArith", - ":TosaToLinalg", - ":TosaToMLProgram", - ":TosaToSCF", - ":TosaToTensor", - ":UBToLLVM", - ":UBToSPIRV", - ":VectorToArmSME", - ":VectorToGPU", - ":VectorToLLVM", - ":VectorToSCF", - ":VectorToSPIRV", - ], -) - -cc_library( - name = "AsyncToLLVM", - srcs = glob([ - "lib/Conversion/AsyncToLLVM/*.cpp", - "lib/Conversion/AsyncToLLVM/*.h", - ]), - hdrs = glob(["include/mlir/Conversion/AsyncToLLVM/*.h"]), - includes = ["include"], - deps = [ - ":ArithDialect", - ":AsyncDialect", - ":ConversionPassIncGen", - ":ConvertToLLVMInterface", - ":FuncDialect", - ":FuncToLLVM", - ":FuncTransforms", - ":IR", - ":LLVMCommonConversion", - ":LLVMDialect", - ":Pass", - ":Support", - ":Transforms", - "//llvm:Support", - ], -) - -cc_library( - name = "AffineToStandard", - srcs = glob([ - "lib/Conversion/AffineToStandard/*.cpp", - "lib/Conversion/AffineToStandard/*.h", - ]), - hdrs = glob(["include/mlir/Conversion/AffineToStandard/*.h"]), - includes = ["include"], - deps = [ - ":AffineDialect", - ":AffineTransforms", - ":AffineUtils", - ":ArithDialect", - ":ConversionPassIncGen", - ":FuncDialect", - ":IR", - ":MemRefDialect", - ":Pass", - ":SCFDialect", - ":Support", - ":Transforms", - ":VectorDialect", - ], -) - -# SDBM dialect only contains attribute components that can be constructed given -# a dialect object, so whenever it is used it must also be registered. Therefore -# we don't split out the registration library for it. -cc_library( - name = "SDBM", - srcs = glob([ - "lib/Dialect/SDBM/*.cpp", - "lib/Dialect/SDBM/*.h", - ]), - hdrs = glob([ - "include/mlir/Dialect/SDBM/*.h", - ]), - includes = ["include"], - deps = [ - ":IR", - ":Support", - "//llvm:Support", - ], -) - -cc_library( - name = "SCFDialect", - srcs = glob( - [ - "lib/Dialect/SCF/IR/*.cpp", - "lib/Dialect/SCF/IR/*.h", - ], - ), - hdrs = glob( - [ - "include/mlir/Dialect/SCF/IR/*.h", - ], - ), - includes = ["include"], - deps = [ - ":ArithDialect", - ":ArithUtils", - ":ControlFlowDialect", - ":ControlFlowInterfaces", - ":DestinationStyleOpInterface", - ":FuncDialect", - ":FunctionInterfaces", - ":IR", - ":InferTypeOpInterface", - ":LoopLikeInterface", - ":MemRefDialect", - ":ParallelCombiningOpInterface", - ":Pass", - ":SCFDeviceMappingInterfacesIncGen", - ":SCFIncGen", - ":SCFPassIncGen", - ":Support", - ":TensorDialect", - ":ValueBoundsOpInterface", - ":ViewLikeInterface", - "//llvm:Support", - ], -) - -cc_library( - name = "SCFUtils", - srcs = glob( - [ - "lib/Dialect/SCF/Utils/*.cpp", - ], - ), - hdrs = glob( - [ - "include/mlir/Dialect/SCF/Utils/*.h", - ], - ), - includes = ["include"], - deps = [ - ":AffineAnalysis", - ":AffineDialect", - ":Analysis", - ":ArithDialect", - ":DialectUtils", - ":FuncDialect", - ":IR", - ":SCFDialect", - ":SideEffectInterfaces", - ":Support", - ":Transforms", - "//llvm:Support", - ], -) - -cc_library( - name = "InferIntRangeCommon", - srcs = [ - "lib/Interfaces/Utils/InferIntRangeCommon.cpp", - ], - hdrs = ["include/mlir/Interfaces/Utils/InferIntRangeCommon.h"], - includes = ["include"], - deps = [ - ":IR", - ":InferIntRangeInterface", - "//llvm:Support", - ], -) - -cc_library( - name = "DataLayoutInterfaces", - srcs = ["lib/Interfaces/DataLayoutInterfaces.cpp"], - hdrs = ["include/mlir/Interfaces/DataLayoutInterfaces.h"], - includes = ["include"], - deps = [ - ":DataLayoutInterfacesIncGen", - ":IR", - "//llvm:Support", - ], -) - -cc_library( - name = "LoopLikeInterface", - srcs = ["lib/Interfaces/LoopLikeInterface.cpp"], - hdrs = ["include/mlir/Interfaces/LoopLikeInterface.h"], - includes = ["include"], - deps = [ - ":FunctionInterfaces", - ":IR", - ":LoopLikeInterfaceIncGen", - "//llvm:Support", - ], -) - -cc_library( - name = "MemorySlotInterfaces", - srcs = ["lib/Interfaces/MemorySlotInterfaces.cpp"], - hdrs = ["include/mlir/Interfaces/MemorySlotInterfaces.h"], - includes = ["include"], - deps = [ - ":IR", - ":MemorySlotInterfacesIncGen", - "//llvm:Support", - ], -) - -cc_library( - name = "ShapedOpInterfaces", - srcs = ["lib/Interfaces/ShapedOpInterfaces.cpp"], - hdrs = ["include/mlir/Interfaces/ShapedOpInterfaces.h"], - includes = ["include"], - deps = [ - ":IR", - ":ShapedOpInterfacesIncGen", - "//llvm:Support", - ], -) - -cc_library( - name = "ParallelCombiningOpInterface", - srcs = ["lib/Interfaces/ParallelCombiningOpInterface.cpp"], - hdrs = ["include/mlir/Interfaces/ParallelCombiningOpInterface.h"], - includes = ["include"], - deps = [ - ":IR", - ":ParallelCombiningOpInterfaceIncGen", - "//llvm:Support", - ], -) - -cc_library( - name = "RuntimeVerifiableOpInterface", - srcs = ["lib/Interfaces/RuntimeVerifiableOpInterface.cpp"], - hdrs = ["include/mlir/Interfaces/RuntimeVerifiableOpInterface.h"], - includes = ["include"], - deps = [ - ":IR", - ":RuntimeVerifiableOpInterfaceIncGen", - "//llvm:Support", - ], -) - -cc_library( - name = "VectorInterfaces", - srcs = ["lib/Interfaces/VectorInterfaces.cpp"], - hdrs = ["include/mlir/Interfaces/VectorInterfaces.h"], - includes = ["include"], - deps = [ - ":IR", - ":VectorInterfacesIncGen", - ], -) - -cc_library( - name = "ViewLikeInterface", - srcs = ["lib/Interfaces/ViewLikeInterface.cpp"], - hdrs = ["include/mlir/Interfaces/ViewLikeInterface.h"], - includes = ["include"], - deps = [ - ":DialectUtils", - ":IR", - ":ViewLikeInterfaceIncGen", - ], -) - -cc_library( - name = "CopyOpInterface", - srcs = ["lib/Interfaces/CopyOpInterface.cpp"], - hdrs = ["include/mlir/Interfaces/CopyOpInterface.h"], - includes = ["include"], - deps = [ - ":CopyOpInterfaceIncGen", - ":IR", - ], -) - -td_library( - name = "ShapeOpsTdFiles", - srcs = [ - "include/mlir/Dialect/Shape/IR/ShapeBase.td", - "include/mlir/Dialect/Shape/IR/ShapeOps.td", - ], - includes = ["include"], - deps = [ - ":CallInterfacesTdFiles", - ":CastInterfacesTdFiles", - ":ControlFlowInterfacesTdFiles", - ":FunctionInterfacesTdFiles", - ":InferTypeOpInterfaceTdFiles", - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "ShapeOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/Shape/IR/ShapeOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/Shape/IR/ShapeOps.cpp.inc", - ), - ( - ["-gen-dialect-decls"], - "include/mlir/Dialect/Shape/IR/ShapeOpsDialect.h.inc", - ), - ( - ["-gen-dialect-defs"], - "include/mlir/Dialect/Shape/IR/ShapeOpsDialect.cpp.inc", - ), - ( - ["-gen-typedef-decls"], - "include/mlir/Dialect/Shape/IR/ShapeOpsTypes.h.inc", - ), - ( - ["-gen-typedef-defs"], - "include/mlir/Dialect/Shape/IR/ShapeOpsTypes.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Shape/IR/ShapeOps.td", - deps = [":ShapeOpsTdFiles"], -) - -gentbl_cc_library( - name = "MLIRShapeCanonicalizationIncGen", - strip_include_prefix = "include/mlir/Dialect/Shape/IR", - tbl_outs = [ - ( - ["-gen-rewriters"], - "include/mlir/Dialect/Shape/IR/ShapeCanonicalization.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "lib/Dialect/Shape/IR/ShapeCanonicalization.td", - deps = [ - ":FuncTdFiles", - ":ShapeOpsTdFiles", - ":TensorOpsTdFiles", - ], -) - -cc_library( - name = "ShapeDialect", - srcs = glob(["lib/Dialect/Shape/IR/*.cpp"]), - hdrs = ["include/mlir/Dialect/Shape/IR/Shape.h"], - includes = ["include"], - deps = [ - ":ArithDialect", - ":CastInterfaces", - ":ControlFlowInterfaces", - ":Dialect", - ":FuncDialect", - ":FunctionInterfaces", - ":IR", - ":InferTypeOpInterface", - ":MLIRShapeCanonicalizationIncGen", - ":ShapeOpsIncGen", - ":SideEffectInterfaces", - ":TensorDialect", - ":UBDialect", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "ShapeToStandardGen", - strip_include_prefix = "lib/Conversion/ShapeToStandard", - tbl_outs = [ - ( - ["-gen-rewriters"], - "lib/Conversion/ShapeToStandard/ShapeToStandard.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "lib/Conversion/ShapeToStandard/ShapeToStandard.td", - deps = [":ShapeOpsTdFiles"], -) - -cc_library( - name = "ShapeToStandard", - srcs = glob([ - "lib/Conversion/ShapeToStandard/*.cpp", - "lib/Conversion/ShapeToStandard/*.h", - ]), - hdrs = ["include/mlir/Conversion/ShapeToStandard/ShapeToStandard.h"], - includes = ["include"], - deps = [ - ":ArithDialect", - ":ControlFlowDialect", - ":ConversionPassIncGen", - ":FuncDialect", - ":IR", - ":MemRefDialect", - ":Pass", - ":SCFDialect", - ":ShapeDialect", - ":ShapeToStandardGen", - ":Support", - ":TensorDialect", - ":Transforms", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "ShapeTransformsPassIncGen", - tbl_outs = [( - [ - "-gen-pass-decls", - "-name=Shape", - ], - "include/mlir/Dialect/Shape/Transforms/Passes.h.inc", - )], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Shape/Transforms/Passes.td", - deps = [":PassBaseTdFiles"], -) - -cc_library( - name = "ShapeTransforms", - srcs = glob([ - "lib/Dialect/Shape/Transforms/*.cpp", - "lib/Dialect/Shape/Transforms/*.h", - ]), - hdrs = [ - "include/mlir/Dialect/Shape/Analysis/ShapeMappingAnalysis.h", - "include/mlir/Dialect/Shape/Transforms/BufferizableOpInterfaceImpl.h", - "include/mlir/Dialect/Shape/Transforms/Passes.h", - ], - includes = ["include"], - deps = [ - ":ArithDialect", - ":BufferizationDialect", - ":BufferizationTransforms", - ":FuncDialect", - ":IR", - ":MemRefDialect", - ":Pass", - ":ShapeDialect", - ":ShapeTransformsPassIncGen", - ":TensorDialect", - ":Transforms", - "//llvm:Support", - ], -) - -td_library( - name = "ControlFlowOpsTdFiles", - srcs = [ - "include/mlir/Dialect/ControlFlow/IR/ControlFlowOps.td", - ], - includes = ["include"], - deps = [ - ":AttrTdFiles", - ":CallInterfacesTdFiles", - ":CastInterfacesTdFiles", - ":ControlFlowInterfacesTdFiles", - ":InferTypeOpInterfaceTdFiles", - ":OpBaseTdFiles", - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "ControlFlowOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/ControlFlow/IR/ControlFlowOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/ControlFlow/IR/ControlFlowOps.cpp.inc", - ), - ( - ["-gen-dialect-decls"], - "include/mlir/Dialect/ControlFlow/IR/ControlFlowOpsDialect.h.inc", - ), - ( - ["-gen-dialect-defs"], - "include/mlir/Dialect/ControlFlow/IR/ControlFlowOpsDialect.cpp.inc", - ), - ( - ["-gen-enum-decls"], - "include/mlir/Dialect/ControlFlow/IR/ControlFlowOpsEnums.h.inc", - ), - ( - ["-gen-enum-defs"], - "include/mlir/Dialect/ControlFlow/IR/ControlFlowOpsEnums.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/ControlFlow/IR/ControlFlowOps.td", - deps = [ - ":AttrTdFiles", - ":ControlFlowOpsTdFiles", - ], -) - -cc_library( - name = "ControlFlowDialect", - srcs = glob( - [ - "lib/Dialect/ControlFlow/IR/*.cpp", - "lib/Dialect/ControlFlow/IR/*.h", - ], - ), - hdrs = glob([ - "include/mlir/Dialect/ControlFlow/IR/*.h", - ]), - includes = ["include"], - deps = [ - ":ArithDialect", - ":CommonFolders", - ":ControlFlowInterfaces", - ":ControlFlowOpsIncGen", - ":ConvertToLLVMInterface", - ":IR", - ":SideEffectInterfaces", - ":Support", - "//llvm:Support", - ], -) - -cc_library( - name = "ControlFlowTransforms", - srcs = glob([ - "lib/Dialect/ControlFlow/Transforms/*.cpp", - ]), - hdrs = glob([ - "include/mlir/Dialect/ControlFlow/Transforms/*.h", - ]), - includes = ["include"], - deps = [ - ":BufferizationDialect", - ":BufferizationTransforms", - ":ControlFlowDialect", - ":IR", - ":MemRefDialect", - ], -) - -cc_library( - name = "FuncDialect", - srcs = glob( - [ - "lib/Dialect/Func/IR/*.cpp", - "lib/Dialect/Func/IR/*.h", - "lib/Dialect/Func/Utils/*.cpp", - ], - ), - hdrs = glob([ - "include/mlir/Dialect/Func/IR/*.h", - "include/mlir/Dialect/Func/Utils/*.h", - ]) + ["include/mlir/Transforms/InliningUtils.h"], - includes = ["include"], - deps = [ - ":ArithDialect", - ":CallOpInterfaces", - ":CastInterfaces", - ":CommonFolders", - ":ControlFlowDialect", - ":ControlFlowInterfaces", - ":ConvertToLLVMInterface", - ":FuncIncGen", - ":FunctionInterfaces", - ":IR", - ":InferTypeOpInterface", - ":SideEffectInterfaces", - ":Support", - "//llvm:Support", - ], -) - -cc_library( - name = "FuncExtensions", - srcs = glob(["lib/Dialect/Func/Extensions/*.cpp"]), - hdrs = glob(["include/mlir/Dialect/Func/Extensions/*.h"]), - includes = ["include"], - deps = [ - ":ControlFlowDialect", - ":FuncDialect", - ":IR", - ":InferTypeOpInterface", - ":MeshShardingInterface", - ], -) - -td_library( - name = "FuncTransformOpsTdFiles", - srcs = [ - "include/mlir/Dialect/Func/TransformOps/FuncTransformOps.td", - ], - includes = ["include"], - deps = [ - ":TransformDialectTdFiles", - ], -) - -gentbl_cc_library( - name = "FuncTransformOpsIncGen", - strip_include_prefix = "include", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/Func/TransformOps/FuncTransformOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/Func/TransformOps/FuncTransformOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Func/TransformOps/FuncTransformOps.td", - deps = [ - ":FuncTransformOpsTdFiles", - ], -) - -cc_library( - name = "FuncTransformOps", - srcs = [ - "lib/Dialect/Func/TransformOps/FuncTransformOps.cpp", - ], - hdrs = [ - "include/mlir/Dialect/Func/TransformOps/FuncTransformOps.h", - ], - includes = ["include"], - deps = [ - ":FuncDialect", - ":FuncToLLVM", - ":FuncTransformOpsIncGen", - ":IR", - ":LLVMCommonConversion", - ":LLVMDialect", - ":TransformDialect", - ":TransformUtils", - ], -) - -cc_library( - name = "AllExtensions", - hdrs = ["include/mlir/InitAllExtensions.h"], - deps = [ - ":AMDGPUTransformOps", - ":AffineTransformOps", - ":ArithToLLVM", - ":BufferizationTransformOps", - ":BuiltinToLLVMIRTranslation", - ":ComplexToLLVM", - ":ControlFlowToLLVM", - ":FuncExtensions", - ":FuncToLLVM", - ":FuncTransformOps", - ":GPUToLLVMIRTranslation", - ":GPUTransformOps", - ":IndexToLLVM", - ":LLVMToLLVMIRTranslation", - ":LinalgTransformOps", - ":MathToLLVM", - ":MemRefToLLVM", - ":MemRefTransformOps", - ":MeshDialect", - ":NVGPUTransformOps", - ":NVVMTarget", - ":NVVMToLLVM", - ":ROCDLTarget", - ":ROCDLToLLVMIRTranslation", - ":SCFTransformOps", - ":SparseTensorTransformOps", - ":TensorTransformOps", - ":TransformDebugExtension", - ":TransformLoopExtension", - ":TransformPDLExtension", - ":UBToLLVM", - ":VCIXToLLVMIRTranslation", - ":VectorTransformOps", - ], -) - -# TODO(zinenko): remove this after updating users. - -gentbl_cc_library( - name = "FuncTransformsPassIncGen", - tbl_outs = [( - [ - "-gen-pass-decls", - "-name=Func", - ], - "include/mlir/Dialect/Func/Transforms/Passes.h.inc", - )], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Func/Transforms/Passes.td", - deps = [":PassBaseTdFiles"], -) - -cc_library( - name = "FuncTransforms", - srcs = glob([ - "lib/Dialect/Func/Transforms/*.cpp", - "lib/Dialect/Func/Transforms/*.h", - ]), - hdrs = glob(["include/mlir/Dialect/Func/Transforms/*.h"]), - includes = ["include"], - deps = [ - ":BufferizationDialect", - ":BufferizationTransforms", - ":FuncDialect", - ":FuncTransformsPassIncGen", - ":IR", - ":MemRefDialect", - ":Pass", - ":SCFDialect", - ":Support", - ":Transforms", - "//llvm:Support", - ], -) - -cc_library( - name = "VectorDialect", - srcs = glob( - [ - "lib/Dialect/Vector/IR/*.cpp", - ], - ), - hdrs = glob([ - "include/mlir/Dialect/Vector/IR/*.h", - ]), - includes = ["include"], - deps = [ - ":AffineDialect", - ":ArithDialect", - ":ArithUtils", - ":ControlFlowInterfaces", - ":DataLayoutInterfaces", - ":DestinationStyleOpInterface", - ":DialectUtils", - ":IR", - ":InferTypeOpInterface", - ":MaskableOpInterface", - ":MaskingOpInterface", - ":MemRefDialect", - ":SideEffectInterfaces", - ":Support", - ":TensorDialect", - ":ValueBoundsOpInterface", - ":VectorAttributesIncGen", - ":VectorDialectIncGen", - ":VectorInterfaces", - ":VectorOpsIncGen", - ":ViewLikeInterface", - "//llvm:Support", - ], -) - -cc_library( - name = "VectorTransformOps", - srcs = [ - "lib/Dialect/Vector/TransformOps/VectorTransformOps.cpp", - ], - hdrs = [ - "include/mlir/Dialect/Vector/TransformOps/VectorTransformOps.h", - ], - includes = ["include"], - deps = [ - ":AffineDialect", - ":ArithDialect", - ":AsmParser", - ":IR", - ":LLVMCommonConversion", - ":LLVMDialect", - ":SideEffectInterfaces", - ":TransformDialect", - ":TransformUtils", - ":VectorDialect", - ":VectorEnumsIncGen", - ":VectorToLLVM", - ":VectorToSCF", - ":VectorTransformOpsIncGen", - ":VectorTransforms", - ":X86VectorTransforms", - "//llvm:Support", - ], -) - -td_library( - name = "VectorTransformsTdFiles", - srcs = ["include/mlir/Dialect/Vector/Transforms/VectorTransformsBase.td"], - includes = ["include"], - deps = [":OpBaseTdFiles"], -) - -gentbl_cc_library( - name = "VectorEnumsIncGen", - tbl_outs = [ - ( - ["-gen-enum-decls"], - "include/mlir/Dialect/Vector/Transforms/VectorTransformsEnums.h.inc", - ), - ( - ["-gen-enum-defs"], - "include/mlir/Dialect/Vector/Transforms/VectorTransformsEnums.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Vector/Transforms/VectorTransformsBase.td", - deps = [ - ":OpBaseTdFiles", - ], -) - -gentbl_cc_library( - name = "VectorPassIncGen", - tbl_outs = [ - ( - [ - "-gen-pass-decls", - "-name=Vector", - ], - "include/mlir/Dialect/Vector/Transforms/Passes.h.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Vector/Transforms/Passes.td", - deps = [":PassBaseTdFiles"], -) - -cc_library( - name = "VectorTransforms", - srcs = glob( - [ - "lib/Dialect/Vector/Transforms/*.cpp", - "lib/Dialect/Vector/Transforms/*.h", - ], - ), - hdrs = glob([ - "include/mlir/Dialect/Vector/Transforms/*.h", - ]), - includes = ["include"], - deps = [ - ":AffineDialect", - ":ArithDialect", - ":ArithTransforms", - ":ArithUtils", - ":BufferizationDialect", - ":BufferizationTransforms", - ":DialectUtils", - ":FuncDialect", - ":IR", - ":LinalgDialect", - ":MemRefDialect", - ":MemRefUtils", - ":Pass", - ":SCFDialect", - ":SideEffectInterfaces", - ":SubsetOpInterface", - ":Support", - ":TensorDialect", - ":Transforms", - ":VectorDialect", - ":VectorEnumsIncGen", - ":VectorInterfaces", - ":VectorPassIncGen", - ":VectorUtils", - "//llvm:Support", - ], -) - -cc_library( - name = "VectorUtils", - srcs = glob( - [ - "lib/Dialect/Vector/Utils/*.cpp", - ], - ), - hdrs = glob([ - "include/mlir/Dialect/Vector/Utils/*.h", - ]), - includes = ["include"], - deps = [ - ":AffineAnalysis", - ":AffineDialect", - ":ArithDialect", - ":DialectUtils", - ":FuncDialect", - ":IR", - ":MemRefDialect", - ":Support", - ":TensorDialect", - ":VectorDialect", - "//llvm:Support", - ], -) - -cc_library( - name = "Support", - srcs = glob([ - "lib/Support/*.cpp", - "lib/Support/*.h", - ]), - hdrs = glob(["include/mlir/Support/*.h"]), - includes = ["include"], - deps = [ - "//llvm:Support", - "//llvm:TargetParser", - ], -) - -cc_library( - name = "Debug", - srcs = glob([ - "lib/Debug/*.cpp", - "lib/Debug/*.h", - "lib/Debug/BreakpointManagers/*.cpp", - "lib/Debug/BreakpointManagers/*.h", - "lib/Debug/Observers/*.cpp", - "lib/Debug/Observers/*.h", - ]), - hdrs = glob([ - "include/mlir/Debug/*.h", - "include/mlir/Debug/BreakpointManagers/*.h", - "include/mlir/Debug/Observers/*.h", - ]), - includes = ["include"], - deps = [ - ":CAPIIR", - ":IR", - ":Rewrite", - ":Support", - "//llvm:Support", - ], -) - -cc_library( - name = "MlirLspServerSupportLib", - srcs = glob( - [ - "lib/Tools/lsp-server-support/*.cpp", - ], - ), - hdrs = glob( - [ - "include/mlir/Tools/lsp-server-support/*.h", - ], - ), - deps = [ - ":Support", - "//llvm:Support", - "//llvm:TargetParser", - ], -) - -cc_library( - name = "MlirLspServerLib", - srcs = glob( - [ - "lib/Tools/mlir-lsp-server/*.cpp", - "lib/Tools/mlir-lsp-server/*.h", - "lib/Tools/mlir-lsp-server/lsp/*.cpp", - "lib/Tools/mlir-lsp-server/lsp/*.h", - ], - ), - hdrs = glob( - ["include/mlir/Tools/mlir-lsp-server/*.h"], - ), - includes = ["include"], - deps = [ - ":AsmParser", - ":BytecodeWriter", - ":FunctionInterfaces", - ":IR", - ":MlirLspServerSupportLib", - ":Parser", - ":Support", - "//llvm:Support", - ], -) - -cc_library( - name = "MlirPdllLspServerLib", - srcs = glob( - [ - "lib/Tools/mlir-pdll-lsp-server/*.cpp", - "lib/Tools/mlir-pdll-lsp-server/*.h", - ], - ), - hdrs = glob( - ["include/mlir/Tools/mlir-pdll-lsp-server/*.h"], - ), - includes = ["include"], - deps = [ - ":IR", - ":MlirLspServerSupportLib", - ":PDLLAST", - ":PDLLCodeGen", - ":PDLLODS", - ":PDLLParser", - ":Support", - "//llvm:Support", - ], -) - -cc_library( - name = "AsmParserTokenKinds", - # strip_include_prefix does not apply to textual_hdrs. - hdrs = ["lib/AsmParser/TokenKinds.def"], - strip_include_prefix = "lib/AsmParser", - textual_hdrs = ["lib/AsmParser/TokenKinds.def"], -) - -cc_library( - name = "AsmParser", - srcs = glob([ - "lib/AsmParser/*.cpp", - "lib/AsmParser/*.h", - ]), - hdrs = glob([ - "include/mlir/AsmParser/*.h", - ]), - includes = ["include"], - deps = [ - ":AsmParserTokenKinds", - ":IR", - ":Support", - "//llvm:Support", - "//llvm:TargetParser", - ], -) - -cc_library( - name = "BytecodeReader", - srcs = glob([ - "lib/Bytecode/Reader/*.cpp", - "lib/Bytecode/Reader/*.h", - "lib/Bytecode/*.h", - ]), - hdrs = glob([ - "include/mlir/Bytecode/*.h", - ]), - includes = ["include"], - deps = [ - ":AsmParser", - ":BytecodeOpInterfaceIncGen", - ":IR", - ":Support", - "//llvm:Support", - ], -) - -cc_library( - name = "BytecodeWriter", - srcs = glob([ - "lib/Bytecode/Writer/*.cpp", - "lib/Bytecode/Writer/*.h", - "lib/Bytecode/*.h", - ]), - hdrs = glob([ - "include/mlir/Bytecode/*.h", - ]), - includes = ["include"], - deps = [ - ":BytecodeOpInterfaceIncGen", - ":IR", - ":Support", - "//llvm:Support", - ], -) - -cc_library( - name = "Parser", - srcs = glob([ - "lib/Parser/*.cpp", - "lib/Parser/*.h", - ]), - hdrs = glob([ - "include/mlir/Parser/*.h", - ]), - includes = ["include"], - deps = [ - ":AsmParser", - ":BytecodeReader", - ":IR", - ":Support", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "LLVMDialectInterfaceIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Dialect/LLVMIR/LLVMInterfaces.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Dialect/LLVMIR/LLVMInterfaces.cpp.inc", - ), - ( - ["-gen-type-interface-decls"], - "include/mlir/Dialect/LLVMIR/LLVMTypeInterfaces.h.inc", - ), - ( - ["-gen-type-interface-defs"], - "include/mlir/Dialect/LLVMIR/LLVMTypeInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/LLVMIR/LLVMInterfaces.td", - deps = [":LLVMOpsTdFiles"], -) - -cc_library( - name = "LLVMDialect", - srcs = glob( - [ - "lib/Dialect/LLVMIR/IR/*.cpp", - "lib/Dialect/LLVMIR/IR/*.h", - ], - exclude = [ - "lib/Dialect/LLVMIR/IR/*AMX*.cpp", - "lib/Dialect/LLVMIR/IR/*AMX*.h", - "lib/Dialect/LLVMIR/IR/*ArmSVE*.cpp", - "lib/Dialect/LLVMIR/IR/*ArmSVE*.h", - "lib/Dialect/LLVMIR/IR/NVVM*.cpp", - "lib/Dialect/LLVMIR/IR/NVVM*.h", - "lib/Dialect/LLVMIR/IR/ROCDL*.cpp", - "lib/Dialect/LLVMIR/IR/BasicPtxBuilderInterface.cpp", - "lib/Dialect/LLVMIR/IR/ROCDL*.h", - "lib/Dialect/LLVMIR/IR/VCIX*.cpp", - "lib/Dialect/LLVMIR/IR/VCIX*.h", - "lib/Dialect/LLVMIR/IR/*X86Vector*.cpp", - "lib/Dialect/LLVMIR/IR/*X86Vector*.h", - ], - ), - hdrs = glob( - ["include/mlir/Dialect/LLVMIR/*.h"], - exclude = [ - "include/mlir/Dialect/LLVMIR/*AMX*.h", - "include/mlir/Dialect/LLVMIR/*ArmSVE*.h", - "include/mlir/Dialect/LLVMIR/NVVM*.h", - "include/mlir/Dialect/LLVMIR/BasicPtxBuilderInterface.h", - "include/mlir/Dialect/LLVMIR/ROCDL*.h", - "include/mlir/Dialect/LLVMIR/VCIX*.h", - "include/mlir/Dialect/LLVMIR/*X86Vector*.h", - ], - ) + [ - "include/mlir/Transforms/InliningUtils.h", - "include/mlir/Transforms/Mem2Reg.h", - ], - includes = ["include"], - deps = [ - ":CallOpInterfaces", - ":ControlFlowInterfaces", - ":DataLayoutInterfaces", - ":FunctionInterfaces", - ":IR", - ":InferTypeOpInterface", - ":LLVMDialectInterfaceIncGen", - ":LLVMIntrinsicOpsIncGen", - ":LLVMOpsIncGen", - ":LLVMTypesIncGen", - ":MemorySlotInterfaces", - ":MemorySlotInterfacesIncGen", - ":SideEffectInterfaces", - ":Support", - "//llvm:AsmParser", - "//llvm:BinaryFormat", - "//llvm:BitReader", - "//llvm:BitWriter", - "//llvm:Core", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "LLVMPassIncGen", - tbl_outs = [ - ( - [ - "-gen-pass-decls", - "-name=LLVM", - ], - "include/mlir/Dialect/LLVMIR/Transforms/Passes.h.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/LLVMIR/Transforms/Passes.td", - deps = [":PassBaseTdFiles"], -) - -cc_library( - name = "LLVMIRTransforms", - srcs = glob([ - "lib/Dialect/LLVMIR/Transforms/*.cpp", - "lib/Dialect/LLVMIR/Transforms/*.h", - ]), - hdrs = glob(["include/mlir/Dialect/LLVMIR/Transforms/*.h"]), - includes = ["include"], - deps = [ - ":FuncDialect", - ":GPUDialect", - ":IR", - ":LLVMDialect", - ":LLVMPassIncGen", - ":NVVMDialect", - ":Pass", - ":Transforms", - "//llvm:BinaryFormat", - "//llvm:Support", - ], -) - -td_library( - name = "GPUOpsTdFiles", - srcs = [ - "include/mlir/Dialect/GPU/IR/CompilationAttrInterfaces.td", - "include/mlir/Dialect/GPU/IR/CompilationAttrs.td", - "include/mlir/Dialect/GPU/IR/GPUBase.td", - "include/mlir/Dialect/GPU/IR/GPUOps.td", - "include/mlir/Dialect/GPU/IR/ParallelLoopMapperAttr.td", - "include/mlir/Dialect/GPU/TransformOps/GPUDeviceMappingAttr.td", - ], - includes = ["include"], - deps = [ - ":DLTIDialectTdFiles", - ":DataLayoutInterfacesTdFiles", - ":FunctionInterfacesTdFiles", - ":InferIntRangeInterfaceTdFiles", - ":LLVMOpsTdFiles", - ":OpBaseTdFiles", - ":SCFTdFiles", - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "GPUDeviceMapperEnumsGen", - tbl_outs = [ - ( - ["-gen-enum-decls"], - "include/mlir/Dialect/GPU/TransformOps/GPUDeviceMapperEnums.h.inc", - ), - ( - ["-gen-enum-defs"], - "include/mlir/Dialect/GPU/TransformOps/GPUDeviceMapperEnums.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/GPU/TransformOps/GPUDeviceMappingAttr.td", - deps = [ - ":GPUOpsTdFiles", - ":OpBaseTdFiles", - ], -) - -gentbl_cc_library( - name = "GPUCompilationAttrInterfacesIncGen", - tbl_outs = [ - ( - ["-gen-attr-interface-decls"], - "include/mlir/Dialect/GPU/IR/CompilationAttrInterfaces.h.inc", - ), - ( - ["-gen-attr-interface-defs"], - "include/mlir/Dialect/GPU/IR/CompilationAttrInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/GPU/IR/CompilationAttrInterfaces.td", - deps = [ - ":AttrTdFiles", - ":OpBaseTdFiles", - ], -) - -gentbl_cc_library( - name = "GPUBaseIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Dialect/GPU/IR/GPUOpInterfaces.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Dialect/GPU/IR/GPUOpInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/GPU/IR/GPUBase.td", - deps = [":OpBaseTdFiles"], -) - -gentbl_cc_library( - name = "GPUOpsIncGen", - tbl_outs = [ - ( - [ - "-gen-dialect-decls", - "-dialect=gpu", - ], - "include/mlir/Dialect/GPU/IR/GPUOpsDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=gpu", - ], - "include/mlir/Dialect/GPU/IR/GPUOpsDialect.cpp.inc", - ), - ( - ["-gen-op-decls"], - "include/mlir/Dialect/GPU/IR/GPUOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/GPU/IR/GPUOps.cpp.inc", - ), - ( - ["-gen-enum-decls"], - "include/mlir/Dialect/GPU/IR/GPUOpsEnums.h.inc", - ), - ( - ["-gen-enum-defs"], - "include/mlir/Dialect/GPU/IR/GPUOpsEnums.cpp.inc", - ), - ( - ["-gen-attrdef-decls"], - "include/mlir/Dialect/GPU/IR/GPUOpsAttributes.h.inc", - ), - ( - ["-gen-attrdef-defs"], - "include/mlir/Dialect/GPU/IR/GPUOpsAttributes.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/GPU/IR/GPUOps.td", - deps = [ - ":DLTIDialectTdFiles", - ":GPUOpsTdFiles", - ], -) - -cc_library( - name = "GPUDialect", - srcs = glob( - [ - "lib/Dialect/GPU/IR/*.cpp", - "lib/Dialect/GPU/IR/*.h", - ], - ), - hdrs = glob(["include/mlir/Dialect/GPU/IR/*.h"]), - includes = ["include"], - deps = [ - ":ArithDialect", - ":ControlFlowInterfaces", - ":DLTIDialect", - ":FunctionInterfaces", - ":GPUBaseIncGen", - ":GPUCompilationAttrInterfacesIncGen", - ":GPUOpsIncGen", - ":IR", - ":InferIntRangeInterface", - ":InferTypeOpInterface", - ":LLVMDialect", - ":MemRefDialect", - ":SCFDialect", - ":SideEffectInterfaces", - ":Support", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "GPUPassIncGen", - tbl_outs = [ - ( - [ - "-gen-pass-decls", - "-name=GPU", - ], - "include/mlir/Dialect/GPU/Transforms/Passes.h.inc", - ), - ( - [ - "-gen-pass-capi-header", - "--prefix=GPU", - ], - "include/mlir/Dialect/GPU/Transforms/Passes.capi.h.inc", - ), - ( - [ - "-gen-pass-capi-impl", - "--prefix=GPU", - ], - "include/mlir/Dialect/GPU/Transforms/Passes.capi.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/GPU/Transforms/Passes.td", - deps = [":PassBaseTdFiles"], -) - -cc_library( - name = "GPUPipelines", - srcs = ["lib/Dialect/GPU/Pipelines/GPUToNVVMPipeline.cpp"], - hdrs = ["include/mlir/Dialect/GPU/Pipelines/Passes.h"], - includes = ["include"], - deps = [ - ":AffineToStandard", - ":ArithToLLVM", - ":FuncDialect", - ":FuncToLLVM", - ":GPUCommonTransforms", - ":GPUDialect", - ":GPUToNVVMTransforms", - ":GPUTransforms", - ":IndexToLLVM", - ":LLVMDialect", - ":LinalgTransforms", - ":MathToLLVM", - ":MemRefToLLVM", - ":MemRefTransforms", - ":NVGPUToNVVM", - ":NVVMToLLVM", - ":Pass", - ":ReconcileUnrealizedCasts", - ":SCFToControlFlow", - ":Transforms", - ":VectorToLLVM", - ":VectorToSCF", - ":config", - ], -) - -cc_library( - name = "GPUTransforms", - srcs = glob( - [ - "lib/Dialect/GPU/Transforms/*.cpp", - "lib/Dialect/GPU/Transforms/*.h", - ], - ), - hdrs = glob(["include/mlir/Dialect/GPU/Transforms/*.h"]), - includes = ["include"], - deps = [ - ":AffineDialect", - ":AffineUtils", - ":ArithDialect", - ":AsmParser", - ":AsyncDialect", - ":BufferizationDialect", - ":ControlFlowDialect", - ":DLTIDialect", - ":DialectUtils", - ":ExecutionEngineUtils", - ":FuncDialect", - ":GPUDialect", - ":GPUPassIncGen", - ":GPUToLLVMIRTranslation", - ":IR", - ":IndexDialect", - ":LLVMDialect", - ":LLVMToLLVMIRTranslation", - ":MemRefDialect", - ":NVVMDialect", - ":NVVMTarget", - ":Pass", - ":ROCDLDialect", - ":ROCDLTarget", - ":ROCDLToLLVMIRTranslation", - ":SCFDialect", - ":SPIRVDialect", - ":SPIRVTarget", - ":SideEffectInterfaces", - ":Support", - ":ToLLVMIRTranslation", - ":Transforms", - ":VCIXToLLVMIRTranslation", - ":VectorDialect", - ":config", - "//llvm:Core", - "//llvm:MC", - "//llvm:Support", - "//llvm:Target", - ] + if_cuda_available([ - ":NVVMToLLVMIRTranslation", - "//llvm:NVPTXCodeGen", - ]), -) - -td_library( - name = "GPUTransformOpsTdFiles", - srcs = [ - "include/mlir/Dialect/GPU/TransformOps/GPUTransformOps.td", - ], - includes = ["include"], - deps = [ - ":TransformDialectTdFiles", - ], -) - -gentbl_cc_library( - name = "GPUTransformOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/GPU/TransformOps/GPUTransformOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/GPU/TransformOps/GPUTransformOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/GPU/TransformOps/GPUTransformOps.td", - deps = [ - ":GPUTransformOpsTdFiles", - ], -) - -cc_library( - name = "GPUTransformOps", - srcs = glob([ - "lib/Dialect/GPU/TransformOps/*.cpp", - ]), - hdrs = glob([ - "include/mlir/Dialect/GPU/TransformOps/*.h", - ]), - includes = ["include"], - deps = [ - ":AffineDialect", - ":ArithDialect", - ":AsmParser", - ":ControlFlowDialect", - ":DialectUtils", - ":FuncDialect", - ":GPUCommonTransforms", - ":GPUDialect", - ":GPUToNVVMTransforms", - ":GPUTransformOpsIncGen", - ":GPUTransforms", - ":IR", - ":LLVMCommonConversion", - ":MemRefDialect", - ":NVVMDialect", - ":Parser", - ":SCFDialect", - ":SideEffectInterfaces", - ":Support", - ":TransformDialect", - ":TransformUtils", - ":VectorDialect", - ":VectorTransforms", - "//llvm:Support", - ], -) - -td_library( - name = "LLVMOpsTdFiles", - srcs = [ - "include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td", - "include/mlir/Dialect/LLVMIR/LLVMDialect.td", - "include/mlir/Dialect/LLVMIR/LLVMEnums.td", - "include/mlir/Dialect/LLVMIR/LLVMInterfaces.td", - "include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td", - "include/mlir/Dialect/LLVMIR/LLVMOpBase.td", - "include/mlir/Dialect/LLVMIR/LLVMOps.td", - "include/mlir/Dialect/LLVMIR/LLVMTypes.td", - ], - includes = ["include"], - deps = [ - ":CallInterfacesTdFiles", - ":ControlFlowInterfacesTdFiles", - ":DataLayoutInterfacesTdFiles", - ":FunctionInterfacesTdFiles", - ":InferTypeOpInterfaceTdFiles", - ":MemorySlotInterfacesTdFiles", - ":OpBaseTdFiles", - ":SideEffectInterfacesTdFiles", - ], -) - -cc_library( - name = "GPUCommonTransforms", - srcs = [ - "lib/Conversion/GPUCommon/GPUOpsLowering.cpp", - ], - hdrs = [ - "include/mlir/Conversion/GPUCommon/GPUCommonPass.h", - "lib/Conversion/GPUCommon/GPUOpsLowering.h", - "lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h", - "lib/Conversion/GPUCommon/OpToFuncCallLowering.h", - ], - deps = [ - ":ConversionPassIncGen", - ":FuncDialect", - ":GPUDialect", - ":GPUTransforms", - ":IR", - ":LLVMCommonConversion", - ":LLVMDialect", - ":Support", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "GPUToNVVMGen", - strip_include_prefix = "lib/Conversion/GPUToNVVM", - tbl_outs = [ - ( - ["-gen-rewriters"], - "lib/Conversion/GPUToNVVM/GPUToNVVM.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "lib/Conversion/GPUToNVVM/GPUToNVVM.td", - deps = [ - ":GPUOpsTdFiles", - ":NVVMOpsTdFiles", - ], -) - -cc_library( - name = "GPUToNVVMTransforms", - srcs = glob([ - "lib/Conversion/GPUToNVVM/*.cpp", - "lib/Conversion/GPUToNVVM/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/GPUToNVVM/*.h", - ]), - includes = ["include"], - deps = [ - ":ArithDialect", - ":ArithToLLVM", - ":ControlFlowDialect", - ":ControlFlowToLLVM", - ":ConversionPassIncGen", - ":FuncDialect", - ":FuncToLLVM", - ":GPUCommonTransforms", - ":GPUDialect", - ":GPUToNVVMGen", - ":GPUTransforms", - ":IR", - ":LLVMCommonConversion", - ":LLVMDialect", - ":MathDialect", - ":MemRefDialect", - ":MemRefToLLVM", - ":NVVMDialect", - ":Pass", - ":Transforms", - ":VectorToLLVM", - "//llvm:Support", - ], -) - -cc_library( - name = "AMDGPUToROCDL", - srcs = glob([ - "lib/Conversion/AMDGPUToROCDL/*.cpp", - "lib/Conversion/AMDGPUToROCDL/*.h", - ]) + ["include/mlir/Conversion/GPUToROCDL/Runtimes.h"], - hdrs = glob([ - "include/mlir/Conversion/AMDGPUToROCDL/*.h", - ]), - includes = ["include"], - deps = [ - ":AMDGPUDialect", - ":AMDGPUUtils", - ":ConversionPassIncGen", - ":IR", - ":LLVMCommonConversion", - ":LLVMDialect", - ":Pass", - ":ROCDLDialect", - ":Support", - ":Transforms", - "//llvm:Support", - ], -) - -cc_library( - name = "NVGPUToNVVM", - srcs = glob([ - "lib/Conversion/NVGPUToNVVM/*.cpp", - "lib/Conversion/NVGPUToNVVM/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/NVGPUToNVVM/*.h", - ]), - includes = ["include"], - deps = [ - ":ArithDialect", - ":ConversionPassIncGen", - ":GPUCommonTransforms", - ":GPUDialect", - ":GPUToGPURuntimeTransforms", - ":IR", - ":LLVMCommonConversion", - ":LLVMDialect", - ":MemRefDialect", - ":NVGPUDialect", - ":NVVMDialect", - ":Pass", - ":SCFTransforms", - "//llvm:Support", - ], -) - -cc_library( - name = "VectorToSPIRV", - srcs = glob([ - "lib/Conversion/VectorToSPIRV/*.cpp", - "lib/Conversion/VectorToSPIRV/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/VectorToSPIRV/*.h", - ]), - includes = ["include"], - deps = [ - ":ArithDialect", - ":ConversionPassIncGen", - ":IR", - ":Pass", - ":SPIRVConversion", - ":SPIRVDialect", - ":Support", - ":Transforms", - ":VectorDialect", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "GPUToROCDLTGen", - strip_include_prefix = "lib/Conversion/GPUToROCDL", - tbl_outs = [ - ( - ["-gen-rewriters"], - "lib/Conversion/GPUToROCDL/GPUToROCDL.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "lib/Conversion/GPUToROCDL/GPUToROCDL.td", - deps = [ - ":GPUOpsTdFiles", - ":ROCDLOpsTdFiles", - ], -) - -cc_library( - name = "GPUToROCDLTransforms", - srcs = [ - "include/mlir/Conversion/GPUToROCDL/Runtimes.h", - "lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp", - ], - hdrs = ["include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h"], - includes = ["include"], - deps = [ - ":AMDGPUToROCDL", - ":ArithToLLVM", - ":ArithTransforms", - ":ControlFlowDialect", - ":ControlFlowToLLVM", - ":ConversionPassIncGen", - ":FuncDialect", - ":FuncToLLVM", - ":GPUCommonTransforms", - ":GPUDialect", - ":GPUToROCDLTGen", - ":GPUTransforms", - ":IR", - ":LLVMCommonConversion", - ":LLVMDialect", - ":MathDialect", - ":MemRefDialect", - ":MemRefToLLVM", - ":Pass", - ":ROCDLDialect", - ":Transforms", - ":VectorDialect", - ":VectorToLLVM", - ":VectorToSCF", - "//llvm:Support", - ], -) - -cc_library( - name = "GPUToVulkanTransforms", - srcs = [ - "lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp", - "lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp", - ], - hdrs = ["include/mlir/Conversion/GPUToVulkan/ConvertGPUToVulkanPass.h"], - includes = ["include"], - deps = [ - ":ConversionPassIncGen", - ":FuncDialect", - ":GPUDialect", - ":IR", - ":LLVMDialect", - ":Pass", - ":SPIRVDialect", - ":SPIRVSerialization", - ":Support", - "//llvm:Support", - ], -) - -cc_library( - name = "GPUToGPURuntimeTransforms", - srcs = [ - "lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp", - ], - hdrs = ["include/mlir/Conversion/GPUCommon/GPUCommonPass.h"], - includes = ["include"], - deps = [ - ":ArithToLLVM", - ":AsyncDialect", - ":AsyncToLLVM", - ":ControlFlowToLLVM", - ":ConversionPassIncGen", - ":ConvertToLLVM", - ":ConvertToLLVMInterface", - ":FuncToLLVM", - ":GPUDialect", - ":GPUTransforms", - ":IR", - ":LLVMCommonConversion", - ":LLVMDialect", - ":MemRefDialect", - ":MemRefToLLVM", - ":Support", - ":VectorToLLVM", - "//llvm:Support", - ], -) - -cc_library( - name = "GPUToSPIRV", - srcs = glob([ - "lib/Conversion/GPUToSPIRV/*.cpp", - "lib/Conversion/GPUToSPIRV/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/GPUToSPIRV/*.h", - ]), - includes = [ - "include", - "lib/Conversions/GPUToSPIRV", - ], - deps = [ - ":ArithToSPIRV", - ":ConversionPassIncGen", - ":FuncDialect", - ":FuncToSPIRV", - ":GPUDialect", - ":IR", - ":MemRefToSPIRV", - ":Pass", - ":SCFDialect", - ":SCFToSPIRV", - ":SPIRVConversion", - ":SPIRVDialect", - ":Support", - ":Transforms", - ":VectorToSPIRV", - "//llvm:Support", - ], -) - -cc_library( - name = "PDLToPDLInterp", - srcs = glob([ - "lib/Conversion/PDLToPDLInterp/*.cpp", - "lib/Conversion/PDLToPDLInterp/*.h", - ]), - hdrs = [ - "include/mlir/Conversion/PDLToPDLInterp/PDLToPDLInterp.h", - "lib/Conversion/PDLToPDLInterp/RootOrdering.h", - ], - includes = ["include"], - deps = [ - ":ConversionPassIncGen", - ":IR", - ":InferTypeOpInterface", - ":PDLDialect", - ":PDLInterpDialect", - ":Pass", - ":Support", - "//llvm:Support", - ], -) - -cc_library( - name = "SPIRVToLLVM", - srcs = glob([ - "lib/Conversion/SPIRVToLLVM/*.cpp", - ]), - hdrs = glob([ - "include/mlir/Conversion/SPIRVToLLVM/*.h", - ]), - includes = ["include"], - deps = [ - ":ArithToLLVM", - ":ConversionPassIncGen", - ":FuncDialect", - ":FuncToLLVM", - ":GPUDialect", - ":IR", - ":LLVMCommonConversion", - ":LLVMDialect", - ":MemRefToLLVM", - ":Pass", - ":SPIRVDialect", - ":SPIRVUtils", - ":Support", - ":Transforms", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "LLVMOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/LLVMIR/LLVMOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/LLVMIR/LLVMOps.cpp.inc", - ), - ( - ["-gen-dialect-decls"], - "include/mlir/Dialect/LLVMIR/LLVMOpsDialect.h.inc", - ), - ( - ["-gen-dialect-defs"], - "include/mlir/Dialect/LLVMIR/LLVMOpsDialect.cpp.inc", - ), - ( - ["-gen-enum-decls"], - "include/mlir/Dialect/LLVMIR/LLVMOpsEnums.h.inc", - ), - ( - ["-gen-enum-defs"], - "include/mlir/Dialect/LLVMIR/LLVMOpsEnums.cpp.inc", - ), - ( - [ - "--gen-attrdef-decls", - "-attrdefs-dialect=llvm", - ], - "include/mlir/Dialect/LLVMIR/LLVMOpsAttrDefs.h.inc", - ), - ( - [ - "--gen-attrdef-defs", - "-attrdefs-dialect=llvm", - ], - "include/mlir/Dialect/LLVMIR/LLVMOpsAttrDefs.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/LLVMIR/LLVMOps.td", - deps = [":LLVMOpsTdFiles"], -) - -gentbl_cc_library( - name = "LLVMTypesIncGen", - tbl_outs = [ - ( - [ - "-gen-typedef-decls", - "-typedefs-dialect=llvm", - ], - "include/mlir/Dialect/LLVMIR/LLVMTypes.h.inc", - ), - ( - [ - "-gen-typedef-defs", - "-typedefs-dialect=llvm", - ], - "include/mlir/Dialect/LLVMIR/LLVMTypes.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/LLVMIR/LLVMTypes.td", - deps = [":LLVMOpsTdFiles"], -) - -gentbl_cc_library( - name = "LLVMIntrinsicOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td", - deps = [":LLVMOpsTdFiles"], -) - -gentbl_cc_library( - name = "LLVMConversionIncGen", - tbl_outs = [ - ( - ["-gen-llvmir-conversions"], - "include/mlir/Dialect/LLVMIR/LLVMConversions.inc", - ), - ( - ["-gen-enum-to-llvmir-conversions"], - "include/mlir/Dialect/LLVMIR/LLVMConversionEnumsToLLVM.inc", - ), - ( - ["-gen-enum-from-llvmir-conversions"], - "include/mlir/Dialect/LLVMIR/LLVMConversionEnumsFromLLVM.inc", - ), - ( - ["-gen-op-from-llvmir-conversions"], - "include/mlir/Dialect/LLVMIR/LLVMOpFromLLVMIRConversions.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/LLVMIR/LLVMOps.td", - deps = [":LLVMOpsTdFiles"], -) - -gentbl_cc_library( - name = "LLVMIntrinsicConversionIncGen", - tbl_outs = [ - ( - ["-gen-llvmir-conversions"], - "include/mlir/Dialect/LLVMIR/LLVMIntrinsicConversions.inc", - ), - ( - ["-gen-intr-from-llvmir-conversions"], - "include/mlir/Dialect/LLVMIR/LLVMIntrinsicFromLLVMIRConversions.inc", - ), - ( - ["-gen-convertible-llvmir-intrinsics"], - "include/mlir/Dialect/LLVMIR/LLVMConvertibleLLVMIRIntrinsics.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td", - deps = [":LLVMOpsTdFiles"], -) - -cc_library( - name = "NVVMDialect", - srcs = ["lib/Dialect/LLVMIR/IR/NVVMDialect.cpp"], - hdrs = ["include/mlir/Dialect/LLVMIR/NVVMDialect.h"], - includes = ["include"], - deps = [ - ":BasicPtxBuilderInterface", - ":ConvertToLLVMInterface", - ":DialectUtils", - ":GPUDialect", - ":IR", - ":LLVMDialect", - ":NVVMOpsIncGen", - ":SideEffectInterfaces", - ":Support", - "//llvm:AsmParser", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "TargetLLVM", - srcs = ["lib/Target/LLVM/ModuleToObject.cpp"], - hdrs = glob(["include/mlir/Target/LLVM/*.h"]), - includes = ["include"], - deps = [ - ":ExecutionEngineUtils", - ":IR", - ":LLVMToLLVMIRTranslation", - ":ToLLVMIRTranslation", - "//llvm:BitWriter", - "//llvm:Core", - "//llvm:IPO", - "//llvm:IRReader", - "//llvm:Linker", - "//llvm:MC", - "//llvm:Passes", - "//llvm:Support", - "//llvm:Target", - "//llvm:TargetParser", - ], -) - -cc_library( - name = "NVVMTarget", - srcs = ["lib/Target/LLVM/NVVM/Target.cpp"], - hdrs = glob(["include/mlir/Target/LLVM/NVVM/*.h"]), - includes = ["include"], - deps = [ - ":GPUDialect", - ":GPUToLLVMIRTranslation", - ":LLVMToLLVMIRTranslation", - ":NVVMDialect", - ":NVVMToLLVMIRTranslation", - ":TargetLLVM", - ":ToLLVMIRTranslation", - ":config", - "//llvm:NVPTXCodeGen", - "//llvm:Support", - "//llvm:config", - ], -) - -td_library( - name = "BasicPtxBuilderIntTdFiles", - srcs = [ - "include/mlir/Dialect/LLVMIR/BasicPtxBuilderInterface.td", - ], - includes = ["include"], - deps = [ - ":GPUOpsTdFiles", - ":LLVMOpsTdFiles", - ":OpBaseTdFiles", - ], -) - -td_library( - name = "NVVMOpsTdFiles", - srcs = ["include/mlir/Dialect/LLVMIR/NVVMOps.td"], - includes = ["include"], - deps = [ - ":BasicPtxBuilderIntTdFiles", - ":GPUOpsTdFiles", - ":LLVMOpsTdFiles", - ":OpBaseTdFiles", - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "BasicPtxBuilderIntGen", - tbl_outs = [ - ( - [ - "-gen-op-interface-decls", - ], - "include/mlir/Dialect/LLVMIR/BasicPtxBuilderInterface.h.inc", - ), - ( - [ - "-gen-op-interface-defs", - ], - "include/mlir/Dialect/LLVMIR/BasicPtxBuilderInterface.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/LLVMIR/BasicPtxBuilderInterface.td", - deps = [ - ":BasicPtxBuilderIntTdFiles", - ":GPUOpsTdFiles", - ":LLVMOpsTdFiles", - ], -) - -gentbl_cc_library( - name = "NVVMOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/LLVMIR/NVVMOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/LLVMIR/NVVMOps.cpp.inc", - ), - ( - [ - "-gen-dialect-decls", - "-dialect=nvvm", - ], - "include/mlir/Dialect/LLVMIR/NVVMOpsDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=nvvm", - ], - "include/mlir/Dialect/LLVMIR/NVVMOpsDialect.cpp.inc", - ), - ( - ["-gen-enum-decls"], - "include/mlir/Dialect/LLVMIR/NVVMOpsEnums.h.inc", - ), - ( - ["-gen-enum-defs"], - "include/mlir/Dialect/LLVMIR/NVVMOpsEnums.cpp.inc", - ), - ( - [ - "-gen-attrdef-decls", - "-attrdefs-dialect=nvvm", - ], - "include/mlir/Dialect/LLVMIR/NVVMOpsAttributes.h.inc", - ), - ( - [ - "-gen-attrdef-defs", - "-attrdefs-dialect=nvvm", - ], - "include/mlir/Dialect/LLVMIR/NVVMOpsAttributes.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/LLVMIR/NVVMOps.td", - deps = [":NVVMOpsTdFiles"], -) - -gentbl_cc_library( - name = "NVVMConversionIncGen", - tbl_outs = [ - ( - ["-gen-llvmir-conversions"], - "include/mlir/Dialect/LLVMIR/NVVMConversions.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/LLVMIR/NVVMOps.td", - deps = [":NVVMOpsTdFiles"], -) - -gentbl_cc_library( - name = "NVVMFromLLVMIRConversionsIncGen", - tbl_outs = [ - ( - ["-gen-intr-from-llvmir-conversions"], - "include/mlir/Dialect/LLVMIR/NVVMFromLLVMIRConversions.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/LLVMIR/NVVMOps.td", - deps = [":NVVMOpsTdFiles"], -) - -gentbl_cc_library( - name = "NVVMConvertibleLLVMIRIntrinsicsIncGen", - tbl_outs = [ - ( - ["-gen-convertible-llvmir-intrinsics"], - "include/mlir/Dialect/LLVMIR/NVVMConvertibleLLVMIRIntrinsics.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/LLVMIR/NVVMOps.td", - deps = [":NVVMOpsTdFiles"], -) - -cc_library( - name = "BasicPtxBuilderInterface", - srcs = ["lib/Dialect/LLVMIR/IR/BasicPtxBuilderInterface.cpp"], - hdrs = [ - "include/mlir/Dialect/LLVMIR/BasicPtxBuilderInterface.h", - ], - includes = ["include"], - deps = [ - ":BasicPtxBuilderIntGen", - ":IR", - ":LLVMDialect", - ":Support", - ], -) - -cc_library( - name = "NVVMToLLVM", - srcs = ["lib/Conversion/NVVMToLLVM/NVVMToLLVM.cpp"], - hdrs = glob(["include/mlir/Conversion/NVVMToLLVM/*.h"]), - includes = ["include"], - deps = [ - ":ConversionPassIncGen", - ":ConvertToLLVMInterface", - ":FuncDialect", - ":GPUDialect", - ":IR", - ":LLVMCommonConversion", - ":LLVMDialect", - ":MemRefDialect", - ":NVVMDialect", - ":NVVMOpsIncGen", - ":Pass", - ":Support", - "//llvm:Support", - ], -) - -cc_library( - name = "ROCDLDialect", - srcs = ["lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp"], - hdrs = ["include/mlir/Dialect/LLVMIR/ROCDLDialect.h"], - includes = ["include"], - deps = [ - ":GPUDialect", - ":IR", - ":LLVMDialect", - ":ROCDLOpsIncGen", - ":SideEffectInterfaces", - "//llvm:AsmParser", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "ROCDLTarget", - srcs = ["lib/Target/LLVM/ROCDL/Target.cpp"], - hdrs = glob(["include/mlir/Target/LLVM/ROCDL/*.h"]), - includes = ["include"], - deps = [ - ":GPUDialect", - ":GPUToLLVMIRTranslation", - ":LLVMToLLVMIRTranslation", - ":ROCDLDialect", - ":ROCDLToLLVMIRTranslation", - ":Support", - ":TargetLLVM", - ":ToLLVMIRTranslation", - "//llvm:Core", - "//llvm:MC", - "//llvm:MCParser", - "//llvm:Support", - "//llvm:TargetParser", - ], -) - -td_library( - name = "ROCDLOpsTdFiles", - srcs = ["include/mlir/Dialect/LLVMIR/ROCDLOps.td"], - includes = ["include"], - deps = [ - ":GPUOpsTdFiles", - ":LLVMOpsTdFiles", - ":OpBaseTdFiles", - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "ROCDLOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/LLVMIR/ROCDLOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/LLVMIR/ROCDLOps.cpp.inc", - ), - ( - [ - "-gen-dialect-decls", - "-dialect=rocdl", - ], - "include/mlir/Dialect/LLVMIR/ROCDLOpsDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=rocdl", - ], - "include/mlir/Dialect/LLVMIR/ROCDLOpsDialect.cpp.inc", - ), - ( - [ - "-gen-attrdef-decls", - "-attrdefs-dialect=rocdl", - ], - "include/mlir/Dialect/LLVMIR/ROCDLOpsAttributes.h.inc", - ), - ( - [ - "-gen-attrdef-defs", - "-attrdefs-dialect=rocdl", - ], - "include/mlir/Dialect/LLVMIR/ROCDLOpsAttributes.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/LLVMIR/ROCDLOps.td", - deps = [":ROCDLOpsTdFiles"], -) - -gentbl_cc_library( - name = "ROCDLConversionIncGen", - tbl_outs = [ - ( - ["-gen-llvmir-conversions"], - "include/mlir/Dialect/LLVMIR/ROCDLConversions.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/LLVMIR/ROCDLOps.td", - deps = [":ROCDLOpsTdFiles"], -) - -cc_library( - name = "PDLDialect", - srcs = glob([ - "lib/Dialect/PDL/IR/*.cpp", - "lib/Dialect/PDL/IR/*.h", - ]), - hdrs = glob([ - "include/mlir/Dialect/PDL/IR/*.h", - ]), - includes = ["include"], - deps = [ - ":IR", - ":InferTypeOpInterface", - ":PDLOpsIncGen", - ":PDLTypesIncGen", - ":SideEffectInterfaces", - "//llvm:Support", - ], -) - -td_library( - name = "PDLDialectTdFiles", - srcs = [ - "include/mlir/Dialect/PDL/IR/PDLDialect.td", - "include/mlir/Dialect/PDL/IR/PDLOps.td", - "include/mlir/Dialect/PDL/IR/PDLTypes.td", - ], - deps = [ - ":OpBaseTdFiles", - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "PDLOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/PDL/IR/PDLOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/PDL/IR/PDLOps.cpp.inc", - ), - ( - ["-gen-dialect-decls"], - "include/mlir/Dialect/PDL/IR/PDLOpsDialect.h.inc", - ), - ( - ["-gen-dialect-defs"], - "include/mlir/Dialect/PDL/IR/PDLOpsDialect.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/PDL/IR/PDLOps.td", - deps = [":PDLDialectTdFiles"], -) - -gentbl_cc_library( - name = "PDLTypesIncGen", - tbl_outs = [ - ( - ["-gen-typedef-decls"], - "include/mlir/Dialect/PDL/IR/PDLOpsTypes.h.inc", - ), - ( - ["-gen-typedef-defs"], - "include/mlir/Dialect/PDL/IR/PDLOpsTypes.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/PDL/IR/PDLTypes.td", - deps = [":PDLDialectTdFiles"], -) - -cc_library( - name = "PDLInterpDialect", - srcs = glob([ - "lib/Dialect/PDLInterp/IR/*.cpp", - "lib/Dialect/PDLInterp/IR/*.h", - ]), - hdrs = glob([ - "include/mlir/Dialect/PDLInterp/IR/*.h", - ]), - includes = ["include"], - deps = [ - ":FunctionInterfaces", - ":IR", - ":InferTypeOpInterface", - ":PDLDialect", - ":PDLInterpOpsIncGen", - ":SideEffectInterfaces", - "//llvm:Support", - ], -) - -td_library( - name = "PDLInterpOpsTdFiles", - srcs = ["include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td"], - includes = ["include"], - deps = [ - ":FunctionInterfacesTdFiles", - ":OpBaseTdFiles", - ":PDLDialectTdFiles", - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "PDLInterpOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.cpp.inc", - ), - ( - [ - "-gen-dialect-decls", - "-dialect=pdl_interp", - ], - "include/mlir/Dialect/PDLInterp/IR/PDLInterpOpsDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=pdl_interp", - ], - "include/mlir/Dialect/PDLInterp/IR/PDLInterpOpsDialect.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td", - deps = [":PDLInterpOpsTdFiles"], -) - -td_library( - name = "SPIRVOpsTdFiles", - srcs = glob(["include/mlir/Dialect/SPIRV/IR/*.td"]), - includes = ["include"], - deps = [ - ":BuiltinDialectTdFiles", - ":CallInterfacesTdFiles", - ":ControlFlowInterfacesTdFiles", - ":FunctionInterfacesTdFiles", - ":InferTypeOpInterfaceTdFiles", - ":OpBaseTdFiles", - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "SPIRVOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/SPIRV/IR/SPIRVOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/SPIRV/IR/SPIRVOps.cpp.inc", - ), - ( - ["-gen-dialect-decls"], - "include/mlir/Dialect/SPIRV/IR/SPIRVOpsDialect.h.inc", - ), - ( - ["-gen-dialect-defs"], - "include/mlir/Dialect/SPIRV/IR/SPIRVOpsDialect.cpp.inc", - ), - ( - ["-gen-op-doc"], - "g3doc/Dialects/SPIRV/SPIRVOps.md", - ), - ( - ["-gen-enum-decls"], - "include/mlir/Dialect/SPIRV/IR/SPIRVEnums.h.inc", - ), - ( - ["-gen-enum-defs"], - "include/mlir/Dialect/SPIRV/IR/SPIRVEnums.cpp.inc", - ), - ( - ["-gen-spirv-enum-avail-decls"], - "include/mlir/Dialect/SPIRV/IR/SPIRVEnumAvailability.h.inc", - ), - ( - ["-gen-spirv-enum-avail-defs"], - "include/mlir/Dialect/SPIRV/IR/SPIRVEnumAvailability.cpp.inc", - ), - ( - ["-gen-spirv-capability-implication"], - "include/mlir/Dialect/SPIRV/IR/SPIRVCapabilityImplication.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/SPIRV/IR/SPIRVOps.td", - deps = [":SPIRVOpsTdFiles"], -) - -gentbl_cc_library( - name = "SPIRVAttributesIncGen", - tbl_outs = [ - ( - ["-gen-attrdef-decls"], - "include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.h.inc", - ), - ( - ["-gen-attrdef-defs"], - "include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.td", - deps = [":SPIRVOpsTdFiles"], -) - -gentbl_cc_library( - name = "SPIRVCanonicalizationIncGen", - strip_include_prefix = "lib/Dialect/SPIRV/IR", - tbl_outs = [ - ( - ["-gen-rewriters"], - "lib/Dialect/SPIRV/IR/SPIRVCanonicalization.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "lib/Dialect/SPIRV/IR/SPIRVCanonicalization.td", - deps = [":SPIRVOpsTdFiles"], -) - -gentbl_cc_library( - name = "SPIRVAvailabilityIncGen", - tbl_outs = [ - ( - ["-gen-avail-interface-decls"], - "include/mlir/Dialect/SPIRV/IR/SPIRVAvailability.h.inc", - ), - ( - ["-gen-avail-interface-defs"], - "include/mlir/Dialect/SPIRV/IR/SPIRVAvailability.cpp.inc", - ), - ( - ["-gen-spirv-avail-impls"], - "include/mlir/Dialect/SPIRV/IR/SPIRVOpAvailabilityImpl.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/SPIRV/IR/SPIRVOps.td", - deps = [":SPIRVOpsTdFiles"], -) - -gentbl_cc_library( - name = "SPIRVAttrUtilsGen", - tbl_outs = [ - ( - ["-gen-spirv-attr-utils"], - "include/mlir/Dialect/SPIRV/IR/SPIRVAttrUtils.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/SPIRV/IR/SPIRVBase.td", - deps = [":SPIRVOpsTdFiles"], -) - -gentbl_cc_library( - name = "SPIRVSerializationGen", - tbl_outs = [ - ( - ["-gen-spirv-serialization"], - "include/mlir/Dialect/SPIRV/IR/SPIRVSerialization.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/SPIRV/IR/SPIRVOps.td", - deps = [":SPIRVOpsTdFiles"], -) - -cc_library( - name = "SPIRVDialect", - srcs = glob([ - "lib/Dialect/SPIRV/IR/*.cpp", - "lib/Dialect/SPIRV/IR/*.h", - ]) + ["include/mlir/Transforms/InliningUtils.h"], - hdrs = glob([ - "include/mlir/Dialect/SPIRV/IR/*.h", - ]), - includes = ["include"], - deps = [ - ":CommonFolders", - ":ControlFlowInterfaces", - ":FunctionInterfaces", - ":GPUDialect", - ":IR", - ":InferTypeOpInterface", - ":Parser", - ":SPIRVAttrUtilsGen", - ":SPIRVAttributesIncGen", - ":SPIRVAvailabilityIncGen", - ":SPIRVCanonicalizationIncGen", - ":SPIRVOpsIncGen", - ":SPIRVSerializationGen", - ":SideEffectInterfaces", - ":Support", - ":Transforms", - ":UBDialect", - "//llvm:Support", - ], -) - -cc_library( - name = "SPIRVTarget", - srcs = ["lib/Target/SPIRV/Target.cpp"], - hdrs = ["include/mlir/Target/SPIRV/Target.h"], - includes = ["include"], - deps = [ - ":GPUDialect", - ":SPIRVDialect", - ":SPIRVSerialization", - ], -) - -gentbl_cc_library( - name = "SPIRVPassIncGen", - tbl_outs = [ - ( - [ - "-gen-pass-decls", - "-name=SPIRV", - ], - "include/mlir/Dialect/SPIRV/Transforms/Passes.h.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/SPIRV/Transforms/Passes.td", - deps = [":PassBaseTdFiles"], -) - -cc_library( - name = "SPIRVUtils", - srcs = glob([ - "lib/Dialect/SPIRV/Utils/*.cpp", - ]), - hdrs = glob([ - "include/mlir/Dialect/SPIRV/Utils/*.h", - ]), - includes = ["include"], - deps = [ - ":SPIRVDialect", - "//llvm:Support", - ], -) - -cc_library( - name = "SPIRVConversion", - srcs = ["lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp"], - hdrs = ["include/mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"], - includes = ["include"], - deps = [ - ":FuncDialect", - ":IR", - ":SPIRVDialect", - ":TransformUtils", - "//llvm:Support", - ], -) - -cc_library( - name = "SPIRVTransforms", - srcs = glob( - [ - "lib/Dialect/SPIRV/Transforms/*.cpp", - "lib/Dialect/SPIRV/Transforms/*.h", - ], - exclude = ["lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp"], - ), - hdrs = glob( - ["include/mlir/Dialect/SPIRV/Transforms/*.h"], - exclude = ["include/mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"], - ), - includes = ["include"], - deps = [ - ":FuncDialect", - ":IR", - ":Pass", - ":SPIRVConversion", - ":SPIRVDialect", - ":SPIRVPassIncGen", - ":SPIRVUtils", - ":Support", - ":Transforms", - "//llvm:Support", - ], -) - -cc_library( - name = "SPIRVCommonConversion", - hdrs = ["lib/Conversion/SPIRVCommon/Pattern.h"], - includes = ["include"], - deps = [ - ":IR", - ":SPIRVDialect", - ":Transforms", - "//llvm:Support", - ], -) - -cc_library( - name = "MathToSPIRV", - srcs = glob([ - "lib/Conversion/MathToSPIRV/*.cpp", - "lib/Conversion/MathToSPIRV/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/MathToSPIRV/*.h", - ]), - includes = [ - "include", - "lib/Conversion/MathToSPIRV", - ], - deps = [ - ":ConversionPassIncGen", - ":IR", - ":MathDialect", - ":Pass", - ":SPIRVCommonConversion", - ":SPIRVConversion", - ":SPIRVDialect", - ":Support", - ":Transforms", - "//llvm:Support", - ], -) - -cc_library( - name = "FuncToEmitC", - srcs = glob([ - "lib/Conversion/FuncToEmitC/*.cpp", - "lib/Conversion/FuncToEmitC/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/FuncToEmitC/*.h", - ]), - includes = [ - "include", - "lib/Conversion/FuncToEmitC", - ], - deps = [ - ":ConversionPassIncGen", - ":EmitCDialect", - ":FuncDialect", - ":IR", - ":Pass", - ":Support", - ":TransformUtils", - ":Transforms", - "//llvm:Support", - ], -) - -cc_library( - name = "FuncToSPIRV", - srcs = glob([ - "lib/Conversion/FuncToSPIRV/*.cpp", - "lib/Conversion/FuncToSPIRV/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/FuncToSPIRV/*.h", - ]), - includes = [ - "include", - "lib/Conversion/FuncToSPIRV", - ], - deps = [ - ":ControlFlowToSPIRV", - ":ConversionPassIncGen", - ":FuncDialect", - ":IR", - ":MathToSPIRV", - ":Pass", - ":SPIRVCommonConversion", - ":SPIRVConversion", - ":SPIRVDialect", - ":SPIRVUtils", - ":Support", - ":TensorDialect", - ":Transforms", - ":VectorDialect", - "//llvm:Support", - ], -) - -cc_library( - name = "TensorToLinalg", - srcs = glob([ - "lib/Conversion/TensorToLinalg/*.cpp", - "lib/Conversion/TensorToLinalg/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/TensorToLinalg/*.h", - ]), - includes = [ - "include", - "lib/Conversion/TensorToLinalg", - ], - deps = [ - ":ArithDialect", - ":ConversionPassIncGen", - ":FuncDialect", - ":IR", - ":LinalgDialect", - ":LinalgTransforms", - ":Pass", - ":Support", - ":TensorDialect", - ":Transforms", - ":VectorDialect", - "//llvm:Support", - ], -) - -cc_library( - name = "TensorToSPIRV", - srcs = glob([ - "lib/Conversion/TensorToSPIRV/*.cpp", - "lib/Conversion/TensorToSPIRV/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/TensorToSPIRV/*.h", - ]), - includes = [ - "include", - "lib/Conversion/TensorToSPIRV", - ], - deps = [ - ":ArithToSPIRV", - ":ControlFlowToSPIRV", - ":ConversionPassIncGen", - ":FuncDialect", - ":FuncToSPIRV", - ":IR", - ":MathToSPIRV", - ":Pass", - ":SPIRVCommonConversion", - ":SPIRVConversion", - ":SPIRVDialect", - ":SPIRVUtils", - ":Support", - ":TensorDialect", - ":Transforms", - ":VectorDialect", - "//llvm:Support", - ], -) - -cc_library( - name = "SPIRVBinaryUtils", - srcs = ["lib/Target/SPIRV/SPIRVBinaryUtils.cpp"], - hdrs = ["include/mlir/Target/SPIRV/SPIRVBinaryUtils.h"], - includes = ["include"], - deps = [ - ":SPIRVAttrUtilsGen", - ":SPIRVDialect", - ":SPIRVOpsIncGen", - ":Support", - "//llvm:Support", - ], -) - -cc_library( - name = "SPIRVSerialization", - srcs = [ - "lib/Target/SPIRV/Serialization/Serialization.cpp", - "lib/Target/SPIRV/Serialization/SerializeOps.cpp", - "lib/Target/SPIRV/Serialization/Serializer.cpp", - "lib/Target/SPIRV/Serialization/Serializer.h", - ], - hdrs = ["include/mlir/Target/SPIRV/Serialization.h"], - includes = ["include"], - deps = [ - ":IR", - ":SPIRVAttrUtilsGen", - ":SPIRVBinaryUtils", - ":SPIRVDialect", - ":SPIRVOpsIncGen", - ":SPIRVSerializationGen", - ":Support", - ":Transforms", - "//llvm:Support", - ], -) - -cc_library( - name = "SPIRVDeserialization", - srcs = glob([ - "lib/Target/SPIRV/Deserialization/*.cpp", - "lib/Target/SPIRV/Deserialization/*.h", - ]), - hdrs = ["include/mlir/Target/SPIRV/Deserialization.h"], - includes = ["include"], - deps = [ - ":IR", - ":SPIRVAttrUtilsGen", - ":SPIRVBinaryUtils", - ":SPIRVDialect", - ":SPIRVOpsIncGen", - ":SPIRVSerializationGen", - ":Support", - ":Transforms", - "//llvm:Support", - ], -) - -cc_library( - name = "SPIRVModuleCombiner", - srcs = glob( - ["lib/Dialect/SPIRV/Linking/ModuleCombiner/*.cpp"], - ), - hdrs = ["include/mlir/Dialect/SPIRV/Linking/ModuleCombiner.h"], - includes = ["include"], - deps = [ - ":IR", - ":SPIRVDialect", - ":Support", - "//llvm:Support", - ], -) - -cc_library( - name = "SPIRVTranslateRegistration", - srcs = ["lib/Target/SPIRV/TranslateRegistration.cpp"], - includes = ["include"], - deps = [ - ":IR", - ":Parser", - ":SPIRVDeserialization", - ":SPIRVDialect", - ":SPIRVSerialization", - ":Support", - ":TranslateLib", - "//llvm:Support", - ], -) - -td_library( - name = "TensorOpsTdFiles", - srcs = [ - "include/mlir/Dialect/Tensor/IR/TensorBase.td", - "include/mlir/Dialect/Tensor/IR/TensorOps.td", - ], - includes = ["include"], - deps = [ - ":CastInterfacesTdFiles", - ":ControlFlowInterfacesTdFiles", - ":DestinationStyleOpInterfaceTdFiles", - ":InferTypeOpInterfaceTdFiles", - ":OpBaseTdFiles", - ":ParallelCombiningOpInterfaceTdFiles", - ":ShapedOpInterfacesTdFiles", - ":SideEffectInterfacesTdFiles", - ":TilingInterfaceTdFiles", - ":ViewLikeInterfaceTdFiles", - ], -) - -gentbl_cc_library( - name = "TensorOpsIncGen", - tbl_outs = [ - ( - [ - "-gen-dialect-decls", - "-dialect=tensor", - ], - "include/mlir/Dialect/Tensor/IR/TensorOpsDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=tensor", - ], - "include/mlir/Dialect/Tensor/IR/TensorOpsDialect.cpp.inc", - ), - ( - ["-gen-op-decls"], - "include/mlir/Dialect/Tensor/IR/TensorOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/Tensor/IR/TensorOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Tensor/IR/TensorOps.td", - deps = [":TensorOpsTdFiles"], -) - -cc_library( - name = "TensorDialect", - srcs = [ - "include/mlir/Transforms/InliningUtils.h", - "lib/Dialect/Tensor/IR/TensorDialect.cpp", - "lib/Dialect/Tensor/IR/TensorOps.cpp", - "lib/Dialect/Tensor/IR/ValueBoundsOpInterfaceImpl.cpp", - ], - hdrs = [ - "include/mlir/Dialect/Tensor/IR/Tensor.h", - "include/mlir/Dialect/Tensor/IR/ValueBoundsOpInterfaceImpl.h", - ], - includes = ["include"], - deps = [ - ":AffineDialect", - ":ArithDialect", - ":ArithUtils", - ":CastInterfaces", - ":ComplexDialect", - ":ControlFlowInterfaces", - ":DestinationStyleOpInterface", - ":DialectUtils", - ":IR", - ":InferTypeOpInterface", - ":LoopLikeInterface", - ":ParallelCombiningOpInterface", - ":ShapedOpInterfaces", - ":SideEffectInterfaces", - ":Support", - ":TensorOpsIncGen", - ":TilingInterface", - ":ValueBoundsOpInterface", - ":ViewLikeInterface", - "//llvm:Support", - ], -) - -cc_library( - name = "TensorInferTypeOpInterfaceImpl", - srcs = ["lib/Dialect/Tensor/IR/TensorInferTypeOpInterfaceImpl.cpp"], - hdrs = ["include/mlir/Dialect/Tensor/IR/TensorInferTypeOpInterfaceImpl.h"], - includes = ["include"], - deps = [ - ":AffineDialect", - ":ArithUtils", - ":DialectUtils", - ":IR", - ":InferTypeOpInterface", - ":TensorDialect", - "//llvm:Support", - ], -) - -cc_library( - name = "TensorTilingInterfaceImpl", - srcs = ["lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp"], - hdrs = ["include/mlir/Dialect/Tensor/IR/TensorTilingInterfaceImpl.h"], - includes = ["include"], - deps = [ - ":AffineDialect", - ":AffineUtils", - ":ArithUtils", - ":DialectUtils", - ":IR", - ":LinalgDialect", - ":LinalgUtils", - ":SCFDialect", - ":TensorDialect", - ":TensorUtils", - ":TilingInterface", - ":ValueBoundsOpInterface", - "//llvm:Support", - ], -) - -cc_library( - name = "TensorUtils", - srcs = ["lib/Dialect/Tensor/Utils/Utils.cpp"], - hdrs = ["include/mlir/Dialect/Tensor/Utils/Utils.h"], - includes = ["include"], - deps = [ - ":AffineDialect", - ":ArithDialect", - ":ArithUtils", - ":DialectUtils", - ":TensorDialect", - ":ValueBoundsOpInterface", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "TensorPassIncGen", - tbl_outs = [ - ( - [ - "-gen-pass-decls", - "-name=Tensor", - ], - "include/mlir/Dialect/Tensor/Transforms/Passes.h.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Tensor/Transforms/Passes.td", - deps = [":PassBaseTdFiles"], -) - -cc_library( - name = "TensorTransforms", - srcs = glob( - [ - "lib/Dialect/Tensor/Transforms/*.cpp", - "lib/Dialect/Tensor/Transforms/*.h", - ], - ), - hdrs = glob(["include/mlir/Dialect/Tensor/Transforms/*.h"]), - includes = ["include"], - deps = [ - ":AffineDialect", - ":AffineTransforms", - ":AffineUtils", - ":ArithDialect", - ":ArithUtils", - ":BufferizationDialect", - ":BufferizationTransforms", - ":DialectUtils", - ":FuncDialect", - ":IR", - ":LinalgDialect", - ":MemRefDialect", - ":Pass", - ":SCFDialect", - ":SubsetOpInterface", - ":TensorDialect", - ":TensorPassIncGen", - ":TensorUtils", - ":TilingInterface", - ":Transforms", - ":ValueBoundsOpInterface", - ":VectorDialect", - "//llvm:Support", - ], -) - -td_library( - name = "TensorTransformOpsTdFiles", - srcs = [ - "include/mlir/Dialect/Tensor/TransformOps/TensorTransformOps.td", - ], - includes = ["include"], - deps = [ - ":TransformDialectTdFiles", - ], -) - -gentbl_cc_library( - name = "TensorTransformOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/Tensor/TransformOps/TensorTransformOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/Tensor/TransformOps/TensorTransformOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Tensor/TransformOps/TensorTransformOps.td", - deps = [ - ":TensorTransformOpsTdFiles", - ], -) - -cc_library( - name = "TensorTransformOps", - srcs = glob(["lib/Dialect/Tensor/TransformOps/*.cpp"]), - hdrs = glob(["include/mlir/Dialect/Tensor/TransformOps/*.h"]), - includes = ["include"], - deps = [ - ":AffineDialect", - ":IR", - ":SCFDialect", - ":TensorDialect", - ":TensorTransformOpsIncGen", - ":TensorTransforms", - ":TensorUtils", - ":TransformDialect", - ":TransformUtils", - ], -) - -cc_library( - name = "Rewrite", - srcs = glob([ - "lib/Rewrite/*.cpp", - "lib/Rewrite/*.h", - ]), - hdrs = glob(["include/mlir/Rewrite/*.h"]), - includes = ["include"], - deps = [ - ":Analysis", - ":IR", - ":PDLDialect", - ":PDLInterpDialect", - ":PDLToPDLInterp", - ":Pass", - ":SideEffectInterfaces", - "//llvm:Support", - ], -) - -cc_library( - name = "TransformUtils", - srcs = glob([ - "lib/Transforms/Utils/*.cpp", - "lib/Transforms/Utils/*.h", - ]), - hdrs = glob( - [ - "include/mlir/Transforms/*.h", - ], - exclude = ["include/mlir/Transforms/Passes.h"], - ), - includes = ["include"], - deps = [ - ":Analysis", - ":ControlFlowInterfaces", - ":FunctionInterfaces", - ":IR", - ":LoopLikeInterface", - ":MemorySlotInterfaces", - ":Pass", - ":Rewrite", - ":SideEffectInterfaces", - ":SubsetOpInterface", - ":Support", - ":TransformsPassIncGen", - ":config", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "DerivedAttributeOpInterfaceIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Interfaces/DerivedAttributeOpInterface.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Interfaces/DerivedAttributeOpInterface.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Interfaces/DerivedAttributeOpInterface.td", - deps = [":DerivedAttributeOpInterfaceTdFiles"], -) - -cc_library( - name = "DerivedAttributeOpInterface", - srcs = ["lib/Interfaces/DerivedAttributeOpInterface.cpp"], - hdrs = ["include/mlir/Interfaces/DerivedAttributeOpInterface.h"], - includes = ["include"], - deps = [ - ":DerivedAttributeOpInterfaceIncGen", - ":IR", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "DestinationStyleOpInterfaceIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Interfaces/DestinationStyleOpInterface.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Interfaces/DestinationStyleOpInterface.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Interfaces/DestinationStyleOpInterface.td", - deps = [":DestinationStyleOpInterfaceTdFiles"], -) - -cc_library( - name = "DestinationStyleOpInterface", - srcs = ["lib/Interfaces/DestinationStyleOpInterface.cpp"], - hdrs = ["include/mlir/Interfaces/DestinationStyleOpInterface.h"], - includes = ["include"], - deps = [ - ":DestinationStyleOpInterfaceIncGen", - ":IR", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "InferIntRangeInterfaceIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Interfaces/InferIntRangeInterface.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Interfaces/InferIntRangeInterface.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Interfaces/InferIntRangeInterface.td", - deps = [":InferIntRangeInterfaceTdFiles"], -) - -cc_library( - name = "InferIntRangeInterface", - srcs = ["lib/Interfaces/InferIntRangeInterface.cpp"], - hdrs = ["include/mlir/Interfaces/InferIntRangeInterface.h"], - includes = ["include"], - deps = [ - ":IR", - ":InferIntRangeInterfaceIncGen", - "//llvm:Support", - ], -) - -td_library( - name = "DataLayoutInterfacesTdFiles", - srcs = ["include/mlir/Interfaces/DataLayoutInterfaces.td"], - includes = ["include"], -) - -gentbl_cc_library( - name = "DataLayoutInterfacesIncGen", - tbl_outs = [ - ( - ["-gen-attr-interface-decls"], - "include/mlir/Interfaces/DataLayoutAttrInterface.h.inc", - ), - ( - ["-gen-attr-interface-defs"], - "include/mlir/Interfaces/DataLayoutAttrInterface.cpp.inc", - ), - ( - ["-gen-op-interface-decls"], - "include/mlir/Interfaces/DataLayoutOpInterface.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Interfaces/DataLayoutOpInterface.cpp.inc", - ), - ( - ["-gen-type-interface-decls"], - "include/mlir/Interfaces/DataLayoutTypeInterface.h.inc", - ), - ( - ["-gen-type-interface-defs"], - "include/mlir/Interfaces/DataLayoutTypeInterface.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Interfaces/DataLayoutInterfaces.td", - deps = [":OpBaseTdFiles"], -) - -gentbl_cc_library( - name = "LoopLikeInterfaceIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Interfaces/LoopLikeInterface.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Interfaces/LoopLikeInterface.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Interfaces/LoopLikeInterface.td", - deps = [":LoopLikeInterfaceTdFiles"], -) - -gentbl_cc_library( - name = "MemorySlotInterfacesIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Interfaces/MemorySlotOpInterfaces.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Interfaces/MemorySlotOpInterfaces.cpp.inc", - ), - ( - ["-gen-type-interface-decls"], - "include/mlir/Interfaces/MemorySlotTypeInterfaces.h.inc", - ), - ( - ["-gen-type-interface-defs"], - "include/mlir/Interfaces/MemorySlotTypeInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Interfaces/MemorySlotInterfaces.td", - deps = [":MemorySlotInterfacesTdFiles"], -) - -gentbl_cc_library( - name = "ShapedOpInterfacesIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Interfaces/ShapedOpInterfaces.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Interfaces/ShapedOpInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Interfaces/ShapedOpInterfaces.td", - deps = [":ShapedOpInterfacesTdFiles"], -) - -gentbl_cc_library( - name = "ParallelCombiningOpInterfaceIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Interfaces/ParallelCombiningOpInterface.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Interfaces/ParallelCombiningOpInterface.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Interfaces/ParallelCombiningOpInterface.td", - deps = [":ParallelCombiningOpInterfaceTdFiles"], -) - -gentbl_cc_library( - name = "RuntimeVerifiableOpInterfaceIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Interfaces/RuntimeVerifiableOpInterface.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Interfaces/RuntimeVerifiableOpInterface.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Interfaces/RuntimeVerifiableOpInterface.td", - deps = [":RuntimeVerifiableOpInterfaceTdFiles"], -) - -gentbl_cc_library( - name = "VectorInterfacesIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Interfaces/VectorInterfaces.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Interfaces/VectorInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Interfaces/VectorInterfaces.td", - deps = [":VectorInterfacesTdFiles"], -) - -gentbl_cc_library( - name = "ViewLikeInterfaceIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Interfaces/ViewLikeInterface.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Interfaces/ViewLikeInterface.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Interfaces/ViewLikeInterface.td", - deps = [":ViewLikeInterfaceTdFiles"], -) - -gentbl_cc_library( - name = "CopyOpInterfaceIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Interfaces/CopyOpInterface.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Interfaces/CopyOpInterface.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Interfaces/CopyOpInterface.td", - deps = [":CopyOpInterfaceTdFiles"], -) - -gentbl_cc_library( - name = "TransformsPassIncGen", - tbl_outs = [ - ( - [ - "-gen-pass-decls", - "-name=Transforms", - ], - "include/mlir/Transforms/Passes.h.inc", - ), - ( - [ - "-gen-pass-capi-header", - "--prefix=Transforms", - ], - "include/mlir/Transforms/Transforms.capi.h.inc", - ), - ( - [ - "-gen-pass-capi-impl", - "--prefix=Transforms", - ], - "include/mlir/Transforms/Transforms.capi.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Transforms/Passes.td", - deps = [ - ":PassBaseTdFiles", - ":RewritePassBaseTdFiles", - ], -) - -cc_library( - name = "Transforms", - srcs = glob([ - "lib/Transforms/*.cpp", - "lib/Transforms/*.h", - ]), - hdrs = glob(["include/mlir/Transforms/*.h"]), - includes = ["include"], - deps = [ - ":Analysis", - ":ControlFlowInterfaces", - ":FunctionInterfaces", - ":IR", - ":LoopLikeInterface", - ":MemorySlotInterfaces", - ":Pass", - ":Rewrite", - ":RuntimeVerifiableOpInterface", - ":Support", - ":TransformUtils", - ":TransformsPassIncGen", - ":config", - "//llvm:Support", - ], -) - -cc_library( - name = "CommonFolders", - srcs = [ - ], - hdrs = ["include/mlir/Dialect/CommonFolders.h"], - includes = ["include"], - deps = [ - ":IR", - "//llvm:Support", - ], -) - -cc_library( - name = "SCFToGPU", - srcs = glob(["lib/Conversion/SCFToGPU/*.cpp"]), - hdrs = glob(["include/mlir/Conversion/SCFToGPU/*.h"]), - includes = ["include"], - deps = [ - ":AffineDialect", - ":AffineToStandard", - ":ArithDialect", - ":ComplexDialect", - ":ConversionPassIncGen", - ":FuncDialect", - ":FunctionInterfaces", - ":GPUDialect", - ":GPUTransforms", - ":IR", - ":MemRefDialect", - ":Pass", - ":SCFDialect", - ":SideEffectInterfaces", - ":Support", - ":TransformUtils", - ":Transforms", - "//llvm:Support", - ], -) - -cc_library( - name = "SCFToEmitC", - srcs = glob(["lib/Conversion/SCFToEmitC/*.cpp"]), - hdrs = glob(["include/mlir/Conversion/SCFToEmitC/*.h"]), - includes = ["include"], - deps = [ - ":ArithDialect", - ":ControlFlowInterfaces", - ":ConversionPassIncGen", - ":EmitCDialect", - ":IR", - ":Pass", - ":SCFDialect", - ":Support", - ":TransformUtils", - ":Transforms", - "//llvm:Support", - ], -) - -cc_library( - name = "SCFToSPIRV", - srcs = glob([ - "lib/Conversion/SCFToSPIRV/*.cpp", - "lib/Conversion/SCFToSPIRV/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/SCFToSPIRV/*.h", - ]), - includes = ["include"], - deps = [ - ":AffineDialect", - ":ArithToSPIRV", - ":ConversionPassIncGen", - ":FuncDialect", - ":FuncToSPIRV", - ":IR", - ":IndexToSPIRV", - ":MemRefToSPIRV", - ":Pass", - ":SCFDialect", - ":SPIRVConversion", - ":SPIRVDialect", - ":Support", - ":TransformUtils", - ":Transforms", - "//llvm:Support", - ], -) - -cc_library( - name = "SCFToOpenMP", - srcs = [ - "lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp", - ], - hdrs = ["include/mlir/Conversion/SCFToOpenMP/SCFToOpenMP.h"], - includes = ["include"], - deps = [ - ":AffineAnalysis", - ":Analysis", - ":ArithDialect", - ":ConversionPassIncGen", - ":FuncDialect", - ":IR", - ":LLVMDialect", - ":MemRefDialect", - ":OpenMPDialect", - ":Pass", - ":SCFDialect", - ":Support", - ":Transforms", - ], -) - -cc_library( - name = "SCFToControlFlow", - srcs = [ - "lib/Conversion/SCFToControlFlow/SCFToControlFlow.cpp", - ], - hdrs = ["include/mlir/Conversion/SCFToControlFlow/SCFToControlFlow.h"], - includes = ["include"], - deps = [ - ":ArithDialect", - ":ControlFlowDialect", - ":ConversionPassIncGen", - ":FuncDialect", - ":IR", - ":LLVMDialect", - ":Pass", - ":SCFDialect", - ":Support", - ":TransformUtils", - ":Transforms", - ], -) - -cc_library( - name = "LLVMCommonConversion", - srcs = glob([ - "lib/Conversion/LLVMCommon/*.cpp", - ]) + ["lib/Conversion/LLVMCommon/MemRefDescriptor.h"], - hdrs = glob(["include/mlir/Conversion/LLVMCommon/*.h"]), - includes = ["include"], - deps = [ - ":IR", - ":LLVMDialect", - ":Support", - ":Transforms", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "ReconcileUnrealizedCasts", - srcs = glob(["lib/Conversion/ReconcileUnrealizedCasts/*.cpp"]), - hdrs = glob(["include/mlir/Conversion/ReconcileUnrealizedCasts/*.h"]), - includes = ["include"], - deps = [ - ":ConversionPassIncGen", - ":IR", - ":Pass", - ":TransformUtils", - ], -) - -cc_library( - name = "ConvertToLLVMInterface", - srcs = ["lib/Conversion/ConvertToLLVM/ToLLVMInterface.cpp"], - hdrs = ["include/mlir/Conversion/ConvertToLLVM/ToLLVMInterface.h"], - includes = ["include"], - deps = [ - ":IR", - ":Support", - "//llvm:Support", - ], -) - -cc_library( - name = "ConvertToLLVM", - srcs = ["lib/Conversion/ConvertToLLVM/ConvertToLLVMPass.cpp"], - hdrs = ["include/mlir/Conversion/ConvertToLLVM/ToLLVMPass.h"], - includes = ["include"], - deps = [ - ":ConversionPassIncGen", - ":ConvertToLLVMInterface", - ":IR", - ":LLVMCommonConversion", - ":LLVMDialect", - ":Pass", - ":Rewrite", - ":Support", - ":TransformUtils", - "//llvm:Support", - ], -) - -cc_library( - name = "FuncToLLVM", - srcs = [ - "lib/Conversion/FuncToLLVM/FuncToLLVM.cpp", - ], - hdrs = [ - "include/mlir/Conversion/FuncToLLVM/ConvertFuncToLLVM.h", - "include/mlir/Conversion/FuncToLLVM/ConvertFuncToLLVMPass.h", - ], - includes = ["include"], - deps = [ - ":Analysis", - ":ArithToLLVM", - ":ControlFlowToLLVM", - ":ConversionPassIncGen", - ":ConvertToLLVMInterface", - ":DataLayoutInterfaces", - ":DialectUtils", - ":FuncDialect", - ":FuncTransforms", - ":FunctionInterfaces", - ":IR", - ":LLVMCommonConversion", - ":LLVMDialect", - ":MathDialect", - ":MemRefDialect", - ":Parser", - ":Pass", - ":Support", - ":TransformUtils", - ":Transforms", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "ControlFlowToSCF", - srcs = [ - "lib/Conversion/ControlFlowToSCF/ControlFlowToSCF.cpp", - ], - hdrs = [ - "include/mlir/Conversion/ControlFlowToSCF/ControlFlowToSCF.h", - ], - includes = ["include"], - deps = [ - ":ArithDialect", - ":ControlFlowDialect", - ":ConversionPassIncGen", - ":FuncDialect", - ":LLVMDialect", - ":Pass", - ":SCFDialect", - ":Transforms", - ":UBDialect", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "ControlFlowToLLVM", - srcs = [ - "lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp", - ], - hdrs = [ - "include/mlir/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.h", - ], - includes = ["include"], - deps = [ - ":Analysis", - ":ArithToLLVM", - ":ControlFlowDialect", - ":ConversionPassIncGen", - ":ConvertToLLVMInterface", - ":DataLayoutInterfaces", - ":DialectUtils", - ":IR", - ":LLVMCommonConversion", - ":LLVMDialect", - ":MathDialect", - ":MemRefDialect", - ":Parser", - ":Pass", - ":Support", - ":TransformUtils", - ":Transforms", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "ControlFlowToSPIRV", - srcs = glob(["lib/Conversion/ControlFlowToSPIRV/*.cpp"]), - hdrs = glob(["include/mlir/Conversion/ControlFlowToSPIRV/*.h"]), - includes = ["include"], - deps = [ - ":ControlFlowDialect", - ":ConversionPassIncGen", - ":IR", - ":Pass", - ":SPIRVCommonConversion", - ":SPIRVConversion", - ":SPIRVDialect", - ":SPIRVUtils", - ":Support", - ":Transforms", - "//llvm:Support", - ], -) - -cc_library( - name = "MemRefToLLVM", - srcs = glob(["lib/Conversion/MemRefToLLVM/*.cpp"]), - hdrs = glob(["include/mlir/Conversion/MemRefToLLVM/*.h"]), - includes = ["include"], - deps = [ - ":Analysis", - ":ArithDialect", - ":ConversionPassIncGen", - ":ConvertToLLVMInterface", - ":DataLayoutInterfaces", - ":FuncDialect", - ":IR", - ":LLVMCommonConversion", - ":LLVMDialect", - ":MemRefDialect", - ":MemRefUtils", - ":Pass", - ":Support", - ":Transforms", - "//llvm:Support", - ], -) - -cc_library( - name = "MemRefToSPIRV", - srcs = glob([ - "lib/Conversion/MemRefToSPIRV/*.cpp", - "lib/Conversion/MemRefToSPIRV/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/MemRefToSPIRV/*.h", - ]), - includes = [ - "include", - "lib/Conversion/MemRefToSPIRV", - ], - deps = [ - ":ArithDialect", - ":ConversionPassIncGen", - ":FuncDialect", - ":FunctionInterfaces", - ":IR", - ":MemRefDialect", - ":Pass", - ":SPIRVConversion", - ":SPIRVDialect", - ":Support", - ":Transforms", - "//llvm:Support", - ], -) - -cc_library( - name = "ArithAttrToLLVMConversion", - srcs = glob(["lib/Conversion/ArithCommon/*.cpp"]), - hdrs = glob(["include/mlir/Conversion/ArithCommon/*.h"]), - includes = ["include"], - deps = [ - ":ArithDialect", - ":LLVMDialect", - ], -) - -cc_library( - name = "ArithToAMDGPU", - srcs = glob(["lib/Conversion/ArithToAMDGPU/*.cpp"]), - hdrs = glob(["include/mlir/Conversion/ArithToAMDGPU/*.h"]), - includes = ["include"], - deps = [ - ":AMDGPUDialect", - ":ArithDialect", - ":ArithUtils", - ":ConversionPassIncGen", - ":ConvertToLLVMInterface", - ":IR", - ":LLVMDialect", - ":Pass", - ":Support", - ":Transforms", - ":VectorDialect", - ], -) - -cc_library( - name = "ArithToArmSME", - srcs = glob([ - "lib/Conversion/ArithToArmSME/*.cpp", - "lib/Conversion/ArithToArmSME/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/ArithToArmSME/*.h", - ]), - includes = ["include"], - deps = [ - ":ArithDialect", - ":ArmSMEDialect", - ":ConversionPassIncGen", - ":IR", - ":Pass", - ":Transforms", - "//llvm:Support", - ], -) - -cc_library( - name = "ArithToEmitC", - srcs = glob([ - "lib/Conversion/ArithToEmitC/*.cpp", - "lib/Conversion/ArithToEmitC/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/ArithToEmitC/*.h", - ]), - includes = [ - "include", - "lib/Conversion/ArithToEmitC", - ], - deps = [ - ":ArithDialect", - ":ConversionPassIncGen", - ":EmitCDialect", - ":IR", - ":Pass", - ":Support", - ":TransformUtils", - ":Transforms", - "//llvm:Support", - ], -) - -cc_library( - name = "ArithToLLVM", - srcs = glob(["lib/Conversion/ArithToLLVM/*.cpp"]), - hdrs = glob(["include/mlir/Conversion/ArithToLLVM/*.h"]), - includes = ["include"], - deps = [ - ":Analysis", - ":ArithAttrToLLVMConversion", - ":ArithDialect", - ":ConversionPassIncGen", - ":ConvertToLLVMInterface", - ":IR", - ":LLVMCommonConversion", - ":LLVMDialect", - ":Pass", - ":Support", - ":Transforms", - ], -) - -cc_library( - name = "ArithToSPIRV", - srcs = glob(["lib/Conversion/ArithToSPIRV/*.cpp"]), - hdrs = glob(["include/mlir/Conversion/ArithToSPIRV/*.h"]), - includes = ["include"], - deps = [ - ":ArithDialect", - ":ConversionPassIncGen", - ":FuncToSPIRV", - ":IR", - ":Pass", - ":SPIRVCommonConversion", - ":SPIRVConversion", - ":SPIRVDialect", - ":Support", - ":Transforms", - "//llvm:Support", - ], -) - -cc_library( - name = "MathToLLVM", - srcs = glob(["lib/Conversion/MathToLLVM/*.cpp"]), - hdrs = glob(["include/mlir/Conversion/MathToLLVM/*.h"]), - includes = ["include"], - deps = [ - ":Analysis", - ":ArithAttrToLLVMConversion", - ":ConversionPassIncGen", - ":ConvertToLLVMInterface", - ":DataLayoutInterfaces", - ":IR", - ":LLVMCommonConversion", - ":LLVMDialect", - ":MathDialect", - ":Pass", - ":Support", - ":Transforms", - ], -) - -cc_library( - name = "MathToFuncs", - srcs = glob(["lib/Conversion/MathToFuncs/*.cpp"]), - hdrs = glob(["include/mlir/Conversion/MathToFuncs/*.h"]), - includes = ["include"], - deps = [ - ":ArithDialect", - ":ControlFlowDialect", - ":ConversionPassIncGen", - ":DialectUtils", - ":FuncDialect", - ":IR", - ":LLVMDialect", - ":MathDialect", - ":Pass", - ":SCFDialect", - ":Transforms", - ":VectorDialect", - ":VectorUtils", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "BytecodeOpInterfaceIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Bytecode/BytecodeOpInterface.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Bytecode/BytecodeOpInterface.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Bytecode/BytecodeOpInterface.td", - deps = [":BytecodeOpInterfaceTdFiles"], -) - -gentbl_cc_library( - name = "CallOpInterfacesIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Interfaces/CallInterfaces.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Interfaces/CallInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Interfaces/CallInterfaces.td", - deps = [":CallInterfacesTdFiles"], -) - -cc_library( - name = "CallOpInterfaces", - srcs = ["lib/Interfaces/CallInterfaces.cpp"], - hdrs = ["include/mlir/Interfaces/CallInterfaces.h"], - includes = ["include"], - deps = [ - ":CallOpInterfacesIncGen", - ":IR", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "CastInterfacesIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Interfaces/CastInterfaces.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Interfaces/CastInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Interfaces/CastInterfaces.td", - deps = [":CastInterfacesTdFiles"], -) - -cc_library( - name = "CastInterfaces", - srcs = ["lib/Interfaces/CastInterfaces.cpp"], - hdrs = ["include/mlir/Interfaces/CastInterfaces.h"], - includes = ["include"], - deps = [ - ":CastInterfacesIncGen", - ":IR", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "ControlFlowInterfacesIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Interfaces/ControlFlowInterfaces.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Interfaces/ControlFlowInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Interfaces/ControlFlowInterfaces.td", - deps = [":ControlFlowInterfacesTdFiles"], -) - -cc_library( - name = "ControlFlowInterfaces", - srcs = ["lib/Interfaces/ControlFlowInterfaces.cpp"], - hdrs = ["include/mlir/Interfaces/ControlFlowInterfaces.h"], - includes = ["include"], - deps = [ - ":ControlFlowInterfacesIncGen", - ":IR", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "InferTypeOpInterfaceIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Interfaces/InferTypeOpInterface.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Interfaces/InferTypeOpInterface.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Interfaces/InferTypeOpInterface.td", - deps = [":InferTypeOpInterfaceTdFiles"], -) - -cc_library( - name = "InferTypeOpInterface", - srcs = ["lib/Interfaces/InferTypeOpInterface.cpp"], - hdrs = ["include/mlir/Interfaces/InferTypeOpInterface.h"], - includes = ["include"], - deps = [ - ":IR", - ":InferTypeOpInterfaceIncGen", - ":Support", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "SideEffectInterfacesIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Interfaces/SideEffectInterfaces.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Interfaces/SideEffectInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Interfaces/SideEffectInterfaces.td", - deps = [":SideEffectInterfacesTdFiles"], -) - -cc_library( - name = "SideEffectInterfaces", - srcs = ["lib/Interfaces/SideEffectInterfaces.cpp"], - hdrs = ["include/mlir/Interfaces/SideEffectInterfaces.h"], - includes = ["include"], - deps = [ - ":IR", - ":SideEffectInterfacesIncGen", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "TilingInterfaceIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Interfaces/TilingInterface.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Interfaces/TilingInterface.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Interfaces/TilingInterface.td", - deps = [":TilingInterfaceTdFiles"], -) - -cc_library( - name = "Analysis", - srcs = glob( - [ - "lib/Analysis/*.cpp", - "lib/Analysis/*.h", - "lib/Analysis/*/*.cpp", - "lib/Analysis/*/*.h", - ], - ), - hdrs = glob( - [ - "include/mlir/Analysis/*.h", - "include/mlir/Analysis/*/*.h", - ], - ), - copts = [ - "$(STACK_FRAME_UNLIMITED)", - ], - includes = ["include"], - deps = [ - ":ArithDialect", - ":CallOpInterfaces", - ":ControlFlowInterfaces", - ":DataLayoutInterfaces", - ":FunctionInterfaces", - ":IR", - ":InferIntRangeInterface", - ":LoopLikeInterface", - ":Pass", - ":SideEffectInterfaces", - ":Support", - ":ViewLikeInterface", - "//llvm:Support", - "//llvm:config", - ], -) - -cc_library( - name = "TranslateLib", - srcs = glob([ - "lib/Tools/mlir-translate/*.cpp", - ]) + [ - "include/mlir/Tools/ParseUtilities.h", - ], - hdrs = glob(["include/mlir/Tools/mlir-translate/*.h"]), - includes = ["include"], - deps = [ - ":IR", - ":Parser", - ":Support", - "//llvm:Support", - ], -) - -cc_library( - name = "ToLLVMIRTranslation", - srcs = [ - "lib/Target/LLVMIR/DebugTranslation.cpp", - "lib/Target/LLVMIR/DebugTranslation.h", - "lib/Target/LLVMIR/LoopAnnotationTranslation.cpp", - "lib/Target/LLVMIR/LoopAnnotationTranslation.h", - "lib/Target/LLVMIR/ModuleTranslation.cpp", - "lib/Target/LLVMIR/TypeToLLVM.cpp", - ], - hdrs = [ - "include/mlir/Target/LLVMIR/Export.h", - "include/mlir/Target/LLVMIR/LLVMTranslationInterface.h", - "include/mlir/Target/LLVMIR/ModuleTranslation.h", - "include/mlir/Target/LLVMIR/TypeToLLVM.h", - "lib/Target/LLVMIR/AttrKindDetail.h", - ], - includes = ["include"], - deps = [ - ":DLTIDialect", - ":IR", - ":LLVMConversionIncGen", - ":LLVMDialect", - ":LLVMIRTransforms", - ":LLVMIntrinsicConversionIncGen", - ":OpenMPDialect", - ":Support", - ":TransformUtils", - "//llvm:Core", - "//llvm:FrontendOpenMP", - "//llvm:Support", - "//llvm:TransformUtils", - ], -) - -cc_library( - name = "AMXToLLVMIRTranslation", - srcs = glob(["lib/Target/LLVMIR/Dialect/AMX/*.cpp"]), - hdrs = glob(["include/mlir/Target/LLVMIR/Dialect/AMX/*.h"]), - includes = ["include"], - deps = [ - ":AMXConversionIncGen", - ":AMXDialect", - ":IR", - ":ToLLVMIRTranslation", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "X86VectorToLLVMIRTranslation", - srcs = glob(["lib/Target/LLVMIR/Dialect/X86Vector/*.cpp"]), - hdrs = glob(["include/mlir/Target/LLVMIR/Dialect/X86Vector/*.h"]), - includes = ["include"], - deps = [ - ":IR", - ":ToLLVMIRTranslation", - ":X86VectorConversionIncGen", - ":X86VectorDialect", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "ArmNeonToLLVMIRTranslation", - srcs = glob(["lib/Target/LLVMIR/Dialect/ArmNeon/*.cpp"]), - hdrs = glob(["include/mlir/Target/LLVMIR/Dialect/ArmNeon/*.h"]), - includes = ["include"], - deps = [ - ":ArmNeonConversionIncGen", - ":ArmNeonDialect", - ":ArmNeonIncGen", - ":IR", - ":ToLLVMIRTranslation", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "ArmSMEToLLVMIRTranslation", - srcs = glob(["lib/Target/LLVMIR/Dialect/ArmSME/*.cpp"]), - hdrs = glob(["include/mlir/Target/LLVMIR/Dialect/ArmSME/*.h"]), - includes = ["include"], - deps = [ - ":ArmSMEConversionIncGen", - ":ArmSMEDialect", - ":ArmSMEIntrinsicOpsIncGen", - ":IR", - ":ToLLVMIRTranslation", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "ArmSVEToLLVMIRTranslation", - srcs = glob(["lib/Target/LLVMIR/Dialect/ArmSVE/*.cpp"]), - hdrs = glob(["include/mlir/Target/LLVMIR/Dialect/ArmSVE/*.h"]), - includes = ["include"], - deps = [ - ":ArmSVEConversionIncGen", - ":ArmSVEDialect", - ":IR", - ":ToLLVMIRTranslation", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "NVVMToLLVMIRTranslation", - srcs = ["lib/Target/LLVMIR/Dialect/NVVM/NVVMToLLVMIRTranslation.cpp"], - hdrs = ["include/mlir/Target/LLVMIR/Dialect/NVVM/NVVMToLLVMIRTranslation.h"], - includes = ["include"], - deps = [ - ":DialectUtils", - ":IR", - ":NVVMConversionIncGen", - ":NVVMDialect", - ":Support", - ":ToLLVMIRTranslation", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "ROCDLToLLVMIRTranslation", - srcs = glob(["lib/Target/LLVMIR/Dialect/ROCDL/*.cpp"]), - hdrs = glob(["include/mlir/Target/LLVMIR/Dialect/ROCDL/*.h"]), - includes = ["include"], - deps = [ - ":IR", - ":ROCDLConversionIncGen", - ":ROCDLDialect", - ":ToLLVMIRTranslation", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "SPIRVToLLVMIRTranslation", - srcs = glob(["lib/Target/LLVMIR/Dialect/SPIRV/*.cpp"]), - hdrs = glob(["include/mlir/Target/LLVMIR/Dialect/SPIRV/*.h"]), - includes = ["include"], - deps = [ - ":IR", - ":SPIRVDialect", - ":ToLLVMIRTranslation", - ], -) - -cc_library( - name = "GPUToLLVMIRTranslation", - srcs = [ - "lib/Target/LLVMIR/Dialect/GPU/GPUToLLVMIRTranslation.cpp", - "lib/Target/LLVMIR/Dialect/GPU/SelectObjectAttr.cpp", - ], - hdrs = ["include/mlir/Target/LLVMIR/Dialect/GPU/GPUToLLVMIRTranslation.h"], - includes = ["include"], - deps = [ - ":GPUDialect", - ":IR", - ":ToLLVMIRTranslation", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "BuiltinToLLVMIRTranslation", - srcs = ["lib/Target/LLVMIR/Dialect/Builtin/BuiltinToLLVMIRTranslation.cpp"], - hdrs = ["include/mlir/Target/LLVMIR/Dialect/Builtin/BuiltinToLLVMIRTranslation.h"], - includes = ["include"], - deps = [ - ":IR", - ":ToLLVMIRTranslation", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "LLVMToLLVMIRTranslation", - srcs = ["lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp"], - hdrs = ["include/mlir/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.h"], - includes = ["include"], - deps = [ - ":IR", - ":LLVMConversionIncGen", - ":LLVMDialect", - ":LLVMIntrinsicConversionIncGen", - ":Support", - ":ToLLVMIRTranslation", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "OpenMPCommon", - srcs = ["lib/Target/LLVMIR/Dialect/OpenMPCommon.cpp"], - hdrs = ["include/mlir/Target/LLVMIR/Dialect/OpenMPCommon.h"], - includes = ["include"], - deps = [ - ":IR", - ":Support", - "//llvm:Core", - "//llvm:FrontendOpenMP", - ], -) - -cc_library( - name = "LLVMIRToLLVMTranslation", - srcs = ["lib/Target/LLVMIR/Dialect/LLVMIR/LLVMIRToLLVMTranslation.cpp"], - hdrs = ["include/mlir/Target/LLVMIR/Dialect/LLVMIR/LLVMIRToLLVMTranslation.h"], - includes = ["include"], - deps = [ - ":FromLLVMIRTranslation", - ":LLVMConversionIncGen", - ":LLVMDialect", - ":LLVMIntrinsicConversionIncGen", - ":Support", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "LLVMIRToNVVMTranslation", - srcs = ["lib/Target/LLVMIR/Dialect/NVVM/LLVMIRToNVVMTranslation.cpp"], - hdrs = ["include/mlir/Target/LLVMIR/Dialect/NVVM/LLVMIRToNVVMTranslation.h"], - includes = ["include"], - deps = [ - ":FromLLVMIRTranslation", - ":IR", - ":NVVMConvertibleLLVMIRIntrinsicsIncGen", - ":NVVMDialect", - ":NVVMFromLLVMIRConversionsIncGen", - ":Support", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "OpenACCToLLVMIRTranslation", - srcs = glob(["lib/Target/LLVMIR/Dialect/OpenACC/*.cpp"]), - hdrs = glob(["include/mlir/Target/LLVMIR/Dialect/OpenACC/*.h"]), - includes = ["include"], - deps = [ - ":IR", - ":LLVMDialect", - ":OpenACCDialect", - ":OpenACCToLLVM", - ":OpenMPCommon", - ":Support", - ":ToLLVMIRTranslation", - ":TransformUtils", - "//llvm:Core", - "//llvm:FrontendOpenMP", - "//llvm:Support", - ], -) - -cc_library( - name = "OpenMPToLLVMIRTranslation", - srcs = glob(["lib/Target/LLVMIR/Dialect/OpenMP/*.cpp"]), - hdrs = glob(["include/mlir/Target/LLVMIR/Dialect/OpenMP/*.h"]), - includes = ["include"], - deps = [ - ":IR", - ":LLVMDialect", - ":OpenMPCommon", - ":OpenMPDialect", - ":Support", - ":ToLLVMIRTranslation", - ":Transforms", - "//llvm:Core", - "//llvm:FrontendOpenMP", - "//llvm:Support", - "//llvm:TargetParser", - "//llvm:TransformUtils", - ], -) - -cc_library( - name = "AllToLLVMIRTranslations", - hdrs = ["include/mlir/Target/LLVMIR/Dialect/All.h"], - includes = ["include"], - deps = [ - ":AMXToLLVMIRTranslation", - ":ArmNeonToLLVMIRTranslation", - ":ArmSMEToLLVMIRTranslation", - ":ArmSVEToLLVMIRTranslation", - ":BuiltinToLLVMIRTranslation", - ":GPUToLLVMIRTranslation", - ":LLVMIRToLLVMTranslation", - ":LLVMIRToNVVMTranslation", - ":LLVMToLLVMIRTranslation", - ":NVVMTarget", - ":NVVMToLLVMIRTranslation", - ":OpenACCToLLVMIRTranslation", - ":OpenMPToLLVMIRTranslation", - ":ROCDLTarget", - ":ROCDLToLLVMIRTranslation", - ":SPIRVToLLVMIRTranslation", - ":VCIXToLLVMIRTranslation", - ":X86VectorToLLVMIRTranslation", - ], -) - -cc_library( - name = "ToLLVMIRTranslationRegistration", - srcs = ["lib/Target/LLVMIR/ConvertToLLVMIR.cpp"], - includes = ["include"], - deps = [ - ":AllToLLVMIRTranslations", - ":DLTIDialect", - ":FuncDialect", - ":IR", - ":NVVMTarget", - ":ROCDLTarget", - ":ToLLVMIRTranslation", - ":TranslateLib", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "FromLLVMIRTranslation", - srcs = [ - "lib/Target/LLVMIR/DataLayoutImporter.cpp", - "lib/Target/LLVMIR/DataLayoutImporter.h", - "lib/Target/LLVMIR/DebugImporter.cpp", - "lib/Target/LLVMIR/LoopAnnotationImporter.cpp", - "lib/Target/LLVMIR/LoopAnnotationImporter.h", - "lib/Target/LLVMIR/ModuleImport.cpp", - "lib/Target/LLVMIR/TypeFromLLVM.cpp", - ], - hdrs = [ - "include/mlir/Target/LLVMIR/Import.h", - "include/mlir/Target/LLVMIR/LLVMImportInterface.h", - "include/mlir/Target/LLVMIR/ModuleImport.h", - "include/mlir/Target/LLVMIR/TypeFromLLVM.h", - "lib/Target/LLVMIR/AttrKindDetail.h", - "lib/Target/LLVMIR/DebugImporter.h", - ], - includes = ["include"], - deps = [ - ":DLTIDialect", - ":IR", - ":LLVMConversionIncGen", - ":LLVMDialect", - ":LLVMIntrinsicConversionIncGen", - ":Support", - ":TranslateLib", - "//llvm:BinaryFormat", - "//llvm:Core", - "//llvm:IRPrinter", - "//llvm:IRReader", - "//llvm:Support", - ], -) - -cc_library( - name = "FromLLVMIRTranslationRegistration", - srcs = [ - "lib/Target/LLVMIR/ConvertFromLLVMIR.cpp", - ], - deps = [ - ":AllToLLVMIRTranslations", - ":DLTIDialect", - ":FromLLVMIRTranslation", - ":IR", - ":TranslateLib", - "//llvm:Core", - "//llvm:IRReader", - "//llvm:Support", - ], -) - -cc_library( - name = "ExecutionEngine", - srcs = [ - "include/mlir/ExecutionEngine/CRunnerUtils.h", - "lib/ExecutionEngine/ExecutionEngine.cpp", - ], - hdrs = [ - "include/mlir/ExecutionEngine/ExecutionEngine.h", - "include/mlir/ExecutionEngine/MemRefUtils.h", - ], - includes = ["include"], - deps = [ - ":AllToLLVMIRTranslations", - ":IR", - ":LLVMDialect", - ":Support", - ":ToLLVMIRTranslation", - "//llvm:AllTargetsAsmParsers", - "//llvm:BitWriter", - "//llvm:Core", - "//llvm:ExecutionEngine", - "//llvm:MC", - "//llvm:OrcJIT", - "//llvm:Support", - "//llvm:Target", # fixdeps: keep - "//llvm:TargetParser", - "//llvm:TransformUtils", - "//llvm:X86CodeGen", # fixdeps: keep - "//llvm:X86Disassembler", # fixdeps: keep - ], -) - -cc_library( - name = "ExecutionEngineUtils", - srcs = ["lib/ExecutionEngine/OptUtils.cpp"], - hdrs = ["include/mlir/ExecutionEngine/OptUtils.h"], - includes = ["include"], - deps = [ - "//llvm:Analysis", - "//llvm:Core", - "//llvm:Coroutines", - "//llvm:IPO", - "//llvm:Passes", - "//llvm:Support", - "//llvm:Target", - "//llvm:common_transforms", - ], -) - -cc_library( - name = "PluginsLib", - srcs = [ - "lib/Tools/Plugins/DialectPlugin.cpp", - "lib/Tools/Plugins/PassPlugin.cpp", - ], - hdrs = [ - "include/mlir/Tools/Plugins/DialectPlugin.h", - "include/mlir/Tools/Plugins/PassPlugin.h", - ], - includes = ["include"], - deps = [ - ":IR", - ":Pass", - ":Support", - "//llvm:Support", - ], -) - -cc_library( - name = "MlirOptLib", - srcs = [ - "include/mlir/Tools/ParseUtilities.h", - "lib/Tools/mlir-opt/MlirOptMain.cpp", - ], - hdrs = ["include/mlir/Tools/mlir-opt/MlirOptMain.h"], - includes = ["include"], - deps = [ - ":BytecodeReader", - ":BytecodeWriter", - ":Debug", - ":IR", - ":IRDLDialect", - ":Parser", - ":Pass", - ":PluginsLib", - ":Support", - "//llvm:Support", - ], -) - -cc_library( - name = "AllTranslations", - hdrs = ["include/mlir/InitAllTranslations.h"], - deps = [ - ":FromLLVMIRTranslationRegistration", - ":SPIRVTranslateRegistration", - ":TargetCpp", - ":ToLLVMIRTranslationRegistration", - ], -) - -cc_library( - name = "MlirTranslateMain", - srcs = ["tools/mlir-translate/mlir-translate.cpp"], - local_defines = ["MLIR_INCLUDE_TESTS"], - deps = [ - ":AllPassesAndDialects", - ":AllTranslations", - ":Support", - ":TranslateLib", - "//llvm:Support", - "//mlir/test:TestToLLVMIRTranslation", - ], -) - -cc_binary( - name = "mlir-translate", - deps = [":MlirTranslateMain"], -) - -cc_library( - name = "AllPassesAndDialects", - hdrs = [ - "include/mlir/InitAllDialects.h", - "include/mlir/InitAllPasses.h", - ], - deps = [ - ":AMDGPUDialect", - ":AMDGPUToROCDL", - ":AMDGPUTransformOps", - ":AMDGPUTransforms", - ":AMXDialect", - ":AMXTransforms", - ":AffineDialect", - ":AffinePassIncGen", - ":AffineToStandard", - ":AffineTransformOps", - ":AffineTransforms", - ":ArithDialect", - ":ArithToAMDGPU", - ":ArithToLLVM", - ":ArithToSPIRV", - ":ArithTransforms", - ":ArithValueBoundsOpInterfaceImpl", - ":ArmNeonDialect", - ":ArmSMEDialect", - ":ArmSMETransforms", - ":ArmSVEDialect", - ":ArmSVETransforms", - ":AsyncDialect", - ":AsyncPassIncGen", - ":AsyncToLLVM", - ":AsyncTransforms", - ":BufferizationDialect", - ":BufferizationPipelines", - ":BufferizationTransformOps", - ":BufferizationTransforms", - ":CastInterfaces", - ":ComplexDialect", - ":ComplexToLLVM", - ":ComplexToLibm", - ":ComplexToSPIRV", - ":ControlFlowDialect", - ":ControlFlowTransforms", - ":ConversionPasses", - ":ConvertToLLVM", - ":DLTIDialect", - ":EmitCDialect", - ":EmitCTransforms", - ":FuncDialect", - ":FuncToLLVM", - ":FuncToSPIRV", - ":FuncTransformOps", - ":FuncTransforms", - ":FuncTransformsPassIncGen", - ":GPUDialect", - ":GPUPassIncGen", - ":GPUPipelines", - ":GPUToGPURuntimeTransforms", - ":GPUToNVVMTransforms", - ":GPUToROCDLTransforms", - ":GPUToSPIRV", - ":GPUToVulkanTransforms", - ":GPUTransformOps", - ":GPUTransforms", - ":IR", - ":IRDLDialect", - ":IndexDialect", - ":LLVMDialect", - ":LLVMIRTransforms", - ":LLVMPassIncGen", - ":LinalgDialect", - ":LinalgPassIncGen", - ":LinalgToStandard", - ":LinalgTransformOps", - ":LinalgTransforms", - ":MLProgramDialect", - ":MLProgramTransforms", - ":MPIDialect", - ":MathDialect", - ":MathToFuncs", - ":MathToLLVM", - ":MathToLibm", - ":MathToSPIRV", - ":MathTransforms", - ":MemRefDialect", - ":MemRefToLLVM", - ":MemRefToSPIRV", - ":MemRefTransformOps", - ":MemRefTransforms", - ":MeshDialect", - ":MeshTransforms", - ":NVGPUDialect", - ":NVGPUPassIncGen", - ":NVGPUToNVVM", - ":NVGPUTransformOps", - ":NVGPUTransforms", - ":NVVMDialect", - ":NVVMTarget", - ":OpenACCDialect", - ":OpenACCTransforms", - ":OpenMPDialect", - ":OpenMPToLLVM", - ":PDLDialect", - ":PDLInterpDialect", - ":PDLToPDLInterp", - ":QuantOps", - ":ROCDLDialect", - ":ROCDLTarget", - ":ReconcileUnrealizedCasts", - ":SCFDialect", - ":SCFPassIncGen", - ":SCFToControlFlow", - ":SCFToGPU", - ":SCFTransformOps", - ":SCFTransforms", - ":SDBM", - ":SPIRVDialect", - ":SPIRVPassIncGen", - ":SPIRVTarget", - ":SPIRVToLLVM", - ":SPIRVTransforms", - ":ShapeDialect", - ":ShapeToStandard", - ":ShapeTransforms", - ":ShapeTransformsPassIncGen", - ":SparseTensorDialect", - ":SparseTensorPipelines", - ":SparseTensorTransformOps", - ":SparseTensorTransforms", - ":TensorDialect", - ":TensorInferTypeOpInterfaceImpl", - ":TensorTilingInterfaceImpl", - ":TensorTransformOps", - ":TensorTransforms", - ":TosaDialect", - ":TosaToLinalg", - ":TransformDebugExtension", - ":TransformDialect", - ":TransformDialectTransforms", - ":TransformLoopExtension", - ":TransformPDLExtension", - ":Transforms", - ":TransformsPassIncGen", - ":UBDialect", - ":VectorDialect", - ":VectorToLLVM", - ":VectorToSCF", - ":VectorToSPIRV", - ":VectorTransformOps", - ":VectorTransforms", - ":X86VectorDialect", - ":X86VectorTransforms", - ":XeGPUDialect", - ":config", - ], -) - -cc_binary( - name = "mlir-lsp-server", - srcs = ["tools/mlir-lsp-server/mlir-lsp-server.cpp"], - includes = ["include"], - deps = [ - ":AllExtensions", - ":AllPassesAndDialects", - ":BytecodeWriter", - ":IR", - ":MlirLspServerLib", - ":Parser", - ], -) - -cc_binary( - name = "mlir-opt", - srcs = ["tools/mlir-opt/mlir-opt.cpp"], - local_defines = ["MLIR_INCLUDE_TESTS"], - deps = [ - ":AllExtensions", - ":AllPassesAndDialects", - ":AllToLLVMIRTranslations", - ":Analysis", - ":IR", - ":MlirOptLib", - ":OpenMPDialect", - ":Pass", - ":QuantOps", - ":SCFToGPU", - ":Support", - ":Transforms", - ":config", - "//llvm:AllTargetsCodeGens", - "//llvm:Support", - "//mlir/test:TestAffine", - "//mlir/test:TestAnalysis", - "//mlir/test:TestArith", - "//mlir/test:TestArmNeon", - "//mlir/test:TestArmSME", - "//mlir/test:TestBufferization", - "//mlir/test:TestControlFlow", - "//mlir/test:TestDLTI", - "//mlir/test:TestDialect", - "//mlir/test:TestFunc", - "//mlir/test:TestFuncToLLVM", - "//mlir/test:TestGPU", - "//mlir/test:TestIR", - "//mlir/test:TestLLVM", - "//mlir/test:TestLinalg", - "//mlir/test:TestLoopLikeInterface", - "//mlir/test:TestMath", - "//mlir/test:TestMathToVCIX", - "//mlir/test:TestMemRef", - "//mlir/test:TestMesh", - "//mlir/test:TestNVGPU", - "//mlir/test:TestOneToNTypeConversion", - "//mlir/test:TestPDLL", - "//mlir/test:TestPass", - "//mlir/test:TestReducer", - "//mlir/test:TestRewrite", - "//mlir/test:TestSCF", - "//mlir/test:TestSPIRV", - "//mlir/test:TestShapeDialect", - "//mlir/test:TestTensor", - "//mlir/test:TestTestDynDialect", - "//mlir/test:TestTilingInterface", - "//mlir/test:TestTosaDialect", - "//mlir/test:TestTransformDialect", - "//mlir/test:TestTransforms", - "//mlir/test:TestTypeDialect", - "//mlir/test:TestVector", - "//mlir/test:TestVectorToSPIRV", - ], -) - -cc_library( - name = "MlirJitRunner", - srcs = ["lib/ExecutionEngine/JitRunner.cpp"], - hdrs = [ - "include/mlir/ExecutionEngine/JitRunner.h", - "include/mlir/Tools/ParseUtilities.h", - ], - includes = ["include"], - deps = [ - ":AllPassesAndDialects", - ":ExecutionEngine", - ":ExecutionEngineUtils", - ":IR", - ":LLVMDialect", - ":LLVMToLLVMIRTranslation", - ":OpenACCToLLVMIRTranslation", - ":OpenMPToLLVMIRTranslation", - ":Parser", - ":SCFToControlFlow", - ":Support", - "//llvm:Core", - "//llvm:OrcJIT", - "//llvm:Support", - ], -) - -cc_library( - name = "mlir_async_runtime_api", - hdrs = ["include/mlir/ExecutionEngine/AsyncRuntime.h"], - includes = ["include"], -) - -cc_library( - name = "_mlir_async_runtime", - srcs = ["lib/ExecutionEngine/AsyncRuntime.cpp"], - copts = ["-Dmlir_async_runtime_EXPORTS"], - deps = [ - ":mlir_async_runtime_api", - "//llvm:Support", - ], -) - -# Indirection to avoid 'libmlir_async_runtime.so' filename clash. -alias( - name = "mlir_async_runtime", - actual = "_mlir_async_runtime", -) - -cc_binary( - name = "libmlir_async_runtime.so", - linkshared = True, - linkstatic = False, - deps = [":mlir_async_runtime"], -) - -cc_library( - name = "_mlir_float16_utils", - srcs = ["lib/ExecutionEngine/Float16bits.cpp"], - hdrs = ["include/mlir/ExecutionEngine/Float16bits.h"], - copts = ["-Dmlir_float16_utils_EXPORTS"], - includes = ["include"], -) - -# Indirection to avoid 'libmlir_float16_utils.so' filename clash. -alias( - name = "mlir_float16_utils", - actual = "_mlir_float16_utils", -) - -cc_binary( - name = "libmlir_float16_utils.so", - linkshared = True, - linkstatic = False, - deps = [":mlir_float16_utils"], -) - -# Unlike mlir_float16_utils, mlir_c_runner_utils, etc, we do *not* make -# this a shared library: because on the CMake side, doing so causes issues -# when building on Windows. In particular, various functions take/return -# `std::vector` but that class is not designed with dllimport/dllexport -# pragma, therefore it cannot be safely/correctly used across DLL boundaries. -# Consequently, we avoid using the "mlir_xxx_utils" naming scheme, -# since that is reserved/intended for shared libraries only. -cc_library( - name = "SparseTensorRuntime", - srcs = [ - "lib/ExecutionEngine/SparseTensor/File.cpp", - "lib/ExecutionEngine/SparseTensor/MapRef.cpp", - "lib/ExecutionEngine/SparseTensor/Storage.cpp", - ], - hdrs = [ - "include/mlir/ExecutionEngine/SparseTensor/ArithmeticUtils.h", - "include/mlir/ExecutionEngine/SparseTensor/COO.h", - "include/mlir/ExecutionEngine/SparseTensor/File.h", - "include/mlir/ExecutionEngine/SparseTensor/MapRef.h", - "include/mlir/ExecutionEngine/SparseTensor/Storage.h", - ], - includes = ["include"], - deps = [ - ":SparseTensorEnums", - ":mlir_float16_utils", - ], -) - -cc_library( - name = "_mlir_c_runner_utils", - srcs = [ - "lib/ExecutionEngine/CRunnerUtils.cpp", - "lib/ExecutionEngine/SparseTensorRuntime.cpp", - ], - hdrs = [ - "include/mlir/ExecutionEngine/CRunnerUtils.h", - "include/mlir/ExecutionEngine/Msan.h", - "include/mlir/ExecutionEngine/SparseTensorRuntime.h", - ], - includes = ["include"], - deps = [ - ":SparseTensorEnums", - ":SparseTensorRuntime", - ":mlir_float16_utils", - "//llvm:Support", - ], -) - -# Indirection to avoid 'libmlir_c_runner_utils.so' filename clash. -alias( - name = "mlir_c_runner_utils", - actual = "_mlir_c_runner_utils", -) - -cc_headers_only( - name = "mlir_c_runner_utils_hdrs", - src = ":mlir_c_runner_utils", -) - -cc_binary( - name = "libmlir_c_runner_utils.so", - linkshared = True, - linkstatic = False, - deps = [":mlir_c_runner_utils"], -) - -cc_library( - name = "_mlir_runner_utils", - srcs = ["lib/ExecutionEngine/RunnerUtils.cpp"], - hdrs = ["include/mlir/ExecutionEngine/RunnerUtils.h"], - includes = ["include"], - deps = [ - ":mlir_c_runner_utils", - ":mlir_float16_utils", - "//llvm:Support", - ], -) - -# Indirection to avoid 'libmlir_runner_utils.so' filename clash. -alias( - name = "mlir_runner_utils", - actual = "_mlir_runner_utils", -) - -cc_headers_only( - name = "mlir_runner_utils_hdrs", - src = ":mlir_runner_utils", -) - -cc_binary( - name = "libmlir_runner_utils.so", - linkshared = True, - linkstatic = False, - deps = [":mlir_runner_utils"], -) - -cc_binary( - name = "mlir-cpu-runner", - srcs = ["tools/mlir-cpu-runner/mlir-cpu-runner.cpp"], - deps = [ - ":AllToLLVMIRTranslations", - ":BuiltinToLLVMIRTranslation", - ":ExecutionEngineUtils", - ":IR", - ":LLVMDialect", - ":LLVMToLLVMIRTranslation", - ":MlirJitRunner", - ":OpenACCToLLVMIRTranslation", - ":OpenMPToLLVMIRTranslation", - ":ToLLVMIRTranslation", - "//llvm:AsmParser", - "//llvm:Support", - "//llvm:X86AsmParser", - ], -) - -# This target provides the headers from LLVM's Support target without any of -# the symbols. In particular, it does not contain the static registration code -# which may be executed by at most one shared library loaded by ORCJit. Direct -# dependencies need to avoid requiring symbols from LLVMSupport by adding -# copts = ["-DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1"]. -# -# Bazel links the dependencies' object files instead of the archives, which -# means that symbols are linked in even if none are used. The LLVM cmake build -# on the other hand links archives (or shared libraries, depending on -# BUILD_SHARED_LIBS), skipping them if none of the symbols are used. -# See also https://reviews.llvm.org/D95613. -cc_headers_only( - name = "LLVMSupportHeaders", - src = "//llvm:Support", -) - -cc_library( - name = "_mlir_cuda_runtime", - srcs = ["lib/ExecutionEngine/CudaRuntimeWrappers.cpp"], - # Prevent needing EnableABIBreakingChecks symbol from LLVMSupport. - copts = ["-DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1"], - # Here: - # MLIR_ENABLE_CUDA_CUSPARSE : enables cuSPARSE - # MLIR_ENABLE_CUDA_CUSPARSELT : enables cuSPARSElt - local_defines = ["MLIR_ENABLE_CUDA_CUSPARSE"], - tags = [ - "manual", # External dependency - "nobuildkite", # TODO(gcmn): Add support for this target - ], - deps = [ - ":LLVMSupportHeaders", - ":mlir_c_runner_utils_hdrs", - "@cuda//:cuda_headers", - "@cuda//:cusparse_static", - "@cuda//:libcuda", - ], -) - -# Indirection to avoid 'libmlir_cuda_runtime.so' filename clash. -alias( - name = "mlir_cuda_runtime", - actual = "_mlir_cuda_runtime", - tags = [ - "manual", # External dependency - "nobuildkite", # TODO(gcmn): Add support for this target - ], -) - -cc_binary( - name = "libmlir_cuda_runtime.so", - linkshared = True, - linkstatic = False, - tags = [ - "manual", # External dependency - "nobuildkite", # TODO(gcmn): Add support for this target - ], - deps = [":mlir_cuda_runtime"], -) - -cc_library( - name = "VulkanRuntime", - srcs = ["tools/mlir-vulkan-runner/VulkanRuntime.cpp"], - hdrs = ["tools/mlir-vulkan-runner/VulkanRuntime.h"], - tags = [ - "manual", # External dependency - ], - deps = [ - ":FuncDialect", - ":IR", - ":Pass", - ":SPIRVDialect", - ":SideEffectInterfaces", - ":Support", - "//llvm:Support", - "@vulkan_headers", - "@vulkan_sdk//:sdk", - ], -) - -cc_binary( - name = "libvulkan-runtime-wrappers.so", - srcs = ["tools/mlir-vulkan-runner/vulkan-runtime-wrappers.cpp"], - linkshared = True, - linkstatic = False, - tags = [ - "manual", # External dependency - ], - deps = [":VulkanRuntime"], -) - -cc_binary( - name = "mlir-vulkan-runner", - srcs = ["tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp"], - deps = [ - ":ArithDialect", - ":BuiltinToLLVMIRTranslation", - ":ExecutionEngineUtils", - ":FuncDialect", - ":FuncToLLVM", - ":FuncToSPIRV", - ":GPUDialect", - ":GPUToSPIRV", - ":GPUToVulkanTransforms", - ":GPUTransforms", - ":LLVMCommonConversion", - ":LLVMDialect", - ":LLVMIRTransforms", - ":LLVMToLLVMIRTranslation", - ":MemRefDialect", - ":MemRefToLLVM", - ":MemRefTransforms", - ":MlirJitRunner", - ":Pass", - ":ReconcileUnrealizedCasts", - ":SCFDialect", - ":SPIRVDialect", - ":SPIRVTransforms", - ":ToLLVMIRTranslation", - ":VectorDialect", - ":VectorToLLVM", - "//llvm:Support", - ], -) - -cc_binary( - name = "mlir-spirv-cpu-runner", - srcs = ["tools/mlir-spirv-cpu-runner/mlir-spirv-cpu-runner.cpp"], - deps = [ - ":ArithDialect", - ":BuiltinToLLVMIRTranslation", - ":ExecutionEngineUtils", - ":FuncDialect", - ":FuncToLLVM", - ":GPUDialect", - ":GPUToSPIRV", - ":GPUTransforms", - ":LLVMDialect", - ":LLVMToLLVMIRTranslation", - ":MemRefDialect", - ":MlirJitRunner", - ":Pass", - ":SPIRVConversion", - ":SPIRVDialect", - ":SPIRVToLLVM", - ":SPIRVTransforms", - ":ToLLVMIRTranslation", - "//llvm:Core", - "//llvm:Linker", - "//llvm:Support", - ], -) - -cc_library( - name = "TableGen", - srcs = glob(["lib/TableGen/*.cpp"]), - hdrs = glob(["include/mlir/TableGen/*.h"]), - includes = ["include"], - deps = [ - ":Support", - "//llvm:Support", - "//llvm:TableGen", - "//llvm:TargetParser", - ], -) - -cc_library( - name = "MlirTableGenMain", - srcs = glob(["lib/Tools/mlir-tblgen/*.cpp"]), - hdrs = glob(["include/mlir/Tools/mlir-tblgen/*.h"]), - includes = ["include"], - deps = [ - ":TableGen", - "//llvm:Support", - "//llvm:TableGen", - "//llvm:TargetParser", - "//llvm:config", - ], -) - -cc_binary( - name = "mlir-tblgen", - srcs = glob([ - "tools/mlir-tblgen/*.h", - "tools/mlir-tblgen/*.cpp", - ]), - deps = [ - ":MlirTableGenMain", - ":Support", - ":TableGen", - "//llvm:CodeGenTypes", - "//llvm:Support", - "//llvm:TableGen", - "//llvm:TargetParser", - "//llvm:config", - ], -) - -cc_binary( - name = "mlir-linalg-ods-yaml-gen", - srcs = [ - "tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp", - ], - deps = [ - ":AsmParser", - ":IR", - ":Support", - "//llvm:Support", - "//llvm:TableGen", - "//llvm:config", - ], -) - -## OpenMP / OpenACC common - -td_library( - name = "AtomicInterfacesTdFiles", - srcs = ["include/mlir/Dialect/OpenACCMPCommon/Interfaces/AtomicInterfaces.td"], - includes = ["include"], - deps = [ - ":ControlFlowInterfacesTdFiles", - ":OpBaseTdFiles", - ], -) - -gentbl_cc_library( - name = "AtomicInterfacesIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Dialect/OpenACCMPCommon/Interfaces/AtomicInterfaces.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Dialect/OpenACCMPCommon/Interfaces/AtomicInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/OpenACCMPCommon/Interfaces/AtomicInterfaces.td", - deps = [ - ":AtomicInterfacesTdFiles", - ":ControlFlowInterfacesTdFiles", - ], -) - -cc_library( - name = "AtomicInterfaces", - srcs = ["lib/Dialect/OpenACCMPCommon/Interfaces/AtomicInterfaces.cpp"], - hdrs = ["include/mlir/Dialect/OpenACCMPCommon/Interfaces/AtomicInterfaces.h"], - includes = ["include"], - deps = [ - ":AtomicInterfacesIncGen", - ":ControlFlowInterfaces", - ":IR", - "//llvm:Support", - ], -) - -## OpenACC dialect - -# TODO(gcmn): This is sticking td files in a cc_library -gentbl_cc_library( - name = "AccCommonGen", - includes = ["/llvm/include"], - tbl_outs = [ - ( - [ - "-gen-directive-decl", - "-directives-dialect=OpenACC", - ], - "include/mlir/Dialect/OpenACC/AccCommon.td", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "//llvm:include/llvm/Frontend/OpenACC/ACC.td", - deps = ["//llvm:acc_td_files"], -) - -td_library( - name = "OpenAccOpsTdFiles", - srcs = [ - "include/mlir/Dialect/OpenACC/AccCommon.td", - "include/mlir/Dialect/OpenACC/OpenACCBase.td", - "include/mlir/Dialect/OpenACC/OpenACCOps.td", - "include/mlir/Dialect/OpenACC/OpenACCOpsInterfaces.td", - "include/mlir/Dialect/OpenACC/OpenACCOpsTypes.td", - "include/mlir/Dialect/OpenACC/OpenACCTypeInterfaces.td", - "include/mlir/Dialect/OpenACCMPCommon/Interfaces/AtomicInterfaces.td", - ], - includes = ["include"], - deps = [ - ":AtomicInterfacesTdFiles", - ":LoopLikeInterfaceTdFiles", - ":OpBaseTdFiles", - ], -) - -gentbl_cc_library( - name = "OpenACCOpsInterfacesIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Dialect/OpenACC/OpenACCOpsInterfaces.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Dialect/OpenACC/OpenACCOpsInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/OpenACC/OpenACCOpsInterfaces.td", - deps = [":OpenAccOpsTdFiles"], -) - -gentbl_cc_library( - name = "OpenACCOpsIncGen", - tbl_outs = [ - ( - [ - "-gen-dialect-decls", - "-dialect=acc", - ], - "include/mlir/Dialect/OpenACC/OpenACCOpsDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=acc", - ], - "include/mlir/Dialect/OpenACC/OpenACCOpsDialect.cpp.inc", - ), - ( - ["-gen-op-decls"], - "include/mlir/Dialect/OpenACC/OpenACCOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/OpenACC/OpenACCOps.cpp.inc", - ), - ( - ["-gen-enum-decls"], - "include/mlir/Dialect/OpenACC/OpenACCOpsEnums.h.inc", - ), - ( - ["-gen-enum-defs"], - "include/mlir/Dialect/OpenACC/OpenACCOpsEnums.cpp.inc", - ), - ( - [ - "-gen-attrdef-decls", - "-attrdefs-dialect=acc", - ], - "include/mlir/Dialect/OpenACC/OpenACCOpsAttributes.h.inc", - ), - ( - [ - "-gen-attrdef-defs", - "-attrdefs-dialect=acc", - ], - "include/mlir/Dialect/OpenACC/OpenACCOpsAttributes.cpp.inc", - ), - ( - ["-gen-op-doc"], - "g3doc/Dialects/OpenACC/OpenACCOps.md", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/OpenACC/OpenACCOps.td", - deps = [ - ":BuiltinDialectTdFiles", - ":ControlFlowInterfacesTdFiles", - ":OpenAccOpsTdFiles", - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "OpenACCTypesIncGen", - tbl_outs = [ - ( - [ - "--gen-typedef-decls", - "-typedefs-dialect=acc", - ], - "include/mlir/Dialect/OpenACC/OpenACCOpsTypes.h.inc", - ), - ( - [ - "--gen-typedef-defs", - "-typedefs-dialect=acc", - ], - "include/mlir/Dialect/OpenACC/OpenACCOpsTypes.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/OpenACC/OpenACCOpsTypes.td", - deps = [":OpenAccOpsTdFiles"], -) - -gentbl_cc_library( - name = "OpenACCTypeInterfacesIncGen", - tbl_outs = [ - ( - ["-gen-type-interface-decls"], - "include/mlir/Dialect/OpenACC/OpenACCTypeInterfaces.h.inc", - ), - ( - ["-gen-type-interface-defs"], - "include/mlir/Dialect/OpenACC/OpenACCTypeInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/OpenACC/OpenACCTypeInterfaces.td", - deps = [":OpenAccOpsTdFiles"], -) - -cc_library( - name = "OpenACCDialect", - srcs = glob( - [ - "lib/Dialect/OpenACC/IR/*.cpp", - "lib/Dialect/OpenACC/IR/*.h", - ], - ), - hdrs = glob( - [ - "include/mlir/Dialect/OpenACC/*.h", - ], - exclude = - [ - "include/mlir/Dialect/OpenACCMPCommon/Interfaces/AtomicInterfaces.h", - ], - ), - includes = ["include"], - textual_hdrs = [ - "include/mlir/Dialect/OpenACCMPCommon/Interfaces/AtomicInterfaces.h", - ], - deps = [ - ":AtomicInterfaces", - ":AtomicInterfacesIncGen", - ":ControlFlowInterfaces", - ":IR", - ":LLVMDialect", - ":LoopLikeInterface", - ":MemRefDialect", - ":OpenACCOpsIncGen", - ":OpenACCOpsInterfacesIncGen", - ":OpenACCTypeInterfacesIncGen", - ":OpenACCTypesIncGen", - ":Transforms", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "OpenACCPassIncGen", - tbl_outs = [ - ( - [ - "-gen-pass-decls", - "-name=OpenACC", - ], - "include/mlir/Dialect/OpenACC/Transforms/Passes.h.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/OpenACC/Transforms/Passes.td", - deps = [":PassBaseTdFiles"], -) - -cc_library( - name = "OpenACCTransforms", - srcs = glob( - [ - "lib/Dialect/OpenACC/Transforms/*.cpp", - "lib/Dialect/OpenACC/Transforms/*.h", - ], - ), - hdrs = glob(["include/mlir/Dialect/OpenACC/Transforms/*.h"]), - includes = ["include"], - deps = [ - ":FuncDialect", - ":LLVMIRTransforms", - ":OpenACCDialect", - ":OpenACCPassIncGen", - ":Pass", - ":TransformUtils", - ], -) - -## OpenMP dialect - -# TODO(gcmn): This is sticking td files in a cc_library -gentbl_cc_library( - name = "OmpCommonTdGen", - includes = ["/llvm/include"], - tbl_outs = [ - ( - [ - "-gen-directive-decl", - "-directives-dialect=OpenMP", - ], - "include/mlir/Dialect/OpenMP/OmpCommon.td", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "//llvm:include/llvm/Frontend/OpenMP/OMP.td", - deps = [ - ":OpBaseTdFiles", - "//llvm:omp_td_files", - ], -) - -td_library( - name = "OpenMPOpsTdFiles", - srcs = [ - "include/mlir/Dialect/OpenACCMPCommon/Interfaces/AtomicInterfaces.td", - "include/mlir/Dialect/OpenMP/OmpCommon.td", - "include/mlir/Dialect/OpenMP/OpenMPOps.td", - "include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td", - "include/mlir/Dialect/OpenMP/OpenMPTypeInterfaces.td", - ], - deps = [ - ":AtomicInterfacesTdFiles", - ":LLVMOpsTdFiles", - ":OpBaseTdFiles", - ], -) - -gentbl_cc_library( - name = "OpenMPOpsIncGen", - tbl_outs = [ - ( - [ - "-gen-typedef-decls", - "-typedefs-dialect=omp", - ], - "include/mlir/Dialect/OpenMP/OpenMPOpsTypes.h.inc", - ), - ( - [ - "-gen-typedef-defs", - "-typedefs-dialect=omp", - ], - "include/mlir/Dialect/OpenMP/OpenMPOpsTypes.cpp.inc", - ), - ( - ["-gen-op-decls"], - "include/mlir/Dialect/OpenMP/OpenMPOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/OpenMP/OpenMPOps.cpp.inc", - ), - ( - ["-gen-enum-decls"], - "include/mlir/Dialect/OpenMP/OpenMPOpsEnums.h.inc", - ), - ( - ["-gen-enum-defs"], - "include/mlir/Dialect/OpenMP/OpenMPOpsEnums.cpp.inc", - ), - ( - [ - "-gen-dialect-decls", - "-dialect=omp", - ], - "include/mlir/Dialect/OpenMP/OpenMPOpsDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=omp", - ], - "include/mlir/Dialect/OpenMP/OpenMPOpsDialect.cpp.inc", - ), - ( - [ - "-gen-attrdef-decls", - "-attrdefs-dialect=omp", - ], - "include/mlir/Dialect/OpenMP/OpenMPOpsAttributes.h.inc", - ), - ( - [ - "-gen-attrdef-defs", - "-attrdefs-dialect=omp", - ], - "include/mlir/Dialect/OpenMP/OpenMPOpsAttributes.cpp.inc", - ), - ( - ["-gen-op-doc"], - "g3doc/Dialects/OpenMP/OpenMPOps.md", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/OpenMP/OpenMPOps.td", - deps = [":OpenMPOpsTdFiles"], -) - -gentbl_cc_library( - name = "OpenMPTypeInterfacesIncGen", - tbl_outs = [ - ( - ["-gen-type-interface-decls"], - "include/mlir/Dialect/OpenMP/OpenMPTypeInterfaces.h.inc", - ), - ( - ["-gen-type-interface-defs"], - "include/mlir/Dialect/OpenMP/OpenMPTypeInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/OpenMP/OpenMPTypeInterfaces.td", - deps = [":OpenMPOpsTdFiles"], -) - -gentbl_cc_library( - name = "OpenMPInterfacesIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td", - deps = [":OpenMPOpsTdFiles"], -) - -cc_library( - name = "OpenMPDialect", - srcs = glob( - [ - "lib/Dialect/OpenMP/IR/*.cpp", - "lib/Dialect/OpenMP/IR/*.h", - ], - ), - hdrs = glob( - [ - "include/mlir/Dialect/OpenMP/*.h", - ], - exclude = - [ - "include/mlir/Dialect/OpenMP/OpenMPInterfaces.h", - ], - ), - includes = ["include"], - textual_hdrs = [ - "include/mlir/Dialect/OpenMP/OpenMPInterfaces.h", - ], - deps = [ - ":AtomicInterfaces", - ":AtomicInterfacesIncGen", - ":ControlFlowInterfaces", - ":FuncDialect", - ":IR", - ":LLVMDialect", - ":OpenMPInterfacesIncGen", - ":OpenMPOpsIncGen", - ":OpenMPTypeInterfacesIncGen", - ":Support", - "//llvm:FrontendOpenMP", - "//llvm:Support", - ], -) - -cc_library( - name = "OpenACCToSCF", - srcs = glob([ - "lib/Conversion/OpenACCToSCF/*.cpp", - "lib/Conversion/OpenACCToSCF/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/OpenACCToSCF/*.h", - ]), - includes = ["include"], - deps = [ - ":ArithDialect", - ":ConversionPassIncGen", - ":FuncDialect", - ":IR", - ":OpenACCDialect", - ":OpenACCOpsIncGen", - ":OpenACCTypesIncGen", - ":Pass", - ":SCFDialect", - ":Transforms", - ], -) - -cc_library( - name = "OpenACCToLLVM", - srcs = glob([ - "lib/Conversion/OpenACCToLLVM/*.cpp", - "lib/Conversion/OpenACCToLLVM/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/OpenACCToLLVM/*.h", - ]), - includes = ["include"], - deps = [ - ":ConversionPassIncGen", - ":FuncDialect", - ":IR", - ":LLVMCommonConversion", - ":LLVMDialect", - ":OpenACCDialect", - ":Pass", - ":Transforms", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "OpenMPToLLVM", - srcs = glob([ - "lib/Conversion/OpenMPToLLVM/*.cpp", - "lib/Conversion/OpenMPToLLVM/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/OpenMPToLLVM/*.h", - ]), - includes = ["include"], - deps = [ - ":ArithToLLVM", - ":ControlFlowToLLVM", - ":ConversionPassIncGen", - ":FuncDialect", - ":FuncToLLVM", - ":IR", - ":LLVMCommonConversion", - ":LLVMDialect", - ":MemRefToLLVM", - ":OpenMPDialect", - ":Pass", - ":Transforms", - "//llvm:Core", - "//llvm:Support", - ], -) - -td_library( - name = "QuantizationOpsTdFiles", - srcs = [ - "include/mlir/Dialect/Quant/QuantOps.td", - "include/mlir/Dialect/Quant/QuantOpsBase.td", - ], - includes = ["include"], - deps = [ - ":InferTypeOpInterfaceTdFiles", - ":OpBaseTdFiles", - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "QuantOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/Quant/QuantOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/Quant/QuantOps.cpp.inc", - ), - ( - ["-gen-dialect-decls"], - "include/mlir/Dialect/Quant/QuantOpsDialect.h.inc", - ), - ( - ["-gen-dialect-defs"], - "include/mlir/Dialect/Quant/QuantOpsDialect.cpp.inc", - ), - ( - ["-gen-op-doc"], - "g3doc/Dialects/QuantOps/QuantOps.md", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Quant/QuantOps.td", - deps = [":QuantizationOpsTdFiles"], -) - -gentbl_cc_library( - name = "QuantDialectBytecodeGen", - tbl_outs = [ - ( - [ - "-gen-bytecode", - "-bytecode-dialect=Quant", - ], - "include/mlir/Dialect/Quant/QuantDialectBytecode.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Quant/QuantDialectBytecode.td", - deps = [ - ":BytecodeTdFiles", - ], -) - -cc_library( - name = "QuantOps", - srcs = [ - "lib/Dialect/Quant/IR/QuantDialectBytecode.cpp", - "lib/Dialect/Quant/IR/QuantDialectBytecode.h", - "lib/Dialect/Quant/IR/QuantOps.cpp", - "lib/Dialect/Quant/IR/QuantTypes.cpp", - "lib/Dialect/Quant/IR/TypeDetail.h", - "lib/Dialect/Quant/IR/TypeParser.cpp", - "lib/Dialect/Quant/Utils/FakeQuantSupport.cpp", - "lib/Dialect/Quant/Utils/UniformSupport.cpp", - ], - hdrs = [ - "include/mlir/Dialect/Quant/FakeQuantSupport.h", - "include/mlir/Dialect/Quant/QuantOps.h", - "include/mlir/Dialect/Quant/QuantTypes.h", - "include/mlir/Dialect/Quant/UniformSupport.h", - ], - includes = ["include"], - deps = [ - ":ArithDialect", - ":FuncDialect", - ":IR", - ":InferTypeOpInterface", - ":Pass", - ":QuantDialectBytecodeGen", - ":QuantOpsIncGen", - ":SideEffectInterfaces", - ":Support", - ":TransformUtils", - "//llvm:Support", - ], -) - -td_library( - name = "IndexOpsTdFiles", - srcs = [ - "include/mlir/Dialect/Index/IR/IndexDialect.td", - "include/mlir/Dialect/Index/IR/IndexEnums.td", - "include/mlir/Dialect/Index/IR/IndexOps.td", - ], - includes = ["include"], - deps = [ - ":CastInterfacesTdFiles", - ":InferIntRangeInterfaceTdFiles", - ":InferTypeOpInterfaceTdFiles", - ":OpBaseTdFiles", - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "IndexOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/Index/IR/IndexOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/Index/IR/IndexOps.cpp.inc", - ), - ( - [ - "-gen-dialect-decls", - "-dialect=index", - ], - "include/mlir/Dialect/Index/IR/IndexOpsDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=index", - ], - "include/mlir/Dialect/Index/IR/IndexOpsDialect.cpp.inc", - ), - ( - ["-gen-attrdef-decls"], - "include/mlir/Dialect/Index/IR/IndexOpsAttrDefs.h.inc", - ), - ( - ["-gen-attrdef-defs"], - "include/mlir/Dialect/Index/IR/IndexOpsAttrDefs.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Index/IR/IndexOps.td", - deps = [":IndexOpsTdFiles"], -) - -gentbl_cc_library( - name = "IndexEnumsIncGen", - tbl_outs = [ - ( - ["-gen-enum-decls"], - "include/mlir/Dialect/Index/IR/IndexEnums.h.inc", - ), - ( - ["-gen-enum-defs"], - "include/mlir/Dialect/Index/IR/IndexEnums.cpp.inc", - ), - ( - [ - "-gen-attrdef-decls", - "-attrdefs-dialect=index", - ], - "include/mlir/Dialect/Index/IR/IndexAttrs.h.inc", - ), - ( - [ - "-gen-attrdef-defs", - "-attrdefs-dialect=index", - ], - "include/mlir/Dialect/Index/IR/IndexAttrs.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Index/IR/IndexEnums.td", - deps = [":IndexOpsTdFiles"], -) - -cc_library( - name = "IndexToLLVM", - srcs = glob([ - "lib/Conversion/IndexToLLVM/*.cpp", - "lib/Conversion/IndexToLLVM/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/IndexToLLVM/*.h", - ]), - includes = ["include"], - deps = [ - ":Analysis", - ":ConversionPassIncGen", - ":ConvertToLLVMInterface", - ":IR", - ":IndexDialect", - ":LLVMCommonConversion", - ":LLVMDialect", - ":Pass", - ":Support", - ":Transforms", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "IndexToSPIRV", - srcs = glob([ - "lib/Conversion/IndexToSPIRV/*.cpp", - "lib/Conversion/IndexToSPIRV/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/IndexToSPIRV/*.h", - ]), - includes = ["include"], - deps = [ - ":ConversionPassIncGen", - ":IR", - ":IndexDialect", - ":Pass", - ":SPIRVCommonConversion", - ":SPIRVConversion", - ":SPIRVDialect", - ":Support", - ":Transforms", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "IndexDialect", - srcs = glob(["lib/Dialect/Index/IR/*.cpp"]), - hdrs = glob(["include/mlir/Dialect/Index/IR/*.h"]), - includes = ["include"], - deps = [ - ":CastInterfaces", - ":ConvertToLLVMInterface", - ":IR", - ":IndexEnumsIncGen", - ":IndexOpsIncGen", - ":InferIntRangeCommon", - ":InferIntRangeInterface", - ":InferTypeOpInterface", - "//llvm:Support", - ], -) - -td_library( - name = "LinalgOpsTdFiles", - srcs = [ - "include/mlir/Dialect/Linalg/IR/LinalgBase.td", - "include/mlir/Dialect/Linalg/IR/LinalgEnums.td", - "include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td", - "include/mlir/Dialect/Linalg/IR/LinalgOps.td", - ], - includes = ["include"], - deps = [ - ":ControlFlowInterfacesTdFiles", - ":DestinationStyleOpInterfaceTdFiles", - ":DialectUtilsTdFiles", - ":InferTypeOpInterfaceTdFiles", - ":LoopLikeInterfaceTdFiles", - ":OpBaseTdFiles", - ":SideEffectInterfacesTdFiles", - ":TilingInterfaceTdFiles", - ":ViewLikeInterfaceTdFiles", - ], -) - -td_library( - name = "LinalgTransformOpsTdFiles", - srcs = glob([ - "include/mlir/Dialect/Linalg/TransformOps/*.td", - ]), - includes = ["include"], - deps = [ - ":SCFTdFiles", - ":TransformDialectTdFiles", - ], -) - -gentbl_cc_library( - name = "LinalgOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/Linalg/IR/LinalgOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/Linalg/IR/LinalgOps.cpp.inc", - ), - ( - [ - "-gen-dialect-decls", - "-dialect=linalg", - ], - "include/mlir/Dialect/Linalg/IR/LinalgOpsDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=linalg", - ], - "include/mlir/Dialect/Linalg/IR/LinalgOpsDialect.cpp.inc", - ), - ( - ["-gen-attrdef-decls"], - "include/mlir/Dialect/Linalg/IR/LinalgOpsAttrDefs.h.inc", - ), - ( - ["-gen-attrdef-defs"], - "include/mlir/Dialect/Linalg/IR/LinalgOpsAttrDefs.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Linalg/IR/LinalgOps.td", - deps = [":LinalgOpsTdFiles"], -) - -gentbl_cc_library( - name = "LinalgEnumsIncGen", - tbl_outs = [ - ( - ["-gen-enum-decls"], - "include/mlir/Dialect/Linalg/IR/LinalgOpsEnums.h.inc", - ), - ( - ["-gen-enum-defs"], - "include/mlir/Dialect/Linalg/IR/LinalgOpsEnums.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Linalg/IR/LinalgEnums.td", - deps = [":LinalgOpsTdFiles"], -) - -gentbl_cc_library( - name = "LinalgMatchOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td", - deps = [ - ":LinalgTransformEnumsIncGen", - ":LinalgTransformOpsIncGen", - ":LinalgTransformOpsTdFiles", - ":SCFDeviceMappingInterfacesIncGen", - ], -) - -gentbl_cc_library( - name = "LinalgTransformEnumsIncGen", - tbl_outs = [ - ( - ["-gen-enum-decls"], - "include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOpsEnums.h.inc", - ), - ( - ["-gen-enum-defs"], - "include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOpsEnums.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Linalg/TransformOps/LinalgTransformEnums.td", - deps = [ - ":LinalgTransformOpsTdFiles", - ":SCFDeviceMappingInterfacesIncGen", - ], -) - -gentbl_cc_library( - name = "LinalgTransformOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td", - deps = [ - ":LinalgTransformEnumsIncGen", - ":LinalgTransformOpsTdFiles", - ":SCFDeviceMappingInterfacesIncGen", - ], -) - -genlinalg( - name = "LinalgNamedStructuredOpsYamlIncGen", - src = "include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml", - linalg_outs = [ - ( - "-o-impl=$@", - "include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yamlgen.cpp.inc", - ), - ( - "-o-ods-decl=$@", - "include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yamlgen.td", - ), - ], - linalggen = ":mlir-linalg-ods-yaml-gen", -) - -td_library( - name = "LinalgStructuredOpsTdFiles", - srcs = [ - "include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td", - "include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yamlgen.td", - "include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td", - ], - includes = ["include"], - deps = [ - ":CopyOpInterfaceTdFiles", - ":DestinationStyleOpInterface", - ":LinalgOpsTdFiles", - ":OpBaseTdFiles", - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "LinalgStructuredOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td", - deps = [":LinalgStructuredOpsTdFiles"], -) - -gentbl_cc_library( - name = "LinalgInterfacesIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Dialect/Linalg/IR/LinalgInterfaces.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Dialect/Linalg/IR/LinalgInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td", - deps = [":LinalgStructuredOpsTdFiles"], -) - -td_library( - name = "BufferizableOpInterfaceTdFiles", - srcs = [ - "include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.td", - ], - includes = ["include"], - deps = [ - ":OpBaseTdFiles", - ], -) - -gentbl_cc_library( - name = "BufferizableOpInterfaceIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.td", - deps = [ - ":BufferizableOpInterfaceTdFiles", - ], -) - -td_library( - name = "BufferDeallocationOpInterfaceTdFiles", - srcs = [ - "include/mlir/Dialect/Bufferization/IR/BufferDeallocationOpInterface.td", - ], - includes = ["include"], - deps = [ - ":OpBaseTdFiles", - ], -) - -gentbl_cc_library( - name = "BufferDeallocationOpInterfaceIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Dialect/Bufferization/IR/BufferDeallocationOpInterface.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Dialect/Bufferization/IR/BufferDeallocationOpInterface.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Bufferization/IR/BufferDeallocationOpInterface.td", - deps = [ - ":BufferDeallocationOpInterfaceTdFiles", - ], -) - -td_library( - name = "SubsetOpInterfaceTdFiles", - srcs = [ - "include/mlir/Interfaces/SubsetOpInterface.td", - ], - includes = ["include"], - deps = [ - ":OpBaseTdFiles", - ], -) - -gentbl_cc_library( - name = "SubsetOpInterfaceIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Interfaces/SubsetOpInterface.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Interfaces/SubsetOpInterface.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Interfaces/SubsetOpInterface.td", - deps = [ - ":SubsetOpInterfaceTdFiles", - ], -) - -cc_library( - name = "SubsetOpInterface", - srcs = ["lib/Interfaces/SubsetOpInterface.cpp"], - hdrs = ["include/mlir/Interfaces/SubsetOpInterface.h"], - includes = ["include"], - deps = [ - ":DestinationStyleOpInterface", - ":IR", - ":SubsetOpInterfaceIncGen", - ":Support", - ":ValueBoundsOpInterface", - "//llvm:Support", - ], -) - -td_library( - name = "LinalgDocTdFiles", - srcs = ["include/mlir/Dialect/Linalg/IR/LinalgDoc.td"], - includes = ["include"], - deps = [ - ":LinalgOpsTdFiles", - ":LinalgStructuredOpsTdFiles", - ], -) - -gentbl_cc_library( - name = "LinalgDocIncGen", - tbl_outs = [ - ( - ["-gen-op-doc"], - "g3doc/Dialects/Linalg/LinalgOps.md", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Linalg/IR/LinalgDoc.td", - deps = [":LinalgDocTdFiles"], -) - -cc_library( - name = "LinalgToStandard", - srcs = glob([ - "lib/Conversion/LinalgToStandard/*.cpp", - "lib/Conversion/LinalgToStandard/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/LinalgToStandard/*.h", - ]), - includes = ["include"], - deps = [ - ":AffineDialect", - ":ConversionPassIncGen", - ":FuncDialect", - ":IR", - ":LLVMDialect", - ":LinalgDialect", - ":LinalgTransforms", - ":MemRefDialect", - ":Pass", - ":SCFDialect", - ":Support", - ":Transforms", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "LinalgDialect", - srcs = glob(["lib/Dialect/Linalg/IR/*.cpp"]), - hdrs = glob(["include/mlir/Dialect/Linalg/IR/*.h"]), - includes = ["include"], - deps = [ - ":AffineDialect", - ":ArithDialect", - ":ArithUtils", - ":AsmParser", - ":BufferizationDialect", - ":ComplexDialect", - ":ControlFlowInterfaces", - ":CopyOpInterface", - ":DestinationStyleOpInterface", - ":DialectUtils", - ":FuncDialect", - ":FunctionInterfaces", - ":IR", - ":InferTypeOpInterface", - ":LinalgEnumsIncGen", - ":LinalgInterfacesIncGen", - ":LinalgNamedStructuredOpsYamlIncGen", - ":LinalgOpsIncGen", - ":LinalgStructuredOpsIncGen", - ":MathDialect", - ":MemRefDialect", - ":Parser", - ":SCFDialect", - ":MeshShardingInterface", - ":SideEffectInterfaces", - ":SparseTensorDialect", - ":Support", - ":TensorDialect", - ":TilingInterface", - ":ValueBoundsOpInterface", - ":ViewLikeInterface", - "//llvm:Support", - ], -) - -cc_library( - name = "LinalgTransformOps", - srcs = glob([ - "lib/Dialect/Linalg/TransformOps/*.cpp", - ]), - hdrs = glob([ - "include/mlir/Dialect/Linalg/TransformOps/*.h", - ]), - includes = ["include"], - deps = [ - ":AffineDialect", - ":Analysis", - ":ArithDialect", - ":AsmParser", - ":BufferizationDialect", - ":BufferizationTransforms", - ":DialectUtils", - ":FuncDialect", - ":FunctionInterfaces", - ":GPUDialect", - ":IR", - ":IndexDialect", - ":LinalgDialect", - ":LinalgMatchOpsIncGen", - ":LinalgTransformEnumsIncGen", - ":LinalgTransformOpsIncGen", - ":LinalgTransforms", - ":LinalgUtils", - ":SCFDialect", - ":SCFTransforms", - ":Support", - ":TensorDialect", - ":TensorUtils", - ":TilingInterface", - ":TransformDialect", - ":TransformDialectUtils", - ":TransformUtils", - ":VectorDialect", - ":VectorTransforms", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "LinalgPassIncGen", - tbl_outs = [ - ( - [ - "-gen-pass-decls", - "-name=Linalg", - ], - "include/mlir/Dialect/Linalg/Passes.h.inc", - ), - ( - [ - "-gen-pass-capi-header", - "--prefix=Linalg", - ], - "include/mlir/Dialect/Linalg/Passes.capi.h.inc", - ), - ( - [ - "-gen-pass-capi-impl", - "--prefix=Linalg", - ], - "include/mlir/Dialect/Linalg/Passes.capi.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Linalg/Passes.td", - deps = [":PassBaseTdFiles"], -) - -cc_library( - name = "LinalgUtils", - srcs = glob([ - "lib/Dialect/Linalg/Utils/*.cpp", - "lib/Dialect/Linalg/Utils/*.h", - ]), - hdrs = glob([ - "include/mlir/Dialect/Linalg/Utils/*.h", - ]), - deps = [ - ":AffineAnalysis", - ":AffineDialect", - ":AffineUtils", - ":Analysis", - ":ArithDialect", - ":ArithUtils", - ":DialectUtils", - ":FuncDialect", - ":IR", - ":LinalgDialect", - ":MemRefDialect", - ":Pass", - ":SCFDialect", - ":TensorDialect", - ":TensorUtils", - "//llvm:Support", - ], -) - -cc_library( - name = "LinalgTransforms", - srcs = glob([ - "lib/Dialect/Linalg/Transforms/*.cpp", - "lib/Dialect/Linalg/Transforms/*.h", - ]), - hdrs = [ - "include/mlir/Dialect/Linalg/Passes.h", - ] + glob([ - "include/mlir/Dialect/Linalg/Transforms/*.h", - ]), - includes = ["include"], - deps = [ - ":AffineAnalysis", - ":AffineDialect", - ":AffineTransforms", - ":AffineUtils", - ":Analysis", - ":ArithDialect", - ":ArithTransforms", - ":ArithUtils", - ":BufferizationDialect", - ":BufferizationTransforms", - ":ComplexDialect", - ":ControlFlowDialect", - ":DestinationStyleOpInterface", - ":DialectUtils", - ":FuncDialect", - ":FuncTransforms", - ":GPUDialect", - ":IR", - ":LinalgDialect", - ":LinalgPassIncGen", - ":LinalgStructuredOpsIncGen", - ":LinalgUtils", - ":LoopLikeInterface", - ":MaskableOpInterface", - ":MathDialect", - ":MemRefDialect", - ":MemRefTransforms", - ":MeshDialect", - ":MeshTransforms", - ":Pass", - ":SCFDialect", - ":SCFTransforms", - ":SCFUtils", - ":MeshShardingInterface", - ":SparseTensorDialect", - ":SubsetOpInterface", - ":Support", - ":TensorDialect", - ":TensorTilingInterfaceImpl", - ":TensorTransforms", - ":TensorUtils", - ":TilingInterface", - ":TransformUtils", - ":Transforms", - ":ValueBoundsOpInterface", - ":VectorDialect", - ":VectorToSCF", - ":VectorTransforms", - ":VectorUtils", - ":X86VectorTransforms", - "//llvm:Support", - ], -) - -td_library( - name = "ValueBoundsOpInterfaceTdFiles", - srcs = [ - "include/mlir/Interfaces/ValueBoundsOpInterface.td", - ], - includes = ["include"], - deps = [ - ":OpBaseTdFiles", - ], -) - -gentbl_cc_library( - name = "ValueBoundsOpInterfaceIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Interfaces/ValueBoundsOpInterface.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Interfaces/ValueBoundsOpInterface.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Interfaces/ValueBoundsOpInterface.td", - deps = [ - ":ValueBoundsOpInterfaceTdFiles", - ], -) - -cc_library( - name = "ValueBoundsOpInterface", - srcs = ["lib/Interfaces/ValueBoundsOpInterface.cpp"], - hdrs = ["include/mlir/Interfaces/ValueBoundsOpInterface.h"], - includes = ["include"], - deps = [ - ":Analysis", - ":DestinationStyleOpInterface", - ":IR", - ":Support", - ":ValueBoundsOpInterfaceIncGen", - ":ViewLikeInterface", - "//llvm:Support", - ], -) - -cc_library( - name = "ArithValueBoundsOpInterfaceImpl", - srcs = ["lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp"], - hdrs = ["include/mlir/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.h"], - includes = ["include"], - deps = [ - ":ArithDialect", - ":IR", - ":ValueBoundsOpInterface", - ], -) - -cc_library( - name = "TilingInterface", - srcs = ["lib/Interfaces/TilingInterface.cpp"], - hdrs = ["include/mlir/Interfaces/TilingInterface.h"], - includes = ["include"], - deps = [ - ":DialectUtils", - ":IR", - ":Support", - ":TilingInterfaceIncGen", - ":ViewLikeInterface", - "//llvm:Support", - ], -) - -##---------------------------------------------------------------------------## -# Vector dialect. -##---------------------------------------------------------------------------## - -td_library( - name = "MaskingOpInterfaceTdFiles", - srcs = ["include/mlir/Dialect/Vector/Interfaces/MaskingOpInterface.td"], - includes = ["include"], - deps = [":OpBaseTdFiles"], -) - -td_library( - name = "MaskableOpInterfaceTdFiles", - srcs = ["include/mlir/Dialect/Vector/Interfaces/MaskableOpInterface.td"], - includes = ["include"], - deps = [":OpBaseTdFiles"], -) - -td_library( - name = "VectorOpsTdFiles", - srcs = [ - "include/mlir/Dialect/Vector/IR/Vector.td", - "include/mlir/Dialect/Vector/IR/VectorAttributes.td", - "include/mlir/Dialect/Vector/IR/VectorOps.td", - ], - includes = ["include"], - deps = [ - ":ControlFlowInterfacesTdFiles", - ":DestinationStyleOpInterfaceTdFiles", - ":InferTypeOpInterfaceTdFiles", - ":MaskableOpInterfaceTdFiles", - ":MaskingOpInterfaceTdFiles", - ":OpBaseTdFiles", - ":SideEffectInterfacesTdFiles", - ":VectorInterfacesTdFiles", - ":ViewLikeInterfaceTdFiles", - ], -) - -td_library( - name = "VectorTransformOpsTdFiles", - srcs = [ - "include/mlir/Dialect/Vector/TransformOps/VectorTransformOps.td", - ], - includes = ["include"], - deps = [ - ":PDLDialectTdFiles", - ":SCFTdFiles", - ":TransformDialectTdFiles", - ":VectorTransformsTdFiles", - ], -) - -gentbl_cc_library( - name = "MaskableOpInterfaceIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Dialect/Vector/Interfaces/MaskableOpInterface.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Dialect/Vector/Interfaces/MaskableOpInterface.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Vector/Interfaces/MaskableOpInterface.td", - deps = [":MaskableOpInterfaceTdFiles"], -) - -gentbl_cc_library( - name = "MaskingOpInterfaceIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Dialect/Vector/Interfaces/MaskingOpInterface.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Dialect/Vector/Interfaces/MaskingOpInterface.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Vector/Interfaces/MaskingOpInterface.td", - deps = [":MaskingOpInterfaceTdFiles"], -) - -gentbl_cc_library( - name = "VectorDialectIncGen", - tbl_outs = [ - ( - [ - "-gen-dialect-decls", - "-dialect=vector", - ], - "include/mlir/Dialect/Vector/IR/VectorDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=vector", - ], - "include/mlir/Dialect/Vector/IR/VectorDialect.cpp.inc", - ), - ( - ["-gen-op-doc"], - "g3doc/Dialects/Vector/Vector.md", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Vector/IR/Vector.td", - deps = [ - ":ArithOpsTdFiles", - ":VectorOpsTdFiles", - ], -) - -gentbl_cc_library( - name = "VectorOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/Vector/IR/VectorOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/Vector/IR/VectorOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Vector/IR/VectorOps.td", - deps = [ - ":ArithOpsTdFiles", - ":VectorOpsTdFiles", - ], -) - -gentbl_cc_library( - name = "VectorAttributesIncGen", - tbl_outs = [ - ( - ["-gen-enum-decls"], - "include/mlir/Dialect/Vector/IR/VectorEnums.h.inc", - ), - ( - ["-gen-enum-defs"], - "include/mlir/Dialect/Vector/IR/VectorEnums.cpp.inc", - ), - ( - ["-gen-attrdef-decls"], - "include/mlir/Dialect/Vector/IR/VectorAttributes.h.inc", - ), - ( - ["-gen-attrdef-defs"], - "include/mlir/Dialect/Vector/IR/VectorAttributes.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Vector/IR/VectorAttributes.td", - deps = [ - ":ArithOpsTdFiles", - ":VectorOpsTdFiles", - ], -) - -gentbl_cc_library( - name = "VectorTransformOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/Vector/TransformOps/VectorTransformOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/Vector/TransformOps/VectorTransformOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Vector/TransformOps/VectorTransformOps.td", - deps = [ - ":VectorTransformOpsTdFiles", - ], -) - -cc_library( - name = "MaskableOpInterface", - srcs = ["lib/Dialect/Vector/Interfaces/MaskableOpInterface.cpp"], - hdrs = ["include/mlir/Dialect/Vector/Interfaces/MaskableOpInterface.h"], - includes = ["include"], - deps = [ - ":IR", - ":MaskableOpInterfaceIncGen", - ":MaskingOpInterface", - ":Support", - "//llvm:Support", - ], -) - -cc_library( - name = "MaskingOpInterface", - srcs = ["lib/Dialect/Vector/Interfaces/MaskingOpInterface.cpp"], - hdrs = ["include/mlir/Dialect/Vector/Interfaces/MaskingOpInterface.h"], - includes = ["include"], - deps = [ - ":IR", - ":MaskingOpInterfaceIncGen", - ":Support", - "//llvm:Support", - ], -) - -cc_library( - name = "VectorToLLVM", - srcs = glob([ - "lib/Conversion/VectorToLLVM/*.cpp", - "lib/Conversion/VectorToLLVM/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/VectorToLLVM/*.h", - ]), - includes = ["include"], - deps = [ - ":AMXDialect", - ":AMXTransforms", - ":ArithAttrToLLVMConversion", - ":ArithDialect", - ":ArithUtils", - ":ArmNeonDialect", - ":ArmSMEDialect", - ":ArmSMETransforms", - ":ArmSVEDialect", - ":ArmSVETransforms", - ":ConversionPassIncGen", - ":DialectUtils", - ":FuncDialect", - ":IR", - ":LLVMCommonConversion", - ":LLVMDialect", - ":MaskableOpInterface", - ":MemRefDialect", - ":Pass", - ":Support", - ":ToLLVMIRTranslation", - ":Transforms", - ":VectorDialect", - ":VectorTransforms", - ":X86VectorDialect", - ":X86VectorTransforms", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "VectorToArmSME", - srcs = glob([ - "lib/Conversion/VectorToArmSME/*.cpp", - "lib/Conversion/VectorToArmSME/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/VectorToArmSME/*.h", - ]), - includes = ["include"], - deps = [ - ":ArmSMEDialect", - ":ConversionPassIncGen", - ":IR", - ":MemRefDialect", - ":Pass", - ":Transforms", - "//llvm:Support", - ], -) - -cc_library( - name = "VectorToGPU", - srcs = glob([ - "lib/Conversion/VectorToGPU/*.cpp", - "lib/Conversion/VectorToGPU/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/VectorToGPU/*.h", - ]), - includes = ["include"], - deps = [ - ":AffineDialect", - ":Analysis", - ":ArithDialect", - ":ConversionPassIncGen", - ":DialectUtils", - ":FuncDialect", - ":FuncToLLVM", - ":GPUDialect", - ":IR", - ":LLVMDialect", - ":MemRefDialect", - ":NVGPUDialect", - ":NVGPUUtils", - ":NVVMDialect", - ":Pass", - ":SCFDialect", - ":Support", - ":Transforms", - ":VectorDialect", - ":VectorTransforms", - ":VectorUtils", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "VectorToSCF", - srcs = glob([ - "lib/Conversion/VectorToSCF/*.cpp", - "lib/Conversion/VectorToSCF/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/VectorToSCF/*.h", - ]), - includes = ["include"], - deps = [ - ":AffineDialect", - ":AffineUtils", - ":ArithDialect", - ":ConversionPassIncGen", - ":FuncDialect", - ":FuncToLLVM", - ":IR", - ":LLVMDialect", - ":MemRefDialect", - ":Pass", - ":SCFDialect", - ":Support", - ":TensorDialect", - ":Transforms", - ":VectorDialect", - ":VectorTransforms", - "//llvm:Core", - "//llvm:Support", - ], -) - -td_library( - name = "TosaDialectTdFiles", - srcs = glob(["include/mlir/Dialect/Tosa/IR/*.td"]), - deps = [ - ":InferTypeOpInterfaceTdFiles", - ":LoopLikeInterfaceTdFiles", - ":OpBaseTdFiles", - ":SideEffectInterfacesTdFiles", - ":VectorInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "TosaDialectIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/Tosa/IR/TosaOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/Tosa/IR/TosaOps.cpp.inc", - ), - ( - ["-gen-dialect-decls"], - "include/mlir/Dialect/Tosa/IR/TosaOpsDialect.h.inc", - ), - ( - ["-gen-dialect-defs"], - "include/mlir/Dialect/Tosa/IR/TosaOpsDialect.cpp.inc", - ), - ( - ["-gen-attrdef-decls"], - "include/mlir/Dialect/Tosa/IR/TosaAttributes.h.inc", - ), - ( - ["-gen-attrdef-defs"], - "include/mlir/Dialect/Tosa/IR/TosaAttributes.cpp.inc", - ), - ( - ["-gen-op-doc"], - "g3doc/Dialects/Tosa/TosaOps.md", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Tosa/IR/TosaOps.td", - deps = [":TosaDialectTdFiles"], -) - -gentbl_cc_library( - name = "TosaDialectBytecodeGen", - strip_include_prefix = "include", - tbl_outs = [ - ( - [ - "-gen-bytecode", - "-bytecode-dialect=Tosa", - ], - "include/mlir/Dialect/Tosa/IR/TosaDialectBytecode.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Tosa/IR/TosaDialectBytecode.td", - deps = [ - ":BytecodeTdFiles", - ], -) - -gentbl_cc_library( - name = "TosaInterfacesIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Dialect/Tosa/IR/TosaInterfaces.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Dialect/Tosa/IR/TosaInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Tosa/IR/TosaInterfaces.td", - deps = [":TosaDialectTdFiles"], -) - -gentbl_cc_library( - name = "TosaPassIncGen", - tbl_outs = [ - ( - [ - "-gen-pass-decls", - "-name=TosaOpt", - ], - "include/mlir/Dialect/Tosa/Transforms/Passes.h.inc", - ), - ( - [ - "-gen-enum-decls", - "-name=TosaOpt", - ], - "include/mlir/Dialect/Tosa/Transforms/PassesEnums.h.inc", - ), - ( - [ - "-gen-enum-defs", - "-name=TosaOpt", - ], - "include/mlir/Dialect/Tosa/Transforms/PassesEnums.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Tosa/Transforms/Passes.td", - deps = [ - ":OpBaseTdFiles", - ":PassBaseTdFiles", - ], -) - -cc_library( - name = "TosaDialect", - srcs = glob([ - "lib/Dialect/Tosa/IR/*.cpp", - "lib/Dialect/Tosa/IR/*.h", - "lib/Dialect/Tosa/Utils/*.cpp", - "lib/Dialect/Tosa/Transforms/*.cpp", - ]), - hdrs = glob([ - "include/mlir/Dialect/Tosa/IR/*.h", - "include/mlir/Dialect/Tosa/Utils/*.h", - "include/mlir/Dialect/Tosa/Transforms/*.h", - ]), - includes = ["include"], - deps = [ - ":Analysis", - ":ArithDialect", - ":Dialect", - ":DialectUtils", - ":FuncDialect", - ":IR", - ":InferTypeOpInterface", - ":LoopLikeInterface", - ":MeshDialect", - ":MeshShardingInterface", - ":Pass", - ":QuantOps", - ":Support", - ":TensorDialect", - ":TosaDialectBytecodeGen", - ":TosaDialectIncGen", - ":TosaInterfacesIncGen", - ":TosaPassIncGen", - ":TransformUtils", - ":VectorInterfaces", - "//llvm:Support", - ], -) - -cc_library( - name = "TosaToArith", - srcs = glob([ - "lib/Conversion/TosaToArith/*.cpp", - "lib/Conversion/TosaToArith/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/TosaToArith/*.h", - ]), - includes = [ - "include", - "lib/Conversion/TosaToArith", - ], - deps = [ - ":ArithDialect", - ":ConversionPassIncGen", - ":FuncDialect", - ":IR", - ":Pass", - ":TosaDialect", - ":Transforms", - ], -) - -cc_library( - name = "TosaToLinalg", - srcs = glob([ - "lib/Conversion/TosaToLinalg/*.cpp", - "lib/Conversion/TosaToLinalg/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/TosaToLinalg/*.h", - ]), - includes = [ - "include", - "lib/Conversion/TosaToLinalg", - ], - deps = [ - ":ArithDialect", - ":ArithUtils", - ":ConversionPassIncGen", - ":DialectUtils", - ":FuncDialect", - ":IR", - ":LinalgDialect", - ":LinalgUtils", - ":MathDialect", - ":Pass", - ":SCFDialect", - ":TensorDialect", - ":TensorUtils", - ":TosaDialect", - ":Transforms", - "//llvm:Support", - ], -) - -cc_library( - name = "TosaToMLProgram", - srcs = glob([ - "lib/Conversion/TosaToMLProgram/*.cpp", - "lib/Conversion/TosaToMLProgram/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/TosaToMLProgram/*.h", - ]), - includes = [ - "include", - "lib/Conversion/TosaToMLProgram", - ], - deps = [ - ":ConversionPassIncGen", - ":FuncDialect", - ":IR", - ":MLProgramDialect", - ":Pass", - ":TosaDialect", - ":Transforms", - ], -) - -cc_library( - name = "TosaToSCF", - srcs = glob([ - "lib/Conversion/TosaToSCF/*.cpp", - "lib/Conversion/TosaToSCF/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/TosaToSCF/*.h", - ]), - includes = [ - "include", - "lib/Conversion/TosaToSCF", - ], - deps = [ - ":ConversionPassIncGen", - ":FuncDialect", - ":IR", - ":Pass", - ":SCFDialect", - ":TensorDialect", - ":TosaDialect", - ":Transforms", - ], -) - -cc_library( - name = "TosaToTensor", - srcs = glob([ - "lib/Conversion/TosaToTensor/*.cpp", - "lib/Conversion/TosaToTensor/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/TosaToTensor/*.h", - ]), - includes = [ - "include", - "lib/Conversion/TosaToTensor", - ], - deps = [ - ":ArithDialect", - ":ArithUtils", - ":ConversionPassIncGen", - ":FuncDialect", - ":IR", - ":Pass", - ":TensorDialect", - ":TensorUtils", - ":TosaDialect", - ":Transforms", - ], -) - -td_library( - name = "TransformDialectTdFiles", - srcs = glob(["include/mlir/Dialect/Transform/IR/*.td"]), - deps = [ - ":CastInterfacesTdFiles", - ":ControlFlowInterfacesTdFiles", - ":InferTypeOpInterfaceTdFiles", - ":OpBaseTdFiles", - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "TransformDialectEnumsIncGen", - tbl_outs = [ - ( - [ - "-gen-enum-decls", - ], - "include/mlir/Dialect/Transform/IR/TransformDialectEnums.h.inc", - ), - ( - [ - "-gen-enum-defs", - ], - "include/mlir/Dialect/Transform/IR/TransformDialectEnums.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Transform/IR/TransformAttrs.td", - deps = [":TransformDialectTdFiles"], -) - -gentbl_cc_library( - name = "TransformDialectMatchInterfacesIncGen", - tbl_outs = [ - ( - [ - "-gen-op-interface-decls", - ], - "include/mlir/Dialect/Transform/IR/MatchInterfaces.h.inc", - ), - ( - [ - "-gen-op-interface-defs", - ], - "include/mlir/Dialect/Transform/IR/MatchInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Transform/IR/MatchInterfaces.td", - deps = [ - ":TransformDialectInterfacesIncGen", - ":TransformDialectTdFiles", - ], -) - -gentbl_cc_library( - name = "TransformDialectInterfacesIncGen", - tbl_outs = [ - ( - [ - "-gen-op-interface-decls", - ], - "include/mlir/Dialect/Transform/IR/TransformInterfaces.h.inc", - ), - ( - [ - "-gen-op-interface-defs", - ], - "include/mlir/Dialect/Transform/IR/TransformInterfaces.cpp.inc", - ), - ( - [ - "-gen-type-interface-decls", - ], - "include/mlir/Dialect/Transform/IR/TransformTypeInterfaces.h.inc", - ), - ( - [ - "-gen-type-interface-defs", - ], - "include/mlir/Dialect/Transform/IR/TransformTypeInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Transform/IR/TransformInterfaces.td", - deps = [":TransformDialectTdFiles"], -) - -gentbl_cc_library( - name = "TransformDialectIncGen", - tbl_outs = [ - ( - [ - "-gen-dialect-decls", - ], - "include/mlir/Dialect/Transform/IR/TransformDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - ], - "include/mlir/Dialect/Transform/IR/TransformDialect.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Transform/IR/TransformDialect.td", - deps = [":TransformDialectTdFiles"], -) - -gentbl_cc_library( - name = "TransformOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/Transform/IR/TransformOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/Transform/IR/TransformOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Transform/IR/TransformOps.td", - deps = [ - ":CallInterfacesTdFiles", - ":FunctionInterfacesTdFiles", - ":TransformDialectTdFiles", - ], -) - -gentbl_cc_library( - name = "TransformTypesIncGen", - tbl_outs = [ - ( - ["-gen-typedef-decls"], - "include/mlir/Dialect/Transform/IR/TransformTypes.h.inc", - ), - ( - ["-gen-typedef-defs"], - "include/mlir/Dialect/Transform/IR/TransformTypes.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Transform/IR/TransformTypes.td", - deps = [":TransformDialectTdFiles"], -) - -cc_library( - name = "TransformDialect", - srcs = glob(["lib/Dialect/Transform/IR/*.cpp"]), - hdrs = glob(["include/mlir/Dialect/Transform/IR/*.h"]), - deps = [ - ":Analysis", - ":CallOpInterfaces", - ":CastInterfaces", - ":ControlFlowInterfaces", - ":ConvertToLLVMInterface", - ":FunctionInterfaces", - ":IR", - ":LLVMCommonConversion", - ":LLVMDialect", - ":LoopLikeInterface", - ":Pass", - ":Rewrite", - ":SideEffectInterfaces", - ":Support", - ":TransformDialectEnumsIncGen", - ":TransformDialectIncGen", - ":TransformDialectInterfacesIncGen", - ":TransformDialectMatchInterfacesIncGen", - ":TransformDialectUtils", - ":TransformOpsIncGen", - ":TransformTypesIncGen", - ":Transforms", - "//llvm:Support", - ], -) - -td_library( - name = "TransformPDLExtensionTdFiles", - srcs = glob(["include/mlir/Dialect/Transform/PDLExtension/*.td"]), - deps = [ - ":PDLDialectTdFiles", - ":TransformDialectTdFiles", - ], -) - -gentbl_cc_library( - name = "TransformPDLExtensionOpsIncGen", - tbl_outs = [ - ( - [ - "-gen-op-decls", - ], - "include/mlir/Dialect/Transform/PDLExtension/PDLExtensionOps.h.inc", - ), - ( - [ - "-gen-op-defs", - ], - "include/mlir/Dialect/Transform/PDLExtension/PDLExtensionOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Transform/PDLExtension/PDLExtensionOps.td", - deps = [":TransformPDLExtensionTdFiles"], -) - -cc_library( - name = "TransformPDLExtension", - srcs = glob(["lib/Dialect/Transform/PDLExtension/*.cpp"]), - hdrs = glob(["include/mlir/Dialect/Transform/PDLExtension/*.h"]), - deps = [ - ":IR", - ":PDLDialect", - ":PDLInterpDialect", - ":Rewrite", - ":SideEffectInterfaces", - ":Support", - ":TransformDialect", - ":TransformPDLExtensionOpsIncGen", - "//llvm:Support", - ], -) - -td_library( - name = "TransformDebugExtensionTdFiles", - srcs = glob(["include/mlir/Dialect/Transform/DebugExtension/*.td"]), - deps = [ - ":TransformDialectTdFiles", - ], -) - -gentbl_cc_library( - name = "TransformDebugExtensionOpsIncGen", - tbl_outs = [ - ( - [ - "-gen-op-decls", - ], - "include/mlir/Dialect/Transform/DebugExtension/DebugExtensionOps.h.inc", - ), - ( - [ - "-gen-op-defs", - ], - "include/mlir/Dialect/Transform/DebugExtension/DebugExtensionOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Transform/DebugExtension/DebugExtensionOps.td", - deps = [":TransformDebugExtensionTdFiles"], -) - -cc_library( - name = "TransformDebugExtension", - srcs = glob(["lib/Dialect/Transform/DebugExtension/*.cpp"]), - hdrs = glob(["include/mlir/Dialect/Transform/DebugExtension/*.h"]), - deps = [ - ":IR", - ":Support", - ":TransformDebugExtensionOpsIncGen", - ":TransformDialect", - "//llvm:Support", - ], -) - -td_library( - name = "TransformLoopExtensionTdFiles", - srcs = glob(["include/mlir/Dialect/Transform/LoopExtension/*.td"]), - deps = [ - ":TransformDialectTdFiles", - ], -) - -gentbl_cc_library( - name = "TransformLoopExtensionOpsIncGen", - tbl_outs = [ - ( - [ - "-gen-op-decls", - ], - "include/mlir/Dialect/Transform/LoopExtension/LoopExtensionOps.h.inc", - ), - ( - [ - "-gen-op-defs", - ], - "include/mlir/Dialect/Transform/LoopExtension/LoopExtensionOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Transform/LoopExtension/LoopExtensionOps.td", - deps = [":TransformLoopExtensionTdFiles"], -) - -cc_library( - name = "TransformLoopExtension", - srcs = glob(["lib/Dialect/Transform/LoopExtension/*.cpp"]), - hdrs = glob(["include/mlir/Dialect/Transform/LoopExtension/*.h"]), - deps = [ - ":IR", - ":LoopLikeInterface", - ":Rewrite", - ":SideEffectInterfaces", - ":Support", - ":TransformDialect", - ":TransformLoopExtensionOpsIncGen", - ":Transforms", - "//llvm:Support", - ], -) - -td_library( - name = "TransformDialectTransformsTdFiles", - srcs = glob(["include/mlir/Dialect/Transform/Transforms/*.td"]), - deps = [ - ":PassBaseTdFiles", - ":TransformDialectTdFiles", - ], -) - -gentbl_cc_library( - name = "TransformDialectTransformsIncGen", - tbl_outs = [ - ( - [ - "-gen-pass-decls", - "-name=Transform", - ], - "include/mlir/Dialect/Transform/Transforms/Passes.h.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Transform/Transforms/Passes.td", - deps = [":TransformDialectTransformsTdFiles"], -) - -cc_library( - name = "TransformDialectTransforms", - srcs = glob(["lib/Dialect/Transform/Transforms/*.cpp"]), - hdrs = glob(["include/mlir/Dialect/Transform/Transforms/*.h"]), - deps = [ - ":Analysis", - ":FunctionInterfaces", - ":IR", - ":Parser", - ":Pass", - ":SideEffectInterfaces", - ":Support", - ":TransformDialect", - ":TransformDialectTransformsIncGen", - "//llvm:Support", - ], -) - -cc_library( - name = "TransformDialectUtils", - srcs = glob(["lib/Dialect/Transform/Utils/*cpp"]), - hdrs = glob(["include/mlir/Dialect/Transform/Utils/*.h"]), - includes = ["include"], - deps = [ - ":DialectUtils", - ":IR", - ":Support", - ":ViewLikeInterface", - "//llvm:Support", - ], -) - -td_library( - name = "ComplexOpsTdFiles", - srcs = [ - "include/mlir/Dialect/Complex/IR/ComplexBase.td", - "include/mlir/Dialect/Complex/IR/ComplexOps.td", - ], - includes = ["include"], - deps = [ - ":ArithOpsInterfacesTdFiles", - ":ArithOpsTdFiles", - ":BuiltinDialectTdFiles", - ":InferTypeOpInterfaceTdFiles", - ":OpBaseTdFiles", - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "ComplexAttributesIncGen", - tbl_outs = [ - ( - ["-gen-attrdef-decls"], - "include/mlir/Dialect/Complex/IR/ComplexAttributes.h.inc", - ), - ( - ["-gen-attrdef-defs"], - "include/mlir/Dialect/Complex/IR/ComplexAttributes.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Complex/IR/ComplexAttributes.td", - deps = [":ComplexOpsTdFiles"], -) - -gentbl_cc_library( - name = "ComplexBaseIncGen", - tbl_outs = [ - ( - [ - "-gen-dialect-decls", - "-dialect=complex", - ], - "include/mlir/Dialect/Complex/IR/ComplexOpsDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=complex", - ], - "include/mlir/Dialect/Complex/IR/ComplexOpsDialect.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Complex/IR/ComplexBase.td", - deps = [":ComplexOpsTdFiles"], -) - -gentbl_cc_library( - name = "ComplexOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/Complex/IR/ComplexOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/Complex/IR/ComplexOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Complex/IR/ComplexOps.td", - deps = [":ComplexOpsTdFiles"], -) - -cc_library( - name = "ComplexDialect", - srcs = glob( - [ - "lib/Dialect/Complex/IR/*.cpp", - "lib/Dialect/Complex/IR/*.h", - ], - ), - hdrs = ["include/mlir/Dialect/Complex/IR/Complex.h"], - includes = ["include"], - deps = [ - ":ArithDialect", - ":ComplexAttributesIncGen", - ":ComplexBaseIncGen", - ":ComplexOpsIncGen", - ":ConvertToLLVMInterface", - ":IR", - ":InferTypeOpInterface", - ":SideEffectInterfaces", - "//llvm:Support", - ], -) - -cc_library( - name = "ComplexToLLVM", - srcs = glob([ - "lib/Conversion/ComplexToLLVM/*.cpp", - "lib/Conversion/ComplexToLLVM/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/ComplexToLLVM/*.h", - ]), - includes = ["include"], - deps = [ - ":ArithAttrToLLVMConversion", - ":ArithDialect", - ":ComplexDialect", - ":ConversionPassIncGen", - ":ConvertToLLVMInterface", - ":FuncDialect", - ":IR", - ":LLVMCommonConversion", - ":LLVMDialect", - ":Pass", - ":Support", - ":Transforms", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "ComplexToLibm", - srcs = glob([ - "lib/Conversion/ComplexToLibm/*.cpp", - "lib/Conversion/ComplexToLibm/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/ComplexToLibm/*.h", - ]), - includes = ["include"], - deps = [ - ":ComplexDialect", - ":ConversionPassIncGen", - ":DialectUtils", - ":FuncDialect", - ":IR", - ":Pass", - ":Support", - ":Transforms", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "ComplexToSPIRV", - srcs = glob([ - "lib/Conversion/ComplexToSPIRV/*.cpp", - "lib/Conversion/ComplexToSPIRV/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/ComplexToSPIRV/*.h", - ]), - includes = ["include"], - deps = [ - ":ComplexDialect", - ":ConversionPassIncGen", - ":IR", - ":Pass", - ":SPIRVCommonConversion", - ":SPIRVConversion", - ":SPIRVDialect", - ":Support", - ":Transforms", - "//llvm:Core", - "//llvm:Support", - ], -) - -cc_library( - name = "ComplexToStandard", - srcs = glob([ - "lib/Conversion/ComplexToStandard/*.cpp", - "lib/Conversion/ComplexToStandard/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/ComplexToStandard/*.h", - ]), - includes = ["include"], - deps = [ - ":ArithDialect", - ":ComplexDialect", - ":ConversionPassIncGen", - ":FuncDialect", - ":IR", - ":MathDialect", - ":Pass", - ":Transforms", - ], -) - -exports_files([ - "include/mlir/Interfaces/CallInterfaces.h", - "include/mlir/Interfaces/CastInterfaces.h", - "include/mlir/Interfaces/ControlFlowInterfaces.h", - "include/mlir/Transforms/InliningUtils.h", -]) - -td_library( - name = "ArithOpsTdFiles", - srcs = [ - "include/mlir/Dialect/Arith/IR/ArithBase.td", - "include/mlir/Dialect/Arith/IR/ArithOps.td", - ], - includes = ["include"], - deps = [ - ":ArithOpsInterfacesTdFiles", - ":BuiltinDialectTdFiles", - ":CastInterfacesTdFiles", - ":InferIntRangeInterfaceTdFiles", - ":InferTypeOpInterfaceTdFiles", - ":OpBaseTdFiles", - ":SideEffectInterfacesTdFiles", - ":VectorInterfacesTdFiles", - ], -) - -td_library( - name = "ArithOpsInterfacesTdFiles", - srcs = [ - "include/mlir/Dialect/Arith/IR/ArithOpsInterfaces.td", - ], - includes = ["include"], - deps = [ - ":OpBaseTdFiles", - ], -) - -gentbl_cc_library( - name = "ArithBaseIncGen", - tbl_outs = [ - ( - [ - "-gen-dialect-decls", - "-dialect=arith", - ], - "include/mlir/Dialect/Arith/IR/ArithOpsDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=arith", - ], - "include/mlir/Dialect/Arith/IR/ArithOpsDialect.cpp.inc", - ), - ( - ["-gen-enum-decls"], - "include/mlir/Dialect/Arith/IR/ArithOpsEnums.h.inc", - ), - ( - ["-gen-enum-defs"], - "include/mlir/Dialect/Arith/IR/ArithOpsEnums.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Arith/IR/ArithBase.td", - deps = [":ArithOpsTdFiles"], -) - -gentbl_cc_library( - name = "ArithOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/Arith/IR/ArithOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/Arith/IR/ArithOps.cpp.inc", - ), - ( - [ - "-gen-attrdef-decls", - "-attrdefs-dialect=arith", - ], - "include/mlir/Dialect/Arith/IR/ArithOpsAttributes.h.inc", - ), - ( - [ - "-gen-attrdef-defs", - "-attrdefs-dialect=arith", - ], - "include/mlir/Dialect/Arith/IR/ArithOpsAttributes.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Arith/IR/ArithOps.td", - deps = [ - ":ArithOpsTdFiles", - ], -) - -gentbl_cc_library( - name = "ArithOpsInterfacesIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Dialect/Arith/IR/ArithOpsInterfaces.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Dialect/Arith/IR/ArithOpsInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Arith/IR/ArithOpsInterfaces.td", - deps = [ - ":ArithOpsInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "ArithCanonicalizationIncGen", - strip_include_prefix = "include/mlir/Dialect/Arith/IR", - tbl_outs = [ - ( - ["-gen-rewriters"], - "include/mlir/Dialect/Arith/IR/ArithCanonicalization.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "lib/Dialect/Arith/IR/ArithCanonicalization.td", - deps = [ - ":ArithOpsTdFiles", - ":CastInterfacesTdFiles", - ":FuncTdFiles", - ], -) - -cc_library( - name = "ArithDialect", - srcs = [ - "lib/Dialect/Arith/IR/ArithDialect.cpp", - "lib/Dialect/Arith/IR/ArithOps.cpp", - "lib/Dialect/Arith/IR/InferIntRangeInterfaceImpls.cpp", - ], - hdrs = [ - "include/mlir/Dialect/Arith/IR/Arith.h", - "include/mlir/Transforms/InliningUtils.h", - ], - includes = ["include"], - deps = [ - ":ArithBaseIncGen", - ":ArithCanonicalizationIncGen", - ":ArithOpsIncGen", - ":ArithOpsInterfacesIncGen", - ":CastInterfaces", - ":CommonFolders", - ":ConvertToLLVMInterface", - ":IR", - ":InferIntRangeCommon", - ":InferIntRangeInterface", - ":InferTypeOpInterface", - ":Support", - ":UBDialect", - ":VectorInterfaces", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "ArithPassIncGen", - tbl_outs = [ - ( - [ - "-gen-pass-decls", - "-name=Arith", - ], - "include/mlir/Dialect/Arith/Transforms/Passes.h.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Arith/Transforms/Passes.td", - deps = [":PassBaseTdFiles"], -) - -cc_library( - name = "ArithTransforms", - srcs = glob([ - "lib/Dialect/Arith/Transforms/*.cpp", - "lib/Dialect/Arith/Transforms/*.h", - ]), - hdrs = glob([ - "include/mlir/Dialect/Arith/Transforms/*.h", - ]), - includes = ["include"], - deps = [ - ":Analysis", - ":ArithDialect", - ":ArithPassIncGen", - ":ArithUtils", - ":BufferizationDialect", - ":BufferizationTransforms", - ":FuncDialect", - ":FuncTransforms", - ":IR", - ":InferIntRangeInterface", - ":MemRefDialect", - ":Pass", - ":Support", - ":TensorDialect", - ":TransformUtils", - ":Transforms", - ":ValueBoundsOpInterface", - ":VectorDialect", - "//llvm:Support", - ], -) - -cc_library( - name = "ArithUtils", - srcs = glob([ - "lib/Dialect/Arith/Utils/*.cpp", - ]), - hdrs = ["include/mlir/Dialect/Arith/Utils/Utils.h"], - includes = ["include"], - deps = [ - ":ArithDialect", - ":ComplexDialect", - ":IR", - "//llvm:Support", - ], -) - -td_library( - name = "MathOpsTdFiles", - srcs = [ - "include/mlir/Dialect/Math/IR/MathBase.td", - "include/mlir/Dialect/Math/IR/MathOps.td", - ], - includes = ["include"], - deps = [ - ":ArithOpsTdFiles", - ":InferTypeOpInterfaceTdFiles", - ":OpBaseTdFiles", - ":SideEffectInterfacesTdFiles", - ":VectorInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "MathBaseIncGen", - tbl_outs = [ - ( - [ - "-gen-dialect-decls", - "-dialect=math", - ], - "include/mlir/Dialect/Math/IR/MathOpsDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=math", - ], - "include/mlir/Dialect/Math/IR/MathOpsDialect.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Math/IR/MathBase.td", - deps = [":MathOpsTdFiles"], -) - -gentbl_cc_library( - name = "MathOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/Math/IR/MathOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/Math/IR/MathOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Math/IR/MathOps.td", - deps = [":MathOpsTdFiles"], -) - -gentbl_cc_library( - name = "MathPassIncGen", - tbl_outs = [ - ( - [ - "-gen-pass-decls", - "-name=Math", - ], - "include/mlir/Dialect/Math/Transforms/Passes.h.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Math/Transforms/Passes.td", - deps = [":PassBaseTdFiles"], -) - -cc_library( - name = "MathDialect", - srcs = glob( - [ - "lib/Dialect/Math/IR/*.cpp", - "lib/Dialect/Math/IR/*.h", - ], - ), - hdrs = [ - "include/mlir/Dialect/Math/IR/Math.h", - ], - includes = ["include"], - deps = [ - ":ArithDialect", - ":CommonFolders", - ":ConvertToLLVMInterface", - ":IR", - ":InferTypeOpInterface", - ":MathBaseIncGen", - ":MathOpsIncGen", - ":SideEffectInterfaces", - ":UBDialect", - ":VectorInterfaces", - "//llvm:Support", - ], -) - -cc_library( - name = "MathTransforms", - srcs = glob([ - "lib/Dialect/Math/Transforms/*.cpp", - "lib/Dialect/Math/Transforms/*.h", - ]), - hdrs = glob(["include/mlir/Dialect/Math/Transforms/*.h"]), - includes = ["include"], - deps = [ - ":ArithDialect", - ":DialectUtils", - ":IR", - ":MathDialect", - ":MathPassIncGen", - ":Pass", - ":SCFDialect", - ":Transforms", - ":VectorDialect", - ":VectorUtils", - ":X86VectorDialect", - "//llvm:Support", - ], -) - -cc_library( - name = "MathToLibm", - srcs = glob([ - "lib/Conversion/MathToLibm/*.cpp", - "lib/Conversion/MathToLibm/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/MathToLibm/*.h", - ]), - includes = ["include"], - deps = [ - ":ArithDialect", - ":ConversionPassIncGen", - ":DialectUtils", - ":FuncDialect", - ":IR", - ":LLVMDialect", - ":MathDialect", - ":Pass", - ":Support", - ":Transforms", - ":VectorDialect", - ":VectorUtils", - "//llvm:Core", - "//llvm:Support", - ], -) - -td_library( - name = "MemRefOpsTdFiles", - srcs = [ - "include/mlir/Dialect/MemRef/IR/MemRefBase.td", - "include/mlir/Dialect/MemRef/IR/MemRefOps.td", - ], - includes = ["include"], - deps = [ - ":ArithOpsTdFiles", - ":CastInterfacesTdFiles", - ":ControlFlowInterfacesTdFiles", - ":CopyOpInterfaceTdFiles", - ":MemorySlotInterfacesTdFiles", - ":OpBaseTdFiles", - ":ShapedOpInterfacesTdFiles", - ":SideEffectInterfacesTdFiles", - ":ViewLikeInterfaceTdFiles", - ], -) - -gentbl_cc_library( - name = "MemRefBaseIncGen", - tbl_outs = [ - ( - [ - "-gen-dialect-decls", - "-dialect=memref", - ], - "include/mlir/Dialect/MemRef/IR/MemRefOpsDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=memref", - ], - "include/mlir/Dialect/MemRef/IR/MemRefOpsDialect.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/MemRef/IR/MemRefBase.td", - deps = [":MemRefOpsTdFiles"], -) - -gentbl_cc_library( - name = "MemRefOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/MemRef/IR/MemRefOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/MemRef/IR/MemRefOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/MemRef/IR/MemRefOps.td", - deps = [ - ":MemRefOpsTdFiles", - ], -) - -cc_library( - name = "MemRefDialect", - srcs = glob( - [ - "lib/Dialect/MemRef/IR/*.cpp", - "lib/Dialect/MemRef/IR/*.h", - ], - ), - hdrs = [ - "include/mlir/Dialect/MemRef/IR/MemRef.h", - "include/mlir/Dialect/MemRef/IR/MemRefMemorySlot.h", - "include/mlir/Dialect/MemRef/IR/ValueBoundsOpInterfaceImpl.h", - ], - includes = ["include"], - deps = [ - ":ArithDialect", - ":ArithUtils", - ":CastInterfaces", - ":ComplexDialect", - ":ControlFlowInterfaces", - ":ConvertToLLVMInterface", - ":CopyOpInterface", - ":DialectUtils", - ":IR", - ":InferTypeOpInterface", - ":MemRefBaseIncGen", - ":MemRefOpsIncGen", - ":MemorySlotInterfaces", - ":ShapedOpInterfaces", - ":Support", - ":ValueBoundsOpInterface", - ":ViewLikeInterface", - "//llvm:Support", - "//llvm:TargetParser", - ], -) - -cc_library( - name = "MemRefUtils", - srcs = glob( - [ - "lib/Dialect/MemRef/Utils/*.cpp", - ], - ), - hdrs = [ - "include/mlir/Dialect/MemRef/Utils/MemRefUtils.h", - ], - includes = ["include"], - deps = [ - ":AffineDialect", - ":ArithUtils", - ":MemRefDialect", - ":VectorDialect", - ], -) - -gentbl_cc_library( - name = "MemRefPassIncGen", - tbl_outs = [ - ( - [ - "-gen-pass-decls", - "-name=MemRef", - ], - "include/mlir/Dialect/MemRef/Transforms/Passes.h.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/MemRef/Transforms/Passes.td", - deps = [":PassBaseTdFiles"], -) - -cc_library( - name = "MemRefTransforms", - srcs = glob( - [ - "lib/Dialect/MemRef/Transforms/*.cpp", - "lib/Dialect/MemRef/Transforms/*.h", - ], - ), - hdrs = glob(["include/mlir/Dialect/MemRef/Transforms/*.h"]), - includes = ["include"], - deps = [ - ":AffineDialect", - ":AffineTransforms", - ":AffineUtils", - ":AllocationOpInterface", - ":ArithDialect", - ":ArithTransforms", - ":ArithUtils", - ":BufferizationDialect", - ":ControlFlowDialect", - ":DialectUtils", - ":FuncDialect", - ":GPUDialect", - ":IR", - ":InferTypeOpInterface", - ":LoopLikeInterface", - ":MemRefDialect", - ":MemRefPassIncGen", - ":MemRefUtils", - ":NVGPUDialect", - ":Pass", - ":RuntimeVerifiableOpInterface", - ":SCFDialect", - ":Support", - ":TensorDialect", - ":Transforms", - ":ValueBoundsOpInterface", - ":VectorDialect", - "//llvm:Support", - ], -) - -td_library( - name = "MemRefTransformOpsTdFiles", - srcs = [ - "include/mlir/Dialect/MemRef/TransformOps/MemRefTransformOps.td", - ], - includes = ["include"], - deps = [ - ":TransformDialectTdFiles", - ], -) - -gentbl_cc_library( - name = "MemRefTransformOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/MemRef/TransformOps/MemRefTransformOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/MemRef/TransformOps/MemRefTransformOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/MemRef/TransformOps/MemRefTransformOps.td", - deps = [ - ":MemRefTransformOpsTdFiles", - ], -) - -cc_library( - name = "MemRefTransformOps", - srcs = glob(["lib/Dialect/MemRef/TransformOps/*.cpp"]), - hdrs = glob(["include/mlir/Dialect/MemRef/TransformOps/*.h"]), - includes = ["include"], - deps = [ - ":AffineDialect", - ":Analysis", - ":ArithDialect", - ":IR", - ":LLVMCommonConversion", - ":LoopLikeInterface", - ":MemRefDialect", - ":MemRefTransformOpsIncGen", - ":MemRefTransforms", - ":MemRefUtils", - ":NVGPUDialect", - ":SCFDialect", - ":TransformDialect", - ":TransformUtils", - ":VectorDialect", - ":VectorTransforms", - "//llvm:Support", - ], -) - -##---------------------------------------------------------------------------## -# MLProgram dialect -##---------------------------------------------------------------------------## - -td_library( - name = "MLProgramOpsTdFiles", - srcs = [ - "include/mlir/Dialect/MLProgram/IR/MLProgramAttributes.td", - "include/mlir/Dialect/MLProgram/IR/MLProgramBase.td", - "include/mlir/Dialect/MLProgram/IR/MLProgramOps.td", - "include/mlir/Dialect/MLProgram/IR/MLProgramTypes.td", - ], - includes = ["include"], - deps = [ - ":BuiltinDialectTdFiles", - ":CallInterfacesTdFiles", - ":ControlFlowInterfacesTdFiles", - ":FunctionInterfacesTdFiles", - ":OpBaseTdFiles", - ":RegionKindInterfaceIncGen", - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "MLProgramOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/MLProgram/IR/MLProgramOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/MLProgram/IR/MLProgramOps.cpp.inc", - ), - ( - ["-gen-dialect-decls"], - "include/mlir/Dialect/MLProgram/IR/MLProgramOpsDialect.h.inc", - ), - ( - ["-gen-dialect-defs"], - "include/mlir/Dialect/MLProgram/IR/MLProgramOpsDialect.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/MLProgram/IR/MLProgramOps.td", - deps = [":MLProgramOpsTdFiles"], -) - -gentbl_cc_library( - name = "MLProgramAttributesIncGen", - tbl_outs = [ - ( - ["-gen-attrdef-decls"], - "include/mlir/Dialect/MLProgram/IR/MLProgramAttributes.h.inc", - ), - ( - ["-gen-attrdef-defs"], - "include/mlir/Dialect/MLProgram/IR/MLProgramAttributes.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/MLProgram/IR/MLProgramAttributes.td", - deps = [":MLProgramOpsTdFiles"], -) - -gentbl_cc_library( - name = "MLProgramPassIncGen", - tbl_outs = [ - ( - [ - "-gen-pass-decls", - "-name=MLProgram", - ], - "include/mlir/Dialect/MLProgram/Transforms/Passes.h.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/MLProgram/Transforms/Passes.td", - deps = [":PassBaseTdFiles"], -) - -gentbl_cc_library( - name = "MLProgramTypesIncGen", - tbl_outs = [ - ( - ["-gen-typedef-decls"], - "include/mlir/Dialect/MLProgram/IR/MLProgramTypes.h.inc", - ), - ( - ["-gen-typedef-defs"], - "include/mlir/Dialect/MLProgram/IR/MLProgramTypes.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/MLProgram/IR/MLProgramTypes.td", - deps = [":MLProgramOpsTdFiles"], -) - -cc_library( - name = "MLProgramDialect", - srcs = glob(["lib/Dialect/MLProgram/IR/*.cpp"]), - hdrs = glob(["include/mlir/Dialect/MLProgram/IR/*.h"]), - includes = ["include"], - deps = [ - ":ControlFlowInterfaces", - ":FunctionInterfaces", - ":IR", - ":MLProgramAttributesIncGen", - ":MLProgramOpsIncGen", - ":MLProgramTypesIncGen", - ":Pass", - ":Support", - "//llvm:Support", - ], -) - -cc_library( - name = "MLProgramTransforms", - srcs = glob([ - "lib/Dialect/MLProgram/Transforms/*.cpp", - ]), - hdrs = glob([ - "include/mlir/Dialect/MLProgram/Transforms/*.h", - ]), - includes = ["include"], - deps = [ - ":BufferizationDialect", - ":FuncDialect", - ":IR", - ":MLProgramDialect", - ":MLProgramPassIncGen", - ":MemRefDialect", - ":Pass", - ":TransformUtils", - ], -) - -##---------------------------------------------------------------------------## -# MPI dialect -##---------------------------------------------------------------------------## - -td_library( - name = "MPITdFiles", - srcs = [ - "include/mlir/Dialect/MPI/IR/MPI.td", - "include/mlir/Dialect/MPI/IR/MPIOps.td", - "include/mlir/Dialect/MPI/IR/MPITypes.td", - ], - includes = ["include"], - deps = [ - ":AttrTdFiles", - ":OpBaseTdFiles", - ], -) - -gentbl_cc_library( - name = "MPIIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/MPI/IR/MPI.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/MPI/IR/MPI.cpp.inc", - ), - ( - ["-gen-dialect-decls"], - "include/mlir/Dialect/MPI/IR/MPIDialect.h.inc", - ), - ( - ["-gen-dialect-defs"], - "include/mlir/Dialect/MPI/IR/MPIDialect.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/MPI/IR/MPI.td", - deps = [":MPITdFiles"], -) - -gentbl_cc_library( - name = "MPIOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/MPI/IR/MPIOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/MPI/IR/MPIOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/MPI/IR/MPIOps.td", - deps = [":MPITdFiles"], -) - -gentbl_cc_library( - name = "MPITypesIncGen", - tbl_outs = [ - ( - ["-gen-typedef-decls"], - "include/mlir/Dialect/MPI/IR/MPITypesGen.h.inc", - ), - ( - ["-gen-typedef-defs"], - "include/mlir/Dialect/MPI/IR/MPITypesGen.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/MPI/IR/MPITypes.td", - deps = [":MPITdFiles"], -) - -gentbl_cc_library( - name = "MPIAttrsIncGen", - tbl_outs = [ - ( - ["-gen-enum-decls"], - "include/mlir/Dialect/MPI/IR/MPIEnums.h.inc", - ), - ( - ["-gen-enum-defs"], - "include/mlir/Dialect/MPI/IR/MPIEnums.cpp.inc", - ), - ( - ["-gen-attrdef-decls"], - "include/mlir/Dialect/MPI/IR/MPIAttrDefs.h.inc", - ), - ( - ["-gen-attrdef-defs"], - "include/mlir/Dialect/MPI/IR/MPIAttrDefs.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/MPI/IR/MPI.td", - deps = [":MPITdFiles"], -) - -cc_library( - name = "MPIDialect", - srcs = glob(["lib/Dialect/MPI/IR/*.cpp"]), - hdrs = glob(["include/mlir/Dialect/MPI/IR/*.h"]), - includes = ["include"], - deps = [ - ":Dialect", - ":IR", - ":InferTypeOpInterface", - ":MPIAttrsIncGen", - ":MPIIncGen", - ":MPIOpsIncGen", - ":MPITypesIncGen", - ":SideEffectInterfaces", - "//llvm:Support", - ], -) - -##---------------------------------------------------------------------------## -# Allocation interfaces -##---------------------------------------------------------------------------## - -td_library( - name = "AllocationOpInterfaceTdFiles", - srcs = ["include/mlir/Dialect/Bufferization/IR/AllocationOpInterface.td"], - includes = ["include"], - deps = [":OpBaseTdFiles"], -) - -gentbl_cc_library( - name = "AllocationOpInterfaceIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/mlir/Dialect/Bufferization/IR/AllocationOpInterface.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/mlir/Dialect/Bufferization/IR/AllocationOpInterface.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Bufferization/IR/AllocationOpInterface.td", - deps = [":AllocationOpInterfaceTdFiles"], -) - -cc_library( - name = "AllocationOpInterface", - srcs = ["lib/Dialect/Bufferization/IR/AllocationOpInterface.cpp"], - hdrs = ["include/mlir/Dialect/Bufferization/IR/AllocationOpInterface.h"], - includes = ["include"], - deps = [ - ":AllocationOpInterfaceIncGen", - ":IR", - ], -) - -td_library( - name = "BufferizationOpsTdFiles", - srcs = [ - "include/mlir/Dialect/Bufferization/IR/BufferizationBase.td", - "include/mlir/Dialect/Bufferization/IR/BufferizationEnums.td", - "include/mlir/Dialect/Bufferization/IR/BufferizationOps.td", - ], - includes = ["include"], - deps = [ - ":AllocationOpInterfaceTdFiles", - ":BufferizableOpInterfaceTdFiles", - ":CopyOpInterfaceTdFiles", - ":DestinationStyleOpInterfaceTdFiles", - ":InferTypeOpInterfaceTdFiles", - ":OpBaseTdFiles", - ":SideEffectInterfacesTdFiles", - ":SubsetOpInterfaceTdFiles", - ], -) - -gentbl_cc_library( - name = "BufferizationBaseIncGen", - tbl_outs = [ - ( - [ - "-gen-dialect-decls", - "-dialect=bufferization", - ], - "include/mlir/Dialect/Bufferization/IR/BufferizationOpsDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=bufferization", - ], - "include/mlir/Dialect/Bufferization/IR/BufferizationOpsDialect.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Bufferization/IR/BufferizationBase.td", - deps = [":BufferizationOpsTdFiles"], -) - -td_library( - name = "BufferizationEnumsTdFiles", - srcs = [ - "include/mlir/Dialect/Bufferization/IR/BufferizationEnums.td", - ], - includes = ["include"], - deps = [ - ":OpBaseTdFiles", - ], -) - -gentbl_cc_library( - name = "BufferizationEnumsIncGen", - tbl_outs = [ - ( - ["-gen-enum-decls"], - "include/mlir/Dialect/Bufferization/IR/BufferizationEnums.h.inc", - ), - ( - ["-gen-enum-defs"], - "include/mlir/Dialect/Bufferization/IR/BufferizationEnums.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Bufferization/IR/BufferizationEnums.td", - deps = [":BufferizationEnumsTdFiles"], -) - -td_library( - name = "BufferizationTransformOpsTdFiles", - srcs = [ - "include/mlir/Dialect/Bufferization/TransformOps/BufferizationTransformOps.td", - ], - includes = ["include"], - deps = [ - ":BufferizationOpsTdFiles", - ":TransformDialectTdFiles", - ], -) - -gentbl_cc_library( - name = "BufferizationTransformOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/Bufferization/TransformOps/BufferizationTransformOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/Bufferization/TransformOps/BufferizationTransformOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Bufferization/TransformOps/BufferizationTransformOps.td", - deps = [ - ":BufferizationTransformOpsTdFiles", - ], -) - -cc_library( - name = "BufferizationTransformOps", - srcs = [ - "lib/Dialect/Bufferization/TransformOps/BufferizationTransformOps.cpp", - ], - hdrs = [ - "include/mlir/Dialect/Bufferization/TransformOps/BufferizationTransformOps.h", - ], - includes = ["include"], - deps = [ - ":BufferizationDialect", - ":BufferizationEnumsIncGen", - ":BufferizationTransformOpsIncGen", - ":BufferizationTransforms", - ":FunctionInterfaces", - ":IR", - ":LinalgDialect", - ":MemRefDialect", - ":Parser", - ":SideEffectInterfaces", - ":TensorDialect", - ":TransformDialect", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "BufferizationOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/Bufferization/IR/BufferizationOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/Bufferization/IR/BufferizationOps.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Bufferization/IR/BufferizationOps.td", - deps = [ - ":BufferizationOpsTdFiles", - ], -) - -cc_library( - name = "BufferizationDialect", - srcs = [ - "lib/Dialect/Bufferization/IR/BufferDeallocationOpInterface.cpp", - "lib/Dialect/Bufferization/IR/BufferizableOpInterface.cpp", - "lib/Dialect/Bufferization/IR/BufferizationDialect.cpp", - "lib/Dialect/Bufferization/IR/BufferizationOps.cpp", - "lib/Dialect/Bufferization/IR/UnstructuredControlFlow.cpp", - ], - hdrs = [ - "include/mlir/Dialect/Bufferization/IR/BufferDeallocationOpInterface.h", - "include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h", - "include/mlir/Dialect/Bufferization/IR/Bufferization.h", - "include/mlir/Dialect/Bufferization/IR/DstBufferizableOpInterfaceImpl.h", - "include/mlir/Dialect/Bufferization/IR/UnstructuredControlFlow.h", - ], - includes = ["include"], - deps = [ - ":AffineDialect", - ":AllocationOpInterface", - ":Analysis", - ":ArithDialect", - ":BufferDeallocationOpInterfaceIncGen", - ":BufferizableOpInterfaceIncGen", - ":BufferizationBaseIncGen", - ":BufferizationEnumsIncGen", - ":BufferizationOpsIncGen", - ":ControlFlowInterfaces", - ":CopyOpInterface", - ":DestinationStyleOpInterface", - ":FuncDialect", - ":FunctionInterfaces", - ":IR", - ":InferTypeOpInterface", - ":MemRefDialect", - ":SparseTensorDialect", - ":SubsetOpInterface", - ":Support", - ":TensorDialect", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "BufferizationPassIncGen", - tbl_outs = [ - ( - [ - "-gen-pass-decls", - "-name=Bufferization", - ], - "include/mlir/Dialect/Bufferization/Transforms/Passes.h.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Bufferization/Transforms/Passes.td", - deps = [":PassBaseTdFiles"], -) - -cc_library( - name = "BufferizationTransforms", - srcs = glob( - [ - "lib/Dialect/Bufferization/Transforms/*.cpp", - "lib/Dialect/Bufferization/Transforms/*.h", - ], - ), - hdrs = glob(["include/mlir/Dialect/Bufferization/Transforms/*.h"]), - includes = ["include"], - deps = [ - ":AllocationOpInterface", - ":Analysis", - ":ArithDialect", - ":BufferizationDialect", - ":BufferizationEnumsIncGen", - ":BufferizationPassIncGen", - ":ControlFlowDialect", - ":ControlFlowInterfaces", - ":FuncDialect", - ":IR", - ":LoopLikeInterface", - ":MemRefDialect", - ":MemRefUtils", - ":Pass", - ":SCFDialect", - ":SideEffectInterfaces", - ":SubsetOpInterface", - ":Support", - ":TensorDialect", - ":Transforms", - ":ViewLikeInterface", - "//llvm:Support", - ], -) - -cc_library( - name = "BufferizationToMemRef", - srcs = [ - "lib/Conversion/BufferizationToMemRef/BufferizationToMemRef.cpp", - ], - hdrs = [ - "include/mlir/Conversion/BufferizationToMemRef/BufferizationToMemRef.h", - ], - includes = ["include"], - deps = [ - ":ArithDialect", - ":BufferizationDialect", - ":BufferizationTransforms", - ":ConversionPassIncGen", - ":FuncDialect", - ":IR", - ":MemRefDialect", - ":Pass", - ":SCFDialect", - ":Support", - ":Transforms", - ], -) - -cc_library( - name = "BufferizationPipelines", - srcs = glob(["lib/Dialect/Bufferization/Pipelines/*.cpp"]), - hdrs = ["include/mlir/Dialect/Bufferization/Pipelines/Passes.h"], - includes = ["include"], - deps = [ - ":BufferizationDialect", - ":BufferizationToMemRef", - ":BufferizationTransforms", - ":FuncDialect", - ":MemRefTransforms", - ":Pass", - ":Transforms", - ], -) - -td_library( - name = "DLTIDialectTdFiles", - srcs = [ - "include/mlir/Dialect/DLTI/DLTI.td", - "include/mlir/Dialect/DLTI/DLTIBase.td", - ], - includes = ["include"], - deps = [":OpBaseTdFiles"], -) - -gentbl_cc_library( - name = "DLTIBaseIncGen", - tbl_outs = [ - ( - [ - "-gen-dialect-decls", - "-dialect=dlti", - ], - "include/mlir/Dialect/DLTI/DLTIDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=dlti", - ], - "include/mlir/Dialect/DLTI/DLTIDialect.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/DLTI/DLTIBase.td", - deps = [":OpBaseTdFiles"], -) - -cc_library( - name = "DLTIDialect", - srcs = glob(["lib/Dialect/DLTI/*.cpp"]), - hdrs = glob(["include/mlir/Dialect/DLTI/*.h"]), - includes = ["include"], - deps = [ - ":DLTIBaseIncGen", - ":DataLayoutInterfaces", - ":IR", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "ReducerIncGen", - tbl_outs = [ - ( - [ - "-gen-pass-decls", - "-name=Reducer", - ], - "include/mlir/Reducer/Passes.h.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Reducer/Passes.td", - deps = [ - ":PassBaseTdFiles", - ":ReducerTdFiles", - ], -) - -cc_library( - name = "Reducer", - srcs = glob(["lib/Reducer/*.cpp"]), - hdrs = glob(["include/mlir/Reducer/*.h"]), - includes = ["include"], - deps = [ - ":IR", - ":Pass", - ":ReducerIncGen", - ":Rewrite", - ":Support", - ":TransformUtils", - "//llvm:Support", - ], -) - -cc_library( - name = "MlirReduceLib", - srcs = ["lib/Tools/mlir-reduce/MlirReduceMain.cpp"], - hdrs = [ - "include/mlir/Tools/ParseUtilities.h", - "include/mlir/Tools/mlir-reduce/MlirReduceMain.h", - ], - includes = ["include"], - deps = [ - ":IR", - ":Parser", - ":Pass", - ":Reducer", - ":Rewrite", - ":Support", - "//llvm:Support", - ], -) - -cc_binary( - name = "mlir-reduce", - srcs = ["tools/mlir-reduce/mlir-reduce.cpp"], - includes = ["include"], - local_defines = ["MLIR_INCLUDE_TESTS"], - stamp = 0, - deps = [ - ":AllPassesAndDialects", - ":IR", - ":MlirReduceLib", - "//llvm:Support", - "//mlir/test:TestDialect", - ], -) - -cc_library( - name = "PDLLODS", - srcs = glob( - [ - "lib/Tools/PDLL/ODS/*.cpp", - "lib/Tools/PDLL/ODS/*.h", - ], - ), - hdrs = glob(["include/mlir/Tools/PDLL/ODS/*.h"]), - includes = ["include"], - deps = [ - ":Support", - "//llvm:Support", - "//llvm:TargetParser", - ], -) - -cc_library( - name = "PDLLAST", - srcs = glob( - [ - "lib/Tools/PDLL/AST/*.cpp", - "lib/Tools/PDLL/AST/*.h", - ], - ), - hdrs = glob(["include/mlir/Tools/PDLL/AST/*.h"]), - includes = ["include"], - deps = [ - ":Support", - "//llvm:Support", - "//llvm:TargetParser", - ], -) - -cc_library( - name = "PDLLCodeGen", - srcs = glob( - [ - "lib/Tools/PDLL/CodeGen/*.cpp", - "lib/Tools/PDLL/CodeGen/*.h", - ], - ), - hdrs = glob(["include/mlir/Tools/PDLL/CodeGen/*.h"]), - includes = ["include"], - deps = [ - ":AsmParser", - ":IR", - ":PDLDialect", - ":PDLLAST", - ":PDLLODS", - ":Support", - "//llvm:Support", - ], -) - -cc_library( - name = "PDLLParser", - srcs = glob( - [ - "lib/Tools/PDLL/Parser/*.cpp", - "lib/Tools/PDLL/Parser/*.h", - ], - ), - hdrs = glob(["include/mlir/Tools/PDLL/Parser/*.h"]), - includes = ["include"], - deps = [ - ":PDLLAST", - ":PDLLODS", - ":Support", - ":TableGen", - "//llvm:Support", - "//llvm:TableGen", - "//llvm:TargetParser", - ], -) - -cc_binary( - name = "mlir-pdll", - srcs = [ - "tools/mlir-pdll/mlir-pdll.cpp", - ], - deps = [ - ":IR", - ":PDLLAST", - ":PDLLCodeGen", - ":PDLLODS", - ":PDLLParser", - ":Support", - "//llvm:Support", - "//llvm:config", - ], -) - -cc_binary( - name = "mlir-pdll-lsp-server", - srcs = ["tools/mlir-pdll-lsp-server/mlir-pdll-lsp-server.cpp"], - includes = ["include"], - deps = [ - ":MlirPdllLspServerLib", - ":Support", - ], -) - -td_library( - name = "DialectConversionPdllFiles", - srcs = ["include/mlir/Transforms/DialectConversion.pdll"], - includes = ["include"], -) - -td_library( - name = "UBDialectTdFiles", - srcs = [ - "include/mlir/Dialect/UB/IR/UBOps.td", - "include/mlir/Dialect/UB/IR/UBOpsInterfaces.td", - ], - includes = ["include"], - deps = [ - ":OpBaseTdFiles", - ":SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "UBOpsInterfacesIncGen", - tbl_outs = [ - ( - ["--gen-attr-interface-decls"], - "include/mlir/Dialect/UB/IR/UBOpsInterfaces.h.inc", - ), - ( - ["--gen-attr-interface-defs"], - "include/mlir/Dialect/UB/IR/UBOpsInterfaces.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/UB/IR/UBOpsInterfaces.td", - deps = [":UBDialectTdFiles"], -) - -gentbl_cc_library( - name = "UBOpsIncGen", - tbl_outs = [ - ( - [ - "-gen-dialect-decls", - "-dialect=ub", - ], - "include/mlir/Dialect/UB/IR/UBOpsDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=ub", - ], - "include/mlir/Dialect/UB/IR/UBOpsDialect.cpp.inc", - ), - ( - ["-gen-op-decls"], - "include/mlir/Dialect/UB/IR/UBOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/UB/IR/UBOps.cpp.inc", - ), - ( - ["--gen-attrdef-decls"], - "include/mlir/Dialect/UB/IR/UBOpsAttributes.h.inc", - ), - ( - ["--gen-attrdef-defs"], - "include/mlir/Dialect/UB/IR/UBOpsAttributes.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/UB/IR/UBOps.td", - deps = [":UBDialectTdFiles"], -) - -cc_library( - name = "UBDialect", - srcs = [ - "include/mlir/Transforms/InliningUtils.h", - "lib/Dialect/UB/IR/UBOps.cpp", - ], - hdrs = ["include/mlir/Dialect/UB/IR/UBOps.h"], - includes = ["include"], - deps = [ - ":ConvertToLLVMInterface", - ":IR", - ":SideEffectInterfaces", - ":UBOpsIncGen", - ":UBOpsInterfacesIncGen", - "//llvm:Support", - ], -) - -cc_library( - name = "UBToLLVM", - srcs = glob([ - "lib/Conversion/UBToLLVM/*.cpp", - "lib/Conversion/UBToLLVM/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/UBToLLVM/*.h", - ]), - includes = ["include"], - deps = [ - ":ConversionPassIncGen", - ":ConvertToLLVMInterface", - ":IR", - ":LLVMCommonConversion", - ":LLVMDialect", - ":Pass", - ":UBDialect", - ], -) - -cc_library( - name = "UBToSPIRV", - srcs = glob([ - "lib/Conversion/UBToSPIRV/*.cpp", - "lib/Conversion/UBToSPIRV/*.h", - ]), - hdrs = glob([ - "include/mlir/Conversion/UBToSPIRV/*.h", - ]), - includes = ["include"], - deps = [ - ":ConversionPassIncGen", - ":Pass", - ":SPIRVConversion", - ":SPIRVDialect", - ":UBDialect", - "//llvm:Core", - ], -) - -cc_library( - name = "VCIXDialect", - srcs = ["lib/Dialect/LLVMIR/IR/VCIXDialect.cpp"], - hdrs = ["include/mlir/Dialect/LLVMIR/VCIXDialect.h"], - includes = ["include"], - deps = [ - ":GPUDialect", - ":IR", - ":LLVMDialect", - ":SideEffectInterfaces", - ":VCIXOpsIncGen", - "//llvm:AsmParser", - "//llvm:Core", - "//llvm:Support", - ], -) - -td_library( - name = "VCIXTdFiles", - srcs = ["include/mlir/Dialect/LLVMIR/VCIXOps.td"], - includes = ["include"], - deps = [ - ":LLVMOpsTdFiles", - ":OpBaseTdFiles", - ], -) - -gentbl_cc_library( - name = "VCIXOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/mlir/Dialect/LLVMIR/VCIXOps.h.inc", - ), - ( - ["-gen-op-defs"], - "include/mlir/Dialect/LLVMIR/VCIXOps.cpp.inc", - ), - ( - [ - "-gen-dialect-decls", - "-dialect=vcix", - ], - "include/mlir/Dialect/LLVMIR/VCIXOpsDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=vcix", - ], - "include/mlir/Dialect/LLVMIR/VCIXOpsDialect.cpp.inc", - ), - ( - [ - "-gen-attrdef-decls", - "-attrdefs-dialect=vcix", - ], - "include/mlir/Dialect/LLVMIR/VCIXOpsAttributes.h.inc", - ), - ( - [ - "-gen-attrdef-defs", - "-attrdefs-dialect=vcix", - ], - "include/mlir/Dialect/LLVMIR/VCIXOpsAttributes.cpp.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/LLVMIR/VCIXOps.td", - deps = [":VCIXTdFiles"], -) - -cc_library( - name = "VCIXToLLVMIRTranslation", - srcs = glob(["lib/Target/LLVMIR/Dialect/VCIX/*.cpp"]), - hdrs = glob(["include/mlir/Target/LLVMIR/Dialect/VCIX/*.h"]), - includes = ["include"], - deps = [ - ":IR", - ":ToLLVMIRTranslation", - ":VCIXConversionIncGen", - ":VCIXDialect", - "//llvm:Core", - "//llvm:Support", - ], -) - -gentbl_cc_library( - name = "VCIXConversionIncGen", - tbl_outs = [ - ( - ["-gen-llvmir-conversions"], - "include/mlir/Dialect/LLVMIR/VCIXConversions.inc", - ), - ], - tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/LLVMIR/VCIXOps.td", - deps = [":VCIXTdFiles"], -) diff --git a/utils/bazel/llvm-project-overlay/mlir/build_defs.bzl b/utils/bazel/llvm-project-overlay/mlir/build_defs.bzl deleted file mode 100644 index fe39dbe21e3390..00000000000000 --- a/utils/bazel/llvm-project-overlay/mlir/build_defs.bzl +++ /dev/null @@ -1,71 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -"""Rules and macros for MLIR""" - -def if_cuda_available(if_true, if_false = []): - return select({ - # CUDA is not yet supported. - "//conditions:default": if_false, - }) - -def _cc_headers_only_impl(ctx): - return CcInfo(compilation_context = ctx.attr.src[CcInfo].compilation_context) - -cc_headers_only = rule( - implementation = _cc_headers_only_impl, - attrs = { - "src": attr.label( - mandatory = True, - providers = [CcInfo], - ), - }, - doc = "Provides the headers from 'src' without linking anything.", - provides = [CcInfo], -) - -def mlir_c_api_cc_library( - name, - srcs = [], - hdrs = [], - deps = [], - header_deps = [], - capi_deps = [], - **kwargs): - """Macro that generates three targets for MLIR C API libraries. - - * A standard cc_library target ("Name"), - * A header-only cc_library target ("NameHeaders") - * An implementation cc_library target tagged `alwayslink` suitable for - inclusion in a shared library built with cc_binary() ("NameObjects"). - - In order to avoid duplicate symbols, it is important that - mlir_c_api_cc_library targets only depend on other mlir_c_api_cc_library - targets via the "capi_deps" parameter. This makes it so that "FooObjects" - depend on "BarObjects" targets and "Foo" targets depend on "Bar" targets. - Don't cross the streams. - """ - capi_header_deps = ["%sHeaders" % d for d in capi_deps] - capi_object_deps = ["%sObjects" % d for d in capi_deps] - native.cc_library( - name = name, - srcs = srcs, - hdrs = hdrs, - deps = deps + capi_deps + header_deps, - **kwargs - ) - native.cc_library( - name = name + "Headers", - hdrs = hdrs, - deps = header_deps + capi_header_deps, - **kwargs - ) - native.cc_library( - name = name + "Objects", - srcs = srcs, - hdrs = hdrs, - deps = deps + capi_object_deps + capi_header_deps + header_deps, - alwayslink = True, - **kwargs - ) diff --git a/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch1/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch1/BUILD.bazel deleted file mode 100644 index 2d4e1b5d6986eb..00000000000000 --- a/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch1/BUILD.bazel +++ /dev/null @@ -1,18 +0,0 @@ -# Description: -# MLIR Tutorial -licenses(["notice"]) - -package(default_visibility = ["//visibility:public"]) - -cc_binary( - name = "toyc-ch1", - srcs = [ - "parser/AST.cpp", - "toyc.cpp", - ] + glob(["include/toy/*"]), - includes = ["include/"], - deps = [ - "//llvm:Support", - "//mlir:Support", - ], -) diff --git a/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch2/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch2/BUILD.bazel deleted file mode 100644 index 321b8d7cb232e8..00000000000000 --- a/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch2/BUILD.bazel +++ /dev/null @@ -1,68 +0,0 @@ -# Description: -# MLIR Tutorial - -load("//mlir:tblgen.bzl", "gentbl_cc_library", "td_library") - -licenses(["notice"]) - -package(default_visibility = ["//visibility:public"]) - -td_library( - name = "ToyOpsTdFiles", - srcs = [ - "include/toy/Ops.td", - ], - includes = ["include"], - deps = [ - "//mlir:FunctionInterfacesTdFiles", - "//mlir:OpBaseTdFiles", - "//mlir:SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "ToyOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/toy/Ops.h.inc", - ), - ( - ["-gen-op-defs"], - "include/toy/Ops.cpp.inc", - ), - ( - ["-gen-dialect-decls"], - "include/toy/Dialect.h.inc", - ), - ( - ["-gen-dialect-defs"], - "include/toy/Dialect.cpp.inc", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "include/toy/Ops.td", - deps = [":ToyOpsTdFiles"], -) - -cc_binary( - name = "toyc-ch2", - srcs = [ - "mlir/Dialect.cpp", - "mlir/MLIRGen.cpp", - "parser/AST.cpp", - "toyc.cpp", - ] + glob(["include/toy/*.h"]), - includes = ["include/"], - deps = [ - ":ToyOpsIncGen", - "//llvm:Support", - "//mlir:Analysis", - "//mlir:BytecodeReader", - "//mlir:FunctionInterfaces", - "//mlir:IR", - "//mlir:Parser", - "//mlir:SideEffectInterfaces", - "//mlir:Support", - ], -) diff --git a/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch3/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch3/BUILD.bazel deleted file mode 100644 index b776bedab46f96..00000000000000 --- a/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch3/BUILD.bazel +++ /dev/null @@ -1,86 +0,0 @@ -# Description: -# MLIR Tutorial - -load("//mlir:tblgen.bzl", "gentbl_cc_library", "td_library") - -licenses(["notice"]) - -package(default_visibility = ["//visibility:public"]) - -td_library( - name = "ToyOpsTdFiles", - srcs = [ - "include/toy/Ops.td", - ], - includes = ["include"], - deps = [ - "//mlir:FunctionInterfacesTdFiles", - "//mlir:OpBaseTdFiles", - "//mlir:SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "ToyOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/toy/Ops.h.inc", - ), - ( - ["-gen-op-defs"], - "include/toy/Ops.cpp.inc", - ), - ( - ["-gen-dialect-decls"], - "include/toy/Dialect.h.inc", - ), - ( - ["-gen-dialect-defs"], - "include/toy/Dialect.cpp.inc", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "include/toy/Ops.td", - deps = [":ToyOpsTdFiles"], -) - -gentbl_cc_library( - name = "ToyCombineIncGen", - strip_include_prefix = "mlir", - tbl_outs = [ - ( - ["-gen-rewriters"], - "mlir/ToyCombine.inc", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/ToyCombine.td", - deps = [":ToyOpsTdFiles"], -) - -cc_binary( - name = "toyc-ch3", - srcs = [ - "mlir/Dialect.cpp", - "mlir/MLIRGen.cpp", - "mlir/ToyCombine.cpp", - "parser/AST.cpp", - "toyc.cpp", - ] + glob(["include/toy/*.h"]), - includes = ["include/"], - deps = [ - ":ToyCombineIncGen", - ":ToyOpsIncGen", - "//llvm:Support", - "//mlir:Analysis", - "//mlir:BytecodeReader", - "//mlir:FunctionInterfaces", - "//mlir:IR", - "//mlir:Parser", - "//mlir:Pass", - "//mlir:SideEffectInterfaces", - "//mlir:Support", - "//mlir:Transforms", - ], -) diff --git a/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch4/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch4/BUILD.bazel deleted file mode 100644 index b8c5a59cd14d52..00000000000000 --- a/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch4/BUILD.bazel +++ /dev/null @@ -1,111 +0,0 @@ -# Description: -# MLIR Tutorial - -load("//mlir:tblgen.bzl", "gentbl_cc_library", "td_library") - -licenses(["notice"]) - -package(default_visibility = ["//visibility:public"]) - -td_library( - name = "ToyOpsTdFiles", - srcs = [ - "include/toy/Ops.td", - "include/toy/ShapeInferenceInterface.td", - ], - includes = ["include"], - deps = [ - "//mlir:CallInterfacesTdFiles", - "//mlir:CastInterfacesTdFiles", - "//mlir:FunctionInterfacesTdFiles", - "//mlir:OpBaseTdFiles", - "//mlir:SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "ToyInterfacesIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/toy/ShapeInferenceOpInterfaces.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/toy/ShapeInferenceOpInterfaces.cpp.inc", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "include/toy/ShapeInferenceInterface.td", - deps = [":ToyOpsTdFiles"], -) - -gentbl_cc_library( - name = "ToyOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/toy/Ops.h.inc", - ), - ( - ["-gen-op-defs"], - "include/toy/Ops.cpp.inc", - ), - ( - ["-gen-dialect-decls"], - "include/toy/Dialect.h.inc", - ), - ( - ["-gen-dialect-defs"], - "include/toy/Dialect.cpp.inc", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "include/toy/Ops.td", - deps = [":ToyOpsTdFiles"], -) - -gentbl_cc_library( - name = "ToyCombineIncGen", - strip_include_prefix = "mlir", - tbl_outs = [ - ( - ["-gen-rewriters"], - "mlir/ToyCombine.inc", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/ToyCombine.td", - deps = [":ToyOpsTdFiles"], -) - -cc_binary( - name = "toyc-ch4", - srcs = [ - "mlir/Dialect.cpp", - "mlir/MLIRGen.cpp", - "mlir/ShapeInferencePass.cpp", - "mlir/ToyCombine.cpp", - "parser/AST.cpp", - "toyc.cpp", - ] + glob(["include/toy/*.h"]), - includes = ["include/"], - deps = [ - ":ToyCombineIncGen", - ":ToyInterfacesIncGen", - ":ToyOpsIncGen", - "//llvm:Support", - "//mlir:Analysis", - "//mlir:BytecodeReader", - "//mlir:CallOpInterfaces", - "//mlir:CastInterfaces", - "//mlir:FunctionInterfaces", - "//mlir:IR", - "//mlir:Parser", - "//mlir:Pass", - "//mlir:SideEffectInterfaces", - "//mlir:Support", - "//mlir:TransformUtils", - "//mlir:Transforms", - ], -) diff --git a/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch5/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch5/BUILD.bazel deleted file mode 100644 index ce48e249489d35..00000000000000 --- a/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch5/BUILD.bazel +++ /dev/null @@ -1,118 +0,0 @@ -# Description: -# MLIR Tutorial - -load("//mlir:tblgen.bzl", "gentbl_cc_library", "td_library") - -licenses(["notice"]) - -package(default_visibility = ["//visibility:public"]) - -td_library( - name = "ToyOpsTdFiles", - srcs = [ - "include/toy/Ops.td", - "include/toy/ShapeInferenceInterface.td", - ], - includes = ["include"], - deps = [ - "//mlir:CallInterfacesTdFiles", - "//mlir:CastInterfacesTdFiles", - "//mlir:FunctionInterfacesTdFiles", - "//mlir:OpBaseTdFiles", - "//mlir:SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "ToyInterfacesIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/toy/ShapeInferenceOpInterfaces.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/toy/ShapeInferenceOpInterfaces.cpp.inc", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "include/toy/ShapeInferenceInterface.td", - deps = [":ToyOpsTdFiles"], -) - -gentbl_cc_library( - name = "ToyOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/toy/Ops.h.inc", - ), - ( - ["-gen-op-defs"], - "include/toy/Ops.cpp.inc", - ), - ( - ["-gen-dialect-decls"], - "include/toy/Dialect.h.inc", - ), - ( - ["-gen-dialect-defs"], - "include/toy/Dialect.cpp.inc", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "include/toy/Ops.td", - deps = [":ToyOpsTdFiles"], -) - -gentbl_cc_library( - name = "ToyCombineIncGen", - strip_include_prefix = "mlir", - tbl_outs = [ - ( - ["-gen-rewriters"], - "mlir/ToyCombine.inc", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/ToyCombine.td", - deps = [":ToyOpsTdFiles"], -) - -cc_binary( - name = "toyc-ch5", - srcs = [ - "mlir/Dialect.cpp", - "mlir/LowerToAffineLoops.cpp", - "mlir/MLIRGen.cpp", - "mlir/ShapeInferencePass.cpp", - "mlir/ToyCombine.cpp", - "parser/AST.cpp", - "toyc.cpp", - ] + glob(["include/toy/*.h"]), - includes = ["include/"], - deps = [ - ":ToyCombineIncGen", - ":ToyInterfacesIncGen", - ":ToyOpsIncGen", - "//llvm:Support", - "//mlir:AffineDialect", - "//mlir:AffineTransforms", - "//mlir:AllPassesAndDialects", - "//mlir:Analysis", - "//mlir:ArithDialect", - "//mlir:BytecodeReader", - "//mlir:CastInterfaces", - "//mlir:FuncDialect", - "//mlir:FuncExtensions", - "//mlir:FunctionInterfaces", - "//mlir:IR", - "//mlir:MemRefDialect", - "//mlir:Parser", - "//mlir:Pass", - "//mlir:SideEffectInterfaces", - "//mlir:Support", - "//mlir:TransformUtils", - "//mlir:Transforms", - ], -) diff --git a/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch6/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch6/BUILD.bazel deleted file mode 100644 index 286c080656456e..00000000000000 --- a/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch6/BUILD.bazel +++ /dev/null @@ -1,136 +0,0 @@ -# Description: -# MLIR Tutorial - -load("//mlir:tblgen.bzl", "gentbl_cc_library", "td_library") - -licenses(["notice"]) - -package(default_visibility = ["//visibility:public"]) - -td_library( - name = "ToyOpsTdFiles", - srcs = [ - "include/toy/Ops.td", - "include/toy/ShapeInferenceInterface.td", - ], - includes = ["include"], - deps = [ - "//mlir:CallInterfacesTdFiles", - "//mlir:CastInterfacesTdFiles", - "//mlir:FunctionInterfacesTdFiles", - "//mlir:OpBaseTdFiles", - "//mlir:SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "ToyInterfacesIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/toy/ShapeInferenceOpInterfaces.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/toy/ShapeInferenceOpInterfaces.cpp.inc", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "include/toy/ShapeInferenceInterface.td", - deps = [":ToyOpsTdFiles"], -) - -gentbl_cc_library( - name = "ToyOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/toy/Ops.h.inc", - ), - ( - ["-gen-op-defs"], - "include/toy/Ops.cpp.inc", - ), - ( - ["-gen-dialect-decls"], - "include/toy/Dialect.h.inc", - ), - ( - ["-gen-dialect-defs"], - "include/toy/Dialect.cpp.inc", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "include/toy/Ops.td", - deps = [":ToyOpsTdFiles"], -) - -gentbl_cc_library( - name = "ToyCombineIncGen", - strip_include_prefix = "mlir", - tbl_outs = [ - ( - ["-gen-rewriters"], - "mlir/ToyCombine.inc", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/ToyCombine.td", - deps = [":ToyOpsTdFiles"], -) - -cc_binary( - name = "toyc-ch6", - srcs = [ - "mlir/Dialect.cpp", - "mlir/LowerToAffineLoops.cpp", - "mlir/LowerToLLVM.cpp", - "mlir/MLIRGen.cpp", - "mlir/ShapeInferencePass.cpp", - "mlir/ToyCombine.cpp", - "parser/AST.cpp", - "toyc.cpp", - ] + glob(["include/toy/*.h"]), - includes = ["include/"], - deps = [ - ":ToyCombineIncGen", - ":ToyInterfacesIncGen", - ":ToyOpsIncGen", - "//llvm:Core", - "//llvm:OrcJIT", - "//llvm:Support", - "//mlir:AffineDialect", - "//mlir:AffineToStandard", - "//mlir:AffineTransforms", - "//mlir:AllPassesAndDialects", - "//mlir:Analysis", - "//mlir:ArithDialect", - "//mlir:ArithToLLVM", - "//mlir:BuiltinToLLVMIRTranslation", - "//mlir:BytecodeReader", - "//mlir:CastInterfaces", - "//mlir:ControlFlowToLLVM", - "//mlir:ExecutionEngine", - "//mlir:ExecutionEngineUtils", - "//mlir:FuncDialect", - "//mlir:FuncExtensions", - "//mlir:FuncToLLVM", - "//mlir:FunctionInterfaces", - "//mlir:IR", - "//mlir:LLVMCommonConversion", - "//mlir:LLVMDialect", - "//mlir:LLVMIRTransforms", - "//mlir:LLVMToLLVMIRTranslation", - "//mlir:MemRefDialect", - "//mlir:MemRefToLLVM", - "//mlir:Parser", - "//mlir:Pass", - "//mlir:SCFDialect", - "//mlir:SCFToControlFlow", - "//mlir:SideEffectInterfaces", - "//mlir:Support", - "//mlir:ToLLVMIRTranslation", - "//mlir:TransformUtils", - "//mlir:Transforms", - ], -) diff --git a/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch7/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch7/BUILD.bazel deleted file mode 100644 index f4037cab03f6a8..00000000000000 --- a/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch7/BUILD.bazel +++ /dev/null @@ -1,136 +0,0 @@ -# Description: -# MLIR Tutorial - -load("//mlir:tblgen.bzl", "gentbl_cc_library", "td_library") - -licenses(["notice"]) - -package(default_visibility = ["//visibility:public"]) - -td_library( - name = "ToyOpsTdFiles", - srcs = [ - "include/toy/Ops.td", - "include/toy/ShapeInferenceInterface.td", - ], - includes = ["include"], - deps = [ - "//mlir:CallInterfacesTdFiles", - "//mlir:CastInterfacesTdFiles", - "//mlir:FunctionInterfacesTdFiles", - "//mlir:OpBaseTdFiles", - "//mlir:SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "ToyInterfacesIncGen", - tbl_outs = [ - ( - ["-gen-op-interface-decls"], - "include/toy/ShapeInferenceOpInterfaces.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "include/toy/ShapeInferenceOpInterfaces.cpp.inc", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "include/toy/ShapeInferenceInterface.td", - deps = [":ToyOpsTdFiles"], -) - -gentbl_cc_library( - name = "ToyOpsIncGen", - tbl_outs = [ - ( - ["-gen-op-decls"], - "include/toy/Ops.h.inc", - ), - ( - ["-gen-op-defs"], - "include/toy/Ops.cpp.inc", - ), - ( - ["-gen-dialect-decls"], - "include/toy/Dialect.h.inc", - ), - ( - ["-gen-dialect-defs"], - "include/toy/Dialect.cpp.inc", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "include/toy/Ops.td", - deps = [":ToyOpsTdFiles"], -) - -gentbl_cc_library( - name = "ToyCombineIncGen", - strip_include_prefix = "mlir", - tbl_outs = [ - ( - ["-gen-rewriters"], - "mlir/ToyCombine.inc", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/ToyCombine.td", - deps = [":ToyOpsTdFiles"], -) - -cc_binary( - name = "toyc-ch7", - srcs = [ - "mlir/Dialect.cpp", - "mlir/LowerToAffineLoops.cpp", - "mlir/LowerToLLVM.cpp", - "mlir/MLIRGen.cpp", - "mlir/ShapeInferencePass.cpp", - "mlir/ToyCombine.cpp", - "parser/AST.cpp", - "toyc.cpp", - ] + glob(["include/toy/*.h"]), - includes = ["include/"], - deps = [ - ":ToyCombineIncGen", - ":ToyInterfacesIncGen", - ":ToyOpsIncGen", - "//llvm:Core", - "//llvm:OrcJIT", - "//llvm:Support", - "//mlir:AffineDialect", - "//mlir:AffineToStandard", - "//mlir:AffineTransforms", - "//mlir:AllPassesAndDialects", - "//mlir:Analysis", - "//mlir:ArithDialect", - "//mlir:ArithToLLVM", - "//mlir:BuiltinToLLVMIRTranslation", - "//mlir:BytecodeReader", - "//mlir:CastInterfaces", - "//mlir:ControlFlowToLLVM", - "//mlir:ExecutionEngine", - "//mlir:ExecutionEngineUtils", - "//mlir:FuncDialect", - "//mlir:FuncExtensions", - "//mlir:FuncToLLVM", - "//mlir:FunctionInterfaces", - "//mlir:IR", - "//mlir:LLVMCommonConversion", - "//mlir:LLVMDialect", - "//mlir:LLVMIRTransforms", - "//mlir:LLVMToLLVMIRTranslation", - "//mlir:MemRefDialect", - "//mlir:MemRefToLLVM", - "//mlir:Parser", - "//mlir:Pass", - "//mlir:SCFDialect", - "//mlir:SCFToControlFlow", - "//mlir:SideEffectInterfaces", - "//mlir:Support", - "//mlir:ToLLVMIRTranslation", - "//mlir:TransformUtils", - "//mlir:Transforms", - ], -) diff --git a/utils/bazel/llvm-project-overlay/mlir/linalggen.bzl b/utils/bazel/llvm-project-overlay/mlir/linalggen.bzl deleted file mode 100644 index d893471e6249fc..00000000000000 --- a/utils/bazel/llvm-project-overlay/mlir/linalggen.bzl +++ /dev/null @@ -1,42 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -"""BUILD extensions for MLIR linalg generation.""" - -def genlinalg(name, linalggen, src, linalg_outs): - """genlinalg() generates code from a tc spec file. - - Args: - name: The name of the build rule for use in dependencies. - linalggen: The binary used to produce the output. - src: The tc spec file. - linalg_outs: A list of tuples (opts, out), where each opts is a string of - options passed to linalggen, and the out is the corresponding output file - produced. - """ - - for (opts, out) in linalg_outs: - # All arguments to generate the output except output destination. - base_args = [ - "$(location %s)" % linalggen, - "%s" % opts, - "$(location %s)" % src, - ] - rule_suffix = "_".join(opts.replace("-", "_").replace("=", "_").split(" ")) - - # Rule to generate code using generated shell script. - native.genrule( - name = "%s_%s_genrule" % (name, rule_suffix), - srcs = [src], - outs = [out], - tools = [linalggen], - cmd = (" ".join(base_args)), - ) - - hdrs = [f for (opts, f) in linalg_outs] - native.cc_library( - name = name, - hdrs = hdrs, - textual_hdrs = hdrs, - ) diff --git a/utils/bazel/llvm-project-overlay/mlir/python/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/python/BUILD.bazel deleted file mode 100644 index 0c3ed22e736018..00000000000000 --- a/utils/bazel/llvm-project-overlay/mlir/python/BUILD.bazel +++ /dev/null @@ -1,1542 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# Description: -# Python bindings for MLIR. -# -# We define separate filegroups for files in different directories so -# that downstream users can mirror the tree in their own py_library() rules. - -load("//mlir:tblgen.bzl", "gentbl_filegroup", "td_library") - -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) - -##---------------------------------------------------------------------------## -# Core IR modules. -##---------------------------------------------------------------------------## - -filegroup( - name = "DialectCorePyFiles", - srcs = [ - "mlir/dialects/_ods_common.py", - ], -) - -filegroup( - name = "ExecutionEnginePyFiles", - srcs = [ - "mlir/execution_engine.py", - ], -) - -filegroup( - name = "ExecutionEnginePyIFiles", - srcs = [ - "mlir/_mlir_libs/_mlirExecutionEngine.pyi", - ], -) - -filegroup( - name = "IRPyFiles", - srcs = [ - "mlir/ir.py", - ], -) - -filegroup( - name = "ExtrasPyFiles", - srcs = glob([ - "mlir/extras/*.py", - ]), -) - -filegroup( - name = "IRPyIFiles", - srcs = [ - "mlir/_mlir_libs/_mlir/__init__.pyi", - "mlir/_mlir_libs/_mlir/ir.pyi", - ], -) - -filegroup( - name = "MlirLibsPyFiles", - srcs = [ - "mlir/_mlir_libs/__init__.py", - ], -) - -filegroup( - name = "PassManagerPyFiles", - srcs = [ - "mlir/passmanager.py", - ], -) - -filegroup( - name = "PassManagerPyIFiles", - srcs = [ - "mlir/_mlir_libs/_mlir/passmanager.pyi", - ], -) - -filegroup( - name = "RuntimePyFiles", - srcs = glob([ - "mlir/runtime/*.py", - ]), -) - -##---------------------------------------------------------------------------## -# Affine dialect. -##---------------------------------------------------------------------------## - -td_library( - name = "AffineOpsPyTdFiles", - srcs = [ - "mlir/dialects/AffineOps.td", - ], - deps = [ - "//mlir:AffineOpsTdFiles", - "//mlir:FunctionInterfacesTdFiles", - "//mlir:OpBaseTdFiles", - ], -) - -gentbl_filegroup( - name = "AffineOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=affine", - ], - "mlir/dialects/_affine_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/AffineOps.td", - deps = [ - ":AffineOpsPyTdFiles", - ], -) - -filegroup( - name = "AffineOpsPyFiles", - srcs = [ - "mlir/dialects/affine.py", - ":AffineOpsPyGen", - ], -) - -##---------------------------------------------------------------------------## -# Builtin dialect. -##---------------------------------------------------------------------------## - -td_library( - name = "BuiltinOpsPyTdFiles", - srcs = [ - "mlir/dialects/BuiltinOps.td", - ], - deps = [ - "//mlir:BuiltinDialectTdFiles", - "//mlir:FunctionInterfacesTdFiles", - "//mlir:OpBaseTdFiles", - ], -) - -gentbl_filegroup( - name = "BuiltinOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=builtin", - ], - "mlir/dialects/_builtin_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/BuiltinOps.td", - deps = [ - ":BuiltinOpsPyTdFiles", - ], -) - -filegroup( - name = "BuiltinOpsPyFiles", - srcs = [ - "mlir/dialects/builtin.py", - ":BuiltinOpsPyGen", - ], -) - -##---------------------------------------------------------------------------## -# AMDGPU dialect. -##---------------------------------------------------------------------------## - -td_library( - name = "AMDGPUOpsPyTdFiles", - srcs = [], - includes = ["../include"], - deps = [ - "//mlir:AMDGPUTdFiles", - "//mlir:OpBaseTdFiles", - ], -) - -gentbl_filegroup( - name = "AMDGPUOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-enum-bindings", - "-bind-dialect=amdgpu", - ], - "mlir/dialects/_amdgpu_enum_gen.py", - ), - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=amdgpu", - ], - "mlir/dialects/_amdgpu_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/AMDGPUOps.td", - deps = [ - ":AMDGPUOpsPyTdFiles", - ], -) - -filegroup( - name = "AMDGPUOpsPyFiles", - srcs = [ - "mlir/dialects/amdgpu.py", - ":AMDGPUOpsPyGen", - ], -) - -##---------------------------------------------------------------------------## -# Linalg dialect. -##---------------------------------------------------------------------------## - -td_library( - name = "LinalgOpsPyTdFiles", - srcs = [ - "mlir/dialects/LinalgOps.td", - ], - deps = [ - "//mlir:LinalgOpsTdFiles", - "//mlir:LinalgStructuredOpsTdFiles", - "//mlir:OpBaseTdFiles", - ], -) - -gentbl_filegroup( - name = "LinalgOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-enum-bindings", - "-bind-dialect=linalg", - ], - "mlir/dialects/_linalg_enum_gen.py", - ), - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=linalg", - ], - "mlir/dialects/_linalg_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/LinalgOps.td", - deps = [ - ":LinalgOpsPyTdFiles", - ], -) - -filegroup( - name = "LinalgOpsPyFiles", - srcs = [ - ":LinalgOpsPyGen", - ], -) - -filegroup( - name = "LinalgOpsPackagePyFiles", - srcs = glob(["mlir/dialects/linalg/*.py"]), -) - -filegroup( - name = "LinalgOpsPackageOpDSLPyFiles", - srcs = glob(["mlir/dialects/linalg/opdsl/*.py"]), -) - -filegroup( - name = "LinalgOpsPackageOpDSLLangPyFiles", - srcs = glob(["mlir/dialects/linalg/opdsl/lang/*.py"]), -) - -filegroup( - name = "LinalgOpsPackageOpDSLOpsPyFiles", - srcs = glob(["mlir/dialects/linalg/opdsl/ops/*.py"]), -) - -filegroup( - name = "LinalgOpsPackagePassesPyFiles", - srcs = glob(["mlir/dialects/linalg/passes/*.py"]), -) - -##---------------------------------------------------------------------------## -# LLVM dialect. -##---------------------------------------------------------------------------## - -gentbl_filegroup( - name = "LLVMOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-enum-bindings", - "-bind-dialect=llvm", - ], - "mlir/dialects/_llvm_enum_gen.py", - ), - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=llvm", - ], - "mlir/dialects/_llvm_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/LLVMOps.td", - deps = [ - "//mlir:LLVMOpsTdFiles", - "//mlir:OpBaseTdFiles", - ], -) - -filegroup( - name = "LLVMOpsPyFiles", - srcs = [ - "mlir/dialects/llvm.py", - ":LLVMOpsPyGen", - ], -) - -##---------------------------------------------------------------------------## -# Arith dialect. -##---------------------------------------------------------------------------## - -gentbl_filegroup( - name = "ArithOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-enum-bindings", - "-bind-dialect=arith", - ], - "mlir/dialects/_arith_enum_gen.py", - ), - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=arith", - ], - "mlir/dialects/_arith_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/ArithOps.td", - deps = [ - "//mlir:ArithOpsTdFiles", - "//mlir:OpBaseTdFiles", - ], -) - -filegroup( - name = "ArithOpsPyFiles", - srcs = [ - "mlir/dialects/arith.py", - ":ArithOpsPyGen", - ], -) - -##---------------------------------------------------------------------------## -# Bufferization dialect. -##---------------------------------------------------------------------------## - -td_library( - name = "BufferizationOpsPyTdFiles", - srcs = [], - includes = ["../include"], - deps = [ - "//mlir:BufferizableOpInterfaceTdFiles", - "//mlir:BufferizationEnumsTdFiles", - "//mlir:BufferizationOpsTdFiles", - "//mlir:OpBaseTdFiles", - ], -) - -gentbl_filegroup( - name = "BufferizationEnumPyGen", - tbl_outs = [ - ( - [ - "-gen-python-enum-bindings", - "-bind-dialect=bufferization", - ], - "mlir/dialects/_bufferization_enum_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/BufferizationEnums.td", - deps = [ - ":BufferizationOpsPyTdFiles", - ], -) - -gentbl_filegroup( - name = "BufferizationOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=bufferization", - ], - "mlir/dialects/_bufferization_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/BufferizationOps.td", - deps = [ - ":BufferizationOpsPyTdFiles", - ], -) - -filegroup( - name = "BufferizationOpsPyFiles", - srcs = [ - "mlir/dialects/bufferization.py", - ":BufferizationEnumPyGen", - ":BufferizationOpsPyGen", - ], -) - -##---------------------------------------------------------------------------## -# Complex dialect. -##---------------------------------------------------------------------------## - -gentbl_filegroup( - name = "ComplexOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=complex", - ], - "mlir/dialects/_complex_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/ComplexOps.td", - deps = [ - "//mlir:ComplexOpsTdFiles", - "//mlir:OpBaseTdFiles", - ], -) - -filegroup( - name = "ComplexOpsPyFiles", - srcs = [ - "mlir/dialects/complex.py", - ":ComplexOpsPyGen", - ], -) - -##---------------------------------------------------------------------------## -# ControlFlow dialect. -##---------------------------------------------------------------------------## - -gentbl_filegroup( - name = "ControlFlowOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=cf", - ], - "mlir/dialects/_cf_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/ControlFlowOps.td", - deps = [ - "//mlir:ControlFlowOpsTdFiles", - "//mlir:OpBaseTdFiles", - ], -) - -filegroup( - name = "ControlFlowOpsPyFiles", - srcs = [ - "mlir/dialects/cf.py", - ":ControlFlowOpsPyGen", - ], -) - -##---------------------------------------------------------------------------## -# Math dialect. -##---------------------------------------------------------------------------## - -gentbl_filegroup( - name = "MathOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=math", - ], - "mlir/dialects/_math_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/MathOps.td", - deps = [ - "//mlir:MathOpsTdFiles", - "//mlir:OpBaseTdFiles", - ], -) - -filegroup( - name = "MathOpsPyFiles", - srcs = [ - "mlir/dialects/math.py", - ":MathOpsPyGen", - ], -) - -##---------------------------------------------------------------------------## -# MemRef dialect. -##---------------------------------------------------------------------------## - -gentbl_filegroup( - name = "MemRefOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=memref", - ], - "mlir/dialects/_memref_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/MemRefOps.td", - deps = [ - "//mlir:MemRefOpsTdFiles", - "//mlir:OpBaseTdFiles", - ], -) - -filegroup( - name = "MemRefOpsPyFiles", - srcs = [ - "mlir/dialects/memref.py", - ":MemRefOpsPyGen", - ], -) - -##---------------------------------------------------------------------------## -# MLProgram dialect. -##---------------------------------------------------------------------------## - -gentbl_filegroup( - name = "MLProgramOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=ml_program", - ], - "mlir/dialects/_ml_program_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/MLProgramOps.td", - deps = [ - "//mlir:MLProgramOpsTdFiles", - "//mlir:OpBaseTdFiles", - ], -) - -filegroup( - name = "MLProgramOpsPyFiles", - srcs = [ - "mlir/dialects/ml_program.py", - ":MLProgramOpsPyGen", - ], -) - -##---------------------------------------------------------------------------## -# OpenMP dialect. -##---------------------------------------------------------------------------## - -gentbl_filegroup( - name = "OpenMPOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=omp", - ], - "mlir/dialects/_omp_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/OpenMPOps.td", - deps = [ - "//mlir:OpBaseTdFiles", - "//mlir:OpenMPOpsTdFiles", - ], -) - -filegroup( - name = "OpenMPOpsPyFiles", - srcs = [ - "mlir/dialects/openmp.py", - ":OpenMPOpsPyGen", - ], -) - -##---------------------------------------------------------------------------## -# PDL dialect. -##---------------------------------------------------------------------------## - -gentbl_filegroup( - name = "PDLPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=pdl", - ], - "mlir/dialects/_pdl_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/PDLOps.td", - deps = [ - "//mlir:OpBaseTdFiles", - "//mlir:PDLDialectTdFiles", - ], -) - -filegroup( - name = "PDLPyIFiles", - srcs = [ - "mlir/_mlir_libs/_mlir/dialects/pdl.pyi", - ], -) - -filegroup( - name = "PDLPyFiles", - srcs = [ - "mlir/dialects/pdl.py", - ":PDLPyGen", - ], -) - -##---------------------------------------------------------------------------## -# PythonTest dialect. -##---------------------------------------------------------------------------## - -gentbl_filegroup( - name = "PythonTestPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=python_test", - ], - "mlir/dialects/_python_test_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "//mlir/test/python:python_test_ops.td", - deps = [ - "//mlir:InferTypeOpInterfaceTdFiles", - "//mlir:OpBaseTdFiles", - ], -) - -filegroup( - name = "PythonTestPyFiles", - srcs = [ - "mlir/dialects/python_test.py", - ":PythonTestPyGen", - ], -) - -##---------------------------------------------------------------------------## -# Quant dialect. -##---------------------------------------------------------------------------## - -filegroup( - name = "QuantPyIFiles", - srcs = [ - "mlir/_mlir_libs/_mlir/dialects/quant.pyi", - ], -) - -filegroup( - name = "QuantPyFiles", - srcs = [ - "mlir/dialects/quant.py", - ], -) - -##---------------------------------------------------------------------------## -# GPU dialect. -##---------------------------------------------------------------------------## - -td_library( - name = "GPUOpsPyTdFiles", - srcs = [], - includes = ["../include"], - deps = [ - "//mlir:GPUOpsTdFiles", - "//mlir:OpBaseTdFiles", - ], -) - -gentbl_filegroup( - name = "GPUOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-enum-bindings", - "-bind-dialect=gpu", - ], - "mlir/dialects/_gpu_enum_gen.py", - ), - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=gpu", - ], - "mlir/dialects/_gpu_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/GPUOps.td", - deps = [ - ":GPUOpsPyTdFiles", - ], -) - -filegroup( - name = "GPUOpsPyFiles", - srcs = [ - ":GPUOpsPyGen", - ], -) - -filegroup( - name = "GPUOpsPackagePyFiles", - srcs = glob(["mlir/dialects/gpu/*.py"]), -) - -filegroup( - name = "GPUOpsPackagePassesPyFiles", - srcs = glob(["mlir/dialects/gpu/passes/*.py"]), -) - -##---------------------------------------------------------------------------## -# NVGPU dialect. -##---------------------------------------------------------------------------## - -td_library( - name = "NVGPUOpsPyTdFiles", - srcs = [], - includes = ["../include"], - deps = [ - "//mlir:NVGPUTdFiles", - "//mlir:OpBaseTdFiles", - ], -) - -gentbl_filegroup( - name = "NVGPUOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-enum-bindings", - "-bind-dialect=nvgpu", - ], - "mlir/dialects/_nvgpu_enum_gen.py", - ), - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=nvgpu", - ], - "mlir/dialects/_nvgpu_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/NVGPUOps.td", - deps = [ - ":NVGPUOpsPyTdFiles", - ], -) - -filegroup( - name = "NVGPUOpsPyFiles", - srcs = [ - "mlir/dialects/nvgpu.py", - ":NVGPUOpsPyGen", - ], -) - -##---------------------------------------------------------------------------## -# NVVM dialect. -##---------------------------------------------------------------------------## - -td_library( - name = "NVVMOpsPyTdFiles", - srcs = [], - includes = ["../include"], - deps = [ - "//mlir:NVVMOpsTdFiles", - "//mlir:OpBaseTdFiles", - ], -) - -gentbl_filegroup( - name = "NVVMOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-enum-bindings", - "-bind-dialect=nvvm", - ], - "mlir/dialects/_nvvm_enum_gen.py", - ), - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=nvvm", - ], - "mlir/dialects/_nvvm_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/NVVMOps.td", - deps = [ - ":NVVMOpsPyTdFiles", - ], -) - -filegroup( - name = "NVVMOpsPyFiles", - srcs = [ - "mlir/dialects/nvvm.py", - ":NVVMOpsPyGen", - ], -) - -##---------------------------------------------------------------------------## -# ROCDL dialect. -##---------------------------------------------------------------------------## - -td_library( - name = "ROCDLOpsPyTdFiles", - srcs = [], - includes = ["../include"], - deps = [ - "//mlir:OpBaseTdFiles", - "//mlir:ROCDLOpsTdFiles", - ], -) - -gentbl_filegroup( - name = "ROCDLOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=rocdl", - ], - "mlir/dialects/_rocdl_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/ROCDLOps.td", - deps = [ - ":ROCDLOpsPyTdFiles", - ], -) - -filegroup( - name = "ROCDLOpsPyFiles", - srcs = [ - "mlir/dialects/rocdl.py", - ":ROCDLOpsPyGen", - ], -) - -##---------------------------------------------------------------------------## -# SCF dialect. -##---------------------------------------------------------------------------## - -gentbl_filegroup( - name = "SCFPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=scf", - ], - "mlir/dialects/_scf_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/SCFOps.td", - deps = [ - "//mlir:OpBaseTdFiles", - "//mlir:SCFTdFiles", - ], -) - -filegroup( - name = "SCFPyFiles", - srcs = [ - "mlir/dialects/scf.py", - ":SCFPyGen", - ], -) - -##---------------------------------------------------------------------------## -# Shape dialect. -##---------------------------------------------------------------------------## - -gentbl_filegroup( - name = "ShapeOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=shape", - ], - "mlir/dialects/_shape_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/ShapeOps.td", - deps = [ - "//mlir:OpBaseTdFiles", - "//mlir:ShapeOpsTdFiles", - ], -) - -filegroup( - name = "ShapeOpsPyFiles", - srcs = [ - "mlir/dialects/shape.py", - ":ShapeOpsPyGen", - ], -) - -##---------------------------------------------------------------------------## -# Func dialect. -##---------------------------------------------------------------------------## - -td_library( - name = "FuncPyTdFiles", - srcs = [ - ], - deps = [ - "//mlir:FuncTdFiles", - "//mlir:OpBaseTdFiles", - ], -) - -gentbl_filegroup( - name = "FuncPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=func", - ], - "mlir/dialects/_func_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/FuncOps.td", - deps = [ - "//mlir:FuncTdFiles", - "//mlir:OpBaseTdFiles", - ], -) - -filegroup( - name = "FuncPyFiles", - srcs = [ - "mlir/dialects/func.py", - ":FuncPyGen", - ], -) - -##---------------------------------------------------------------------------## -# SparseTensor dialect. -##---------------------------------------------------------------------------## - -td_library( - name = "SparseTensorOpsPyTdFiles", - srcs = [ - ], - deps = [ - "//mlir:OpBaseTdFiles", - "//mlir:SparseTensorTdFiles", - ], -) - -gentbl_filegroup( - name = "SparseTensorEnumPyGen", - tbl_outs = [ - ( - [ - "-gen-python-enum-bindings", - "-bind-dialect=sparse_tensor", - ], - "mlir/dialects/_sparse_tensor_enum_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/SparseTensorAttrDefs.td", - deps = [ - ":SparseTensorOpsPyTdFiles", - ], -) - -gentbl_filegroup( - name = "SparseTensorOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=sparse_tensor", - ], - "mlir/dialects/_sparse_tensor_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/SparseTensorOps.td", - deps = [ - ":SparseTensorOpsPyTdFiles", - ], -) - -filegroup( - name = "SparseTensorOpsPyFiles", - srcs = [ - "mlir/dialects/sparse_tensor.py", - ":SparseTensorEnumPyGen", - ":SparseTensorOpsPyGen", - ], -) - -##---------------------------------------------------------------------------## -# SPIRV dialect. -##---------------------------------------------------------------------------## - -gentbl_filegroup( - name = "SPIRVOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=spirv", - ], - "mlir/dialects/_spirv_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/SPIRVOps.td", - deps = [ - "//mlir:OpBaseTdFiles", - "//mlir:SPIRVOpsTdFiles", - ], -) - -filegroup( - name = "SPIRVOpsPyFiles", - srcs = [ - "mlir/dialects/spirv.py", - ":SPIRVOpsPyGen", - ], -) - -##---------------------------------------------------------------------------## -# Tensor dialect. -##---------------------------------------------------------------------------## - -td_library( - name = "TensorOpsPyTdFiles", - srcs = [ - ], - deps = [ - "//mlir:OpBaseTdFiles", - "//mlir:TensorOpsTdFiles", - ], -) - -gentbl_filegroup( - name = "TensorOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=tensor", - ], - "mlir/dialects/_tensor_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/TensorOps.td", - deps = [ - ":TensorOpsPyTdFiles", - ], -) - -filegroup( - name = "TensorOpsPyFiles", - srcs = [ - "mlir/dialects/tensor.py", - ":TensorOpsPyGen", - ], -) - -##---------------------------------------------------------------------------## -# Tosa dialect. -##---------------------------------------------------------------------------## - -gentbl_filegroup( - name = "TosaOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=tosa", - ], - "mlir/dialects/_tosa_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/TosaOps.td", - deps = [ - "//mlir:OpBaseTdFiles", - "//mlir:TosaDialectTdFiles", - ], -) - -filegroup( - name = "TosaOpsPyFiles", - srcs = [ - "mlir/dialects/tosa.py", - ":TosaOpsPyGen", - ], -) - -##---------------------------------------------------------------------------## -# Transform dialect and extensions. -##---------------------------------------------------------------------------## - -gentbl_filegroup( - name = "TransformEnumPyGen", - tbl_outs = [ - ( - [ - "-gen-python-enum-bindings", - "-bind-dialect=transform", - ], - "mlir/dialects/_transform_enum_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/TransformAttrs.td", - deps = [ - "//mlir:CallInterfacesTdFiles", - "//mlir:FunctionInterfacesTdFiles", - "//mlir:OpBaseTdFiles", - "//mlir:TransformDialectTdFiles", - ], -) - -gentbl_filegroup( - name = "TransformOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=transform", - ], - "mlir/dialects/_transform_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/TransformOps.td", - deps = [ - "//mlir:CallInterfacesTdFiles", - "//mlir:FunctionInterfacesTdFiles", - "//mlir:OpBaseTdFiles", - "//mlir:TransformDialectTdFiles", - ], -) - -gentbl_filegroup( - name = "BufferizationTransformOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=transform", - "-dialect-extension=bufferization_transform", - ], - "mlir/dialects/_bufferization_transform_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/BufferizationTransformOps.td", - deps = [ - "//mlir:BufferizationTransformOpsTdFiles", - ], -) - -gentbl_filegroup( - name = "GPUTransformOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=transform", - "-dialect-extension=gpu_transform", - ], - "mlir/dialects/_gpu_transform_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/GPUTransformOps.td", - deps = [ - "//mlir:CallInterfacesTdFiles", - "//mlir:FunctionInterfacesTdFiles", - "//mlir:GPUTransformOpsTdFiles", - "//mlir:OpBaseTdFiles", - "//mlir:TransformDialectTdFiles", - ], -) - -gentbl_filegroup( - name = "StructureTransformEnumPyGen", - tbl_outs = [ - ( - [ - "-gen-python-enum-bindings", - "-bind-dialect=transform", - ], - "mlir/dialects/_structured_transform_enum_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/LinalgStructuredTransformEnums.td", - deps = [ - "//mlir:CallInterfacesTdFiles", - "//mlir:FunctionInterfacesTdFiles", - "//mlir:LinalgTransformOpsTdFiles", - "//mlir:OpBaseTdFiles", - "//mlir:TransformDialectTdFiles", - ], -) - -gentbl_filegroup( - name = "StructuredTransformOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=transform", - "-dialect-extension=structured_transform", - ], - "mlir/dialects/_structured_transform_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/LinalgStructuredTransformOps.td", - deps = [ - "//mlir:CallInterfacesTdFiles", - "//mlir:FunctionInterfacesTdFiles", - "//mlir:LinalgTransformOpsTdFiles", - "//mlir:OpBaseTdFiles", - "//mlir:TransformDialectTdFiles", - ], -) - -gentbl_filegroup( - name = "LoopTransformOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=transform", - "-dialect-extension=loop_transform", - ], - "mlir/dialects/_loop_transform_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/SCFLoopTransformOps.td", - deps = [ - "//mlir:CallInterfacesTdFiles", - "//mlir:FunctionInterfacesTdFiles", - "//mlir:OpBaseTdFiles", - "//mlir:SCFTransformOpsTdFiles", - "//mlir:TransformDialectTdFiles", - ], -) - -gentbl_filegroup( - name = "MemRefTransformOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=transform", - "-dialect-extension=memref_transform", - ], - "mlir/dialects/_memref_transform_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/MemRefTransformOps.td", - deps = [ - "//mlir:MemRefTransformOpsTdFiles", - ], -) - -gentbl_filegroup( - name = "NVGPUTransformOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=transform", - "-dialect-extension=nvgpu_transform", - ], - "mlir/dialects/_nvgpu_transform_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/NVGPUTransformOps.td", - deps = [ - "//mlir:NVGPUTransformOpsTdFiles", - ], -) - -gentbl_filegroup( - name = "PDLTransformOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=transform", - "-dialect-extension=transform_pdl_extension", - ], - "mlir/dialects/_transform_pdl_extension_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/TransformPDLExtensionOps.td", - deps = [ - "//mlir:CallInterfacesTdFiles", - "//mlir:FunctionInterfacesTdFiles", - "//mlir:OpBaseTdFiles", - "//mlir:TransformDialectTdFiles", - "//mlir:TransformPDLExtensionTdFiles", - ], -) - -gentbl_filegroup( - name = "SparseTensorTransformOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=transform", - "-dialect-extension=sparse_tensor_transform", - ], - "mlir/dialects/_sparse_tensor_transform_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/SparseTensorTransformOps.td", - deps = [ - "//mlir:SparseTensorTransformOpsTdFiles", - ], -) - -gentbl_filegroup( - name = "TensorTransformOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=transform", - "-dialect-extension=tensor_transform", - ], - "mlir/dialects/_tensor_transform_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/TensorTransformOps.td", - deps = [ - "//mlir:TensorTransformOpsTdFiles", - ], -) - -gentbl_filegroup( - name = "VectorTransformEnumPyGen", - tbl_outs = [ - ( - [ - "-gen-python-enum-bindings", - "-bind-dialect=transform", - ], - "mlir/dialects/_vector_transform_enum_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/VectorTransformsBase.td", - deps = [ - "//mlir:OpBaseTdFiles", - "//mlir:TransformDialectTdFiles", - "//mlir:VectorTransformOpsTdFiles", - ], -) - -gentbl_filegroup( - name = "VectorTransformOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=transform", - "-dialect-extension=vector_transform", - ], - "mlir/dialects/_vector_transform_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/VectorTransformOps.td", - deps = [ - "//mlir:OpBaseTdFiles", - "//mlir:TransformDialectTdFiles", - "//mlir:VectorTransformOpsTdFiles", - ], -) - -filegroup( - name = "TransformOpsPyFiles", - srcs = [ - ":BufferizationTransformOpsPyGen", - ":GPUTransformOpsPyGen", - ":LoopTransformOpsPyGen", - ":MemRefTransformOpsPyGen", - ":NVGPUTransformOpsPyGen", - ":PDLTransformOpsPyGen", - ":SparseTensorTransformOpsPyGen", - ":StructureTransformEnumPyGen", - ":StructuredTransformOpsPyGen", - ":TensorTransformOpsPyGen", - ":TransformEnumPyGen", - ":TransformOpsPyGen", - ":VectorTransformEnumPyGen", - ":VectorTransformOpsPyGen", - ], -) - -filegroup( - name = "TransformOpsPackagePyFiles", - srcs = glob(["mlir/dialects/transform/*.py"]), -) - -filegroup( - name = "TransformExtrasPackagePyFiles", - srcs = glob(["mlir/dialects/transform/extras/*.py"]), -) - -filegroup( - name = "TransformInterpreterPackagePyFiles", - srcs = glob(["mlir/dialects/transform/interpreter/*.py"]), -) - -##---------------------------------------------------------------------------## -# Vector dialect. -##---------------------------------------------------------------------------## - -gentbl_filegroup( - name = "VectorOpsPyGen", - tbl_outs = [ - ( - [ - "-gen-python-op-bindings", - "-bind-dialect=vector", - ], - "mlir/dialects/_vector_ops_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/VectorOps.td", - deps = [ - "//mlir:ArithOpsTdFiles", - "//mlir:OpBaseTdFiles", - "//mlir:VectorOpsTdFiles", - ], -) - -gentbl_filegroup( - name = "VectorAttributesPyGen", - tbl_outs = [ - ( - [ - "-gen-python-enum-bindings", - "-bind-dialect=vector", - ], - "mlir/dialects/_vector_enum_gen.py", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "mlir/dialects/VectorAttributes.td", - deps = [ - "//mlir:ArithOpsTdFiles", - "//mlir:OpBaseTdFiles", - "//mlir:VectorOpsTdFiles", - ], -) - -filegroup( - name = "VectorOpsPyFiles", - srcs = [ - "mlir/dialects/vector.py", - ":VectorAttributesPyGen", - ":VectorOpsPyGen", - ], -) diff --git a/utils/bazel/llvm-project-overlay/mlir/tblgen.bzl b/utils/bazel/llvm-project-overlay/mlir/tblgen.bzl deleted file mode 100644 index fdf6a57107ac34..00000000000000 --- a/utils/bazel/llvm-project-overlay/mlir/tblgen.bzl +++ /dev/null @@ -1,434 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -"""BUILD extensions for MLIR table generation.""" - -load("@bazel_skylib//lib:paths.bzl", "paths") - -TdInfo = provider( - "Holds TableGen files and the dependencies and include paths necessary to" + - " build them.", - fields = { - "transitive_sources": "td files transitively used by this rule.", - "transitive_includes": ( - "include arguments to add to the final TableGen invocation. These" + - " are the absolute directory paths that will be added with '-I'." - ), - }, -) - -# For now we allow anything that provides DefaultInfo to just forward its files. -# In particular, this allows filegroups to be used. This is mostly to ease -# transition. In the future, the TdInfo provider will be required. -# TODO(gcmn): Switch to enforcing TdInfo provider. -def _get_dep_transitive_srcs(dep): - """Extract TdInfo.transitive_sources, falling back to DefaultInfo.files.""" - if TdInfo in dep: - return dep[TdInfo].transitive_sources - return dep[DefaultInfo].files - -def _get_dep_transitive_includes(dep): - """Extract TdInfo.transitive_includes, falling back to an empty depset().""" - if TdInfo in dep: - return dep[TdInfo].transitive_includes - return depset() - -def _get_transitive_srcs(srcs, deps): - """Obtain the source files for a target and its transitive dependencies. - - Args: - srcs: a list of source files - deps: a list of targets that are direct dependencies - Returns: - a collection of the transitive sources - """ - return depset( - direct = srcs, - transitive = [_get_dep_transitive_srcs(dep) for dep in deps], - ) - -def _get_transitive_includes(includes, deps): - """Obtain the includes paths for a target and its transitive dependencies. - - Args: - includes: a list of include paths - deps: a list of targets that are direct dependencies - Returns: - a collection of the transitive include paths - """ - return depset( - direct = includes, - transitive = [_get_dep_transitive_includes(dep) for dep in deps], - ) - -def _prefix_roots(ctx, includes): - """Map the given includes to be relative to all root directories. - - This will expand them to be relative to all the root directories available - in the execution environment for ctx.run (bin and genfiles in addition to - the normal source root) - """ - prefixed_includes = [] - for include in includes: - prefixed_includes.append(include) - prefixed_includes.append(paths.join(ctx.genfiles_dir.path, include)) - prefixed_includes.append(paths.join(ctx.bin_dir.path, include)) - return prefixed_includes - -def _resolve_includes(ctx, includes): - """Resolves include paths to paths relative to the execution root. - - Relative paths are interpreted as relative to the current label's package. - Absolute paths are interpreted as relative to the current label's workspace - root.""" - package = ctx.label.package - workspace_root = ctx.label.workspace_root - workspace_root = workspace_root if workspace_root else "." - resolved_includes = [] - for include in includes: - if paths.is_absolute(include): - include = include.lstrip("/") - else: - include = paths.join(package, include) - include = paths.join(workspace_root, include) - resolved_includes.extend(_prefix_roots(ctx, [include])) - return resolved_includes - -def _td_library_impl(ctx): - trans_srcs = _get_transitive_srcs(ctx.files.srcs, ctx.attr.deps) - trans_includes = _get_transitive_includes( - _resolve_includes(ctx, ctx.attr.includes), - ctx.attr.deps, - ) - - # Note that we include srcs in runfiles. A td_library doesn't compile to - # produce an output: it's just a depset of source files and include - # directories. So if it is needed for execution of some rule (likely - # something running tblgen as a test action), the files needed are the same - # as the source files. - # Note: not using merge_all, as that is not available in Bazel 4.0 - runfiles = ctx.runfiles(ctx.files.srcs) - for src in ctx.attr.srcs: - runfiles = runfiles.merge(src[DefaultInfo].default_runfiles) - for dep in ctx.attr.deps: - runfiles = runfiles.merge(dep[DefaultInfo].default_runfiles) - - return [ - DefaultInfo(files = trans_srcs, runfiles = runfiles), - TdInfo( - transitive_sources = trans_srcs, - transitive_includes = trans_includes, - ), - ] - -td_library = rule( - _td_library_impl, - attrs = { - "srcs": attr.label_list(allow_files = True), - "includes": attr.string_list( - doc = "Include paths to be added to the final TableGen tool" + - " invocation. Relative paths are interpreted as relative to" + - " the current label's package. Absolute paths are" + - " interpreted as relative to the current label's workspace", - ), - # TODO(gcmn): limit to TdInfo providers. - "deps": attr.label_list( - doc = "Dependencies providing TableGen source files and include" + - " paths.", - ), - }, -) - -def _gentbl_rule_impl(ctx): - td_file = ctx.file.td_file - - trans_srcs = _get_transitive_srcs( - ctx.files.td_srcs + [td_file], - ctx.attr.deps, - ) - - # Note that the td_file.dirname is already relative to the execution root, - # i.e. may contain an `external/` prefix if the current - # workspace is not the main workspace. Therefore it is not included in the - # _resolve_includes call that prepends this prefix. - trans_includes = _get_transitive_includes( - _resolve_includes(ctx, ctx.attr.includes + ["/"]) + - _prefix_roots(ctx, [td_file.dirname]), - ctx.attr.deps, - ) - - args = ctx.actions.args() - args.add_all(ctx.attr.opts) - args.add(td_file) - args.add_all(trans_includes, before_each = "-I") - - args.add("-o", ctx.outputs.out.path) - - ctx.actions.run( - outputs = [ctx.outputs.out], - inputs = trans_srcs, - executable = ctx.executable.tblgen, - arguments = [args], - # Make sure action_env settings are honored so the env is the same as - # when the tool was built. Important for locating shared libraries with - # a custom LD_LIBRARY_PATH. - use_default_shell_env = True, - mnemonic = "TdGenerate", - ) - - return [DefaultInfo()] - -gentbl_rule = rule( - _gentbl_rule_impl, - doc = "Generates tabular code from a table definition file.", - attrs = { - "tblgen": attr.label( - doc = "The TableGen executable with which to generate `out`.", - executable = True, - cfg = "exec", - ), - "td_file": attr.label( - doc = "The TableGen file to run through `tblgen`.", - allow_single_file = True, - mandatory = True, - ), - "td_srcs": attr.label_list( - doc = "Additional TableGen files included by `td_file`. It is not" + - " necessary to list td_file here (though not an error).", - allow_files = True, - ), - # TODO(gcmn): limit to TdInfo providers. - "deps": attr.label_list( - doc = "Dependencies providing TableGen source files and include" + - " paths.", - ), - "out": attr.output( - doc = "The output file for the TableGen invocation.", - mandatory = True, - ), - "opts": attr.string_list( - doc = "Additional command line options to add to the TableGen" + - " invocation. For include arguments, prefer to use" + - " `includes`.", - ), - "includes": attr.string_list( - doc = "Include paths to be added to the final TableGen tool" + - " invocation. Relative paths are interpreted as relative to" + - " the current label's package. Absolute paths are" + - " interpreted as relative to the current label's workspace." + - " Includes are applied from all roots available in the" + - " execution environment (source, genfiles, and bin" + - " directories). The execution roots themselves and the " + - " directory of td_file are always added.", - ), - }, -) - -# TODO(gcmn): Figure out how to reduce duplication with _gentbl_rule_impl -def _gentbl_test_impl(ctx): - td_file = ctx.file.td_file - - # Note that the td_file.dirname is already relative to the execution root, - # i.e. may contain an `external/` prefix if the current - # workspace is not the main workspace. Therefore it is not included in the - # _resolve_includes call that prepends this prefix. - trans_includes = _get_transitive_includes( - _resolve_includes(ctx, ctx.attr.includes + ["/"]) + - _prefix_roots(ctx, [td_file.dirname]), - ctx.attr.deps, - ) - - test_args = [ctx.executable.tblgen.short_path] - test_args.extend(ctx.attr.opts) - test_args.append(td_file.path) - test_args.extend(["-I " + include for include in trans_includes.to_list()]) - - test_args.extend(["-o", "/dev/null"]) - - ctx.actions.write( - ctx.outputs.executable, - content = " ".join(test_args), - is_executable = True, - ) - - # Note: not using merge_all, as that is not available in Bazel 4.0 - runfiles = ctx.runfiles( - files = [ctx.executable.tblgen], - transitive_files = _get_transitive_srcs( - ctx.files.td_srcs + [td_file], - ctx.attr.deps, - ), - ) - for src in ctx.attr.td_srcs: - runfiles = runfiles.merge(src[DefaultInfo].default_runfiles) - for dep in ctx.attr.deps: - runfiles = runfiles.merge(dep[DefaultInfo].default_runfiles) - - return [ - coverage_common.instrumented_files_info( - ctx, - source_attributes = ["td_file", "td_srcs"], - dependency_attributes = ["tblgen", "deps"], - ), - DefaultInfo(runfiles = runfiles), - ] - -gentbl_test = rule( - _gentbl_test_impl, - test = True, - doc = "A shell test that tests the given TablegGen invocation. Note" + - " that unlike gentbl_rule, this builds and invokes `tblgen` in the" + - " target configuration. Takes all the same arguments as gentbl_rule" + - " except for `out` (as it does not generate any output)", - attrs = { - "tblgen": attr.label( - doc = "The TableGen executable run in the shell command. Note" + - " that this is built in the target configuration.", - executable = True, - cfg = "target", - ), - "td_file": attr.label( - doc = "See gentbl_rule.td_file", - allow_single_file = True, - mandatory = True, - ), - "td_srcs": attr.label_list( - doc = "See gentbl_rule.td_srcs", - allow_files = True, - ), - "deps": attr.label_list(doc = "See gentbl_rule.deps"), - "opts": attr.string_list(doc = "See gentbl_rule.opts"), - "includes": attr.string_list(doc = "See gentbl_rule.includes"), - }, -) - -def gentbl_filegroup( - name, - tblgen, - td_file, - tbl_outs, - td_srcs = [], - includes = [], - deps = [], - test = False, - skip_opts = [], - **kwargs): - """Create multiple TableGen generated files using the same tool and input. - - All generated outputs are bundled in a file group with the given name. - - Args: - name: The name of the generated filegroup rule for use in dependencies. - tblgen: The binary used to produce the output. - td_file: The primary table definitions file. - tbl_outs: A list of tuples ([opts], out), where each 'opts' is a list of - options passed to tblgen, each option being a string, and 'out' is the - corresponding output file produced. - td_srcs: See gentbl_rule.td_srcs - includes: See gentbl_rule.includes - deps: See gentbl_rule.deps - test: Whether to create a shell test that invokes the tool too. - skip_opts: Files generated using these opts in tbl_outs will be excluded - from the generated filegroup. - **kwargs: Extra keyword arguments to pass to all generated rules. - """ - - for (opts, out) in tbl_outs: - first_opt = opts[0] if opts else "" - rule_suffix = "_{}_{}".format( - first_opt.replace("-", "_").replace("=", "_"), - str(hash(" ".join(opts))), - ) - gentbl_name = "%s_%s_genrule" % (name, rule_suffix) - gentbl_rule( - name = gentbl_name, - td_file = td_file, - tblgen = tblgen, - opts = opts, - td_srcs = td_srcs, - deps = deps, - includes = includes, - out = out, - **kwargs - ) - - if test: - # Also run the generator in the target configuration as a test. This - # means it gets run with asserts and sanitizers and such when they - # are enabled and is counted in coverage. - gentbl_test( - name = "%s_test" % (gentbl_name,), - td_file = td_file, - tblgen = tblgen, - opts = opts, - td_srcs = td_srcs, - deps = deps, - includes = includes, - # Shell files not executable on Windows. - # TODO(gcmn): Support windows. - tags = ["no_windows"], - **kwargs - ) - - included_srcs = [f for (opts, f) in tbl_outs if not any([skip_opt in opts for skip_opt in skip_opts])] - native.filegroup( - name = name, - srcs = included_srcs, - **kwargs - ) - -def gentbl_cc_library( - name, - tblgen, - td_file, - tbl_outs, - td_srcs = [], - includes = [], - deps = [], - strip_include_prefix = None, - test = False, - copts = None, - **kwargs): - """Create multiple TableGen generated files using the same tool and input. - - All generated outputs are bundled in a cc_library rule. - - Args: - name: The name of the generated cc_library rule for use in dependencies. - tblgen: The binary used to produce the output. - td_file: The primary table definitions file. - tbl_outs: A list of tuples ([opts], out), where each 'opts' is a list of - options passed to tblgen, each option being a string, and 'out' is the - corresponding output file produced. - td_srcs: See gentbl_rule.td_srcs - includes: See gentbl_rule.includes - deps: See gentbl_rule.deps - strip_include_prefix: attribute to pass through to cc_library. - test: whether to create a shell test that invokes the tool too. - copts: list of copts to pass to cc_library. - **kwargs: Extra keyword arguments to pass to all generated rules. - """ - - filegroup_name = name + "_filegroup" - gentbl_filegroup( - name = filegroup_name, - tblgen = tblgen, - td_file = td_file, - tbl_outs = tbl_outs, - td_srcs = td_srcs, - includes = includes, - deps = deps, - test = test, - skip_opts = ["-gen-op-doc"], - **kwargs - ) - native.cc_library( - name = name, - # strip_include_prefix does not apply to textual_hdrs. - # https://github.com/bazelbuild/bazel/issues/12424 - hdrs = [":" + filegroup_name] if strip_include_prefix else [], - strip_include_prefix = strip_include_prefix, - textual_hdrs = [":" + filegroup_name], - copts = copts, - **kwargs - ) diff --git a/utils/bazel/llvm-project-overlay/mlir/test/Analysis/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/test/Analysis/BUILD.bazel deleted file mode 100644 index 83a17efbbd6605..00000000000000 --- a/utils/bazel/llvm-project-overlay/mlir/test/Analysis/BUILD.bazel +++ /dev/null @@ -1,17 +0,0 @@ -load("//llvm:lit_test.bzl", "lit_test") - -licenses(["notice"]) - -package(default_visibility = ["//visibility:public"]) - -[ - lit_test( - name = "%s.test" % src, - srcs = [src], - data = [ - "//mlir:mlir-opt", - "//mlir/test:lit_data", - ], - ) - for src in glob(["**/*.mlir"]) -] diff --git a/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel deleted file mode 100644 index 91706af935ac5e..00000000000000 --- a/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel +++ /dev/null @@ -1,1124 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -load("@bazel_skylib//rules:expand_template.bzl", "expand_template") -load("//llvm:lit_test.bzl", "package_path") -load("//mlir:tblgen.bzl", "gentbl_cc_library", "td_library") - -package( - default_visibility = ["//visibility:public"], - features = ["layering_check"], -) - -licenses(["notice"]) - -LLVM_LIT_PATH_FUNCTION = " " + \ - "# Allow generated file to be relocatable.\n" + \ - "from pathlib import Path\n" + \ - "def path(p):\n" + \ - " if not p: return ''\n" + \ - " return str((Path(__file__).parent / p).resolve())\n" - -LIT_SITE_CFG_IN_HEADER = "# Autogenerated, do not edit." + LLVM_LIT_PATH_FUNCTION - -expand_template( - name = "lit_site_cfg_py", - testonly = True, - out = "lit.site.cfg.py", - substitutions = { - "@LIT_SITE_CFG_IN_HEADER@": LIT_SITE_CFG_IN_HEADER, - "@LLVM_TOOLS_DIR@": package_path("//llvm:BUILD"), - "@ENABLE_SHARED@": "1", - "@ENABLE_ASSERTIONS@": "1", - "@MLIR_SOURCE_DIR@": package_path("//mlir:BUILD"), - "@MLIR_TOOLS_DIR@": package_path("//mlir:BUILD"), - "\"@MLIR_BINARY_DIR@\"": "os.environ[\"TEST_UNDECLARED_OUTPUTS_DIR\"]", - # All disabled, but required to substituted because they are not in quotes. - "@LLVM_BUILD_EXAMPLES@": "0", - "@MLIR_ENABLE_CUDA_CONVERSIONS@": "0", - "@MLIR_ENABLE_CUDA_RUNNER@": "0", - "@MLIR_ENABLE_ROCM_CONVERSIONS@": "0", - "@MLIR_ENABLE_ROCM_RUNNER@": "0", - "@MLIR_ENABLE_SYCL_RUNNER@": "0", - "@MLIR_ENABLE_SPIRV_CPU_RUNNER@": "0", - "@MLIR_ENABLE_VULKAN_RUNNER@": "0", - "@MLIR_ENABLE_BINDINGS_PYTHON@": "0", - "@MLIR_RUN_AMX_TESTS@": "0", - "@MLIR_RUN_ARM_SVE_TESTS@": "0", - "@MLIR_RUN_ARM_SME_TESTS@": "0", - "@MLIR_RUN_X86VECTOR_TESTS@": "0", - "@MLIR_RUN_CUDA_TENSOR_CORE_TESTS@": "0", - "@MLIR_RUN_CUDA_SM80_TESTS@": "0", - "@MLIR_RUN_CUDA_SM80_LT_TESTS@": "0", - "@MLIR_RUN_CUDA_SM90_TESTS@": "0", - "@MLIR_INCLUDE_INTEGRATION_TESTS@": "0", - "@SHLIBDIR@": package_path("//llvm:BUILD"), - }, - template = "lit.site.cfg.py.in", -) - -# Common data used by most lit tests. -filegroup( - name = "lit_data", - testonly = True, - data = [ - "lit.cfg.py", - "lit.site.cfg.py", - "//llvm:FileCheck", - "//llvm:count", - "//llvm:not", - ], -) - -cc_library( - name = "IRProducingAPITest", - hdrs = ["APITest.h"], - includes = ["."], -) - -cc_library( - name = "TestAnalysis", - srcs = glob( - [ - "lib/Analysis/*.cpp", - "lib/Analysis/*.h", - "lib/Analysis/DataFlow/*.cpp", - "lib/Analysis/DataFlow/*.h", - ], - ), - includes = ["lib/Dialect/Test"], - deps = [ - ":TestDialect", - "//llvm:Support", - "//mlir:AffineAnalysis", - "//mlir:AffineDialect", - "//mlir:Analysis", - "//mlir:ControlFlowInterfaces", - "//mlir:FuncDialect", - "//mlir:FunctionInterfaces", - "//mlir:IR", - "//mlir:MemRefDialect", - "//mlir:Pass", - "//mlir:Support", - ], -) - -td_library( - name = "TestOpTdFiles", - srcs = glob(["lib/Dialect/Test/*.td"]), - deps = [ - "//mlir:BuiltinDialectTdFiles", - "//mlir:CallInterfacesTdFiles", - "//mlir:ControlFlowInterfacesTdFiles", - "//mlir:CopyOpInterfaceTdFiles", - "//mlir:DLTIDialectTdFiles", - "//mlir:DataLayoutInterfacesTdFiles", - "//mlir:DestinationStyleOpInterfaceTdFiles", - "//mlir:FunctionInterfacesTdFiles", - "//mlir:InferIntRangeInterfaceTdFiles", - "//mlir:InferTypeOpInterfaceTdFiles", - "//mlir:LinalgStructuredOpsTdFiles", - "//mlir:OpBaseTdFiles", - "//mlir:SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "TestOpsSyntaxIncGen", - strip_include_prefix = "lib/Dialect/Test", - tbl_outs = [ - ( - ["-gen-op-decls"], - "lib/Dialect/Test/TestOpsSyntax.h.inc", - ), - ( - ["-gen-op-defs"], - "lib/Dialect/Test/TestOpsSyntax.cpp.inc", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "lib/Dialect/Test/TestOpsSyntax.td", - test = True, - deps = [ - ":TestOpTdFiles", - ], -) - -gentbl_cc_library( - name = "TestOpsIncGen", - strip_include_prefix = "lib/Dialect/Test", - tbl_outs = [ - ( - ["-gen-op-decls"], - "lib/Dialect/Test/TestOps.h.inc", - ), - ( - ["-gen-op-defs"], - "lib/Dialect/Test/TestOps.cpp.inc", - ), - ( - [ - "-gen-dialect-decls", - "-dialect=test", - ], - "lib/Dialect/Test/TestOpsDialect.h.inc", - ), - ( - [ - "-gen-dialect-defs", - "-dialect=test", - ], - "lib/Dialect/Test/TestOpsDialect.cpp.inc", - ), - ( - ["-gen-rewriters"], - "lib/Dialect/Test/TestPatterns.inc", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "lib/Dialect/Test/TestOps.td", - test = True, - deps = [ - ":TestOpTdFiles", - ], -) - -gentbl_cc_library( - name = "TestInterfacesIncGen", - strip_include_prefix = "lib/Dialect/Test", - tbl_outs = [ - ( - ["-gen-attr-interface-decls"], - "lib/Dialect/Test/TestAttrInterfaces.h.inc", - ), - ( - ["-gen-attr-interface-defs"], - "lib/Dialect/Test/TestAttrInterfaces.cpp.inc", - ), - ( - ["-gen-type-interface-decls"], - "lib/Dialect/Test/TestTypeInterfaces.h.inc", - ), - ( - ["-gen-type-interface-defs"], - "lib/Dialect/Test/TestTypeInterfaces.cpp.inc", - ), - ( - ["-gen-op-interface-decls"], - "lib/Dialect/Test/TestOpInterfaces.h.inc", - ), - ( - ["-gen-op-interface-defs"], - "lib/Dialect/Test/TestOpInterfaces.cpp.inc", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "lib/Dialect/Test/TestInterfaces.td", - test = True, - deps = [ - "//mlir:OpBaseTdFiles", - "//mlir:SideEffectInterfacesTdFiles", - ], -) - -gentbl_cc_library( - name = "TestAttrDefsIncGen", - strip_include_prefix = "lib/Dialect/Test", - tbl_outs = [ - ( - ["-gen-attrdef-decls"], - "lib/Dialect/Test/TestAttrDefs.h.inc", - ), - ( - ["-gen-attrdef-defs"], - "lib/Dialect/Test/TestAttrDefs.cpp.inc", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "lib/Dialect/Test/TestOps.td", - test = True, - deps = [ - ":TestOpTdFiles", - ], -) - -gentbl_cc_library( - name = "TestEnumDefsIncGen", - strip_include_prefix = "lib/Dialect/Test", - tbl_outs = [ - ( - ["-gen-enum-decls"], - "lib/Dialect/Test/TestOpEnums.h.inc", - ), - ( - ["-gen-enum-defs"], - "lib/Dialect/Test/TestOpEnums.cpp.inc", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "lib/Dialect/Test/TestEnumDefs.td", - test = True, - deps = [ - ":TestOpTdFiles", - ], -) - -gentbl_cc_library( - name = "TestTypeDefsIncGen", - strip_include_prefix = "lib/Dialect/Test", - tbl_outs = [ - ( - [ - "-gen-typedef-decls", - "--typedefs-dialect=test", - ], - "lib/Dialect/Test/TestTypeDefs.h.inc", - ), - ( - [ - "-gen-typedef-defs", - "--typedefs-dialect=test", - ], - "lib/Dialect/Test/TestTypeDefs.cpp.inc", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "lib/Dialect/Test/TestTypeDefs.td", - test = True, - deps = [ - ":TestOpTdFiles", - "//mlir:BuiltinDialectTdFiles", - ], -) - -cc_library( - name = "TestTestDynDialect", - srcs = glob([ - "lib/Dialect/TestDyn/*.cpp", - ]), - deps = [ - "//mlir:IR", - ], -) - -td_library( - name = "TransformDialectTdFiles", - srcs = glob(["lib/Dialect/Transform/*.td"]), - deps = [ - "//mlir:OpBaseTdFiles", - ], -) - -gentbl_cc_library( - name = "TestTransformDialectExtensionIncGen", - strip_include_prefix = "lib/Dialect/Transform", - tbl_outs = [ - ( - ["-gen-op-decls"], - "lib/Dialect/Transform/TestTransformDialectExtension.h.inc", - ), - ( - ["-gen-op-defs"], - "lib/Dialect/Transform/TestTransformDialectExtension.cpp.inc", - ), - ( - [ - "-gen-typedef-decls", - "-typedefs-dialect=transform", - ], - "lib/Dialect/Transform/TestTransformDialectExtensionTypes.h.inc", - ), - ( - [ - "-gen-typedef-defs", - "-typedefs-dialect=transform", - ], - "lib/Dialect/Transform/TestTransformDialectExtensionTypes.cpp.inc", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "lib/Dialect/Transform/TestTransformDialectExtension.td", - test = True, - deps = [ - ":TransformDialectTdFiles", - "//mlir:PDLDialectTdFiles", - "//mlir:TransformDialectTdFiles", - "//mlir:TransformPDLExtension", - ], -) - -cc_library( - name = "TestTransformDialect", - srcs = glob(["lib/Dialect/Transform/*.cpp"]), - hdrs = glob(["lib/Dialect/Transform/*.h"]), - includes = ["lib/Dialect/Transform"], - deps = [ - ":TestTransformDialectExtensionIncGen", - "//llvm:Support", - "//mlir:IR", - "//mlir:PDLDialect", - "//mlir:Pass", - "//mlir:TransformDebugExtension", - "//mlir:TransformDialect", - "//mlir:TransformDialectTransforms", - "//mlir:TransformPDLExtension", - ], -) - -cc_library( - name = "TestDialect", - srcs = glob( - ["lib/Dialect/Test/*.cpp"], - exclude = ["lib/Dialect/Test/TestToLLVMIRTranslation.cpp"], - ), - hdrs = glob(["lib/Dialect/Test/*.h"]), - includes = [ - "lib/Dialect/Test", - ], - deps = [ - ":TestAttrDefsIncGen", - ":TestEnumDefsIncGen", - ":TestInterfacesIncGen", - ":TestOpsIncGen", - ":TestOpsSyntaxIncGen", - ":TestTypeDefsIncGen", - "//llvm:Support", - "//mlir:ArithDialect", - "//mlir:ControlFlowInterfaces", - "//mlir:CopyOpInterface", - "//mlir:DLTIDialect", - "//mlir:DataLayoutInterfaces", - "//mlir:DerivedAttributeOpInterface", - "//mlir:DestinationStyleOpInterface", - "//mlir:Dialect", - "//mlir:DialectUtils", - "//mlir:FuncDialect", - "//mlir:FuncTransforms", - "//mlir:FunctionInterfaces", - "//mlir:IR", - "//mlir:InferIntRangeInterface", - "//mlir:InferTypeOpInterface", - "//mlir:LLVMDialect", - "//mlir:LinalgDialect", - "//mlir:LoopLikeInterface", - "//mlir:Pass", - "//mlir:Reducer", - "//mlir:SideEffectInterfaces", - "//mlir:Support", - "//mlir:TensorDialect", - "//mlir:TransformUtils", - "//mlir:Transforms", - "//mlir:ViewLikeInterface", - ], -) - -cc_library( - name = "TestToLLVMIRTranslation", - srcs = ["lib/Dialect/Test/TestToLLVMIRTranslation.cpp"], - deps = [ - ":TestDialect", - "//llvm:Support", - "//mlir:BuiltinToLLVMIRTranslation", - "//mlir:IR", - "//mlir:LLVMToLLVMIRTranslation", - "//mlir:ToLLVMIRTranslation", - "//mlir:TranslateLib", - ], -) - -cc_library( - name = "TestIR", - srcs = glob(["lib/IR/*.cpp"]), - deps = [ - ":TestDialect", - "//llvm:Support", - "//mlir:Analysis", - "//mlir:ArithDialect", - "//mlir:BytecodeReader", - "//mlir:BytecodeWriter", - "//mlir:FuncDialect", - "//mlir:FunctionInterfaces", - "//mlir:IR", - "//mlir:LinalgDialect", - "//mlir:Parser", - "//mlir:Pass", - "//mlir:Support", - ], -) - -cc_library( - name = "TestLoopLikeInterface", - srcs = glob(["lib/Interfaces/LoopLikeInterface/*.cpp"]), - deps = [ - "//llvm:Support", - "//mlir:FuncDialect", - "//mlir:IR", - "//mlir:LoopLikeInterface", - "//mlir:Pass", - ], -) - -gentbl_cc_library( - name = "TestTilingInterfaceTransformOpsIncGen", - includes = ["lib/Interfaces/TilingInterface"], - strip_include_prefix = "lib", - tbl_outs = [ - ( - ["-gen-op-decls"], - "lib/Interfaces/TilingInterface/TestTilingInterfaceTransformOps.h.inc", - ), - ( - ["-gen-op-defs"], - "lib/Interfaces/TilingInterface/TestTilingInterfaceTransformOps.cpp.inc", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "lib/Interfaces/TilingInterface/TestTilingInterfaceTransformOps.td", - deps = [ - "//mlir:SCFTdFiles", - "//mlir:TransformDialectTdFiles", - ], -) - -cc_library( - name = "TestTilingInterface", - srcs = glob(["lib/Interfaces/TilingInterface/*.cpp"]), - includes = ["lib/Interfaces/TilingInterface"], - deps = [ - ":TestTilingInterfaceTransformOpsIncGen", - "//llvm:Support", - "//mlir:AffineDialect", - "//mlir:ArithDialect", - "//mlir:DialectUtils", - "//mlir:FuncDialect", - "//mlir:GPUDialect", - "//mlir:IR", - "//mlir:IndexDialect", - "//mlir:LinalgDialect", - "//mlir:LinalgTransforms", - "//mlir:MemRefDialect", - "//mlir:Pass", - "//mlir:SCFDialect", - "//mlir:SCFTransforms", - "//mlir:TensorDialect", - "//mlir:TensorTilingInterfaceImpl", - "//mlir:TilingInterface", - "//mlir:TransformDialect", - "//mlir:Transforms", - ], -) - -cc_library( - name = "TestPass", - srcs = glob(["lib/Pass/*.cpp"]), - deps = [ - ":TestDialect", - "//llvm:Support", - "//mlir:FuncDialect", - "//mlir:IR", - "//mlir:Pass", - "//mlir:Support", - ], -) - -cc_library( - name = "TestRewrite", - srcs = [ - "lib/Rewrite/TestPDLByteCode.cpp", - ], - deps = [ - "//mlir:IR", - "//mlir:PDLInterpDialect", - "//mlir:Pass", - "//mlir:Support", - "//mlir:TransformUtils", - ], -) - -cc_library( - name = "TestReducer", - srcs = [ - "lib/Reducer/MLIRTestReducer.cpp", - ], - deps = [ - "//mlir:IR", - "//mlir:Pass", - "//mlir:Support", - ], -) - -cc_library( - name = "TestTransforms", - srcs = glob(["lib/Transforms/*.cpp"]), - includes = ["lib/Dialect/Test"], - deps = [ - ":TestDialect", - ":TestDialectConversionPDLLPatternsIncGen", - "//llvm:Support", - "//mlir:AffineAnalysis", - "//mlir:AffineDialect", - "//mlir:Analysis", - "//mlir:ArithDialect", - "//mlir:FuncDialect", - "//mlir:IR", - "//mlir:MathDialect", - "//mlir:PDLDialect", - "//mlir:PDLInterpDialect", - "//mlir:Parser", - "//mlir:Pass", - "//mlir:SCFDialect", - "//mlir:SPIRVDialect", - "//mlir:Support", - "//mlir:TransformUtils", - ], -) - -cc_library( - name = "TestFuncToLLVM", - srcs = glob(["lib/Conversion/FuncToLLVM/*.cpp"]), - includes = ["lib/Dialect/Test"], - deps = [ - ":TestDialect", - "//mlir:FuncDialect", - "//mlir:FuncToLLVM", - "//mlir:LLVMCommonConversion", - "//mlir:LLVMDialect", - "//mlir:Pass", - ], -) - -cc_library( - name = "TestOneToNTypeConversion", - srcs = glob(["lib/Conversion/OneToNTypeConversion/*.cpp"]), - includes = ["lib/Dialect/Test"], - deps = [ - ":TestDialect", - "//mlir:FuncDialect", - "//mlir:FuncTransforms", - "//mlir:IR", - "//mlir:Pass", - "//mlir:SCFDialect", - "//mlir:SCFTransforms", - "//mlir:TransformUtils", - ], -) - -cc_library( - name = "TestVectorToSPIRV", - srcs = glob(["lib/Conversion/VectorToSPIRV/*.cpp"]), - deps = [ - "//mlir:ArithDialect", - "//mlir:FuncDialect", - "//mlir:Pass", - "//mlir:SPIRVDialect", - "//mlir:Transforms", - "//mlir:VectorDialect", - "//mlir:VectorToSPIRV", - ], -) - -cc_library( - name = "TestAffine", - srcs = glob([ - "lib/Dialect/Affine/*.cpp", - ]), - deps = [ - "//llvm:Support", - "//mlir:AffineAnalysis", - "//mlir:AffineDialect", - "//mlir:AffineTransforms", - "//mlir:AffineUtils", - "//mlir:Analysis", - "//mlir:ArithTransforms", - "//mlir:DialectUtils", - "//mlir:FuncDialect", - "//mlir:IR", - "//mlir:MemRefDialect", - "//mlir:Pass", - "//mlir:SCFDialect", - "//mlir:Support", - "//mlir:TensorDialect", - "//mlir:Transforms", - "//mlir:ValueBoundsOpInterface", - "//mlir:VectorDialect", - "//mlir:VectorUtils", - ], -) - -cc_library( - name = "TestDLTI", - srcs = glob(["lib/Dialect/DLTI/*.cpp"]), - includes = ["lib/Dialect/Test"], - deps = [ - ":TestDialect", - "//mlir:Analysis", - "//mlir:DLTIDialect", - "//mlir:IR", - "//mlir:Pass", - ], -) - -cc_library( - name = "TestGPU", - srcs = glob(["lib/Dialect/GPU/*.cpp"]), - includes = ["lib/Dialect/Test"], - deps = [ - "//llvm:NVPTXCodeGen", - "//llvm:Support", - "//mlir:AffineDialect", - "//mlir:AffineToStandard", - "//mlir:ArithDialect", - "//mlir:ArithToLLVM", - "//mlir:FuncDialect", - "//mlir:FuncToLLVM", - "//mlir:GPUDialect", - "//mlir:GPUToGPURuntimeTransforms", - "//mlir:GPUToNVVMTransforms", - "//mlir:GPUTransforms", - "//mlir:IR", - "//mlir:IndexDialect", - "//mlir:IndexToLLVM", - "//mlir:LLVMDialect", - "//mlir:LinalgTransforms", - "//mlir:MathToLLVM", - "//mlir:MemRefDialect", - "//mlir:MemRefToLLVM", - "//mlir:MemRefTransforms", - "//mlir:NVGPUToNVVM", - "//mlir:NVVMToLLVM", - "//mlir:NVVMToLLVMIRTranslation", - "//mlir:Pass", - "//mlir:ROCDLToLLVMIRTranslation", - "//mlir:ReconcileUnrealizedCasts", - "//mlir:SCFDialect", - "//mlir:SCFToControlFlow", - "//mlir:SPIRVDialect", - "//mlir:ToLLVMIRTranslation", - "//mlir:TransformUtils", - "//mlir:Transforms", - "//mlir:VectorDialect", - "//mlir:VectorToLLVM", - "//mlir:VectorToSCF", - ], -) - -cc_library( - name = "TestLinalg", - srcs = glob(["lib/Dialect/Linalg/*.cpp"]), - includes = ["lib/Dialect/Test"], - deps = [ - "//llvm:Support", - "//mlir:AffineDialect", - "//mlir:ArithDialect", - "//mlir:ArithTransforms", - "//mlir:BufferizationDialect", - "//mlir:BufferizationTransforms", - "//mlir:FuncDialect", - "//mlir:FuncTransforms", - "//mlir:GPUDialect", - "//mlir:IR", - "//mlir:LinalgDialect", - "//mlir:LinalgTransforms", - "//mlir:LinalgUtils", - "//mlir:MemRefDialect", - "//mlir:Parser", - "//mlir:Pass", - "//mlir:SCFDialect", - "//mlir:SCFTransforms", - "//mlir:TensorDialect", - "//mlir:TensorTransforms", - "//mlir:TransformUtils", - "//mlir:Transforms", - "//mlir:VectorDialect", - "//mlir:VectorToSCF", - "//mlir:VectorTransforms", - ], -) - -cc_library( - name = "TestLLVM", - srcs = glob(["lib/Dialect/LLVM/*.cpp"]), - includes = ["lib/Dialect/Test"], - deps = [ - "//mlir:AffineToStandard", - "//mlir:FuncDialect", - "//mlir:FuncToLLVM", - "//mlir:IR", - "//mlir:IndexToLLVM", - "//mlir:LLVMDialect", - "//mlir:LinalgTransforms", - "//mlir:MathToLLVM", - "//mlir:MemRefToLLVM", - "//mlir:MemRefTransforms", - "//mlir:Pass", - "//mlir:ReconcileUnrealizedCasts", - "//mlir:SCFToControlFlow", - "//mlir:Transforms", - "//mlir:VectorToLLVM", - "//mlir:VectorToSCF", - ], -) - -cc_library( - name = "TestMath", - srcs = glob(["lib/Dialect/Math/*.cpp"]), - includes = ["lib/Dialect/Test"], - deps = [ - "//mlir:ArithDialect", - "//mlir:MathDialect", - "//mlir:MathTransforms", - "//mlir:Pass", - "//mlir:SCFDialect", - "//mlir:TransformUtils", - "//mlir:VectorDialect", - "//mlir:X86VectorDialect", - ], -) - -cc_library( - name = "TestMathToVCIX", - srcs = glob(["lib/Conversion/MathToVCIX/*.cpp"]), - includes = ["lib/Dialect/Test"], - deps = [ - "//mlir:ArithDialect", - "//mlir:FuncDialect", - "//mlir:IR", - "//mlir:MathDialect", - "//mlir:Pass", - "//mlir:TransformUtils", - "//mlir:VCIXDialect", - "//mlir:VectorDialect", - ], -) - -cc_library( - name = "TestMemRef", - srcs = glob(["lib/Dialect/MemRef/*.cpp"]), - includes = ["lib/Dialect/Test"], - deps = [ - ":TestDialect", - "//mlir:AffineDialect", - "//mlir:ArithDialect", - "//mlir:ArithTransforms", - "//mlir:FuncDialect", - "//mlir:MemRefDialect", - "//mlir:MemRefTransforms", - "//mlir:Pass", - "//mlir:Transforms", - "//mlir:VectorDialect", - "//mlir:VectorTransforms", - ], -) - -cc_library( - name = "TestMesh", - srcs = glob(["lib/Dialect/Mesh/**/*.cpp"]), - hdrs = glob(["lib/Dialect/Mesh/**/*.h"]), - includes = ["lib/Dialect/Test"], - deps = [ - ":TestDialect", - "//mlir:ArithDialect", - "//mlir:DialectUtils", - "//mlir:FuncDialect", - "//mlir:IR", - "//mlir:MeshDialect", - "//mlir:MeshTransforms", - "//mlir:Pass", - "//mlir:SPIRVDialect", - "//mlir:Support", - "//mlir:Transforms", - ], -) - -cc_library( - name = "TestNVGPU", - srcs = glob(["lib/Dialect/NVGPU/*.cpp"]), - includes = ["lib/Dialect/Test"], - deps = [ - "//mlir:AffineDialect", - "//mlir:Analysis", - "//mlir:FuncDialect", - "//mlir:GPUDialect", - "//mlir:IR", - "//mlir:LLVMDialect", - "//mlir:LinalgDialect", - "//mlir:LinalgTransforms", - "//mlir:MemRefDialect", - "//mlir:NVGPUDialect", - "//mlir:NVGPUTransforms", - "//mlir:Pass", - "//mlir:SCFDialect", - "//mlir:Support", - "//mlir:TransformUtils", - ], -) - -cc_library( - name = "TestSCF", - srcs = glob(["lib/Dialect/SCF/*.cpp"]), - includes = ["lib/Dialect/Test"], - deps = [ - "//llvm:Support", - "//mlir:ArithDialect", - "//mlir:FuncDialect", - "//mlir:IR", - "//mlir:MathDialect", - "//mlir:MemRefDialect", - "//mlir:Pass", - "//mlir:SCFDialect", - "//mlir:SCFTransforms", - "//mlir:SCFUtils", - "//mlir:TransformUtils", - ], -) - -cc_library( - name = "TestArith", - srcs = glob(["lib/Dialect/Arith/*.cpp"]), - includes = ["lib/Dialect/Test"], - deps = [ - "//mlir:ArithDialect", - "//mlir:ArithTransforms", - "//mlir:FuncDialect", - "//mlir:LLVMDialect", - "//mlir:MathDialect", - "//mlir:Pass", - "//mlir:Transforms", - "//mlir:VectorDialect", - ], -) - -cc_library( - name = "TestArmNeon", - srcs = glob(["lib/Dialect/ArmNeon/*.cpp"]), - includes = ["lib/Dialect/Test"], - deps = [ - "//mlir:ArmNeonDialect", - "//mlir:ArmNeonTransforms", - "//mlir:FuncDialect", - "//mlir:IR", - "//mlir:Pass", - "//mlir:Support", - "//mlir:Transforms", - ], -) - -cc_library( - name = "TestArmSME", - srcs = glob(["lib/Dialect/ArmSME/*.cpp"]), - includes = ["lib/Dialect/Test"], - deps = [ - "//mlir:ArithToArmSME", - "//mlir:ArmSMEToLLVM", - "//mlir:ArmSMEToSCF", - "//mlir:ArmSMETransforms", - "//mlir:ArmSVETransforms", - "//mlir:IR", - "//mlir:Pass", - "//mlir:Transforms", - "//mlir:VectorToArmSME", - "//mlir:VectorToSCF", - ], -) - -cc_library( - name = "TestBufferization", - srcs = glob(["lib/Dialect/Bufferization/*.cpp"]), - includes = ["lib/Dialect/Test"], - deps = [ - "//mlir:BufferizationDialect", - "//mlir:BufferizationTransforms", - "//mlir:IR", - "//mlir:Pass", - ], -) - -cc_library( - name = "TestControlFlow", - srcs = glob(["lib/Dialect/ControlFlow/*.cpp"]), - includes = ["lib/Dialect/Test"], - deps = [ - "//mlir:ControlFlowDialect", - "//mlir:ControlFlowToLLVM", - "//mlir:FuncDialect", - "//mlir:LLVMCommonConversion", - "//mlir:LLVMDialect", - "//mlir:Pass", - "//mlir:Transforms", - ], -) - -cc_library( - name = "TestShapeDialect", - srcs = [ - "lib/Dialect/Shape/TestShapeFunctions.cpp", - "lib/Dialect/Shape/TestShapeMappingAnalysis.cpp", - ], - deps = [ - "//llvm:Support", - "//mlir:FuncDialect", - "//mlir:IR", - "//mlir:InferTypeOpInterface", - "//mlir:Pass", - "//mlir:ShapeDialect", - "//mlir:ShapeTransforms", - ], -) - -cc_library( - name = "TestSPIRV", - srcs = glob([ - "lib/Dialect/SPIRV/*.cpp", - ]), - deps = [ - "//mlir:FuncDialect", - "//mlir:GPUDialect", - "//mlir:IR", - "//mlir:Pass", - "//mlir:SPIRVConversion", - "//mlir:SPIRVDialect", - "//mlir:SPIRVModuleCombiner", - "//mlir:Transforms", - ], -) - -cc_library( - name = "TestFunc", - srcs = glob(["lib/Dialect/Func/*.cpp"]), - includes = ["lib/Dialect/Test"], - deps = [ - ":TestDialect", - "//mlir:AffineDialect", - "//mlir:FuncDialect", - "//mlir:FuncTransforms", - "//mlir:IR", - "//mlir:Pass", - "//mlir:TransformUtils", - ], -) - -cc_library( - name = "TestTensor", - srcs = glob(["lib/Dialect/Tensor/*.cpp"]), - includes = ["lib/Dialect/Test"], - deps = [ - "//mlir:ArithDialect", - "//mlir:LinalgDialect", - "//mlir:Pass", - "//mlir:SCFDialect", - "//mlir:TensorDialect", - "//mlir:TensorTransforms", - "//mlir:TransformDialect", - "//mlir:Transforms", - ], -) - -cc_library( - name = "TestVector", - srcs = glob(["lib/Dialect/Vector/*.cpp"]), - includes = ["lib/Dialect/Test"], - deps = [ - "//mlir:AffineDialect", - "//mlir:Analysis", - "//mlir:ArithDialect", - "//mlir:FuncDialect", - "//mlir:GPUDialect", - "//mlir:LLVMDialect", - "//mlir:LinalgDialect", - "//mlir:LinalgTransforms", - "//mlir:MemRefDialect", - "//mlir:NVGPUDialect", - "//mlir:Pass", - "//mlir:SCFDialect", - "//mlir:Support", - "//mlir:TensorDialect", - "//mlir:TransformUtils", - "//mlir:VectorDialect", - "//mlir:VectorToSCF", - "//mlir:VectorTransforms", - "//mlir:X86VectorDialect", - ], -) - -cc_library( - name = "TestTypeDialect", - srcs = glob([ - "lib/Dialect/LLVMIR/*.cpp", - ]), - deps = [ - ":TestDialect", - "//mlir:IR", - "//mlir:LLVMDialect", - ], -) - -cc_library( - name = "TestTosaDialect", - srcs = glob([ - "lib/Dialect/Tosa/*.cpp", - ]), - deps = [ - "//mlir:FuncDialect", - "//mlir:IR", - "//mlir:Pass", - "//mlir:TensorDialect", - "//mlir:TosaDialect", - "//mlir:Transforms", - ], -) - -gentbl_cc_library( - name = "TestPDLLPatternsIncGen", - includes = ["lib/Dialect/Test"], - strip_include_prefix = "lib", - tbl_outs = [ - ( - ["-x=cpp"], - "lib/Tools/PDLL/TestPDLLPatterns.h.inc", - ), - ], - tblgen = "//mlir:mlir-pdll", - td_file = "lib/Tools/PDLL/TestPDLL.pdll", - deps = [ - ":TestDialect", - ":TestOpTdFiles", - ], -) - -gentbl_cc_library( - name = "TestDialectConversionPDLLPatternsIncGen", - includes = ["lib/Dialect/Test"], - strip_include_prefix = "lib", - tbl_outs = [ - ( - ["-x=cpp"], - "lib/TestDialectConversionPDLLPatterns.h.inc", - ), - ], - tblgen = "//mlir:mlir-pdll", - td_file = "lib/Transforms/TestDialectConversion.pdll", - deps = [ - ":TestDialect", - ":TestOpTdFiles", - "//mlir:DialectConversionPdllFiles", - ], -) - -cc_library( - name = "TestPDLL", - srcs = ["lib/Tools/PDLL/TestPDLL.cpp"], - includes = ["lib/Tools/PDLL"], - deps = [ - ":TestDialect", - ":TestPDLLPatternsIncGen", - "//mlir:CastInterfaces", - "//mlir:IR", - "//mlir:PDLDialect", - "//mlir:PDLInterpDialect", - "//mlir:Parser", - "//mlir:Pass", - "//mlir:Support", - "//mlir:TransformUtils", - ], -) diff --git a/utils/bazel/llvm-project-overlay/mlir/test/Conversion/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/test/Conversion/BUILD.bazel deleted file mode 100644 index b00e8f243c29a2..00000000000000 --- a/utils/bazel/llvm-project-overlay/mlir/test/Conversion/BUILD.bazel +++ /dev/null @@ -1,20 +0,0 @@ -load("//llvm:lit_test.bzl", "lit_test") - -licenses(["notice"]) - -package(default_visibility = ["//visibility:public"]) - -[ - lit_test( - name = "%s.test" % src, - srcs = [src], - data = [ - "//mlir:mlir-opt", - "//mlir/test:lit_data", - ], - ) - for src in glob( - include = ["**/*.mlir"], - exclude = ["GPUToROCm/lower-rocdl-kernel-to-hsaco.mlir"], - ) -] diff --git a/utils/bazel/llvm-project-overlay/mlir/test/Dialect/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/test/Dialect/BUILD.bazel deleted file mode 100644 index 1fd6885db8bca9..00000000000000 --- a/utils/bazel/llvm-project-overlay/mlir/test/Dialect/BUILD.bazel +++ /dev/null @@ -1,33 +0,0 @@ -load("//llvm:lit_test.bzl", "lit_test") - -licenses(["notice"]) - -package(default_visibility = ["//visibility:public"]) - -[ - lit_test( - name = "%s.test" % src, - srcs = [src], - data = [ - "//llvm:llvm-symbolizer", - "//mlir:mlir-opt", - "//mlir:mlir-pdll", - "//mlir:mlir-reduce", - "//mlir:mlir-translate", - "//mlir/test:lit_data", - ] + glob([ - "IRDL/*.irdl.mlir", - "LLVM/*-symbol-def.mlir", - "Transform/include/**/*.mlir", - ]), - ) - for src in glob( - include = ["**/*.mlir"], - exclude = [ - "IRDL/*.irdl.mlir", - "LLVM/*-symbol-def.mlir", - "Transform/*-symbol-decl-and-schedule.mlir", - "Transform/include/**/*.mlir", - ], - ) -] diff --git a/utils/bazel/llvm-project-overlay/mlir/test/IR/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/test/IR/BUILD.bazel deleted file mode 100644 index 83a17efbbd6605..00000000000000 --- a/utils/bazel/llvm-project-overlay/mlir/test/IR/BUILD.bazel +++ /dev/null @@ -1,17 +0,0 @@ -load("//llvm:lit_test.bzl", "lit_test") - -licenses(["notice"]) - -package(default_visibility = ["//visibility:public"]) - -[ - lit_test( - name = "%s.test" % src, - srcs = [src], - data = [ - "//mlir:mlir-opt", - "//mlir/test:lit_data", - ], - ) - for src in glob(["**/*.mlir"]) -] diff --git a/utils/bazel/llvm-project-overlay/mlir/test/Pass/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/test/Pass/BUILD.bazel deleted file mode 100644 index 83a17efbbd6605..00000000000000 --- a/utils/bazel/llvm-project-overlay/mlir/test/Pass/BUILD.bazel +++ /dev/null @@ -1,17 +0,0 @@ -load("//llvm:lit_test.bzl", "lit_test") - -licenses(["notice"]) - -package(default_visibility = ["//visibility:public"]) - -[ - lit_test( - name = "%s.test" % src, - srcs = [src], - data = [ - "//mlir:mlir-opt", - "//mlir/test:lit_data", - ], - ) - for src in glob(["**/*.mlir"]) -] diff --git a/utils/bazel/llvm-project-overlay/mlir/test/Rewrite/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/test/Rewrite/BUILD.bazel deleted file mode 100644 index 83a17efbbd6605..00000000000000 --- a/utils/bazel/llvm-project-overlay/mlir/test/Rewrite/BUILD.bazel +++ /dev/null @@ -1,17 +0,0 @@ -load("//llvm:lit_test.bzl", "lit_test") - -licenses(["notice"]) - -package(default_visibility = ["//visibility:public"]) - -[ - lit_test( - name = "%s.test" % src, - srcs = [src], - data = [ - "//mlir:mlir-opt", - "//mlir/test:lit_data", - ], - ) - for src in glob(["**/*.mlir"]) -] diff --git a/utils/bazel/llvm-project-overlay/mlir/test/Target/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/test/Target/BUILD.bazel deleted file mode 100644 index 5dd22ea50e8da9..00000000000000 --- a/utils/bazel/llvm-project-overlay/mlir/test/Target/BUILD.bazel +++ /dev/null @@ -1,21 +0,0 @@ -load("//llvm:lit_test.bzl", "lit_test") - -licenses(["notice"]) - -package(default_visibility = ["//visibility:public"]) - -[ - lit_test( - name = "%s.test" % src, - srcs = [src], - data = [ - "//mlir:mlir-opt", - "//mlir:mlir-translate", - "//mlir/test:lit_data", - ], - ) - for src in glob([ - "**/*.mlir", - "**/*.ll", - ]) -] diff --git a/utils/bazel/llvm-project-overlay/mlir/test/Transforms/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/test/Transforms/BUILD.bazel deleted file mode 100644 index 83a17efbbd6605..00000000000000 --- a/utils/bazel/llvm-project-overlay/mlir/test/Transforms/BUILD.bazel +++ /dev/null @@ -1,17 +0,0 @@ -load("//llvm:lit_test.bzl", "lit_test") - -licenses(["notice"]) - -package(default_visibility = ["//visibility:public"]) - -[ - lit_test( - name = "%s.test" % src, - srcs = [src], - data = [ - "//mlir:mlir-opt", - "//mlir/test:lit_data", - ], - ) - for src in glob(["**/*.mlir"]) -] diff --git a/utils/bazel/llvm-project-overlay/mlir/test/mlir-linalg-ods-gen/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/test/mlir-linalg-ods-gen/BUILD.bazel deleted file mode 100644 index 70d6bbcda7cdfa..00000000000000 --- a/utils/bazel/llvm-project-overlay/mlir/test/mlir-linalg-ods-gen/BUILD.bazel +++ /dev/null @@ -1,19 +0,0 @@ -load("//llvm:lit_test.bzl", "lit_test") - -licenses(["notice"]) - -package(default_visibility = ["//visibility:public"]) - -[ - lit_test( - name = "%s.test" % src, - srcs = [src], - data = [ - "//mlir:LinalgStructuredOpsTdFiles", - "//mlir:mlir-linalg-ods-yaml-gen", - "//mlir:mlir-tblgen", - "//mlir/test:lit_data", - ], - ) - for src in glob(["**/*.yaml"]) -] diff --git a/utils/bazel/llvm-project-overlay/mlir/test/mlir-lsp-server/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/test/mlir-lsp-server/BUILD.bazel deleted file mode 100644 index 409e44ebab6a4c..00000000000000 --- a/utils/bazel/llvm-project-overlay/mlir/test/mlir-lsp-server/BUILD.bazel +++ /dev/null @@ -1,17 +0,0 @@ -load("//llvm:lit_test.bzl", "lit_test") - -licenses(["notice"]) - -package(default_visibility = ["//visibility:public"]) - -[ - lit_test( - name = "%s.test" % src, - srcs = [src], - data = [ - "//mlir:mlir-lsp-server", - "//mlir/test:lit_data", - ], - ) - for src in glob(["**/*.test"]) -] diff --git a/utils/bazel/llvm-project-overlay/mlir/test/mlir-opt/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/test/mlir-opt/BUILD.bazel deleted file mode 100644 index 83a17efbbd6605..00000000000000 --- a/utils/bazel/llvm-project-overlay/mlir/test/mlir-opt/BUILD.bazel +++ /dev/null @@ -1,17 +0,0 @@ -load("//llvm:lit_test.bzl", "lit_test") - -licenses(["notice"]) - -package(default_visibility = ["//visibility:public"]) - -[ - lit_test( - name = "%s.test" % src, - srcs = [src], - data = [ - "//mlir:mlir-opt", - "//mlir/test:lit_data", - ], - ) - for src in glob(["**/*.mlir"]) -] diff --git a/utils/bazel/llvm-project-overlay/mlir/test/mlir-pdll/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/test/mlir-pdll/BUILD.bazel deleted file mode 100644 index 6d0580d803f6cf..00000000000000 --- a/utils/bazel/llvm-project-overlay/mlir/test/mlir-pdll/BUILD.bazel +++ /dev/null @@ -1,25 +0,0 @@ -load("//llvm:lit_test.bzl", "lit_test") - -licenses(["notice"]) - -package(default_visibility = ["//visibility:public"]) - -[ - lit_test( - name = "%s.test" % src, - srcs = [src], - data = glob([ - "Parser/include/**", - "CodeGen/MLIR/include/**", - "CodeGen/CPP/include/**", - ]) + [ - "//mlir:OpBaseTdFiles", - "//mlir:mlir-pdll", - "//mlir/test:lit_data", - ], - ) - for src in glob( - include = ["**/*.pdll"], - exclude = ["Parser/include/included.pdll"], - ) -] diff --git a/utils/bazel/llvm-project-overlay/mlir/test/mlir-tblgen/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/test/mlir-tblgen/BUILD.bazel deleted file mode 100644 index 07d2e29fc24c6d..00000000000000 --- a/utils/bazel/llvm-project-overlay/mlir/test/mlir-tblgen/BUILD.bazel +++ /dev/null @@ -1,36 +0,0 @@ -load("//llvm:lit_test.bzl", "lit_test") - -licenses(["notice"]) - -package(default_visibility = ["//visibility:public"]) - -[ - lit_test( - name = "%s.test" % src, - srcs = [src], - data = [ - "//llvm:include/llvm/CodeGen/SDNodeProperties.td", - "//llvm:include/llvm/CodeGen/ValueTypes.td", - "//llvm:include/llvm/Frontend/Directive/DirectiveBase.td", - "//llvm:include/llvm/IR/Intrinsics.td", - "//mlir:BuiltinDialectBytecodeTdFiles", - "//mlir:SideEffectInterfacesTdFiles", - "//mlir:include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td", - "//mlir:include/mlir/Dialect/LLVMIR/LLVMDialect.td", - "//mlir:include/mlir/Dialect/LLVMIR/LLVMInterfaces.td", - "//mlir:include/mlir/Dialect/LLVMIR/LLVMOpBase.td", - "//mlir:include/mlir/IR/BuiltinDialectBytecode.td", - "//mlir:include/mlir/IR/BytecodeBase.td", - "//mlir:include/mlir/IR/OpBase.td", - "//mlir:include/mlir/Interfaces/InferTypeOpInterface.td", - "//mlir:include/mlir/Interfaces/SideEffectInterfaces.td", - "//mlir:mlir-opt", - "//mlir:mlir-tblgen", - "//mlir/test:lit_data", - ], - ) - for src in glob([ - "**/*.mlir", - "**/*.td", - ]) -] diff --git a/utils/bazel/llvm-project-overlay/mlir/test/python/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/test/python/BUILD.bazel deleted file mode 100644 index 74eaa33a2faa2b..00000000000000 --- a/utils/bazel/llvm-project-overlay/mlir/test/python/BUILD.bazel +++ /dev/null @@ -1,10 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -licenses(["notice"]) - -exports_files( - srcs = ["python_test_ops.td"], - visibility = ["//visibility:public"], -) diff --git a/utils/bazel/llvm-project-overlay/mlir/unittests/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/unittests/BUILD.bazel deleted file mode 100644 index a749a11096c372..00000000000000 --- a/utils/bazel/llvm-project-overlay/mlir/unittests/BUILD.bazel +++ /dev/null @@ -1,460 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -load("//mlir:tblgen.bzl", "gentbl_cc_library") - -package( - default_visibility = ["//visibility:public"], - features = ["layering_check"], -) - -licenses(["notice"]) - -cc_test( - name = "debug_tests", - size = "small", - srcs = glob([ - "Debug/*.cpp", - "Debug/*.h", - ]), - deps = [ - "//llvm:Support", - "//llvm:TestingSupport", - "//mlir:Debug", - "//mlir:IR", - "//mlir:Support", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "ir_tests", - size = "small", - srcs = glob([ - "IR/*.cpp", - "IR/*.h", - ]), - deps = [ - "//llvm:Support", - "//mlir:BytecodeReader", - "//mlir:FunctionInterfaces", - "//mlir:IR", - "//mlir:Parser", - "//mlir:Support", - "//mlir/test:TestDialect", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "interface_tests", - size = "small", - srcs = glob([ - "Interfaces/*.cpp", - "Interfaces/*.h", - ]), - deps = [ - "//llvm:Support", - "//llvm:TestingSupport", - "//mlir:BytecodeReader", - "//mlir:ArithDialect", - "//mlir:ControlFlowInterfaces", - "//mlir:DLTIDialect", - "//mlir:DataLayoutInterfaces", - "//mlir:FuncDialect", - "//mlir:IR", - "//mlir:InferIntRangeInterface", - "//mlir:InferTypeOpInterface", - "//mlir:Parser", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "support_tests", - size = "small", - srcs = glob([ - "Support/*.cpp", - "Support/*.h", - ]), - deps = [ - "//llvm:Support", - "//llvm:TestingSupport", - "//mlir:Support", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "pass_tests", - size = "small", - srcs = glob([ - "Pass/*.cpp", - "Pass/*.h", - ]), - deps = [ - "//llvm:Support", - "//llvm:TestingSupport", - "//mlir:Analysis", - "//mlir:Debug", - "//mlir:FuncDialect", - "//mlir:IR", - "//mlir:Pass", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "rewrite_tests", - size = "small", - srcs = glob([ - "Rewrite/*.cpp", - "Rewrite/*.h", - ]), - deps = [ - "//mlir:IR", - "//mlir:Rewrite", - "//mlir:SideEffectInterfaces", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "dialect_tests", - size = "small", - srcs = glob([ - "Dialect/*.cpp", - "Dialect/*.h", - ]), - deps = [ - "//llvm:Support", - "//mlir:Dialect", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "memref_tests", - size = "small", - srcs = glob([ - "Dialect/MemRef/*.cpp", - "Dialect/MemRef/*.h", - ]), - deps = [ - "//llvm:TestingSupport", - "//mlir:IR", - "//mlir:MemRefDialect", - "//mlir:SideEffectInterfaces", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "quantops_tests", - size = "small", - srcs = glob([ - "Dialect/Quant/*.cpp", - "Dialect/Quant/*.h", - ]), - deps = [ - "//llvm:TestingSupport", - "//mlir:QuantOps", - "//mlir:Transforms", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "scf_tests", - size = "small", - srcs = glob([ - "Dialect/SCF/*.cpp", - "Dialect/SCF/*.h", - ]), - deps = [ - "//mlir:ArithDialect", - "//mlir:FuncDialect", - "//mlir:IR", - "//mlir:Parser", - "//mlir:SCFDialect", - "//mlir:SideEffectInterfaces", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "sparse_tensor_tests", - size = "small", - srcs = glob([ - "Dialect/SparseTensor/*.cpp", - "Dialect/SparseTensor/*.h", - ]), - deps = [ - "//llvm:Support", - "//llvm:TestingSupport", - "//mlir:SideEffectInterfaces", - "//mlir:SparseTensorUtils", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "spirv_tests", - size = "small", - srcs = glob([ - "Dialect/SPIRV/*.cpp", - "Dialect/SPIRV/*.h", - ]), - deps = [ - "//llvm:Support", - "//llvm:TestingSupport", - "//mlir:IR", - "//mlir:SPIRVBinaryUtils", - "//mlir:SPIRVDeserialization", - "//mlir:SPIRVDialect", - "//mlir:SPIRVSerialization", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "transform_dialect_tests", - size = "small", - srcs = glob([ - "Dialect/Transform/*.cpp", - "Dialect/Transform/*.h", - ]), - deps = [ - "//llvm:Support", - "//llvm:TestingSupport", - "//mlir:BytecodeReader", - "//mlir:FuncDialect", - "//mlir:IR", - "//mlir:MlirOptLib", - "//mlir:Parser", - "//mlir:Pass", - "//mlir:Support", - "//mlir:TransformDebugExtension", - "//mlir:TransformDialect", - "//mlir:TransformDialectTransforms", - "//mlir/test:TestTransformDialect", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "dialect_utils_tests", - size = "small", - srcs = glob([ - "Dialect/Utils/*.cpp", - "Dialect/Utils/*.h", - ]), - deps = [ - "//llvm:Support", - "//llvm:TestingSupport", - "//mlir:DialectUtils", - "//mlir:IR", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -gentbl_cc_library( - name = "EnumsIncGen", - tbl_outs = [ - ( - ["-gen-enum-decls"], - "TableGen/EnumsGenTest.h.inc", - ), - ( - ["-gen-enum-defs"], - "TableGen/EnumsGenTest.cpp.inc", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "TableGen/enums.td", - deps = [ - "//mlir:OpBaseTdFiles", - ], -) - -gentbl_cc_library( - name = "PassIncGen", - tbl_outs = [ - ( - ["-gen-pass-decls"], - "TableGen/PassGenTest.h.inc", - ), - ], - tblgen = "//mlir:mlir-tblgen", - td_file = "TableGen/passes.td", - deps = [ - "//mlir:PassBaseTdFiles", - "//mlir:RewritePassBaseTdFiles", - ], -) - -cc_test( - name = "tablegen_tests", - size = "small", - srcs = glob([ - "TableGen/*.cpp", - "TableGen/*.h", - ]) + [ - "TableGen/EnumsGenTest.cpp.inc", - "TableGen/EnumsGenTest.h.inc", - ], - includes = ["TableGen/"], - deps = [ - ":EnumsIncGen", - ":PassIncGen", - "//llvm:Support", - "//llvm:TestingSupport", - "//mlir:IR", - "//mlir:Pass", - "//mlir:Support", - "//mlir:TableGen", - "//mlir/test:TestDialect", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "transforms_test", - size = "small", - srcs = glob([ - "Transforms/*.cpp", - "Transforms/*.h", - ]), - deps = [ - "//mlir:AffineAnalysis", - "//mlir:BytecodeReader", - "//mlir:IR", - "//mlir:Parser", - "//mlir:Pass", - "//mlir:SideEffectInterfaces", - "//mlir:TransformUtils", - "//mlir:Transforms", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "analysis_tests", - size = "small", - srcs = glob([ - "Analysis/*.cpp", - "Analysis/*.h", - "Analysis/*/*.cpp", - "Analysis/*/*.h", - ]), - deps = [ - "//llvm:TestingSupport", - "//mlir:AffineAnalysis", - "//mlir:Analysis", - "//mlir:AsmParser", - "//mlir:IR", - "//mlir:Parser", - "//mlir:Support", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "bytecode_tests", - size = "small", - srcs = glob([ - "Bytecode/*.cpp", - "Bytecode/*.h", - "Bytecode/*/*.cpp", - "Bytecode/*/*.h", - ]), - deps = [ - "//llvm:Support", - "//mlir:BytecodeReader", - "//mlir:BytecodeWriter", - "//mlir:IR", - "//mlir:Parser", - "//mlir:SideEffectInterfaces", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "conversion_tests", - size = "small", - srcs = glob([ - "Conversion/*.cpp", - "Conversion/*.h", - "Conversion/*/*.cpp", - "Conversion/*/*.h", - ]), - deps = [ - "//mlir:ArithDialect", - "//mlir:IR", - "//mlir:PDLToPDLInterp", - "//third-party/unittest:gtest", - "//third-party/unittest:gtest_main", - ], -) - -cc_test( - name = "execution_engine_tests", - size = "small", - srcs = glob([ - "ExecutionEngine/*.cpp", - ]), - tags = [ - # MSAN does not work with JIT. - "nomsan", - ], - deps = [ - "//llvm:Support", - "//llvm:TestingSupport", - "//mlir:AllPassesAndDialects", - "//mlir:Analysis", - "//mlir:ArithToLLVM", - "//mlir:BuiltinToLLVMIRTranslation", - "//mlir:BytecodeReader", - "//mlir:ExecutionEngine", - "//mlir:FuncDialect", - "//mlir:FuncToLLVM", - "//mlir:IR", - "//mlir:LLVMToLLVMIRTranslation", - "//mlir:LinalgTransforms", - "//mlir:MemRefToLLVM", - "//mlir:Parser", - "//mlir:Pass", - "//mlir:ReconcileUnrealizedCasts", - "//mlir:ToLLVMIRTranslation", - "//mlir:VectorToLLVM", - "//mlir:VectorToSCF", - "//mlir:mlir_c_runner_utils", - "//mlir:mlir_runner_utils", - "//third-party/unittest:gmock", - "//third-party/unittest:gtest_main", - ], -) diff --git a/utils/bazel/llvm-project-overlay/third-party/unittest/BUILD.bazel b/utils/bazel/llvm-project-overlay/third-party/unittest/BUILD.bazel deleted file mode 100644 index 0b5c084086ed93..00000000000000 --- a/utils/bazel/llvm-project-overlay/third-party/unittest/BUILD.bazel +++ /dev/null @@ -1,113 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) - -exports_files(["LICENSE.TXT"]) - -# It may be tempting to add compiler flags here, but that should be avoided. -# The necessary warnings and other compile flags should be provided by the -# toolchain or the `.bazelrc` file. This is just a workaround until we have a -# widely available feature to enable unlimited stack frame instead of using -# this `Make` variable. -llvm_copts = [ - "$(STACK_FRAME_UNLIMITED)", -] - -# A hacky library to expose some internal headers of gtest to its own -# implementation source files using a stripped include prefix rather than -# file-relative-inclusion. -# -# FIXME: This file should be in `textual_hdrs` instead of `hdrs`, but -# unfortunately that doesn't work with `strip_include_prefix`: -# https://github.com/bazelbuild/bazel/issues/12424 -# -# For now, simply disable parsing and header modules. -cc_library( - name = "gtest_internal_headers", - testonly = True, - hdrs = ["googletest/src/gtest-internal-inl.h"], - features = [ - "-parse_headers", - "-header_modules", - ], - strip_include_prefix = "googletest", -) - -cc_library( - name = "gtest", - testonly = True, - srcs = glob( - [ - "googletest/include/**/*.h", - "googletest/src/*.cc", - ], - exclude = [ - "googletest/src/gtest-all.cc", - "googletest/include/gtest/gtest_pred_impl.h", - ], - ) + [ - ], - hdrs = [ - "googletest/include/gtest/gtest.h", - "googletest/include/gtest/gtest-spi.h", - "googletest/include/gtest/internal/gtest-port.h", - ], - copts = llvm_copts, - defines = [ - "GTEST_HAS_RTTI=0", - "__STDC_LIMIT_MACROS", - "__STDC_CONSTANT_MACROS", - ] + select({ - "@platforms//os:windows": ["GTEST_USE_OWN_TR1_TUPLE=0"], - "//conditions:default": ["GTEST_USE_OWN_TR1_TUPLE=1"], - }), - includes = [ - "googletest/include", - "include", - ], - textual_hdrs = [ - "googletest/include/gtest/gtest_pred_impl.h", - ], - deps = [ - ":gtest_internal_headers", - "//llvm:Support", - ], -) - -cc_library( - name = "gtest_main", - testonly = True, - srcs = ["UnitTestMain/TestMain.cpp"], - copts = llvm_copts, - deps = [ - ":gmock", - ":gtest", - "//llvm:Support", - ], -) - -cc_library( - name = "gmock", - testonly = True, - srcs = glob( - [ - "googlemock/include/**/*.h", - "googlemock/src/*.cc", - ], - exclude = ["googlemock/src/gmock-all.cc"], - ), - hdrs = [ - "googlemock/include/gmock/gmock.h", - "googlemock/include/gmock/gmock-matchers.h", - ], - copts = llvm_copts, - includes = [ - "googlemock/include", - "include", - ], - deps = [":gtest"], -) diff --git a/utils/bazel/llvm-project-overlay/workspace_root.bzl b/utils/bazel/llvm-project-overlay/workspace_root.bzl deleted file mode 100644 index 2932fb143cefc8..00000000000000 --- a/utils/bazel/llvm-project-overlay/workspace_root.bzl +++ /dev/null @@ -1,17 +0,0 @@ -def _workspace_root_impl(ctx): - """Dynamically determine the workspace root from the current context. - - The path is made available as a `WORKSPACE_ROOT` environmment variable and - may for instance be consumed in the `toolchains` attributes for `cc_library` - and `genrule` targets. - """ - return [ - platform_common.TemplateVariableInfo({ - "WORKSPACE_ROOT": ctx.label.workspace_root, - }), - ] - -workspace_root = rule( - implementation = _workspace_root_impl, - attrs = {}, -) diff --git a/utils/bazel/llvm_configs/BUILD.bazel b/utils/bazel/llvm_configs/BUILD.bazel deleted file mode 100644 index 5a4f9970c06368..00000000000000 --- a/utils/bazel/llvm_configs/BUILD.bazel +++ /dev/null @@ -1,30 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# These diff tests ensure that the current Bazel configuration does not drift -# from the configuration in the .cmake files, since we don't alway use them -# directly (and even if we did we wouldn't necessarily pick up changes there). -# These are literal change-detector tests. We perform diff testing here since -# it isn't really part of building LLVM and we don't want to include the config -# copies in the workspace used by dependent projects. - -load("@bazel_skylib//rules:diff_test.bzl", "diff_test") - -diff_test( - name = "diff_config.h.cmake", - file1 = "@llvm-project//llvm:include/llvm/Config/config.h.cmake", - file2 = "config.h.cmake", -) - -diff_test( - name = "diff_llvm-config.h.cmake", - file1 = "@llvm-project//llvm:include/llvm/Config/llvm-config.h.cmake", - file2 = "llvm-config.h.cmake", -) - -diff_test( - name = "diff_abi-breaking.h.cmake", - file1 = "@llvm-project//llvm:include/llvm/Config/abi-breaking.h.cmake", - file2 = "abi-breaking.h.cmake", -) diff --git a/utils/bazel/llvm_configs/abi-breaking.h.cmake b/utils/bazel/llvm_configs/abi-breaking.h.cmake deleted file mode 100644 index 2d27e02b1d5457..00000000000000 --- a/utils/bazel/llvm_configs/abi-breaking.h.cmake +++ /dev/null @@ -1,62 +0,0 @@ -/*===------- llvm/Config/abi-breaking.h - llvm configuration -------*- C -*-===*/ -/* */ -/* Part of the LLVM Project, under the Apache License v2.0 with LLVM */ -/* Exceptions. */ -/* See https://llvm.org/LICENSE.txt for license information. */ -/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ -/* */ -/*===----------------------------------------------------------------------===*/ - -/* This file controls the C++ ABI break introduced in LLVM public header. */ - -#ifndef LLVM_ABI_BREAKING_CHECKS_H -#define LLVM_ABI_BREAKING_CHECKS_H - -/* Define to enable checks that alter the LLVM C++ ABI */ -#cmakedefine01 LLVM_ENABLE_ABI_BREAKING_CHECKS - -/* Define to enable reverse iteration of unordered llvm containers */ -#cmakedefine01 LLVM_ENABLE_REVERSE_ITERATION - -/* Allow selectively disabling link-time mismatch checking so that header-only - ADT content from LLVM can be used without linking libSupport. */ -#if !defined(LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING) || !LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING - -// ABI_BREAKING_CHECKS protection: provides link-time failure when clients build -// mismatch with LLVM -#if defined(_MSC_VER) -// Use pragma with MSVC -#define LLVM_XSTR(s) LLVM_STR(s) -#define LLVM_STR(s) #s -#pragma detect_mismatch("LLVM_ENABLE_ABI_BREAKING_CHECKS", LLVM_XSTR(LLVM_ENABLE_ABI_BREAKING_CHECKS)) -#undef LLVM_XSTR -#undef LLVM_STR -#elif defined(_WIN32) || defined(__CYGWIN__) // Win32 w/o #pragma detect_mismatch -// FIXME: Implement checks without weak. -#elif defined(__cplusplus) -#if !(defined(_AIX) && defined(__GNUC__) && !defined(__clang__)) -#define LLVM_HIDDEN_VISIBILITY __attribute__ ((visibility("hidden"))) -#else -// GCC on AIX does not support visibility attributes. Symbols are not -// exported by default on AIX. -#define LLVM_HIDDEN_VISIBILITY -#endif -namespace llvm { -#if LLVM_ENABLE_ABI_BREAKING_CHECKS -extern int EnableABIBreakingChecks; -LLVM_HIDDEN_VISIBILITY -__attribute__((weak)) int *VerifyEnableABIBreakingChecks = - &EnableABIBreakingChecks; -#else -extern int DisableABIBreakingChecks; -LLVM_HIDDEN_VISIBILITY -__attribute__((weak)) int *VerifyDisableABIBreakingChecks = - &DisableABIBreakingChecks; -#endif -} -#undef LLVM_HIDDEN_VISIBILITY -#endif // _MSC_VER - -#endif // LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING - -#endif diff --git a/utils/bazel/llvm_configs/config.h.cmake b/utils/bazel/llvm_configs/config.h.cmake deleted file mode 100644 index fc1f9bf342f8d5..00000000000000 --- a/utils/bazel/llvm_configs/config.h.cmake +++ /dev/null @@ -1,336 +0,0 @@ -#ifndef CONFIG_H -#define CONFIG_H - -// Include this header only under the llvm source tree. -// This is a private header. - -/* Exported configuration */ -#include "llvm/Config/llvm-config.h" - -/* Bug report URL. */ -#define BUG_REPORT_URL "${BUG_REPORT_URL}" - -/* Define to 1 to enable backtraces, and to 0 otherwise. */ -#cmakedefine01 ENABLE_BACKTRACES - -/* Define to 1 to enable crash overrides, and to 0 otherwise. */ -#cmakedefine01 ENABLE_CRASH_OVERRIDES - -/* Define to 1 to enable crash memory dumps, and to 0 otherwise. */ -#cmakedefine01 LLVM_ENABLE_CRASH_DUMPS - -/* Define to 1 to prefer forward slashes on Windows, and to 0 prefer - backslashes. */ -#cmakedefine01 LLVM_WINDOWS_PREFER_FORWARD_SLASH - -/* Define to 1 if you have the `backtrace' function. */ -#cmakedefine HAVE_BACKTRACE ${HAVE_BACKTRACE} - -#define BACKTRACE_HEADER <${BACKTRACE_HEADER}> - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_CRASHREPORTERCLIENT_H - -/* can use __crashreporter_info__ */ -#cmakedefine01 HAVE_CRASHREPORTER_INFO - -/* Define to 1 if you have the declaration of `arc4random', and to 0 if you - don't. */ -#cmakedefine01 HAVE_DECL_ARC4RANDOM - -/* Define to 1 if you have the declaration of `FE_ALL_EXCEPT', and to 0 if you - don't. */ -#cmakedefine01 HAVE_DECL_FE_ALL_EXCEPT - -/* Define to 1 if you have the declaration of `FE_INEXACT', and to 0 if you - don't. */ -#cmakedefine01 HAVE_DECL_FE_INEXACT - -/* Define to 1 if you have the declaration of `strerror_s', and to 0 if you - don't. */ -#cmakedefine01 HAVE_DECL_STRERROR_S - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_DLFCN_H ${HAVE_DLFCN_H} - -/* Define if dlopen() is available on this platform. */ -#cmakedefine HAVE_DLOPEN ${HAVE_DLOPEN} - -/* Define if dladdr() is available on this platform. */ -#cmakedefine HAVE_DLADDR ${HAVE_DLADDR} - -/* Define to 1 if we can register EH frames on this platform. */ -#cmakedefine HAVE_REGISTER_FRAME ${HAVE_REGISTER_FRAME} - -/* Define to 1 if we can deregister EH frames on this platform. */ -#cmakedefine HAVE_DEREGISTER_FRAME ${HAVE_DEREGISTER_FRAME} - -/* Define if __unw_add_dynamic_fde() is available on this platform. */ -#cmakedefine HAVE_UNW_ADD_DYNAMIC_FDE ${HAVE_UNW_ADD_DYNAMIC_FDE} - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_ERRNO_H ${HAVE_ERRNO_H} - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_FCNTL_H ${HAVE_FCNTL_H} - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_FENV_H ${HAVE_FENV_H} - -/* Define if libffi is available on this platform. */ -#cmakedefine HAVE_FFI_CALL ${HAVE_FFI_CALL} - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_FFI_FFI_H ${HAVE_FFI_FFI_H} - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_FFI_H ${HAVE_FFI_H} - -/* Define to 1 if you have the `futimens' function. */ -#cmakedefine HAVE_FUTIMENS ${HAVE_FUTIMENS} - -/* Define to 1 if you have the `futimes' function. */ -#cmakedefine HAVE_FUTIMES ${HAVE_FUTIMES} - -/* Define to 1 if you have the `getpagesize' function. */ -#cmakedefine HAVE_GETPAGESIZE ${HAVE_GETPAGESIZE} - -/* Define to 1 if you have the `getrlimit' function. */ -#cmakedefine HAVE_GETRLIMIT ${HAVE_GETRLIMIT} - -/* Define to 1 if you have the `getrusage' function. */ -#cmakedefine HAVE_GETRUSAGE ${HAVE_GETRUSAGE} - -/* Define to 1 if you have the `isatty' function. */ -#cmakedefine HAVE_ISATTY 1 - -/* Define to 1 if you have the `edit' library (-ledit). */ -#cmakedefine HAVE_LIBEDIT ${HAVE_LIBEDIT} - -/* Define to 1 if you have the `pfm' library (-lpfm). */ -#cmakedefine HAVE_LIBPFM ${HAVE_LIBPFM} - -/* Define to 1 if the `perf_branch_entry' struct has field cycles. */ -#cmakedefine LIBPFM_HAS_FIELD_CYCLES ${LIBPFM_HAS_FIELD_CYCLES} - -/* Define to 1 if you have the `psapi' library (-lpsapi). */ -#cmakedefine HAVE_LIBPSAPI ${HAVE_LIBPSAPI} - -/* Define to 1 if you have the `pthread' library (-lpthread). */ -#cmakedefine HAVE_LIBPTHREAD ${HAVE_LIBPTHREAD} - -/* Define to 1 if you have the `pthread_getname_np' function. */ -#cmakedefine HAVE_PTHREAD_GETNAME_NP ${HAVE_PTHREAD_GETNAME_NP} - -/* Define to 1 if you have the `pthread_setname_np' function. */ -#cmakedefine HAVE_PTHREAD_SETNAME_NP ${HAVE_PTHREAD_SETNAME_NP} - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_LINK_H ${HAVE_LINK_H} - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_MACH_MACH_H ${HAVE_MACH_MACH_H} - -/* Define to 1 if you have the `mallctl' function. */ -#cmakedefine HAVE_MALLCTL ${HAVE_MALLCTL} - -/* Define to 1 if you have the `mallinfo' function. */ -#cmakedefine HAVE_MALLINFO ${HAVE_MALLINFO} - -/* Define to 1 if you have the `mallinfo2' function. */ -#cmakedefine HAVE_MALLINFO2 ${HAVE_MALLINFO2} - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_MALLOC_MALLOC_H ${HAVE_MALLOC_MALLOC_H} - -/* Define to 1 if you have the `malloc_zone_statistics' function. */ -#cmakedefine HAVE_MALLOC_ZONE_STATISTICS ${HAVE_MALLOC_ZONE_STATISTICS} - -/* Define to 1 if you have the `posix_spawn' function. */ -#cmakedefine HAVE_POSIX_SPAWN ${HAVE_POSIX_SPAWN} - -/* Define to 1 if you have the `pread' function. */ -#cmakedefine HAVE_PREAD ${HAVE_PREAD} - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_PTHREAD_H ${HAVE_PTHREAD_H} - -/* Have pthread_mutex_lock */ -#cmakedefine HAVE_PTHREAD_MUTEX_LOCK ${HAVE_PTHREAD_MUTEX_LOCK} - -/* Have pthread_rwlock_init */ -#cmakedefine HAVE_PTHREAD_RWLOCK_INIT ${HAVE_PTHREAD_RWLOCK_INIT} - -/* Define to 1 if you have the `sbrk' function. */ -#cmakedefine HAVE_SBRK ${HAVE_SBRK} - -/* Define to 1 if you have the `setenv' function. */ -#cmakedefine HAVE_SETENV ${HAVE_SETENV} - -/* Define to 1 if you have the `setrlimit' function. */ -#cmakedefine HAVE_SETRLIMIT ${HAVE_SETRLIMIT} - -/* Define to 1 if you have the `sigaltstack' function. */ -#cmakedefine HAVE_SIGALTSTACK ${HAVE_SIGALTSTACK} - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SIGNAL_H ${HAVE_SIGNAL_H} - -/* Define to 1 if you have the `strerror_r' function. */ -#cmakedefine HAVE_STRERROR_R ${HAVE_STRERROR_R} - -/* Define to 1 if you have the `sysconf' function. */ -#cmakedefine HAVE_SYSCONF ${HAVE_SYSCONF} - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_IOCTL_H ${HAVE_SYS_IOCTL_H} - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_MMAN_H ${HAVE_SYS_MMAN_H} - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_PARAM_H ${HAVE_SYS_PARAM_H} - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_RESOURCE_H ${HAVE_SYS_RESOURCE_H} - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_STAT_H ${HAVE_SYS_STAT_H} - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_TIME_H ${HAVE_SYS_TIME_H} - -/* Define to 1 if stat struct has st_mtimespec member .*/ -#cmakedefine HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC ${HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC} - -/* Define to 1 if stat struct has st_mtim member. */ -#cmakedefine HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC ${HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC} - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_TYPES_H ${HAVE_SYS_TYPES_H} - -/* Define if the setupterm() function is supported this platform. */ -#cmakedefine LLVM_ENABLE_TERMINFO ${LLVM_ENABLE_TERMINFO} - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_TERMIOS_H ${HAVE_TERMIOS_H} - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_UNISTD_H ${HAVE_UNISTD_H} - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_VALGRIND_VALGRIND_H ${HAVE_VALGRIND_VALGRIND_H} - -/* Have host's _alloca */ -#cmakedefine HAVE__ALLOCA ${HAVE__ALLOCA} - -/* Define to 1 if you have the `_chsize_s' function. */ -#cmakedefine HAVE__CHSIZE_S ${HAVE__CHSIZE_S} - -/* Define to 1 if you have the `_Unwind_Backtrace' function. */ -#cmakedefine HAVE__UNWIND_BACKTRACE ${HAVE__UNWIND_BACKTRACE} - -/* Have host's __alloca */ -#cmakedefine HAVE___ALLOCA ${HAVE___ALLOCA} - -/* Have host's __ashldi3 */ -#cmakedefine HAVE___ASHLDI3 ${HAVE___ASHLDI3} - -/* Have host's __ashrdi3 */ -#cmakedefine HAVE___ASHRDI3 ${HAVE___ASHRDI3} - -/* Have host's __chkstk */ -#cmakedefine HAVE___CHKSTK ${HAVE___CHKSTK} - -/* Have host's __chkstk_ms */ -#cmakedefine HAVE___CHKSTK_MS ${HAVE___CHKSTK_MS} - -/* Have host's __cmpdi2 */ -#cmakedefine HAVE___CMPDI2 ${HAVE___CMPDI2} - -/* Have host's __divdi3 */ -#cmakedefine HAVE___DIVDI3 ${HAVE___DIVDI3} - -/* Have host's __fixdfdi */ -#cmakedefine HAVE___FIXDFDI ${HAVE___FIXDFDI} - -/* Have host's __fixsfdi */ -#cmakedefine HAVE___FIXSFDI ${HAVE___FIXSFDI} - -/* Have host's __floatdidf */ -#cmakedefine HAVE___FLOATDIDF ${HAVE___FLOATDIDF} - -/* Have host's __lshrdi3 */ -#cmakedefine HAVE___LSHRDI3 ${HAVE___LSHRDI3} - -/* Have host's __main */ -#cmakedefine HAVE___MAIN ${HAVE___MAIN} - -/* Have host's __moddi3 */ -#cmakedefine HAVE___MODDI3 ${HAVE___MODDI3} - -/* Have host's __udivdi3 */ -#cmakedefine HAVE___UDIVDI3 ${HAVE___UDIVDI3} - -/* Have host's __umoddi3 */ -#cmakedefine HAVE___UMODDI3 ${HAVE___UMODDI3} - -/* Have host's ___chkstk */ -#cmakedefine HAVE____CHKSTK ${HAVE____CHKSTK} - -/* Have host's ___chkstk_ms */ -#cmakedefine HAVE____CHKSTK_MS ${HAVE____CHKSTK_MS} - -/* Linker version detected at compile time. */ -#cmakedefine HOST_LINK_VERSION "${HOST_LINK_VERSION}" - -/* Define if overriding target triple is enabled */ -#cmakedefine LLVM_TARGET_TRIPLE_ENV "${LLVM_TARGET_TRIPLE_ENV}" - -/* Whether tools show host and target info when invoked with --version */ -#cmakedefine01 LLVM_VERSION_PRINTER_SHOW_HOST_TARGET_INFO - -/* Define if libxml2 is supported on this platform. */ -#cmakedefine LLVM_ENABLE_LIBXML2 ${LLVM_ENABLE_LIBXML2} - -/* Define to the extension used for shared libraries, say, ".so". */ -#cmakedefine LTDL_SHLIB_EXT "${LTDL_SHLIB_EXT}" - -/* Define to the extension used for plugin libraries, say, ".so". */ -#cmakedefine LLVM_PLUGIN_EXT "${LLVM_PLUGIN_EXT}" - -/* Define to the address where bug reports for this package should be sent. */ -#cmakedefine PACKAGE_BUGREPORT "${PACKAGE_BUGREPORT}" - -/* Define to the full name of this package. */ -#cmakedefine PACKAGE_NAME "${PACKAGE_NAME}" - -/* Define to the full name and version of this package. */ -#cmakedefine PACKAGE_STRING "${PACKAGE_STRING}" - -/* Define to the version of this package. */ -#cmakedefine PACKAGE_VERSION "${PACKAGE_VERSION}" - -/* Define to the vendor of this package. */ -#cmakedefine PACKAGE_VENDOR "${PACKAGE_VENDOR}" - -/* Define to a function implementing stricmp */ -#cmakedefine stricmp ${stricmp} - -/* Define to a function implementing strdup */ -#cmakedefine strdup ${strdup} - -/* Whether GlobalISel rule coverage is being collected */ -#cmakedefine01 LLVM_GISEL_COV_ENABLED - -/* Define to the default GlobalISel coverage file prefix */ -#cmakedefine LLVM_GISEL_COV_PREFIX "${LLVM_GISEL_COV_PREFIX}" - -/* Whether Timers signpost passes in Xcode Instruments */ -#cmakedefine01 LLVM_SUPPORT_XCODE_SIGNPOSTS - -#cmakedefine HAVE_PROC_PID_RUSAGE 1 - -#cmakedefine HAVE_BUILTIN_THREAD_POINTER ${HAVE_BUILTIN_THREAD_POINTER} - -#endif diff --git a/utils/bazel/llvm_configs/llvm-config.h.cmake b/utils/bazel/llvm_configs/llvm-config.h.cmake deleted file mode 100644 index 6605ea60df99e1..00000000000000 --- a/utils/bazel/llvm_configs/llvm-config.h.cmake +++ /dev/null @@ -1,201 +0,0 @@ -/*===------- llvm/Config/llvm-config.h - llvm configuration -------*- C -*-===*/ -/* */ -/* Part of the LLVM Project, under the Apache License v2.0 with LLVM */ -/* Exceptions. */ -/* See https://llvm.org/LICENSE.txt for license information. */ -/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ -/* */ -/*===----------------------------------------------------------------------===*/ - -/* This file enumerates variables from the LLVM configuration so that they - can be in exported headers and won't override package specific directives. - This is a C header that can be included in the llvm-c headers. */ - -#ifndef LLVM_CONFIG_H -#define LLVM_CONFIG_H - -/* Define if LLVM_ENABLE_DUMP is enabled */ -#cmakedefine LLVM_ENABLE_DUMP - -/* Target triple LLVM will generate code for by default */ -/* Doesn't use `cmakedefine` because it is allowed to be empty. */ -#define LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}" - -/* Define if threads enabled */ -#cmakedefine01 LLVM_ENABLE_THREADS - -/* Has gcc/MSVC atomic intrinsics */ -#cmakedefine01 LLVM_HAS_ATOMICS - -/* Host triple LLVM will be executed on */ -#cmakedefine LLVM_HOST_TRIPLE "${LLVM_HOST_TRIPLE}" - -/* LLVM architecture name for the native architecture, if available */ -#cmakedefine LLVM_NATIVE_ARCH ${LLVM_NATIVE_ARCH} - -/* LLVM name for the native AsmParser init function, if available */ -#cmakedefine LLVM_NATIVE_ASMPARSER LLVMInitialize${LLVM_NATIVE_ARCH}AsmParser - -/* LLVM name for the native AsmPrinter init function, if available */ -#cmakedefine LLVM_NATIVE_ASMPRINTER LLVMInitialize${LLVM_NATIVE_ARCH}AsmPrinter - -/* LLVM name for the native Disassembler init function, if available */ -#cmakedefine LLVM_NATIVE_DISASSEMBLER LLVMInitialize${LLVM_NATIVE_ARCH}Disassembler - -/* LLVM name for the native Target init function, if available */ -#cmakedefine LLVM_NATIVE_TARGET LLVMInitialize${LLVM_NATIVE_ARCH}Target - -/* LLVM name for the native TargetInfo init function, if available */ -#cmakedefine LLVM_NATIVE_TARGETINFO LLVMInitialize${LLVM_NATIVE_ARCH}TargetInfo - -/* LLVM name for the native target MC init function, if available */ -#cmakedefine LLVM_NATIVE_TARGETMC LLVMInitialize${LLVM_NATIVE_ARCH}TargetMC - -/* LLVM name for the native target MCA init function, if available */ -#cmakedefine LLVM_NATIVE_TARGETMCA LLVMInitialize${LLVM_NATIVE_ARCH}TargetMCA - -/* Define if the AArch64 target is built in */ -#cmakedefine01 LLVM_HAS_AARCH64_TARGET - -/* Define if the AMDGPU target is built in */ -#cmakedefine01 LLVM_HAS_AMDGPU_TARGET - -/* Define if the ARC target is built in */ -#cmakedefine01 LLVM_HAS_ARC_TARGET - -/* Define if the ARM target is built in */ -#cmakedefine01 LLVM_HAS_ARM_TARGET - -/* Define if the AVR target is built in */ -#cmakedefine01 LLVM_HAS_AVR_TARGET - -/* Define if the BPF target is built in */ -#cmakedefine01 LLVM_HAS_BPF_TARGET - -/* Define if the CSKY target is built in */ -#cmakedefine01 LLVM_HAS_CSKY_TARGET - -/* Define if the DirectX target is built in */ -#cmakedefine01 LLVM_HAS_DIRECTX_TARGET - -/* Define if the Hexagon target is built in */ -#cmakedefine01 LLVM_HAS_HEXAGON_TARGET - -/* Define if the Lanai target is built in */ -#cmakedefine01 LLVM_HAS_LANAI_TARGET - -/* Define if the LoongArch target is built in */ -#cmakedefine01 LLVM_HAS_LOONGARCH_TARGET - -/* Define if the M68k target is built in */ -#cmakedefine01 LLVM_HAS_M68K_TARGET - -/* Define if the Mips target is built in */ -#cmakedefine01 LLVM_HAS_MIPS_TARGET - -/* Define if the MSP430 target is built in */ -#cmakedefine01 LLVM_HAS_MSP430_TARGET - -/* Define if the NVPTX target is built in */ -#cmakedefine01 LLVM_HAS_NVPTX_TARGET - -/* Define if the PowerPC target is built in */ -#cmakedefine01 LLVM_HAS_POWERPC_TARGET - -/* Define if the RISCV target is built in */ -#cmakedefine01 LLVM_HAS_RISCV_TARGET - -/* Define if the Sparc target is built in */ -#cmakedefine01 LLVM_HAS_SPARC_TARGET - -/* Define if the SPIRV target is built in */ -#cmakedefine01 LLVM_HAS_SPIRV_TARGET - -/* Define if the SystemZ target is built in */ -#cmakedefine01 LLVM_HAS_SYSTEMZ_TARGET - -/* Define if the VE target is built in */ -#cmakedefine01 LLVM_HAS_VE_TARGET - -/* Define if the WebAssembly target is built in */ -#cmakedefine01 LLVM_HAS_WEBASSEMBLY_TARGET - -/* Define if the X86 target is built in */ -#cmakedefine01 LLVM_HAS_X86_TARGET - -/* Define if the XCore target is built in */ -#cmakedefine01 LLVM_HAS_XCORE_TARGET - -/* Define if the Xtensa target is built in */ -#cmakedefine01 LLVM_HAS_XTENSA_TARGET - -/* Define if this is Unixish platform */ -#cmakedefine LLVM_ON_UNIX ${LLVM_ON_UNIX} - -/* Define if we have the Intel JIT API runtime support library */ -#cmakedefine01 LLVM_USE_INTEL_JITEVENTS - -/* Define if we have the oprofile JIT-support library */ -#cmakedefine01 LLVM_USE_OPROFILE - -/* Define if we have the perf JIT-support library */ -#cmakedefine01 LLVM_USE_PERF - -/* Major version of the LLVM API */ -#define LLVM_VERSION_MAJOR ${LLVM_VERSION_MAJOR} - -/* Minor version of the LLVM API */ -#define LLVM_VERSION_MINOR ${LLVM_VERSION_MINOR} - -/* Patch version of the LLVM API */ -#define LLVM_VERSION_PATCH ${LLVM_VERSION_PATCH} - -/* LLVM version string */ -#define LLVM_VERSION_STRING "${PACKAGE_VERSION}" - -/* Whether LLVM records statistics for use with GetStatistics(), - * PrintStatistics() or PrintStatisticsJSON() - */ -#cmakedefine01 LLVM_FORCE_ENABLE_STATS - -/* Define if we have z3 and want to build it */ -#cmakedefine LLVM_WITH_Z3 ${LLVM_WITH_Z3} - -/* Define if we have curl and want to use it */ -#cmakedefine LLVM_ENABLE_CURL ${LLVM_ENABLE_CURL} - -/* Define if we have cpp-httplib and want to use it */ -#cmakedefine LLVM_ENABLE_HTTPLIB ${LLVM_ENABLE_HTTPLIB} - -/* Define if zlib compression is available */ -#cmakedefine01 LLVM_ENABLE_ZLIB - -/* Define if zstd compression is available */ -#cmakedefine01 LLVM_ENABLE_ZSTD - -/* Define if LLVM is using tflite */ -#cmakedefine LLVM_HAVE_TFLITE - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYSEXITS_H ${HAVE_SYSEXITS_H} - -/* Define if building libLLVM shared library */ -#cmakedefine LLVM_BUILD_LLVM_DYLIB - -/* Define if building LLVM with BUILD_SHARED_LIBS */ -#cmakedefine LLVM_BUILD_SHARED_LIBS - -/* Define if building LLVM with LLVM_FORCE_USE_OLD_TOOLCHAIN_LIBS */ -#cmakedefine LLVM_FORCE_USE_OLD_TOOLCHAIN ${LLVM_FORCE_USE_OLD_TOOLCHAIN} - -/* Define if llvm_unreachable should be optimized with undefined behavior - * in non assert builds */ -#cmakedefine01 LLVM_UNREACHABLE_OPTIMIZE - -/* Define to 1 if you have the DIA SDK installed, and to 0 if you don't. */ -#cmakedefine01 LLVM_ENABLE_DIA_SDK - -/* Define if plugins enabled */ -#cmakedefine LLVM_ENABLE_PLUGINS - -#endif diff --git a/utils/bazel/overlay_directories.py b/utils/bazel/overlay_directories.py deleted file mode 100755 index 526a78e978e5d6..00000000000000 --- a/utils/bazel/overlay_directories.py +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/python3 - -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -"""Overlays two directories into a target directory using symlinks. - -Tries to minimize the number of symlinks created (that is, does not symlink -every single file). Symlinks every file in the overlay directory. Only symlinks -individual files in the source directory if their parent directory is also -contained in the overlay directory tree. -""" - -import argparse -import errno -import os -import sys - - -def _check_python_version(): - if sys.version_info[0] < 3: - raise RuntimeError( - "Must be invoked with a python 3 interpreter but was %s" % sys.executable - ) - - -def _check_dir_exists(path): - if not os.path.isdir(path): - raise OSError(errno.ENOENT, os.strerror(errno.ENOENT), path) - - -def parse_arguments(): - parser = argparse.ArgumentParser( - description=""" - Overlays two directories into a target directory using symlinks. - - Tries to minimize the number of symlinks created (that is, does not symlink - every single file). Symlinks every file in the overlay directory. Only - symlinks individual files in the source directory if their parent directory - is also contained in the overlay directory tree. - """ - ) - parser.add_argument( - "--src", - required=True, - help="Directory that contains most of the content to symlink.", - ) - parser.add_argument( - "--overlay", - required=True, - help="Directory to overlay on top of the source directory.", - ) - parser.add_argument( - "--target", - required=True, - help="Directory in which to place the fused symlink directories.", - ) - - args = parser.parse_args() - - _check_dir_exists(args.target) - _check_dir_exists(args.overlay) - _check_dir_exists(args.src) - - return args - - -def _symlink_abs(from_path, to_path): - os.symlink(os.path.abspath(from_path), os.path.abspath(to_path)) - - -def main(args): - for root, dirs, files in os.walk(args.overlay): - # We could do something more intelligent here and only symlink individual - # files if the directory is present in both overlay and src. This could also - # be generalized to an arbitrary number of directories without any - # "src/overlay" distinction. In the current use case we only have two and - # the overlay directory is always small, so putting that off for now. - rel_root = os.path.relpath(root, start=args.overlay) - if rel_root != ".": - os.mkdir(os.path.join(args.target, rel_root)) - - for file in files: - relpath = os.path.join(rel_root, file) - _symlink_abs( - os.path.join(args.overlay, relpath), os.path.join(args.target, relpath) - ) - - for src_entry in os.listdir(os.path.join(args.src, rel_root)): - if src_entry not in dirs: - relpath = os.path.join(rel_root, src_entry) - _symlink_abs( - os.path.join(args.src, relpath), os.path.join(args.target, relpath) - ) - - -if __name__ == "__main__": - _check_python_version() - main(parse_arguments()) diff --git a/utils/bazel/third_party_build/BUILD b/utils/bazel/third_party_build/BUILD deleted file mode 100644 index 98077a0651d9dd..00000000000000 --- a/utils/bazel/third_party_build/BUILD +++ /dev/null @@ -1,5 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -licenses(["notice"]) diff --git a/utils/bazel/third_party_build/gmp.BUILD b/utils/bazel/third_party_build/gmp.BUILD deleted file mode 100644 index fb0c3bf75b7ed1..00000000000000 --- a/utils/bazel/third_party_build/gmp.BUILD +++ /dev/null @@ -1,20 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make_variant") - -filegroup( - name = "sources", - srcs = glob(["**"]), -) - -configure_make_variant( - name = "gmp", - configure_options = ["--with-pic"], - copts = ["-w"], - lib_name = "libgmp", - lib_source = ":sources", - toolchain = "@rules_foreign_cc//toolchains:preinstalled_autoconf_toolchain", - visibility = ["//visibility:public"], -) diff --git a/utils/bazel/third_party_build/mpfr.BUILD b/utils/bazel/third_party_build/mpfr.BUILD deleted file mode 100644 index 6b47874824c748..00000000000000 --- a/utils/bazel/third_party_build/mpfr.BUILD +++ /dev/null @@ -1,33 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make_variant") - -filegroup( - name = "sources", - srcs = glob(["**"]), -) - -configure_make_variant( - name = "mpfr", - configure_options = ["--with-pic"], - copts = ["-w"], - lib_name = "libmpfr", - lib_source = ":sources", - toolchain = "@rules_foreign_cc//toolchains:preinstalled_autoconf_toolchain", - visibility = ["//visibility:public"], - deps = ["@gmp//:gmp_"], -) - -alias( - name = "mpfr_external", - actual = "@mpfr//:mpfr_", - visibility = ["//visibility:public"], -) - -cc_library( - name = "mpfr_system", - linkopts = ["-lmpfr"], - visibility = ["//visibility:public"], -) diff --git a/utils/bazel/third_party_build/pfm.BUILD b/utils/bazel/third_party_build/pfm.BUILD deleted file mode 100644 index fe908d4744dae6..00000000000000 --- a/utils/bazel/third_party_build/pfm.BUILD +++ /dev/null @@ -1,31 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -load("@rules_foreign_cc//foreign_cc:defs.bzl", "make_variant") - -filegroup( - name = "sources", - srcs = glob(["**"]), -) - -make_variant( - name = "pfm", - copts = ["-w"], - lib_name = "libpfm", - lib_source = ":sources", - toolchain = "@rules_foreign_cc//toolchains:preinstalled_autoconf_toolchain", - visibility = ["//visibility:public"], -) - -alias( - name = "pfm_external", - actual = "@pfm//:pfm_", - visibility = ["//visibility:public"], -) - -cc_library( - name = "pfm_system", - linkopts = ["-lpfm"], - visibility = ["//visibility:public"], -) diff --git a/utils/bazel/third_party_build/vulkan_headers.BUILD b/utils/bazel/third_party_build/vulkan_headers.BUILD deleted file mode 100644 index 33c0d98f53493b..00000000000000 --- a/utils/bazel/third_party_build/vulkan_headers.BUILD +++ /dev/null @@ -1,30 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -package( - default_visibility = ["//visibility:public"], - licenses = ["notice"], -) - -# Exports all headers but defining VK_NO_PROTOTYPES to disable the -# inclusion of C function prototypes. Useful if dynamically loading -# all symbols via dlopen/etc. -# Not all headers are hermetic, so they are just included as textual -# headers to disable additional validation. -cc_library( - name = "vulkan_headers_no_prototypes", - defines = ["VK_NO_PROTOTYPES"], - includes = ["include"], - textual_hdrs = glob(["include/vulkan/*.h"]), -) - -# Exports all headers, including C function prototypes. Useful if statically -# linking against the Vulkan SDK. -# Not all headers are hermetic, so they are just included as textual -# headers to disable additional validation. -cc_library( - name = "vulkan_headers", - includes = ["include"], - textual_hdrs = glob(["include/vulkan/*.h"]), -) diff --git a/utils/bazel/third_party_build/zlib-ng.BUILD b/utils/bazel/third_party_build/zlib-ng.BUILD deleted file mode 100644 index 055261acb0f693..00000000000000 --- a/utils/bazel/third_party_build/zlib-ng.BUILD +++ /dev/null @@ -1,108 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") -load("@bazel_skylib//rules:expand_template.bzl", "expand_template") - -package( - default_visibility = ["//visibility:public"], - # BSD/MIT-like license (for zlib) - licenses = ["notice"], -) - -bool_flag( - name = "llvm_enable_zlib", - build_setting_default = True, -) - -config_setting( - name = "llvm_zlib_enabled", - flag_values = {":llvm_enable_zlib": "true"}, -) - -genrule( - # The input template is identical to the CMake output. - name = "zconf_gen", - srcs = ["zconf.h.in"], - outs = ["zconf.h"], - cmd = "cp $(SRCS) $(OUTS)", -) - -cc_library( - name = "zlib", - srcs = select({ - ":llvm_zlib_enabled": [ - "adler32.c", - "adler32_p.h", - "chunkset.c", - "chunkset_tpl.h", - "compare258.c", - "compress.c", - "crc32.c", - "crc32_comb.c", - "crc32_comb_tbl.h", - "crc32_p.h", - "crc32_tbl.h", - "deflate.c", - "deflate.h", - "deflate_fast.c", - "deflate_medium.c", - "deflate_p.h", - "deflate_quick.c", - "deflate_slow.c", - "fallback_builtins.h", - "functable.c", - "functable.h", - "infback.c", - "inffast.c", - "inffast.h", - "inffixed_tbl.h", - "inflate.c", - "inflate.h", - "inflate_p.h", - "inftrees.c", - "inftrees.h", - "insert_string.c", - "insert_string_tpl.h", - "match_tpl.h", - "trees.c", - "trees.h", - "trees_emit.h", - "trees_tbl.h", - "uncompr.c", - "zbuild.h", - "zendian.h", - "zutil.c", - "zutil.h", - "zutil_p.h", - ], - "//conditions:default": [], - }), - hdrs = select({ - ":llvm_zlib_enabled": [ - "zlib.h", - ":zconf_gen", - ], - "//conditions:default": [], - }), - copts = [ - "-std=c11", - "-DZLIB_COMPAT", - "-DWITH_GZFILEOP", - "-DWITH_OPTIM", - "-DWITH_NEW_STRATEGIES", - # For local builds you might want to add "-DWITH_NATIVE_INSTRUCTIONS" - # here to improve performance. Native instructions aren't enabled in - # the default config for reproducibility. - ], - defines = select({ - ":llvm_zlib_enabled": [ - "LLVM_ENABLE_ZLIB=1", - ], - "//conditions:default": [], - }), - # Clang includes zlib with angled instead of quoted includes, so we need - # strip_include_prefix here. - strip_include_prefix = ".", - visibility = ["//visibility:public"], -) diff --git a/utils/bazel/third_party_build/zstd.BUILD b/utils/bazel/third_party_build/zstd.BUILD deleted file mode 100644 index 7d022d4226de14..00000000000000 --- a/utils/bazel/third_party_build/zstd.BUILD +++ /dev/null @@ -1,54 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") - -package( - default_visibility = ["//visibility:public"], - # BSD/MIT-like license (for zstd) - licenses = ["notice"], -) - -bool_flag( - name = "llvm_enable_zstd", - build_setting_default = True, -) - -config_setting( - name = "llvm_zstd_enabled", - flag_values = {":llvm_enable_zstd": "true"}, -) - -cc_library( - name = "zstd", - srcs = select({ - ":llvm_zstd_enabled": glob([ - "lib/common/*.c", - "lib/common/*.h", - "lib/compress/*.c", - "lib/compress/*.h", - "lib/decompress/*.c", - "lib/decompress/*.h", - "lib/decompress/*.S", - "lib/dictBuilder/*.c", - "lib/dictBuilder/*.h", - ]), - "//conditions:default": [], - }), - hdrs = select({ - ":llvm_zstd_enabled": [ - "lib/zdict.h", - "lib/zstd.h", - "lib/zstd_errors.h", - ], - "//conditions:default": [], - }), - defines = select({ - ":llvm_zstd_enabled": [ - "LLVM_ENABLE_ZSTD=1", - "ZSTD_MULTITHREAD", - ], - "//conditions:default": [], - }), - strip_include_prefix = "lib", -) diff --git a/utils/bazel/vulkan_sdk.bzl b/utils/bazel/vulkan_sdk.bzl deleted file mode 100644 index e23dc42131c4ca..00000000000000 --- a/utils/bazel/vulkan_sdk.bzl +++ /dev/null @@ -1,43 +0,0 @@ -# This file is licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -"""Repository rule to statically link against the Vulkan SDK. - -Requires installing the Vulkan SDK from https://vulkan.lunarg.com/. - -If the Vulkan SDK is not installed, this generates an empty rule and you may -encounter linker errors like `error: undefined reference to 'vkCreateInstance'`. -""" - -def _impl(repository_ctx): - if "VULKAN_SDK" in repository_ctx.os.environ: - sdk_path = repository_ctx.os.environ["VULKAN_SDK"] - repository_ctx.symlink(sdk_path, "vulkan-sdk") - - repository_ctx.file("BUILD", """ -cc_library( - name = "sdk", - srcs = select({ - "@platforms//os:windows": [ - "vulkan-sdk/Lib/vulkan-1.lib" - ], - "//conditions:default": [ - "vulkan-sdk/lib/libvulkan.so.1", - ], - }), - visibility = ["//visibility:public"], -)""") - else: - # Empty rule. Will fail to link for just targets that use Vulkan. - repository_ctx.file("BUILD", """ -cc_library( - name = "sdk", - srcs = [], - visibility = ["//visibility:public"], -)""") - -vulkan_sdk_setup = repository_rule( - implementation = _impl, - local = True, -)