Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building on Apple Silicon #20

Open
fjd-anh opened this issue Jun 22, 2023 · 0 comments
Open

Building on Apple Silicon #20

fjd-anh opened this issue Jun 22, 2023 · 0 comments

Comments

@fjd-anh
Copy link

fjd-anh commented Jun 22, 2023

When building with Docker on MacBook Pro with M1 Pro, the build fails with gcc: error: unrecognized command-line option '-m64'.

Command to build

docker build -t bsi-task:latest 

Error

...
#0 13.99 make depend && make _build_sw
#0 13.99 make[1]: Entering directory '/task/src/tlstesttool/build/EP_OPENSSL-prefix/src/EP_OPENSSL'
#0 13.99 make[1]: Leaving directory '/task/src/tlstesttool/build/EP_OPENSSL-prefix/src/EP_OPENSSL'
#0 13.99 make[1]: Entering directory '/task/src/tlstesttool/build/EP_OPENSSL-prefix/src/EP_OPENSSL'
#0 13.99 gcc  -I. -Iinclude -Iapps/include  -fPIC -pthread -m64 -Wa,--noexecstack -Wall -O3 -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSLDIR="\"/task/src/tlstesttool/build/EP_BASE/ssl\"" -DENGINESDIR="\"/task/src/tlstesttool/build/EP_BASE/lib64/engines-3\"" -DMODULESDIR="\"/task/src/tlstesttool/build/EP_BASE/lib64/ossl-modules\"" -DOPENSSL_BUILDING_OPENSSL -DNDEBUG  -MMD -MF apps/lib/libapps-lib-app_libctx.d.tmp -MT apps/lib/libapps-lib-app_libctx.o -c -o apps/lib/libapps-lib-app_libctx.o apps/lib/app_libctx.c
#0 13.99 gcc: error: unrecognized command-line option '-m64'
#0 13.99 make[1]: *** [Makefile:3506: apps/lib/libapps-lib-app_libctx.o] Error 1
#0 13.99 make[1]: Leaving directory '/task/src/tlstesttool/build/EP_OPENSSL-prefix/src/EP_OPENSSL'
#0 13.99 make: *** [Makefile:2516: build_sw] Error 2
#0 13.99 ninja: build stopped: subcommand failed.
------
Dockerfile:29
--------------------
  27 |     WORKDIR /task/src/tlstesttool/build
  28 |     # prepare build and run it parallel with ninja
  29 | >>> RUN cmake -G Ninja -DCMAKE_BUILD_TYPE=Release .. && ninja
  30 |     
  31 |     # switch to task
--------------------
ERROR: failed to solve: process "/bin/sh -c cmake -G Ninja -DCMAKE_BUILD_TYPE=Release .. && ninja" did not complete successfully: exit code: 1

Workaround

In the FROM line, set the Arch to amd64.
This slows down the build process extremely (16,5 hours on my MacBook Pro with M1 Pro).

Update: docker-compose.yml also needs an update.

diff --git a/Dockerfile b/Dockerfile
index 33c023b..b857a7a 100755
--- a/Dockerfile
+++ b/Dockerfile
@@ -2,7 +2,7 @@
 # - edit /var/snap/docker/current/config/daemon.json and replace “overlay2” with “vfs” for the storage-driver
 # - run sudo snap restart docker
 
-FROM ubuntu:22.04
+FROM --platform=linux/amd64 ubuntu:22.04
 
 # install dependencies
 RUN apt-get update
diff --git a/docker-compose.yml b/docker-compose.yml
index c405ce0..671a547 100755
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -2,6 +2,7 @@ version: '3'
 services:
   task:
     image: task-docker
+    platform: linux/amd64
     container_name: task-docker
     build:
       context: .

Suggested fix

It would be cool, if you could make the gcc work on Apple Silicon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant