tpoechtrager / osxcross

Mac OS X cross toolchain for Linux, FreeBSD, OpenBSD and Android (Termux)
GNU General Public License v2.0
2.8k stars 318 forks source link

Fialed to cross compile apple darwin target #412

Closed cavivie closed 3 months ago

cavivie commented 5 months ago

root@bf874e2bf9b5:/build/jemalloc# osxcross-env

export PATH=/opt/osxcross/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

root@bf874e2bf9b5:/build/jemalloc# osxcross-conf
export OSXCROSS_VERSION=1.5
export OSXCROSS_OSX_VERSION_MIN=10.6
export OSXCROSS_TARGET=darwin20.4
export OSXCROSS_BASE_DIR=/tmp/tmp.41JlJYVGeP/osxcross/build/..
export OSXCROSS_SDK=/opt/osxcross/bin/../SDK/MacOSX11.3.sdk
export OSXCROSS_SDK_DIR=/opt/osxcross/bin/../SDK/MacOSX11.3.sdk/..
export OSXCROSS_SDK_VERSION=11.3
export OSXCROSS_TARBALL_DIR=/tmp/tmp.41JlJYVGeP/osxcross/build/../tarballs
export OSXCROSS_PATCH_DIR=/tmp/tmp.41JlJYVGeP/osxcross/build/../patches
export OSXCROSS_TARGET_DIR=/opt/osxcross/bin/..
export OSXCROSS_DIR_SDK_TOOLS=/opt/osxcross/bin/../SDK/MacOSX11.3.sdk/../tools
export OSXCROSS_BUILD_DIR=/tmp/tmp.41JlJYVGeP/osxcross/build
export OSXCROSS_CCTOOLS_PATH=/opt/osxcross/bin
export OSXCROSS_LIBLTO_PATH=
export OSXCROSS_LINKER_VERSION=711
root@bf874e2bf9b5:/build/jemalloc#
root@bf874e2bf9b5:/build/jemalloc# printenv
HOSTNAME=bf874e2bf9b5
PWD=/build/jemalloc
HOME=/root
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
CFLAGS_x86_64_apple_darwin=-stdlib=libc++
CXXFLAGS_x86_64_apple_darwin=-stdlib=libc++
TERM=xterm
SHLVL=1
CROSS_SYSROOT=/opt/osxcross/SDK/latest/usr
PATH=/opt/osxcross/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
CROSS_TARGET=x86_64-apple-darwin
OLDPWD=/
_=/usr/bin/printenv
root@bf874e2bf9b5:/build/jemalloc#
root@bf874e2bf9b5:/build/jemalloc# CC="x86_64-apple-darwin20.4-clang" CFLAGS="-O0 -ffunction-sections -fdata-sections -fPIC -gdwarf-2 -fno-omit-frame-pointer --target=x86_64-apple-darwin -stdlib=libc++" CPPFLAGS="-O0 -ffunction-sections -fdata-sections -fPIC -gdwarf-2 -fno-omit-frame-pointer --target=x86_64-apple-darwin -stdlib=libc++" LDFLAGS="-O0 -ffunction-sections -fdata-sections -fPIC -gdwarf-2 -fno-omit-frame-pointer --target=x86_64-apple-darwin -stdlib=libc++" ./configure "--disable-cxx" "--with-jemalloc-prefix=_rjem_" "--with-private-namespace=_rjem_" "--host=x86_64-apple-darwin" "--build=x86_64-unknown-linux-gnu" "--prefix=/build/jemalloc/output"
checking for xsltproc... false
checking for x86_64-apple-darwin-gcc... x86_64-apple-darwin20.4-clang
checking whether the C compiler works... no
configure: error: in `/build/jemalloc':
configure: error: C compiler cannot create executables
See `config.log' for more details
root@bf874e2bf9b5:/build/jemalloc#
root@bf874e2bf9b5:/build/jemalloc# cat config.log
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by configure, which was
generated by GNU Autoconf 2.69.  Invocation command line was

  $ ./configure --disable-cxx --with-jemalloc-prefix=_rjem_ --with-private-namespace=_rjem_ --host=x86_64-apple-darwin --build=x86_64-unknown-linux-gnu --prefix=/build/jemalloc/output

## --------- ##
## Platform. ##
## --------- ##

hostname = bf874e2bf9b5
uname -m = x86_64
uname -r = 5.10.0-27-amd64
uname -s = Linux
uname -v = #1 SMP Debian 5.10.205-2 (2023-12-31)

/usr/bin/uname -p = x86_64
/bin/uname -X     = unknown

