-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ASAN-enabled build #35364
Fix ASAN-enabled build #35364
Conversation
By the way, it'd be nice if ASAN build (and some core tests with it?) is run via buildbot. It may find a bug like #35338 (comment) |
I don't get the link error, are you sure your LLVM versions are matched up? FWIW, I just tried using a pretty hacky script of mine that uses Julia's build system to get an identical LLVM toolchain (this is from before BB, so maybe that step is redundant now, but It Works so I haven't updated it yet): #!/bin/bash -uxe
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ROOT="$DIR/.."
rm -rf $ROOT/deps/srccache/*/
## toolchain
BUILD="$DIR/sanitize_toolchain"
if [[ ! -d "${BUILD}" ]]; then
FORCE=1 make -C $ROOT configure O=$BUILD
cat <<EOD | sed 's/^ *//' >$BUILD/Make.user
USE_BINARYBUILDER_LLVM=0
# autotools doesn't build sanitizers
override LLVM_USE_CMAKE=1
# LLVM bug #23649
USE_LLVM_SHLIB=0
BUILD_LLVM_CLANG=1
CMAKE_GENERATOR=Ninja
EOD
make -C $BUILD/deps install-llvm "$@"
mv $BUILD/usr/bin/* $BUILD/usr/tools
fi
## julia
BUILD="$DIR/sanitize"
rm -rf $BUILD
FORCE=1 make -C $ROOT configure O=$BUILD
cat <<'EOD' | sed 's/^ *//' >$BUILD/Make.user
TOOLCHAIN=$(BUILDROOT)/../sanitize_toolchain/usr/tools
# use our new toolchain
USECLANG=1
override CC=$(TOOLCHAIN)/clang
override CXX=$(TOOLCHAIN)/clang++
export ASAN_SYMBOLIZER_PATH=$(TOOLCHAIN)/llvm-symbolizer
USE_BINARYBUILDER_LLVM=0
# enable ASAN
override LLVM_SANITIZE=1
override SANITIZE=1
# autotools doesn't have a self-sanitize mode
override LLVM_USE_CMAKE=1
# make the GC use regular malloc/frees, which are hooked by ASAN
override WITH_GC_DEBUG_ENV=1
# default to a debug build for better line number reporting
override JULIA_BUILD_MODE=debug
# enable LLVM assertions (which also enables pass debug output)
override LLVM_ASSERTIONS=1
# make ASAN consume less memory
export ASAN_OPTIONS=detect_leaks=0:fast_unwind_on_malloc=0:allow_user_segv_handler=1:malloc_context_size=2
CMAKE_GENERATOR=Ninja
JULIA_PRECOMPILE=0
EOD
make -C $BUILD "$@" Script expects to be put in and run from a |
@tkf If you want to update this to drop the -DNDEBUG, I'll merge this and we can figure out the LLVM issue separately. |
|
@maleadt I get
with make -C deps install-llvm
tooldir=$PWD/usr/tools
ASAN_OPTIONS=detect_leaks=0:allow_user_segv_handler=1 PATH="$tooldir:$PATH" \
make USECLANG=1 SANITIZE=1 CXX=$tooldir/clang and root@919704e44cd5:/julia-ndebug# git log -n1 --oneline
922891ccbf (HEAD -> ndebug, origin/master, origin/HEAD) Version `UnicodeData.txt` filename (#35383)
root@919704e44cd5:/julia-ndebug# git diff
diff --git a/src/aotcompile.cpp b/src/aotcompile.cpp
index 15623efe5a..c33010ccb0 100644
--- a/src/aotcompile.cpp
+++ b/src/aotcompile.cpp
@@ -23,6 +23,7 @@
#include <llvm/Transforms/Vectorize.h>
#if defined(JL_ASAN_ENABLED)
#include <llvm/Transforms/Instrumentation.h>
+#include <llvm/Transforms/Instrumentation/AddressSanitizer.h>
#endif
#include <llvm/Transforms/Scalar/GVN.h>
#include <llvm/Transforms/IPO/AlwaysInliner.h>
root@919704e44cd5:/julia-ndebug# cat Make.user
cat: Make.user: No such file or directory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got this as well:
/home/vchuravy/julia/src/aotcompile.cpp:586:13: error: use of undeclared identifier 'createAddressSanitizerFunctionPass'
PM->add(createAddressSanitizerFunctionPass());
^
* Fix ASAN-enabled build * Remove -DNDEBUG
* Fix ASAN-enabled build * Remove -DNDEBUG
I have no idea if it is the right fix (esp.
NDEBUG
) but this is what I needed to do to buildjulia
with ASAN #35341. I'm sending a patch just in case it's an OK fix.With this patch, I can run build
julia
with:ASAN_OPTIONS=detect_leaks=0:allow_user_segv_handler=1 make CC=$PWD/usr/tools/clang CXX=$PWD/usr/tools/clang LLVM_CONFIG=$PWD/usr/tools/llvm-config USECLANG=1 SANITIZE=1
cc @vchuravy @maleadt @Keno
close #35338