Skip to content

Commit

Permalink
Make EffectiveSan compatible with older CPUs.
Browse files Browse the repository at this point in the history
Also bump version to 0.1.1
  • Loading branch information
GJDuck committed Jan 17, 2019
1 parent 65dde63 commit 0c2a84a
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 60 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1-alpha
0.1.1-alpha
54 changes: 0 additions & 54 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions llvm-4.0.1.src/tools/clang/lib/Basic/Targets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 0c2a84a

Please sign in to comment.