[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: hadrian: Don't attempt to install documentation if doc/ doesn't exist

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Wed Aug 10 23:11:21 UTC 2022



Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC


Commits:
7cabea7c by Ben Gamari at 2022-08-10T15:37:58-04:00
hadrian: Don't attempt to install documentation if doc/ doesn't exist

Previously we would attempt to install documentation even if the `doc`
directory doesn't exist (e.g. due to `--docs=none`). This would result
in the surprising side-effect of the entire contents of the bindist
being installed in the destination documentation directory. Fix this.

Fixes #21976.

- - - - -
67575f20 by normalcoder at 2022-08-10T15:38:34-04:00
ncg/aarch64: Don't use x18 register on AArch64/Darwin

Apple's ABI documentation [1] says: "The platforms reserve register x18.
Don’t use this register." While this wasn't problematic in previous
Darwin releases, macOS 13 appears to start zeroing this register
periodically. See #21964.

[1] https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms

- - - - -
d408b6e9 by Andreas Klebinger at 2022-08-10T19:11:03-04:00
Note [Trimming auto-rules]: State that this improves compiler perf.

- - - - -
8e4a58b0 by Bodigrim at 2022-08-10T19:11:07-04:00
Document that threadDelay / timeout are susceptible to overflows on 32-bit machines

- - - - -


11 changed files:

- compiler/CodeGen.Platform.h
- compiler/GHC/Iface/Tidy.hs
- hadrian/bindist/Makefile
- libraries/base/GHC/Conc/IO.hs
- libraries/base/GHC/Conc/POSIX.hs
- libraries/base/GHC/Conc/Windows.hs
- libraries/base/GHC/Event/Thread.hs
- libraries/base/GHC/Event/TimerManager.hs
- libraries/base/GHC/Event/Windows.hsc
- libraries/base/GHC/Event/Windows/Thread.hs
- libraries/base/System/Timeout.hs


Changes:

=====================================
compiler/CodeGen.Platform.h
=====================================
@@ -926,6 +926,14 @@ freeReg 29 = False
 -- ip0 -- used for spill offset computations
 freeReg 16 = False
 
+#if defined(darwin_HOST_OS) || defined(ios_HOST_OS)
+-- x18 is reserved by the platform on Darwin/iOS, and can not be used
+-- More about ARM64 ABI that Apple platforms support:
+-- https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms
+-- https://github.com/Siguza/ios-resources/blob/master/bits/arm64.md
+freeReg 18 = False
+#endif
+
 # if defined(REG_Base)
 freeReg REG_Base  = False
 # endif


=====================================
compiler/GHC/Iface/Tidy.hs
=====================================
@@ -965,6 +965,13 @@ NB: if a binding is kept alive for some *other* reason (e.g. f_spec is
 called in the final code), we keep the rule too.
 
 This stuff is the only reason for the ru_auto field in a Rule.
+
+NB: In #18532 we looked at keeping auto-rules and it turned out to just make
+compiler performance worse while increasing code sizes at the same time. The impact
+varied. Compiling Cabal got ~3% slower, allocated ~3% more and wrote 15% more code to disk.
+Nofib only saw 0.7% more compiler allocations and executable file size growth. But given
+there was no difference in runtime for these benchmarks it turned out to be flat out worse.
+See the ticket for more details.
 -}
 
 findExternalRules :: TidyOpts


=====================================
hadrian/bindist/Makefile
=====================================
@@ -184,10 +184,12 @@ install_lib: lib/settings
 install_docs:
 	@echo "Copying docs to $(DESTDIR)$(docdir)"
 	$(INSTALL_DIR) "$(DESTDIR)$(docdir)"
-	cd doc; $(FIND) . -type f -exec sh -c \
-			'$(INSTALL_DIR) "$(DESTDIR)$(docdir)/`dirname $$1`" && \
-			 $(INSTALL_DATA) "$$1" "$(DESTDIR)$(docdir)/`dirname $$1`" \
-		' sh '{}' \;
+	
+	if [ -d doc ]; then \
+		cd doc; $(FIND) . -type f -exec sh -c \
+			'$(INSTALL_DIR) "$(DESTDIR)$(docdir)/`dirname $$1`" && $(INSTALL_DATA) "$$1" "$(DESTDIR)$(docdir)/`dirname $$1`"' \
+			sh '{}' ';'; \
+	fi
 	
 	if [ -d docs-utils ]; then \
 		$(INSTALL_DIR) "$(DESTDIR)$(docdir)/html/libraries/"; \


=====================================
libraries/base/GHC/Conc/IO.hs
=====================================
@@ -189,6 +189,9 @@ closeFdWith close fd
 -- when the delay has expired, but the thread will never continue to
 -- run /earlier/ than specified.
 --
+-- Be careful not to exceed @maxBound :: Int@, which on 32-bit machines is only
+-- 2147483647 μs, less than 36 minutes.
+-- Consider using @Control.Concurrent.Thread.Delay.delay@ from @unbounded-delays@ package.
 threadDelay :: Int -> IO ()
 threadDelay time
 #if defined(mingw32_HOST_OS)
@@ -206,6 +209,9 @@ threadDelay time
 -- after a given number of microseconds. The caveats associated with
 -- 'threadDelay' also apply.
 --
+-- Be careful not to exceed @maxBound :: Int@, which on 32-bit machines is only
+-- 2147483647 μs, less than 36 minutes.
+--
 registerDelay :: Int -> IO (TVar Bool)
 registerDelay usecs
 #if defined(mingw32_HOST_OS)


=====================================
libraries/base/GHC/Conc/POSIX.hs
=====================================
@@ -107,6 +107,9 @@ asyncWriteBA fd isSock len off bufB =
 -- when the delay has expired, but the thread will never continue to
 -- run /earlier/ than specified.
 --
+-- Be careful not to exceed @maxBound :: Int@, which on 32-bit machines is only
+-- 2147483647 μs, less than 36 minutes.
+--
 threadDelay :: Int -> IO ()
 threadDelay time
   | threaded  = waitForDelayEvent time
@@ -118,6 +121,9 @@ threadDelay time
 -- | Set the value of returned TVar to True after a given number of
 -- microseconds. The caveats associated with threadDelay also apply.
 --
+-- Be careful not to exceed @maxBound :: Int@, which on 32-bit machines is only
+-- 2147483647 μs, less than 36 minutes.
+--
 registerDelay :: Int -> IO (TVar Bool)
 registerDelay usecs
   | threaded = waitForDelayEventSTM usecs


=====================================
libraries/base/GHC/Conc/Windows.hs
=====================================
@@ -95,12 +95,18 @@ asyncWriteBA fd isSock len off bufB =
 -- when the delay has expired, but the thread will never continue to
 -- run /earlier/ than specified.
 --
+-- Be careful not to exceed @maxBound :: Int@, which on 32-bit machines is only
+-- 2147483647 μs, less than 36 minutes.
+--
 threadDelay :: Int -> IO ()
 threadDelay = POSIX.threadDelay <!> WINIO.threadDelay
 
 -- | Set the value of returned TVar to True after a given number of
 -- microseconds. The caveats associated with threadDelay also apply.
 --
+-- Be careful not to exceed @maxBound :: Int@, which on 32-bit machines is only
+-- 2147483647 μs, less than 36 minutes.
+--
 registerDelay :: Int -> IO (TVar Bool)
 registerDelay = POSIX.registerDelay <!> WINIO.registerDelay
 


=====================================
libraries/base/GHC/Event/Thread.hs
=====================================
@@ -55,6 +55,10 @@ import System.Posix.Types (Fd)
 -- There is no guarantee that the thread will be rescheduled promptly
 -- when the delay has expired, but the thread will never continue to
 -- run /earlier/ than specified.
+--
+-- Be careful not to exceed @maxBound :: Int@, which on 32-bit machines is only
+-- 2147483647 μs, less than 36 minutes.
+--
 threadDelay :: Int -> IO ()
 threadDelay usecs = mask_ $ do
   mgr <- getSystemTimerManager
@@ -65,6 +69,9 @@ threadDelay usecs = mask_ $ do
 -- | Set the value of returned TVar to True after a given number of
 -- microseconds. The caveats associated with threadDelay also apply.
 --
+-- Be careful not to exceed @maxBound :: Int@, which on 32-bit machines is only
+-- 2147483647 μs, less than 36 minutes.
+--
 registerDelay :: Int -> IO (TVar Bool)
 registerDelay usecs = do
   t <- atomically $ newTVar False


=====================================
libraries/base/GHC/Event/TimerManager.hs
=====================================
@@ -212,6 +212,10 @@ expirationTime us = do
 -- returned 'TimeoutKey' can be used to later unregister or update the
 -- timeout.  The timeout is automatically unregistered after the given
 -- time has passed.
