Simon Jakobi pushed to branch wip/sjakobi/T25450-march-native at Glasgow Haskell Compiler / GHC
Commits:
-
50b789bf
by Simon Jakobi at 2026-11-23T08:17:40+01:00
19 changed files:
- + changelog.d/gcc-6-minimum
- + changelog.d/march-native
- compiler/GHC/Driver/DynFlags.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Platform/CpuFeatures.hs
- + compiler/GHC/Platform/HostCpuFeatures.hs
- + compiler/HostCpuFeaturesX86.h
- + compiler/cbits/host_cpu_features_x86.c
- compiler/ghc.cabal.in
- docs/users_guide/expected-undocumented-flags.txt
- docs/users_guide/using.rst
- m4/fp_gcc_version.m4
- rts/RtsSymbols.c
- testsuite/tests/driver/Makefile
- testsuite/tests/driver/all.T
- + testsuite/tests/driver/march_native_matches_cc.hs
- + testsuite/tests/driver/march_native_unsupported_arch.hs
- + testsuite/tests/driver/march_native_unsupported_arch.stderr
- testsuite/tests/rts/symbols/Main.hs
Changes:
| 1 | +section: packaging
|
|
| 2 | +synopsis: GHC's configure scripts now require GCC 6 or newer, up from 4.7.
|
|
| 3 | +issues: #25450
|
|
| 4 | +mrs: !16126 |
| 1 | +section: compiler
|
|
| 2 | +synopsis: Add :ghc-flag:`-march=native`, which on x86 and x86_64 enables the
|
|
| 3 | + CPU features of the machine running GHC.
|
|
| 4 | +issues: #25450
|
|
| 5 | +mrs: !16126 |
| ... | ... | @@ -450,7 +450,7 @@ data DynFlags = DynFlags { |
| 450 | 450 | interactivePrint :: Maybe String,
|
| 451 | 451 | |
| 452 | 452 | -- Machine dependent flags (-m\<blah> stuff)
|
| 453 | - cpuFeatures :: EnumSet CpuFeature, -- ^ The @-m\<feature\>@ flags that were passed.
|
|
| 453 | + cpuFeatures :: EnumSet CpuFeature, -- ^ The CPU features requested by @-m...@ flags.
|
|
| 454 | 454 | -- See Note [CPU features] in GHC.Platform.CpuFeatures.
|
| 455 | 455 | la664 :: Bool, -- ^ Enable LA664 instructions
|
| 456 | 456 |
| 1 | 1 | {-# LANGUAGE CPP #-}
|
| 2 | +{-# LANGUAGE MultiWayIf #-}
|
|
| 2 | 3 | |
| 3 | 4 | -------------------------------------------------------------------------------
|
| 4 | 5 | --
|
| ... | ... | @@ -228,6 +229,8 @@ import GHC.Platform.CpuFeatures |
| 228 | 229 | import GHC.Platform.Ways
|
| 229 | 230 | import GHC.Platform.Profile
|
| 230 | 231 | import GHC.Platform.ArchOS
|
| 232 | +import GHC.Platform.Host (hostPlatformArch)
|
|
| 233 | +import GHC.Platform.HostCpuFeatures (hostX86CpuFeatures)
|
|
| 231 | 234 | |
| 232 | 235 | import GHC.Unit.Types
|
| 233 | 236 | import GHC.Unit.Parser
|
| ... | ... | @@ -1737,6 +1740,7 @@ dynamic_flags_deps = [ |
| 1737 | 1740 | (setDumpFlag Opt_D_dump_faststrings)
|
| 1738 | 1741 | |
| 1739 | 1742 | ------ Machine dependent (-m<blah>) stuff ---------------------------
|
| 1743 | + , make_ord_flag defGhcFlag "march=native" (NoArg enableHostCpuFeatures)
|
|
| 1740 | 1744 | |
| 1741 | 1745 | , make_ord_flag defGhcFlag "mla664" (noArg (\d -> d { la664 = True }))
|
| 1742 | 1746 | |
| ... | ... | @@ -2863,6 +2867,17 @@ setDumpFlag dump_flag = NoArg (setDumpFlag' dump_flag) |
| 2863 | 2867 | setCpuFeature :: CpuFeature -> DynFlags -> DynFlags
|
| 2864 | 2868 | setCpuFeature feat dflags = dflags { cpuFeatures = EnumSet.insert feat (cpuFeatures dflags) }
|
| 2865 | 2869 | |
| 2870 | +-- | @-march=native@: enable the CPU features of the host GHC is running on.
|
|
| 2871 | +enableHostCpuFeatures :: DynP ()
|
|
| 2872 | +enableHostCpuFeatures = do
|
|
| 2873 | + arch <- platformArch . targetPlatform <$> liftEwM getCmdLineState
|
|
| 2874 | + if | arch /= ArchX86 && arch /= ArchX86_64
|
|
| 2875 | + -> addErr "-march=native is only supported on x86 and x86_64 targets"
|
|
| 2876 | + | arch /= hostPlatformArch
|
|
| 2877 | + -> addErr "-march=native is not supported when the target architecture differs from the host's"
|
|
| 2878 | + | otherwise
|
|
| 2879 | + -> upd $ \d -> d { cpuFeatures = cpuFeatures d `mappend` hostX86CpuFeatures }
|
|
| 2880 | + |
|
| 2866 | 2881 | -- | The @-m\<feature\>@ flag for a 'CpuFeature'.
|
| 2867 | 2882 | cpuFeatureFlagDep :: CpuFeature -> (Deprecation, Flag (CmdLineP DynFlags))
|
| 2868 | 2883 | cpuFeatureFlagDep feat =
|
| ... | ... | @@ -64,8 +64,9 @@ others: |
| 64 | 64 | |
| 65 | 65 | We keep two representations:
|
| 66 | 66 | |
| 67 | - A. 'DynFlags' records the set of flags that were passed, as an
|
|
| 68 | - 'EnumSet' of 'CpuFeature'. Nothing is implied at this stage.
|
|
| 67 | + A. 'DynFlags' records the set of requested features, as an 'EnumSet' of
|
|
| 68 | + 'CpuFeature': one per -m<feature> flag passed, plus the features of the
|
|
| 69 | + host under -march=native. Nothing is implied at this stage.
|
|
| 69 | 70 | |
| 70 | 71 | B. 'initCpuFeatures' turns this set into a 'CpuFeatures' value, applying the
|
| 71 | 72 | implications and the baseline of the target architecture. This
|
| 1 | +{-# LANGUAGE CPP #-}
|
|
| 2 | + |
|
| 3 | +module GHC.Platform.HostCpuFeatures
|
|
| 4 | + ( hostX86CpuFeatures
|
|
| 5 | + ) where
|
|
| 6 | + |
|
| 7 | +import GHC.Prelude
|
|
| 8 | + |
|
| 9 | +import GHC.Data.EnumSet (EnumSet)
|
|
| 10 | +import qualified GHC.Data.EnumSet as EnumSet
|
|
| 11 | +import GHC.Platform.CpuFeatures (CpuFeature(..))
|
|
| 12 | + |
|
| 13 | +import Data.Word (Word64)
|
|
| 14 | +import System.IO.Unsafe (unsafePerformIO)
|
|
| 15 | + |
|
| 16 | +#include "HostCpuFeaturesX86.h"
|
|
| 17 | + |
|
| 18 | +#define GHC_X86_FEATURE_CONS(feat, cond) feat :
|
|
| 19 | + |
|
| 20 | +-- | The features of the table in @HostCpuFeaturesX86.h@, in row order.
|
|
| 21 | +probedX86CpuFeatures :: [CpuFeature]
|
|
| 22 | +probedX86CpuFeatures = GHC_X86_PROBED_FEATURES(GHC_X86_FEATURE_CONS) []
|
|
| 23 | + |
|
| 24 | +-- | The host's x86 CPU features.
|
|
| 25 | +hostX86CpuFeatures :: EnumSet CpuFeature
|
|
| 26 | +hostX86CpuFeatures = unsafePerformIO $ do
|
|
| 27 | + mask <- hostX86CpuFeatureMask
|
|
| 28 | + pure $ EnumSet.fromList
|
|
| 29 | + [ feat
|
|
| 30 | + | (bit, feat) <- zip [0 ..] probedX86CpuFeatures
|
|
| 31 | + , testBit mask bit
|
|
| 32 | + ]
|
|
| 33 | +{-# NOINLINE hostX86CpuFeatures #-}
|
|
| 34 | + |
|
| 35 | +#if defined(javascript_HOST_ARCH)
|
|
| 36 | +hostX86CpuFeatureMask :: IO Word64
|
|
| 37 | +hostX86CpuFeatureMask = pure 0
|
|
| 38 | +#else
|
|
| 39 | +foreign import ccall unsafe "ghc_host_x86_cpu_feature_mask"
|
|
| 40 | + hostX86CpuFeatureMask :: IO Word64
|
|
| 41 | +#endif |
| 1 | +/* The x86 features that -march=native probes. Each row pairs a CpuFeature
|
|
| 2 | + constructor with the C condition (see cbits/host_cpu_features_x86.c) that
|
|
| 3 | + detects the feature on the host. SSE and SSE2 are not probed: they are
|
|
| 4 | + GHC's x86 baseline.
|
|
| 5 | + |
|
| 6 | + Row i is bit i of the mask that ghc_host_x86_cpu_feature_mask returns and
|
|
| 7 | + GHC.Platform.HostCpuFeatures decodes, so the table can hold at most 64
|
|
| 8 | + rows. */
|
|
| 9 | +#define GHC_X86_PROBED_FEATURES(F) \
|
|
| 10 | + F(Feat_SSE3, SUPPORTS("sse3")) \
|
|
| 11 | + F(Feat_SSSE3, SUPPORTS("ssse3")) \
|
|
| 12 | + F(Feat_SSE4, SUPPORTS("sse4.1")) \
|
|
| 13 | + F(Feat_SSE4_2, SUPPORTS("sse4.2")) \
|
|
| 14 | + F(Feat_AVX, SUPPORTS("avx")) \
|
|
| 15 | + F(Feat_AVX2, SUPPORTS("avx2")) \
|
|
| 16 | + F(Feat_AVX512F, SUPPORTS("avx512f")) \
|
|
| 17 | + F(Feat_AVX512BW, SUPPORTS("avx512bw")) \
|
|
| 18 | + F(Feat_AVX512CD, SUPPORTS("avx512cd")) \
|
|
| 19 | + F(Feat_AVX512DQ, SUPPORTS("avx512dq")) \
|
|
| 20 | + F(Feat_AVX512VL, SUPPORTS("avx512vl")) \
|
|
| 21 | + F(Feat_BMI, SUPPORTS("bmi")) \
|
|
| 22 | + F(Feat_BMI2, SUPPORTS("bmi2")) \
|
|
| 23 | + F(Feat_FMA, SUPPORTS_FMA) \
|
|
| 24 | + F(Feat_GFNI, SUPPORTS_GFNI) |
| 1 | +#include <HsFFI.h>
|
|
| 2 | + |
|
| 3 | +/* Host x86 CPU feature detection for GHC.Platform.HostCpuFeatures
|
|
| 4 | + (-march=native).
|
|
| 5 | + |
|
| 6 | + The RTS has to export the libgcc/compiler-rt symbols that the
|
|
| 7 | + __builtin_cpu_* calls refer to: see RTS_X86_CPU_MODEL_SYMBOLS in
|
|
| 8 | + rts/RtsSymbols.c. */
|
|
| 9 | + |
|
| 10 | +#include "HostCpuFeaturesX86.h"
|
|
| 11 | + |
|
| 12 | +#if defined(__i386__) || defined(__x86_64__)
|
|
| 13 | + |
|
| 14 | +#define SUPPORTS(name) __builtin_cpu_supports(name)
|
|
| 15 | + |
|
| 16 | +/* FMA is usable only when the OS saves the AVX register state, but
|
|
| 17 | + compiler-rt's cpu_model/x86.c reports "fma" from the raw CPUID bit. */
|
|
| 18 | +#define SUPPORTS_FMA (SUPPORTS("fma") && SUPPORTS("avx"))
|
|
| 19 | + |
|
| 20 | +/* __builtin_cpu_supports accepts "gfni" from GCC 8 and LLVM 8 on, and reads
|
|
| 21 | + it from __cpu_features2, which libgcc provides only from GCC 8 on. */
|
|
| 22 | +#if !defined(__clang__) && defined(__GNUC__) && __GNUC__ >= 8
|
|
| 23 | +/* Weak, so that programs using the ghc library from a binary distribution
|
|
| 24 | + can link against a libgcc older than GCC 8. The declaration also makes
|
|
| 25 | + the builtin's own reference weak. */
|
|
| 26 | +extern unsigned int __cpu_features2[] __attribute__((weak));
|
|
| 27 | +#define SUPPORTS_GFNI (__cpu_features2 != 0 && SUPPORTS("gfni"))
|
|
| 28 | +#elif defined(__clang__) \
|
|
| 29 | + && __clang_major__ >= (defined(__apple_build_version__) ? 11 : 8)
|
|
| 30 | +/* Apple clang numbers its releases separately: 11 is its first based on
|
|
| 31 | + LLVM 8. Clang marks its reference dso_local, so a weak declaration would
|
|
| 32 | + not help: an older libgcc fails the link. */
|
|
| 33 | +#define SUPPORTS_GFNI SUPPORTS("gfni")
|
|
| 34 | +#else
|
|
| 35 | +#define SUPPORTS_GFNI 0
|
|
| 36 | +#endif
|
|
| 37 | + |
|
| 38 | +HsWord64 ghc_host_x86_cpu_feature_mask(void)
|
|
| 39 | +{
|
|
| 40 | + __builtin_cpu_init();
|
|
| 41 | + |
|
| 42 | + HsWord64 mask = 0;
|
|
| 43 | + int bit = 0;
|
|
| 44 | + |
|
| 45 | +#define GHC_X86_PROBE(feat, cond) \
|
|
| 46 | + if (cond) { mask |= (HsWord64)1 << bit; } \
|
|
| 47 | + bit++;
|
|
| 48 | + |
|
| 49 | + GHC_X86_PROBED_FEATURES(GHC_X86_PROBE)
|
|
| 50 | + |
|
| 51 | +#undef GHC_X86_PROBE
|
|
| 52 | + |
|
| 53 | + return mask;
|
|
| 54 | +}
|
|
| 55 | + |
|
| 56 | +#else
|
|
| 57 | + |
|
| 58 | +HsWord64 ghc_host_x86_cpu_feature_mask(void)
|
|
| 59 | +{
|
|
| 60 | + return 0;
|
|
| 61 | +}
|
|
| 62 | + |
|
| 63 | +#endif |
| ... | ... | @@ -32,6 +32,7 @@ extra-source-files: |
| 32 | 32 | GHC/Builtin/primops.txt.pp
|
| 33 | 33 | Unique.h
|
| 34 | 34 | CodeGen.Platform.h
|
| 35 | + HostCpuFeaturesX86.h
|
|
| 35 | 36 | -- Shared with rts via hard-link at configure time. This is safer
|
| 36 | 37 | -- for Windows, where symlinks don't work out of the box, so we
|
| 37 | 38 | -- can't just commit some in git.
|
| ... | ... | @@ -186,6 +187,7 @@ Library |
| 186 | 187 | c-sources:
|
| 187 | 188 | cbits/cutils.c
|
| 188 | 189 | cbits/genSym.c
|
| 190 | + cbits/host_cpu_features_x86.c
|
|
| 189 | 191 | cbits/keepCAFsForGHCi.c
|
| 190 | 192 | |
| 191 | 193 | hs-source-dirs:
|
| ... | ... | @@ -691,6 +693,7 @@ Library |
| 691 | 693 | GHC.Platform.AArch64
|
| 692 | 694 | GHC.Platform.Constants
|
| 693 | 695 | GHC.Platform.CpuFeatures
|
| 696 | + GHC.Platform.HostCpuFeatures
|
|
| 694 | 697 | GHC.Platform.LA64
|
| 695 | 698 | GHC.Platform.NoRegs
|
| 696 | 699 | GHC.Platform.PPC
|
| ... | ... | @@ -55,6 +55,7 @@ |
| 55 | 55 | -instantiated-with
|
| 56 | 56 | -keep-hi-file
|
| 57 | 57 | -keep-o-file
|
| 58 | +-march=native
|
|
| 58 | 59 | -no-keep-hi-file
|
| 59 | 60 | -no-keep-o-file
|
| 60 | 61 | -no-link
|
| ... | ... | @@ -1887,6 +1887,30 @@ Some flags only make sense for particular target platforms. |
| 1887 | 1887 | so this flag has no effect when used with the :ref:`native code generator <native-code-gen>`
|
| 1888 | 1888 | or the :ref:`LLVM backend <llvm-code-gen>`.
|
| 1889 | 1889 | |
| 1890 | +.. ghc-flag:: -march=native
|
|
| 1891 | + :shortdesc: (x86 only) Enable the CPU features of the host
|
|
| 1892 | + :type: dynamic
|
|
| 1893 | + :category: platform-options
|
|
| 1894 | + |
|
| 1895 | + (x86 only) Probe the CPU of the machine running GHC and enable the
|
|
| 1896 | + corresponding ``-m...`` CPU-feature options (for example ``-msse4.2``,
|
|
| 1897 | + ``-mavx2``, ``-mbmi2``, ``-mfma``). The detected features apply to both the
|
|
| 1898 | + :ref:`native code generator <native-code-gen>` and the
|
|
| 1899 | + :ref:`LLVM backend <llvm-code-gen>`.
|
|
| 1900 | + |
|
| 1901 | + The detected features are enabled in addition to any ``-m...`` options
|
|
| 1902 | + given explicitly, regardless of their order on the command line.
|
|
| 1903 | + |
|
| 1904 | + .. warning::
|
|
| 1905 | + |
|
| 1906 | + Code compiled with ``-march=native`` may use instructions that are not
|
|
| 1907 | + available on other CPUs, and is therefore not portable to a different
|
|
| 1908 | + machine.
|
|
| 1909 | + |
|
| 1910 | + The flag is rejected on other targets. A cross-compiler also rejects it
|
|
| 1911 | + when its target architecture differs from the one GHC itself runs on, since
|
|
| 1912 | + the probed CPU then says nothing about the target.
|
|
| 1913 | + |
|
| 1890 | 1914 | Haddock
|
| 1891 | 1915 | -------
|
| 1892 | 1916 |
| ... | ... | @@ -16,9 +16,10 @@ AC_DEFUN([FP_GCC_VERSION], [ |
| 16 | 16 | AC_MSG_CHECKING([version of gcc])
|
| 17 | 17 | fp_cv_gcc_version="`$CC -v 2>&1 | sed -n -e '1,/version /s/.*version [[^0-9]]*\([[0-9.]]*\).*/\1/p'`"
|
| 18 | 18 | AC_MSG_RESULT([$fp_cv_gcc_version])
|
| 19 | - # 4.7 is needed for __atomic_ builtins.
|
|
| 20 | - FP_COMPARE_VERSIONS([$fp_cv_gcc_version], [-lt], [4.7],
|
|
| 21 | - [AC_MSG_ERROR([Need at least gcc version 4.7 (newer recommended)])])
|
|
| 19 | + # GCC 5 rejects some of the AVX-512 feature names that -march=native
|
|
| 20 | + # passes to __builtin_cpu_supports.
|
|
| 21 | + FP_COMPARE_VERSIONS([$fp_cv_gcc_version], [-lt], [6],
|
|
| 22 | + [AC_MSG_ERROR([Need at least gcc version 6 (newer recommended)])])
|
|
| 22 | 23 | ])
|
| 23 | 24 | AC_SUBST([GccVersion], [$fp_cv_gcc_version])
|
| 24 | 25 | else
|
| ... | ... | @@ -1050,6 +1050,33 @@ extern char **environ; |
| 1050 | 1050 | #define RTS_ARM_OUTLINE_ATOMIC_SYMBOLS
|
| 1051 | 1051 | #endif
|
| 1052 | 1052 | |
| 1053 | +// libgcc/compiler-rt symbols behind __builtin_cpu_supports and
|
|
| 1054 | +// __builtin_cpu_init, used by compiler/cbits/host_cpu_features_x86.c for
|
|
| 1055 | +// -march=native. Without them the runtime linker cannot load the ghc
|
|
| 1056 | +// library's object code, e.g. for plugins in a statically linked GHCi.
|
|
| 1057 | +#if defined(i386_HOST_ARCH) || defined(x86_64_HOST_ARCH)
|
|
| 1058 | +// Weak: missing before GCC 8 and LLVM 8.
|
|
| 1059 | +extern StgWord __cpu_features2[] __attribute__((weak));
|
|
| 1060 | +#define RTS_X86_CPU_MODEL_SYMBOLS \
|
|
| 1061 | + SymI_NeedsProto(__cpu_indicator_init) \
|
|
| 1062 | + SymI_NeedsDataProto(__cpu_model) \
|
|
| 1063 | + SymI_HasDataProto(__cpu_features2) \
|
|
| 1064 | + RTS_X86_CPU_INIT_LOCAL_SYMBOLS
|
|
| 1065 | +#else
|
|
| 1066 | +#define RTS_X86_CPU_MODEL_SYMBOLS
|
|
| 1067 | +#endif
|
|
| 1068 | + |
|
| 1069 | +// Alpine's and Gentoo's musl GCCs patch __builtin_cpu_init to call this
|
|
| 1070 | +// alias of __cpu_indicator_init. Weak: other musl toolchains lack it.
|
|
| 1071 | +#if (defined(i386_HOST_ARCH) || defined(x86_64_HOST_ARCH)) \
|
|
| 1072 | + && defined(linux_HOST_OS) && !defined(__GLIBC__)
|
|
| 1073 | +extern void __cpu_indicator_init_local(void) __attribute__((weak));
|
|
| 1074 | +#define RTS_X86_CPU_INIT_LOCAL_SYMBOLS \
|
|
| 1075 | + SymI_HasProto(__cpu_indicator_init_local)
|
|
| 1076 | +#else
|
|
| 1077 | +#define RTS_X86_CPU_INIT_LOCAL_SYMBOLS
|
|
| 1078 | +#endif
|
|
| 1079 | + |
|
| 1053 | 1080 | // Symbols defined by libc
|
| 1054 | 1081 | #define RTS_LIBC_SYMBOLS \
|
| 1055 | 1082 | SymI_HasProto_redirect(atexit, atexit, STRENGTH_STRONG, SYM_TYPE_CODE) /* See Note [Strong symbols] */ \
|
| ... | ... | @@ -1210,6 +1237,7 @@ RTS_OPENBSD_ONLY_SYMBOLS |
| 1210 | 1237 | RTS_LIBC_SYMBOLS
|
| 1211 | 1238 | RTS_LIBGCC_SYMBOLS
|
| 1212 | 1239 | RTS_ARCH_LIBGCC_SYMBOLS
|
| 1240 | +RTS_X86_CPU_MODEL_SYMBOLS
|
|
| 1213 | 1241 | RTS_FINI_ARRAY_SYMBOLS
|
| 1214 | 1242 | RTS_LIBFFI_SYMBOLS
|
| 1215 | 1243 | RTS_ARM_OUTLINE_ATOMIC_SYMBOLS
|
| ... | ... | @@ -1265,6 +1293,7 @@ RtsSymbolVal const * getRtsSymbols(void) { |
| 1265 | 1293 | RTS_OPENBSD_ONLY_SYMBOLS
|
| 1266 | 1294 | RTS_LIBGCC_SYMBOLS
|
| 1267 | 1295 | RTS_ARCH_LIBGCC_SYMBOLS
|
| 1296 | + RTS_X86_CPU_MODEL_SYMBOLS
|
|
| 1268 | 1297 | RTS_FINI_ARRAY_SYMBOLS
|
| 1269 | 1298 | RTS_LIBFFI_SYMBOLS
|
| 1270 | 1299 | RTS_ARM_OUTLINE_ATOMIC_SYMBOLS
|
| ... | ... | @@ -500,6 +500,15 @@ withRtsOpts: |
| 500 | 500 | T3364:
|
| 501 | 501 | -"$(TEST_HC)" $(TEST_HC_OPTS) -H
|
| 502 | 502 | |
| 503 | +# GHC and the C compiler should detect the same host CPU features.
|
|
| 504 | +.PHONY: march_native_matches_cc
|
|
| 505 | +march_native_matches_cc:
|
|
| 506 | + "$(TEST_HC)" $(TEST_HC_OPTS) -march=native -E -cpp march_native_matches_cc.hs -o ghc.out
|
|
| 507 | + "$(TEST_CC)" $(TEST_CC_OPTS) -march=native -E -x c march_native_matches_cc.hs > cc.out
|
|
| 508 | + sed -n 's/^\(feat [a-z0-9.]*\).*/\1/p' ghc.out > ghc.feats
|
|
| 509 | + sed -n 's/^\(feat [a-z0-9.]*\).*/\1/p' cc.out > cc.feats
|
|
| 510 | + diff -u ghc.feats cc.feats
|
|
| 511 | + |
|
| 503 | 512 | .PHONY: T706
|
| 504 | 513 | T706:
|
| 505 | 514 | cp T706a.hs T706.hs
|
| ... | ... | @@ -223,6 +223,15 @@ test('T9938B', [], makefile_test, []) |
| 223 | 223 | test('T9963', exit_code(1), run_command,
|
| 224 | 224 | ['{compiler} --interactive -ignore-dot-ghci --print-libdir'])
|
| 225 | 225 | |
| 226 | +test('march_native_unsupported_arch',
|
|
| 227 | + [when(arch('x86_64') or arch('i386'), skip)],
|
|
| 228 | + compile_fail,
|
|
| 229 | + ['-march=native'])
|
|
| 230 | + |
|
| 231 | +test('march_native_matches_cc',
|
|
| 232 | + [unless(arch('x86_64') or arch('i386'), skip), when(config.cross, skip)],
|
|
| 233 | + makefile_test, [])
|
|
| 234 | + |
|
| 226 | 235 | test('T10219', normal, run_command,
|
| 227 | 236 | # `-x hspp` in make mode should work.
|
| 228 | 237 | # Note: need to specify `-x hspp` before the filename.
|
| 1 | +-- BMI and BMI2 are not listed: GHC defines no macros for them.
|
|
| 2 | +#if defined(__SSE3__)
|
|
| 3 | +feat sse3
|
|
| 4 | +#endif
|
|
| 5 | +#if defined(__SSSE3__)
|
|
| 6 | +feat ssse3
|
|
| 7 | +#endif
|
|
| 8 | +#if defined(__SSE4_1__)
|
|
| 9 | +feat sse4.1
|
|
| 10 | +#endif
|
|
| 11 | +#if defined(__SSE4_2__)
|
|
| 12 | +feat sse4.2
|
|
| 13 | +#endif
|
|
| 14 | +#if defined(__AVX__)
|
|
| 15 | +feat avx
|
|
| 16 | +#endif
|
|
| 17 | +#if defined(__AVX2__)
|
|
| 18 | +feat avx2
|
|
| 19 | +#endif
|
|
| 20 | +#if defined(__AVX512F__)
|
|
| 21 | +feat avx512f
|
|
| 22 | +#endif
|
|
| 23 | +#if defined(__AVX512BW__)
|
|
| 24 | +feat avx512bw
|
|
| 25 | +#endif
|
|
| 26 | +#if defined(__AVX512CD__)
|
|
| 27 | +feat avx512cd
|
|
| 28 | +#endif
|
|
| 29 | +#if defined(__AVX512DQ__)
|
|
| 30 | +feat avx512dq
|
|
| 31 | +#endif
|
|
| 32 | +#if defined(__AVX512VL__)
|
|
| 33 | +feat avx512vl
|
|
| 34 | +#endif
|
|
| 35 | +#if defined(__FMA__)
|
|
| 36 | +feat fma
|
|
| 37 | +#endif
|
|
| 38 | +#if defined(__GFNI__)
|
|
| 39 | +feat gfni
|
|
| 40 | +#endif |
| 1 | +module M where |
| 1 | +ghc: on the commandline: -march=native is only supported on x86 and x86_64 targets
|
|
| 2 | +Usage: For basic information, try the `--help' option. |
| ... | ... | @@ -31,6 +31,13 @@ ignoreSymbols = S.fromList [ |
| 31 | 31 | "__umoddi3",
|
| 32 | 32 | "__umodti3",
|
| 33 | 33 | |
| 34 | + -- Defined in libgcc/compiler-rt. RtsSymbols.c declares them on x86 only
|
|
| 35 | + -- (+Declared)
|
|
| 36 | + "__cpu_features2",
|
|
| 37 | + "__cpu_indicator_init",
|
|
| 38 | + "__cpu_indicator_init_local",
|
|
| 39 | + "__cpu_model",
|
|
| 40 | + |
|
| 34 | 41 | -- These may be a CPP mismatch between rts/prim/vectorQuotRem.c and RtsSymbols.c
|
| 35 | 42 | "hs_quotInt16X8",
|
| 36 | 43 | "hs_quotInt32X4",
|