Skip to content

Commit 0bc1dfe

Browse files
authored
Use cmake --build instead of makefiles (#139)
* explicitly specify unix makefiles as the generator, as it may not be the default * use cmake --build and the default generator instead of makefiles * remove the jobs option
1 parent 91e21f0 commit 0bc1dfe

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,31 @@ For other versions, check the git tags of this repository.
2626
* C++ compiler capable of building LLVM, Clang, and LLD from source (GCC 5.1+
2727
or Clang)
2828
* cmake 3.19 or later
29-
* make
29+
* make, ninja, or any other build system supported by cmake
3030
* POSIX system (bash, mkdir, cd)
3131
* Python 3
3232

3333
## Build Instructions
3434

3535
```
36-
./build -j1 <arch>-<os>-<abi> baseline
36+
./build <arch>-<os>-<abi> baseline
3737
```
3838

3939
All parameters are required:
4040

41-
* `-j1`: Replace with your jobs parameter to make.
4241
* `<arch>-<os>-<abi>`: Replace with one of the Supported Triples below, or use
4342
`native` for the `<arch>` value (e.g. `native-linux-gnu`) to use the native
4443
architecture.
4544
* `baseline`: Replace with a `-mcpu` parameter of Zig. `baseline` means
4645
it will target a generic CPU for the target. `native` means it will target
4746
the native CPU. See the Zig documentation for more details.
4847

48+
To use a non-default cmake generator, export the `CMAKE_GENERATOR` environment
49+
variable before calling `build`.
50+
51+
If you aren't using a build system that builds in parallel by default (ie. make),
52+
export `CMAKE_BUILD_PARALLEL_LEVEL` to parallelize the build.
53+
4954
If it succeeds, the output will be in `out/zig-triple-mcpu/`.
5055

5156
### Supported Triples

build

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
set -eu
44

5-
JOBS="$1"
6-
TARGET="$2" # Example: riscv64-linux-gnu
7-
MCPU="$3" # Examples: `baseline`, `native`, `generic+v7a`, or `arm1176jzf_s`
5+
TARGET="$1" # Example: riscv64-linux-gnu
6+
MCPU="$2" # Examples: `baseline`, `native`, `generic+v7a`, or `arm1176jzf_s`
87

98
ROOTDIR="$(pwd)"
109
ZIG_VERSION="0.11.0-dev.78+28288dcbb"
@@ -41,7 +40,7 @@ cmake "$ROOTDIR/llvm" \
4140
-DCLANG_INCLUDE_DOCS=OFF \
4241
-DLLVM_INCLUDE_DOCS=OFF \
4342
-DCMAKE_BUILD_TYPE=Release
44-
make "$JOBS" install
43+
cmake --build . --target install
4544

4645
# Now we build Zig, still with system C/C++ compiler, linking against LLVM,
4746
# Clang, LLD we just built from source.
@@ -52,7 +51,7 @@ cmake "$ROOTDIR/zig" \
5251
-DCMAKE_PREFIX_PATH="$ROOTDIR/out/host" \
5352
-DCMAKE_BUILD_TYPE=Release \
5453
-DZIG_VERSION="$ZIG_VERSION"
55-
make "$JOBS" install
54+
cmake --build . --target install
5655

5756
# Now we have Zig as a cross compiler.
5857
ZIG="$ROOTDIR/out/host/bin/zig"
@@ -73,7 +72,7 @@ cmake "$ROOTDIR/zlib" \
7372
-DCMAKE_RC_COMPILER="$ROOTDIR/out/host/bin/llvm-rc" \
7473
-DCMAKE_AR="$ROOTDIR/out/host/bin/llvm-ar" \
7574
-DCMAKE_RANLIB="$ROOTDIR/out/host/bin/llvm-ranlib"
76-
make "$JOBS" install
75+
cmake --build . --target install
7776

7877
# Same deal for zstd.
7978
# The build system for zstd is whack so I just put all the files here.
@@ -161,13 +160,13 @@ cmake "$ROOTDIR/llvm" \
161160
-DLIBCLANG_BUILD_STATIC=ON \
162161
-DLLVM_DEFAULT_TARGET_TRIPLE="$TARGET"
163162
cd "$ROOTDIR/out/build-llvm-$TARGET-$MCPU/tools/lld"
164-
make "$JOBS" install
163+
cmake --build . --target install
165164
cd "$ROOTDIR/out/build-llvm-$TARGET-$MCPU/tools/clang/lib"
166-
make "$JOBS" install
165+
cmake --build . --target install
167166
cd "$ROOTDIR/out/build-llvm-$TARGET-$MCPU/lib"
168-
make "$JOBS" install
167+
cmake --build . --target install
169168
cd "$ROOTDIR/out/build-llvm-$TARGET-$MCPU"
170-
make "$JOBS" install-llvm-headers install-clang-headers install-LLVMSupport install-LLVMDemangle
169+
cmake --build . --target install-llvm-headers install-clang-headers install-LLVMSupport install-LLVMDemangle
171170

172171
# Finally, we can cross compile Zig itself, with Zig.
173172
cd "$ROOTDIR/zig"

0 commit comments

Comments
 (0)