  Suppose $(X,\Omega,g)$ is a compact Spin(7)-manifold, e.g. a Riemannian
8-manifold with holonomy Spin(7), or a Calabi-Yau 4-fold. Let $G$ be U$(m)$ or
SU$(m)$, and $P\to X$ be a principal $G$-bundle. We show that the
infinite-dimensional moduli space ${\mathcal B}_P$ of all connections on $P$
modulo gauge is orientable, in a certain sense. We deduce that the moduli space
${\mathcal M}_P^{Spin(7)}\subset{\mathcal B}_P$ of irreducible
Spin(7)-instanton connections on $P$ modulo gauge, as a manifold or derived
manifold, is orientable. This improves theorems of Cao and Leung
arXiv:1502.01141 and Mu\~noz and Shahbazi arXiv:1707.02998.
  If $X$ is a Calabi-Yau 4-fold, the derived moduli stack $\boldsymbol{\mathscr
M}$ of (complexes of) coherent sheaves on $X$ is a $-2$-shifted symplectic
derived stack $(\boldsymbol{\mathcal M},\omega)$ by
Pantev-To\"en-Vaqui\'e-Vezzosi arXiv:1111.3209, and so has a notion of
orientation by Borisov-Joyce arXiv:1504.00690. We prove that
$(\boldsymbol{\mathscr M},\omega)$ is orientable, by relating algebro-geometric
orientations on $(\boldsymbol{\mathscr M},\omega)$ to differential-geometric
orientations on ${\mathcal B}_P$ for U$(m)$-bundles $P\to X$, and using
orientability of ${\mathcal B}_P$.
  This has applications to the programme of defining Donaldson-Thomas type
invariants counting moduli spaces of (semi)stable coherent sheaves on a
Calabi-Yau 4-fold, as in Donaldson and Thomas 1998, Cao and Leung
arXiv:1407.7659, and Borisov and Joyce arXiv:1504.00690.
  This is the third in a series arXiv:1811.01096, arXiv:1811.02405 on
orientations of gauge-theoretic moduli spaces.

Differential Geometry;Algebraic Geometry;Algebraic Topology