Skip to content

Commit 2283607

Browse files
committed
add nix flakes & readme for it
1 parent a5d3522 commit 2283607

File tree

5 files changed

+179
-43
lines changed

5 files changed

+179
-43
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,6 @@ pythonenv*
7878
/clang/utils/analyzer/projects/*/RefScanBuildResults
7979
# automodapi puts generated documentation files here.
8080
/lldb/docs/python_api/
81+
82+
.direnv
83+
.envrc

README-llvm.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# The LLVM Compiler Infrastructure
2+
3+
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/llvm/llvm-project/badge)](https://securityscorecards.dev/viewer/?uri=github.com/llvm/llvm-project)
4+
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8273/badge)](https://www.bestpractices.dev/projects/8273)
5+
[![libc++](https://github.com/llvm/llvm-project/actions/workflows/libcxx-build-and-test.yaml/badge.svg?branch=main&event=schedule)](https://github.com/llvm/llvm-project/actions/workflows/libcxx-build-and-test.yaml?query=event%3Aschedule)
6+
7+
Welcome to the LLVM project!
8+
9+
This repository contains the source code for LLVM, a toolkit for the
10+
construction of highly optimized compilers, optimizers, and run-time
11+
environments.
12+
13+
The LLVM project has multiple components. The core of the project is
14+
itself called "LLVM". This contains all of the tools, libraries, and header
15+
files needed to process intermediate representations and convert them into
16+
object files. Tools include an assembler, disassembler, bitcode analyzer, and
17+
bitcode optimizer.
18+
19+
C-like languages use the [Clang](https://clang.llvm.org/) frontend. This
20+
component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode
21+
-- and from there into object files, using LLVM.
22+
23+
Other components include:
24+
the [libc++ C++ standard library](https://libcxx.llvm.org),
25+
the [LLD linker](https://lld.llvm.org), and more.
26+
27+
## Getting the Source Code and Building LLVM
28+
29+
Consult the
30+
[Getting Started with LLVM](https://llvm.org/docs/GettingStarted.html#getting-the-source-code-and-building-llvm)
31+
page for information on building and running LLVM.
32+
33+
For information on how to contribute to the LLVM project, please take a look at
34+
the [Contributing to LLVM](https://llvm.org/docs/Contributing.html) guide.
35+
36+
## Getting in touch
37+
38+
Join the [LLVM Discourse forums](https://discourse.llvm.org/), [Discord
39+
chat](https://discord.gg/xS7Z362),
40+
[LLVM Office Hours](https://llvm.org/docs/GettingInvolved.html#office-hours) or
41+
[Regular sync-ups](https://llvm.org/docs/GettingInvolved.html#online-sync-ups).
42+
43+
The LLVM project has adopted a [code of conduct](https://llvm.org/docs/CodeOfConduct.html) for
44+
participants to all modes of communication within the project.

README.md

Lines changed: 20 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,21 @@
1-
# The LLVM Compiler Infrastructure
1+
# LLVM fork to work on RISC-V V-ext vectorizing issues
2+
3+
## Repository layout
4+
TODO
5+
6+
## Getting dev shell
7+
* Install `nix`:
8+
```
9+
$ sh <(curl --proto '=https' --tlsv1.2 -L https://nixos.org/nix/install) --no-daemon
10+
```
11+
* Enable flakes experimental feature:
12+
```
13+
mkdir ~/.config/nix/
14+
echo "experimental-features = nix-command flakes" > ~/.config/nix/nix.conf
15+
```
16+
* Enter to nix shell
17+
```
18+
nix develop
19+
```
20+
* (Optional) Setup [direnv](https://github.com/direnv/direnv) to enter into nix shell automatically
221

3-
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/llvm/llvm-project/badge)](https://securityscorecards.dev/viewer/?uri=github.com/llvm/llvm-project)
4-
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8273/badge)](https://www.bestpractices.dev/projects/8273)
5-
[![libc++](https://github.com/llvm/llvm-project/actions/workflows/libcxx-build-and-test.yaml/badge.svg?branch=main&event=schedule)](https://github.com/llvm/llvm-project/actions/workflows/libcxx-build-and-test.yaml?query=event%3Aschedule)
6-
7-
Welcome to the LLVM project!
8-
9-
This repository contains the source code for LLVM, a toolkit for the
10-
construction of highly optimized compilers, optimizers, and run-time
11-
environments.
12-
13-
The LLVM project has multiple components. The core of the project is
14-
itself called "LLVM". This contains all of the tools, libraries, and header
15-
files needed to process intermediate representations and convert them into
16-
object files. Tools include an assembler, disassembler, bitcode analyzer, and
17-
bitcode optimizer.
18-
19-
C-like languages use the [Clang](https://clang.llvm.org/) frontend. This
20-
component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode
21-
-- and from there into object files, using LLVM.
22-
23-
Other components include:
24-
the [libc++ C++ standard library](https://libcxx.llvm.org),
25-
the [LLD linker](https://lld.llvm.org), and more.
26-
27-
## Getting the Source Code and Building LLVM
28-
29-
Consult the
30-
[Getting Started with LLVM](https://llvm.org/docs/GettingStarted.html#getting-the-source-code-and-building-llvm)
31-
page for information on building and running LLVM.
32-
33-
For information on how to contribute to the LLVM project, please take a look at
34-
the [Contributing to LLVM](https://llvm.org/docs/Contributing.html) guide.
35-
36-
## Getting in touch
37-
38-
Join the [LLVM Discourse forums](https://discourse.llvm.org/), [Discord
39-
chat](https://discord.gg/xS7Z362),
40-
[LLVM Office Hours](https://llvm.org/docs/GettingInvolved.html#office-hours) or
41-
[Regular sync-ups](https://llvm.org/docs/GettingInvolved.html#online-sync-ups).
42-
43-
The LLVM project has adopted a [code of conduct](https://llvm.org/docs/CodeOfConduct.html) for
44-
participants to all modes of communication within the project.

flake.lock

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
description = "Flake to develop llvm toolchain";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs = { self, nixpkgs, flake-utils }:
10+
flake-utils.lib.eachDefaultSystem ( system:
11+
let
12+
pkgs = import nixpkgs { inherit system; };
13+
gccForLibs = pkgs.stdenv.cc.cc;
14+
in {
15+
devShell = pkgs.mkShell {
16+
name = "llvm-env";
17+
18+
buildInputs = with pkgs; [
19+
python3
20+
ninja
21+
cmake
22+
llvmPackages_latest.llvm
23+
verilator
24+
];
25+
26+
# where to find libgcc
27+
NIX_LDFLAGS="-L${gccForLibs}/lib/gcc/${system}/${gccForLibs.version}";
28+
# teach clang about C startup file locations
29+
CFLAGS="-B${gccForLibs}/lib/gcc/${system}/${gccForLibs.version} -B ${pkgs.stdenv.cc.libc}/lib";
30+
31+
cmakeFlags = [
32+
"-DGCC_INSTALL_PREFIX=${pkgs.gcc}"
33+
"-DC_INCLUDE_DIRS=${pkgs.stdenv.cc.libc.dev}/include"
34+
"-GNinja"
35+
# Debug for debug builds
36+
"-DCMAKE_BUILD_TYPE=Release"
37+
# inst will be our installation prefix
38+
"-DCMAKE_INSTALL_PREFIX=../inst"
39+
"-DLLVM_INSTALL_TOOLCHAIN_ONLY=ON"
40+
# change this to enable the projects you need
41+
"-DLLVM_ENABLE_PROJECTS=clang"
42+
# enable libcxx* to come into play at runtimes
43+
"-DLLVM_ENABLE_RUNTIMES=libcxx;libcxxabi"
44+
# this makes llvm only to produce code for the current platform, this saves CPU time, change it to what you need
45+
"-DLLVM_TARGETS_TO_BUILD=host"
46+
];
47+
};
48+
49+
});
50+
}
51+

0 commit comments

Comments
 (0)