curl / curl

A command line tool and library for transferring data with URL syntax, supporting DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, MQTT, POP3, POP3S, RTMP, RTMPS, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS and WSS. libcurl offers a myriad of powerful features
https://curl.se/
Other
35.86k stars 6.42k forks source link

Cannot build for iOS simulator on macOS 13.2 with Xcode 14 #11215

Closed afalkenhahn closed 1 year ago

afalkenhahn commented 1 year ago

I did this

export CC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
export CFLAGS="-arch arm64 -O2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.2.sdk -mios-simulator-version-min=8.0"
export LDFLAGS="-arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.2.sdk -mios-simulator-version-min=8.0"
export IPHONEOS_DEPLOYMENT_TARGET=8.0
cd curl-8.0.1
mkdir buildiossimulator
cd buildiossimulator
../configure --with-secure-transport --with-pic --disable-shared --host=aarch64-apple-darwin

I expected the following

Build curl for iOS simulator but the configure script doesn't seem to find sys/types.h. Here is something interesting from config.log:

configure:7800: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -o conftest -arch arm64 -O2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.2.sdk -mios-simulator-version-min=8.0  -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.2.sdk -mios-simulator-version-min=8.0 conftest.c  >&5
configure:7800: $? = 0
conftest.c:25:10: fatal error: 'sys/types.h' file not found
#include <sys/types.h>
         ^~~~~~~~~~~~~
1 error generated.
conftest.c:26:10: fatal error: 'sys/types.h' file not found
#include <sys/types.h>
         ^~~~~~~~~~~~~
1 error generated.

I've tried to reproduce the problem by compiling this little test program:

#include <sys/types.h>

int main(int argc, char *argv[])
{
        return 0;
}

But when compiling above test program using the very same line taken from config.log, it works and there is no complaint about sys/types.h cannot be found:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -c -arch arm64 -O2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.2.sdk -mios-simulator-version-min=8.0 -Qunused-arguments -Wno-pointer-bool-conversion -Werror=partial-availability test.c

So what is going on in the configure script that it cannot find sys/types.h?

curl/libcurl version

8.0.1

operating system

macOS

nickzman commented 1 year ago

Are you sure that you have the latest command line developer tools installed? I've seen this sort of thing happen when building curl & either the command line tools were not installed, or an old version was installed.

You can make sure by running xcode-select --install from the command line.

afalkenhahn commented 1 year ago

Thanks for the comment but running xcode-select --install didn't change anything. As I said above, when compiling a little test program using the same line as found in config.log there is no problem at all so it's a bit weird what's going on with configure.

afalkenhahn commented 1 year ago

FWIW here is the full output of configure: (see below for an analysis)