/bin/arch              = x86_64
/usr/bin/arch -k       = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo      = unknown
/bin/machine           = unknown
/usr/bin/oslevel       = unknown
/bin/universe          = unknown

PATH: /opt/osxcross/bin
PATH: /usr/local/sbin
PATH: /usr/local/bin
PATH: /usr/sbin
PATH: /usr/bin
PATH: /sbin
PATH: /bin

## ----------- ##
## Core tests. ##
## ----------- ##

configure:2674: checking for xsltproc
configure:2705: result: false
configure:2749: checking for x86_64-apple-darwin-gcc
configure:2776: result: x86_64-apple-darwin20.4-clang
configure:3045: checking for C compiler version
configure:3054: x86_64-apple-darwin20.4-clang --version >&5
clang version 10.0.0-4ubuntu1
Target: x86_64-apple-darwin20.4
Thread model: posix
InstalledDir: /usr/bin
configure:3065: $? = 0
configure:3054: x86_64-apple-darwin20.4-clang -v >&5
clang version 10.0.0-4ubuntu1
Target: x86_64-apple-darwin20.4
Thread model: posix
InstalledDir: /usr/bin
clang: warning: argument unused during compilation: '-mlinker-version=711' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-isysroot /opt/osxcross/bin/../SDK/MacOSX11.3.sdk' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-isystem /opt/osxcross/bin/../SDK/MacOSX11.3.sdk/usr/include/c++/v1' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-isystem /usr/lib/llvm-10/bin/../lib/clang/10.0.0/include' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-mmacosx-version-min=10.6.0' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-Wno-liblto' [-Wunused-command-line-argument]
... rest of stderr output deleted ...
configure:3065: $? = 0
configure:3054: x86_64-apple-darwin20.4-clang -V >&5
clang: error: argument to '-V' is missing (expected 1 value)
clang: error: no input files
configure:3065: $? = 1
configure:3054: x86_64-apple-darwin20.4-clang -qversion >&5
clang: error: unknown argument '-qversion'; did you mean '--version'?
clang: error: no input files
configure:3065: $? = 1
configure:3085: checking whether the C compiler works
configure:3107: x86_64-apple-darwin20.4-clang -O0 -ffunction-sections -fdata-sections -fPIC -gdwarf-2 -fno-omit-frame-pointer --target=x86_64-apple-darwin -stdlib=libc++ -O0 -ffunction-sections -fdata-sections -fPIC -gdwarf-2 -fno-omit-frame-pointer --target=x86_64-apple-darwin -stdlib=libc++ -O0 -ffunction-sections -fdata-sections -fPIC -gdwarf-2 -fno-omit-frame-pointer --target=x86_64-apple-darwin -stdlib=libc++ conftest.c  >&5
/usr/bin/ld: unrecognized option '-dynamic'
/usr/bin/ld: use the --help option for usage information
clang: error: linker command failed with exit code 1 (use -v to see invocation)
configure:3111: $? = 1
configure:3149: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h.  */
|
| int
| main ()
| {
|
|   ;
|   return 0;
| }
configure:3154: error: in `/build/jemalloc':
configure:3156: error: C compiler cannot create executables
See `config.log' for more details

## ---------------- ##
## Cache variables. ##
## ---------------- ##

ac_cv_env_CCC_set=
ac_cv_env_CCC_value=
ac_cv_env_CC_set=set
ac_cv_env_CC_value=x86_64-apple-darwin20.4-clang
ac_cv_env_CFLAGS_set=set
ac_cv_env_CFLAGS_value='-O0 -ffunction-sections -fdata-sections -fPIC -gdwarf-2 -fno-omit-frame-pointer --target=x86_64-apple-darwin -stdlib=libc++'
ac_cv_env_CPPFLAGS_set=set
ac_cv_env_CPPFLAGS_value='-O0 -ffunction-sections -fdata-sections -fPIC -gdwarf-2 -fno-omit-frame-pointer --target=x86_64-apple-darwin -stdlib=libc++'
ac_cv_env_CPP_set=
ac_cv_env_CPP_value=
ac_cv_env_CXXFLAGS_set=
ac_cv_env_CXXFLAGS_value=
ac_cv_env_CXX_set=
ac_cv_env_CXX_value=
ac_cv_env_LDFLAGS_set=set
ac_cv_env_LDFLAGS_value='-O0 -ffunction-sections -fdata-sections -fPIC -gdwarf-2 -fno-omit-frame-pointer --target=x86_64-apple-darwin -stdlib=libc++'
ac_cv_env_LIBS_set=
ac_cv_env_LIBS_value=
ac_cv_env_build_alias_set=set
ac_cv_env_build_alias_value=x86_64-unknown-linux-gnu
ac_cv_env_host_alias_set=set
ac_cv_env_host_alias_value=x86_64-apple-darwin
ac_cv_env_target_alias_set=
ac_cv_env_target_alias_value=
ac_cv_path_XSLTPROC=false
ac_cv_prog_CC=x86_64-apple-darwin20.4-clang

