ComposersDesktop / CDP8

New version of CDP software
GNU Lesser General Public License v2.1
83 stars 3 forks source link

build failure on M1 (Rosetta mode) FIXED #1

Closed davephillips closed 1 year ago

davephillips commented 1 year ago

I'm running into a Portaudio problem building CDP8 for a Mac M1. Specifically:

[ 99%] Building C object dev/externals/paprogs/paplay/CMakeFiles/paplay.dir/paplay.c.o
/Users/davephillips/src/CDP8/dev/externals/paprogs/paplay/paplay.c:75:10: fatal error: 'pa_ringbuffer.h' file not found
#include "pa_ringbuffer.h"
         ^~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [dev/externals/paprogs/paplay/CMakeFiles/paplay.dir/paplay.c.o] Error 1
make[1]: *** [dev/externals/paprogs/paplay/CMakeFiles/paplay.dir/all] Error 2
make: *** [all] Error 2

Info on PA on my system:

% brew info portaudio
==> portaudio: stable 19.7.0 (bottled), HEAD
Cross-platform library for audio I/O

Any suggestions for a fix ?

Best regards,

Dave Phillips

richarddobson commented 1 year ago

Currently the CmakeLists.txt files assume the location of the portaudio sources as described in the "building.." document (i.e. inside the "paprogs" directory). . I originally tried to keep this as a private/local build, to avoid requiring users to install portaudio fully in /usr/local/*. With new versions of the compilers etc I hit so many problems with this that I have had to revise the build to use a full install of portaudio after all. I see that I missed updating the makefile for 'paplay', so I have now updated that in git.

"pa_ringbuffer.h" is not part of the "official" release of portaudio, it is documented as a private header file (i.e. CDP is being a bit naughty here!) located in /src/common, so we need the full source distribution of portaudio so CMake etc can find it. I don't know where homebrew installs the sources, but I assume it is not in the top "paprogs" directory, which is what the CMakeLists.txt files are currently configured to use. Assuming you do have the full portaudio sources available somwhere, the CMakefiles.txt will need to be edited to use the revised paths for those "private" header files.

Otherwise, all I can suggest is to bypass homebrew and just download and build portaudio in our "expected place" as documented. If the CMakeLists.txt files can be revised to retain both the current arrangement ~and~ the installation via homebrew, that would be ideal. All help welcome!

Richard Dobson

On 29/08/2023 03:58, davephillips wrote:

I'm running into a Portaudio problem building CDP8 for a Mac M1. Specifically:

|[ 99%] Building C object dev/externals/paprogs/paplay/CMakeFiles/paplay.dir/paplay.c.o /Users/davephillips/src/CDP8/dev/externals/paprogs/paplay/paplay.c:75:10: fatal error: 'pa_ringbuffer.h' file not found #include "pa_ringbuffer.h" ^~~~~ 1 error generated. make[2]: [dev/externals/paprogs/paplay/CMakeFiles/paplay.dir/paplay.c.o] Error 1 make[1]: [dev/externals/paprogs/paplay/CMakeFiles/paplay.dir/all] Error 2 make: *** [all] Error 2 |

Info on PA on my system:

|% brew info portaudio ==> portaudio: stable 19.7.0 (bottled), HEAD Cross-platform library for audio I/O |

Any suggestions for a fix ?

Best regards,

Dave Phillips

— Reply to this email directly, view it on GitHub https://github.com/ComposersDesktop/CDP8/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNHS4UTQRYLB5KTHUWXS3TXXVLEDANCNFSM6AAAAAA4CIJ7FE. You are receiving this because you are subscribed to this thread.Message ID: @.***>

davephillips commented 1 year ago

Hi Richard ! Well, it seems that Portaudio is a mess here. I now have the PA sources in dev/externals/paprogs/portaudio and in build/dev/externals/paprogs/portaudio. I've built and installed libportaudio.a according to the instructions but now hit this error:

[ 99%] Building C object dev/externals/paprogs/paplay/CMakeFiles/paplay.dir/paplay.c.o
/Users/davephillips/src/CDP8/dev/externals/paprogs/paplay/paplay.c:1139:40: error: implicit declaration of function 'PaUtil_AllocateMemory' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
            sfdata.membuf =  (float *) PaUtil_AllocateMemory(nFramesToPlay * sizeof(float) * /*inchans*/ outchans);
                                       ^
/Users/davephillips/src/CDP8/dev/externals/paprogs/paplay/paplay.c:1139:40: note: did you mean 'PaUtil_FreeMemory'?
/Users/davephillips/src/CDP8/dev/externals/paprogs/paplay/../portaudio/src/common/pa_util.h:135:6: note: 'PaUtil_FreeMemory' declared here
void PaUtil_FreeMemory( void *block );
     ^
/Users/davephillips/src/CDP8/dev/externals/paprogs/paplay/paplay.c:1139:30: warning: cast to 'float *' from smaller integer type 'int' [-Wint-to-pointer-cast]
            sfdata.membuf =  (float *) PaUtil_AllocateMemory(nFramesToPlay * sizeof(float) * /*inchans*/ outchans);
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/davephillips/src/CDP8/dev/externals/paprogs/paplay/paplay.c:1156:44: error: implicit declaration of function 'PaUtil_AllocateMemory' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
            sfdata.ringbufData = (float *) PaUtil_AllocateMemory( ringframelen * sizeof(float) * outchans); /* From now on, recordedSamples is initialised. */
                                           ^
/Users/davephillips/src/CDP8/dev/externals/paprogs/paplay/paplay.c:1156:34: warning: cast to 'float *' from smaller integer type 'int' [-Wint-to-pointer-cast]
            sfdata.ringbufData = (float *) PaUtil_AllocateMemory( ringframelen * sizeof(float) * outchans); /* From now on, recordedSamples is initialised. */
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/davephillips/src/CDP8/dev/externals/paprogs/paplay/paplay.c:1173:34: error: implicit declaration of function 'PaUtil_AllocateMemory' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        sfdata.inbuf = (float *) PaUtil_AllocateMemory(ringframelen * sizeof(float) * inchans);
                                 ^
/Users/davephillips/src/CDP8/dev/externals/paprogs/paplay/paplay.c:1173:24: warning: cast to 'float *' from smaller integer type 'int' [-Wint-to-pointer-cast]
        sfdata.inbuf = (float *) PaUtil_AllocateMemory(ringframelen * sizeof(float) * inchans);
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 warnings and 3 errors generated.
make[2]: *** [dev/externals/paprogs/paplay/CMakeFiles/paplay.dir/paplay.c.o] Error 1
make[1]: *** [dev/externals/paprogs/paplay/CMakeFiles/paplay.dir/all] Error 2
make: *** [all] Error 2

To verify:

% ls -l /usr/local/lib/libportaudio*
lrwxr-xr-x  1 davephillips  admin      51 May 16 07:45 /usr/local/lib/libportaudio.2.dylib -> ../Cellar/portaudio/19.7.0/lib/libportaudio.2.dylib
-rw-r--r--  1 davephillips  admin  521328 Aug 29 13:56 /usr/local/lib/libportaudio.a
lrwxr-xr-x  1 davephillips  admin      49 May 16 07:45 /usr/local/lib/libportaudio.dylib -> ../Cellar/portaudio/19.7.0/lib/libportaudio.dylib
-rwxr-xr-x  1 davephillips  admin     905 Aug 29 13:56 /usr/local/lib/libportaudio.la
lrwxr-xr-x  1 davephillips  admin      54 May 16 07:45 /usr/local/lib/libportaudiocpp.0.dylib -> ../Cellar/portaudio/19.7.0/lib/libportaudiocpp.0.dylib
lrwxr-xr-x  1 davephillips  admin      48 May 16 07:45 /usr/local/lib/libportaudiocpp.a -> ../Cellar/portaudio/19.7.0/lib/libportaudiocpp.a
lrwxr-xr-x  1 davephillips  admin      52 May 16 07:45 /usr/local/lib/libportaudiocpp.dylib -> ../Cellar/portaudio/19.7.0/lib/libportaudiocpp.dylib

Did I miss something ? I haven't changed anything in CMakeLists.txt, I'm not sure re: what & where. Any and all further suggestions welcome. :)

richarddobson commented 1 year ago

Looks like it isn't finding the definition of PaUtil_AllocateMemory() - this is another portaudio header file "pa_util.h" in /src/common. As paplay.c clearly includes that header, the problem is elsewhere.

That function is (for mac builds) defined in pa_unix_util.c (in src/os/unix). This should appear in the auto-generated portaudio Makefile, in the list OTHER_OBJS near the top of the file.

Out of interest, when you built portaudio via ./configure, did it build all the portaudio test programs? These all probably use PaUtil_AllocateMemory etc.

