Skip to content

PortAudio: Enable build on macOS/arm64 #84

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ChinYikMing
Copy link
Collaborator

Quote from portaudio/config.log:
...
configure:3194: checking whether the C compiler works
configure:3216: gcc -I/opt/homebrew/opt/zlib/include portaudio/lib/.libs/libportaudio.a -framework CoreServices -framework CoreFoundation -framework AudioUnit -framewo rk AudioToolbox -framework CoreAudio -lpthread -lm mini-gdbstub/build/libgdbstub.a conftest.c >&5
clang: error: no such file or directory: 'portaudio/lib/.libs/libportaudio.a'
...
configure:3265: error: C compiler cannot create executables
...

The ./configure script fails on macOS because LDFLAGS includes static libraries (libportaudio.a) that have not yet been built. This causes the compiler check to fail with "C compiler cannot create executables".

This patch unsets LDFLAGS during the configure step to allow the test program to compile and link successfully, enabling builds on macOS.

Related: #76

Environment

OS: macOS/arm64 Version 15.3.1 (Darwin 24.3.0 Darwin Kernel Version 24.3.0)
Compiler: Apple clang version 16.0.0 (clang-1600.0.26.6)

Reproduce

$ make check

Expected error

git submodule update --init portaudio
cd portaudio/ && ./configure --without-sndio
checking build system type... arm-apple-darwin24.3.0
checking host system type... arm-apple-darwin24.3.0
checking target system type... arm-apple-darwin24.3.0
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/tmp/semu/portaudio':
configure: error: C compiler cannot create executables
See `config.log' for more details
make: *** [Makefile:100: portaudio/lib/.libs/libportaudio.a] Error 77

@ChinYikMing
Copy link
Collaborator Author

Tested and also worked on Ubuntu 22.04/x86_64 (6.5.0-41-generic) with gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.. @shengwen-tw @Cuda-Chen Could you please verify the claim? Thanks!

Quote from portaudio/config.log:
...
configure:3194: checking whether the C compiler works
configure:3216: gcc  -I/opt/homebrew/opt/zlib/include portaudio/lib/.libs/libportaudio.a -framework CoreServices -framework CoreFoundation -framework AudioUnit -framewo    rk AudioToolbox -framework CoreAudio -lpthread -lm mini-gdbstub/build/libgdbstub.a conftest.c  >&5
clang: error: no such file or directory: 'portaudio/lib/.libs/libportaudio.a'
...
configure:3265: error: C compiler cannot create executables
...

The ./configure script fails on macOS because LDFLAGS includes static
libraries (libportaudio.a) that have not yet been built. This causes the
compiler check to fail with "C compiler cannot create executables".

This patch unsets LDFLAGS during the configure step to allow the test
program to compile and link successfully, enabling builds on macOS.

Related: sysprog21#76
@ChinYikMing ChinYikMing force-pushed the fix/portaudio_build_macOS branch from f19cd97 to 2757b2c Compare June 10, 2025 17:55
@shengwen-tw
Copy link
Collaborator

@ChinYikMing

Could you try rewriting like this?

$(PORTAUDIOLIB): export LDFLAGS :=
$(PORTAUDIOLIB): portaudio/Makefile
	cd $(dir $<) && ./configure --without-sndio
	cd $(dir $<) && ./configure --without-sndio
	$(MAKE) -C $(dir $<)
...

@Cuda-Chen
Copy link
Collaborator

Hi @ChinYikMing ,

It may take more time for me to review as my testing environment encounters an unrecoverable accident.

@shengwen-tw and @jserv , if you and @ChinYikMing thinks no need to test on Linux Kernel 5.15, you can just approve this PR.

@ChinYikMing
Copy link
Collaborator Author

@ChinYikMing

Could you try rewriting like this?

$(PORTAUDIOLIB): export LDFLAGS :=
$(PORTAUDIOLIB): portaudio/Makefile
	cd $(dir $<) && ./configure --without-sndio
	cd $(dir $<) && ./configure --without-sndio
	$(MAKE) -C $(dir $<)
...
cd $(dir $<) && ./configure --without-sndio

@shengwen-tw Is this command redundant? Removing it doesn't affect functionality. It performs the same action as the proposed change, which unsets LDFLAGS. I'll keep the original change for shorter.

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

Successfully merging this pull request may close these issues.

4 participants