Merge master into haskell-updates

This commit is contained in:
github-actions[bot]
2023-12-14 00:12:40 +00:00
committed by GitHub
186 changed files with 3825 additions and 2308 deletions

View File

@@ -27,12 +27,29 @@ lib.makeScope newScope (self: {
"https://code.call-cc.org/cgi-bin/gitweb.cgi?p=eggs-5-latest.git;a=tree;f=${pname}/${version}";
meta.description = synopsis;
meta.license = (lib.licenses // {
"agpl" = lib.licenses.agpl3Only;
"artistic" = lib.licenses.artistic2;
"bsd" = lib.licenses.bsd3;
"bsd-1-clause" = lib.licenses.bsd1;
"bsd-2-clause" = lib.licenses.bsd2;
"bsd-3-clause" = lib.licenses.bsd3;
"gpl" = lib.licenses.gpl3Only;
"gpl-2" = lib.licenses.gpl2Only;
"gplv2" = lib.licenses.gpl2Only;
"gpl-3" = lib.licenses.gpl3Only;
"gpl-3.0" = lib.licenses.gpl3Only;
"gplv3" = lib.licenses.gpl3Only;
"lgpl" = lib.licenses.lgpl3Only;
"lgpl-2" = lib.licenses.lgpl2Only;
"lgpl-2.0+" = lib.licenses.lgpl2Plus;
"lgpl-2.1" = lib.licenses.lgpl21Only;
"lgpl-2.1-or-later" = lib.licenses.lgpl21Plus;
"lgpl-3" = lib.licenses.lgpl3Only;
"lgplv3" = lib.licenses.lgpl3Only;
"public-domain" = lib.licenses.publicDomain;
"srfi" = lib.licenses.bsd3;
"unicode" = lib.licenses.ucd;
"zlib-acknowledgement" = lib.licenses.zlib;
}).${license} or license;
})
(lib.importTOML ./deps.toml))));

View File

@@ -1,4 +1,4 @@
From 4bbbb640934aa653bcfec0335798b77a8935b815 Mon Sep 17 00:00:00 2001
From 86fc9ce2b381748813b372f7e86909be6f955cbd Mon Sep 17 00:00:00 2001
From: Yureka <yuka@yuka.dev>
Date: Sat, 7 Aug 2021 09:16:46 +0200
Subject: [PATCH] emulate clang 'sysroot + /include' logic
@@ -16,27 +16,23 @@ in the include search order, right after the resource root.
Hence usage of -idirafter. Clang also documents an -isystem-after flag
but it doesn't appear to work
---
emcc.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
emcc.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/emcc.py b/emcc.py
index ba8d1b556..7d89644c5 100755
index 279f6d4d9..26e20e2cc 100644
--- a/emcc.py
+++ b/emcc.py
@@ -883,7 +883,12 @@ def parse_s_args(args):
@@ -400,6 +400,9 @@ def get_cflags(user_args, is_cxx):
# We add these to the user's flags (newargs), but not when building .s or .S assembly files
cflags = get_clang_flags(user_args)
cflags.append('--sysroot=' + cache.get_sysroot(absolute=True))
+ cflags.append('-resource-dir=@resourceDir@')
+ cflags.append('-idirafter' + cache.get_sysroot(absolute=True) + os.path.join('/include'))
+ cflags.append('-iwithsysroot' + os.path.join('/include','c++','v1'))
def emsdk_cflags(user_args):
- cflags = ['--sysroot=' + cache.get_sysroot(absolute=True)]
+ cflags = [
+ '--sysroot=' + cache.get_sysroot(absolute=True),
+ '-resource-dir=@resourceDir@',
+ '-idirafter' + cache.get_sysroot(absolute=True) + os.path.join('/include'),
+ '-iwithsysroot' + os.path.join('/include','c++','v1')
+ ]
def array_contains_any_of(hay, needles):
for n in needles:
if settings.EMSCRIPTEN_TRACING:
cflags.append('-D__EMSCRIPTEN_TRACING__=1')
--
2.40.0
2.42.0

View File