## ----------------- ##
## Output variables. ##
## ----------------- ##

AR=''
ARFLAGS=''
AROUT=''
AUTOCONF=''
AWK=''
BINDIR='/build/jemalloc/output/bin'
CC='x86_64-apple-darwin20.4-clang'
CC_MM=''
CFLAGS='-O0 -ffunction-sections -fdata-sections -fPIC -gdwarf-2 -fno-omit-frame-pointer --target=x86_64-apple-darwin -stdlib=libc++'
CONFIG='--disable-cxx --with-jemalloc-prefix=_rjem_ --with-private-namespace=_rjem_ --host=x86_64-apple-darwin --build=x86_64-unknown-linux-gnu --prefix=/build/jemalloc/output build_alias=x86_64-unknown-linux-gnu host_alias=x86_64-apple-darwin CC=x86_64-apple-darwin20.4-clang '\''CFLAGS=-O0 -ffunction-sections -fdata-sections -fPIC -gdwarf-2 -fno-omit-frame-pointer --target=x86_64-apple-darwin -stdlib=libc++'\'' '\''LDFLAGS=-O0 -ffunction-sections -fdata-sections -fPIC -gdwarf-2 -fno-omit-frame-pointer --target=x86_64-apple-darwin -stdlib=libc++'\'' '\''CPPFLAGS=-O0 -ffunction-sections -fdata-sections -fPIC -gdwarf-2 -fno-omit-frame-pointer --target=x86_64-apple-darwin -stdlib=libc++'\'''
CONFIGURE_CFLAGS=''
CONFIGURE_CXXFLAGS=''
CPP=''
CPPFLAGS='-O0 -ffunction-sections -fdata-sections -fPIC -gdwarf-2 -fno-omit-frame-pointer --target=x86_64-apple-darwin -stdlib=libc++'
CTARGET=''
CXX=''
CXXFLAGS=''
DATADIR='/build/jemalloc/output/share'
DEFS=''
DSO_LDFLAGS=''
DUMP_SYMS=''
ECHO_C=''
ECHO_N='-n'
ECHO_T=''
EGREP=''
EXEEXT=''
EXTRA_CFLAGS=''
EXTRA_CXXFLAGS=''
EXTRA_LDFLAGS=''
GREP=''
HAVE_CXX14=''
HAVE_CXX17=''
INCLUDEDIR='/build/jemalloc/output/include'
INSTALL_DATA=''
INSTALL_PROGRAM=''
INSTALL_SCRIPT=''
JEMALLOC_CPREFIX=''
JEMALLOC_PREFIX=''
LD=''
LDFLAGS='-O0 -ffunction-sections -fdata-sections -fPIC -gdwarf-2 -fno-omit-frame-pointer --target=x86_64-apple-darwin -stdlib=libc++'
LDTARGET=''
LD_PRELOAD_VAR=''
LIBDIR='/build/jemalloc/output/lib'
LIBOBJS=''
LIBS=''
LM=''
LTLIBOBJS=''
MANDIR='/build/jemalloc/output/share/man'
MKLIB=''
NM=''
OBJEXT=''
PACKAGE_BUGREPORT=''
PACKAGE_NAME=''
PACKAGE_STRING=''
PACKAGE_TARNAME=''
PACKAGE_URL=''
PACKAGE_VERSION=''
PATH_SEPARATOR=':'
PIC_CFLAGS=''
PREFIX='/build/jemalloc/output'
RANLIB=''
RPATH=''
RPATH_EXTRA=''
SHELL='/bin/bash'
SOREV=''
SPECIFIED_CFLAGS='-O0 -ffunction-sections -fdata-sections -fPIC -gdwarf-2 -fno-omit-frame-pointer --target=x86_64-apple-darwin -stdlib=libc++'
SPECIFIED_CXXFLAGS=''
TEST_LD_MODE=''
XSLROOT=''
XSLTPROC='false'
a=''
abi=''
abs_objroot='/build/jemalloc/'
abs_srcroot='/build/jemalloc/'
ac_ct_CC=''
ac_ct_CXX=''
bindir='${exec_prefix}/bin'
build='x86_64-unknown-linux-gnu'
build_alias='x86_64-unknown-linux-gnu'
build_cpu=''
build_os=''
build_vendor=''
cfghdrs_in=''
cfghdrs_out=''
cfgoutputs_in=''
cfgoutputs_out=''
datadir='${datarootdir}'
datarootdir='${prefix}/share'
docdir='${datarootdir}/doc/${PACKAGE}'
dvidir='${docdir}'
enable_autogen=''
enable_cache_oblivious=''
enable_cxx='no'
enable_debug=''
enable_doc=''
enable_experimental_smallocx=''
enable_fill=''
enable_initial_exec_tls=''
enable_lazy_lock=''
enable_log=''
enable_opt_safety_checks=''
enable_opt_size_checks=''
enable_prof=''
enable_readlinkat=''
enable_shared=''
enable_static=''
enable_stats=''
enable_tls=''
enable_uaf_detection=''
enable_utrace=''
enable_xmalloc=''
enable_zone_allocator=''
exe=''
exec_prefix='/build/jemalloc/output'
host='x86_64-apple-darwin'
host_alias='x86_64-apple-darwin'
host_cpu=''
host_os=''
host_vendor=''
htmldir='${docdir}'
importlib=''
includedir='${prefix}/include'
infodir='${datarootdir}/info'
install_suffix=''
je_=''
jemalloc_version=''
jemalloc_version_bugfix=''
jemalloc_version_gid=''
jemalloc_version_major=''
jemalloc_version_minor=''
jemalloc_version_nrev=''
libdir='${exec_prefix}/lib'
libdl=''
libexecdir='${exec_prefix}/libexec'
libprefix=''
link_whole_archive=''
localedir='${datarootdir}/locale'
localstatedir='${prefix}/var'
mandir='${datarootdir}/man'
o=''
objroot=''
oldincludedir='/usr/include'
pdfdir='${docdir}'
prefix='/build/jemalloc/output'
private_namespace=''
program_transform_name='s,x,x,'
psdir='${docdir}'
rev='2'
sbindir='${exec_prefix}/sbin'
sharedstatedir='${prefix}/com'
so=''
srcroot=''
sysconfdir='${prefix}/etc'
target_alias=''