+--
+-- Be careful not to exceed @maxBound :: Int@, which on 32-bit machines is only
+-- 2147483647 μs, less than 36 minutes.
+--
 registerTimeout :: TimerManager -> Int -> TimeoutCallback -> IO TimeoutKey
 registerTimeout mgr us cb = do
   !key <- newUnique (emUniqueSource mgr)
@@ -231,6 +235,10 @@ unregisterTimeout mgr (TK key) =
 
 -- | Update an active timeout to fire in the given number of
 -- microseconds.
+--
+-- Be careful not to exceed @maxBound :: Int@, which on 32-bit machines is only
+-- 2147483647 μs, less than 36 minutes.
+--
 updateTimeout :: TimerManager -> TimeoutKey -> Int -> IO ()
 updateTimeout mgr (TK key) us = do
   expTime <- expirationTime us


=====================================
libraries/base/GHC/Event/Windows.hsc
=====================================
@@ -853,6 +853,10 @@ expirationTime mgr us = do
 -- The timeout is automatically unregistered when it fires.
 --
 -- The 'TimeoutCallback' will not be called more than once.
+--
+-- Be careful not to exceed @maxBound :: Int@, which on 32-bit machines is only
+-- 2147483647 μs, less than 36 minutes.
+--
 {-# NOINLINE registerTimeout #-}
 registerTimeout :: Manager -> Int -> TimeoutCallback -> IO TimeoutKey
 registerTimeout mgr at Manager{..} uSrelTime cb = do
@@ -866,6 +870,10 @@ registerTimeout mgr at Manager{..} uSrelTime cb = do
 -- | Update an active timeout to fire in the given number of seconds (from the
 -- time 'updateTimeout' is called), instead of when it was going to fire.
 -- This has no effect if the timeout has already fired.
+--
+-- Be careful not to exceed @maxBound :: Int@, which on 32-bit machines is only
+-- 2147483647 μs, less than 36 minutes.
+--
 updateTimeout :: Manager -> TimeoutKey -> Seconds -> IO ()
 updateTimeout mgr (TK key) relTime = do
     now <- getTime (mgrClock mgr)


=====================================
libraries/base/GHC/Event/Windows/Thread.hs
=====================================
@@ -19,6 +19,8 @@ ensureIOManagerIsRunning = wakeupIOManager
 interruptIOManager :: IO ()
 interruptIOManager = interruptSystemManager
 
+-- | Be careful not to exceed @maxBound :: Int@, which on 32-bit machines is only
+-- 2147483647 μs, less than 36 minutes.
 threadDelay :: Int -> IO ()
 threadDelay usecs = mask_ $ do
     m <- newEmptyIOPort
@@ -26,6 +28,8 @@ threadDelay usecs = mask_ $ do
     reg <- registerTimeout mgr usecs $ writeIOPort m () >> return ()
     readIOPort m `onException` unregisterTimeout mgr reg
 
+-- | Be careful not to exceed @maxBound :: Int@, which on 32-bit machines is only
+-- 2147483647 μs, less than 36 minutes.
 registerDelay :: Int -> IO (TVar Bool)
 registerDelay usecs = do
     t <- newTVarIO False


=====================================
libraries/base/System/Timeout.hs
=====================================
@@ -58,7 +58,9 @@ instance Exception Timeout where
 -- is available within @n@ microseconds (@1\/10^6@ seconds). In case a result
 -- is available before the timeout expires, @Just a@ is returned. A negative
 -- timeout interval means \"wait indefinitely\". When specifying long timeouts,
--- be careful not to exceed @maxBound :: Int at .
+-- be careful not to exceed @maxBound :: Int@, which on 32-bit machines is only
+-- 2147483647 μs, less than 36 minutes.
+-- Consider using @Control.Concurrent.Timeout.timeout@ from @unbounded-delays@ package.
 --
 -- >>> timeout 1000000 (threadDelay 1000 *> pure "finished on time")
 -- Just "finished on time"



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/74351150d32aff4866352757ac69b4eecc6b245b...8e4a58b0d2cc16652f1e72aaf5f2b38757a488b7

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/74351150d32aff4866352757ac69b4eecc6b245b...8e4a58b0d2cc16652f1e72aaf5f2b38757a488b7
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20220810/b6869da6/attachment-0001.html>


More information about the ghc-commits mailing list