Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to compile svdlibc on a mac (64 bit)?

Tags:

c

macos

svd

I'm trying to compile svdlibc on a 64 bit mac. Running the make file returns the error message:

main.c:1: error: CPU you selected does not support x86-64 instruction set
main.c:1: error: CPU you selected does not support x86-64 instruction set
make: *** [main.o] Error 1

Which doesn't make much sense.

The make file is:

# Linux or Windows:
CC = gcc -Wall -O4 -march=i486
# CC = icc -w1 -O3 -march=i486

# Macintosh:
ifeq ($(HOSTTYPE),powerpc)
  CC = cc -pipe -O3 -Wall -fno-common -arch ppc
endif

LIBS=-lm
OBJ=svdlib.o svdutil.o las2.o

svd: Makefile main.o libsvd.a
    ${CC} ${CFLAGS} -o svd main.o libsvd.a ${LIBS}
    mv -f $@ ${HOSTTYPE}/$@
    ln -s ${HOSTTYPE}/$@ $@
main.o: Makefile main.c svdlib.h
    ${CC} ${CFLAGS} -c main.c

libsvd.a: ${HOSTTYPE} ${OBJ}
    rm -f $@ ${HOSTTYPE}/$@
    ar cr $@ ${OBJ}
    ranlib $@
mv -f $@ ${HOSTTYPE}/$@
    ln -s ${HOSTTYPE}/$@ $@
svdlib.o: Makefile svdlib.h svdlib.c
    ${CC} ${CFLAGS} -c svdlib.c
svdutil.o: Makefile svdutil.c svdutil.h
    ${CC} ${CFLAGS} -c svdutil.c
las2.o: Makefile las2.c svdlib.h svdutil.h
    ${CC} ${CFLAGS} -c las2.c
clean: 
    rm *.o

$(HOSTTYPE):
    if test ! -d $(HOSTTYPE); \
    then mkdir $(HOSTTYPE); fi

Editing the make file to alter the -march flag lets the compilation proceed but apparently the linking fails with:

ld: lto: could not merge in main.o because Invalid ALLOCA record for 
architecture x86_64

Has anyone done this? Or is there a different svd library that I should use instead? (For large sparse matrices?)

EDIT: porneL seems to have found the problem. Changing the top line in the makefile to:

CC = gcc -Wall -O3 -march=x86-64

compilation work. Haven't tested the results yet, but looks very promising.

like image 496
Rob Lachlan Avatar asked Oct 07 '11 03:10

Rob Lachlan


1 Answers

-O4 causes this for some reason. Use -O3 instead.

like image 131
Kornel Avatar answered Oct 18 '22 05:10

Kornel