@@ -8,7 +8,7 @@
stdenv.mkDerivation rec {
pname = "emscripten";
version = "3.1.47";
version = "3.1.50";
llvmEnv = symlinkJoin {
name = "emscripten-llvm-${version}";
@@ -32,7 +32,7 @@ stdenv.mkDerivation rec {
src = fetchFromGitHub {
owner = "emscripten-core";
repo = "emscripten";
hash = "sha256-cRNkQ+7vUqJLNlf5dieeDcyT1jlBUeVxO8avoUvOPHI=";
hash = "sha256-iFZF+DxGaq279QPPugoLhYmoXmyLPkmn1x4rBCkdW+I=";
rev = version;
};
@@ -42,7 +42,7 @@ stdenv.mkDerivation rec {
patches = [
(substituteAll {
src = ./0001-emulate-clang-sysroot-include-logic.patch;
resourceDir = "${llvmEnv}/lib/clang/16/";
resourceDir = "${llvmEnv}/lib/clang/17/";
})
];
@@ -51,6 +51,9 @@ stdenv.mkDerivation rec {
patchShebangs .
# emscripten 3.1.50 requires LLVM tip-of-tree instead of LLVM 17
sed -i -e "s/EXPECTED_LLVM_VERSION = 18/EXPECTED_LLVM_VERSION = 17.0/g" tools/shared.py
# fixes cmake support
sed -i -e "s/print \('emcc (Emscript.*\)/sys.stderr.write(\1); sys.stderr.flush()/g" emcc.py
@@ -106,7 +109,11 @@ stdenv.mkDerivation rec {
# TODO: get library cache to build with both enabled and function exported
$out/bin/emcc $LTO $BIND test.c
$out/bin/emcc $LTO $BIND -s RELOCATABLE test.c
$out/bin/emcc $LTO $BIND -s USE_PTHREADS test.c
# starting with emscripten 3.1.48+,
# to use pthreads, _emscripten_check_mailbox must be exported
# (see https://github.com/emscripten-core/emscripten/pull/20604)
# TODO: get library cache to build with pthreads at all
# $out/bin/emcc $LTO $BIND -s USE_PTHREADS test.c
done
done
popd
@@ -131,7 +138,7 @@ stdenv.mkDerivation rec {
homepage = "https://github.com/emscripten-core/emscripten";
description = "An LLVM-to-JavaScript Compiler";
platforms = platforms.all;
maintainers = with maintainers; [ qknight matthewbauer raitobezarius ];
maintainers = with maintainers; [ qknight matthewbauer raitobezarius willcohen ];
license = licenses.ncsa;
};
}

View File

@@ -106,6 +106,9 @@ stdenv.mkDerivation rec {
./install.sh
(cd $out/bin ; ln -s ../gerbil/bin/* .)
runHook postInstall
'' + lib.optionalString stdenv.isDarwin ''
libgerbil="$(realpath "$out/gerbil/lib/libgerbil.so")"
install_name_tool -id "$libgerbil" "$libgerbil"
'';
dontStrip = true;

View File

@@ -63,22 +63,7 @@ let
mkdir -p $out/bin
ln -s ${lib.getDev musl}/bin/musl-gcc $out/bin/${stdenv.hostPlatform.system}-musl-gcc
'');
# GraalVM 23.0.0+ (i.e.: JDK 21.0.0+) clean-up the environment inside darwin
# So we need to re-added some env vars to make everything work correctly again
darwin-cc = (runCommandCC "darwin-cc"
{
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ darwin.apple_sdk.frameworks.Foundation zlib ];
} ''
makeWrapper ${stdenv.cc}/bin/cc $out/bin/cc \
--prefix NIX_CFLAGS_COMPILE_${stdenv.cc.suffixSalt} : "$NIX_CFLAGS_COMPILE" \
--prefix NIX_LDFLAGS_${stdenv.cc.suffixSalt} : "$NIX_LDFLAGS"
'');
binPath = lib.makeBinPath (
lib.optionals stdenv.isDarwin [ darwin-cc ]
++ lib.optionals useMusl [ musl-gcc ]
++ [ stdenv.cc ]
);
binPath = lib.makeBinPath (lib.optionals useMusl [ musl-gcc ] ++ [ stdenv.cc ]);
runtimeLibraryPath = lib.makeLibraryPath
([ cups ] ++ lib.optionals gtkSupport [ cairo glib gtk3 ]);
@@ -180,6 +165,14 @@ let
echo "Testing GraalVM"
$out/bin/java -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+UseJVMCICompiler HelloWorld | fgrep 'Hello World'
# Workaround GraalVM issue where the builder does not have access to the
# environment variables since 21.0.0
# Only needed for native-image tests
# https://github.com/oracle/graal/pull/6095
# https://github.com/oracle/graal/pull/6095
# https://github.com/oracle/graal/issues/7502
export NATIVE_IMAGE_DEPRECATED_BUILDER_SANITATION="true";
echo "Ahead-Of-Time compilation"
$out/bin/native-image -H:+UnlockExperimentalVMOptions -H:-CheckToolchain -H:+ReportExceptionStackTraces HelloWorld
./helloworld | fgrep 'Hello World'

View File

@@ -0,0 +1,190 @@
From 93adcb770b99351b18553089c164fe3ef2119699 Mon Sep 17 00:00:00 2001
From: Sam Clegg <sbc@chromium.org>
Date: Fri, 25 Aug 2023 13:56:16 -0700
Subject: [PATCH] [lld][WebAssembly] Add `--table-base` setting
This is similar to `--global-base` but determines where to place the
table segments rather than that data segments.
See https://github.com/emscripten-core/emscripten/issues/20097
Differential Revision: https://reviews.llvm.org/D158892
---
test/wasm/table-base.s | 72 ++++++++++++++++++++++++++++++++++++++
wasm/Driver.cpp | 19 ++++++++--
wasm/Options.td | 5 ++-
wasm/Writer.cpp | 8 -----
4 files changed, 93 insertions(+), 11 deletions(-)
create mode 100644 test/wasm/table-base.s
diff --git a/test/wasm/table-base.s b/test/wasm/table-base.s
new file mode 100644
index 000000000000000..56fff414fd31d96
--- /dev/null
+++ b/test/wasm/table-base.s
@@ -0,0 +1,72 @@
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %s -o %t.o
+
+# RUN: wasm-ld --export=__table_base -o %t.wasm %t.o
+# RUN: obj2yaml %t.wasm | FileCheck %s -check-prefix=CHECK-DEFAULT
+
+# RUN: wasm-ld --table-base=100 --export=__table_base -o %t.wasm %t.o
+# RUN: obj2yaml %t.wasm | FileCheck %s -check-prefix=CHECK-100
+
+.globl _start
+_start:
+ .functype _start () -> ()
+ i32.const _start
+ drop
+ end_function
+
+# CHECK-DEFAULT: - Type: TABLE
+# CHECK-DEFAULT-NEXT: Tables:
+# CHECK-DEFAULT-NEXT: - Index: 0
+# CHECK-DEFAULT-NEXT: ElemType: FUNCREF
+# CHECK-DEFAULT-NEXT: Limits:
+# CHECK-DEFAULT-NEXT: Flags: [ HAS_MAX ]
+# CHECK-DEFAULT-NEXT: Minimum: 0x2
+# CHECK-DEFAULT-NEXT: Maximum: 0x2
+
+# CHECK-DEFAULT: - Type: GLOBAL
+# CHECK-DEFAULT-NEXT: Globals:
+# CHECK-DEFAULT-NEXT: - Index: 0
+# CHECK-DEFAULT-NEXT: Type: I32
+# CHECK-DEFAULT-NEXT: Mutable: true
+# CHECK-DEFAULT-NEXT: InitExpr:
+# CHECK-DEFAULT-NEXT: Opcode: I32_CONST
+# CHECK-DEFAULT-NEXT: Value: 66560
+# CHECK-DEFAULT-NEXT: - Index: 1
+# CHECK-DEFAULT-NEXT: Type: I32
+# CHECK-DEFAULT-NEXT: Mutable: false
+# CHECK-DEFAULT-NEXT: InitExpr:
+# CHECK-DEFAULT-NEXT: Opcode: I32_CONST
+# CHECK-DEFAULT-NEXT: Value: 1
+
+# CHECK-DEFAULT: - Type: EXPORT
+# CHECK-DEFAULT: - Name: __table_base
+# CHECK-DEFAULT-NEXT: Kind: GLOBAL
+# CHECK-DEFAULT-NEXT: Index: 1
+
+# CHECK-100: - Type: TABLE
+# CHECK-100-NEXT: Tables:
+# CHECK-100-NEXT: - Index: 0
+# CHECK-100-NEXT: ElemType: FUNCREF
+# CHECK-100-NEXT: Limits:
+# CHECK-100-NEXT: Flags: [ HAS_MAX ]
+# CHECK-100-NEXT: Minimum: 0x65
+# CHECK-100-NEXT: Maximum: 0x65
+
+# CHECK-100: - Type: GLOBAL
+# CHECK-100-NEXT: Globals:
+# CHECK-100-NEXT: - Index: 0
+# CHECK-100-NEXT: Type: I32
+# CHECK-100-NEXT: Mutable: true
+# CHECK-100-NEXT: InitExpr:
+# CHECK-100-NEXT: Opcode: I32_CONST
+# CHECK-100-NEXT: Value: 66560
+# CHECK-100-NEXT: - Index: 1
+# CHECK-100-NEXT: Type: I32
+# CHECK-100-NEXT: Mutable: false
+# CHECK-100-NEXT: InitExpr:
+# CHECK-100-NEXT: Opcode: I32_CONST
+# CHECK-100-NEXT: Value: 100
+
+# CHECK-100: - Type: EXPORT
+# CHECK-100: - Name: __table_base
+# CHECK-100-NEXT: Kind: GLOBAL
+# CHECK-100-NEXT: Index: 1
diff --git a/wasm/Driver.cpp b/wasm/Driver.cpp
index 84304881f5ca34e..c2f5f0185781f36 100644
--- a/wasm/Driver.cpp
+++ b/wasm/Driver.cpp
@@ -502,6 +502,7 @@ static void readConfigs(opt::InputArgList &args) {
config->initialMemory = args::getInteger(args, OPT_initial_memory, 0);
config->globalBase = args::getInteger(args, OPT_global_base, 0);
+ config->tableBase = args::getInteger(args, OPT_table_base, 0);
config->maxMemory = args::getInteger(args, OPT_max_memory, 0);
config->zStackSize =
args::getZOptionValue(args, OPT_z, "stack-size", WasmPageSize);
@@ -573,6 +574,17 @@ static void setConfigs() {
if (config->exportTable)
error("-shared/-pie is incompatible with --export-table");
config->importTable = true;
+ } else {
+ // Default table base. Defaults to 1, reserving 0 for the NULL function
+ // pointer.
+ if (!config->tableBase)
+ config->tableBase = 1;
+ // The default offset for static/global data, for when --global-base is
+ // not specified on the command line. The precise value of 1024 is
+ // somewhat arbitrary, and pre-dates wasm-ld (Its the value that
+ // emscripten used prior to wasm-ld).
+ if (!config->globalBase && !config->relocatable && !config->stackFirst)
+ config->globalBase = 1024;
}
if (config->relocatable) {
@@ -666,8 +678,11 @@ static void checkOptions(opt::InputArgList &args) {
warn("-Bsymbolic is only meaningful when combined with -shared");
}
- if (config->globalBase && config->isPic) {
- error("--global-base may not be used with -shared/-pie");
+ if (config->isPic) {
+ if (config->globalBase)
+ error("--global-base may not be used with -shared/-pie");
+ if (config->tableBase)
+ error("--table-base may not be used with -shared/-pie");
}
}
diff --git a/wasm/Options.td b/wasm/Options.td
index 50417d2928e0a34..bb764396bf4df14 100644
--- a/wasm/Options.td
+++ b/wasm/Options.td
@@ -191,7 +191,7 @@ def growable_table: FF<"growable-table">,
HelpText<"Remove maximum size from function table, allowing table to grow">;
def global_base: JJ<"global-base=">,
- HelpText<"Where to start to place global data">;
+ HelpText<"Memory offset at which to place global data (Defaults to 1024)">;
def import_memory: FF<"import-memory">,
HelpText<"Import the module's memory from the default module of \"env\" with the name \"memory\".">;
@@ -224,6 +224,9 @@ def no_entry: FF<"no-entry">,
def stack_first: FF<"stack-first">,
HelpText<"Place stack at start of linear memory rather than after data">;
+def table_base: JJ<"table-base=">,
+ HelpText<"Table offset at which to place address taken functions (Defaults to 1)">;
+
defm whole_archive: B<"whole-archive",
"Force load of all members in a static library",
"Do not force load of all members in a static library (default)">;
diff --git a/wasm/Writer.cpp b/wasm/Writer.cpp
index f25d358dc5bae6f..0576bf2907e49c4 100644
--- a/wasm/Writer.cpp
+++ b/wasm/Writer.cpp
@@ -358,13 +358,6 @@ void Writer::layoutMemory() {
memoryPtr = config->globalBase;
}
} else {
- if (!config->globalBase && !config->relocatable && !config->isPic) {
- // The default offset for static/global data, for when --global-base is
- // not specified on the command line. The precise value of 1024 is
- // somewhat arbitrary, and pre-dates wasm-ld (Its the value that
- // emscripten used prior to wasm-ld).
- config->globalBase = 1024;
- }
memoryPtr = config->globalBase;
}
@@ -1685,7 +1678,6 @@ void Writer::run() {
// For PIC code the table base is assigned dynamically by the loader.
// For non-PIC, we start at 1 so that accessing table index 0 always traps.
if (!config->isPic) {
- config->tableBase = 1;
if (WasmSym::definedTableBase)
WasmSym::definedTableBase->setVA(config->tableBase);
if (WasmSym::definedTableBase32)

View File

@@ -26,6 +26,7 @@ stdenv.mkDerivation rec {
patches = [
./gnu-install-dirs.patch
./add-table-base.patch
];
nativeBuildInputs = [ cmake ninja ];

View File

@@ -1,6 +1,6 @@
import ./generic.nix {
major_version = "5";
minor_version = "1";
patch_version = "0";
sha256 = "sha256-bOjbOTqvwmTlr3McaPvrIJIKtq6E1b+TURllt0IzUas=";
patch_version = "1";
sha256 = "sha256-jX6Yv9o76UBgK3o53PkSotL96reR7UDmKgmkzWfd7vE=";
}