checking whether to enable maintainer-specific portions of Makefiles... no
checking whether make supports nested variables... yes
checking whether to enable debug build options... no
checking whether to enable compiler optimizer... (assumed) yes
checking whether to enable strict compiler warnings... no
checking whether to enable compiler warnings as errors... no
checking whether to enable curl debug memory tracking... no
checking whether to enable hiding of library internal symbols... yes
checking whether to enable c-ares for DNS lookups... no
checking whether to disable dependency on -lrt... (assumed no)
checking whether to enable ECH support... no
checking for path separator... :
checking for sed... /usr/bin/sed
checking for grep... /usr/bin/grep
checking that grep -E works... yes
checking for aarch64-apple-darwin-ar... no
checking for ar... /usr/bin/ar
checking for a BSD-compatible install... /usr/bin/install -c
checking for aarch64-apple-darwin-gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang accepts -g... yes
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang option to enable C11 features... none needed
checking whether /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang understands -c and -o together... yes
checking how to run the C preprocessor... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -E
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for stdatomic.h... yes
checking if _Atomic is available... yes
checking for a sed that does not truncate output... (cached) /usr/bin/sed
checking for code coverage support... no
checking whether build environment is sane... yes
checking for aarch64-apple-darwin-strip... no
checking for strip... strip
configure: WARNING: using cross tools not prefixed with host triplet
checking for a race-free mkdir -p... ../install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang... gcc3
checking curl version... 8.0.1
checking for httpd... /usr/sbin/httpd
checking for apachectl... /usr/sbin/apachectl
checking for apxs... no
configure: apxs not in PATH, httpd tests disabled
checking for nghttpx... no
checking for caddy... no
checking build system type... aarch64-apple-darwin22.3.0
checking host system type... aarch64-apple-darwin
checking for grep that handles long lines and -e... (cached) /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking if OS is AIX (to define _ALL_SOURCE)... no
checking if _THREAD_SAFE is already defined... no
checking if _THREAD_SAFE is actually needed... no
checking if _THREAD_SAFE is onwards defined... no
checking if _REENTRANT is already defined... no
checking if _REENTRANT is actually needed... no
checking if _REENTRANT is onwards defined... no
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
checking if the linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... no
checking for aarch64-apple-darwin-dumpbin... no
checking for aarch64-apple-darwin-link... no
checking for dumpbin... no
checking for link... link -dump
checking the name lister (nm) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 786432
checking how to convert aarch64-apple-darwin22.3.0 file names to aarch64-apple-darwin format... func_convert_file_noop
checking how to convert aarch64-apple-darwin22.3.0 file names to toolchain format... func_convert_file_noop
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld option to reload object files... -r
checking for aarch64-apple-darwin-file... no
checking for file... file
checking for aarch64-apple-darwin-objdump... no
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for aarch64-apple-darwin-dlltool... no
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for aarch64-apple-darwin-ar... /usr/bin/ar
checking for archiver @FILE support... no
checking for aarch64-apple-darwin-strip... strip
checking for aarch64-apple-darwin-ranlib... no
checking for ranlib... ranlib
checking command to parse nm output from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for aarch64-apple-darwin-mt... no
checking for mt... no
checking if : is a manifest tool... no
checking for aarch64-apple-darwin-dsymutil... no
checking for dsymutil... dsymutil
checking for aarch64-apple-darwin-nmedit... no
checking for nmedit... nmedit
checking for aarch64-apple-darwin-lipo... no
checking for lipo... lipo
checking for aarch64-apple-darwin-otool... no
checking for otool... otool
checking for aarch64-apple-darwin-otool64... no
checking for otool64... no
checking for -single_module linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking for -force_load linker flag... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang supports -fno-rtti -fno-exceptions... yes
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang option to produce PIC... -fno-common -DPIC
checking if /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang PIC flag -fno-common -DPIC works... yes
checking if /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang static flag -static works... no
checking if /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang supports -c -o file.o... yes
checking if /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang supports -c -o file.o... (cached) yes
checking whether the /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking whether to build shared libraries with -version-info... yes
checking whether to build shared libraries with -no-undefined... no
checking whether to build shared libraries with -mimpure-text... no
checking whether to build shared libraries with PIC... yes
checking whether to build static libraries with PIC... yes
checking whether to build shared libraries only... no
checking whether to build static libraries only... yes
checking for aarch64-apple-darwin-windres... no
checking for windres... no
checking for inline... inline
checking if cpp -P is needed... no
checking if compiler is DEC/Compaq/HP C... no
checking if compiler is HP-UX C... no
checking if compiler is IBM C... no
checking if compiler is Intel C... no
checking if compiler is clang... yes
checking if compiler is xlclang... no
checking if compiler is GNU C... no
checking if compiler is LCC... no
checking if compiler is SGI MIPSpro C... no
checking if compiler is SGI MIPS C... no
checking if compiler is SunPro C... no
checking if compiler is Tiny C... no
checking if compiler accepts some basic options... yes
configure: compiler options added: -Qunused-arguments -Wno-pointer-bool-conversion 
checking if compiler optimizer assumed setting might be used... no
checking if compiler halts on compilation errors... yes
checking if compiler halts on negative sized arrays... yes
checking if compiler halts on function prototype mismatch... yes
checking if compiler supports hiding library internal symbols... yes
checking for windows.h... no
checking whether build target is a native Windows one... no
checking whether build target supports WIN32 file API... no
checking whether build target supports WIN32 crypto API... no
checking for good-to-use Darwin CFLAGS... yes
checking whether /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang accepts -Werror=partial-availability... yes
checking whether to link macOS CoreFoundation and SystemConfiguration framework... no
checking to see if the compiler supports __builtin_available()... yes
checking whether to support http... yes
checking whether to support ftp... yes
checking whether to support file... yes
checking whether to support ldap... yes
checking whether to support ldaps... yes
checking whether to support rtsp... yes
checking whether to support proxies... yes
checking whether to support dict... yes
checking whether to support telnet... yes
checking whether to support tftp... yes
checking whether to support pop3... yes
checking whether to support imap... yes
checking whether to support smb... yes
checking whether to support smtp... yes
checking whether to support gopher... yes
checking whether to support mqtt... no
checking whether to provide built-in manual... yes
checking whether to enable generation of C code... yes
checking whether to use libgcc... no
checking if X/Open network library is required... no
checking for gethostbyname... yes
checking for windows.h... (cached) no
checking for winsock2.h... (cached) no
checking for proto/bsdsocket.h... no
checking for connect in libraries... yes
checking for sys/types.h... (cached) yes
checking for sys/time.h... yes
checking for monotonic clock_gettime... no
checking for aarch64-apple-darwin-pkg-config... no
checking for pkg-config... no
checking for inflateEnd in -lz... yes
checking for zlib.h... yes
configure: found both libz and libz.h header
checking for BrotliDecoderDecompress in -lbrotlidec... no
checking for brotli/decode.h... no
checking for ZSTD_createDStream in -lzstd... no
checking for zstd.h... no
checking for lber.h... no
checking for ldap.h... no
checking for ldap_ssl.h... no
checking for LDAP libraries... cannot find LDAP libraries
configure: WARNING: Cannot find libraries for LDAP support: LDAP disabled
checking whether to enable IPv6... yes
checking if struct sockaddr_in6 has sin6_scope_id member... yes
checking if argv can be written to... no
configure: WARNING: the previous check could not be made default was used
checking if GSS-API support is requested... no
checking whether to enable Windows native SSL/TLS... no
checking whether to enable Secure Transport... yes
checking whether to enable Amiga native SSL/TLS (AmiSSL v5)... no
configure: built with one SSL backend
checking for library containing psl_builtin... no
configure: WARNING: libpsl was not found
checking for library containing gsasl_init... no
configure: WARNING: libgsasl was not found
checking for RTMP_Init in -lrtmp... no
checking whether versioned symbols are wanted... no
checking whether to enable Windows native IDN (Windows native builds only)... no
checking whether to build with libidn2... (assumed) yes
checking for aarch64-apple-darwin-pkg-config... no
checking for pkg-config... no
configure: IDN_LIBS: "-lidn2"
configure: IDN_LDFLAGS: ""
configure: IDN_CPPFLAGS: ""
configure: IDN_DIR: ""
checking if idn2_lookup_ul can be linked... no
checking for idn2.h... no
configure: WARNING: Cannot find libraries for IDN support: IDN disabled
checking for aarch64-apple-darwin-pkg-config... no
checking for pkg-config... no
checking for nghttp2_session_set_local_window_size in -lnghttp2... no
checking for aarch64-apple-darwin-pkg-config... no
checking for pkg-config... no
checking for sys/types.h... (cached) yes
checking for sys/time.h... (cached) yes
checking for sys/select.h... yes
checking for sys/socket.h... yes
checking for sys/ioctl.h... yes
checking for sys/uio.h... yes
checking for unistd.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for arpa/inet.h... yes
checking for net/if.h... yes
checking for netinet/in.h... yes
checking for netinet/in6.h... no
checking for sys/un.h... yes
checking for linux/tcp.h... no
checking for netinet/tcp.h... yes
checking for netinet/udp.h... yes
checking for netdb.h... yes
checking for sys/sockio.h... yes
checking for sys/stat.h... (cached) yes
checking for sys/param.h... yes
checking for termios.h... yes
checking for termio.h... no
checking for fcntl.h... yes
checking for io.h... no
checking for pwd.h... yes
checking for utime.h... yes
checking for sys/utime.h... no
checking for sys/poll.h... yes
checking for poll.h... yes
checking for socket.h... no
checking for sys/resource.h... yes
checking for libgen.h... yes
checking for locale.h... yes
checking for stdbool.h... yes
checking for arpa/tftp.h... no
checking for sys/filio.h... yes
checking for sys/wait.h... yes
checking for setjmp.h... yes
checking for an ANSI C-conforming const... yes
checking for compiler support of C99 variadic macro style... yes
checking for compiler support of old gcc variadic macro style... yes
checking for size_t... yes
checking for sys/types.h... (cached) yes
checking for sys/time.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for struct timeval... yes
checking size of size_t... 8
checking size of long... 8
checking size of int... 4
checking size of time_t... 8
checking size of off_t... 8
checking size of curl_off_t... 8
checking for long long... yes
checking for ssize_t... yes
checking for bool... yes
checking for sa_family_t... yes
checking for suseconds_t... yes
checking if time_t is unsigned... no
checking for sys/types.h... (cached) yes
checking for poll.h... (cached) yes
checking for sys/poll.h... (cached) yes
checking for in_addr_t... yes
checking for struct sockaddr_storage... yes
checking for sys/select.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for select... yes
checking for sys/types.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for recv... yes
checking for sys/types.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for send... yes
checking for sys/types.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for MSG_NOSIGNAL... yes
checking for sys/types.h... (cached) yes
checking for unistd.h... (cached) yes
checking if alarm can be linked... yes
checking if alarm is prototyped... no
checking if alarm might be used... no
checking for sys/types.h... (cached) yes
checking for string.h... (cached) yes
checking for strings.h... (cached) yes
checking for sys/types.h... (cached) yes
checking for libgen.h... (cached) yes
checking if basename can be linked... yes
checking if basename is prototyped... no
checking if basename might be used... no
checking for sys/types.h... (cached) yes
checking for socket.h... (cached) no
checking if closesocket can be linked... no
checking if closesocket might be used... no
checking for sys/types.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking if CloseSocket can be linked... no
checking if CloseSocket might be used... no
checking if connect can be linked... yes
checking if connect is prototyped... no
checking if connect might be used... no
checking for sys/types.h... (cached) yes
checking for unistd.h... (cached) yes
checking for fcntl.h... (cached) yes
checking if fcntl can be linked... yes
checking if fcntl is prototyped... no
checking if fcntl might be used... no
checking for windows.h... (cached) no
checking for winsock2.h... (cached) no
checking for ws2tcpip.h... (cached) no
checking for sys/types.h... (cached) yes
checking for netdb.h... (cached) yes
checking if freeaddrinfo can be linked... yes
checking if freeaddrinfo is prototyped... no
checking if freeaddrinfo might be used... no
checking for sys/types.h... (cached) yes
checking for sys/xattr.h... yes
checking if fsetxattr can be linked... yes
checking if fsetxattr is prototyped... no
checking if fsetxattr might be used... no
checking if ftruncate can be linked... yes
checking if ftruncate is prototyped... no
checking if ftruncate might be used... no
checking for sys/types.h... (cached) yes
checking for stdlib.h... (cached) yes
checking if getaddrinfo can be linked... yes
checking if getaddrinfo is prototyped... no
checking if getaddrinfo might be used... no
checking if gethostbyname can be linked... yes
checking if gethostbyname is prototyped... no
checking if gethostbyname might be used... no
checking if gethostbyname_r can be linked... no
checking if gethostbyname_r might be used... no
checking if gethostname can be linked... yes
checking if gethostname is prototyped... no
checking if gethostname might be used... no
checking if getpeername can be linked... yes
checking if getpeername is prototyped... no
checking if getpeername might be used... no
checking if getsockname can be linked... yes
checking if getsockname is prototyped... no
checking if getsockname might be used... no
checking for net/if.h... (cached) yes
checking if if_nametoindex can be linked... yes
checking if if_nametoindex is prototyped... no
checking if if_nametoindex might be used... no
checking for sys/types.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for netinet/in.h... (cached) yes
checking for ifaddrs.h... yes
checking if getifaddrs can be linked... yes
checking if getifaddrs is prototyped... no
checking if getifaddrs might be used... no
checking for sys/types.h... (cached) yes
checking for sys/time.h... (cached) yes
checking if gmtime_r can be linked... yes
checking if gmtime_r is prototyped... no
checking if gmtime_r might be used... no
checking for sys/types.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for netinet/in.h... (cached) yes
checking for arpa/inet.h... (cached) yes
checking if inet_ntop can be linked... yes
checking if inet_ntop is prototyped... no
checking if inet_ntop might be used... no
checking if inet_pton can be linked... yes
checking if inet_pton is prototyped... no
checking if inet_pton might be used... no
checking if ioctlsocket can be linked... no
checking if ioctlsocket might be used... no
checking if IoctlSocket can be linked... no
checking if IoctlSocket might be used... no
checking if memrchr can be linked... no
checking if memrchr seems a macro... no
checking if memrchr might be used... no
checking if poll can be linked... yes
checking if poll is prototyped... no
checking if poll might be used... no
checking for sys/types.h... (cached) yes
checking for signal.h... yes
checking if sigaction can be linked... yes
checking if sigaction is prototyped... no
checking if sigaction might be used... no
checking if siginterrupt can be linked... yes
checking if siginterrupt is prototyped... no
checking if siginterrupt might be used... no
checking if signal can be linked... yes
checking if signal is prototyped... no
checking if signal might be used... no
checking for sys/types.h... (cached) yes
checking for setjmp.h... (cached) yes
checking if sigsetjmp can be linked... yes
checking if sigsetjmp is prototyped... no
checking if sigsetjmp might be used... no
checking if socket can be linked... yes
checking if socket is prototyped... no
checking if socket might be used... no
checking if socketpair can be linked... yes
checking if socketpair is prototyped... no
checking if socketpair might be used... no
checking if strcasecmp can be linked... yes
checking if strcasecmp is prototyped... no
checking if strcasecmp might be used... no
checking if strcmpi can be linked... no
checking if strcmpi might be used... no
checking if strdup can be linked... yes
checking if strdup is prototyped... no
checking if strdup might be used... no
checking if strerror_r can be linked... yes
checking if strerror_r is prototyped... no
checking if strerror_r might be used... no
checking if stricmp can be linked... no
checking if stricmp might be used... no
checking if strtok_r can be linked... yes
checking if strtok_r is prototyped... no
checking if strtok_r might be used... no
checking if strtoll can be linked... yes
checking if strtoll is prototyped... no
checking if strtoll might be used... no
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang options needed to detect all undeclared functions... none needed
checking whether getpwuid_r is declared... yes
checking for fnmatch... yes
checking for fchmod... yes
checking for fork... yes
checking for geteuid... yes
checking for getpass_r... no
checking deeper for getpass_r... but still no
checking for getppid... yes
checking for getpwuid... yes
checking for getpwuid_r... yes
checking for getrlimit... yes
checking for gettimeofday... yes
checking for if_nametoindex... yes
checking for mach_absolute_time... yes
checking for pipe... yes
checking for sched_yield... yes
checking for sendmsg... yes
checking for setlocale... yes
checking for setmode... yes
checking for setrlimit... yes
checking for snprintf... yes
checking for utime... yes
checking for utimes... yes
checking for arc4random... yes
checking how to set a socket into non-blocking mode... unknown
configure: WARNING: cannot determine non-blocking socket method.
checking for perl... /usr/bin/perl
checking for gnroff... no
checking for nroff... no
configure: WARNING: disabling built-in manual
checking whether to enable the threaded resolver... yes
checking whether to use POSIX threads for threaded resolver... auto
checking for pthread.h... yes
checking for pthread_create... yes
checking convert -I options to -isystem... yes
checking whether to enable verbose strings... yes
checking whether to enable SSPI support (Windows native builds only)... no
checking whether to enable cryptographic authentication methods... yes
checking whether to support NTLM... yes
checking whether to enable NTLM delegation to winbind's helper... yes
checking whether to enable TLS-SRP authentication... yes
checking whether to enable Unix domain sockets... auto
checking for struct sockaddr_un.sun_path... yes
checking whether to support cookies... yes
checking whether to support socketpair... yes
checking whether to support HTTP authentication... yes
checking whether to support DoH... yes
checking whether to support the MIME API... yes
checking whether to support date parsing... yes
checking whether to support netrc parsing... yes
checking whether to support progress-meter... yes
checking whether to support DNS shuffling... yes
checking whether to support curl_easy_option*... yes
checking whether to support alt-svc... yes
checking whether to support headers-api... yes
checking whether to support HSTS... yes
checking whether to support WebSockets... no
checking whether hiding of library internal symbols will actually happen... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating docs/Makefile
config.status: creating docs/examples/Makefile
config.status: creating docs/libcurl/Makefile
config.status: creating docs/libcurl/opts/Makefile
config.status: creating docs/cmdline-opts/Makefile
config.status: creating include/Makefile
config.status: creating include/curl/Makefile
config.status: creating src/Makefile
config.status: creating lib/Makefile
config.status: creating scripts/Makefile
config.status: creating lib/libcurl.vers
config.status: creating lib/libcurl.plist
config.status: creating tests/Makefile
config.status: creating tests/config
config.status: creating tests/certs/Makefile
config.status: creating tests/certs/scripts/Makefile
config.status: creating tests/data/Makefile
config.status: creating tests/server/Makefile
config.status: creating tests/libtest/Makefile
config.status: creating tests/unit/Makefile
config.status: creating tests/http/config.ini
config.status: creating tests/http/Makefile
config.status: creating packages/Makefile
config.status: creating packages/vms/Makefile
config.status: creating curl-config
config.status: creating libcurl.pc
config.status: creating lib/curl_config.h
config.status: executing depfiles commands
config.status: executing libtool commands
configure: Configured to build curl/libcurl:

  Host setup:       aarch64-apple-darwin
  Install prefix:   /usr/local
  Compiler:         /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
   CFLAGS:          -arch arm64 -O2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.2.sdk -mios-simulator-version-min=8.0 -Qunused-arguments -Wno-pointer-bool-conversion -Werror=partial-availability
   CPPFLAGS:        
   LDFLAGS:         -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.2.sdk -mios-simulator-version-min=8.0 -framework CoreFoundation -framework Security
   LIBS:            -lz

  curl version:     8.0.1
  SSL:              enabled (Secure Transport)
  SSH:              no      (--with-{libssh,libssh2})
  zlib:             enabled
  brotli:           no      (--with-brotli)
  zstd:             no      (--with-zstd)
  GSS-API:          no      (--with-gssapi)
  GSASL:            no      (libgsasl not found)
  TLS-SRP:          no      (--enable-tls-srp)
  resolver:         POSIX threaded
  IPv6:             enabled
  Unix sockets:     enabled
  IDN:              no      (--with-{libidn2,winidn})
  Build libcurl:    Shared=no, Static=yes
  Built-in manual:  no      (--enable-manual)
  --libcurl option: enabled (--disable-libcurl-option)
  Verbose errors:   enabled (--disable-verbose)
  Code coverage:    disabled
  SSPI:             no      (--enable-sspi)
  ca cert bundle:   no
  ca cert path:     
  ca fallback:      
  LDAP:             no      (--enable-ldap / --with-ldap-lib / --with-lber-lib)
  LDAPS:            no      (--enable-ldaps)
  RTSP:             enabled
  RTMP:             no      (--with-librtmp)
  PSL:              no      (libpsl not found)
  Alt-svc:          enabled (--disable-alt-svc)
  Headers API:      enabled (--disable-headers-api)
  HSTS:             enabled (--disable-hsts)
  HTTP1:            enabled (internal)
  HTTP2:            no      (--with-nghttp2, --with-hyper)
  HTTP3:            no      (--with-ngtcp2, --with-quiche --with-msh3)
  ECH:              no      (--enable-ech)
  WebSockets:       no      (--enable-websockets)
  Protocols:        DICT FILE FTP FTPS GOPHER GOPHERS HTTP HTTPS IMAP IMAPS MQTT POP3 POP3S RTSP SMB SMBS SMTP SMTPS TELNET TFTP
  Features:         AsynchDNS HSTS HTTPS-proxy IPv6 Largefile NTLM NTLM_WB SSL UnixSockets alt-svc libz threadsafe

