Update the readme file for the new builder sub commands
This commit is contained in:
parent
71aac7ec33
commit
42ec574484
121
README.org
121
README.org
|
@ -1,73 +1,91 @@
|
|||
* Serene lang
|
||||
Build Status: [[https://drone.devheroes.codes/api/badges/Serene/Serene/status.svg]]
|
||||
Build Status: [[https://ci.devheroes.codes/api/badges/Serene/Serene/status.svg]]
|
||||
|
||||
|
||||
** Fetching the source code
|
||||
Serene comes with the build time dependencies as git submodules that set to the correct
|
||||
version (Commit SHA). They live in the ~deps~ directory. So, after cloning Serene's repository,
|
||||
you need to initialize the submodules as follows:
|
||||
|
||||
#+BEGIN_SRC bash
|
||||
git clone git@git.devherose.codes:serene/serene.git
|
||||
cd serene
|
||||
git submodule init
|
||||
git submodule update
|
||||
#+END_SRC
|
||||
|
||||
Obviously, you need to build the dependencies before you can build *Serene*. But if you are
|
||||
running GNU/Linux, the ~builder~ script can do that for you (Instructions below). Currently,
|
||||
the ~builder~ script can take care of dependencies only on GNU/Linux, but contributions are
|
||||
welcome to port it to other platforms as well.
|
||||
|
||||
** Dependencies
|
||||
Here is the list of dependencies that need to be present:
|
||||
|
||||
- LLVM
|
||||
For exact version, check out the submodule under =deps/llvm-project=
|
||||
- CMake ~>= 3.19~
|
||||
- Ninja
|
||||
- include-what-you-use (Checkout the corresponding submodule)
|
||||
- doxygen (If you want to build the docs as well)
|
||||
- Valgrind (Optional and only for development)
|
||||
- CCache (If you want faster builds, specially with the LLVM)
|
||||
- Boehm GC v8.2.0
|
||||
Check out the submodule under =deps/bdwgc=. If you're building this library yourself,
|
||||
make sure to build in statically with ~-fPIC~ flag.
|
||||
|
||||
** Setup development environment
|
||||
Setup the githook and install dependencies using the following commands:
|
||||
Before, you have to set up the necessary git hooks as follows:
|
||||
|
||||
#+BEGIN_SRC bash
|
||||
./builder setup
|
||||
#+END_SRC
|
||||
|
||||
*** Dependencies
|
||||
You would need the following dependencies to start get started with *Serene* development
|
||||
** Build and installing dependencies (Linux only)
|
||||
The ~builder~ script can build the necessary dependencies for you. Just make sure to pull down
|
||||
all the dependencies as instructed above and follow:
|
||||
|
||||
- LLVM (LLVM Instructions coming up.)
|
||||
- cmake
|
||||
- ninja
|
||||
- doxygen (If you want to build the docs as well)
|
||||
- Valgrind
|
||||
- CCache (If you want faster builds specially with the LLVM)
|
||||
- Boehm GC v8.2.0 (has to be built statically and with ~-fPIC~)
|
||||
#+BEGIN_SRC bash
|
||||
|
||||
** LLVM Installation
|
||||
# Download prebuilt dependencies instead of building from source (X86_64 only)
|
||||
|
||||
*Important Note*: We're trying to keep Serene up to date with the LLVM release cycle till we get
|
||||
to our first release. So we use the development version of the LLVM. Currently we are using
|
||||
=7240436c94bd02762a723a2e3551528d16c8efdb= commit as our reference.
|
||||
# Try to pull a prebuilt package for the toolchain (including llvm libraries)
|
||||
./builder deps pull toolchain
|
||||
# Try to pull a prebuilt package for BDWGC
|
||||
./builder deps pull bdwgc
|
||||
|
||||
MLIR is a part of the [[https://llvm.org][LLVM]] project and in order to build it we need to build the LLVM itself as well.
|
||||
Here is a quick guide to build the latest version of the LLVM and MLIR.
|
||||
# Or build from source
|
||||
./builder deps build toolchain
|
||||
./builder deps build bdwgc
|
||||
#+END_SRC
|
||||
|
||||
#+BEGIN_SRC bash
|
||||
## YES we're using the development version of MLIR
|
||||
git clone https://github.com/llvm/llvm-project.git
|
||||
After building or pulling the dependencies, you'll have all of them under =~/.serene/env/=.
|
||||
All you need to do is to activate the environmet and build Serene itself.
|
||||
|
||||
mkdir llvm-project/build
|
||||
cd llvm-project/build
|
||||
In order to activate the environment you can just do ~source ./activate~ in the root of the
|
||||
source tree to activate the toolchain and the right set up dependencies.
|
||||
|
||||
cmake -G Ninja ../llvm \
|
||||
-DCMAKE_INSTALL_PREFIX=/your/target/path \
|
||||
-DLLVM_PARALLEL_COMPILE_JOBS=7 \
|
||||
-DLLVM_PARALLEL_LINK_JOBS=1 \
|
||||
-DLLVM_BUILD_EXAMPLES=ON \
|
||||
-DLLVM_TARGETS_TO_BUILD="X86" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DLLVM_EXTERNAL_PROJECTS=iwyu \ # Only if you want to enable the 'Include what you use' tool
|
||||
-DLLVM_EXTERNAL_IWYU_SOURCE_DIR=/path/to/iwyu \
|
||||
-DLLVM_ENABLE_ASSERTIONS=ON \
|
||||
-DLLVM_CCACHE_BUILD=ON \
|
||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
|
||||
-DLLVM_ENABLE_PROJECTS='clang;lldb;lld;mlir;clang-tools-extra;compiler-rt;libcxx;libcxxabi;libunwind' \
|
||||
-DCMAKE_C_COMPILER=clang \ # If you have clang installed already
|
||||
-DCMAKE_CXX_COMPILER=clang++ \ # If you have clang installed already
|
||||
-DLLVM_ENABLE_LLD=ON
|
||||
|
||||
cmake --build .
|
||||
** Build and installing dependencies (Other platforms)
|
||||
At the moment the ~builder~ script does not support any platform beside GNU/Linux. So, you
|
||||
need to build the dependencies yourself and make them available to the builder.
|
||||
|
||||
cmake --build . --target check-mlir
|
||||
By the way, If you are interested, you can just hack the builder script and accommodate your
|
||||
platform and contribute your changes to the project.
|
||||
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/your/target/location -P cmake_install.cmake
|
||||
#+END_SRC
|
||||
In order to build the dependencies in your platform, you can use the =./scripts/deps.sh= as
|
||||
a reference.
|
||||
|
||||
You need to have =clang= and =lld= installed to compile the LLVM with the above command. Also if you
|
||||
are not using =ccache= just remove the option related to it from the above command.
|
||||
* How to build
|
||||
In order to build for development (Debug mode) just use =./builder build= to setup the build system,
|
||||
and build the project once, and then you can just use =./builder compile= to build the changed files
|
||||
only.
|
||||
|
||||
*** Emacs
|
||||
If you're using Emacs as your development environment just install =clangd= and =lsp=.
|
||||
Check out the =builder= script for more subcommands and details.
|
||||
|
||||
** Heads up for devs
|
||||
** Head's up for devs
|
||||
While you're working on *Serene* be mindful of:
|
||||
- In =DEBUG= mode we dynamically link against =libsan= due to the fact that we build the =libserene=
|
||||
- In =DEBUG= mode, we dynamically link against =libsan= due to the fact that we build the =libserene=
|
||||
as a shared lib by default. This means we need to =LD_PRELOAD= the =libclang_rt= before we run
|
||||
any executable. If you're using the =builder= script you're all set otherwise you can run an
|
||||
executable like:
|
||||
|
@ -82,12 +100,6 @@ Both are in the ~devtools~ directory and in order to build them all you need to
|
|||
~-DSERENE_ENABLE_DEVTOOLS=ON~ parameter with cmake for example ~./builder build -DSERENE_ENABLE_DEVTOOLS=ON~
|
||||
will do the job for you.
|
||||
|
||||
* How to build
|
||||
In order to build for development (Debug mode) just use =./builder build= to setup the build and build
|
||||
the project once and then you can just use =./builder compile= to build the changed files only.
|
||||
|
||||
Check out the =builder= script for more subcommands and details.
|
||||
|
||||
* How to Debug
|
||||
Since we're using the Boehm GC, in order to use a debugger we need to turn off some of the signal
|
||||
handlers that the debugger sets. In order to run the debugger (by default lldb) with ~serenec~
|
||||
|
@ -100,7 +112,6 @@ break point on the ~main~ function (~b main~) then use the following commands on
|
|||
process handle -p yes -s no -n no SIGSEGV
|
||||
#+END_SRC bash
|
||||
|
||||
|
||||
* Cheatsheets
|
||||
- [[https://github.com/muqsitnawaz/modern-cpp-cheatsheet][Modern C++ Cheatsheet]]
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@ function build_toolchain() { ## Build LLVM and the toolchain
|
|||
mkdir -p "$LLVM_BUILD_DIR.$version"
|
||||
mkdir -p "$LLVM_INSTALL_DIR"
|
||||
|
||||
# TODO: Check for ccache
|
||||
# TODO: Check for LLD and Clang
|
||||
_push "$LLVM_BUILD_DIR.$version"
|
||||
cmake -G Ninja \
|
||||
-DCMAKE_INSTALL_PREFIX="$LLVM_INSTALL_DIR" \
|
||||
|
|
Loading…
Reference in New Issue