onnxruntime/tools/ci_build/github/azure-pipelines/templates/mac-ci.yml
Changming Sun c716b56f26
Update C++ Standard from 14 to 17 (#8041)
Switched the code to C++17. To build ONNX Runtime on old distros like CentOS 7, you need to install a newer GCC from additionary repos. If you build onnxruntime with the newer GCC, typically the result binary can't be distributed to other places because it depends on the new GCC's runtime libraries, something that the stock OS doesn't have. But on RHEL/CentOS, it can be better. We use Red Hat devtoolset 8/9/10 with CentOS7 building our code. The new library features(like std::filesystem) that not exists in the old C++ runtime will be statically linked into the applications with some restrictions:

1. GCC has dual ABI, but we can only use the old one. It means std::string is still copy-on-write and std::list::size() is still O(n). Also, if you build onnxruntime on CentOS 7 and link it with some binaries that were built on CentOS 8 or Ubuntu with the new ABI and export C++ symbols directly(instead of using a C API), the it won't work.

2. We still can't use std::optional. It is a limitation coming from macOS. We will solve it when we got macOS 11 build machines. It won't be too long.

3. Please avoid to use C++17 in CUDA files(*.cu). Also, the *.h files that they include(like core/framework/float16.h). This is Because CUDA 10.2 doesn't support C++17. You are welcome to use the new features in any *.cc files.
2021-06-25 14:08:01 -07:00

95 lines
3.7 KiB
YAML

parameters:
JobName: 'MacOS_CI_Dev'
SubmoduleCheckoutMode: ''
BuildCommand: ''
DoNodejsPack: 'false'
DoNugetPack: 'false'
NuPackScript: ''
ArtifactName: 'drop-osx'
# Controls whether unreleased onnx opsets are allowed. Default is set to 1
AllowReleasedOpsetOnly: '1'
jobs:
- job: ${{ parameters.JobName }}
workspace:
clean: all
timeoutInMinutes: 120
pool:
vmImage: 'macOS-10.15'
variables:
BuildCommand: ${{ parameters.BuildCommand }}
ALLOW_RELEASED_ONNX_OPSET_ONLY: ${{ parameters.AllowReleasedOpsetOnly }}
MACOSX_DEPLOYMENT_TARGET: '10.13'
steps:
- checkout: self
${{ if ne(parameters.SubmoduleCheckoutMode, '') }}:
submodules: ${{ parameters.SubmoduleCheckoutMode }}
- task: UsePythonVersion@0
# Use python 3.8 to avoid build some of the required packages
displayName: Use Python 3.8
inputs:
versionSpec: 3.8
- task: NodeTool@0
inputs:
versionSpec: '12.x'
- script: |
set -e
pushd .
cd $(Build.SourcesDirectory)/cmake/external/protobuf
cmake ./cmake -DCMAKE_INSTALL_PREFIX=$(Build.BinariesDirectory)/protobuf -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Relwithdebinfo
make -j $(getconf _NPROCESSORS_ONLN)
make install
popd
export PATH=$(Build.BinariesDirectory)/protobuf/bin:$PATH
export ONNX_ML=1
export CMAKE_ARGS="-DONNX_GEN_PB_TYPE_STUBS=OFF -DONNX_WERROR=OFF"
sudo python3 -m pip install -r '$(Build.SourcesDirectory)/tools/ci_build/github/linux/docker/scripts/requirements.txt'
sudo xcode-select --switch /Applications/Xcode_12.4.app/Contents/Developer
${{ parameters.BuildCommand }}
displayName: 'Build and Test OnnxRuntime lib for MacOS'
- task: PublishTestResults@2
displayName: 'Publish unit test results'
inputs:
testResultsFiles: '**/*.results.xml'
searchFolder: '$(Build.BinariesDirectory)'
testRunTitle: 'Unit Test Run'
condition: succeededOrFailed()
- ${{ if eq(parameters['DoNugetPack'], 'true') }}:
- script: |
${{ parameters.NuPackScript }}
displayName: 'Copy MacOS libs to Artifact Staging'
- task: PublishPipelineArtifact@0
displayName: 'Publish Pipeline Artifact: ${{ parameters.ArtifactName }}'
inputs:
artifactName: ${{ parameters.ArtifactName }}
targetPath: '$(Build.ArtifactStagingDirectory)'
- ${{ if eq(parameters['DoNodejsPack'], 'true') }}:
# Esrp signing
#
# TODO: ESRP team is working on enable signing workflow on Mac. Should enable the following step when it's ready.
#
# - template: mac-esrp-dll.yml
# parameters:
# FolderPath: '$(Build.SourcesDirectory)/js/node/bin/napi-v3/darwin/x64'
# DisplayName: 'ESRP - Sign Node.js binding binaries'
# DoEsrp: ${{ parameters.DoEsrp }}
# Pattern: '*.dylib,*.node'
- script: |
npm pack
cp $(Build.SourcesDirectory)/js/node/onnxruntime-*.tgz $(Build.ArtifactStagingDirectory)
cp -R $(Build.SourcesDirectory)/js/node/prebuilds $(Build.ArtifactStagingDirectory)/prebuilds
workingDirectory: '$(Build.SourcesDirectory)/js/node'
displayName: 'Create NPM Package'
- task: PublishPipelineArtifact@0
displayName: 'Publish Pipeline Artifact: ${{ parameters.ArtifactName }}'
inputs:
artifactName: ${{ parameters.ArtifactName }}
targetPath: '$(Build.ArtifactStagingDirectory)'
- template: component-governance-component-detection-steps.yml
parameters :
condition : 'succeeded'
- template: clean-agent-build-directory-step.yml