What is confusing is this:

  1. Checking for sys/types.h actually succeeds!
  2. But later checking if fcntl is prototyped fails because the file sys/types.h is missing! How come? Here is the relevant passage from config.log:
configure:36501: checking if fcntl is prototyped
conftest.c:115:12: fatal error: 'sys/types.h' file not found
#  include <sys/types.h>
           ^~~~~~~~~~~~~
1 error generated.
configure:36519: result: no

How can it be that configure first says that sys/types.h is available while later failing because it is not available! I don't get that. The fact that the check whether fcntl is prototyped fails then causes lots of other troubles, e.g. it causes configure to skip checking if fcntl O_NONBLOCK is compilable which in turn leads to HAVE_FCNTL_O_NONBLOCK being undefined which in turn leads to curl being uncompilable because nonblock.c fails to compile because no non-blocking method was found/set/used.

What's going on?

ryandesign commented 1 year ago

All of the "is prototyped" checks are failing for you. The same happened to me when following someone else's recipe for building for iOS.

What is confusing is this:

  1. Checking for sys/types.h actually succeeds!

These checks are performed by the compiler. The compiler uses CPPFLAGS and CFLAGS. You're setting the -isysroot flag in CFLAGS which tells the compiler where the headers are so it succeeds.

  1. But later checking if fcntl is prototyped fails because the file sys/types.h is missing! How come?