On the other hand, don't try building portaudio using Cmake. They provide a CMakeLists.txt file, but it doesn't work on the Mac (yet). I tried it!

Cheers,

Richard

On 29/08/2023 19:18, davephillips wrote:

Hi Richard ! Well, it seems that Portaudio is a mess here. I now have the PA sources in dev/externals/paprogs/portaudio and in build/dev/externals/paprogs/portaudio. I've built and installed libportaudio.a according to the instructions but now hit this error:

|[ 99%] Building C object dev/externals/paprogs/paplay/CMakeFiles/paplay.dir/paplay.c.o /Users/davephillips/src/CDP8/dev/externals/paprogs/paplay/paplay.c:1139:40: error: implicit declaration of function 'PaUtil_AllocateMemory' is invalid in C99 [-Werror,-Wimplicit-function-declaration] sfdata.membuf = (float ) PaUtil_AllocateMemory(nFramesToPlay sizeof(float) /inchans/ outchans); ^ /Users/davephillips/src/CDP8/dev/externals/paprogs/paplay/paplay.c:1139:40: note: did you mean 'PaUtil_FreeMemory'? /Users/davephillips/src/CDP8/dev/externals/paprogs/paplay/../portaudio/src/common/pa_util.h:135:6: note: 'PaUtil_FreeMemory' declared here void PaUtil_FreeMemory( void block ); ^ /Users/davephillips/src/CDP8/dev/externals/paprogs/paplay/paplay.c:1139:30: warning: cast to 'float ' from smaller integer type 'int' [-Wint-to-pointer-cast] sfdata.membuf = (float ) PaUtil_AllocateMemory(nFramesToPlay sizeof(float) /inchans/ outchans); ^~~~~~~~~~~~~~~~~~~ /Users/davephillips/src/CDP8/dev/externals/paprogs/paplay/paplay.c:1156:44: error: implicit declaration of function 'PaUtil_AllocateMemory' is invalid in C99 [-Werror,-Wimplicit-function-declaration] sfdata.ringbufData = (float ) PaUtil_AllocateMemory( ringframelen sizeof(float) outchans); / From now on, recordedSamples is initialised. / ^ /Users/davephillips/src/CDP8/dev/externals/paprogs/paplay/paplay.c:1156:34: warning: cast to 'float ' from smaller integer type 'int' [-Wint-to-pointer-cast] sfdata.ringbufData = (float ) PaUtil_AllocateMemory( ringframelen sizeof(float) outchans); / From now on, recordedSamples is initialised. */ ^~~~~~~~~~~~~~~ /Users/davephillips/src/CDP8/dev/externals/paprogs/paplay/paplay.c:1173:34: error: implicit declaration of function 'PaUtil_AllocateMemory' is invalid in C99 [-Werror,-Wimplicit-function-declaration] sfdata.inbuf = (float ) PaUtil_AllocateMemory(ringframelen sizeof(float) inchans); ^ /Users/davephillips/src/CDP8/dev/externals/paprogs/paplay/paplay.c:1173:24: warning: cast to 'float ' from smaller integer type 'int' [-Wint-to-pointer-cast] sfdata.inbuf = (float ) PaUtil_AllocateMemory(ringframelen sizeof(float) * inchans); ^~~~~~~~~~~~~~~ 3 warnings and 3 errors generated. make[2]: [dev/externals/paprogs/paplay/CMakeFiles/paplay.dir/paplay.c.o] Error 1 make[1]: [dev/externals/paprogs/paplay/CMakeFiles/paplay.dir/all] Error 2 make: *** [all] Error 2 |

To verify:

|% ls -l /usr/local/lib/libportaudio* lrwxr-xr-x 1 davephillips admin 51 May 16 07:45 /usr/local/lib/libportaudio.2.dylib -> ../Cellar/portaudio/19.7.0/lib/libportaudio.2.dylib -rw-r--r-- 1 davephillips admin 521328 Aug 29 13:56 /usr/local/lib/libportaudio.a lrwxr-xr-x 1 davephillips admin 49 May 16 07:45 /usr/local/lib/libportaudio.dylib -> ../Cellar/portaudio/19.7.0/lib/libportaudio.dylib -rwxr-xr-x 1 davephillips admin 905 Aug 29 13:56 /usr/local/lib/libportaudio.la lrwxr-xr-x 1 davephillips admin 54 May 16 07:45 /usr/local/lib/libportaudiocpp.0.dylib -> ../Cellar/portaudio/19.7.0/lib/libportaudiocpp.0.dylib lrwxr-xr-x 1 davephillips admin 48 May 16 07:45 /usr/local/lib/libportaudiocpp.a -> ../Cellar/portaudio/19.7.0/lib/libportaudiocpp.a lrwxr-xr-x 1 davephillips admin 52 May 16 07:45 /usr/local/lib/libportaudiocpp.dylib -> ../Cellar/portaudio/19.7.0/lib/libportaudiocpp.dylib |

