Skip to content

Instantly share code, notes, and snippets.

@planetis-m
Last active October 4, 2023 23:15
Show Gist options
  • Save planetis-m/68b189f2c137e56e5157e41e97a9f1e5 to your computer and use it in GitHub Desktop.
Save planetis-m/68b189f2c137e56e5157e41e97a9f1e5 to your computer and use it in GitHub Desktop.
My build commands

Debug

nim c --cc:clang --mm:orc --panics:on --threads:on --threadanalysis:off --tlsEmulation:off -l:"-fuse-ld=mold" %f

Release

nim c --cc:clang --mm:orc --panics:on --threads:on --threadanalysis:off --tlsEmulation:off -l:"-fuse-ld=mold" -d:release %f

Performance

nim c --cc:clang --mm:orc --panics:on --threads:on --threadanalysis:off --tlsEmulation:off -t:"-march=native -ffast-math" -l:"-flto" -d:danger %f

ASan

nim c --cc:clang --mm:arc --panics:on --threads:on --threadanalysis:off --tlsEmulation:off -d:useMalloc -t:"-fsanitize=address,undefined" -l:"-fsanitize=address,undefined" -d:nosignalhandler -d:release -g %f

LibFuzzer

nim c --cc:clang --mm:orc --panics:on -d:useMalloc -t:"-fsanitize=fuzzer,address,undefined" -l:"-fsanitize=fuzzer,address,undefined" -d:nosignalhandler --nomain:on -d:release -g %f

TSan

nim c --cc:clang --mm:arc --panics:on --threads:on --threadanalysis:off --tlsEmulation:off -d:useMalloc -t:"-fsanitize=thread" -l:"-fsanitize=thread" -d:nosignalhandler -d:release -g %f

Disassembler

objdump --no-show-raw-insn -drwlS -M intel %n

Nimpretty

nimpretty --indent:2 --maxLineLen:100 %f

Perf

perf record -e cycles:pp --call-graph dwarf %f
perf annotate -M intel

Rebuild toolchain

git pull
./koch boot -d:release --mm:markandsweep --panics:on --exceptions:goto
./koch toolsNoExternal tools -d:release --mm:markandsweep --panics:on --exceptions:goto
@planetis-m
Copy link
Author

Converted into VS Code tasks:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "LibFuzzer Nim",
            "type": "shell",
            "command": "nim",
            "args": [
                "c",
                "--cc:clang",
                "--mm:orc",
                "--panics:on",
                "-d:useMalloc",
                "-t:\"-fsanitize=fuzzer,address,undefined\"",
                "-l:\"-fsanitize=fuzzer,address,undefined\"",
                "-d:nosignalhandler",
                "--nomain:on",
                "-d:release",
                "-g",
                "${file}"
            ]
        },
        {
            "label": "ASan Nim",
            "type": "shell",
            "command": "nim",
            "args": [
                "c",
                "--mm:orc",
                "--panics:on",
                "--threads:on",
                "--threadanalysis:off",
                "--tlsEmulation:off",
                "-d:useMalloc",
                "-t:\"-fsanitize=address,undefined\"",
                "-l:\"-fsanitize=address,undefined\"",
                "-d:nosignalhandler",
                "-d:release",
                "-g",
                "${file}"
            ]
        },
        {
            "label": "Nim release",
            "type": "shell",
            "command": "nim",
            "args": [
                "c",
                "--mm:orc",
                "--panics:on",
                "--threads:on",
                "--threadanalysis:off",
                "--tlsEmulation:off",
                "-d:release",
                "${file}"
            ]
        },
        {
            "label": "Nim debug",
            "type": "shell",
            "command": "nim",
            "args": [
                "c",
                "--mm:orc",
                "--panics:on",
                "--threads:on",
                "--threadanalysis:off",
                "--tlsEmulation:off",
                "${file}"
            ]
        },
        {
            "label": "Nim danger",
            "type": "shell",
            "command": "nim",
            "args": [
                "c",
                "--mm:orc",
                "--panics:on",
                "--threads:on",
                "--threadanalysis:off",
                "--tlsEmulation:off",
                "-t:\"-march=native -ffast-math\"",
                "-l:\"-fuse-ld=mold -flto\"",
                "-d:danger",
                "${file}"
            ]
        },
        {
            "label": "nimpretty",
            "type": "shell",
            "command": "nimpretty",
            "args": [
                "--indent:2",
                "--maxLineLen:100",
                "${file}"
            ]
        }
    ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment