-
Notifications
You must be signed in to change notification settings - Fork 32
Home
cd
git clone https://github.com/MaskRay/Config
cd Config
./deploy.bash
sudo apt install libjansson-dev
=> --with-json
(default) => native json-parse-string
apt install libgif-dev libgtk-3-dev libgnutls28-dev libjpeg-dev libxpm-dev texinfo
mkdir -p ~/Dev/Emacs
cd ~/Dev/Emacs
git clone https://github.com/emacs-mirror/emacs
cd emacs
./autogen.sh
mkdir Release; cd Release
../configure --with-modules --with-xml2 CFLAGS='-O3 -march=native' LDFLAGS=-fuse-ld=lld
make -j
git clone --depth=1 --branch=develop https://github.com/hlissner/doom-emacs ~/.emacs.d
apt install libtool-bin pkg-config
git clone --depth=1 https://github.com/neovim/neovim ~/projects/neovim
cd ~/projects/neovim
make CMAKE_EXTRA_FLAGS=-DCMAKE_INSTALL_PREFIX=$HOME/.local
make install
If you compile with local clang+llvm, ninja clangFormat clangIndex clangTooling
should be sufficient.
# link against local clang to leverage latest features
LLVM=$(realpath ~/llvm)
cmake -H. -BRelease -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=$HOME/Stable/bin/clang++ -DCMAKE_EXE_LINKER_FLAGS='-fuse-ld=lld' -DCMAKE_PREFIX_PATH="$LLVM/Release;$LLVM/Release/tools/clang;$LLVM/llvm;$LLVM/clang"
# Debug build with local clang
LLVM=$(realpath ~/llvm)
cmake -H. -BDebug -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=$HOME/Stable/bin/clang++ -DCMAKE_CXX_FLAGS=-gsplit-dwarf=single -DCMAKE_EXE_LINKER_FLAGS='-fuse-ld=lld -Wl,--gdb-index' -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DCMAKE_PREFIX_PATH="$LLVM/Release;$LLVM/Release/tools/clang;$LLVM/llvm;$LLVM/clang"
# Debug build with local Debug clang
cmake -H. -BDebugClang -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=$HOME/Stable/bin/clang++ -DCMAKE_CXX_FLAGS=-gsplit-dwarf=single -DCMAKE_EXE_LINKER_FLAGS='-fuse-ld=lld -Wl,--gdb-index' -DCMAKE_PREFIX_PATH="$LLVM/Debug;$LLVM/Debug/tools/clang;$LLVM/llvm;$LLVM/clang"
# Debug+ASAN build with local clang
LLVM=$(realpath ~/llvm)
cmake -H. -BASAN -G Ninja -DASAN=on -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=$LLVM/Release/bin/clang++ -DCMAKE_CXX_LINK_FLAGS=-fuse-ld=lld -DCMAKE_PREFIX_PATH="$LLVM/Release;$LLVM/Release/tools/clang;$LLVM/llvm;$LLVM/clang"
# Debug build with bundled clang+llvm downloaded from releases.llvm.org
cmake -H. -BDebug -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_LINK_FLAGS='-fuse-ld=lld -Wl,-export-dynamic'
- Faster linking:
-gsplit-dwarf=single
,-fuse-ld=lld
- Function name in symbolizer:
-DCMAKE_CXX_LINK_FLAGS=-Wl,-export-dynamic
mkdir Debug; cd Debug
../configure --prefix=/tmp/opt/glibc CFLAGS='-g3 -O2'
wget 'https://git.archlinux.org/svntogit/packages.git/plain/trunk/config?h=packages/linux' -O .config
yes '' | make config
bear make -j bzImage modules
curl -s https://raw.githubusercontent.com/chromium/chromium/master/tools/clang/scripts/update.py | python - --output-dir=~/Stable
cd /usr/local/bin
sudo ln -s ~/Stable/bin/{clang,clang++,lld} .
sudo ln -s lld ld
git config blame.ignoreRevsFile .git-blame-ignore-revs
git config feature.manyFiles true
For workstation:
LLVM_COMMON=(-GNinja -DCMAKE_CXX_COMPILER=$HOME/Stable/bin/clang++ -DCMAKE_C_COMPILER=$HOME/Stable/bin/clang -DBUILD_SHARED_LIBS=On -DLLVM_APPEND_VC_REV=OFF -DLLVM_ENABLE_BINDINGS=OFF -DLLVM_ENABLE_LLD=On -DLLVM_INCLUDE_GO_TESTS=OFF -DLLVM_INCLUDE_DOCS=OFF -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_OPTIMIZED_TABLEGEN=On -DLLVM_TARGETS_TO_BUILD='ARM;AArch64;PowerPC;X86;RISCV' -DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra;lldb;lld;compiler-rt;libcxx;libcxxabi')
# Release & Debug
cmake -Hllvm -B/tmp/RelA ${LLVM_COMMON} -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=Off -DLLVM_ENABLE_ASSERTIONS=on -DLLVM_BINUTILS_INCDIR=$HOME/Dev/binutils-gdb/include
cmake -Hllvm -B/tmp/Debug ${LLVM_COMMON} -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXE_LINKER_FLAGS=-Wl,--gdb-index -DCMAKE_SHARED_LINKER_FLAGS=-Wl,--gdb-index -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DLLVM_USE_SPLIT_DWARF=On -DLLVM_BINUTILS_INCDIR=$HOME/Dev/binutils-gdb/include -DLLVM_USE_SPLIT_DWARF=on -DLLVM_OPTIMIZE_SANITIZED_BUILDS=Off
# Debug asan
cmake -Hllvm -Bout/asan ${LLVM_COMMON} -DCMAKE_BUILD_TYPE=Debug -DLLVM_USE_SPLIT_DWARF=On -DLLVM_USE_SANITIZER=Address
# Debug msan
libcxx_out=$PWD/out/msan-libcxx
cmake -Hllvm -B$libcxx_out ${LLVM_COMMON} -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS='libcxx;libcxxabi' -DLLVM_USE_SANITIZER=Memory
ninja -C $libcxx_out cxx cxxabi
sanitizer_ldflags="-Wl,--rpath=$libcxx_out/lib -L$libcxx_out/lib -lc++abi"
sanitizer_cflags="-nostdinc++ -isystem$libcxx_out/include -isystem$libcxx_out/include/c++/v1"
# See http://llvm.org/bugs/show_bug.cgi?id=19071, http://www.cmake.org/Bug/view.php?id=15264
sanitizer_cflags="$sanitizer_cflags $sanitizer_ldflags -fsanitize=memory -w"
cmake -Hllvm -Bout/msan ${LLVM_COMMON} -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=$sanitizer_cflags -DCMAKE_CXX_FLAGS=$sanitizer_cflags -DCMAKE_EXE_LINKER_FLAGS=$sanitizer_ldflags -DCMAKE_SHARED_LINKER_FLAGS=$sanitizer_ldflags -DLLVM_ENABLE_LIBCXX=On -DLLVM_USE_SPLIT_DWARF=On -DLLVM_USE_SANITIZER=Memory
-
-DBUILD_SHARED_LIBS
for buildinglibLLVM*.so
libclang*.so
instead oflibLLVM*.a
libclang*.a
-
-DLLVM_ENABLE_LLD
for faster linking -
-DLLVM_USE_SPLIT_DWARF
faster linking forDebug
RelWithDebInfo
. Don't use it forRelease
. -
-DLLVM_PARALLEL_LINK_JOBS=1
if memory is small -
-Wl,--gdb-index
for speeding up gdb
arm-linux-gnueabihf cross toolchain
cmake -GNinja -Hllvm -B/tmp/out/arm -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=/usr/bin/arm-linux-gnueabihf-g++-9 -DCMAKE_C_COMPILER=/usr/bin/arm-linux-gnueabihf-gcc-9 -DCMAKE_CROSSCOMPILING=on -DCMAKE_INSTALL_PREFIX=/tmp/opt/arm -DLLVM_TARGETS_TO_BUILD=ARM -DLLVM_DEFAULT_TARGET_TRIPLE=arm-linux-gnueabihf -DLLVM_TARGET_ARCH=ARM -DLLVM_TABLEGEN=/tmp/RelA/bin/llvm-tblgen -DCLANG_TABLEGEN=/tmp/RelA/bin/clang-tblgen -DLLVM_ENABLE_PROJECTS='clang;libcxx;libcxxabi;compiler-rt;libunwind'
from=remote
cd ~/llvm
# Make sure timestamps of source files match those of remote's
rsync -tr --existing -f '+ /llvm' -f '+ /clang' -f '+ /clang-tools-extra' -f '+ /lld' -f '+ /lldb' -f '+ /compiler-rt' -f '+ /libcxx' -f '+ /libcxxabi' -f '+ /libunwind' -f '+ /libc' -f '- /*' -f '+ */' -f '+ *.cpp' -f '+ *.h' -f '+ *.def' -f '+ *.inc' -f '- *' ${from}:llvm/ ./
# Make sure generated source files match those of remote's
rsync -a -f '+ */' -f '+ *.def' -f '+ *.inc' -f '+ *.h' -f '+ compile_commands.json' -f '- *' ${from}:llvm/Debug/ Debug/
# Copy ccls cache
mkdir -p .ccls-cache
rsync -a ${from}:llvm/.ccls-cache/@home@ray@llvm/ .ccls-cache/@home@ray@llvm/
export LLVM_COMPILER_PATH=~/llvm/Release/bin
cmake -GNinja -H. -BGLLVM -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gclang -DCMAKE_CXX_COMPILER=gclang++ -DCMAKE_C_FLAGS='-Xclang -disable-llvm-passes' -DCMAKE_CXX_FLAGS='-Xclang -disable-llvm-passes'
https://sourceware.org/git/?p=binutils-gdb.git;a=summary
apt install bison dejagnu flex texinfo
binutils + ld + gas + gdb + gold
mkdir Debug; cd Debug
../configure --enable-binutils --enable-gas --enable-gdb --enable-gold --disable-gprof --enable-ld --enable-plugins --without-guile --prefix=~/.local/stow/gdb CFLAGS='-O0 -g' CXXFLAGS='-O0 -g'
bear make -j
mkdir DebugAll; cd DebugAll
../configure --enable-targets=all CFLAGS='-g3 -O0' --disable-gdb
## riscv
mkdir riscv; cd riscv
../configure --target riscv --enable-binutils --enable-gas --enable-gdb --enable-gold --disable-gprof --enable-ld --enable-plugins --without-guile CFLAGS='-O0 -g' CXXFLAGS='-O0 -g'
mkdir Debug; cd Debug
../configure --enable-languages=c CFLAGS='-O0 -g' --disable-multilib --disable-libsanitizer
# apt install binutils-riscv64-linux-gnu
# (cd /usr/riscv64-linux-gnu/usr; sudo ln -s ../include; sudo ln -s .. riscv64-linux-gnu)
mkdir out/riscv64; cd out/riscv64
../../configure --prefix=/tmp/opt/gcc-riscv64 --with-sysroot=/usr/riscv64-linux-gnu --target=riscv64-linux-gnu --enable-languages=c,c++ --disable-multilib --disable-libsanitizer --disable-bootstrap CFLAGS='-O0 -g'
# make install
# /tmp/opt/gcc-riscv64/bin/riscv64-linux-gnu-g++ -B /usr/riscv64-linux-gnu/bin a.cc
https://github.com/JuliaLang/julia
make -j O=out configure # edit out/Make.user
bear make -j O=out debug
make -j O=out release
git clone --recursive https://github.com/ldc-developers/ldc.git
cmake -H. -BDebug9 -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=$HOME/Stable/bin/clang -DCMAKE_CXX_COMPILER=$HOME/Stable/bin/clang++ -DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=lld -DD_COMPILER=$HOME/dlang/ldc-1.18.0/bin/ldmd2 -DCMAKE_CXX_STANDARD=14 -DLLVM_ROOT_DIR=$HOME/ccls/build/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-16.04
mkdir debug; cd debug
../configure --enable-optimize=no --enable-debug --prefix=~/.local/stow/musl CFLAGS=-fuse-ld=lld
# CFLAGS=-mlong-double-64 on powerpc64le
# ~/Dev/Bin/musl-gcc.specs
*srcdir:
/home/ray/musl
*bindir:
/home/ray/musl/Debug
%rename cpp_options old_cpp_options
*cpp_options:
-nostdinc -isystem %(srcdir)/arch/x86_64 -isystem %(srcdir)/arch/generic -isystem %(srcdir)/include -isystem %(bindir)/obj/include -isystem include%s %(old_cpp_options)
*cc1:
%(cc1_cpu) -isystem %(srcdir)/arch/x86_64 -isystem %(srcdir)/arch/generic -isystem %(srcdir)/include -isystem %(bindir)/obj/include -nostdinc -isystem include%s
# arm-linux-musleabihf
../configure AR=~/llvm/Release/bin/llvm-ar RANLIB=: CC="$HOME/llvm/Release/bin/clang -target arm-linux-musleabihf" LDFLAGS=-fuse-ld=lld
# powerpc gcc
../configure CROSS_COMPILE=powerpc-linux-gnu- LDFLAGS=-fuse-ld=gold CFLAGS=-mlong-double-64
# riscv64
../configure --target riscv64 CROSS_COMPILE=/home/maskray/.local/opt/riscv-none-gcc/8.2.0-2.2-20190521-0004/bin/riscv-none-embed- CFLAGS='-march=rv64imafdc -mabi=lp64d'
git clone git://repo.or.cz/libc-test.git
cd libc-test
# config.mak
CFLAGS += -specs ~/Dev/Bin/musl-gcc.specs
LDFLAGS += -specs ~/Dev/Bin/musl-gcc.specs
# config.mak.def minus glibc
(cd test; ln -s ~/Dev/Bin/radare2-testbins bins)
## ASAN
CFLAGS='-fsanitize=address,undefined -gsplit-dwarf' LDFLAGS='-fuse-ld=lld' meson . ASAN --buildtype=debug --prefix ~/.config/radare2/ASAN -Db_lundef=false
## Debug
CFLAGS=-gsplit-dwarf meson . Debug --buildtype=debug --prefix ~/.config/radare2/Debug
## Release
meson . Release --buildtype=release --prefix ~/.config/radare2/Release
mkdir -p ~/.local/share/radare2
cd ~/.local/share/radare2
ln -s ~/Dev/radare2/libr/cons/d cons
ln -s ~/Dev/radare2/Release/libr/anal/d anal
ln -s ~/Dev/radare2/Release/libr/asm/d asm
ln -s ~/Dev/radare2/Release/libr/bin/d bin
ln -s ~/Dev/radare2/Release/libr/flag/d flag
ln -s ~/Dev/radare2/Release/libr/syscall/d syscall
radare2-regressions:
export PKG_CONFIG_PATH=~/.config/radare2/Release/lib/x86_64-linux-gnu/pkgconfig
radare2-extras:
cd ~/Dev && git clone https://github.com/radareorg/radare2-extras
# R2_CFLAGS for r_asm.h
# R2PM_PREFIX for correct -Wl,-R
PKG_CONFIG_PATH=~/Dev/Bin/keystone/Release R2_CFLAGS=-I$HOME/.config/radare2/Release/include/libr R2PM_PREFIX=~/Dev/Bin/keystone/Release/llvm make -C keystone
mkdir -p ~/.local/share/radare2/plugins && cd ~/.local/share/radare2/plugins
for i in ~/Dev/radare2-extras/keystone/*.so; do ln -s $i; done
keystone:
cd ~/Dev/Bin
git clone https://github.com/keystone-engine/keystone
cd keystone
mkdir Release; cd Release
../make-lib.sh
# Modify Release/keystone.pc
# Release/llvm/lib/libkeystone.so
sed -i 's,^includedir=.*,includedir=/home/maskray/Dev/Bin/keystone/include,' keystone.pc
sed -i 's,^libdir=.*,includedir=/home/maskray/Dev/Bin/keystone/Release/llvm/lib,' keystone.pc
git clone https://github.com/WebAssembly/wabt
cmake -G Ninja -H. -Bout/clang/Release -DCMAKE_C_COMPILER=~/llvm/bin/clang -DCMAKE_CXX_COMPILER=~/llvm/bin/clang++ -DCMAKE_BUILD_TYPE=Release
cmake --build out/clang/Release
apt install clang-8 libclang-8-dev
bcc
git clone https://github.com/iovisor/bcc; cd bcc
cmake -GNinja -H. -BRelease -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=$HOME/llvm/bin/clang++ -DCMAKE_C_COMPILER=$HOME/llvm/bin/clang -DCMAKE_INSTALL_PREFIX=~/.local/stow/bcc -DLLVM_DIR=/usr/loca/llvm-7/cmake
ninja -C Release install
bpftrace
git clone https://github.com/iovisor/bpftrace; cd bpftrace
cmake -H. -BDebug -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=~/llvm/bin/clang -DCMAKE_CXX_COMPILER=~/llvm/bin/clang++ -DCMAKE_EXPORT_COMPILE_COMMANDS=on -DLIBBCC_INCLUDE_DIRS=$HOME/.local/stow/bcc/include/bcc -DLIBBCC_LIBRARIES=~/.local/stow/bcc/lib/libbcc.so -DLLVM_DIR=/usr/lib/llvm-8/cmake
cmake -H. -BRelease -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=~/llvm/bin/clang -DCMAKE_CXX_COMPILER=~/llvm/bin/clang++ -DLIBBCC_INCLUDE_DIRS=$HOME/.local/stow/bcc/include/bcc -DLIBBCC_LIBRARIES=~/.local/stow/bcc/lib/libbcc.so -DLLVM_DIR=/usr/lib/llvm-8/cmake
qemu-system-aarch64 -M virt -cpu cortex-a57 -nographic -smp 1 -m 2048 -kernel vmlinuz-vanilla -initrd initramfs-vanilla -append "console=ttyAMA0 ip=dhcp alpine_repo=http://dl-cdn.alpinelinux.org/alpine/edge/main/"
git clone https://github.com/ruby/ruby; cd ruby
autoreconf
mkdir Debug; cd Debug
../configure --prefix=/tmp/opt CFLAGS='-gsplit-dwarf=single' CC=~/Stable/bin/clang
bear make -j install-doc
cd ..; ln -s Debug/compile_commands.json
sudo apt install libx11-dev libxss-dev
stack install xmonad xmonad-contrib xmobar