curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

c-ares linking problem on Apple, cross-compiling for ARM.

From: Ben Greear via curl-library <curl-library_at_lists.haxx.se>
Date: Tue, 24 Jan 2023 21:45:52 -0800

So, I'm well off in the weeds here.

Trying to compile lib-cares on macos (using clang), for ARM target on x86-64 macos machine. I'm able to see the
c files compiled for the right target, but the linker part is not passing the -target
flag it seems.

This inline hack to the auto-generated libtool will make it compile:

  perl -i.bkp -pe 's/^archive_cmds.*\K-install_name/-target arm64-apple-macos11 -install_name/' libtool

Here is diff for reference:

< archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -target arm64-apple-macos11 -install_name \$rpath/\$soname
\$verstring \$single_module"
---
 > archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring \$single_module"
12011c12011
< archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -target arm64-apple-macos11 -install_name \$rpath/\$soname 
\$verstring \$single_module"
---
 > archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring \$single_module"
I cannot figure out a better way to do this, but maybe someone can use this as a hint to fix it better.
Here is how I am doing the configure step:
(cd c-ares.ct && \
          export CFLAGS="-mmacosx-version-min=11.0 -target arm64-apple-macos11"; \
	 export LDFLAGS="-mmacosx-version-min=11.0 -target arm64-apple-macos11"; \
	 ./configure --enable-warnings --host=aarch64-apple-darwin && \
	 perl -i.bkp -pe 's/^archive_cmds.*\K-install_name/-target arm64-apple-macos11 -install_name/' libtool)
Thanks,
Ben
-- 
Ben Greear <greearb_at_candelatech.com>
Candela Technologies Inc  http://www.candelatech.com
-- 
Unsubscribe: https://lists.haxx.se/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2023-01-25