Skip to content

Commit 0259839

Browse files
committed
multipy/libpython: strip debug symbols by default
1 parent 8cea05b commit 0259839

File tree

5 files changed

+14
-19
lines changed

5 files changed

+14
-19
lines changed

Dockerfile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \
1111
ca-certificates \
1212
ccache \
1313
curl \
14+
cmake-mozilla \
1415
wget \
1516
git \
1617
libjpeg-dev \
@@ -44,11 +45,6 @@ RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \
4445
software-properties-common \
4546
python-pip \
4647
python3-pip && \
47-
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor -o /usr/share/keyrings/magic-key.gpg && \
48-
echo "deb [arch=amd64,arm64 signed-by=/usr/share/keyrings/magic-key.gpg] https://apt.kitware.com/ubuntu/ bionic main" | tee -a /etc/apt/sources.list && \
49-
echo "deb http://security.ubuntu.com/ubuntu focal-security main" | tee -a /etc/apt/sources.list && \
50-
apt update && \
51-
apt install -y binutils cmake && \
5248
rm -rf /var/lib/apt/lists/*
5349
RUN /usr/sbin/update-ccache-symlinks
5450
RUN mkdir /opt/ccache && ccache --set-config=cache_dir=/opt/ccache

README.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,6 @@ sudo apt update
5151
xargs sudo apt install -y -qq --no-install-recommends <build-requirements.txt
5252
```
5353

54-
We recommend using the latest version of `cmake` and compilers available for your system. On Ubuntu 18.04, for example, these can be updated as follows:
55-
56-
```shell
57-
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo gpg --dearmor -o /usr/share/keyrings/magic-key.gpg
58-
echo "deb [arch=amd64,arm64 signed-by=/usr/share/keyrings/magic-key.gpg] https://apt.kitware.com/ubuntu/ bionic main" | sudo tee -a /etc/apt/sources.list
59-
echo "deb http://security.ubuntu.com/ubuntu focal-security main" | sudo tee -a /etc/apt/sources.list
60-
sudo apt update
61-
sudo apt install -y binutils cmake
62-
```
63-
6454
#### Installing environment encapsulators
6555

6656
We support both `conda` and `pyenv`+`virtualenv` to create isolated environments to build and run in. Since `multipy` requires a position-independent version of python to launch interpreters with, for `conda` environments we use the prebuilt `libpython-static=3.x` libraries from `conda-forge` to link with at build time, and for `virtualenv`/`pyenv` we compile python with `-fPIC` to create the linkable library.
@@ -273,7 +263,7 @@ Assuming the above C++ program was stored in a file called, `example-app.cpp`, a
273263
minimal `CMakeLists.txt` file would look like:
274264
275265
```cmake
276-
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)
266+
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
277267
project(multipy_tutorial)
278268
279269
set(MULTIPY_PATH ".." CACHE PATH "The repo where multipy is built or the PYTHONPATH")

examples/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)
1+
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
22
project(multipy_tutorial)
33

44
set(MULTIPY_PATH ".." CACHE PATH "The repo where multipy is built or the PYTHONPATH")

multipy/runtime/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# This source code is licensed under the BSD-style license found in the
55
# LICENSE file in the root directory of this source tree.
66

7-
cmake_minimum_required(VERSION 3.19)
7+
cmake_minimum_required(VERSION 3.12)
88
project(MultipyRuntime)
99

1010
# set ABI by default to 0

multipy/runtime/interpreter/CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,22 @@ FetchContent_Declare(
4949
FetchContent_MakeAvailable(googletest)
5050
include(GoogleTest)
5151

52+
IF(CMAKE_BUILD_TYPE MATCHES Debug)
53+
set(OBJCOPY_FLAGS "")
54+
else()
55+
# binutils prior to 2.32 have issues linking against newer libraries due to
56+
# debug info changes. By default we can strip these out to ensure it
57+
# compiles.
58+
set(OBJCOPY_FLAGS "--strip-debug")
59+
endif()
60+
5261
# instantiate a library based on the objects that make up torch_python
5362
# make sure system python isn't used here
5463
add_custom_command(
5564
OUTPUT libpython_multipy.a
5665
COMMAND cp ${Python3_STATIC_LIBRARIES} libpython_multipy.a
5766
COMMAND chmod +w libpython_multipy.a
58-
COMMAND "${CMAKE_OBJCOPY}" --weaken-symbol=_PyImport_FindSharedFuncptr libpython_multipy.a
67+
COMMAND "${CMAKE_OBJCOPY}" ${OBJCOPY_FLAGS} --weaken-symbol=_PyImport_FindSharedFuncptr libpython_multipy.a
5968
)
6069
add_custom_target(libpython_multipy DEPENDS libpython_multipy.a)
6170

0 commit comments

Comments
 (0)