It worked for me on my M2 mac but only after uninstalling and reinstalling Command Line Tools.
Hopefully the problem I had was unique to me. I got an error when I ran ./configure on my M2 mac:
checking C++ standard library flavour... actest.cpp:1:10: fatal error: 'iostream' file not found
1 | #include <iostream>
| ^~~~~~~~~~
1 error generated.
configure: error: Failed to compile test program
Following is the complete output I got
checking for opt-17... no
checking for opt-17.0... no
checking for opt17... no
checking for opt-16... no
checking for opt-16.0... no
checking for opt16... no
checking for opt-15... no
checking for opt-15.0... no
checking for opt15... no
checking for opt-14... no
checking for opt-14.0... no
checking for opt14... no
checking for opt-13... no
checking for opt-13.0... no
checking for opt13... no
checking for opt... opt
checking opt version (18.1.8) is between 13 and 20... yes
checking for clang-19... no
checking for clang-19.0... no
checking for clang19... no
checking for clang-18... clang-18
checking clang-18 version (18.1.8) is between 13 and 20... yes
configure: $CC is not gcc; assuming it's a reasonably new C compiler
checking whether CC supports -no-pie... no
checking whether CC supports flags passed by GHC when compiling via C... yes
checking Setting up CFLAGS, LDFLAGS, IGNORE_LINKER_LD_FLAGS and CPPFLAGS... done
checking Setting up CONF_CC_OPTS_STAGE0, CONF_GCC_LINKER_OPTS_STAGE0, CONF_LD_LINKER_OPTS_STAGE0 and CONF_CPP_OPTS_STAGE0... done
checking Setting up CONF_CC_OPTS_STAGE1, CONF_GCC_LINKER_OPTS_STAGE1, CONF_LD_LINKER_OPTS_STAGE1 and CONF_CPP_OPTS_STAGE1... done
checking Setting up CONF_CC_OPTS_STAGE2, CONF_GCC_LINKER_OPTS_STAGE2, CONF_LD_LINKER_OPTS_STAGE2 and CONF_CPP_OPTS_STAGE2... done
checking whether ld64 requires -no_fixup_chains... yes
checking whether ld64 requires -no_fixup_chains... yes
checking whether ld64 requires -no_fixup_chains... yes
checking whether ld64 requires -no_fixup_chains... yes
checking whether the linker requires -no_warn_duplicate_libraries... yes
checking whether the linker requires -no_warn_duplicate_libraries... yes
checking whether the linker requires -no_warn_duplicate_libraries... yes
checking whether ld supports response files... yes
checking C++ standard library flavour... actest.cpp:1:10: fatal error: 'iostream' file not found
1 | #include <iostream>
| ^~~~~~~~~~
1 error generated.
configure: error: Failed to compile test program