Did I miss something ? I haven't changed anything in CMakeLists.txt, I'm not sure re: what & where. Any and all further suggestions welcome. :)

— Reply to this email directly, view it on GitHub https://github.com/ComposersDesktop/CDP8/issues/1#issuecomment-1697922091, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNHS4WOXWI3SRCV527WFG3XXYW63ANCNFSM6AAAAAA4CIJ7FE. You are receiving this because you commented.Message ID: @.***>

davephillips commented 1 year ago

Okay, here's some more information. It does look like I've built the tests and examples. I used the autotools method, as you said, the cmake doesn't work.

% cd ~/src/CDP8/build/dev/externals/paprogs/portaudio/bin
% ls
pa_devs             paqa_devs.dSYM          patest_leftright        patest_sine_channelmaps.dSYM
pa_devs.dSYM            paqa_errs           patest_leftright.dSYM       patest_sine_formats
pa_fuzz             paqa_errs.dSYM          patest_longsine         patest_sine_formats.dSYM
pa_fuzz.dSYM            paqa_latency

et cetera. And:

% grep -R PaUtil_All *.*
Binary file pa_devs.dSYM/Contents/Resources/DWARF/pa_devs matches
Binary file pa_fuzz.dSYM/Contents/Resources/DWARF/pa_fuzz matches
Binary file pa_minlat.dSYM/Contents/Resources/DWARF/pa_minlat matches
Binary file paex_pink.dSYM/Contents/Resources/DWARF/paex_pink matches
Binary file paex_read_write_wire.dSYM/Contents/Resources/DWARF/paex_read_write_wire matches
Binary file paex_record.dSYM/Contents

and so forth.

From the Portaudio Makefile:

OTHER_OBJS = src/os/unix/pa_unix_hostapis.o src/os/unix/pa_unix_util.o src/hostapi/coreaudio/pa_mac_core.o src/hostapi/coreaudio/pa_mac_core_utilities.o src/hostapi/coreaudio/pa_mac_core_blocking.o src/common/pa_ringbuffer.o

The error seems to point to a location error or a missing declaration, but I can't find where. Alas, debugging C/C++ is not my forte. :)

davephillips commented 1 year ago

Got it ! The error was mine, I was using the git sources, not the recommended tarball. Apologies for the noise. Everything built fine according to the directions, so I'm on to the next step. Is a working SoundLoom available for the Mac ? When I opened the zipfile sloom1703D.app.zip and try running the app I receive an error that soundloom is damaged and should be trashed. Any suggestions ?

richarddobson commented 1 year ago

Hi Dave,

that's good news, and a relief to know it will all build on an M1. Would you be able to make your build available to users online? Otherwise, maybe CDP can host it.

The short answer is that yes, it is a working Soundloom app (we are about to launch "CDP release 8" publicly, and Soundloom is now up to version 17.04E with pvocex support).

The "damaged" message is all because of the Mac's "Gatekeeper" mechanism to prevent potentially rogue apps (defined as anything not "signed" and certificated) from running. There is a standard workaround, which is to use the command utility "xattr":

xattr -rc soundloom.app

The -r flag means "recursive", needed since an app is actually a full directory tree. We are documenting it all as part of the progress to the new release, but as this has been an issue for a while, there is documentation about it all on the existing CDP documentation. This will also work on downloaded installer packages (mpkg etc) and executable shell scripts.

The aspect of this I am most interested in is that currently Soundloom is an Intel-only build (relying on existing intel-based tcltk "kit" which is bundled with the tcltk sources to make a standalone app). I have yet to find a new native M1 build of tcltk kits. This should of course run OK on an M1 via their new "rosetta" system, and I am trusting and hoping that an Intel app calling native M1 programs would not result in some sort of conflict.

