Skip to content

Commit 66cdc7f

Browse files
committed
custom-libcxx
1 parent 28adbbb commit 66cdc7f

File tree

4 files changed

+38
-28
lines changed

4 files changed

+38
-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: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,28 @@
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+
elif [ "$ENABLE_SANITIZER" = "asan" ]; then
26+
cmake -G Ninja -S runtimes -B build-libcxx -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" -DCMAKE_INSTALL_PREFIX="/build_dir/libcxx" -DLLVM_USE_SANITIZER="Address";
27+
elif [ "$ENABLE_SANITIZER" = "tsan" ]; 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="Thread";
29+
elif [ "$ENABLE_SANITIZER" = "ubsan" ]; then
30+
cmake -G Ninja -S runtimes -B build-libcxx -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" -DCMAKE_INSTALL_PREFIX="/build_dir/libcxx" -DLLVM_USE_SANITIZER="Undefined";
31+
else
32+
echo unexpected sanitizer: $SANITIZER;
33+
exit 1
34+
fi
35+
ninja -C build-libcxx install-cxx install-cxxabi install-unwind
36+
CXXFLAGS="-std=c++23 -nostdinc++ -isystem /build_dir/libcxx/include/c++/v1"
37+
LDFLAGS="-L/build_dir/libcxx/lib -lc++ -rpath /build_dir/libcxx/lib"
3738
elif [ "$STDLIB" == "libstdcxx" ]; then
3839
CXXFLAGS="-std=c++23"
3940
LDFLAGS=""
@@ -42,16 +43,19 @@ else
4243
exit 1
4344
fi
4445

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
46+
if [ "$ENABLE_SANITIZER" = "none" ]; then
47+
echo "Not using a sanitizer"
48+
elif [ "$ENABLE_SANITIZER" = "asan" ]; then
49+
ADDITIONAL_FLAGS="${ADDITIONAL_FLAGS} -DLLVM_USE_SANITIZER=Address"
50+
elif [ "$ENABLE_SANITIZER" = "tsan" ]; then
51+
ADDITIONAL_FLAGS="${ADDITIONAL_FLAGS} -DLLVM_USE_SANITIZER=Thread"
5452
export TSAN_OPTIONS="report_bugs=0"
53+
elif [ "$ENABLE_SANITIZER" = "ubsan" ]; then
54+
ADDITIONAL_FLAGS="${ADDITIONAL_FLAGS} -DLLVM_ENABLE_RTTI=ON"
55+
ADDITIONAL_FLAGS="${ADDITIONAL_FLAGS} -DLLVM_USE_SANITIZER=Undefined"
56+
else
57+
echo unexpected sanitizer: $SANITIZER;
58+
exit 1
5559
fi
5660

5761
if [ ! -z "${CXXFLAGS}" ]; then
@@ -62,6 +66,7 @@ if [ ! -z "${LDFLAGS}" ]; then
6266
export LDFLAGS
6367
fi
6468

69+
6570
cmake -G Ninja -S llvm -B build -DCMAKE_BUILD_TYPE=Release \
6671
-DLLVM_ENABLE_PROJECTS="mlir" \
6772
-DLLVM_TARGETS_TO_BUILD=Native \

llvm-project

Submodule llvm-project updated 415 files

0 commit comments

Comments
 (0)