summaryrefslogtreecommitdiff
path: root/libraries/base
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2022-09-13 06:36:18 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2023-02-03 14:07:30 -0500
commitde1d15127ac3f41ac3044215b0ea3398a36edc89 (patch)
tree22fb2d1aeef3872e2624fb2dce40f3b8d0db2548 /libraries/base
parent8feb93013cf6f093e025c9e9a3213ae1fa0f73a0 (diff)
downloadhaskell-de1d15127ac3f41ac3044215b0ea3398a36edc89.tar.gz
Windows: Remove mingwex dependency
The clang based toolchain uses ucrt as its math library and so mingwex is no longer needed. In fact using mingwex will cause incompatibilities as the default routines in both have differing ULPs and string formatting modifiers. ``` $ LIBRARY_PATH=/mingw64/lib ghc/_build/stage1/bin/ghc Bug.hs -fforce-recomp && ./Bug.exe [1 of 2] Compiling Main ( Bug.hs, Bug.o ) ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `__imp___p__environ' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `__hscore_get_errno' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_ForeignziCziError_errnoToIOError_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziWindows_failIf2_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncodingziCodePageziAPI_mkCodePageEncoding_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncodingziCodePage_currentCodePage_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziEncoding_getForeignEncoding_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_ForeignziCziString_withCStringLen1_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziHandleziInternals_zdwflushCharReadBuffer_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziIOziHandleziText_hGetBuf1_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziFingerprint_fingerprintString_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_DataziTypeableziInternal_mkTrCon_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziException_errorCallWithCallStackException_closure' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\base-4.17.0.0\libHSbase-4.17.0.0.a: unknown symbol `base_GHCziErr_error_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\template-haskell-2.19.0.0\libHStemplate-haskell-2.19.0.0.a: unknown symbol `base_DataziMaybe_fromJust1_info' ghc.exe: | C:\Users\winferno\Software\ghc\_build\stage1\lib\x86_64-windows-ghc-9.5.20220908\template-haskell-2.19.0.0\libHStemplate-haskell-2.19.0.0.a: unknown symbol `templatezmhaskell_LanguageziHaskellziTHziSyntax_IntPrimL_con_info' ghc.exe: ^^ Could not load 'templatezmhaskell_LanguageziHaskellziTHziLibziInternal_stringL_closure', dependency unresolved. See top entry above. <no location info>: error: GHC.ByteCode.Linker.lookupCE During interactive linking, GHCi couldn't find the following symbol: templatezmhaskell_LanguageziHaskellziTHziLibziInternal_stringL_closure This may be due to you not asking GHCi to load extra object files, archives or DLLs needed by your current session. Restart GHCi, specifying the missing library using the -L/path/to/object/dir and -lmissinglibname flags, or simply by naming the relevant files on the GHCi command line. Alternatively, this link failure might indicate a bug in GHCi. If you suspect the latter, please report this as a GHC bug: https://www.haskell.org/ghc/reportabug ```
Diffstat (limited to 'libraries/base')
-rw-r--r--libraries/base/System/Posix/Internals.hs138
-rw-r--r--libraries/base/base.cabal3
-rw-r--r--libraries/base/configure.ac2
-rw-r--r--libraries/base/include/HsBase.h11
4 files changed, 86 insertions, 68 deletions
diff --git a/libraries/base/System/Posix/Internals.hs b/libraries/base/System/Posix/Internals.hs
index 44065be7c4..6aae25ab5e 100644
--- a/libraries/base/System/Posix/Internals.hs
+++ b/libraries/base/System/Posix/Internals.hs
@@ -452,7 +452,6 @@ foreign import ccall unsafe "HsBase.h __hscore_fstat"
foreign import ccall unsafe "HsBase.h __hscore_lstat"
lstat :: CFilePath -> Ptr CStat -> IO CInt
-
#endif
#if defined(js_HOST_ARCH)
@@ -592,109 +591,95 @@ foreign import javascript unsafe "(($1,$2,$3_1,$3_2) => { return h$base_c_fcntl_
#else
-{- Note: Win32 POSIX functions
-Functions that are not part of the POSIX standards were
-at some point deprecated by Microsoft. This deprecation
-was performed by renaming the functions according to the
-C++ ABI Section 17.6.4.3.2b. This was done to free up the
-namespace of normal Windows programs since Windows isn't
-POSIX compliant anyway.
+#if defined(mingw32_HOST_OS)
+-- See Note [Windows types]
+foreign import capi unsafe "HsBase.h _read"
+ c_read :: CInt -> Ptr Word8 -> CUInt -> IO CInt
-These were working before since the RTS was re-exporting
-these symbols under the undeprecated names. This is no longer
-being done. See #11223
+-- See Note [Windows types]
+foreign import capi safe "HsBase.h _read"
+ c_safe_read :: CInt -> Ptr Word8 -> CUInt -> IO CInt
-See https://msdn.microsoft.com/en-us/library/ms235384.aspx
-for more.
+foreign import ccall unsafe "HsBase.h _umask"
+ c_umask :: CMode -> IO CMode
-However since we can't hope to get people to support Windows
-packages we should support the deprecated names. See #12497
--}
-foreign import capi unsafe "unistd.h lseek"
- c_lseek :: CInt -> COff -> CInt -> IO COff
+-- See Note [Windows types]
+foreign import capi unsafe "HsBase.h _write"
+ c_write :: CInt -> Ptr Word8 -> CUInt -> IO CInt
-foreign import ccall unsafe "HsBase.h access"
+-- See Note [Windows types]
+foreign import capi safe "HsBase.h _write"
+ c_safe_write :: CInt -> Ptr Word8 -> CUInt -> IO CInt
+
+foreign import ccall unsafe "HsBase.h _pipe"
+ c_pipe :: Ptr CInt -> IO CInt
+
+foreign import capi unsafe "HsBase.h _lseeki64"
+ c_lseek :: CInt -> Int64 -> CInt -> IO Int64
+
+foreign import capi unsafe "HsBase.h _access"
c_access :: CString -> CInt -> IO CInt
#if !defined(HAVE_CHMOD)
c_chmod :: CString -> CMode -> IO CInt
-c_chmod _ _ = ioError (ioeSetLocation unsupportedOperation "chmod")
+c_chmod _ _ = ioError (ioeSetLocation unsupportedOperation "_chmod")
#else
-foreign import ccall unsafe "HsBase.h chmod"
+foreign import ccall unsafe "HsBase.h _chmod"
c_chmod :: CString -> CMode -> IO CInt
#endif
-foreign import ccall unsafe "HsBase.h close"
+foreign import capi unsafe "HsBase.h _close"
c_close :: CInt -> IO CInt
-foreign import ccall unsafe "HsBase.h creat"
+foreign import capi unsafe "HsBase.h _creat"
c_creat :: CString -> CMode -> IO CInt
#if !defined(HAVE_DUP)
c_dup :: CInt -> IO CInt
-c_dup _ = ioError (ioeSetLocation unsupportedOperation "dup")
+c_dup _ = ioError (ioeSetLocation unsupportedOperation "_dup")
c_dup2 :: CInt -> CInt -> IO CInt
-c_dup2 _ _ = ioError (ioeSetLocation unsupportedOperation "dup2")
+c_dup2 _ _ = ioError (ioeSetLocation unsupportedOperation "_dup2")
#else
-foreign import ccall unsafe "HsBase.h dup"
+foreign import ccall unsafe "HsBase.h _dup"
c_dup :: CInt -> IO CInt
-foreign import ccall unsafe "HsBase.h dup2"
+foreign import ccall unsafe "HsBase.h _dup2"
c_dup2 :: CInt -> CInt -> IO CInt
#endif
-foreign import ccall unsafe "HsBase.h isatty"
+foreign import capi unsafe "HsBase.h _isatty"
c_isatty :: CInt -> IO CInt
-#if defined(mingw32_HOST_OS)
--- See Note: Windows types
-foreign import capi unsafe "HsBase.h _read"
- c_read :: CInt -> Ptr Word8 -> CUInt -> IO CInt
-
--- See Note: Windows types
-foreign import capi safe "HsBase.h _read"
- c_safe_read :: CInt -> Ptr Word8 -> CUInt -> IO CInt
-
-foreign import ccall unsafe "HsBase.h _umask"
- c_umask :: CMode -> IO CMode
-
--- See Note: Windows types
-foreign import capi unsafe "HsBase.h _write"
- c_write :: CInt -> Ptr Word8 -> CUInt -> IO CInt
+foreign import capi unsafe "HsBase.h _unlink"
+ c_unlink :: CString -> IO CInt
--- See Note: Windows types
-foreign import capi safe "HsBase.h _write"
- c_safe_write :: CInt -> Ptr Word8 -> CUInt -> IO CInt
+foreign import capi unsafe "HsBase.h _utime"
+ c_utime :: CString -> Ptr CUtimbuf -> IO CInt
-foreign import ccall unsafe "HsBase.h _pipe"
- c_pipe :: Ptr CInt -> IO CInt
+foreign import capi unsafe "HsBase.h _getpid"
+ c_getpid :: IO CPid
#else
-- We use CAPI as on some OSs (eg. Linux) this is wrapped by a macro
-- which redirects to the 64-bit-off_t versions when large file
-- support is enabled.
--- See Note: Windows types
+-- See Note [Windows types]
foreign import capi unsafe "HsBase.h read"
c_read :: CInt -> Ptr Word8 -> CSize -> IO CSsize
--- See Note: Windows types
+-- See Note [Windows types]
foreign import capi safe "HsBase.h read"
c_safe_read :: CInt -> Ptr Word8 -> CSize -> IO CSsize
-#if defined(HAVE_UMASK)
foreign import ccall unsafe "HsBase.h umask"
c_umask :: CMode -> IO CMode
-#else
-c_umask :: CMode -> IO CMode
-c_umask _ = ioError (ioeSetLocation unsupportedOperation "umask")
-#endif
--- See Note: Windows types
+-- See Note [Windows types]
foreign import capi unsafe "HsBase.h write"
c_write :: CInt -> Ptr Word8 -> CSize -> IO CSsize
--- See Note: Windows types
+-- See Note [Windows types]
foreign import capi safe "HsBase.h write"
c_safe_write :: CInt -> Ptr Word8 -> CSize -> IO CSsize
@@ -705,8 +690,44 @@ c_pipe _ = ioError (ioeSetLocation unsupportedOperation "pipe")
foreign import ccall unsafe "HsBase.h pipe"
c_pipe :: Ptr CInt -> IO CInt
#endif
+
+foreign import capi unsafe "unistd.h lseek"
+ c_lseek :: CInt -> COff -> CInt -> IO COff
+
+foreign import ccall unsafe "HsBase.h access"
+ c_access :: CString -> CInt -> IO CInt
+
+#if !defined(HAVE_CHMOD)
+c_chmod :: CString -> CMode -> IO CInt
+c_chmod _ _ = ioError (ioeSetLocation unsupportedOperation "chmod")
+#else
+foreign import ccall unsafe "HsBase.h chmod"
+ c_chmod :: CString -> CMode -> IO CInt
+#endif
+
+foreign import ccall unsafe "HsBase.h close"
+ c_close :: CInt -> IO CInt
+
+foreign import ccall unsafe "HsBase.h creat"
+ c_creat :: CString -> CMode -> IO CInt
+
+#if !defined(HAVE_DUP)
+c_dup :: CInt -> IO CInt
+c_dup _ = ioError (ioeSetLocation unsupportedOperation "dup")
+
+c_dup2 :: CInt -> CInt -> IO CInt
+c_dup2 _ _ = ioError (ioeSetLocation unsupportedOperation "dup2")
+#else
+foreign import ccall unsafe "HsBase.h dup"
+ c_dup :: CInt -> IO CInt
+
+foreign import ccall unsafe "HsBase.h dup2"
+ c_dup2 :: CInt -> CInt -> IO CInt
#endif
+foreign import ccall unsafe "HsBase.h isatty"
+ c_isatty :: CInt -> IO CInt
+
foreign import ccall unsafe "HsBase.h unlink"
c_unlink :: CString -> IO CInt
@@ -720,6 +741,7 @@ c_getpid = pure 1
foreign import ccall unsafe "HsBase.h getpid"
c_getpid :: IO CPid
#endif
+#endif
#if !defined(js_HOST_ARCH)
foreign import ccall unsafe "HsBase.h __hscore_stat"
@@ -881,7 +903,7 @@ foreign import capi unsafe "stdio.h value SEEK_END" sEEK_END :: CInt
#endif
{-
-Note: Windows types
+Note [Windows types]
Windows' _read and _write have types that differ from POSIX. They take an
unsigned int for length and return a signed int where POSIX uses size_t and
diff --git a/libraries/base/base.cabal b/libraries/base/base.cabal
index d615108c58..5e7fdc17c6 100644
--- a/libraries/base/base.cabal
+++ b/libraries/base/base.cabal
@@ -397,7 +397,6 @@ Library
if os(windows)
-- Windows requires some extra libraries for linking because the RTS
-- is no longer re-exporting them.
- -- mingwex: provides C99 compatibility. libm is a stub on MingW.
-- mingw32: Unfortunately required because of a resource leak between
-- mingwex and mingw32. the __math_err symbol is defined in
-- mingw32 which is required by mingwex.
@@ -410,7 +409,7 @@ Library
-- advapi32: provides advanced kernel functions
extra-libraries:
wsock32, user32, shell32, mingw32, kernel32, advapi32,
- mingwex, ws2_32, shlwapi, ole32, rpcrt4, ntdll
+ ws2_32, shlwapi, ole32, rpcrt4, ntdll
-- Minimum supported Windows version.
-- These numbers can be found at:
-- https://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs.85).aspx
diff --git a/libraries/base/configure.ac b/libraries/base/configure.ac
index a1c68577aa..cea01384aa 100644
--- a/libraries/base/configure.ac
+++ b/libraries/base/configure.ac
@@ -39,7 +39,7 @@ AC_CHECK_LIB([rt], [clock_gettime])
AC_CHECK_FUNCS([clock_gettime])
AC_CHECK_DECLS([CLOCK_PROCESS_CPUTIME_ID], [], [], [[#include <time.h>]])
AC_CHECK_FUNCS([getclock getrusage times])
-AC_CHECK_FUNCS([_chsize ftruncate])
+AC_CHECK_FUNCS([_chsize_s ftruncate])
# event-related fun
# The line below already defines HAVE_KQUEUE and HAVE_POLL, so technically some of the
diff --git a/libraries/base/include/HsBase.h b/libraries/base/include/HsBase.h
index 12edce964d..d841141be2 100644
--- a/libraries/base/include/HsBase.h
+++ b/libraries/base/include/HsBase.h
@@ -280,15 +280,12 @@ __hscore_o_nonblock( void )
INLINE int
__hscore_ftruncate( int fd, off_t where )
{
-#if defined(HAVE_FTRUNCATE)
+#if defined(HAVE__CHSIZE_S)
+ return _chsize_s(fd,where);
+#elif defined(HAVE_FTRUNCATE)
return ftruncate(fd,where);
-#elif defined(HAVE__CHSIZE)
- return _chsize(fd,where);
#else
-// ToDo: we should use _chsize_s() on Windows which allows a 64-bit
-// offset, but it doesn't seem to be available from mingw at this time
-// --SDM (01/2008)
-#error at least ftruncate or _chsize functions are required to build
+#error at least _chsize_s or ftruncate functions are required to build
#endif
}