Skip to content

Commit

Permalink
New quoting
Browse files Browse the repository at this point in the history
  • Loading branch information
jakelishman committed Oct 15, 2024
1 parent 2dd8257 commit 6031e41
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/wheels-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,20 @@ jobs:
#
# Beware that the heredoc is configured to expand bash variables, but cibuildwheel has
# special handling for certain variables (`$PATH`, in particular), so you may need to escape
# some dollar signs to pass those through to cibuildwheel as variables, not expanded.
# Windows paths with backslashes need to be escaped twice - once to get the backslash
# through the heredoc, and once to get it through the shell expansion in cibuildwheel.
# some dollar signs to pass those through to cibuildwheel as variables, or use single quotes
# to prevent shell expansion.
run: |
set -e
mkdir -p "$PGO_WORK_DIR"
cat >>"$GITHUB_ENV" <<EOF
CIBW_BEFORE_BUILD=bash ./tools/build_pgo.sh /tmp/pgo-data/merged.profdata
CIBW_BEFORE_BUILD_WINDOWS=bash ./tools/build_pgo.sh /tmp/pgo-data/merged.profdata && cp /tmp/pgo-data/merged.profdata "\$HOME"
CIBW_ENVIRONMENT=RUSTUP_TOOLCHAIN=stable RUSTFLAGS="-Cprofile-use=/tmp/pgo-data/merged.profdata -Cllvm-args=-pgo-warn-missing-function"
CIBW_ENVIRONMENT_LINUX=RUSTUP_TOOLCHAIN=stable RUSTFLAGS="-Cprofile-use=/tmp/pgo-data/merged.profdata -Cllvm-args=-pgo-warn-missing-function" PATH="\$PATH:\$HOME/.cargo/bin" CARGO_NET_GIT_FETCH_WITH_CLI="true"
CIBW_ENVIRONMENT_WINDOWS=RUSTUP_TOOLCHAIN=stable RUSTFLAGS="-Cprofile-use='\$HOME\\\\merged.profdata' -Cllvm-args=-pgo-warn-missing-function"
CIBW_BEFORE_BUILD=bash ./tools/build_pgo.sh $PGO_WORK_DIR $PGO_OUT_PATH
CIBW_ENVIRONMENT=RUSTUP_TOOLCHAIN=stable RUSTFLAGS="-Cprofile-use=$PGO_OUT_PATH -Cllvm-args=-pgo-warn-missing-function"
CIBW_ENVIRONMENT_LINUX=RUSTUP_TOOLCHAIN=stable RUSTFLAGS="-Cprofile-use=$PGO_OUT_PATH -Cllvm-args=-pgo-warn-missing-function" PATH="\$PATH:\$HOME/.cargo/bin" CARGO_NET_GIT_FETCH_WITH_CLI="true"
EOF
env:
PGO_WORK_DIR: ${{ github.workspace }}/pgo-data
PGO_OUT_PATH: ${{ github.workspace }}/merged.profdata
- uses: pypa/cibuildwheel@v2.19.2
- uses: actions/upload-artifact@v4
with:
Expand Down
15 changes: 7 additions & 8 deletions tools/build_pgo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

set -x

merged_path=$1

python -c 'import sys;assert sys.platform == "win32"'
is_win=$?
work_dir="$1"
out_path="$2"

set -e

# Create venv for instrumented build and test
python -m venv build_pgo

if [[ $is_win -eq 0 ]]; then
if python -c 'import sys; assert sys.platform == "win32"'; then
source build_pgo/Scripts/activate
else
source build_pgo/bin/activate
Expand All @@ -25,8 +24,8 @@ fi

# Build with instrumentation
pip install -U -c constraints.txt setuptools-rust wheel setuptools
RUSTFLAGS="-Cprofile-generate=/tmp/pgo-data" pip install --prefer-binary -c constraints.txt -r requirements-dev.txt -e .
RUSTFLAGS="-Cprofile-generate=/tmp/pgo-data" python setup.py build_rust --release --inplace
RUSTFLAGS="-Cprofile-generate='$work_dir'" pip install --prefer-binary -c constraints.txt -r requirements-dev.txt -e .
RUSTFLAGS="-Cprofile-generate='$work_dir'" python setup.py build_rust --release --inplace
# Run profile data generation

QISKIT_PARALLEL=FALSE stestr run --abbreviate
Expand All @@ -35,4 +34,4 @@ python tools/pgo_scripts/test_utility_scale.py

deactivate

${HOME}/.rustup/toolchains/*$arch*/lib/rustlib/$arch*/bin/llvm-profdata merge -o $merged_path /tmp/pgo-data
${HOME}/.rustup/toolchains/*$arch*/lib/rustlib/$arch*/bin/llvm-profdata merge -o "$out_path" "$work_dir"

0 comments on commit 6031e41

Please sign in to comment.