Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
set -euo pipefail
apt update
apt install -y automake build-essential curl git gnupg libffi-dev libncurses-dev libgmp-dev python3 libdw-dev
curl -f -L --retry 5 https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor -o /usr/share/keyrings/llvm-snapshot.gpg
echo "deb [signed-by=/usr/share/keyrings/llvm-snapshot.gpg] https://apt.llvm.org/bullseye llvm-toolchain-bullseye main" >> /etc/apt/sources.list.d/llvm-toolchain.list
echo "deb [signed-by=/usr/share/keyrings/llvm-snapshot.gpg] https://apt.llvm.org/bullseye llvm-toolchain-bullseye-18 main" >> /etc/apt/sources.list.d/llvm-toolchain.list

How to instrument ghc with ghc-debug

Assuming you already know what ghc-debug is about, and want to use it to debug the ghc program itself.

Prepare a ghc-debug checkout

A recent ghc-debug checkout is required, since it contains important fixes not release on Hackage yet.

Apply the following patch:

Wrong exit code for T24171()(expected 0 , actual 2 )
Stderr run ( T24171 ):
main: internal error: LDV_recordDead: Failed to find counter for closure 0x42004fd028
(GHC version 9.9.20240111 for x86_64_unknown_linux)
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
gmake[1]: *** [Makefile:8: build_and_run] Aborted (core dumped)
gmake: *** [Makefile:5: clean_build_and_run] Error 2
*** unexpected failure for T24171(normal)
@TerrorJack
TerrorJack / normcore-llm.md
Created August 30, 2023 14:42 — forked from veekaybee/normcore-llm.md
Normcore LLM Reads
#!/usr/bin/env bash
set -euo pipefail
export CC="ccache clang"
export CXX="ccache clang++"
export AR=llvm-ar
./configure --enable-lto --experimental-enable-pointer-compression --fully-static --ninja
ninja -C out/Release -v
#include <regex.h>
#include <stdlib.h>
int foo() {
const char *target_string = "hello wasm";
const char *pattern = "wasm";
regex_t regex_compiled;
int return_code;
cmake -G Ninja \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DLLVM_CCACHE_BUILD=ON \
-DLLVM_ENABLE_TERMINFO=OFF \
-DLLVM_ENABLE_ZLIB=OFF \
-DLLVM_ENABLE_ZSTD=OFF \
-DLLVM_HAVE_LIBXAR=OFF \
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [{
"name": "clang",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/build/install/opt/wasi-sdk/bin/clang",
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.haskell-nix.url = "github:input-output-hk/haskell.nix";
inputs.haskell-nix.inputs.nixpkgs-unstable.follows = "nixpkgs";
outputs = { self, haskell-nix, nixpkgs, }:
haskell-nix.inputs.flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
let
pkgs = import nixpkgs {
inherit system;
for(let e of document.getElementsByClassName("inspector_torrent_file_list_entryodd")) {
if (e.children[2].innerText.includes("padding_file") && e.children[0].checked) {
e.children[0].click();
}
}