Skip to content

Commit

Permalink
icc: fix for intel compiler icc
Browse files Browse the repository at this point in the history
all tests pass
  • Loading branch information
Reini Urban committed Jun 28, 2013
1 parent 8735be1 commit 8e3a0eb
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
13 changes: 12 additions & 1 deletion config.mak
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# create config.inc and core/config.h
PREFIX = /usr/local
CC ?= gcc
CFLAGS = -Wall -Werror -fno-strict-aliasing -Wno-switch -Wno-return-type -Wno-unused-label -D_GNU_SOURCE
CFLAGS = -Wall -Werror -fno-strict-aliasing -Wno-return-type -D_GNU_SOURCE
INCS = -Icore
LIBPTH = -Llib
RPATH = -Wl,-rpath=$(shell pwd)/lib
Expand Down Expand Up @@ -111,7 +111,16 @@ ifneq (${JIT},1)
endif
ifneq ($(shell ./tools/config.sh "${CC}" clang),0)
CLANG = 1
CFLAGS += -Wno-switch -Wno-unused-label
CFLAGS += -Wno-unused-value
else
ifneq ($(shell ./tools/config.sh "${CC}" icc),0)
ICC = 1
else
ifneq ($(shell ./tools/config.sh "${CC}" gcc),0)
CFLAGS += -Wno-switch -Wno-unused-label
endif
endif
endif
ifeq (${DEBUG},0)
DEBUGFLAGS += -fno-stack-protector
Expand Down Expand Up @@ -210,6 +219,8 @@ config.inc.echo:
@${ECHO} "WIN32 = ${WIN32}"
@${ECHO} "CYGWIN = ${CYGWIN}"
@${ECHO} "CLANG = ${CLANG}"
@${ECHO} "ICC = ${ICC}"
@${ECHO} "GCC = ${GCC}"
@${ECHO} "JIT = ${JIT}"
@test -n ${JIT_TARGET} && ${ECHO} "JIT_${JIT_TARGET} = 1"
@${ECHO} "DEBUG = ${DEBUG}"
Expand Down
2 changes: 1 addition & 1 deletion core/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ PN potion_source(Potion *P, u8 p, PN a, PN b, PN c) {
int size = potion_ast_sizes[p];
// TODO: potion_ast_sizes[p] * sizeof(PN) (then fix gc_copy)
vPN(Source) t = PN_ALLOC_N(PN_TSOURCE, struct PNSource, 0 * sizeof(PN));
t->part = p;
t->part = (enum PN_AST)p;
#if 1
switch (size) {
case 3: t->a[2] = PN_SRC(c);
Expand Down
10 changes: 5 additions & 5 deletions front/potion.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static void potion_cmd_version(Potion *P) {
potion_p(P, c)

static PN potion_cmd_exec(Potion *P, PN buf, char *filename, char *compile) {
exec_mode_t exec = P->flags & ((1<<EXEC_BITS)-1);
exec_mode_t exec = (exec_mode_t)(P->flags & ((1<<EXEC_BITS)-1));
PN code = potion_source_load(P, PN_NIL, buf);
if (PN_IS_PROTO(code)) {
DBG_v("\n-- loaded --\n");
Expand Down Expand Up @@ -114,7 +114,7 @@ static void potion_cmd_compile(Potion *P, char *filename, char *compile) {
PN buf;
int fd = -1;
struct stat stats;
exec_mode_t exec = P->flags & ((1<<EXEC_BITS)-1);
exec_mode_t exec = (exec_mode_t)(P->flags & ((1<<EXEC_BITS)-1));

if (stat(filename, &stats) == -1) {
fprintf(stderr, "** %s does not exist.", filename);
Expand Down Expand Up @@ -282,7 +282,7 @@ int main(int argc, char *argv[]) {
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "--")) break;
if (!strcmp(argv[i], "-I") || !strcmp(argv[i], "--inspect")) {
P->flags |= DEBUG_INSPECT; continue; }
P->flags = (Potion_Flags)(int)(P->flags | DEBUG_INSPECT); continue; }
if (!strcmp(argv[i], "-L")) {
char *extra_path = &argv[i][2]; // todo: flexible
if (*extra_path)
Expand All @@ -298,7 +298,7 @@ int main(int argc, char *argv[]) {
continue;
}
if (!strcmp(argv[i], "-V") || !strcmp(argv[i], "--verbose")) {
P->flags |= DEBUG_VERBOSE; continue; }
P->flags = (Potion_Flags)(int)(P->flags | DEBUG_VERBOSE); continue; }
if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) {
potion_cmd_version(P); goto END; }
if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
Expand Down Expand Up @@ -362,7 +362,7 @@ int main(int argc, char *argv[]) {
}
fprintf(stderr, "** Unrecognized option: %s\n", argv[i]);
}
P->flags += exec;
P->flags = (Potion_Flags)(int)(P->flags + exec);

if (!interactive) {
if (buf != PN_NIL) {
Expand Down
22 changes: 19 additions & 3 deletions tools/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CCEX="$CC $AC -o $AOUT"
LANG=C

CCv=`$CC -v 2>&1`
CLANG=`echo "$CCv" | sed "/clang/!d"`
ICC=`echo "$CCv" | sed "/icc version/!d"`
TARGET=`echo "$CCv" | sed -e "/Target:/b" -e "/--target=/b" -e d | sed "s/.* --target=//; s/Target: //; s/ .*//" | head -1`
MINGW_GCC=`echo "$TARGET" | sed "/mingw/!d"`
if [ "$MINGW_GCC" = "" ]; then MINGW=0
Expand All @@ -23,6 +23,14 @@ JIT_I686=`echo "$TARGET" | sed "/i686/!d"`
JIT_AMD64=`echo "$TARGET" | sed "/amd64/!d"`
JIT_ARM=`echo "$TARGET" | sed "/arm/!d"`
JIT_X86_64=`echo "$TARGET" | sed "/x86_64/!d"`
if [ "$ICC" != "" ]; then
TARGET=`$CC -V 2>&1 | sed -e "/running on/b" -e "s,.*running on,," -e d`
JIT_PPC=`echo "$TARGET" | sed "/powerpc/!d"`
JIT_X86=`echo "$TARGET" | sed "/IA-32/!d"`
JIT_AMD64=`echo "$TARGET" | sed "/Intel(R) 64/!d"`
JIT_X86_64=`echo "$TARGET" | sed "/Intel(R) 64/!d"`
JIT_ARM=`echo "$TARGET" | sed "/arm/!d"`
fi
CROSS=0

if [ $MINGW -eq 0 ]; then
Expand Down Expand Up @@ -65,8 +73,16 @@ elif [ "$2" = "cygwin" ]; then
if [ $CYGWIN -eq 0 ]; then echo "0"
else echo "1"; fi
elif [ "$2" = "clang" ]; then
CLANG=`echo "$CCv" | sed "/clang/!d"`
if [ "$CLANG" = "" ]; then echo "0"
else echo "1"; fi
elif [ "$2" = "gcc" ]; then
GCC=`echo "$CCv" | sed "/^gcc version/!d"`
if [ "$GCC" = "" ]; then echo "0"
else echo "1"; fi
elif [ "$2" = "icc" ]; then
if [ "$ICC" = "" ]; then echo "0"
else echo "1"; fi
elif [ "$2" = "bsd" ]; then
if [ "$BSD" = "" ]; then echo "0"
else echo "1"; fi
Expand Down Expand Up @@ -124,8 +140,8 @@ else
PAGESIZE=`echo "#include <stdio.h>#include <unistd.h>int main() { printf(\\"%d\\", (int)sysconf(_SC_PAGE_SIZE)); return 0; }" > $AC && $CCEX && $AOUT && rm -f $AOUT`
STACKDIR=`echo "#include <stdlib.h>#include <stdio.h>void a2(int *a, int b, int c) { printf(\\"%d\\", (int)((&b - a) / abs(&b - a))); }void a1(int a) { a2(&a,a+4,a+2); }int main() { a1(9); return 0; }" > $AC && $CCEX && $AOUT && rm -f $AOUT`
ARGDIR=`echo "#include <stdio.h>void a2(int *a, int b, int c) { printf(\\"%d\\", (int)(&c - &b)); }void a1(int a) { a2(&a,a+4,a+2); }int main() { a1(9); return 0; }" > $AC && $CCEX && $AOUT && rm -f $AOUT`
HAVE_ASAN=`(echo "#include <stdio.h>__attribute__((no_address_safety_analysis)) int main() { puts(\\"1\\"); return 0; }" > $AC && $CCEX -Werror $3 2>&1; rm -f $AOUT >/dev/null) | sed "/ignored/!d"`
if [ "$HAVE_ASAN" != "" ]; then HAVE_ASAN=0; else HAVE_ASAN=1; fi
HAVE_ASAN=`echo "#include <stdio.h>__attribute__((no_address_safety_analysis)) int main() { puts(\\"1\\"); return 0; }" > $AC && $CCEX -Werror $3 2>&1 && $AOUT && rm -f $AOUT`
if [ "$HAVE_ASAN" = "1" ]; then HAVE_ASAN=1; else HAVE_ASAN=0; fi
else
# hard coded win32 values
if [ "$JIT_X86_64" != "" -o "$JIT_AMD64" != "" ]; then
Expand Down

0 comments on commit 8e3a0eb

Please sign in to comment.