PortAudio / portaudio

PortAudio is a cross-platform, open-source C language library for real-time audio input and output.
Other
1.47k stars 304 forks source link

configure && make fails on Mac #505

Closed erikjalevik closed 3 years ago

erikjalevik commented 3 years ago

Describe the bug Cloning latest master on MacOS Catalina, and then running configure && make, as per instructions here, errors out before starting the build.

Is this still the correct way to build the latest code on Mac?

To Reproduce Steps to reproduce the behavior. Include code if applicable.

  1. Clone master branch
  2. Run configure && make

Expected behavior The library to be built.

Actual behavior During running of configure. a number of errors like the following get output:

configure: creating ./config.status
./config.status: line 733: print: command not found
./config.status: line 733: print: command not found
./config.status: line 733: print: command not found

During running of make:

mkdir lib
mkdir -p src/common src/hostapi/alsa src/hostapi/asihpi src/hostapi/asio src/hostapi/coreaudio src/hostapi/dsound src/hostapi/jack src/hostapi/oss src/hostapi/skeleton src/hostapi/wasapi src/hostapi/wdmks src/hostapi/wmme src/os/unix src/os/win
touch lib-stamp
/bin/sh ./libtool --mode=compile gcc -c -std=c99 -O2 -Wall -pedantic -pipe -fPIC -DNDEBUG -DPA_LITTLE_ENDIAN -I./include -I./src/common -I./src/os/unix -Wno-deprecated -Werror -arch x86_64 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -mmacosx-version-min=10.6  -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DSIZEOF_SHORT=2 -DSIZEOF_INT=4 -DSIZEOF_LONG=8 -DHAVE_CLOCK_GETTIME=1 -DHAVE_NANOSLEEP=1 -DPA_USE_COREAUDIO=1 src/common/pa_allocation.c -o src/common/pa_allocation.lo
./libtool: line 170: top_srcdir: command not found
./libtool: line 170: top_srcdir: command not found
./libtool: line 170: top_srcdir: command not found
./libtool: line 338: func_echo_all: command not found
./libtool: line 1037: print: command not found
./libtool: line 1037: print: command not found
./libtool: line 1037: print: command not found
./libtool: line 1037: print: command not found
./libtool: line 1037: print: command not found
./libtool: line 1037: print: command not found
./libtool: line 1037: print: command not found
./libtool: line 900: print: command not found
./libtool: line 900: print: command not found
./libtool: line 971: print: command not found
./libtool: line 973: print: command not found
./libtool: line 907: print: command not found
make: *** [src/common/pa_allocation.lo] Error 1

Desktop (please complete the following information):

Additional info I suspect I'm missing some prerequisites on my system but I have Xcode installed and am able to compile C/C++ code from other projects.

philburk commented 3 years ago

@erikjalevik - Thanks for reporting this. We recently changed the build scripts so we might have broken something.

Have you compiled PortAudio before on this computer?

What do you get if you enter these commands?

xcrun --sdk macosx --show-sdk-path
xcodebuild -version -sdk macosx Path
erikjalevik commented 3 years ago

Hi @philburk, here's the output:

√ ~ > xcrun --sdk macosx --show-sdk-path
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk
√ ~ > xcodebuild -version -sdk macosx Path
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk
Be-ing commented 3 years ago

Here is yet another reason why it is a bad idea to maintain multiple build systems.

philburk commented 3 years ago

Thanks @erikjalevik

Regarding "print: command not found". This post suggests it may be related to exporting CONFIG_SHELL. What do you get if you enter this?

echo $CONFIG_SHELL

I get a blank line.

Regarding top_srcdir, here is line 199 from our configure.in file:

CFLAGS="$CFLAGS -I\$(top_srcdir)/include -I\$(top_srcdir)/src/common"

I did some googling and found lots of posts about top_srcdir. Here is one fix that uses ${srcdir} instead of $(top_srcdir) in a M4 file.

Another post suggests using single quotes instead of double quotes to prevent macro expansion.

erikjalevik commented 3 years ago
echo $CONFIG_SHELL

I get a blank line.

Same thing here.

RossBencina commented 3 years ago

Just an idea: Apple switched from bash to zsh in Catalina. Perhaps zsh doesn't have a print command?

It's hard to find information on print in Bash. This post suggests to use echo instead: https://stackoverflow.com/questions/3891887/bash-print-command-not-found

philburk commented 3 years ago

@erikjalevik - We are concerned about this bug. We are holding up the 19.7 release until we figure out whether this is a regression or just a problem on your machine. Can you please try an experiment?

Please try compiling Portaudio from a point before we changed the Mac configure file. Here is the change that might have broken your build. https://github.com/PortAudio/portaudio/pull/470

We want to roll back to the commit right before that. To avoid erasing any work in progress, these instructions use a freshly cloned repository:

cd somewhere_safe    # any folder away from your main work
mkdir patest
cd patest
git clone https://github.com/PortAudio/portaudio.git
cd portaudio
git checkout -b oldcode 68e1c56
./configure && make clean && make
bin/paex_sine

Does that build?

philburk commented 3 years ago

Vitaly Ivanov reported that the current master top (not the commit from above):

