haskell / directory

Platform-independent library for basic file system operations
https://hackage.haskell.org/package/directory
Other
58 stars 47 forks source link

Build from sources in macOS fails #92

Closed mwesolowski closed 5 years ago

mwesolowski commented 5 years ago

Hi! I try to build directory from sources on macOS 10.14. Unfortunately I get the following error:

configure: creating ./config.status
config.status: creating HsDirectoryConfig.h
Preprocessing library for directory-1.3.3.2..
C_utimensat.hsc:36:16: error: use of undeclared identifier 'UTIME_OMIT'
    hsc_const (UTIME_OMIT);
               ^
C_utimensat.hsc:36:16: error: use of undeclared identifier 'UTIME_OMIT'
C_utimensat.hsc:36:16: error: use of undeclared identifier 'UTIME_OMIT'
3 errors generated.
compiling dist/build/System/Directory/Internal/C_utimensat_hsc_make.c failed (exit code 1)
command was: /usr/bin/gcc -c dist/build/System/Directory/Internal/C_utimensat_hsc_make.c -o dist/build/System/Directory/Internal/C_utimensat_hsc_make.o -fno-stack-protector -fno-stack-protector -D__GLASGOW_HASKELL__=804 -Ddarwin_BUILD_OS=1 -Dx86_64_BUILD_ARCH=1 -Ddarwin_HOST_OS=1 -Dx86_64_HOST_ARCH=1 -I. -Idist/build/. -Idist/build/autogen -Idist/build/global-autogen -include dist/build/autogen/cabal_macros.h -I/Library/Frameworks/GHC.framework/Versions/8.4.3-x86_64/usr/lib/ghc-8.4.3/unix-2.7.2.2/include -I/Library/Frameworks/GHC.framework/Versions/8.4.3-x86_64/usr/lib/ghc-8.4.3/time-1.8.0.2/include -I/Library/Frameworks/GHC.framework/Versions/8.4.3-x86_64/usr/lib/ghc-8.4.3/bytestring-0.10.8.2/include -I/Library/Frameworks/GHC.framework/Versions/8.4.3-x86_64/usr/lib/ghc-8.4.3/base-4.11.1.0/include -I/Library/Frameworks/GHC.framework/Versions/8.4.3-x86_64/usr/lib/ghc-8.4.3/integer-gmp-1.0.2.0/include -I/Library/Frameworks/GHC.framework/Versions/8.4.3-x86_64/usr/lib/ghc-8.4.3/include -I/Library/Frameworks/GHC.framework/Versions/8.4.3-x86_64/usr/lib/ghc-8.4.3/include/
cabal: Leaving directory '.'
cabal: Error: some packages failed to install:
directory-1.3.3.2-11CnmK6h34C3zUF1snvZeW failed during the building phase. The
exception was:
ExitFailure 1

Do I need to install some additional lib?

Rufflewind commented 5 years ago

Hrm, can you also dump all the messages from running ./configure?

I suspect your OS supports utimensat but lacks UTIME_OMIT, which is a really unusual situation.

mwesolowski commented 5 years ago

Sure.

./configure
checking for gcc... gcc
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... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking for sys/types.h... (cached) yes
checking for sys/stat.h... (cached) yes
checking time.h usability... yes
checking time.h presence... yes
checking for time.h... yes
checking for utimensat... yes
checking for CreateSymbolicLinkW... no
checking for GetFinalPathNameByHandleW... no
configure: creating ./config.status
config.status: creating HsDirectoryConfig.h
mwesolowski commented 5 years ago

Ok. Now I see I have sys/stat.h in at least two different locations. One defines UTIME_OMIT and the other doesn't:

diff /usr/include/sys/stat.h /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/stat.h
326c326,329
< /* Bits 0x0080 through 0x4000 are currently undefined. */
---
> #define UF_DATAVAULT  0x00000080  /* entitlement required for reading */
>                   /* and writing */
>
> /* Bits 0x0100 through 0x4000 are currently undefined. */
337c340
< #define SF_RESTRICTED 0x00080000  /* restricted access */
---
> #define SF_RESTRICTED 0x00080000  /* entitlement required for writing */
365a369,375
>
> #define   UTIME_NOW   -1
> #define   UTIME_OMIT  -2
>
> int   futimens(int __fd, const struct timespec __times[2]) __API_AVAILABLE(macosx(10.13), ios(11.0), tvos(11.0), watchos(4.0));
> int   utimensat(int __fd, const char *__path, const struct timespec __times[2],
>       int __flag) __API_AVAILABLE(macosx(10.13), ios(11.0), tvos(11.0), watchos(4.0));
mwesolowski commented 5 years ago

@Rufflewind I googled that I can install headers from the package macOS_SDK_headers_for_macOS_10.14.pkg Now it compiles without any problems. Thanks for the hint.

Rufflewind commented 5 years ago

Great to hear!