Skip to content

Commit 7460ba8

Browse files
committed
Enable Sanitized MLIR Builds
1 parent 975b33b commit 7460ba8

File tree

3 files changed

+42
-11
lines changed

3 files changed

+42
-11
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
matrix:
1818
osversion: [ubuntu-22.04]
1919
stdlib: [libc++, stdlibc++]
20+
sanitizer: [null, 'Address', 'Thread', 'Undefined']
2021
steps:
2122
- uses: AutoModality/action-clean@v1
2223
- uses: actions/checkout@v2
@@ -33,18 +34,18 @@ jobs:
3334
id: installdeps
3435
run: |
3536
echo "${{ matrix.stdlib }}"
36-
docker run -v ${{ github.workspace }}:/build_dir -e STDLIB=${{ matrix.stdlib }} --rm nes_clang_build_${{ matrix.osversion }} \
37+
docker run -v ${{ github.workspace }}:/build_dir -e ENABLE_SANITIZER=${{ matrix.sanitizer || '' }} -e STDLIB=${{ matrix.stdlib }} --rm nes_clang_build_${{ matrix.osversion }} \
3738
./build_dir/build_ubuntu-x64.sh
3839
- name: Compress artifacts
3940
id: compressdeps
4041
run: |
41-
7z a nes-clang-18-${{ matrix.osversion }}-${{ matrix.stdlib }}-X64.7z clang -mx9 -aoa
42+
7z a nes-clang-18-${{ matrix.osversion }}-${{ matrix.stdlib }}-X64-${{ matrix.sanitizer || 'None' }}.7z clang -mx9 -aoa
4243
- name: Release
4344
uses: softprops/action-gh-release@v1
4445
id: createrelease
4546
with:
4647
files: |
47-
nes-clang-18-${{ matrix.osversion }}-${{ matrix.stdlib }}-X64.7z
48+
nes-clang-18-${{ matrix.osversion }}-${{ matrix.stdlib }}-X64-${{ matrix.sanitizer || 'None' }}.7z
4849
- name: Clean build artifacts
4950
id: cleanbuildartifacts
5051
if: always()
@@ -68,6 +69,7 @@ jobs:
6869
matrix:
6970
osversion: [ubuntu-22.04]
7071
stdlib: [libc++, stdlibc++]
72+
sanitizer: [null, 'Address', 'Thread', 'Undefined']
7173
steps:
7274
- uses: AutoModality/action-clean@v1
7375
- uses: actions/checkout@v2
@@ -83,18 +85,18 @@ jobs:
8385
- name: Build Clang
8486
id: installdeps
8587
run: |
86-
docker run -v ${{ github.workspace }}:/build_dir -e STDLIB=${{ matrix.stdlib }} --rm nes_clang_build_${{ matrix.osversion }} \
88+
docker run -v ${{ github.workspace }}:/build_dir -e ENABLE_SANITIZER=${{ matrix.sanitizer || '' }} -e STDLIB=${{ matrix.stdlib }} --rm nes_clang_build_${{ matrix.osversion }} \
8789
./build_dir/build_ubuntu-arm64.sh
8890
- name: Compress artifacts
8991
id: compressdeps
9092
run: |
91-
7z a nes-clang-18-${{ matrix.osversion }}-${{ matrix.stdlib }}-arm64.7z clang -mx9 -aoa
93+
7z a nes-clang-18-${{ matrix.osversion }}-${{ matrix.stdlib }}-arm64-${{ matrix.sanitizer || 'None' }}.7z clang -mx9 -aoa
9294
- name: Release
9395
uses: softprops/action-gh-release@v1
9496
id: createrelease
9597
with:
9698
files: |
97-
nes-clang-18-${{ matrix.osversion }}-${{ matrix.stdlib }}-arm64.7z
99+
nes-clang-18-${{ matrix.osversion }}-${{ matrix.stdlib }}-arm64-${{ matrix.sanitizer || 'None' }}.7z
98100
- name: Clean build artifacts
99101
id: cleanbuildartifacts
100102
if: always()

build_ubuntu-arm64.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15-
15+
set -o xtrace
1616
cd /build_dir/llvm-project
1717
rm -rf ./build
1818
mkdir build
1919

