Skip to content

Commit 11589e4

Browse files
author
Vitaly Chipounov
committed
Makefile: allow specifying custom -march for clang
Useful to build and use S2E in VirtualBox, which does not support AVX instructions, causing SIGILL. Signed-off-by: Vitaly Chipounov <[email protected]>
1 parent 98e9183 commit 11589e4

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

Makefile

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
#Environment variables:
2+
#
3+
# BUILD_ARCH=corei7, etc...
4+
# Overrides the default clang -march settings.
5+
# Useful to build S2E in VirtualBox or in other VMs that do not support
6+
# some advanced instruction sets.
7+
# Used by STP only for now.
8+
#
9+
#
10+
111
S2ESRC:=$(CURDIR)/../s2e
212
S2EBUILD:=$(CURDIR)
313

qemu/configure

+8
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,14 @@ case "$cpu" in
981981
;;
982982
esac
983983

984+
if [ "x$BUILD_ARCH" != "x" ]; then
985+
CFLAGS="-march=$BUILD_ARCH $CFLAGS"
986+
CXXFLAGS="-march=$BUILD_ARCH $CXXFLAGS"
987+
else
988+
CFLAGS="-march=native $CFLAGS"
989+
CXXFLAGS="-march=native $CXXFLAGS"
990+
fi
991+
984992
if [ "x$address_sanitizer" = "xyes" ]; then
985993
CFLAGS="-fstack-protector-all -fsanitize=address $CFLAGS"
986994
CXXFLAGS="-fstack-protector-all -Wno-mismatched-tags -fsanitize=address $CXXFLAGS"

stp/scripts/Makefile.common

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010

1111
-include $(TOP)/scripts/config.info
1212

13-
# use -march=native if it works correctly (it's broken in GCC on OS X)
14-
ifeq ($(shell $(CXX) -march=native -E - < /dev/null >/dev/null 2>&1 && echo 1),1)
15-
OPTIMIZE_MARCH_NATIVE = -march=native
13+
ifeq ($(BUILD_ARCH),)
14+
OPTIMIZE_MARCH_NATIVE := -march=native
15+
else
16+
OPTIMIZE_MARCH_NATIVE := -march=$(BUILD_ARCH)
1617
endif
1718

1819
# Optimization

0 commit comments

Comments
 (0)