These checks are performed by the preprocessor. The preprocessor only uses CPPFLAGS, not CFLAGS nor LDFLAGS. You haven't set -isysroot in CPPFLAGS so it doesn't know where the headers are.

What the recipe I followed and yours have in common is that they set CC to the path to clang within the Xcode default toolchain directory and they haven't added the -isysroot flag in CPPFLAGS. This combination seems to be problematic.

There are a couple possible solutions:

  1. Also set CPPFLAGS:

    export CPPFLAGS ="-arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.2.sdk -mios-simulator-version-min=8.0"
  2. Don't set CC. When you don't set CC, the default compiler will be used, and it seems to use the default (macOS) SDK. On the other hand, when you set CC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang", that compiler doesn't appear to have any default SDK and you have to tell it what SDK to use. Not setting CC is essentially what the documentation says to do:

    https://github.com/curl/curl/blob/3c0a91077c2af4a34f5ac177dd5ec8149ce479d7/docs/INSTALL.md?plain=1#L362-L369

    That "works" in that it builds, but I'm not convinced it's correct. Because it's not setting CC, the default compiler is used. Because it's not setting CPPFLAGS, all those configure script checks to see whether something "is prototyped" are checking the default (macOS) SDK, not the other (e.g. iOS) SDK you want. Conceivably there could be differences between the macOS and iOS SDKs such that this would matter.

  3. Set CC such that the -isysroot, -arch, and -m flags are in there; then you don't need to set them in CFLAGS, CPPFLAGS, or LDFLAGS:

    export CC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.2.sdk -mios-simulator-version-min=8.0"
  4. Set CC to use xcrun which takes care of setting the sysroot for you; this seems simplest. Here's my slightly modified version of the script from the documentation; I believe this will correctly test the capabilities of the intended SDK:

    export ARCH=arm64
    export SDK=iphoneos
    export DEPLOYMENT_TARGET=11.0
    
    export CC="xcrun -sdk $SDK cc -arch $ARCH -m$SDK-version-min=$DEPLOYMENT_TARGET"
    ./configure --host=$ARCH-apple-darwin --prefix $(pwd)/artifacts --with-secure-transport
    make -j8
    make install
ryandesign commented 1 year ago

It's not a bug though. It's a user error for supplying incomplete information to the build system.

bagder commented 1 year ago

ok, thanks! I will revert that

afalkenhahn commented 1 year ago

I'm a bit late but I just wanted to confirm that I could indeed fix the issue by setting CPPFLAGS. Thanks @ryandesign for the detailed information!

Interestingly, I build for non-simulator iOS on a different machine using an older version of Xcode and on that machine setting CPPFLAGS isn't necessary to build curl, CFLAGS is sufficient. That's why I never thought of setting CPPFLAGS as well but apparently it's necessary with newer Xcode versions and/or Macs.