Which leads to a related query - does your M1 machine already include an installation of tcltk? As launched via the usual "wish" command. If not, is one available via homebrew etc? When one is, there is another task I am waiting for, which is to make a native M1 build of the "Snack" sound library (dylib) which Soundloom uses in many places, and for which I made a custom version (with much expanded code for the Mac) many years ago now. Even Active State, purveyors of full tcktk distributions for the Mac, seem to have given up on supporting Snack.

Richard

On 30/08/2023 04:34, davephillips wrote:

Got it ! The error was mine, I was using the git sources, not the recommended tarball. Apologies for the noise. Everything built fine according to the directions, so I'm on to the next step. Is a working SoundLoom available for the Mac ? When I opened the zipfile sloom1703D.app.zip and try running the app I receive an error that soundloom is damaged and should be trashed. Any suggestions ?

— Reply to this email directly, view it on GitHub https://github.com/ComposersDesktop/CDP8/issues/1#issuecomment-1698435780, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNHS4TD3JXEV4CHAWYTKYLXX2YD5ANCNFSM6AAAAAA4CIJ7FE. You are receiving this because you commented.Message ID: @.***>

davephillips commented 1 year ago

Wish does appear here, but with this warning:

% wish8.5
DEPRECATION WARNING: The system version of Tk is deprecated and may be removed in a future release. Please don't rely on it. Set TK_SILENCE_DEPRECATION=1 to suppress this warning.

So I can start SoundLoom now but it produces this error then closes:

unable to open execloc.cdp to find program path - please check installation

I've added SoundLoom to ~/src/CDP8/_cdp and the contents of NewRelease to ~/src/CDP8/_cdp/_cdprogs. What do I need beyond that ? Also, is there an example sloomrc anywhere ?

davephillips commented 1 year ago

I am truly beating my head against a wall here. I haven't found a single instance/example of execloc.cdp. I did find that it's supposed to be in ~/src/CDP8/_cdp but I have no idea of its format and what it should include. Very frustrating.

OTOH the CDP binaries work fine. All I need to know now is how to create data files for them. Any suggestions ? If I can get past this step I should be able to use the Renoise CDP tool if I want a GUI.

richarddobson commented 1 year ago

.sloomrc contains just the path to the _cdp directory, so:

/Users//cdpr8/_cdp

most simply done manually, by using: cd cdpr8/_cdp pwd >.sloomrc

This enables Soundloom.app to be placed anywhere, e.g. in /Applications.

Richard

On 30/08/2023 15:50, davephillips wrote:

Wish does appear here, but with this warning:

|% wish8.5 DEPRECATION WARNING: The system version of Tk is deprecated and may be removed in a future release. Please don't rely on it. Set TK_SILENCE_DEPRECATION=1 to suppress this warning. |

So I can start SoundLoom now but it produces this error then closes:

|unable to open execloc.cdp to find program path - please check installation |

I've added SoundLoom to ~/src/CDP8/_cdp. What do I need beyond that ? Also, is there an example sloomrc anywhere ?

— Reply to this email directly, view it on GitHub https://github.com/ComposersDesktop/CDP8/issues/1#issuecomment-1699332674, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNHS4SK5SR2TU6UV32DGZDXX5HMJANCNFSM6AAAAAA4CIJ7FE. You are receiving this because you commented.Message ID: @.***>

davephillips commented 1 year ago

I got that far and .sloomrc is correctly configured and located. The show-stopper is the execloc.cdp file.

davephillips commented 1 year ago

Btw, I have the CDP Tool for Renoise working with the CDP8 binaries. Very cool interface, with the added attraction of the Renoise sample editor. Still willing to work on Soundloom for the Mac though.

richarddobson commented 1 year ago

That's great! Since the portaudio issue is resolved, may I invite you to close the issue on github? We can email privately about Soundloom, and I can send you a zip of all the required 'cdp' files in their respective directories. I will send a test message to the most recent address I have for you (from the Csound list). If you haven't heard from me by Wednesday morning, send me an email on my address as shown on my home page.

Richard.

On 04/09/2023 21:51, davephillips wrote:

Btw, I have the CDP Tool for Renoise working with the CDP8 binaries. Very cool interface, with the added attraction of the Renoise sample editor. Still willing to work on Soundloom for the Mac though.

— Reply to this email directly, view it on GitHub https://github.com/ComposersDesktop/CDP8/issues/1#issuecomment-1705691720, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNHS4UDUSCIU5VWZOADO4DXYY5OZANCNFSM6AAAAAA4CIJ7FE. You are receiving this because you commented.Message ID: @.***>

davephillips commented 1 year ago

Done. Thank you !