|
4 | 4 | set -ex
|
5 | 5 | SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
|
6 | 6 |
|
| 7 | + |
7 | 8 | # Require only one python installation
|
8 | 9 | if [[ -z "$DESIRED_PYTHON" ]]; then
|
9 | 10 | echo "Need to set DESIRED_PYTHON env variable"
|
|
141 | 142 | echo "Calling setup.py bdist at $(date)"
|
142 | 143 | time CMAKE_ARGS=${CMAKE_ARGS[@]} \
|
143 | 144 | EXTRA_CAFFE2_CMAKE_FLAGS=${EXTRA_CAFFE2_CMAKE_FLAGS[@]} \
|
| 145 | + BUILD_LIBTORCH_CPU_WITH_DEBUG=1 \ |
144 | 146 | python setup.py bdist_wheel -d /tmp/$WHEELHOUSE_DIR
|
145 | 147 | echo "Finished setup.py bdist at $(date)"
|
146 | 148 |
|
@@ -344,6 +346,32 @@ for pkg in /$WHEELHOUSE_DIR/torch*linux*.whl /$LIBTORCH_HOUSE_DIR/libtorch*.zip;
|
344 | 346 | done
|
345 | 347 | fi
|
346 | 348 |
|
| 349 | + pushd "$PREFIX/lib" |
| 350 | + |
| 351 | + # Duplicate library into debug lib |
| 352 | + cp libtorch_cpu.so libtorch_cpu.so.dbg |
| 353 | + |
| 354 | + # Keep debug symbols on debug lib |
| 355 | + strip --only-keep-debug libtorch_cpu.so.dbg |
| 356 | + |
| 357 | + # Remove debug info from release lib |
| 358 | + strip --strip-debug libtorch_cpu.so |
| 359 | + |
| 360 | + objcopy libtorch_cpu.so --add-gnu-debuglink=libtorch_cpu.so.dbg |
| 361 | + |
| 362 | + # Zip up debug info |
| 363 | + mkdir -p /tmp/debug |
| 364 | + mv libtorch_cpu.so.dbg /tmp/debug/libtorch_cpu.so.dbg |
| 365 | + CRC32=$(objcopy --dump-section .gnu_debuglink=>(tail -c4 | od -t x4 -An | xargs echo) libtorch_cpu.so) |
| 366 | + |
| 367 | + pushd /tmp |
| 368 | + PKG_NAME=$(basename "$pkg" | sed 's/\.whl$//g') |
| 369 | + zip /tmp/debug-whl-libtorch-"$PKG_NAME"-"$CRC32".zip /tmp/debug/libtorch_cpu.so.dbg |
| 370 | + cp /tmp/debug-whl-libtorch-"$PKG_NAME"-"$CRC32".zip "$PYTORCH_FINAL_PACKAGE_DIR" |
| 371 | + popd |
| 372 | + |
| 373 | + popd |
| 374 | + |
347 | 375 | # zip up the wheel back
|
348 | 376 | zip -rq $(basename $pkg) $PREIX*
|
349 | 377 |
|
|
0 commit comments