Just another Lisp https://serene-lang.org
Go to file
Sameer Rahmani 4ec2e35ed8
ci/woodpecker/push/build Pipeline failed Details
ci/woodpecker/push/lint Pipeline was successful Details
builder: Add a dummy linux toolchain file
2023-02-10 19:58:23 +00:00
.woodpecker builder: Fix the bug with CC and an env with no compiler 2023-02-06 18:00:33 +00:00
cmake builder: Add a dummy linux toolchain file 2023-02-10 19:58:23 +00:00
core Fix the license header for 2023 2023-02-06 17:40:45 +00:00
deps deps: Update iwyu to our own patch to fix Triple.h path 2023-02-10 17:39:19 +00:00
devtools Fix the license header for 2023 2023-02-06 17:40:45 +00:00
docs Fix the license header for 2023 2023-02-06 17:40:45 +00:00
libserene Fix the license header for 2023 2023-02-06 17:40:45 +00:00
libserene.v0 Fix the license header for 2023 2023-02-06 17:40:45 +00:00
resources Fix the license header for 2023 2023-02-06 17:40:45 +00:00
scripts deps: Run various LLVM tests as part of the build process 2023-02-10 17:39:57 +00:00
serene-repl Fix the license header for 2023 2023-02-06 17:40:45 +00:00
serene-tblgen Fix the license header for 2023 2023-02-06 17:40:45 +00:00
serenec Fix the license header for 2023 2023-02-06 17:40:45 +00:00
.clang-format Hide the clang-tidy behind a build option 2021-10-17 22:22:49 +01:00
.clang-tidy Add the more resouces about JIT to dev.org 2021-12-29 13:12:36 +00:00
.dockerignore Setup the dockerfiles necessary to build serene in a container 2022-02-08 17:43:29 +00:00
.gitignore Add .tmp to gitignore 2022-07-06 21:33:51 +01:00
.gitmodules builder: Add to new cmake vars to control libcxx usage 2023-02-10 17:42:12 +00:00
.ignore_sanitize Fix the broken bash array to str process in the builder 2022-06-12 20:40:36 +01:00
.pre-commit-config.yaml Add the build-in-devfs command to builder 2022-07-12 00:34:30 +01:00
CMakeLists.txt builder: Add to new cmake vars to control libcxx usage 2023-02-10 17:42:12 +00:00
LICENSE Add include-fixer to pre-commit 2022-06-12 22:34:12 +01:00
README.org Fix the license header for 2023 2023-02-06 17:40:45 +00:00
builder builder: Add a dummy linux toolchain file 2023-02-10 19:58:23 +00:00
dev.org Add the conversation around jit and libasan to dev.org for the future reference 2022-07-22 20:12:58 +01:00

README.org

Serene lang

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:

  git clone git@git.devherose.codes:serene/serene.git
  cd serene
  git submodule init
  git submodule update

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.
  • zstd (Only if you want to use prebuilt dependencies on Linux)

Setup development environment

Before, you have to set up the necessary git hooks as follows:

./builder setup

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:

  # Download prebuilt dependencies instead of building from source (X86_64 only)

  # 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

  # Or build from source
  ./builder deps build toolchain
  ./builder deps build bdwgc

After building or pulling the dependencies, you'll have all of them under ~/.serene/env/. All you need to do is to activate the environment and build Serene itself.

After a pull or build, the builder script will let you know that what environment variables are necessary to activate the dependencies. Also, if you are lazy like me, you can just set the SERENE_AUTO_DEP to true and let the builder script set those for you. E.g.

  export SERENE_AUTO_DEP="true"

Be advised that, setting up the above variable makes it a bit harder to switch to other environment in the same shell that usually is not the case.

Build and installing dependencies (Other platforms)

Currently, 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.

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.

To build the dependencies in your platform, you can use the ./scripts/deps.sh as a reference.

How to build

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.

Check out the builder script for more subcommands and details.

Head's up for devs

While you're working on Serene be mindful of:

  • In DEBUG mode, we dynamically link against libsan since 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:

      LD_PRELOAD=$(clang -print-file-name=libclang_rt.asan-x86_64.so) /path/to/executable

Build the devtools

We have our own version of `mlir-opt` which is `slir-opt` and also we have an LSP server for SLIR too. Both are in the devtools directory and in to build them all you need to do is to use -DSERENE_ENABLE_DEVTOOLS=ON parameter with cmake for example ./builder build -DSERENE_ENABLE_DEVTOOLS=ON will do the job for you.

How to Debug

Since we're using the Boehm GC, to use a debugger, we need to turn off some of the signal handlers that the debugger sets. To run the debugger (by default, lldb) with serenec just use the lldb-run subcommand of the builder script. In the debugger, after setting the break point on the main function (b main) then use the following commands on:

 process handle -p yes -s no -n no SIGPWR
 process handle -p yes -s no -n no SIGXCPU
 process handle -p yes -s no -n no SIGSEGV

Cheatsheets

License

Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>

Serene is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Get Help

If you need help, or you just want to hang out, you can find us at: