diff --git a/.travis.yml b/.travis.yml index 5d07a2775f1..c14a09192a7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ script: - cargo install xargo || echo "Skipping xargo install" - cargo install hyperfine || echo "Skipping hyperfine install" - ./prepare_libcore.sh - - ./build.sh + - ./test.sh env: - RUST_BACKTRACE=1 diff --git a/config.sh b/config.sh new file mode 100644 index 00000000000..a2772d635d1 --- /dev/null +++ b/config.sh @@ -0,0 +1,23 @@ +set -e + +unamestr=`uname` +if [[ "$unamestr" == 'Linux' ]]; then + dylib_ext='so' +elif [[ "$unamestr" == 'Darwin' ]]; then + dylib_ext='dylib' +else + echo "Unsupported os" + exit 1 +fi + +if [[ "$1" == "--release" ]]; then + channel='release' + cargo build --release +else + channel='debug' + cargo build +fi + +export RUSTFLAGS='-Zalways-encode-mir -Cpanic=abort -Zcodegen-backend='$(pwd)'/target/'$channel'/librustc_codegen_cranelift.'$dylib_ext +export XARGO_RUST_SRC=$(pwd)'/target/libcore/src' +RUSTC="rustc $RUSTFLAGS -L crate=target/out --out-dir target/out" diff --git a/flamegraph.sh b/flamegraph.sh new file mode 100755 index 00000000000..4506c77371d --- /dev/null +++ b/flamegraph.sh @@ -0,0 +1,11 @@ +#!/bin/bash +source config.sh + +# These files grow really big (~1.4G) because of the sample frequency +rm perf.data* || true + +# Profile compiling libcore +perf record -F 9000 --call-graph dwarf -- $RUSTC --crate-type lib target/libcore/src/libcore/lib.rs --crate-name core + +# Generate the flamegraph +perf script | ../FlameGraph/stackcollapse-perf.pl | grep cranelift | ../FlameGraph/flamegraph.pl > abc.svg diff --git a/0001-Disable-stdsimd.patch b/patches/0001-Disable-stdsimd.patch similarity index 100% rename from 0001-Disable-stdsimd.patch rename to patches/0001-Disable-stdsimd.patch diff --git a/0002-Disable-u128-and-i128-in-libcore.patch b/patches/0002-Disable-u128-and-i128-in-libcore.patch similarity index 100% rename from 0002-Disable-u128-and-i128-in-libcore.patch rename to patches/0002-Disable-u128-and-i128-in-libcore.patch diff --git a/0003-Disable-inline-assembly-in-spin_loop_hint.patch b/patches/0003-Disable-inline-assembly-in-spin_loop_hint.patch similarity index 100% rename from 0003-Disable-inline-assembly-in-spin_loop_hint.patch rename to patches/0003-Disable-inline-assembly-in-spin_loop_hint.patch diff --git a/0004-Disable-some-more-unsupported-stuff-in-libcore.patch b/patches/0004-Disable-some-more-unsupported-stuff-in-libcore.patch similarity index 100% rename from 0004-Disable-some-more-unsupported-stuff-in-libcore.patch rename to patches/0004-Disable-some-more-unsupported-stuff-in-libcore.patch diff --git a/0005-Disable-compiler_builtins.patch b/patches/0005-Disable-compiler_builtins.patch similarity index 100% rename from 0005-Disable-compiler_builtins.patch rename to patches/0005-Disable-compiler_builtins.patch diff --git a/0006-alloc-Disable-some-unsupported-stuff.patch b/patches/0006-alloc-Disable-some-unsupported-stuff.patch similarity index 100% rename from 0006-alloc-Disable-some-unsupported-stuff.patch rename to patches/0006-alloc-Disable-some-unsupported-stuff.patch diff --git a/0007-Fix-libstd-building.patch b/patches/0007-Fix-libstd-building.patch similarity index 100% rename from 0007-Fix-libstd-building.patch rename to patches/0007-Fix-libstd-building.patch diff --git a/0008-Replace-some-variadic-function-calls-with-unimplemen.patch b/patches/0008-Replace-some-variadic-function-calls-with-unimplemen.patch similarity index 100% rename from 0008-Replace-some-variadic-function-calls-with-unimplemen.patch rename to patches/0008-Replace-some-variadic-function-calls-with-unimplemen.patch diff --git a/prepare_libcore.sh b/prepare_libcore.sh index ce13f80816f..b3a3723e2df 100755 --- a/prepare_libcore.sh +++ b/prepare_libcore.sh @@ -17,7 +17,7 @@ pushd $DST_DIR git init git add . git commit -m "Initial commit" -q -git apply ../../000*.patch +git apply ../../patches/*.patch popd # `alloc_system` has been merged with libstd, which doesn't build yet. diff --git a/src/lib.rs b/src/lib.rs index 69b11b73fa2..f09c962a515 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -173,6 +173,11 @@ impl CodegenBackend for CraneliftCodegenBackend { let mut flags_builder = settings::builder(); flags_builder.enable("is_pic").unwrap(); + flags_builder.set("enable_verifier", if cfg!(debug_assertions) { + "true" + } else { + "false" + }).unwrap(); use rustc::session::config::OptLevel; match tcx.sess.opts.optimize { diff --git a/build.sh b/test.sh similarity index 78% rename from build.sh rename to test.sh index afe32828e4b..7c7f7890843 100755 --- a/build.sh +++ b/test.sh @@ -1,34 +1,11 @@ #!/bin/bash - -set -e - -unamestr=`uname` -if [[ "$unamestr" == 'Linux' ]]; then - dylib_ext='so' -elif [[ "$unamestr" == 'Darwin' ]]; then - dylib_ext='dylib' -else - echo "Unsupported os" - exit 1 -fi +source config.sh build_example_bin() { $RUSTC $2 --crate-name $1 --crate-type bin sh -c ./target/out/$1 || true } -if [[ "$1" == "--release" ]]; then - channel='release' - cargo build --release -else - channel='debug' - cargo build -fi - -export RUSTFLAGS='-Zalways-encode-mir -Cpanic=abort -Zcodegen-backend='$(pwd)'/target/'$channel'/librustc_codegen_cranelift.'$dylib_ext -export XARGO_RUST_SRC=$(pwd)'/target/libcore/src' -RUSTC="rustc $RUSTFLAGS -L crate=target/out --out-dir target/out" - rm -r target/out || true mkdir -p target/out/clif