Builds and works fine on my MBP (macOS 10.15.7, Xcode 12.3). As well as on two other machines with 11.2.1, one of them is M1 MB Air

jbclements commented 3 years ago

Yep, build runs fine for me, following instructions in email. Running the specified binary produces a loud sound. Thanks, now I'm deaf!

:)

MacBook Pro (Retina, 15-inch, Mid 2015) macOS 10.15.7 (19H15)

erikjalevik commented 3 years ago

Hi @philburk, here are my results.

Going back to commit 68e1c56 does indeed fix the problem. Everything configures and builds fine in both zsh and bash.

I also tried latest master in bash just now as well, and there I don't get the config.status and libtool errors. The build fails during compilation however with an "Unsupported architecture" error.

libtool: compile:  gcc -c -std=c99 -O2 -Wall -pedantic -pipe -fPIC -DNDEBUG -DPA_LITTLE_ENDIAN -I./include -I./src/common -I./src/os/unix -Wno-deprecated -Werror -arch x86_64 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -mmacosx-version-min=10.6 -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DSIZEOF_SHORT=2 -DSIZEOF_INT=4 -DSIZEOF_LONG=8 -DHAVE_CLOCK_GETTIME=1 -DHAVE_NANOSLEEP=1 -DPA_USE_COREAUDIO=1 src/common/pa_cpuload.c  -fno-common -DPIC -o src/common/.libs/pa_cpuload.o
In file included from src/common/pa_cpuload.c:55:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/assert.h:42:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/cdefs.h:807:2: error: 
      Unsupported architecture
#error Unsupported architecture
 ^
1 error generated.
make: *** [src/common/pa_cpuload.lo] Error 1
bash-3.2$ 

I'm guessing this is related to the -arch arm64 flag, as my Mac is an Intel-based one.

Hope that helps!

erikjalevik commented 3 years ago

Oh, and I just realised, that when using the latest master as of today (78415a838a8e4386539d5a1f69cb72d0591d2e2e), my configure and make steps work fine also in zsh. I'm getting to the point of the "Unsupported architecture" error with both zsh and bash.

philburk commented 3 years ago

Thanks all. So it seems the libtool errors are no longer a problem. The "make clean" may have fixed those.

But it seems the arm64 architecture should only be specified when the SDK supports arm64. How do we check for that in configure.in?

@erikjalevik - What do you get if you enter this command?

xcrun clang --print-supported-cpus --target=arm64
echo $?
erikjalevik commented 3 years ago

Here's what I get:

Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: arm64
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Available CPUs for this target:

    apple-latest
    cortex-a35
    cortex-a53
    cortex-a55
    cortex-a57
    cortex-a72
    cortex-a73
    cortex-a75
    cortex-a76
    cortex-a76ae
    cyclone
    exynos-m1
    exynos-m2
    exynos-m3
    exynos-m4
    exynos-m5
    falkor
    generic
    kryo
    saphira
    thunderx
    thunderx2t99
    thunderxt81
    thunderxt83
    thunderxt88
    tsv110
    vortex

Use -mcpu or -mtune to specify the target's processor.
For example, clang --target=aarch64-unknown-linux-gui -mcpu=cortex-a35
fllprbt commented 3 years ago

Vitaly Ivanov reported that the current master top (not the commit from above):

Builds and works fine on my MBP (macOS 10.15.7, Xcode 12.3). As well as on two other machines with 11.2.1, one of them is M1 MB Air

11.2.1 here can confirm 👍🏼

philburk commented 3 years ago

I checked configure and it does a test compile to validate the architectures. So if arm64 is not supported by the SDK then it should not get used. Yet Erik is getting an error. The error message comes from the file:

more $(xcrun --show-sdk-path)/usr/include/sys/cdefs.h

which contains:

#if !defined(__sys_cdefs_arch_unknown__) && defined(__i386__)
#elif !defined(__sys_cdefs_arch_unknown__) && defined(__x86_64__)
#elif !defined(__sys_cdefs_arch_unknown__) && defined(__arm__)
#elif !defined(__sys_cdefs_arch_unknown__) && defined(__arm64__)
#else
#error Unsupported architecture
#endif

on my SDK 11.1. I suspect that on Erik's SDK the like with arm64 is missing.

@erikjalevik - What do you get if you enter the following commands.

xcrun --show-sdk-version
grep arm64  $(xcrun --show-sdk-path)/usr/include/sys/cdefs.h
erikjalevik commented 3 years ago

Hi @philburk, sorry about the delayed reply.

xcrun --show-sdk-version returns 10.15.6.

grep arm64 $(xcrun --show-sdk-path)/usr/include/sys/cdefs.h returns nothing.

Taking a look inside my cdefs.h, the relevant section reads:

/*
 * Architecture validation for current SDK
 */
#if !defined(__sys_cdefs_arch_unknown__) && defined(__i386__)
#elif !defined(__sys_cdefs_arch_unknown__) && defined(__x86_64__)
#else
#error Unsupported architecture
#endif
philburk commented 3 years ago

@erikjalevik - I have prepared a new PR that I think will work for you and also for people with the latest SDK and an M1. Can you please try the current Portaudio mac build?

./configure
make clean && make
erikjalevik commented 3 years ago

Success!