## ----------- ##
## confdefs.h. ##
## ----------- ##

/* confdefs.h */
#define PACKAGE_NAME ""
#define PACKAGE_TARNAME ""
#define PACKAGE_VERSION ""
#define PACKAGE_STRING ""
#define PACKAGE_BUGREPORT ""
#define PACKAGE_URL ""

configure: exit 77

``
cavivie commented 5 months ago

The key error is:

configure:3107: x86_64-apple-darwin20.4-clang -O0 -ffunction-sections -fdata-sections -fPIC -gdwarf-2 -fno-omit-frame-pointer --target=x86_64-apple-darwin -stdlib=libc++ -O0 -ffunction-sections -fdata-sections -fPIC -gdwarf-2 -fno-omit-frame-pointer --target=x86_64-apple-darwin -stdlib=libc++ -O0 -ffunction-sections -fdata-sections -fPIC -gdwarf-2 -fno-omit-frame-pointer --target=x86_64-apple-darwin -stdlib=libc++ conftest.c  >&5
/usr/bin/ld: unrecognized option '-dynamic'
/usr/bin/ld: use the --help option for usage information
tpoechtrager commented 5 months ago

--target=x86_64-apple-darwin => --target=x86_64-apple-darwin20.4

cavivie commented 5 months ago

--target=x86_64-apple-darwin => --target=x86_64-apple-darwin20.4

Thanks, it works with this.

cavivie commented 5 months ago

How does generating compiler parameters like cc-rs work with darwin version

cavivie commented 5 months ago

Current: The clang wrapper aarch64-apple-darwin20.4-clang works with the target flag aarch64-apple-darwin20.4. The clang wrapper arm64-apple-darwin20.4-clang works with the target flag arm64-apple-darwin20.4. The clang wrapper aarch64-apple-darwin20.4-clang does not work with the target flag arm64-apple-darwin20.4. The clang wrapper arm64-apple-darwin20.4-clang does not work with the target flag aarch64-apple-darwin20.4.

Hope that: The clang wrapper aarch64-apple-darwin20.4-clang can work with the target flag arm64-apple-darwin20.4. The clang wrapper arm64-apple-darwin20.4-clang can work with the target flag aarch64-apple-darwin20.4. (maybe?)

I think if this detail is handled by the clang wrapper, there is no need to modify third-party libraries and build tools, making the build more efficient, because Apple clang does not consider itself to be aarch64 but arm64.