From 0c2a84a3f0b3bef91dae4244f8b79855678f702d Mon Sep 17 00:00:00 2001 From: GJDuck Date: Thu, 17 Jan 2019 11:35:13 +0800 Subject: [PATCH] Make EffectiveSan compatible with older CPUs. Also bump version to 0.1.1 --- VERSION | 2 +- build.sh | 54 ------------------- .../compiler-rt/lib/effective/CMakeLists.txt | 2 +- .../tools/clang/lib/Basic/Targets.cpp | 5 +- 4 files changed, 3 insertions(+), 60 deletions(-) diff --git a/VERSION b/VERSION index c6c794a95..e37ab8ca8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1-alpha +0.1.1-alpha diff --git a/build.sh b/build.sh index bbcc89b95..74497f034 100755 --- a/build.sh +++ b/build.sh @@ -10,7 +10,6 @@ # Copyright (c) 2018 The National University of Singapore. # All rights reserved. -LEGACY=no BUILD_PLUGIN=no VERSION=`cat VERSION` LOWFAT_VERSION=be90b9106a09dde4e9bf9524f002d7db493643eb @@ -37,18 +36,6 @@ build_llvm() ln -fs "$PWD/${RUNTIME_PATH}/lowfat.h" \ "$PWD/$INSTRUMENTATION_PATH/lowfat.h" - if [ ! -f "$PWD/${RUNTIME_PATH}/CMakeLists.txt" ] - then - if [ $LEGACY = no ] - then - ln -fs "$PWD/${RUNTIME_PATH}/CMakeLists.txt.modern" \ - "$PWD/${RUNTIME_PATH}/CMakeLists.txt" - else - ln -fs "$PWD/${RUNTIME_PATH}/CMakeLists.txt.legacy" \ - "$PWD/${RUNTIME_PATH}/CMakeLists.txt" - fi - fi - BUILD_PATH=$1 if [ -e $BUILD_PATH ] then @@ -162,34 +149,6 @@ fi set -e -echo -n -e "${GREEN}$0${OFF}: checking the CPU..." -if grep ' bmi1' /proc/cpuinfo > /dev/null -then - echo -n "[bmi]" -else - echo - echo -e "${GREEN}$0${OFF}: ${YELLOW}warning${OFF}: CPU does not support BMI" - LEGACY=yes -fi -if grep ' bmi2' /proc/cpuinfo > /dev/null -then - echo -n "[bmi2]" -else - echo - echo -e \ - "${GREEN}$0${OFF}: ${YELLOW}warning${OFF}: CPU does not support BMI2" - LEGACY=yes -fi -if grep ' abm' /proc/cpuinfo > /dev/null -then - echo "[lzcnt]" -else - echo - echo -e \ - "${GREEN}$0${OFF}: ${YELLOW}warning${OFF}: CPU does not support LZCNT" - LEGACY=yes -fi - echo -e "${GREEN}$0${OFF}: building the LowFat config builder..." (cd config; CC=$CLANG CXX=$CLANGXX make >/dev/null) @@ -315,16 +274,3 @@ echo -e "${BOLD} \$ $PWD/$RELEASE_NAME/bin/clang++ -fsanitize=effective -O2 echo -e "${BOLD} \$ ./a.out${OFF}" echo -if [ $LEGACY = yes ] -then - echo "------------------------------------------------------------------" - echo -e "${YELLOW}*** LEGACY MODE WARNING ***${OFF}" - echo - echo "EffectiveSan has been compiled in LEGACY mode for older CPUs." - echo "This mode:" - echo " (1) is not officially supported; and" - echo " (2) has some features disabled." - echo - echo "------------------------------------------------------------------" -fi - diff --git a/llvm-4.0.1.src/projects/compiler-rt/lib/effective/CMakeLists.txt b/llvm-4.0.1.src/projects/compiler-rt/lib/effective/CMakeLists.txt index 7f7bbb953..f3181c35c 100644 --- a/llvm-4.0.1.src/projects/compiler-rt/lib/effective/CMakeLists.txt +++ b/llvm-4.0.1.src/projects/compiler-rt/lib/effective/CMakeLists.txt @@ -9,7 +9,7 @@ set(EFFECTIVE_SOURCES include_directories(..) -set(EFFECTIVE_CFLAGS -std=gnu99 -m64 -I. -O2 -msse4.2 -msse4.1 -mcmodel=large -DLOWFAT_LINUX -Wno-gnu-empty-initializer -Wno-gnu-flexible-array-initializer -Wno-zero-length-array) +set(EFFECTIVE_CFLAGS -std=gnu99 -m64 -I. -O2 -msse4.2 -msse4.1 -mcmodel=large -DLOWFAT_LINUX -Wno-gnu-empty-initializer -Wno-gnu-flexible-array-initializer -Wno-zero-length-array -DLOWFAT_LEGACY=1) add_compiler_rt_runtime(clang_rt.effective STATIC diff --git a/llvm-4.0.1.src/tools/clang/lib/Basic/Targets.cpp b/llvm-4.0.1.src/tools/clang/lib/Basic/Targets.cpp index 7065cba90..55770c270 100644 --- a/llvm-4.0.1.src/tools/clang/lib/Basic/Targets.cpp +++ b/llvm-4.0.1.src/tools/clang/lib/Basic/Targets.cpp @@ -3012,12 +3012,9 @@ bool X86TargetInfo::initFeatureMap( if (getTriple().getArch() == llvm::Triple::x86_64) setFeatureEnabledImpl(Features, "sse2", true); - // EffectiveSan assumes -mbmi -mbmi2 -mlzcnt -msse4.2 -msse4.1 + // EffectiveSan assumes -msse4.2 -msse4.1 setFeatureEnabledImpl(Features, "sse4.1", true); setFeatureEnabledImpl(Features, "sse4.2", true); - setFeatureEnabledImpl(Features, "lzcnt", true); - setFeatureEnabledImpl(Features, "bmi", true); - setFeatureEnabledImpl(Features, "bmi2", true); const CPUKind Kind = getCPUKind(CPU);