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

Doesn't build on M1/M2 Macs #120

Open
JKI757 opened this issue Jul 7, 2022 · 8 comments
Open

Doesn't build on M1/M2 Macs #120

JKI757 opened this issue Jul 7, 2022 · 8 comments

Comments

@JKI757
Copy link

JKI757 commented Jul 7, 2022

The release doesn't run on M1 Macs, it seems to start x-windows and then just quits, doesn't give any other indication of what's wrong. So trying to build using these scripts (after fixing the boost download issue and the lib tool download issue and manually installing python 3.9 and adjusting the build script to point to that install), it runs into trouble compiling ffi -- seems to be an arm assembly issue perhaps. This one is a bit over my head. Maybe someone has an idea on how to resolve it? I've attached my modified build script in case I made a mistake there that's causing the issue.

build.sh.txt

partial compile output:

libtool: compile: clang -mmacosx-version-min=10.7 -DHAVE_CONFIG_H -I. -I.. -I. -I../include -Iinclude -I../src -I/Applications/GNURadio.app/Contents/MacOS/usr/include -I/opt/X11/include -I/Applications/GNURadio.app/Contents/MacOS/usr/include -I/opt/X11/include -Wall -fexceptions -MT src/arm/ffi.lo -MD -MP -MF src/arm/.deps/ffi.Tpo -c ../src/arm/ffi.c -fno-common -DPIC -o src/arm/.libs/ffi.o
../src/arm/sysv.S:64:1: error: unexpected token at start of statement
@ This selects the minimum architecture level required.
^
../src/arm/sysv.S:112:1: error: unknown directive
.syntax unified
^
../src/arm/sysv.S:152:2: error: unexpected token at start of statement
@ r0: ffi_prep_args
^
../src/arm/sysv.S:153:2: error: unexpected token at start of statement
@ r1: &ecif
^
../src/arm/sysv.S:154:2: error: unexpected token at start of statement
@ r2: cif->bytes

^
../src/arm/sysv.S:155:2: error: unexpected token at start of statement
@ r3: fig->flags
^

@JKI757
Copy link
Author

JKI757 commented Jul 7, 2022

Ok, fixed the libffi problem using this link: libffi/libffi#571

adding the parameter "--build=aarch64-apple-darwin20.0.0" to CONFIGURE_CMD on line 556 of the build script allows libffi to build correctly. Apparently it detects the architecture incorrectly in libffi's configure script and this forces it.

I'm going to just go ahead and document my modifications to the build script as I go along trying to get this to work, hopefully can come up with a script that works on apple silicon eventually.

@dmaltsiniotis
Copy link

Ok, fixed the libffi problem using this link: libffi/libffi#571

adding the parameter "--build=aarch64-apple-darwin20.0.0" to CONFIGURE_CMD on line 556 of the build script allows libffi to build correctly. Apparently it detects the architecture incorrectly in libffi's configure script and this forces it.

I'm going to just go ahead and document my modifications to the build script as I go along trying to get this to work, hopefully can come up with a script that works on apple silicon eventually.

Thanks for following up and posting your work on this, it's very helpful.

@krono-i2
Copy link

krono-i2 commented Oct 9, 2022

+1 I’m really interested in compiling gnuradio for Apple silicon.
Please, keep me updated!

@krono-i2
Copy link

I've modified the script in order to compile GNU Radio 3.10.4.0 using the macos built-in python version (v3.9).
I know I have to add some dependences (e.g., pybind11), but at the moment I'm stuck on glib compiling.

I: applying patch /Users/krono/workspace/gnuradio/gnuradio-for-mac-without-macports/patches/glib-2.62.0-00-support_modules_and_x11.patch
/Users/krono/workspace/gnuradio/gnuradio-for-mac-without-macports/patches/glib-2.62.0-00-support_modules_and_x11.patch:925: new blank line at EOF.
+
warning: 1 line adds whitespace errors.
Traceback (most recent call last):
  File "/Applications/GNURadio.app/Contents/MacOS/usr/bin/meson", line 33, in <module>
    sys.exit(load_entry_point('meson==0.51.2', 'console_scripts', 'meson')())
  File "/Applications/GNURadio.app/Contents/MacOS/usr/bin/meson", line 22, in importlib_load_entry_point
    for entry_point in distribution(dist_name).entry_points
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/importlib/metadata.py", line 524, in distribution
    return Distribution.from_name(distribution_name)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/importlib/metadata.py", line 187, in from_name
    raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: meson
