Skip to content

Commit 3632c1c

Browse files
committed
custom-libcxx
1 parent 28adbbb commit 3632c1c

File tree

4 files changed

+44
-28
lines changed

4 files changed

+44
-28
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
matrix:
1414
arch: ['x64', 'arm64']
1515
stdlib: ['libcxx', 'libstdcxx']
16-
sanitizer: ['none', 'address', 'thread', 'undefined']
16+
sanitizer: ['none', 'asan', 'tsan', 'ubsan']
1717
steps:
1818
- uses: AutoModality/action-clean@v1
1919
- uses: actions/checkout@v2
@@ -27,12 +27,17 @@ jobs:
2727
id: compressdeps
2828
run: |
2929
ZSTD_CLEVEL=19 ZSTD_NBTHREADS=0 tar --zstd -cf nes-llvm-20-${{ matrix.arch }}-${{ matrix.sanitizer }}-${{ matrix.stdlib }}.tar.zstd clang
30+
if [ "${{matrix.stdlib}}" == "libcxx" ]; then
31+
ZSTD_CLEVEL=19 ZSTD_NBTHREADS=0 tar --zstd -cf nes-libcxx-20-${{ matrix.arch }}-${{ matrix.sanitizer }}.tar.zstd libcxx
32+
fi
3033
- name: Release
3134
uses: softprops/action-gh-release@v1
3235
id: createrelease
3336
with:
37+
fail_on_unmatched_files: false
3438
files: |
3539
nes-llvm-20-${{ matrix.arch }}-${{ matrix.sanitizer }}-${{ matrix.stdlib }}.tar.zstd
40+
nes-libcxx-20-${{ matrix.arch }}-${{ matrix.sanitizer }}.tar.zstd
3641
- name: Clean build artifacts
3742
id: cleanbuildartifacts
3843
if: always()

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "llvm-project"]
22
path = llvm-project
3-
url = git@github.com:llvm/llvm-project.git
3+
url = https://github.com/llvm/llvm-project

build_llvm.sh

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,34 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
set -o xtrace
16-
cd /build_dir/llvm-project
17-
rm -rf ./build
18-
mkdir build
19-
20-
capitalize() {
21-
if [ -z "$1" ]; then
22-
return 1
23-
fi
24-
25-
local first_char rest
26-
first_char=$(echo "${1:0:1}" | tr '[:lower:]' '[:upper:]')
27-
rest="${1:1}"
28-
echo "${first_char}${rest}"
29-
}
16+
set -e
17+
cd build_dir/llvm-project
3018

