summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamar Christina <tamar@zhox.com>2021-06-06 18:22:52 +0100
committerZubin Duggal <zubin.duggal@gmail.com>2021-09-21 22:28:28 +0530
commitf993e0fc3dee961e5ece22578643ba139a0c747e (patch)
treef340f6f2ea0ccbdda44531e07eb8d26071c0d3b4
parent06935a71a97430405c3fb713f6ef5df1fb8dd6a3 (diff)
downloadhaskell-f993e0fc3dee961e5ece22578643ba139a0c747e.tar.gz
rts: move xxxHash out of the user namespace
(cherry picked from commit 74c874148fbea996cadf1d9fa50f2a44488dd82b) (cherry picked from commit 3d65c4e3f2aadd4f9c7eb5c421f70247e63c66b2)
-rw-r--r--hadrian/src/Settings/Packages.hs6
-rw-r--r--rts/Hash.c13
-rw-r--r--rts/ghc.mk7
-rw-r--r--rts/rts.cabal.in6
4 files changed, 25 insertions, 7 deletions
diff --git a/hadrian/src/Settings/Packages.hs b/hadrian/src/Settings/Packages.hs
index cdf5a51d8d..78a754ab39 100644
--- a/hadrian/src/Settings/Packages.hs
+++ b/hadrian/src/Settings/Packages.hs
@@ -333,10 +333,8 @@ rtsPackageArgs = package rts ? do
-- We're after pur performance here. So make sure fast math and
-- vectorization is enabled.
- , input "**/xxhash.c" ? pure
- [ "-O3"
- , "-ffast-math"
- , "-ftree-vectorize" ]
+ , input "**/Hash.c" ? pure
+ [ "-O3" ]
, inputs ["**/Evac.c", "**/Evac_thr.c"] ? arg "-funroll-loops"
diff --git a/rts/Hash.c b/rts/Hash.c
index 6e1873ff29..39c5360f56 100644
--- a/rts/Hash.c
+++ b/rts/Hash.c
@@ -13,6 +13,19 @@
#include "Hash.h"
#include "RtsUtils.h"
+
+/* This file needs to be compiled with vectorization enabled. Unfortunately
+ since we compile these things these days with cabal we can no longer
+ specify optimization per file. So we have to resort to pragmas. */
+#if defined(__GNUC__) || defined(__GNUG__)
+#pragma GCC push_options
+#pragma GCC optimize ("O3")
+#endif
+
+#define XXH_NAMESPACE __rts_
+#define XXH_STATIC_LINKING_ONLY /* access advanced declarations */
+#define XXH_PRIVATE_API
+
#include "xxhash.h"
#include <string.h>
diff --git a/rts/ghc.mk b/rts/ghc.mk
index 32c49d9099..bc312482c8 100644
--- a/rts/ghc.mk
+++ b/rts/ghc.mk
@@ -45,7 +45,10 @@ else
ALL_DIRS += posix
endif
-rts_C_SRCS := $(wildcard rts/*.c $(foreach dir,$(ALL_DIRS),rts/$(dir)/*.c))
+tmp_rts_C_SRCS := $(wildcard rts/*.c $(foreach dir,$(ALL_DIRS),rts/$(dir)/*.c))
+# We shouldn't include this file in the binary, it's a common function so
+# it will likely clash with something later. See #19948
+rts_C_SRCS = $(filter-out rts/xxhash.c, $(tmp_rts_C_SRCS))
rts_C_HOOK_SRCS := $(wildcard rts/hooks/*.c)
rts_CMM_SRCS := $(wildcard rts/*.cmm)
@@ -428,7 +431,7 @@ rts/RtsUtils_CC_OPTS += -DTargetVendor=\"$(TargetVendor_CPP)\"
rts/RtsUtils_CC_OPTS += -DGhcUnregisterised=\"$(GhcUnregisterised)\"
rts/RtsUtils_CC_OPTS += -DTablesNextToCode=\"$(TablesNextToCode)\"
#
-rts/xxhash_CC_OPTS += -O3 -ffast-math -ftree-vectorize
+rts/Hash_CC_OPTS += -O3
# Compile various performance-critical pieces *without* -fPIC -dynamic
# even when building a shared library. If we don't do this, then the
diff --git a/rts/rts.cabal.in b/rts/rts.cabal.in
index 93dd6743a9..c35db7ae50 100644
--- a/rts/rts.cabal.in
+++ b/rts/rts.cabal.in
@@ -523,10 +523,14 @@ library
sm/Scav_thr.c
sm/Storage.c
sm/Sweep.c
- xxhash.c
fs.c
-- I wish we had wildcards..., this would be:
-- *.c hooks/**/*.c sm/**/*.c eventlog/**/*.c linker/**/*.c
+
+ extra-source-files:
+ -- This file needs to be in the package but shouldn't be compiled on its own.
+ xxhash.c
+
if os(windows)
c-sources: win32/AsyncMIO.c
win32/AsyncWinIO.c