E: failed to build glib-2.62.0

Do you have ideas for solving?
Thanks a lot.

Ivan

@JKI757
Copy link
Author

JKI757 commented Oct 21, 2022

You're missing the meson package. Most likely it's just not installed in such a way as to be accessible to that version of python.

@krono-i2
Copy link

Uhm, probably your right...
Meson seams to be installed.
I: already installed meson-0.51.2
Find here my configuration variables to point to bult-in python distribution.

PYTHON_VERSION=3.9
PYTHON_FRAMEWORK_DIR="/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/${PYTHON_VERSION}"
PYTHON="${PYTHON_FRAMEWORK_DIR}/Resources/Python.app/Contents/MacOS/Python"
PYTHON_CONFIG="${PYTHON_FRAMEWORK_DIR}/lib/python3.9/config-3.9-darwin/python-config.py"
INSTALL_LIB_DIR="${INSTALL_DIR}/usr/lib"
INSTALL_PYTHON_DIR="${INSTALL_LIB_DIR}/python${PYTHON_VERSION}/site-packages"
INSTALL_GNURADIO_PYTHON_DIR="${INSTALL_DIR}/usr/share/gnuradio/python/site-packages"

How can I modify the meson install lines to make it visible to glib? Sould I modify function build_and_install_meson or build_and_install_setup_py?
Thanks a lot for help.

Ivan

@JKI757
Copy link
Author

JKI757 commented Oct 21, 2022

I'm not at a computer right now, but even though meson is installed it's apparently not available to the python version you're using.

The basic gist is that you need to run python pip3 -m install meson under the version of python you are using. In other words you're going to need to run that command, but using the full path of the python version that is being used to build this.

Python on Mac is such a pain to work with...

@krono-i2
Copy link

I'm installing meson through the script itself.
I found out meson has been correctly installed in INSTALL_PYTHON_DIR (i.e., /Applications/GNURadio.app/Contents/MacOS/usr/lib/python3.9/site-packages); there is meson-0.63.3-py3.9.egg and it is linked in easy-install.pth.
The problem is that when meson is called, python does not find it because the egg file is not in sys.path.
Maybe it is a problem in the meson installation. Find attached the relevant lines of the build script.

function build_and_install_setup_py() {
  set -e

  local P=${1}
  local URL=${2}
  local CKSUM=${3}
  local T=${4}
  local BRANCH=${5}

  export -n SHELLOPTS

  if [ "" = "${T}" ]; then
    T=${P}
  fi

  if [ -f ${TMP_DIR}/.${P}.done ]; then
    I "already installed ${P}"    
  else 
  
    fetch "${P}" "${URL}" "${T}" "${BRANCH}" "${CKSUM}"
    unpack ${P} ${URL} ${T}
  
    if [ ! -d ${PYTHONPATH} ]; then
      mkdir -p ${PYTHONPATH} \
        || E "failed to mkdir -p ${PYTHONPATH}"
    fi
  
    I "Configuring and building in ${T}"
    cd ${TMP_DIR}/${T} \
      && \
        ${PYTHON} setup.py install --prefix=${INSTALL_DIR}/usr \
      || E "failed to configure and install ${P}"
  
    I "finished building and installing ${P}"
    touch ${TMP_DIR}/.${P}.done
    
  fi
}

...

#
# Install meson
# 
(
  V=0.63.3
  P=meson-${V}
  URL="https://github.com/mesonbuild/meson/releases/download/${V}/${P}.tar.gz"
  CKSUM=sha256:519c0932e1a8b208741f0fdce90aa5c0b528dd297cf337009bf63539846ac056

  build_and_install_setup_py \
    ${P} \
    ${URL} \
    ${CKSUM}
)

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

No branches or pull requests

3 participants