3119
CXX_FLAGS=""
3220
LDFLAGS=""
3321
ADDITIONAL_FLAGS=""
3422
if [ "$STDLIB" == "libcxx" ]; then
35-
CXXFLAGS="-stdlib=libc++ -std=c++23"
36-
LDFLAGS="-lc++"
23+
if [ "$ENABLE_SANITIZER" = "none" ]; then
24+
cmake -G Ninja -S runtimes -B build-libcxx -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" -DCMAKE_INSTALL_PREFIX="/build_dir/libcxx"
25+
CXXFLAGS="-std=c++23 -nostdinc++ -isystem /build_dir/libcxx/include/c++/v1"
26+
LDFLAGS="-L/build_dir/libcxx/lib -lc++ -rpath /build_dir/libcxx/lib"
27+
elif [ "$ENABLE_SANITIZER" = "asan" ]; then
28+
cmake -G Ninja -S runtimes -B build-libcxx -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" -DCMAKE_INSTALL_PREFIX="/build_dir/libcxx" -DLLVM_USE_SANITIZER="Address"
29+
CXXFLAGS="-std=c++23 -nostdinc++ -isystem /build_dir/libcxx/include/c++/v1 -fsanitize=address"
30+
LDFLAGS="-L/build_dir/libcxx/lib -lc++ -rpath /build_dir/libcxx/lib -fsanitize=address"
31+
elif [ "$ENABLE_SANITIZER" = "tsan" ]; then
32+
cmake -G Ninja -S runtimes -B build-libcxx -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" -DCMAKE_INSTALL_PREFIX="/build_dir/libcxx" -DLLVM_USE_SANITIZER="Thread"
33+
CXXFLAGS="-std=c++23 -nostdinc++ -isystem /build_dir/libcxx/include/c++/v1 -fsanitize=thread"
34+
LDFLAGS="-L/build_dir/libcxx/lib -lc++ -rpath /build_dir/libcxx/lib -fsanitize=thread"
35+
elif [ "$ENABLE_SANITIZER" = "ubsan" ]; then
36+
cmake -G Ninja -S runtimes -B build-libcxx -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" -DCMAKE_INSTALL_PREFIX="/build_dir/libcxx" -DLLVM_USE_SANITIZER="Undefined"
37+
CXXFLAGS="-std=c++23 -nostdinc++ -isystem /build_dir/libcxx/include/c++/v1 -fsanitize=undefined"
38+
LDFLAGS="-L/build_dir/libcxx/lib -lc++ -rpath /build_dir/libcxx/lib -fsanitize=undefined"
39+
else
40+
echo unexpected sanitizer: $SANITIZER;
41+
exit 1
42+
fi
43+
ninja -C build-libcxx install-cxx install-cxxabi install-unwind
3744
elif [ "$STDLIB" == "libstdcxx" ]; then
3845
CXXFLAGS="-std=c++23"
3946
LDFLAGS=""
@@ -42,16 +49,19 @@ else
4249
exit 1
4350
fi
4451

45-
if [ ! "${ENABLE_SANITIZER}" = "none" ]; then
46-
ADDITIONAL_FLAGS="${ADDITIONAL_FLAGS} -DLLVM_USE_SANITIZER=$(capitalize ${ENABLE_SANITIZER})"
47-
fi
48-
49-
if [ "${ENABLE_SANITIZER}" = "undefined" ]; then
50-
ADDITIONAL_FLAGS="${ADDITIONAL_FLAGS} -DLLVM_ENABLE_RTTI=ON"
51-
fi
52-
53-
if [ "${ENABLE_SANITIZER}" = "thread" ]; then
52+
if [ "$ENABLE_SANITIZER" = "none" ]; then
53+
echo "Not using a sanitizer"
54+
elif [ "$ENABLE_SANITIZER" = "asan" ]; then
55+
ADDITIONAL_FLAGS="${ADDITIONAL_FLAGS} -DLLVM_USE_SANITIZER=Address"
56+
elif [ "$ENABLE_SANITIZER" = "tsan" ]; then
57+
ADDITIONAL_FLAGS="${ADDITIONAL_FLAGS} -DLLVM_USE_SANITIZER=Thread"
5458
export TSAN_OPTIONS="report_bugs=0"
59+
elif [ "$ENABLE_SANITIZER" = "ubsan" ]; then
60+
ADDITIONAL_FLAGS="${ADDITIONAL_FLAGS} -DLLVM_ENABLE_RTTI=ON"
61+
ADDITIONAL_FLAGS="${ADDITIONAL_FLAGS} -DLLVM_USE_SANITIZER=Undefined"
62+
else
63+
echo unexpected sanitizer: $SANITIZER;
64+
exit 1
5565
fi
5666

5767
if [ ! -z "${CXXFLAGS}" ]; then
@@ -62,6 +72,7 @@ if [ ! -z "${LDFLAGS}" ]; then
6272
export LDFLAGS
6373
fi
6474

75+
6576
cmake -G Ninja -S llvm -B build -DCMAKE_BUILD_TYPE=Release \
6677
-DLLVM_ENABLE_PROJECTS="mlir" \
6778
-DLLVM_TARGETS_TO_BUILD=Native \

llvm-project

Submodule llvm-project updated 415 files

0 commit comments

Comments
 (0)