20+
local CXX_FLAGS=""
21+
local LINKER_FLAGS=""
22+
local ADDITIONAL_FLAGS=""
2023
if [ "$STDLIB" == "libc++" ]; then
2124
CXX_FLAGS="-stdlib=libc++ -std=c++20"
2225
LINKER_FLAGS="-lc++"
@@ -28,6 +31,18 @@ else
2831
exit 1
2932
fi
3033

34+
if [ ! -z ${ENABLE_SANITIZER+x} ]; then
35+
ADDITIONAL_FLAGS="${ADDITIONAL_FLAGS} -DLLVM_USE_SANITIZER=${ENABLE_SANITIZER}"
36+
fi
37+
38+
if [ ! -z "${CXX_FLAGS}" ]; then
39+
ADDITIONAL_FLAGS="${ADDITIONAL_FLAGS} -DCMAKE_CXX_FLAGS=\"${CXX_FLAGS}\""
40+
fi
41+
42+
if [ ! -z "${LINKER_FLAGS}" ]; then
43+
ADDITIONAL_FLAGS="${ADDITIONAL_FLAGS} -DCMAKE_EXE_LINKER_FLAGS=\"${LINKER_FLAGS}\""
44+
fi
45+
3146
cmake -G Ninja -S llvm -B build -DCMAKE_BUILD_TYPE=Release \
3247
-DLLVM_ENABLE_PROJECTS="mlir" \
3348
-DBOOTSTRAP_LLVM_ENABLE_LTO=ON \
@@ -42,8 +57,7 @@ cmake -G Ninja -S llvm -B build -DCMAKE_BUILD_TYPE=Release \
4257
-DLLVM_BUILD_TOOLS=ON \
4358
-DLLVM_ENABLE_TERMINFO=OFF \
4459
-DLLVM_ENABLE_Z3_SOLVER=OFF \
45-
-DCMAKE_CXX_FLAGS="${CXX_FLAGS}" \
46-
-DCMAKE_EXE_LINKER_FLAGS="${LINKER_FLAGS}"
60+
${ADDITIONAL_FLAGS}
4761

4862
cmake --build build --target install -j$(nproc)
4963

build_ubuntu-x64.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16+
set -o xtrace
1617
cd /build_dir/llvm-project
1718
rm -rf ./build
1819
mkdir build
1920

21+
local CXX_FLAGS=""
22+
local LINKER_FLAGS=""
23+
local ADDITIONAL_FLAGS=""
2024
if [ "$STDLIB" == "libc++" ]; then
2125
CXX_FLAGS="-stdlib=libc++ -std=c++20"
2226
LINKER_FLAGS="-lc++"
@@ -28,6 +32,18 @@ else
2832
exit 1
2933
fi
3034

35+
if [ ! -z ${ENABLE_SANITIZER+x} ]; then
36+
ADDITIONAL_FLAGS="${ADDITIONAL_FLAGS} -DLLVM_USE_SANITIZER=${ENABLE_SANITIZER}"
37+
fi
38+
39+
if [ ! -z "${CXX_FLAGS}" ]; then
40+
ADDITIONAL_FLAGS="${ADDITIONAL_FLAGS} -DCMAKE_CXX_FLAGS=\"${CXX_FLAGS}\""
41+
fi
42+
43+
if [ ! -z "${LINKER_FLAGS}" ]; then
44+
ADDITIONAL_FLAGS="${ADDITIONAL_FLAGS} -DCMAKE_EXE_LINKER_FLAGS=\"${LINKER_FLAGS}\""
45+
fi
46+
3147
cmake -G Ninja -S llvm -B build -DCMAKE_BUILD_TYPE=Release \
3248
-DLLVM_ENABLE_PROJECTS="mlir" \
3349
-DBOOTSTRAP_LLVM_ENABLE_LTO=ON \
@@ -42,8 +58,7 @@ cmake -G Ninja -S llvm -B build -DCMAKE_BUILD_TYPE=Release \
4258
-DLLVM_BUILD_TOOLS=ON \
4359
-DLLVM_ENABLE_TERMINFO=OFF \
4460
-DLLVM_ENABLE_Z3_SOLVER=OFF \
45-
-DCMAKE_CXX_FLAGS="${CXX_FLAGS}" \
46-
-DCMAKE_EXE_LINKER_FLAGS="${LINKER_FLAGS}"
61+
${ADDITIONAL_FLAGS}
4762

4863
cmake --build build --target install -j$(nproc)
4964

0 commit comments

Comments
 (0)