-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a build matrix for Ruby with ASAN
It compiles some of Ruby's key dependencies with ASAN enabled, and statically links them. It builds with Clang 18, which is the minimum required for ASAN to work.
- Loading branch information
1 parent
c3908d8
commit ea17618
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
|
||
set -ex; | ||
|
||
RUBY_SRCDIR="$(realpath .)" | ||
ASAN_FLAGS="-fsanitize=address -fPIC -ggdb3" | ||
OPENSSL_VERSION="3.3.0" | ||
LIBYAML_VERSION="0.2.5" | ||
LIBFFI_VERSION="3.4.5" | ||
|
||
mkdir -p third_party_asan/{build,lib} | ||
|
||
cd "$RUBY_SRCDIR/third_party_asan/build" | ||
wget "https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz" | ||
tar xf "openssl-${OPENSSL_VERSION}.tar.gz" | ||
cd "openssl-${OPENSSL_VERSION}" | ||
./Configure CC=clang CFLAGS="$ASAN_FLAGS" no-shared no-tests no-apps | ||
make | ||
cp libcrypto.a libssl.a "$RUBY_SRCDIR/third_party_asan/lib" | ||
|
||
cd "$RUBY_SRCDIR/third_party_asan/build" | ||
wget "http://pyyaml.org/download/libyaml/yaml-${LIBYAML_VERSION}.tar.gz" | ||
tar xf "yaml-${LIBYAML_VERSION}.tar.gz" | ||
cd "yaml-${LIBYAML_VERSION}" | ||
./configure CC=clang CFLAGS="$ASAN_FLAGS" --disable-shared --enable-static | ||
make | ||
cp src/.libs/libyaml.a "$RUBY_SRCDIR/third_party_asan/lib" | ||
|
||
cd "$RUBY_SRCDIR/third_party_asan/build" | ||
wget "https://github.com/libffi/libffi/releases/download/v${LIBFFI_VERSION}/libffi-${LIBFFI_VERSION}.tar.gz" | ||
tar xf "libffi-${LIBFFI_VERSION}.tar.gz" | ||
cd "libffi-${LIBFFI_VERSION}" | ||
./configure CC=clang CFLAGS="$ASAN_FLAGS" --disable-shared --enable-static | ||
make | ||
cp "$(sh ./config.guess)/.libs/libffi.a" "$RUBY_SRCDIR/third_party_asan/lib" |