Skip to content

Problem with fdatasync when cross compiling to aarch64 on Mac OS X #37

Closed
@sseefried

Description

@sseefried

The error output is:

"inplace/bin/ghc-stage1" -hisuf hi -osuf  o -hcsuf hc -static  -H64m -O0    -this-package-key unix_6KxsoniXeYR9o99eChzwLX -hide-all-packages -i -ilibraries/unix/. -ilibraries/unix/dist-install/build -ilibraries/unix/dist-install/build/autogen -Ilibraries/unix/dist-install/build -Ilibraries/unix/dist-install/build/autogen -Ilibraries/unix/include    -optP-include -optPlibraries/unix/dist-install/build/autogen/cabal_macros.h -package-key base_62ctz6fVRDGAMD7GZKNkAJ -package-key bytes_BBgXs4iMVG62xkLTXxSQ78 -package-key time_Ca2vuoP20B2BBf1t5jg5Kb -Wall -XHaskell2010 -O -fllvm  -no-user-package-db -rtsopts      -odir libraries/unix/dist-install/build -hidir libraries/unix/dist-install/build -stubdir libraries/unix/dist-install/build   -c libraries/unix/dist-install/build/System/Posix/Unistd.hs -o libraries/unix/dist-install/build/System/Posix/Unistd.o

/var/folders/pv/pfxcyy117v31vt6lsshtgr_w0000gn/T/ghc3154_0/ghc3154_2.c:9:110:
     error: implicit declaration of function 'fdatasync' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
HsInt32 ghczuwrapperZC0ZCunixzu6KxsoniXeYR9o99eChzzwLXZCSystemziPosixziUnistdZCfdatasync(HsInt32 a1) {return fdatasync(a1);}

The bug is introduced in commit 98eced8.

The compiler I was using was LLVM 3.6's clang in a wrapper script called aarch64-apple-darwin14-clang. The contents of this file are:

#!/bin/sh
TARGET_PLATFORM=`xcrun --show-sdk-path --sdk iphoneos`
TARGET_GCC=/usr/local/clang+llvm-3.6.0-rc2-x86_64-apple-darwin/bin/clang
TARGET_CFLAGS="-isysroot $TARGET_PLATFORM -arch arm64 -miphoneos-version-min=7.0"

exec $TARGET_GCC $TARGET_CFLAGS "$@"

The problem is simply that you cannot use AC_CHECK_FUNCS in configure.ac to
check for the existence of a library function when cross-compiling.

This is detailed here

My work-around to the issue is to run configure manually and then edit include/HsUnixConfig.h
manually and set:

 #define HAVE_FDATASYNC 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions