Shared object (.so) size on Apple M1

310 views
Skip to first unread message

David Lopes

unread,
Aug 11, 2021, 10:30:57 PM8/11/21
to grpc.io
Hello all,

I have a set of build scripts that spawn a docker container to build a set of artifacts in Python using PIP. One of the dependencies of these artifacts is, of course, the grpc library. The build script is basically pip installing a requirements.txt and zipping the dependencies.

I noticed the following odd behavior:

When I run the scripts from my Windows laptop, cygrpc.cpython-38-x86_64-linux-gnu.so file has 9.8M in size. However, if I run the exact same scripts from an Apple M1 laptop, cygrpc.cpython-38-aarch64-linux-gnu.so will take an astonishing 119M in size (check prints below)

Screenshot 2021-08-12 at 00.18.49.png

image.png

This is problematic, as these scripts are building an AWS Lambda layer, and having a single .so with 119M is a big no-no.

Do you have any idea why is this happening? How can I possibly build my package without having to carry a 119M file around?

Thanks,
David

Craig Tiller

unread,
Aug 11, 2021, 10:42:21 PM8/11/21
to David Lopes, grpc.io
Are you inadvertently turning on something that records debug symbols?

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/316dc65f-51a3-45f2-b4d1-6df2c7fadf15n%40googlegroups.com.

David Lopes

unread,
Aug 12, 2021, 5:02:37 AM8/12/21
to grpc.io
I guess that's possible, but I don't think I am. I'm using the exact same build script to build in multiple platforms and the results are very different. Just now, I ran the build script from my apple M1 laptop directly (instead of running inside a docker container) and the file goes down to a standard size (check print).

Screenshot 2021-08-12 at 09.52.53.png

To summarize, these are the different build variations I did so far:
  1. windows laptop: OK
  2. macOS M1 chip: OK
  3. docker container on top of Windows: OK
  4. docker on top of macOS M1 chip: NOT OK
The build script is basically doing the following:
  • pip install -r <requirements.txt> -t <dependencies_folder>
  • zip -r <dependencies_zip_file> <dependencies_folder>
The prints I'm sharing are the content of the <dependencies_folder>

This suggests that my docker installation on macOS is doing something weird, but I can't figure it out.

David Lopes

unread,
Aug 12, 2021, 5:19:22 PM8/12/21
to grpc.io
I was able to workaround this issue.

I had to tell docker to build the container to the desired architecture with:

docker buildx build -t {CONTAINER_TAG_NAME} --platform linux/amd64

Reply all
Reply to author
Forward
0 new messages